diff --git a/Gulpfile.ts b/Gulpfile.ts index 054e99c8003..bf5a074ef06 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -242,13 +242,14 @@ function needsUpdate(source: string | string[], dest: string | string[]): boolea return true; } +// Doing tsconfig inheritance manually. https://github.com/ivogabe/gulp-typescript/issues/459 +const tsconfigBase = JSON.parse(fs.readFileSync("src/tsconfig-base.json", "utf-8")).compilerOptions; + function getCompilerSettings(base: tsc.Settings, useBuiltCompiler?: boolean): tsc.Settings { const copy: tsc.Settings = {}; - copy.noEmitOnError = true; - copy.noImplicitAny = true; - copy.noImplicitThis = true; - copy.pretty = true; - copy.types = []; + for (const key in tsconfigBase) { + copy[key] = tsconfigBase[key]; + } for (const key in base) { copy[key] = base[key]; } @@ -256,9 +257,6 @@ function getCompilerSettings(base: tsc.Settings, useBuiltCompiler?: boolean): ts if (copy.removeComments === undefined) copy.removeComments = true; copy.newLine = "lf"; } - else { - copy.preserveConstEnums = true; - } if (useBuiltCompiler === true) { copy.typescript = require("./built/local/typescript.js"); } @@ -330,6 +328,7 @@ const builtGeneratedDiagnosticMessagesJSON = path.join(builtLocalDirectory, "dia // processDiagnosticMessages script gulp.task(processDiagnosticMessagesJs, false, [], () => { const settings: tsc.Settings = getCompilerSettings({ + target: "es5", declaration: false, removeComments: true, noResolve: false, @@ -471,7 +470,10 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => { js.pipe(prependCopyright()) .pipe(sourcemaps.write(".")) .pipe(gulp.dest(".")), - dts.pipe(prependCopyright()) + dts.pipe(prependCopyright(/*outputCopyright*/true)) + .pipe(insert.transform((content) => { + return content + "\r\nexport = ts;\r\nexport as namespace ts;"; + })) .pipe(gulp.dest(".")) ]); }); diff --git a/Jakefile.js b/Jakefile.js index 89d068021e7..47b677b18f4 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -153,6 +153,7 @@ var servicesSources = [ "signatureHelp.ts", "symbolDisplay.ts", "transpile.ts", + // Formatting "formatting/formatting.ts", "formatting/formattingContext.ts", "formatting/formattingRequestKind.ts", @@ -168,28 +169,45 @@ var servicesSources = [ "formatting/rulesMap.ts", "formatting/rulesProvider.ts", "formatting/smartIndenter.ts", - "formatting/tokenRange.ts" + "formatting/tokenRange.ts", + // CodeFixes + "codeFixProvider.ts", + "codefixes/fixes.ts", + "codefixes/fixExtendsInterfaceBecomesImplements.ts", + "codefixes/fixClassIncorrectlyImplementsInterface.ts", + "codefixes/fixClassDoesntImplementInheritedAbstractMember.ts", + "codefixes/fixClassSuperMustPrecedeThisAccess.ts", + "codefixes/fixConstructorForDerivedNeedSuperCall.ts", + "codefixes/helpers.ts", + "codefixes/importFixes.ts", + "codefixes/unusedIdentifierFixes.ts" ].map(function (f) { return path.join(servicesDirectory, f); })); -var serverCoreSources = [ - "types.d.ts", - "shared.ts", - "utilities.ts", - "scriptVersionCache.ts", - "typingsCache.ts", - "scriptInfo.ts", +var baseServerCoreSources = [ + "builder.ts", + "editorServices.ts", "lsHost.ts", "project.ts", - "editorServices.ts", "protocol.ts", + "scriptInfo.ts", + "scriptVersionCache.ts", "session.ts", - "server.ts" + "shared.ts", + "types.ts", + "typingsCache.ts", + "utilities.ts", ].map(function (f) { return path.join(serverDirectory, f); }); +var serverCoreSources = [ + "server.ts" +].map(function (f) { + return path.join(serverDirectory, f); +}).concat(baseServerCoreSources); + var cancellationTokenSources = [ "cancellationToken.ts" ].map(function (f) { @@ -197,7 +215,7 @@ var cancellationTokenSources = [ }); var typingsInstallerSources = [ - "../types.d.ts", + "../types.ts", "../shared.ts", "typingsInstaller.ts", "nodeTypingsInstaller.ts" @@ -206,20 +224,7 @@ var typingsInstallerSources = [ }); var serverSources = serverCoreSources.concat(servicesSources); - -var languageServiceLibrarySources = [ - "protocol.ts", - "utilities.ts", - "scriptVersionCache.ts", - "scriptInfo.ts", - "lsHost.ts", - "project.ts", - "editorServices.ts", - "session.ts", - -].map(function (f) { - return path.join(serverDirectory, f); -}).concat(servicesSources); +var languageServiceLibrarySources = baseServerCoreSources.concat(servicesSources); var harnessCoreSources = [ "harness.ts", @@ -717,7 +722,18 @@ compileFile( [builtLocalDirectory, copyright, builtLocalCompiler].concat(languageServiceLibrarySources).concat(libraryTargets), /*prefixes*/[copyright], /*useBuiltCompiler*/ true, - { noOutFile: false, generateDeclarations: true }); + { noOutFile: false, generateDeclarations: true, stripInternal: true }, + /*callback*/ function () { + prependFile(copyright, tsserverLibraryDefinitionFile); + + // Appending exports at the end of the server library + var tsserverLibraryDefinitionFileContents = + fs.readFileSync(tsserverLibraryDefinitionFile).toString() + + "\r\nexport = ts;" + + "\r\nexport as namespace ts;"; + + fs.writeFileSync(tsserverLibraryDefinitionFile, tsserverLibraryDefinitionFileContents); + }); // Local target to build the language service server library desc("Builds language service server library"); @@ -1181,7 +1197,6 @@ task("update-sublime", ["local", serverFile], function () { var tslintRuleDir = "scripts/tslint"; var tslintRules = [ "nextLineRule", - "preferConstRule", "booleanTriviaRule", "typeOperatorSpacingRule", "noInOperatorRule", diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 5b1f3d7c393..6a4e8ec5216 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -1191,8 +1191,9 @@ interface Array { /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. */ - splice(start: number): T[]; + splice(start: number, deleteCount?: number): T[]; /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index 4d48fed85ed..2ce9151e289 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -1191,8 +1191,9 @@ interface Array { /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. */ - splice(start: number): T[]; + splice(start: number, deleteCount?: number): T[]; /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 9530bf7bfbc..1c5224c0cc8 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -1191,8 +1191,9 @@ interface Array { /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. */ - splice(start: number): T[]; + splice(start: number, deleteCount?: number): T[]; /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index f3737c76c46..d6c0246af34 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -1722,12 +1722,14 @@ declare namespace ts.server.protocol { insertSpaceAfterCommaDelimiter?: boolean; insertSpaceAfterSemicolonInForStatements?: boolean; insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterConstructor?: boolean; insertSpaceAfterKeywordsInControlFlowStatements?: boolean; insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + insertSpaceBeforeFunctionParenthesis?: boolean; placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; } diff --git a/lib/tsc.js b/lib/tsc.js index 840e832f3bf..c1ab6d062f5 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -201,7 +201,7 @@ var ts; ts.toPath = toPath; function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -220,7 +220,7 @@ var ts; ts.zipWith = zipWith; function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -230,7 +230,7 @@ var ts; } ts.every = every; function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -240,7 +240,7 @@ var ts; } ts.find = find; function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -263,7 +263,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -273,7 +273,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -976,6 +976,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -2470,7 +2471,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_be_declared_in_an_ambient_context_1086", message: "An accessor cannot be declared in an ambient context." }, _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", message: "'{0}' modifier cannot appear on a constructor declaration." }, _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_parameter_1090", message: "'{0}' modifier cannot appear on a parameter." }, @@ -2627,6 +2628,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "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_2301", message: "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_2302", message: "Static members cannot reference class type parameters." }, @@ -2856,6 +2858,8 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "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: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2865,6 +2869,7 @@ var ts; Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "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: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -2916,6 +2921,8 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "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_4002", message: "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_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -3084,6 +3091,7 @@ var ts; Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -3097,10 +3105,10 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, @@ -3149,6 +3157,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -3205,22 +3215,25 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); var ts; @@ -3601,7 +3614,7 @@ var ts; if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { var ch = text.charCodeAt(pos); if ((pos + mergeConflictMarkerLength) < text.length) { - for (var i = 0, n = mergeConflictMarkerLength; i < n; i++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -3787,7 +3800,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -4891,7 +4904,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 261) { + while (node && node.kind !== 262) { node = node.parent; } return node; @@ -4899,11 +4912,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 204: - case 232: - case 211: + case 205: + case 233: case 212: case 213: + case 214: return true; } return false; @@ -4968,18 +4981,18 @@ var ts; if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 292 && node._children.length > 0) { + if (node.kind === 293 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 262 && node.kind <= 288; + return node.kind >= 263 && node.kind <= 289; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 278 && node.kind <= 291; + return node.kind >= 279 && node.kind <= 292; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -5073,11 +5086,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 223 && node.parent.kind === 256; + return node.kind === 224 && node.parent.kind === 257; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 230 && + return node && node.kind === 231 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -5086,11 +5099,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 230 && (!node.body); + return node.kind === 231 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 261 || - node.kind === 230 || + return node.kind === 262 || + node.kind === 231 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -5103,9 +5116,9 @@ var ts; return false; } switch (node.parent.kind) { - case 261: + case 262: return ts.isExternalModule(node.parent); - case 231: + case 232: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -5117,22 +5130,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 261: - case 232: - case 256: - case 230: - case 211: + case 262: + case 233: + case 257: + case 231: case 212: case 213: + case 214: case 150: case 149: case 151: case 152: - case 225: + case 226: case 184: case 185: return true; - case 204: + case 205: return parentNode && !isFunctionLike(parentNode); } return false; @@ -5210,7 +5223,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 204) { + if (node.body && node.body.kind === 205) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -5222,26 +5235,26 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 261: + case 262: 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 223: + case 224: case 174: - case 226: - case 197: case 227: + case 197: + case 228: + case 231: case 230: - case 229: - case 260: - case 225: + case 261: + case 226: case 184: case 149: case 151: case 152: - case 228: + case 229: errorNode = node.name; break; case 185: @@ -5265,7 +5278,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 229 && isConst(node); + return node.kind === 230 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -5282,7 +5295,7 @@ var ts; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 207 + return node.kind === 208 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -5354,9 +5367,9 @@ var ts; case 147: case 146: case 144: - case 223: + case 224: return node === parent_1.type; - case 225: + case 226: case 184: case 185: case 150: @@ -5381,27 +5394,41 @@ var ts; return false; } ts.isPartOfTypeNode = isPartOfTypeNode; + function isChildOfNodeWithKind(node, kind) { + while (node) { + if (node.kind === kind) { + return true; + } + node = node.parent; + } + return false; + } + ts.isChildOfNodeWithKind = isChildOfNodeWithKind; + function isPrefixUnaryExpression(node) { + return node.kind === 190; + } + ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 216: + case 217: return visitor(node); - case 232: - case 204: - case 208: + case 233: + case 205: case 209: case 210: case 211: case 212: case 213: - case 217: + case 214: case 218: - case 253: - case 254: case 219: - case 221: - case 256: + case 254: + case 255: + case 220: + case 222: + case 257: return ts.forEachChild(node, traverse); } } @@ -5417,11 +5444,11 @@ var ts; if (operand) { traverse(operand); } - case 229: - case 227: case 230: case 228: - case 226: + case 231: + case 229: + case 227: case 197: return; default: @@ -5455,13 +5482,13 @@ var ts; if (node) { switch (node.kind) { case 174: - case 260: + case 261: case 144: - case 257: + case 258: case 147: case 146: - case 258: - case 223: + case 259: + case 224: return true; } } @@ -5473,7 +5500,7 @@ var ts; } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 226 || node.kind === 197); + return node && (node.kind === 227 || node.kind === 197); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -5484,7 +5511,7 @@ var ts; switch (kind) { case 150: case 184: - case 225: + case 226: case 185: case 149: case 148: @@ -5507,7 +5534,7 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 184: return true; } @@ -5516,20 +5543,32 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 211: case 212: case 213: - case 209: + case 214: case 210: + case 211: return true; - case 219: + case 220: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; + function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + while (true) { + if (beforeUnwrapLabelCallback) { + beforeUnwrapLabelCallback(node); + } + if (node.statement.kind !== 220) { + return node.statement; + } + node = node.statement; + } + } + ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 204 && isFunctionLike(node.parent); + return node && node.kind === 205 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { @@ -5593,9 +5632,9 @@ var ts; if (!includeArrowFunctions) { continue; } - case 225: + case 226: case 184: - case 230: + case 231: case 147: case 146: case 149: @@ -5606,13 +5645,26 @@ var ts; case 153: case 154: case 155: - case 229: - case 261: + case 230: + case 262: return node; } } } ts.getThisContainer = getThisContainer; + function getNewTargetContainer(node) { + var container = getThisContainer(node, false); + if (container) { + switch (container.kind) { + case 150: + case 226: + case 184: + return container; + } + } + return undefined; + } + ts.getNewTargetContainer = getNewTargetContainer; function getSuperContainer(node, stopOnFunctions) { while (true) { node = node.parent; @@ -5623,7 +5675,7 @@ var ts; case 142: node = node.parent; break; - case 225: + case 226: case 184: case 185: if (!stopOnFunctions) { @@ -5672,7 +5724,7 @@ var ts; function getEntityNameFromTypeNode(node) { switch (node.kind) { case 157: - case 272: + case 273: return node.typeName; case 199: return isEntityNameExpression(node.expression) @@ -5706,21 +5758,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 226: + case 227: return true; case 147: - return node.parent.kind === 226; + return node.parent.kind === 227; case 151: case 152: case 149: return node.body !== undefined - && node.parent.kind === 226; + && node.parent.kind === 227; case 144: return node.parent.body !== undefined && (node.parent.kind === 150 || node.parent.kind === 149 || node.parent.kind === 152) - && node.parent.parent.kind === 226; + && node.parent.parent.kind === 227; } return false; } @@ -5736,7 +5788,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 226: + case 227: return ts.forEach(node.members, nodeOrChildIsDecorated); case 149: case 152: @@ -5746,9 +5798,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 248 || - parent.kind === 247 || - parent.kind === 249) { + if (parent.kind === 249 || + parent.kind === 248 || + parent.kind === 250) { return parent.tagName === node; } return false; @@ -5787,10 +5839,11 @@ var ts; case 194: case 12: case 198: - case 246: case 247: + case 248: case 195: case 189: + case 202: return true; case 141: while (node.parent.kind === 141) { @@ -5806,46 +5859,46 @@ var ts; case 98: var parent_3 = node.parent; switch (parent_3.kind) { - case 223: + case 224: case 144: case 147: case 146: - case 260: - case 257: + case 261: + case 258: case 174: return parent_3.initializer === node; - case 207: case 208: case 209: case 210: - case 216: + case 211: case 217: case 218: - case 253: - case 220: - case 218: + case 219: + case 254: + case 221: + case 219: return parent_3.expression === node; - case 211: + case 212: var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 224) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 225) || forStatement.condition === node || forStatement.incrementor === node; - case 212: case 213: + case 214: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 225) || forInStatement.expression === node; case 182: case 200: return node === parent_3.expression; - case 202: + case 203: return node === parent_3.expression; case 142: return node === parent_3.expression; case 145: + case 253: case 252: - case 251: - case 259: + case 260: return true; case 199: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); @@ -5865,7 +5918,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind === 245; + return node.kind === 235 && node.moduleReference.kind === 246; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5874,7 +5927,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind !== 245; + return node.kind === 235 && node.moduleReference.kind !== 246; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -5898,7 +5951,7 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 223) { + if (s.valueDeclaration && s.valueDeclaration.kind === 224) { var declaration = s.valueDeclaration; return declaration.initializer && declaration.initializer.kind === 184; } @@ -5945,35 +5998,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 235) { + if (node.kind === 236) { return node.moduleSpecifier; } - if (node.kind === 234) { + if (node.kind === 235) { var reference = node.moduleReference; - if (reference.kind === 245) { + if (reference.kind === 246) { return reference.expression; } } - if (node.kind === 241) { + if (node.kind === 242) { return node.moduleSpecifier; } - if (node.kind === 230 && node.name.kind === 9) { + if (node.kind === 231 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 234) { + if (node.kind === 235) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 238) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 235 + return node.kind === 236 && node.importClause && !!node.importClause.name; } @@ -5984,8 +6037,8 @@ var ts; case 144: case 149: case 148: + case 259: case 258: - case 257: case 147: case 146: return node.questionToken !== undefined; @@ -5995,9 +6048,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 274 && + return node.kind === 275 && node.parameters.length > 0 && - node.parameters[0].type.kind === 276; + node.parameters[0].type.kind === 277; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { @@ -6010,7 +6063,7 @@ var ts; var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 281) { + if (doc.kind === 282) { if (doc.kind === kind) { result.push(doc); } @@ -6036,9 +6089,9 @@ var ts; var parent = node.parent; var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 205; + parent.parent.parent.kind === 206; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 205; + parent.parent.kind === 206; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -6048,13 +6101,13 @@ var ts; var isSourceOfAssignmentExpressionStatement = parent && parent.parent && parent.kind === 192 && parent.operatorToken.kind === 57 && - parent.parent.kind === 207; + parent.parent.kind === 208; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 230 && - parent && parent.kind === 230; - var isPropertyAssignmentExpression = parent && parent.kind === 257; + var isModuleDeclaration = node.kind === 231 && + parent && parent.kind === 231; + var isPropertyAssignmentExpression = parent && parent.kind === 258; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } @@ -6072,17 +6125,17 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 281); + var tags = getJSDocTags(func, 282); if (!param.name) { var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 281; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 282; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70) { var name_6 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 281 && tag.parameterName.text === name_6; }); + return ts.filter(tags, function (tag) { return tag.kind === 282 && tag.parameterName.text === name_6; }); } else { return undefined; @@ -6090,7 +6143,7 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 283); + var tag = getFirstJSDocTag(node, 284); if (!tag && node.kind === 144) { var paramTags = getJSDocParameterTags(node); if (paramTags) { @@ -6101,15 +6154,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 280); + return getFirstJSDocTag(node, 281); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 282); + return getFirstJSDocTag(node, 283); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 284); + return getFirstJSDocTag(node, 285); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -6122,8 +6175,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536)) { - if (node.type && node.type.kind === 275 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275; })) { + if (node.type && node.type.kind === 276 || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 276; })) { return true; } } @@ -6147,19 +6200,19 @@ var ts; case 191: var unaryOperator = parent.operator; return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; - case 212: case 213: + case 214: return parent.initializer === node ? 1 : 0; case 183: case 175: case 196: node = parent; break; - case 258: + case 259: if (parent.name !== node) { return 0; } - case 257: + case 258: node = parent.parent; break; default: @@ -6173,6 +6226,17 @@ var ts; return getAssignmentTargetKind(node) !== 0; } ts.isAssignmentTarget = isAssignmentTarget; + function isDeleteTarget(node) { + if (node.kind !== 177 && node.kind !== 178) { + return false; + } + node = node.parent; + while (node && node.kind === 183) { + node = node.parent; + } + return node && node.kind === 186; + } + ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { while (node) { if (node === ancestor) @@ -6184,7 +6248,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2) || (node.kind === 261 && node.isDeclarationFile)) { + if (hasModifier(node, 2) || (node.kind === 262 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -6197,7 +6261,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 239 || parent.kind === 243) { + if (parent.kind === 240 || parent.kind === 244) { if (parent.propertyName) { return true; } @@ -6223,8 +6287,8 @@ var ts; case 148: case 151: case 152: - case 260: - case 257: + case 261: + case 258: case 177: return parent.name === node; case 141: @@ -6236,22 +6300,22 @@ var ts; } return false; case 174: - case 239: + case 240: return parent.propertyName === node; - case 243: + case 244: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 234 || - node.kind === 233 || - node.kind === 236 && !!node.name || - node.kind === 237 || - node.kind === 239 || - node.kind === 243 || - node.kind === 240 && exportAssignmentIsAlias(node); + return node.kind === 235 || + node.kind === 234 || + node.kind === 237 && !!node.name || + node.kind === 238 || + node.kind === 240 || + node.kind === 244 || + node.kind === 241 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -6431,13 +6495,13 @@ var ts; var kind = node.kind; return kind === 150 || kind === 184 - || kind === 225 + || kind === 226 || kind === 185 || kind === 149 || kind === 151 || kind === 152 - || kind === 230 - || kind === 261; + || kind === 231 + || kind === 262; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -6559,14 +6623,13 @@ var ts; case 184: case 185: case 197: - case 246: case 247: + case 248: case 11: case 12: case 194: case 183: case 198: - case 297: return 19; case 181: case 177: @@ -6740,13 +6803,12 @@ var ts; "\u0085": "\\u0085" }); function escapeString(s) { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; - return s; - function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } + return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; + function getReplacement(c) { + return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); return ch.toLowerCase() === ch; @@ -7622,8 +7684,8 @@ var ts; var parseNode = getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 229: case 230: + case 231: return parseNode === parseNode.parent.name; } } @@ -7641,7 +7703,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 && declaration !== node) { + if (declaration.kind === 227 && declaration !== node) { return true; } } @@ -7692,6 +7754,10 @@ var ts; return node.kind === 70; } ts.isIdentifier = isIdentifier; + function isVoidExpression(node) { + return node.kind === 188; + } + ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { return isIdentifier(node) && node.autoGenerateKind > 0; } @@ -7759,18 +7825,18 @@ var ts; || kind === 151 || kind === 152 || kind === 155 - || kind === 203; + || kind === 204; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 257 - || kind === 258 + return kind === 258 || kind === 259 + || kind === 260 || kind === 149 || kind === 151 || kind === 152 - || kind === 244; + || kind === 245; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { @@ -7823,7 +7889,7 @@ var ts; ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 223: + case 224: case 144: case 174: return true; @@ -7901,8 +7967,8 @@ var ts; || kind === 178 || kind === 180 || kind === 179 - || kind === 246 || kind === 247 + || kind === 248 || kind === 181 || kind === 175 || kind === 183 @@ -7921,7 +7987,7 @@ var ts; || kind === 100 || kind === 96 || kind === 201 - || kind === 297; + || kind === 202; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); @@ -7949,7 +8015,6 @@ var ts; || kind === 196 || kind === 200 || kind === 198 - || kind === 297 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -7963,11 +8028,11 @@ var ts; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 294; + return node.kind === 295; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 293; + return node.kind === 294; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -7980,11 +8045,11 @@ var ts; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 202; + return node.kind === 203; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 204; + return node.kind === 205; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -8002,121 +8067,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 223; + return node.kind === 224; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 224; + return node.kind === 225; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 232; + return node.kind === 233; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 231 - || kind === 230; + return kind === 232 + || kind === 231; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 234; + return node.kind === 235; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 236; + return node.kind === 237; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 238 - || kind === 237; + return kind === 239 + || kind === 238; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 239; + return node.kind === 240; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 242; + return node.kind === 243; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 243; + return node.kind === 244; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 230 || node.kind === 229; + return node.kind === 231 || node.kind === 230; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { return kind === 185 || kind === 174 - || kind === 226 + || kind === 227 || kind === 197 || kind === 150 - || kind === 229 - || kind === 260 - || kind === 243 - || kind === 225 + || kind === 230 + || kind === 261 + || kind === 244 + || kind === 226 || kind === 184 || kind === 151 - || kind === 236 - || kind === 234 - || kind === 239 - || kind === 227 + || kind === 237 + || kind === 235 + || kind === 240 + || kind === 228 || kind === 149 || kind === 148 - || kind === 230 - || kind === 233 - || kind === 237 + || kind === 231 + || kind === 234 + || kind === 238 || kind === 144 - || kind === 257 + || kind === 258 || kind === 147 || kind === 146 || kind === 152 - || kind === 258 - || kind === 228 + || kind === 259 + || kind === 229 || kind === 143 - || kind === 223 - || kind === 285; + || kind === 224 + || kind === 286; } function isDeclarationStatementKind(kind) { - return kind === 225 - || kind === 244 - || kind === 226 + return kind === 226 + || kind === 245 || kind === 227 || kind === 228 || kind === 229 || kind === 230 + || kind === 231 + || kind === 236 || kind === 235 - || kind === 234 + || kind === 242 || kind === 241 - || kind === 240 - || kind === 233; + || kind === 234; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 215 - || kind === 214 - || kind === 222 - || kind === 209 - || kind === 207 - || kind === 206 - || kind === 212 - || kind === 213 - || kind === 211 - || kind === 208 - || kind === 219 - || kind === 216 - || kind === 218 - || kind === 220 - || kind === 221 - || kind === 205 + return kind === 216 + || kind === 215 + || kind === 223 || kind === 210 + || kind === 208 + || kind === 207 + || kind === 213 + || kind === 214 + || kind === 212 + || kind === 209 + || kind === 220 || kind === 217 - || kind === 293 - || kind === 296 - || kind === 295; + || kind === 219 + || kind === 221 + || kind === 222 + || kind === 206 + || kind === 211 + || kind === 218 + || kind === 294 + || kind === 297 + || kind === 296; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -8134,22 +8199,22 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 204; + || kind === 205; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 245 + return kind === 246 || kind === 141 || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 248; + return node.kind === 249; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 249; + return node.kind === 250; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { @@ -8161,60 +8226,60 @@ var ts; ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 246 - || kind === 252 - || kind === 247 + return kind === 247 + || kind === 253 + || kind === 248 || kind === 10; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 250 - || kind === 251; + return kind === 251 + || kind === 252; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 251; + return node.kind === 252; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 250; + return node.kind === 251; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 252; + || kind === 253; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 253 - || kind === 254; + return kind === 254 + || kind === 255; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 255; + return node.kind === 256; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 256; + return node.kind === 257; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 257; + return node.kind === 258; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 258; + return node.kind === 259; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isEnumMember(node) { - return node.kind === 260; + return node.kind === 261; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 261; + return node.kind === 262; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -8355,7 +8420,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 143) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 227) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 228) { return current; } } @@ -8375,14 +8440,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 223) { + if (node.kind === 224) { node = node.parent; } - if (node && node.kind === 224) { + if (node && node.kind === 225) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 205) { + if (node && node.kind === 206) { flags |= ts.getModifierFlags(node); } return flags; @@ -8391,14 +8456,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 223) { + if (node.kind === 224) { node = node.parent; } - if (node && node.kind === 224) { + if (node && node.kind === 225) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 205) { + if (node && node.kind === 206) { flags |= node.flags; } return flags; @@ -8457,7 +8522,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 261 + var ConstructorForKind = kind === 262 ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -9153,7 +9218,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createTemplateSpan(expression, literal, location) { - var node = createNode(202, location); + var node = createNode(203, location); node.expression = expression; node.literal = literal; return node; @@ -9167,7 +9232,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, location, multiLine, flags) { - var block = createNode(204, location, flags); + var block = createNode(205, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -9183,7 +9248,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(205, location, flags); + var node = createNode(206, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -9198,7 +9263,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(224, location, flags); + var node = createNode(225, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -9211,7 +9276,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(223, location, flags); + var node = createNode(224, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -9226,11 +9291,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(206, location); + return createNode(207, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(207, location, flags); + var node = createNode(208, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -9243,7 +9308,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(208, location); + var node = createNode(209, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -9258,7 +9323,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(209, location); + var node = createNode(210, location); node.statement = statement; node.expression = expression; return node; @@ -9272,7 +9337,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(210, location); + var node = createNode(211, location); node.expression = expression; node.statement = statement; return node; @@ -9286,7 +9351,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(211, location, undefined); + var node = createNode(212, location, undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -9302,7 +9367,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(212, location); + var node = createNode(213, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -9317,7 +9382,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(213, location); + var node = createNode(214, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -9332,7 +9397,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(214, location); + var node = createNode(215, location); if (label) { node.label = label; } @@ -9347,7 +9412,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(215, location); + var node = createNode(216, location); if (label) { node.label = label; } @@ -9362,7 +9427,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(216, location); + var node = createNode(217, location); node.expression = expression; return node; } @@ -9375,7 +9440,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(217, location); + var node = createNode(218, location); node.expression = expression; node.statement = statement; return node; @@ -9389,7 +9454,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(218, location); + var node = createNode(219, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -9403,7 +9468,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(219, location); + var node = createNode(220, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -9417,7 +9482,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(220, location); + var node = createNode(221, location); node.expression = expression; return node; } @@ -9430,7 +9495,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(221, location); + var node = createNode(222, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -9445,7 +9510,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(232, location); + var node = createNode(233, location); node.clauses = createNodeArray(clauses); return node; } @@ -9458,7 +9523,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(225, location, flags); + var node = createNode(226, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -9478,7 +9543,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(226, location); + var node = createNode(227, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -9496,7 +9561,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(235, location); + var node = createNode(236, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -9512,7 +9577,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(236, location); + var node = createNode(237, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -9526,7 +9591,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(237, location); + var node = createNode(238, location); node.name = name; return node; } @@ -9539,7 +9604,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(238, location); + var node = createNode(239, location); node.elements = createNodeArray(elements); return node; } @@ -9552,7 +9617,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(239, location); + var node = createNode(240, location); node.propertyName = propertyName; node.name = name; return node; @@ -9566,7 +9631,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(240, location); + var node = createNode(241, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -9582,7 +9647,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(241, location); + var node = createNode(242, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -9598,7 +9663,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(242, location); + var node = createNode(243, location); node.elements = createNodeArray(elements); return node; } @@ -9611,7 +9676,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(243, location); + var node = createNode(244, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -9625,7 +9690,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(246, location); + var node = createNode(247, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -9640,7 +9705,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(247, location); + var node = createNode(248, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -9654,7 +9719,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(248, location); + var node = createNode(249, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -9668,7 +9733,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(249, location); + var node = createNode(250, location); node.tagName = tagName; return node; } @@ -9681,7 +9746,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(250, location); + var node = createNode(251, location); node.name = name; node.initializer = initializer; return node; @@ -9695,7 +9760,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(251, location); + var node = createNode(252, location); node.expression = expression; return node; } @@ -9707,21 +9772,22 @@ var ts; return node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, location) { - var node = createNode(252, location); + function createJsxExpression(expression, dotDotDotToken, location) { + var node = createNode(253, location); + node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node), node); + return updateNode(createJsxExpression(expression, node.dotDotDotToken, node), node); } return node; } ts.updateJsxExpression = updateJsxExpression; function createHeritageClause(token, types, location) { - var node = createNode(255, location); + var node = createNode(256, location); node.token = token; node.types = createNodeArray(types); return node; @@ -9735,7 +9801,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(253, location); + var node = createNode(254, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -9749,7 +9815,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(254, location); + var node = createNode(255, location); node.statements = createNodeArray(statements); return node; } @@ -9762,7 +9828,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(256, location); + var node = createNode(257, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -9776,7 +9842,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer, location) { - var node = createNode(257, location); + var node = createNode(258, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -9791,14 +9857,14 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(258, location); + var node = createNode(259, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; function createSpreadAssignment(expression, location) { - var node = createNode(259, location); + var node = createNode(260, location); node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; return node; } @@ -9819,7 +9885,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(261, node, node.flags); + var updated = createNode(262, node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -9879,27 +9945,27 @@ var ts; } ts.updateSourceFileNode = updateSourceFileNode; function createNotEmittedStatement(original) { - var node = createNode(293, original); + var node = createNode(294, original); node.original = original; return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createNode(296); + var node = createNode(297); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createNode(295); + var node = createNode(296); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(294, location || original); + var node = createNode(295, location || original); node.expression = expression; node.original = original; return node; @@ -9912,12 +9978,6 @@ var ts; return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; - function createRawExpression(text) { - var node = createNode(297); - node.text = text; - return node; - } - ts.createRawExpression = createRawExpression; function createComma(left, right) { return createBinary(left, 25, right); } @@ -10081,6 +10141,19 @@ var ts; return setEmitFlags(createIdentifier(name), 4096 | 2); } ts.getHelperName = getHelperName; + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 220 + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { @@ -10180,9 +10253,9 @@ var ts; case 151: case 152: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 257: - return createExpressionForPropertyAssignment(property, receiver); case 258: + return createExpressionForPropertyAssignment(property, receiver); + case 259: return createExpressionForShorthandPropertyAssignment(property, receiver); case 149: return createExpressionForMethodDeclaration(property, receiver); @@ -10540,7 +10613,7 @@ var ts; case 177: node = node.expression; continue; - case 294: + case 295: node = node.expression; continue; } @@ -10588,7 +10661,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 294) { + while (node.kind === 295) { node = node.expression; } return node; @@ -10648,7 +10721,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 261) { + if (node.kind === 262) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -10839,10 +10912,10 @@ var ts; var name_9 = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 235 && node.importClause) { + if (node.kind === 236 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 241 && node.moduleSpecifier) { + if (node.kind === 242 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -10906,11 +10979,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 257: - return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 258: - return bindingElement.name; + return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 259: + return bindingElement.name; + case 260: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -10930,7 +11003,7 @@ var ts; case 174: return bindingElement.dotDotDotToken; case 196: - case 259: + case 260: return bindingElement; } return undefined; @@ -10946,7 +11019,7 @@ var ts; : propertyName; } break; - case 257: + case 258: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -10954,7 +11027,7 @@ var ts; : propertyName; } break; - case 259: + case 260: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -11059,15 +11132,15 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 235: + case 236: externalImports.push(node); break; - case 234: - if (node.moduleReference.kind === 245) { + case 235: + if (node.moduleReference.kind === 246) { externalImports.push(node); } break; - case 241: + case 242: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -11094,12 +11167,12 @@ var ts; } } break; - case 240: + case 241: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 205: + case 206: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -11107,7 +11180,7 @@ var ts; } } break; - case 225: + case 226: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -11125,7 +11198,7 @@ var ts; } } break; - case 226: + case 227: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -11173,7 +11246,7 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 261) { + if (kind === 262) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70) { @@ -11222,20 +11295,20 @@ var ts; return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 258: + case 259: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 259: + case 260: return visitNode(cbNode, node.expression); case 144: case 147: case 146: - case 257: - case 223: + case 258: + case 224: case 174: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -11261,7 +11334,7 @@ var ts; case 151: case 152: case 184: - case 225: + case 226: case 185: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -11353,6 +11426,8 @@ var ts; visitNode(cbNode, node.type); case 201: return visitNode(cbNode, node.expression); + case 202: + return visitNode(cbNode, node.name); case 193: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || @@ -11361,84 +11436,77 @@ var ts; visitNode(cbNode, node.whenFalse); case 196: return visitNode(cbNode, node.expression); - case 204: - case 231: + case 205: + case 232: return visitNodes(cbNodes, node.statements); - case 261: + case 262: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 205: + case 206: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 224: + case 225: return visitNodes(cbNodes, node.declarations); - case 207: - return visitNode(cbNode, node.expression); case 208: + return visitNode(cbNode, node.expression); + case 209: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 209: + case 210: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 210: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 211: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 212: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 213: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 214: - case 215: - return visitNode(cbNode, node.label); - case 216: - return visitNode(cbNode, node.expression); - case 217: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 215: + case 216: + return visitNode(cbNode, node.label); + case 217: + return visitNode(cbNode, node.expression); case 218: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 219: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 232: + case 233: return visitNodes(cbNodes, node.clauses); - case 253: + case 254: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 254: + case 255: return visitNodes(cbNodes, node.statements); - case 219: + case 220: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 220: - return visitNode(cbNode, node.expression); case 221: + return visitNode(cbNode, node.expression); + case 222: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 256: + case 257: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 145: return visitNode(cbNode, node.expression); - case 226: - case 197: - 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: + case 197: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -11450,143 +11518,151 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 229: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 260: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 230: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 261: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 234: + case 235: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 235: + case 236: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 236: + case 237: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 233: - return visitNode(cbNode, node.name); - case 237: + case 234: return visitNode(cbNode, node.name); case 238: - case 242: + return visitNode(cbNode, node.name); + case 239: + case 243: return visitNodes(cbNodes, node.elements); - case 241: + case 242: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 239: - case 243: + case 240: + case 244: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 240: + case 241: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); case 194: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 202: + case 203: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 142: return visitNode(cbNode, node.expression); - case 255: + case 256: return visitNodes(cbNodes, node.types); case 199: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 245: - return visitNode(cbNode, node.expression); - case 244: - return visitNodes(cbNodes, node.decorators); case 246: + return visitNode(cbNode, node.expression); + case 245: + return visitNodes(cbNodes, node.decorators); + case 247: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 247: case 248: + case 249: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 250: + case 251: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 251: - return visitNode(cbNode, node.expression); case 252: return visitNode(cbNode, node.expression); - case 249: + case 253: + return visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.expression); + case 250: return visitNode(cbNode, node.tagName); - case 262: + case 263: return visitNode(cbNode, node.type); - case 266: - return visitNodes(cbNodes, node.types); case 267: return visitNodes(cbNodes, node.types); - case 265: + case 268: + return visitNodes(cbNodes, node.types); + case 266: return visitNode(cbNode, node.elementType); + case 270: + return visitNode(cbNode, node.type); case 269: return visitNode(cbNode, node.type); - case 268: - return visitNode(cbNode, node.type); - case 270: + case 271: return visitNode(cbNode, node.literal); - case 272: + case 273: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 273: - return visitNode(cbNode, node.type); case 274: + return visitNode(cbNode, node.type); + case 275: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 275: - return visitNode(cbNode, node.type); case 276: return visitNode(cbNode, node.type); case 277: return visitNode(cbNode, node.type); - case 271: + case 278: + return visitNode(cbNode, node.type); + case 272: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 278: + case 279: return visitNodes(cbNodes, node.tags); - case 281: + case 282: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 282: - return visitNode(cbNode, node.typeExpression); case 283: return visitNode(cbNode, node.typeExpression); - case 280: - return visitNode(cbNode, node.typeExpression); case 284: - return visitNodes(cbNodes, node.typeParameters); + return visitNode(cbNode, node.typeExpression); + case 281: + return visitNode(cbNode, node.typeExpression); case 285: + return visitNodes(cbNodes, node.typeParameters); + case 286: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 287: + case 288: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 286: + case 287: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 294: + case 295: return visitNode(cbNode, node.expression); - case 288: + case 289: return visitNode(cbNode, node.literal); } } @@ -11750,7 +11826,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(261, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(262, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -12369,7 +12445,7 @@ var ts; case 151: case 152: case 147: - case 203: + case 204: return true; case 149: var methodDeclaration = node; @@ -12383,8 +12459,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 253: case 254: + case 255: return true; } } @@ -12393,42 +12469,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 225: + case 226: + case 206: case 205: - case 204: + case 209: case 208: - case 207: - case 220: + case 221: + case 217: + case 219: case 216: - case 218: case 215: + case 213: case 214: case 212: - case 213: case 211: - case 210: - case 217: - case 206: - case 221: - case 219: - case 209: + case 218: + case 207: case 222: + case 220: + case 210: + case 223: + case 236: case 235: - case 234: + case 242: case 241: - case 240: - case 230: - case 226: + case 231: case 227: - case 229: case 228: + case 230: + case 229: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 260; + return node.kind === 261; } function isReusableTypeMember(node) { if (node) { @@ -12444,7 +12520,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 223) { + if (node.kind !== 224) { return false; } var variableDeclarator = node; @@ -12576,7 +12652,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(202); + var span = createNode(203); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -13701,8 +13777,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 248) { - var node = createNode(246, opening.pos); + if (opening.kind === 249) { + var node = createNode(247, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -13712,7 +13788,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 247); + ts.Debug.assert(opening.kind === 248); result = opening; } if (inExpressionContext && token() === 26) { @@ -13772,7 +13848,7 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token() === 28) { - node = createNode(248, fullStart); + node = createNode(249, fullStart); scanJsxText(); } else { @@ -13784,7 +13860,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(247, fullStart); + node = createNode(248, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -13803,9 +13879,10 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(252); + var node = createNode(253); parseExpected(16); if (token() !== 17) { + node.dotDotDotToken = parseOptionalToken(23); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { @@ -13822,7 +13899,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(250); + var node = createNode(251); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -13837,7 +13914,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(251); + var node = createNode(252); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -13845,7 +13922,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(249); + var node = createNode(250); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -14062,7 +14139,7 @@ var ts; var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23); if (dotDotDotToken) { - var spreadElement = createNode(259, fullStart); + var spreadElement = createNode(260, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -14081,7 +14158,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(258, fullStart); + var shorthandDeclaration = createNode(259, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -14092,7 +14169,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(257, fullStart); + var propertyAssignment = createNode(258, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -14138,8 +14215,15 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(180); + var fullStart = scanner.getStartPos(); parseExpected(93); + if (parseOptional(22)) { + var node_1 = createNode(202, fullStart); + node_1.keywordToken = 93; + node_1.name = parseIdentifierName(); + return finishNode(node_1); + } + var node = createNode(180, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18) { @@ -14148,7 +14232,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(204); + var node = createNode(205); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14179,12 +14263,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(206); + var node = createNode(207); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(208); + var node = createNode(209); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14194,7 +14278,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(209); + var node = createNode(210); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -14205,7 +14289,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(210); + var node = createNode(211); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14228,21 +14312,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(212, pos); + var forInStatement = createNode(213, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19); forOrForInOrForOfStatement = forInStatement; } else if (parseOptional(140)) { - var forOfStatement = createNode(213, pos); + var forOfStatement = createNode(214, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(211, pos); + var forStatement = createNode(212, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -14260,7 +14344,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 215 ? 71 : 76); + parseExpected(kind === 216 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -14268,7 +14352,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(216); + var node = createNode(217); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -14277,7 +14361,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(217); + var node = createNode(218); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14286,7 +14370,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(253); + var node = createNode(254); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -14294,7 +14378,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(254); + var node = createNode(255); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -14304,12 +14388,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(218); + var node = createNode(219); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(232, scanner.getStartPos()); + var caseBlock = createNode(233, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -14317,14 +14401,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(220); + var node = createNode(221); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(221); + var node = createNode(222); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -14335,7 +14419,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(256); + var result = createNode(257); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -14345,7 +14429,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(222); + var node = createNode(223); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -14354,13 +14438,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(219, fullStart); + var labeledStatement = createNode(220, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(207, fullStart); + var expressionStatement = createNode(208, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -14512,9 +14596,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(214); - case 71: return parseBreakOrContinueStatement(215); + case 71: + return parseBreakOrContinueStatement(216); case 95: return parseReturnStatement(); case 106: @@ -14593,7 +14677,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(244, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(245, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -14665,7 +14749,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(223); + var node = createNode(224); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -14674,7 +14758,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(224); + var node = createNode(225); switch (token()) { case 103: break; @@ -14703,7 +14787,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(205, fullStart); + var node = createNode(206, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -14711,7 +14795,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -14896,7 +14980,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(203); + var result = createNode(204); nextToken(); return finishNode(result); } @@ -14930,7 +15014,7 @@ var ts; return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 197); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 227); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -14965,7 +15049,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 || token() === 107) { - var node = createNode(255); + var node = createNode(256); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -14988,7 +15072,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -14999,7 +15083,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228, fullStart); + var node = createNode(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(136); @@ -15011,13 +15095,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(260, scanner.getStartPos()); + var node = createNode(261, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -15032,7 +15116,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(231, scanner.getStartPos()); + var node = createNode(232, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -15043,7 +15127,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -15055,7 +15139,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (token() === 139) { @@ -15100,7 +15184,7 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(233, fullStart); + var exportDeclaration = createNode(234, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); @@ -15116,7 +15200,7 @@ var ts; if (isIdentifier()) { identifier = parseIdentifier(); if (token() !== 25 && token() !== 138) { - var importEqualsDeclaration = createNode(234, fullStart); + var importEqualsDeclaration = createNode(235, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -15126,7 +15210,7 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(235, fullStart); + var importDeclaration = createNode(236, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || @@ -15140,13 +15224,13 @@ var ts; return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(236, fullStart); + var importClause = createNode(237, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(238); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(239); } return finishNode(importClause); } @@ -15156,7 +15240,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(245); + var node = createNode(246); parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); @@ -15174,7 +15258,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(237); + var namespaceImport = createNode(238); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -15182,14 +15266,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 238 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 239 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(243); + return parseImportOrExportSpecifier(244); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(239); + return parseImportOrExportSpecifier(240); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -15208,13 +15292,13 @@ var ts; else { node.name = identifierName; } - if (kind === 239 && checkIdentifierIsKeyword) { + if (kind === 240 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(241, fullStart); + var node = createNode(242, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38)) { @@ -15222,7 +15306,7 @@ var ts; node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(242); + node.exportClause = parseNamedImportsOrExports(243); if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { parseExpected(138); node.moduleSpecifier = parseModuleSpecifier(); @@ -15232,7 +15316,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(240, fullStart); + var node = createNode(241, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -15311,10 +15395,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 234 && node.moduleReference.kind === 245 - || node.kind === 235 - || node.kind === 240 + || node.kind === 235 && node.moduleReference.kind === 246 + || node.kind === 236 || node.kind === 241 + || node.kind === 242 ? node : undefined; }); @@ -15350,7 +15434,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(262, scanner.getTokenPos()); + var result = createNode(263, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -15361,12 +15445,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(266, type.pos); + var unionType = createNode(267, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(273, type.pos); + var optionalType = createNode(274, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -15377,20 +15461,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(265, type.pos); + var arrayType = createNode(266, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(268, type.pos); + var nullableType = createNode(269, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(269, type.pos); + var nonNullableType = createNode(270, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -15442,27 +15526,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(277); + var result = createNode(278); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(276); + var result = createNode(277); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(275); + var result = createNode(276); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(274); + var result = createNode(275); nextToken(); parseExpected(18); result.parameters = parseDelimitedList(23, parseJSDocParameter); @@ -15483,7 +15567,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(272); + var result = createNode(273); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -15523,18 +15607,18 @@ var ts; return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(270); + var result = createNode(271); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(269); + var result = createNode(270); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(267); + var result = createNode(268); nextToken(); result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); @@ -15548,7 +15632,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(266); + var result = createNode(267); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -15564,12 +15648,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(263); + var result = createNode(264); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(288); + var result = createNode(289); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -15582,11 +15666,11 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(264, pos); + var result = createNode(265, pos); return finishNode(result); } else { - var result = createNode(268, pos); + var result = createNode(269, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -15730,7 +15814,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(278, start); + var result = createNode(279, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -15840,7 +15924,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(279, atToken.pos); + var result = createNode(280, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -15895,7 +15979,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(281, atToken.pos); + var result = createNode(282, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -15906,20 +15990,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 282; })) { + if (ts.forEach(tags, function (t) { return t.kind === 283; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(282, atToken.pos); + var result = createNode(283, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283; })) { + if (ts.forEach(tags, function (t) { return t.kind === 284; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -15934,7 +16018,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(286, atToken.pos); + var result = createNode(287, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -15943,7 +16027,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(280, atToken.pos); + var result = createNode(281, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -15952,7 +16036,7 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(285, atToken.pos); + var typedefTag = createNode(286, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); @@ -15966,7 +16050,7 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 272) { + if (typeExpression.type.kind === 273) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { var name_14 = jsDocTypeReference.name; @@ -15984,7 +16068,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(287, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(288, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -16025,7 +16109,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(230, pos); + var jsDocNamespaceNode = createNode(231, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -16069,7 +16153,7 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284; })) { + if (ts.forEach(tags, function (t) { return t.kind === 285; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); @@ -16092,7 +16176,7 @@ var ts; break; } } - var result = createNode(284, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -16384,7 +16468,7 @@ var ts; } function visitArray(array) { if (position >= array.pos && position < array.end) { - for (var i = 0, n = array.length; i < n; i++) { + for (var i = 0; i < array.length; i++) { var child = array[i]; if (child) { if (child.pos === position) { @@ -16411,16 +16495,16 @@ var ts; var ts; (function (ts) { function getModuleInstanceState(node) { - if (node.kind === 227 || node.kind === 228) { + if (node.kind === 228 || node.kind === 229) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 235 || node.kind === 234) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 236 || node.kind === 235) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 231) { + else if (node.kind === 232) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -16436,7 +16520,7 @@ var ts; }); return state_1; } - else if (node.kind === 230) { + else if (node.kind === 231) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -16545,7 +16629,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 230)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 231)) { symbol.valueDeclaration = node; } } @@ -16576,9 +16660,9 @@ var ts; return "__new"; case 155: return "__index"; - case 241: + case 242: return "__export"; - case 240: + case 241: return node.isExportEquals ? "export=" : "default"; case 192: switch (ts.getSpecialPropertyAssignmentKind(node)) { @@ -16592,20 +16676,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 225: case 226: + case 227: return ts.hasModifier(node, 512) ? "default" : undefined; - case 274: + case 275: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; case 144: - ts.Debug.assert(node.parent.kind === 274); + ts.Debug.assert(node.parent.kind === 275); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 285: + case 286: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 205) { + if (parentNode && parentNode.kind === 206) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -16649,7 +16733,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 240 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 241 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -16669,7 +16753,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 243 || (node.kind === 234 && hasExportModifier)) { + if (node.kind === 244 || (node.kind === 235 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -16677,7 +16761,7 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 285 && + var isJSDocTypedefInJSDocNamespace = node.kind === 286 && node.name && node.name.kind === 70 && node.name.isInJSDocNamespace; @@ -16738,7 +16822,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 261) { + if (node.kind === 262) { node.flags |= emitFlags; } if (isIIFE) { @@ -16814,43 +16898,43 @@ var ts; return; } switch (node.kind) { - case 210: + case 211: bindWhileStatement(node); break; - case 209: + case 210: bindDoStatement(node); break; - case 211: + case 212: bindForStatement(node); break; - case 212: case 213: + case 214: bindForInOrForOfStatement(node); break; - case 208: + case 209: bindIfStatement(node); break; - case 216: - case 220: + case 217: + case 221: bindReturnOrThrow(node); break; + case 216: case 215: - case 214: bindBreakOrContinueStatement(node); break; - case 221: + case 222: bindTryStatement(node); break; - case 218: + case 219: bindSwitchStatement(node); break; - case 232: + case 233: bindCaseBlock(node); break; - case 253: + case 254: bindCaseClause(node); break; - case 219: + case 220: bindLabeledStatement(node); break; case 190: @@ -16868,7 +16952,7 @@ var ts; case 193: bindConditionalExpressionFlow(node); break; - case 223: + case 224: bindVariableDeclarationFlow(node); break; case 179: @@ -17034,11 +17118,11 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 208: - case 210: case 209: - return parent.expression === node; case 211: + case 210: + return parent.expression === node; + case 212: case 193: return parent.condition === node; } @@ -17102,7 +17186,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 219 + var enclosingLabeledStatement = node.parent.kind === 220 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -17137,7 +17221,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 224) { + if (node.initializer.kind !== 225) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -17159,7 +17243,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 216) { + if (node.kind === 217) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -17179,7 +17263,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 215 ? breakTarget : continueTarget; + var flowLabel = node.kind === 216 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -17236,7 +17320,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 254; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 255; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -17301,7 +17385,7 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 209) { + if (!node.statement || node.statement.kind !== 210) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } @@ -17332,13 +17416,13 @@ var ts; else if (node.kind === 176) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 257) { + if (p.kind === 258) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 258) { + else if (p.kind === 259) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 259) { + else if (p.kind === 260) { bindAssignmentTargetFlow(p.expression); } } @@ -17438,7 +17522,7 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 212 || node.parent.parent.kind === 213) { + if (node.initializer || node.parent.parent.kind === 213 || node.parent.parent.kind === 214) { bindInitializedVariableFlow(node); } } @@ -17465,28 +17549,28 @@ var ts; function getContainerFlags(node) { switch (node.kind) { case 197: - case 226: - case 229: + case 227: + case 230: case 176: case 161: - case 287: - case 270: + case 288: + case 271: return 1; - case 227: - return 1 | 64; - case 274: - case 230: case 228: + return 1 | 64; + case 275: + case 231: + case 229: case 170: return 1 | 32; - case 261: + case 262: return 1 | 4 | 32; case 149: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } case 150: - case 225: + case 226: case 148: case 151: case 152: @@ -17499,17 +17583,17 @@ var ts; case 184: case 185: return 1 | 4 | 32 | 8 | 16; - case 231: + case 232: return 4; case 147: return node.initializer ? 4 : 0; - case 256: - case 211: + case 257: case 212: case 213: - case 232: + case 214: + case 233: return 2; - case 204: + case 205: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -17525,20 +17609,20 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 230: + case 231: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 261: + case 262: return declareSourceFileMember(node, symbolFlags, symbolExcludes); case 197: - case 226: + case 227: return declareClassMember(node, symbolFlags, symbolExcludes); - case 229: + case 230: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 161: case 176: - case 227: - case 270: - case 287: + case 228: + case 271: + case 288: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); case 158: case 159: @@ -17550,11 +17634,11 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 184: case 185: - case 274: - case 228: + case 275: + case 229: case 170: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } @@ -17570,11 +17654,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 261 ? node : node.body; - if (body && (body.kind === 261 || body.kind === 231)) { + var body = node.kind === 262 ? node : node.body; + if (body && (body.kind === 262 || body.kind === 232)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 241 || stat.kind === 240) { + if (stat.kind === 242 || stat.kind === 241) { return true; } } @@ -17650,11 +17734,11 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 || prop.name.kind !== 70) { + if (prop.kind === 260 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 257 || prop.kind === 258 || prop.kind === 149 + var currentKind = prop.kind === 258 || prop.kind === 259 || prop.kind === 149 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -17676,10 +17760,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 230: + case 231: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 261: + case 262: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -17769,8 +17853,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 261 && - blockScopeContainer.kind !== 230 && + if (blockScopeContainer.kind !== 262 && + blockScopeContainer.kind !== 231 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -17853,14 +17937,14 @@ var ts; case 70: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 285) { + while (parentNode && parentNode.kind !== 286) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 258)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 259)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); @@ -17892,7 +17976,7 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 256: + case 257: return checkStrictModeCatchClause(node); case 186: return checkStrictModeDeleteExpression(node); @@ -17902,7 +17986,7 @@ var ts; return checkStrictModePostfixUnaryExpression(node); case 190: return checkStrictModePrefixUnaryExpression(node); - case 217: + case 218: return checkStrictModeWithStatement(node); case 167: seenThisKeyword = true; @@ -17913,22 +17997,22 @@ var ts; return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 144: return bindParameter(node); - case 223: + case 224: case 174: return bindVariableDeclarationOrBindingElement(node); case 147: case 146: - case 271: + case 272: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 286: + case 287: return bindJSDocProperty(node); - case 257: case 258: - return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 260: - return bindPropertyOrMethodOrAccessor(node, 8, 900095); case 259: - case 251: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 261: + return bindPropertyOrMethodOrAccessor(node, 8, 900095); + case 260: + case 252: var root = container; var hasRest = false; while (root.parent) { @@ -17949,7 +18033,7 @@ var ts; case 149: case 148: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 225: + case 226: return bindFunctionDeclaration(node); case 150: return declareSymbolAndAddToSymbolTable(node, 16384, 0); @@ -17959,12 +18043,12 @@ var ts; return bindPropertyOrMethodOrAccessor(node, 65536, 74687); case 158: case 159: - case 274: + case 275: return bindFunctionOrConstructorType(node); case 161: case 170: - case 287: - case 270: + case 288: + case 271: return bindAnonymousDeclaration(node, 2048, "__type"); case 176: return bindObjectLiteralExpression(node); @@ -17977,43 +18061,43 @@ var ts; } break; case 197: - case 226: + case 227: inStrictMode = true; return bindClassLikeDeclaration(node); - case 227: + case 228: return bindBlockScopedDeclaration(node, 64, 792968); - case 285: + case 286: if (!node.fullName || node.fullName.kind === 70) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 228: - return bindBlockScopedDeclaration(node, 524288, 793064); case 229: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 230: + return bindEnumDeclaration(node); + case 231: return bindModuleDeclaration(node); - case 234: - case 237: - case 239: - case 243: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 233: - return bindNamespaceExportDeclaration(node); - case 236: - return bindImportClause(node); - case 241: - return bindExportDeclaration(node); + case 235: + case 238: case 240: + case 244: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 234: + return bindNamespaceExportDeclaration(node); + case 237: + return bindImportClause(node); + case 242: + return bindExportDeclaration(node); + case 241: return bindExportAssignment(node); - case 261: + case 262: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 204: + case 205: if (!ts.isFunctionLike(node.parent)) { return; } - case 231: + case 232: return updateStrictModeStatementList(node.statements); } } @@ -18041,7 +18125,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 240 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 241 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -18051,7 +18135,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 261) { + if (node.parent.kind !== 262) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -18100,7 +18184,7 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 225 || container.kind === 184) { + if (container.kind === 226 || container.kind === 184) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } @@ -18136,7 +18220,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 226) { + if (node.kind === 227) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -18246,15 +18330,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 206) || - node.kind === 226 || - (node.kind === 230 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 229 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 207) || + node.kind === 227 || + (node.kind === 231 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 230 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 205 || + (node.kind !== 206 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -18272,13 +18356,13 @@ var ts; return computeCallExpression(node, subtreeFlags); case 180: return computeNewExpression(node, subtreeFlags); - case 230: + case 231: return computeModuleDeclaration(node, subtreeFlags); case 183: return computeParenthesizedExpression(node, subtreeFlags); case 192: return computeBinaryExpression(node, subtreeFlags); - case 207: + case 208: return computeExpressionStatement(node, subtreeFlags); case 144: return computeParameter(node, subtreeFlags); @@ -18286,23 +18370,23 @@ var ts; return computeArrowFunction(node, subtreeFlags); case 184: return computeFunctionExpression(node, subtreeFlags); - case 225: - return computeFunctionDeclaration(node, subtreeFlags); - case 223: - return computeVariableDeclaration(node, subtreeFlags); - case 224: - return computeVariableDeclarationList(node, subtreeFlags); - case 205: - return computeVariableStatement(node, subtreeFlags); - case 219: - return computeLabeledStatement(node, subtreeFlags); case 226: + return computeFunctionDeclaration(node, subtreeFlags); + case 224: + return computeVariableDeclaration(node, subtreeFlags); + case 225: + return computeVariableDeclarationList(node, subtreeFlags); + case 206: + return computeVariableStatement(node, subtreeFlags); + case 220: + return computeLabeledStatement(node, subtreeFlags); + case 227: return computeClassDeclaration(node, subtreeFlags); case 197: return computeClassExpression(node, subtreeFlags); - case 255: - return computeHeritageClause(node, subtreeFlags); case 256: + return computeHeritageClause(node, subtreeFlags); + case 257: return computeCatchClause(node, subtreeFlags); case 199: return computeExpressionWithTypeArguments(node, subtreeFlags); @@ -18315,7 +18399,7 @@ var ts; case 151: case 152: return computeAccessor(node, subtreeFlags); - case 234: + case 235: return computeImportEquals(node, subtreeFlags); case 177: return computePropertyAccess(node, subtreeFlags); @@ -18703,25 +18787,25 @@ var ts; case 116: case 123: case 75: - case 229: - case 260: + case 230: + case 261: case 182: case 200: case 201: case 130: transformFlags |= 3; break; - case 246: case 247: case 248: - case 10: case 249: + case 10: case 250: case 251: case 252: + case 253: transformFlags |= 4; break; - case 213: + case 214: transformFlags |= 8; case 12: case 13: @@ -18729,8 +18813,9 @@ var ts; case 15: case 194: case 181: - case 258: + case 259: case 114: + case 202: transformFlags |= 192; break; case 195: @@ -18760,8 +18845,8 @@ var ts; case 164: case 165: case 166: - case 227: case 228: + case 229: case 167: case 168: case 169: @@ -18779,7 +18864,7 @@ var ts; case 196: transformFlags |= 192 | 524288; break; - case 259: + case 260: transformFlags |= 8 | 1048576; break; case 96: @@ -18827,22 +18912,22 @@ var ts; transformFlags |= 192; } break; - case 209: case 210: case 211: case 212: + case 213: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 261: + case 262: if (subtreeFlags & 32768) { transformFlags |= 192; } break; - case 216: - case 214: + case 217: case 215: + case 216: transformFlags |= 33554432; break; } @@ -18858,18 +18943,18 @@ var ts; case 180: case 175: return 537396545; - case 230: + case 231: return 574674241; case 144: return 536872257; case 185: return 601249089; case 184: - case 225: - return 601281857; - case 224: - return 546309441; case 226: + return 601281857; + case 225: + return 546309441; + case 227: case 197: return 539358529; case 150: @@ -18891,12 +18976,12 @@ var ts; case 153: case 154: case 155: - case 227: case 228: + case 229: return -3; case 176: return 540087617; - case 256: + case 257: return 537920833; case 172: case 173: @@ -18917,6 +19002,12 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; + var Extensions; + (function (Extensions) { + Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; + Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; + Extensions[Extensions["DtsOnly"] = 2] = "DtsOnly"; + })(Extensions || (Extensions = {})); function resolvedTypeScriptOnly(resolved) { if (!resolved) { return undefined; @@ -18924,9 +19015,6 @@ var ts; ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); return resolved.path; } - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } function resolvedModuleFromResolved(_a, isExternalLibraryImport) { var path = _a.path, extension = _a.extension; return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; @@ -18938,13 +19026,13 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { + function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); switch (extensions) { - case 2: - case 0: + case Extensions.DtsOnly: + case Extensions.TypeScript: return tryReadFromField("typings") || tryReadFromField("types"); - case 1: + case Extensions.JavaScript: if (typeof jsonContent.main === "string") { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); @@ -19006,6 +19094,7 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } + return undefined; }); return typeRoots; } @@ -19060,7 +19149,11 @@ var ts; return ts.forEach(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); }); } else { @@ -19076,7 +19169,8 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -19117,31 +19211,115 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + if (!perModuleNameCache) { + moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent_5 = ts.getDirectoryPath(current); + if (parent_5 === current || directoryPathMap.contains(parent_5)) { + break; + } + directoryPathMap.set(parent_5, result); + current = parent_5; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache[moduleName]; + if (result) { if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache[moduleName] = result; + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; } if (traceEnabled) { if (result.resolvedModule) { @@ -19266,33 +19444,33 @@ var ts; return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0) || tryResolve(1); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } @@ -19309,10 +19487,33 @@ var ts; } function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); @@ -19340,11 +19541,11 @@ var ts; } } switch (extensions) { - case 2: + case Extensions.DtsOnly: return tryExtension(".d.ts", ts.Extension.Dts); - case 0: + case Extensions.TypeScript: return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1: + case Extensions.JavaScript: return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } function tryExtension(ext, extension) { @@ -19353,19 +19554,21 @@ var ts; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } } - failedLookupLocations.push(fileName); - return undefined; } + failedLookupLocations.push(fileName); + return undefined; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var packageJsonPath = pathToPackageJson(candidate); @@ -19374,16 +19577,22 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - return resolvedFromAnyFile(fromFile); + var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); + if (mainOrTypesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); + var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); + if (fromExactFile) { + var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); + if (resolved_3) { + return resolved_3; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } - var x = tryAddingExtensions(typesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; + var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved) { + return resolved; } } else { @@ -19393,73 +19602,117 @@ var ts; } } else { - if (state.traceEnabled) { + if (directoryExists && state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } failedLookupLocations.push(packageJsonPath); } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); } function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(2, moduleName, directory, failedLookupLocations, state, true); + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, true, undefined); } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); } }); } function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } - if (extensions !== 1) { - return loadModuleFromNodeModulesFolder(2, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0) || tryResolve(1); - return createResolvedModuleWithFailedLookupLocations(resolved, false, failedLookupLocations); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); if (resolvedUsingSettings) { - return resolvedUsingSettings; + return { value: resolvedUsingSettings }; } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { - var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); - if (resolved_3) { - return resolved_3; + if (resolved_4) { + return resolved_4; } - if (extensions === 0) { + if (extensions === Extensions.TypeScript) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); } } } @@ -19471,10 +19724,13 @@ var ts; } var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2, moduleName, globalCache, failedLookupLocations, state); + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } function forEachAncestorDirectory(directory, callback) { while (true) { var result = callback(directory); @@ -19548,9 +19804,11 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, + getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, + getTypeFromTypeNode: getTypeFromTypeNode, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -19559,6 +19817,7 @@ var ts; getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, + signatureToString: signatureToString, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -19581,7 +19840,8 @@ var ts; tryGetMemberInModuleExports: tryGetMemberInModuleExports, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { return tryFindAmbientModule(moduleName, false); - } + }, + getApparentType: getApparentType }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -19675,6 +19935,7 @@ var ts; var visitedFlowNodes = []; var visitedFlowTypes = []; var potentialThisCollisions = []; + var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var typeofEQFacts = ts.createMap({ @@ -19820,7 +20081,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 230 && source.valueDeclaration.kind !== 230))) { + (target.valueDeclaration.kind === 231 && source.valueDeclaration.kind !== 231))) { target.valueDeclaration = source.valueDeclaration; } ts.addRange(target.declarations, source.declarations); @@ -19915,7 +20176,7 @@ var ts; return type.flags & 32768 ? type.objectFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 261 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 262 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -19959,25 +20220,35 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 223 || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + if (declaration.kind === 174) { + var errorBindingElement = ts.getAncestor(usage, 174); + if (errorBindingElement) { + return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + declaration.pos < errorBindingElement.pos; + } + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 224), usage); + } + else if (declaration.kind === 224) { + return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); return isUsedInFunctionOrNonStaticProperty(usage, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 205: - case 211: - case 213: + case 206: + case 212: + case 214: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 212: case 213: + case 214: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } @@ -20004,6 +20275,15 @@ var ts; } return false; } + function getAncestorBindingPattern(node) { + while (node) { + if (ts.isBindingPattern(node)) { + return node; + } + node = node.parent; + } + return undefined; + } } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { var result; @@ -20017,7 +20297,7 @@ var ts; if (result = getSymbol(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 793064 && lastLocation.kind !== 278) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 279) { useResult = result.flags & 262144 ? lastLocation === location.type || lastLocation.kind === 144 || @@ -20040,13 +20320,13 @@ var ts; } } switch (location.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 230: + case 231: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 261 || ts.isAmbientModule(location)) { + if (location.kind === 262 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -20056,7 +20336,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 243)) { + ts.getDeclarationOfKind(moduleExports[name], 244)) { break; } } @@ -20064,7 +20344,7 @@ var ts; break loop; } break; - case 229: + case 230: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } @@ -20080,9 +20360,9 @@ var ts; } } break; - case 226: - case 197: case 227: + case 197: + case 228: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -20100,7 +20380,7 @@ var ts; break; case 142: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 227) { + if (ts.isClassLike(grandparent) || grandparent.kind === 228) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; @@ -20112,7 +20392,7 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 185: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; @@ -20176,7 +20456,7 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 233) { + if (decls && decls.length === 1 && decls[0].kind === 234) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -20256,7 +20536,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 223), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -20273,10 +20553,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 234) { + if (node.kind === 235) { return node; } - while (node && node.kind !== 235) { + while (node && node.kind !== 236) { node = node.parent; } return node; @@ -20286,7 +20566,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 245) { + if (node.moduleReference.kind === 246) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -20390,19 +20670,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 234: + case 235: return getTargetOfImportEqualsDeclaration(node); - case 236: - return getTargetOfImportClause(node); case 237: + return getTargetOfImportClause(node); + case 238: return getTargetOfNamespaceImport(node); - case 239: - return getTargetOfImportSpecifier(node); - case 243: - return getTargetOfExportSpecifier(node); case 240: + return getTargetOfImportSpecifier(node); + case 244: + return getTargetOfExportSpecifier(node); + case 241: return getTargetOfExportAssignment(node); - case 233: + case 234: return getTargetOfNamespaceExportDeclaration(node); } } @@ -20446,10 +20726,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 240) { + if (node.kind === 241) { checkExpressionCached(node.expression); } - else if (node.kind === 243) { + else if (node.kind === 244) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -20465,7 +20745,7 @@ var ts; return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 234); + ts.Debug.assert(entityName.parent.kind === 235); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -20762,11 +21042,11 @@ var ts; } } switch (location_1.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 230: + case 231: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -20810,7 +21090,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -20842,7 +21122,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -20915,7 +21195,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 261 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 262 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -20953,7 +21233,7 @@ var ts; meaning = 107455 | 1048576; } else if (entityName.kind === 141 || entityName.kind === 177 || - entityName.parent.kind === 234) { + entityName.parent.kind === 235) { meaning = 1920; } else { @@ -21048,7 +21328,7 @@ var ts; while (node.kind === 166) { node = node.parent; } - if (node.kind === 228) { + if (node.kind === 229) { return getSymbolOfNode(node); } } @@ -21056,7 +21336,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 231 && + node.parent.kind === 232 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -21125,9 +21405,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_5 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_5) { - walkSymbol(parent_5, getQualifiedLeftMeaning(meaning), false); + var parent_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_6) { + walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -21260,12 +21540,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_6 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_6); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_6, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -21324,7 +21604,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 261 || declaration.parent.kind === 231; + return declaration.parent.kind === 262 || declaration.parent.kind === 232; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -21337,25 +21617,6 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } - function writeIndexSignature(info, keyword) { - if (info) { - if (info.isReadonly) { - writeKeyword(writer, 130); - writeSpace(writer); - } - writePunctuation(writer, 20); - writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55); - writeSpace(writer); - writeKeyword(writer, keyword); - writePunctuation(writer, 21); - writePunctuation(writer, 55); - writeSpace(writer); - writeType(info.type, 0); - writePunctuation(writer, 24); - writer.writeLine(); - } - } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { writeKeyword(writer, 130); @@ -21438,8 +21699,8 @@ var ts; writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 134); - writeIndexSignature(resolved.numberIndexInfo, 132); + buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0, enclosingDeclaration, globalFlags, symbolStack); + buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, 1, enclosingDeclaration, globalFlags, symbolStack); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -21618,6 +21879,10 @@ var ts; buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + var returnType = getReturnTypeOfSignature(signature); + if (flags & 2048 && isTypeAny(returnType)) { + return; + } if (flags & 8) { writeSpace(writer); writePunctuation(writer, 35); @@ -21630,7 +21895,6 @@ var ts; buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); } else { - var returnType = getReturnTypeOfSignature(signature); buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } } @@ -21648,6 +21912,32 @@ var ts; buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } + function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 130); + writeSpace(writer); + } + writePunctuation(writer, 20); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 55); + writeSpace(writer); + switch (kind) { + case 1: + writeKeyword(writer, 132); + break; + case 0: + writeKeyword(writer, 134); + break; + } + writePunctuation(writer, 21); + writePunctuation(writer, 55); + writeSpace(writer); + buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); + writePunctuation(writer, 24); + writer.writeLine(); + } + } return _displayBuilder || (_displayBuilder = { buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, @@ -21658,6 +21948,7 @@ var ts; buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, + buildIndexSignatureDisplay: buildIndexSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay }); } @@ -21674,27 +21965,27 @@ var ts; switch (node.kind) { case 174: return isDeclarationVisible(node.parent.parent); - case 223: + case 224: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 230: - case 226: + case 231: case 227: case 228: - case 225: case 229: - case 234: + case 226: + case 230: + case 235: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_7 = getDeclarationContainer(node); + var parent_8 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 234 && parent_7.kind !== 261 && ts.isInAmbientContext(parent_7))) { - return isGlobalSourceFile(parent_7); + !(node.kind !== 235 && parent_8.kind !== 262 && ts.isInAmbientContext(parent_8))) { + return isGlobalSourceFile(parent_8); } - return isDeclarationVisible(parent_7); + return isDeclarationVisible(parent_8); case 147: case 146: case 151: @@ -21709,7 +22000,7 @@ var ts; case 153: case 155: case 144: - case 231: + case 232: case 158: case 159: case 161: @@ -21720,15 +22011,15 @@ var ts; case 165: case 166: return isDeclarationVisible(node.parent); - case 236: case 237: - case 239: + case 238: + case 240: return false; case 143: - case 261: - case 233: + case 262: + case 234: return true; - case 240: + case 241: return false; default: return false; @@ -21737,10 +22028,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 240) { + if (node.parent && node.parent.kind === 241) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 243) { + else if (node.parent.kind === 244) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -21818,12 +22109,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 223: case 224: + case 225: + case 240: case 239: case 238: case 237: - case 236: node = node.parent; break; default: @@ -21842,9 +22133,6 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1) !== 0; } - function isTypeNever(type) { - return type && (type.flags & 8192) !== 0; - } function getTypeForBindingElementParent(node) { var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); @@ -21979,11 +22267,11 @@ var ts; return type; } } - if (declaration.parent.parent.kind === 212) { + if (declaration.parent.parent.kind === 213) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 | 262144) ? indexType : stringType; } - if (declaration.parent.parent.kind === 213) { + if (declaration.parent.parent.kind === 214) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -21993,7 +22281,7 @@ var ts; return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && - declaration.kind === 223 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 224 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -22031,7 +22319,7 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 258) { + if (declaration.kind === 259) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -22106,7 +22394,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 257) { + if (declaration.kind === 258) { return type; } return getWidenedType(type); @@ -22134,10 +22422,10 @@ var ts; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 240) { + if (declaration.kind === 241) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 && declaration.kind === 286 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 287 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { @@ -22344,8 +22632,8 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 226 || node.kind === 197 || - node.kind === 225 || node.kind === 184 || + if (node.kind === 227 || node.kind === 197 || + node.kind === 226 || node.kind === 184 || node.kind === 149 || node.kind === 185) { var declarations = node.typeParameters; if (declarations) { @@ -22355,15 +22643,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 227); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 228); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 227 || node.kind === 226 || - node.kind === 197 || node.kind === 228) { + if (node.kind === 228 || node.kind === 227 || + node.kind === 197 || node.kind === 229) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -22496,7 +22784,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 228 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -22525,7 +22813,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227) { + if (declaration.kind === 228) { if (declaration.flags & 64) { return false; } @@ -22575,7 +22863,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 285); + var declaration = ts.getDeclarationOfKind(symbol, 286); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -22586,7 +22874,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 228); + declaration = ts.getDeclarationOfKind(symbol, 229); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -22618,7 +22906,7 @@ var ts; function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 230) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -22646,7 +22934,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 230) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -23121,8 +23409,8 @@ var ts; else { var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; @@ -23393,7 +23681,7 @@ var ts; } function isJSDocOptionalParameter(node) { if (node.flags & 65536) { - if (node.type && node.type.kind === 273) { + if (node.type && node.type.kind === 274) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -23404,7 +23692,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 273; + return paramTag.typeExpression.type.kind === 274; } } } @@ -23456,7 +23744,7 @@ var ts; var thisParameter = undefined; var hasThisParameter = void 0; var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); - for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { + for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) { @@ -23539,12 +23827,12 @@ var ts; if (!symbol) return emptyArray; var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { + for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { case 158: case 159: - case 225: + case 226: case 149: case 148: case 150: @@ -23555,7 +23843,7 @@ var ts; case 152: case 184: case 185: - case 274: + case 275: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -23827,7 +24115,7 @@ var ts; switch (node.kind) { case 157: return node.typeName; - case 272: + case 273: return node.name; case 199: var expr = node.expression; @@ -23853,7 +24141,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 272) { + if (symbol.flags & 107455 && node.kind === 273) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -23863,7 +24151,7 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 272) { + if (node.kind === 273) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); @@ -23898,9 +24186,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 226: case 227: - case 229: + case 228: + case 230: return declaration; } } @@ -24074,8 +24362,9 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; + if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } } @@ -24185,8 +24474,8 @@ var ts; } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; addTypeToIntersection(typeSet, type); } } @@ -24304,7 +24593,7 @@ var ts; getIndexInfoOfType(objectType, 0) || undefined; if (indexInfo) { - if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return unknownType; } @@ -24416,7 +24705,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 228 ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 229 ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -24539,7 +24828,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 227)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 228)) { if (!(ts.getModifierFlags(container) & 32) && (container.kind !== 150 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -24558,8 +24847,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118: - case 263: case 264: + case 265: return anyType; case 134: return stringType; @@ -24577,21 +24866,21 @@ var ts; return nullType; case 129: return neverType; - case 289: - return nullType; case 290: - return undefinedType; + return nullType; case 291: + return undefinedType; + case 292: return neverType; case 167: case 98: return getTypeFromThisTypeNode(node); case 171: return getTypeFromLiteralTypeNode(node); - case 288: + case 289: return getTypeFromLiteralTypeNode(node.literal); case 157: - case 272: + case 273: return getTypeFromTypeReference(node); case 156: return booleanType; @@ -24600,29 +24889,29 @@ var ts; case 160: return getTypeFromTypeQueryNode(node); case 162: - case 265: + case 266: return getTypeFromArrayTypeNode(node); case 163: return getTypeFromTupleTypeNode(node); case 164: - case 266: + case 267: return getTypeFromUnionTypeNode(node); case 165: return getTypeFromIntersectionTypeNode(node); case 166: - case 268: case 269: - case 276: - case 277: - case 273: - return getTypeFromTypeNode(node.type); case 270: + case 277: + case 278: + case 274: + return getTypeFromTypeNode(node.type); + case 271: return getTypeFromTypeNode(node.literal); case 158: case 159: case 161: - case 287: - case 274: + case 288: + case 275: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 168: return getTypeFromTypeOperatorNode(node); @@ -24634,9 +24923,9 @@ var ts; case 141: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 267: + case 268: return getTypeFromJSDocTupleType(node); - case 275: + case 276: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -24785,17 +25074,19 @@ var ts; var constraintType = getConstraintTypeFromMappedType(type); if (constraintType.flags & 262144) { var typeVariable_1 = constraintType.type; - var mappedTypeVariable = instantiateType(typeVariable_1, mapper); - if (typeVariable_1 !== mappedTypeVariable) { - return mapType(mappedTypeVariable, function (t) { - if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); - } - return t; - }); + if (typeVariable_1.flags & 16384) { + var mappedTypeVariable = instantiateType(typeVariable_1, mapper); + if (typeVariable_1 !== mappedTypeVariable) { + return mapType(mappedTypeVariable, function (t) { + if (isMappableType(t)) { + var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); + var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); + combinedMapper.mappedTypes = mapper.mappedTypes; + return instantiateMappedObjectType(type, combinedMapper); + } + return t; + }); + } } } return instantiateMappedObjectType(type, mapper); @@ -24816,12 +25107,12 @@ var ts; return false; } var mappedTypes = mapper.mappedTypes; - var node = symbol.declarations[0].parent; + var node = symbol.declarations[0]; while (node) { switch (node.kind) { case 158: case 159: - case 225: + case 226: case 149: case 148: case 150: @@ -24832,10 +25123,10 @@ var ts; case 152: case 184: case 185: - case 226: - case 197: case 227: + case 197: case 228: + case 229: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -24845,15 +25136,24 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 227) { + if (ts.isClassLike(node) || node.kind === 228) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 230: - case 261: + case 275: + var func = node; + for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { + var p = _c[_b]; + if (ts.contains(mappedTypes, getTypeOfNode(p))) { + return true; + } + } + break; + case 231: + case 262: return false; } node = node.parent; @@ -24863,7 +25163,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 261 || parentKind === 231; + return parentKind === 262 || parentKind === 232; } return false; } @@ -24930,7 +25230,7 @@ var ts; case 192: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 257: + case 258: return isContextSensitive(node.initializer); case 149: case 148: @@ -24986,7 +25286,7 @@ var ts; return isTypeRelatedTo(source, target, assignableRelation); } function isTypeInstanceOf(source, target) { - return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); } function isTypeComparableTo(source, target) { return isTypeRelatedTo(source, target, comparableRelation); @@ -25688,8 +25988,11 @@ var ts; } } } - else if (relation !== identityRelation && isEmptyObjectType(resolveStructuredTypeMembers(target))) { - return -1; + else if (relation !== identityRelation) { + var resolved = resolveStructuredTypeMembers(target); + if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1) { + return -1; + } } return 0; } @@ -25840,7 +26143,7 @@ var ts; return 0; } var result = -1; - for (var i = 0, len = sourceSignatures.length; i < len; i++) { + for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], false, false, false, isRelatedTo); if (!related) { return 0; @@ -26049,8 +26352,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var t = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var t = types_8[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -26058,8 +26361,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -26150,8 +26453,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; result |= getFalsyFlags(t); } return result; @@ -26310,7 +26613,7 @@ var ts; case 174: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 225: + case 226: case 149: case 148: case 151: @@ -26651,8 +26954,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -26768,7 +27071,7 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 223 || target.kind === 174) && + (target.kind === 224 || target.kind === 174) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; @@ -26866,8 +27169,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getTypeFacts(t); } return result; @@ -26953,7 +27256,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 || node.parent.kind === 257 ? + return node.parent.kind === 175 || node.parent.kind === 258 ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } @@ -26972,9 +27275,9 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 212: - return stringType; case 213: + return stringType; + case 214: return checkRightHandSideOfForOf(parent.expression) || unknownType; case 192: return getAssignedTypeOfBinaryExpression(parent); @@ -26984,9 +27287,9 @@ var ts; return getAssignedTypeOfArrayLiteralElement(parent, node); case 196: return getAssignedTypeOfSpreadExpression(parent); - case 257: - return getAssignedTypeOfPropertyAssignment(parent); case 258: + return getAssignedTypeOfPropertyAssignment(parent); + case 259: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -27009,26 +27312,26 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 212) { + if (node.parent.parent.kind === 213) { return stringType; } - if (node.parent.parent.kind === 213) { + if (node.parent.parent.kind === 214) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 223 ? + return node.kind === 224 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 223 || node.kind === 174 ? + return node.kind === 224 || node.kind === 174 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 223 && node.initializer && + return node.kind === 224 && node.initializer && isEmptyArrayLiteral(node.initializer) || node.kind !== 174 && node.parent.kind === 192 && isEmptyArrayLiteral(node.parent.right); @@ -27055,7 +27358,7 @@ var ts; getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 253) { + if (clause.kind === 254) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -27157,8 +27460,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -27700,8 +28003,8 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 231 || - node.kind === 261 || + node.kind === 232 || + node.kind === 262 || node.kind === 147) { return node; } @@ -27771,7 +28074,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; - if (declaration_1.kind === 226 + if (declaration_1.kind === 227 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -27799,6 +28102,7 @@ var ts; } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkCollisionWithCapturedNewTargetVariable(node, node); checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; @@ -27826,7 +28130,7 @@ var ts; flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0 || isInTypeQuery(node)) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); if (type === autoType || type === autoArrayType) { @@ -27857,7 +28161,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 256) { + symbol.valueDeclaration.parent.kind === 257) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -27875,8 +28179,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 211 && - ts.getAncestor(symbol.valueDeclaration, 224).parent === container && + if (container.kind === 212 && + ts.getAncestor(symbol.valueDeclaration, 225).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -27966,10 +28270,10 @@ var ts; needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 230: + case 231: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 229: + case 230: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; case 150: @@ -28027,9 +28331,9 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 274) { + if (jsdocType && jsdocType.kind === 275) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 277) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 278) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -28323,8 +28627,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -28394,13 +28698,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 250) { + if (attribute.kind === 251) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 251) { + else if (attribute.kind === 252) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -28418,14 +28722,14 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 223: + case 224: case 144: case 147: case 146: case 174: return getContextualTypeForInitializerExpression(node); case 185: - case 216: + case 217: return getContextualTypeForReturnExpression(node); case 195: return getContextualTypeForYieldOperand(parent); @@ -28437,22 +28741,22 @@ var ts; return getTypeFromTypeNode(parent.type); case 192: return getContextualTypeForBinaryOperand(node); - case 257: case 258: + case 259: return getContextualTypeForObjectLiteralElement(parent); case 175: return getContextualTypeForElementExpression(node); case 193: return getContextualTypeForConditionalOperand(node); - case 202: + case 203: ts.Debug.assert(parent.parent.kind === 194); return getContextualTypeForSubstitutionExpression(parent.parent, node); case 183: return getContextualType(parent); - case 252: + case 253: return getContextualType(parent); - case 250: case 251: + case 252: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -28504,8 +28808,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -28648,25 +28952,25 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 257 || - memberDecl.kind === 258 || + if (memberDecl.kind === 258 || + memberDecl.kind === 259 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 257) { + if (memberDecl.kind === 258) { type = checkPropertyAssignment(memberDecl, contextualMapper); } else if (memberDecl.kind === 149) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 258); + ts.Debug.assert(memberDecl.kind === 259); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 257 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 258 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 258 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 259 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912; } @@ -28692,7 +28996,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 259) { + else if (memberDecl.kind === 260) { if (languageVersion < 5) { checkExternalEmitHelpers(memberDecl, 2); } @@ -28792,13 +29096,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 252: + case 253: checkJsxExpression(child); break; - case 246: + case 247: checkJsxElement(child); break; - case 247: + case 248: checkJsxSelfClosingElement(child); break; } @@ -29093,11 +29397,11 @@ var ts; var nameTable = ts.createMap(); var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 250) { + if (node.attributes[i].kind === 251) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 251); + ts.Debug.assert(node.attributes[i].kind === 252); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -29116,7 +29420,11 @@ var ts; } function checkJsxExpression(node) { if (node.expression) { - return checkExpression(node.expression); + var type = checkExpression(node.expression); + if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { + error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); + } + return type; } else { return unknownType; @@ -29134,7 +29442,7 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 || node.kind === 223 ? + var errorNode = node.kind === 177 || node.kind === 224 ? node.name : node.right; if (left.kind === 96) { @@ -29280,7 +29588,7 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 224) { + if (initializer.kind === 225) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -29302,7 +29610,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 212 && + if (node.kind === 213 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -29398,19 +29706,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_8 = signature.declaration && signature.declaration.parent; + var parent_9 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_8 === lastParent) { + if (lastParent && parent_9 === lastParent) { index++; } else { - lastParent = parent_8; + lastParent = parent_9; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_8; + lastParent = parent_9; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -29630,7 +29938,7 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 145) { switch (node.parent.kind) { - case 226: + case 227: case 197: return 1; case 147: @@ -29651,7 +29959,7 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } @@ -29672,7 +29980,7 @@ var ts; return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } @@ -29709,7 +30017,7 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } @@ -30070,7 +30378,7 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 226: + case 227: case 197: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 144: @@ -30180,9 +30488,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 225 + ? 226 : resolvedRequire.flags & 3 - ? 223 + ? 224 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -30208,6 +30516,23 @@ var ts; function checkNonNullAssertion(node) { return getNonNullableType(checkExpression(node.expression)); } + function checkMetaProperty(node) { + checkGrammarMetaProperty(node); + ts.Debug.assert(node.keywordToken === 93 && node.name.text === "target", "Unrecognized meta-property."); + var container = ts.getNewTargetContainer(node); + if (!container) { + error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); + return unknownType; + } + else if (container.kind === 150) { + var symbol = getSymbolOfNode(container.parent); + return getTypeOfSymbol(symbol); + } + else { + var symbol = getSymbolOfNode(container); + return getTypeOfSymbol(symbol); + } + } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks) { @@ -30315,7 +30640,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 204) { + if (func.body.kind !== 205) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -30394,7 +30719,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 218 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 219 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -30440,7 +30765,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 204 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 205 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -30506,6 +30831,7 @@ var ts; if (produceDiagnostics && node.kind !== 149) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); } return type; } @@ -30520,7 +30846,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 204) { + if (node.body.kind === 205) { checkSourceElement(node.body); } else { @@ -30573,7 +30899,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 237; + return declaration && declaration.kind === 238; } } } @@ -30589,6 +30915,16 @@ var ts; } function checkDeleteExpression(node) { checkExpression(node.expression); + var expr = ts.skipParentheses(node.expression); + if (expr.kind !== 177 && expr.kind !== 178) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); + return booleanType; + } + var links = getNodeLinks(expr); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } return booleanType; } function checkTypeOfExpression(node) { @@ -30659,8 +30995,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -30674,8 +31010,8 @@ var ts; } if (type.flags & 65536) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -30684,8 +31020,8 @@ var ts; } if (type.flags & 131072) { var types = type.types; - for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { - var t = types_17[_a]; + for (var _a = 0, types_18 = types; _a < types_18.length; _a++) { + var t = types_18[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -30732,7 +31068,7 @@ var ts; return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 257 || property.kind === 258) { + if (property.kind === 258 || property.kind === 259) { var name_20 = property.name; if (name_20.kind === 142) { checkComputedPropertyName(name_20); @@ -30747,7 +31083,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 258) { + if (property.kind === 259) { return checkDestructuringAssignment(property, type); } else { @@ -30758,7 +31094,7 @@ var ts; error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); } } - else if (property.kind === 259) { + else if (property.kind === 260) { if (languageVersion < 5) { checkExternalEmitHelpers(property, 4); } @@ -30826,7 +31162,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 258) { + if (exprOrAssignment.kind === 259) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -30854,7 +31190,7 @@ var ts; } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 259 ? + var error = target.parent.kind === 260 ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -30883,8 +31219,8 @@ var ts; case 176: case 187: case 201: + case 248: case 247: - case 246: return true; case 193: return isSideEffectFree(node.whenTrue) && @@ -31318,6 +31654,8 @@ var ts; return checkAssertion(node); case 201: return checkNonNullAssertion(node); + case 202: + return checkMetaProperty(node); case 186: return checkDeleteExpression(node); case 188: @@ -31338,13 +31676,13 @@ var ts; return undefinedWideningType; case 195: return checkYieldExpression(node); - case 252: + case 253: return checkJsxExpression(node); - case 246: - return checkJsxElement(node); case 247: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 248: + return checkJsxSelfClosingElement(node); + case 249: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -31389,7 +31727,7 @@ var ts; return false; } return node.kind === 149 || - node.kind === 225 || + node.kind === 226 || node.kind === 184; } function getTypePredicateParameterIndex(parameterList, parameter) { @@ -31448,14 +31786,14 @@ var ts; switch (node.parent.kind) { case 185: case 153: - case 225: + case 226: case 184: case 158: case 149: case 148: - var parent_9 = node.parent; - if (node === parent_9.type) { - return parent_9; + var parent_10 = node.parent; + if (node === parent_10.type) { + return parent_10; } } } @@ -31483,7 +31821,7 @@ var ts; if (node.kind === 155) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 || node.kind === 225 || node.kind === 159 || + else if (node.kind === 158 || node.kind === 226 || node.kind === 159 || node.kind === 153 || node.kind === 150 || node.kind === 154) { checkGrammarFunctionLikeDeclaration(node); @@ -31605,7 +31943,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 227) { + if (node.kind === 228) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -31687,7 +32025,7 @@ var ts; if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 && n.kind !== 225) { + else if (n.kind !== 184 && n.kind !== 226) { ts.forEachChild(n, markThisReferencesAsErrors); } } @@ -31712,7 +32050,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -31861,8 +32199,8 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 227 && - n.parent.kind !== 226 && + if (n.parent.kind !== 228 && + n.parent.kind !== 227 && n.parent.kind !== 197 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { @@ -31973,11 +32311,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 227 || node.parent.kind === 161 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 228 || node.parent.kind === 161 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 225 || node.kind === 149 || node.kind === 148 || node.kind === 150) { + if (node.kind === 226 || node.kind === 149 || node.kind === 148 || node.kind === 150) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -32088,16 +32426,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 227: + case 228: return 2097152; - case 230: + case 231: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 226: - case 229: + case 227: + case 230: return 2097152 | 1048576; - case 234: + case 235: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -32109,7 +32447,8 @@ var ts; } function checkNonThenableType(type, location, message) { type = getWidenedType(type); - if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + var apparentType = getApparentType(type); + if ((apparentType.flags & (1 | 8192)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -32244,7 +32583,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 226: + case 227: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -32299,7 +32638,7 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 226: + case 227: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -32332,6 +32671,7 @@ var ts; checkFunctionOrMethodDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -32382,28 +32722,28 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 261: - case 230: + case 262: + case 231: checkUnusedModuleMembers(node); break; - case 226: + case 227: case 197: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 227: + case 228: checkUnusedTypeParameters(node); break; - case 204: - case 232: - case 211: + case 205: + case 233: case 212: case 213: + case 214: checkUnusedLocalsAndParameters(node); break; case 150: case 184: - case 225: + case 226: case 185: case 149: case 151: @@ -32427,7 +32767,7 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 227 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 228 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_2 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { @@ -32460,9 +32800,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 223 && - (declaration.parent.parent.kind === 212 || - declaration.parent.parent.kind === 213)) { + if (declaration.kind === 224 && + (declaration.parent.parent.kind === 213 || + declaration.parent.parent.kind === 214)) { return; } } @@ -32523,7 +32863,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - error(declaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + errorUnusedLocal(declaration.name, local.name); } } } @@ -32531,7 +32871,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 204) { + if (node.kind === 205) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -32575,6 +32915,11 @@ var ts; potentialThisCollisions.push(node); } } + function checkCollisionWithCapturedNewTargetVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_newTarget")) { + potentialNewTargetCollisions.push(node); + } + } function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; while (current) { @@ -32591,6 +32936,22 @@ var ts; current = current.parent; } } + function checkIfNewTargetIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 8) { + var isDeclaration_2 = node.kind !== 70; + if (isDeclaration_2) { + error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); + } + return; + } + current = current.parent; + } + } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -32600,8 +32961,8 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 70; - if (isDeclaration_2) { + var isDeclaration_3 = node.kind !== 70; + if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -32616,11 +32977,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 262 && ts.isExternalOrCommonJsModule(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)); } } @@ -32628,11 +32989,11 @@ var ts; if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 262 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -32640,7 +33001,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 223 && !node.initializer) { + if (node.kind === 224 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -32650,15 +33011,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 224); - var container = varDeclList.parent.kind === 205 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 225); + var container = varDeclList.parent.kind === 206 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 204 && ts.isFunctionLike(container.parent) || + (container.kind === 205 && ts.isFunctionLike(container.parent) || + container.kind === 232 || container.kind === 231 || - container.kind === 230 || - container.kind === 261); + container.kind === 262); if (!namesShareScope) { var name_23 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_23, name_23); @@ -32691,7 +33052,8 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144) { + if (symbol.valueDeclaration.kind === 144 || + symbol.valueDeclaration.kind === 174) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -32729,19 +33091,19 @@ var ts; } } if (node.kind === 174) { - if (node.parent.kind === 172 && languageVersion < 5) { + if (node.parent.kind === 172 && languageVersion < 5 && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4); } if (node.propertyName && node.propertyName.kind === 142) { checkComputedPropertyName(node.propertyName); } - var parent_10 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_10); + var parent_11 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_11); var name_24 = node.propertyName || node.name; var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_24)); markPropertyAsReferenced(property); - if (parent_10.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_10, parent_10.initializer, parentType, property); + if (parent_11.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { @@ -32752,7 +33114,7 @@ var ts; return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 213) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -32761,7 +33123,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 213) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -32781,18 +33143,19 @@ var ts; } if (node.kind !== 147 && node.kind !== 146) { checkExportsOnMergedDeclarations(node); - if (node.kind === 223 || node.kind === 174) { + if (node.kind === 224 || node.kind === 174) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 && right.kind === 223) || - (left.kind === 223 && right.kind === 144)) { + if ((left.kind === 144 && right.kind === 224) || + (left.kind === 224 && right.kind === 144)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -32838,7 +33201,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 206) { + if (node.thenStatement.kind === 207) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -32855,12 +33218,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 224) { + if (node.initializer && node.initializer.kind === 225) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -32878,7 +33241,7 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { checkForInOrForOfVariableDeclaration(node); } else { @@ -32903,7 +33266,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { 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); @@ -33160,7 +33523,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 254 && !hasDuplicateDefaultClause) { + if (clause.kind === 255 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -33172,7 +33535,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 253) { + if (produceDiagnostics && clause.kind === 254) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); var caseIsLiteral = isLiteralType(caseType); @@ -33198,7 +33561,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 219 && current.label.text === node.label.text) { + if (current.kind === 220 && 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; @@ -33321,7 +33684,7 @@ var ts; } function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { @@ -33341,7 +33704,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 || declaration.kind === 227) { + if (declaration.kind === 227 || declaration.kind === 228) { if (!firstDecl) { firstDecl = declaration; } @@ -33374,6 +33737,7 @@ var ts; if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -33409,7 +33773,7 @@ var ts; checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 226) { + baseType_1.symbol.valueDeclaration.kind === 227) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -33536,7 +33900,7 @@ var ts; if (!list1 || !list2 || list1.length !== list2.length) { return false; } - for (var i = 0, len = list1.length; i < len; i++) { + for (var i = 0; i < list1.length; i++) { var tp1 = list1[i]; var tp2 = list2[i]; if (tp1.name.text !== tp2.name.text) { @@ -33594,7 +33958,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 228); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -33725,6 +34089,7 @@ var ts; } return undefined; case 8: + checkGrammarNumericLiteral(e); return +e.text; case 183: return evalConstant(e.expression); @@ -33798,6 +34163,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); @@ -33818,7 +34184,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 229) { + if (declaration.kind !== 230) { return false; } var enumDeclaration = declaration; @@ -33841,8 +34207,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 226 || - (declaration.kind === 225 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 227 || + (declaration.kind === 226 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -33901,7 +34267,7 @@ 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, 226); + var mergedClass = ts.getDeclarationOfKind(symbol, 227); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -33944,22 +34310,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 205: + case 206: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 240: case 241: + case 242: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 234: case 235: + case 236: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; case 174: - case 223: + case 224: var name_25 = node.name; if (ts.isBindingPattern(name_25)) { for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { @@ -33968,12 +34334,12 @@ var ts; } break; } - case 226: - case 229: - case 225: case 227: case 230: + case 226: case 228: + case 231: + case 229: if (isGlobalAugmentation) { return; } @@ -34009,9 +34375,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { - error(moduleName, node.kind === 241 ? + var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 && !inAmbientExternalModule) { + error(moduleName, node.kind === 242 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -34032,7 +34398,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 243 ? + var message = node.kind === 244 ? 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)); @@ -34059,7 +34425,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237) { + if (importClause.namedBindings.kind === 238) { checkImportBinding(importClause.namedBindings); } else { @@ -34110,8 +34476,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -34124,7 +34490,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 261 || node.parent.kind === 231 || node.parent.kind === 230; + var isInAppropriateContext = node.parent.kind === 262 || node.parent.kind === 232 || node.parent.kind === 231; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -34147,9 +34513,14 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 261 ? node.parent : node.parent.parent; - if (container.kind === 230 && !ts.isAmbientModule(container)) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + var container = node.parent.kind === 262 ? node.parent : node.parent.parent; + if (container.kind === 231 && !ts.isAmbientModule(container)) { + if (node.isExportEquals) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + } + else { + error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); + } return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { @@ -34215,7 +34586,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 225 && declaration.kind !== 149) || + return (declaration.kind !== 226 && declaration.kind !== 149) || !!declaration.body; } } @@ -34226,10 +34597,10 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 230: - case 226: + case 231: case 227: - case 225: + case 228: + case 226: cancellationToken.throwIfCancellationRequested(); } } @@ -34278,71 +34649,71 @@ var ts; return checkIndexedAccessType(node); case 170: return checkMappedType(node); - case 225: + case 226: return checkFunctionDeclaration(node); - case 204: - case 231: - return checkBlock(node); case 205: + case 232: + return checkBlock(node); + case 206: return checkVariableStatement(node); - case 207: - return checkExpressionStatement(node); case 208: - return checkIfStatement(node); + return checkExpressionStatement(node); case 209: - return checkDoStatement(node); + return checkIfStatement(node); case 210: - return checkWhileStatement(node); + return checkDoStatement(node); case 211: - return checkForStatement(node); + return checkWhileStatement(node); case 212: - return checkForInStatement(node); + return checkForStatement(node); case 213: - return checkForOfStatement(node); + return checkForInStatement(node); case 214: + return checkForOfStatement(node); case 215: - return checkBreakOrContinueStatement(node); case 216: - return checkReturnStatement(node); + return checkBreakOrContinueStatement(node); case 217: - return checkWithStatement(node); + return checkReturnStatement(node); case 218: - return checkSwitchStatement(node); + return checkWithStatement(node); case 219: - return checkLabeledStatement(node); + return checkSwitchStatement(node); case 220: - return checkThrowStatement(node); + return checkLabeledStatement(node); case 221: + return checkThrowStatement(node); + case 222: return checkTryStatement(node); - case 223: + case 224: return checkVariableDeclaration(node); case 174: return checkBindingElement(node); - case 226: - return checkClassDeclaration(node); case 227: - return checkInterfaceDeclaration(node); + return checkClassDeclaration(node); case 228: - return checkTypeAliasDeclaration(node); + return checkInterfaceDeclaration(node); case 229: - return checkEnumDeclaration(node); + return checkTypeAliasDeclaration(node); case 230: + return checkEnumDeclaration(node); + case 231: return checkModuleDeclaration(node); - case 235: + case 236: return checkImportDeclaration(node); - case 234: + case 235: return checkImportEqualsDeclaration(node); - case 241: + case 242: return checkExportDeclaration(node); - case 240: + case 241: return checkExportAssignment(node); - case 206: + case 207: checkGrammarStatementInAmbientContext(node); return; - case 222: + case 223: checkGrammarStatementInAmbientContext(node); return; - case 244: + case 245: return checkMissingDeclaration(node); } } @@ -34385,6 +34756,7 @@ var ts; } checkGrammarSourceFile(node); potentialThisCollisions.length = 0; + potentialNewTargetCollisions.length = 0; deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; ts.forEach(node.statements, checkSourceElement); @@ -34404,6 +34776,10 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } + if (potentialNewTargetCollisions.length) { + ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); + potentialNewTargetCollisions.length = 0; + } links.flags |= 1; } } @@ -34448,7 +34824,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 217 && node.parent.statement === node) { + if (node.parent.kind === 218 && node.parent.statement === node) { return true; } node = node.parent; @@ -34470,14 +34846,14 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230: + case 231: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 229: + case 230: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; case 197: @@ -34485,8 +34861,8 @@ var ts; if (className) { copySymbol(location.symbol, meaning); } - case 226: case 227: + case 228: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } @@ -34531,10 +34907,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 143: - case 226: case 227: case 228: case 229: + case 230: return true; } } @@ -34543,7 +34919,7 @@ var ts; while (node.parent && node.parent.kind === 141) { node = node.parent; } - return node.parent && (node.parent.kind === 157 || node.parent.kind === 272); + return node.parent && (node.parent.kind === 157 || node.parent.kind === 273); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; @@ -34570,10 +34946,10 @@ var ts; while (nodeOnRightSide.parent.kind === 141) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 234) { + if (nodeOnRightSide.parent.kind === 235) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 240) { + if (nodeOnRightSide.parent.kind === 241) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -34597,11 +34973,11 @@ var ts; default: } } - if (entityName.parent.kind === 240 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 241 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } if (entityName.kind !== 177 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 234); + var importEqualsDeclaration = ts.getAncestor(entityName, 235); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -34648,10 +35024,10 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 272) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 273) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 250) { + else if (entityName.parent.kind === 251) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 156) { @@ -34660,7 +35036,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 261) { + if (node.kind === 262) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -34713,7 +35089,7 @@ var ts; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 235 || node.parent.kind === 241) && + ((node.parent.kind === 236 || node.parent.kind === 242) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -34735,7 +35111,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 258) { + if (location && location.kind === 259) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -34786,7 +35162,7 @@ var ts; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { ts.Debug.assert(expr.kind === 176 || expr.kind === 175); - if (expr.parent.kind === 213) { + if (expr.parent.kind === 214) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -34794,7 +35170,7 @@ var ts; var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 257) { + if (expr.parent.kind === 258) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } @@ -34905,7 +35281,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 261) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 262) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -34943,7 +35319,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 204 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 205 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -34983,16 +35359,16 @@ var ts; return true; } switch (node.kind) { - case 234: - case 236: + case 235: case 237: - case 239: - case 243: + case 238: + case 240: + case 244: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 241: + case 242: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 240: + case 241: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -35002,7 +35378,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 261 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 262 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -35053,7 +35429,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 260) { + if (node.kind === 261) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -35147,9 +35523,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_11 = reference.parent; - if (ts.isDeclaration(parent_11) && reference === parent_11.name) { - location = getDeclarationContainer(parent_11); + var parent_12 = reference.parent; + if (ts.isDeclaration(parent_12) && reference === parent_12.name) { + location = getDeclarationContainer(parent_12); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -35262,15 +35638,15 @@ var ts; } var current = symbol; while (true) { - var parent_12 = getParentOfSymbol(current); - if (parent_12) { - current = parent_12; + var parent_13 = getParentOfSymbol(current); + if (parent_13) { + current = parent_13; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 261 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 262 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -35289,7 +35665,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 261); + return ts.getDeclarationOfKind(moduleSymbol, 262); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -35466,7 +35842,7 @@ var ts; } switch (modifier.kind) { case 75: - if (node.kind !== 229 && node.parent.kind === 226) { + if (node.kind !== 230 && node.parent.kind === 227) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -35492,7 +35868,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 232 || node.parent.kind === 262) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -35515,7 +35891,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 232 || node.parent.kind === 262) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 144) { @@ -35550,7 +35926,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 144) { @@ -35565,13 +35941,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 231) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 232) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -35581,14 +35957,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 226) { + if (node.kind !== 227) { if (node.kind !== 149 && node.kind !== 147 && node.kind !== 151 && node.kind !== 152) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 226 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 227 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -35630,7 +36006,7 @@ var ts; } return; } - else if ((node.kind === 235 || node.kind === 234) && flags & 2) { + else if ((node.kind === 236 || node.kind === 235) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 144 && (flags & 92) && ts.isBindingPattern(node.name)) { @@ -35660,29 +36036,29 @@ var ts; case 149: case 148: case 155: - case 230: + case 231: + case 236: case 235: - case 234: + case 242: case 241: - case 240: case 184: case 185: case 144: return false; default: - if (node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 232 || node.parent.kind === 262) { return false; } switch (node.kind) { - case 225: - return nodeHasAnyModifiersExcept(node, 119); case 226: - return nodeHasAnyModifiersExcept(node, 116); + return nodeHasAnyModifiersExcept(node, 119); case 227: - case 205: + return nodeHasAnyModifiersExcept(node, 116); case 228: - return true; + case 206: case 229: + return true; + case 230: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -35696,7 +36072,7 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 149: - case 225: + case 226: case 184: case 185: if (!node.asteriskToken) { @@ -35902,7 +36278,7 @@ var ts; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 225 || + ts.Debug.assert(node.kind === 226 || node.kind === 184 || node.kind === 149); if (ts.isInAmbientContext(node)) { @@ -35929,14 +36305,14 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259) { + if (prop.kind === 260) { continue; } var name_28 = prop.name; if (name_28.kind === 142) { checkGrammarComputedPropertyName(name_28); } - if (prop.kind === 258 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 259 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { @@ -35948,7 +36324,7 @@ var ts; } } var currentKind = void 0; - if (prop.kind === 257 || prop.kind === 258) { + if (prop.kind === 258 || prop.kind === 259) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_28.kind === 8) { checkGrammarNumericLiteral(name_28); @@ -35997,7 +36373,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 251) { + if (attr.kind === 252) { continue; } var jsxAttr = attr; @@ -36009,7 +36385,7 @@ var ts; return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 252 && !initializer.expression) { + if (initializer && initializer.kind === 253 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -36018,7 +36394,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 224) { + if (forInOrOfStatement.initializer.kind === 225) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -36026,20 +36402,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? 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 = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? 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 === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? 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); @@ -36123,7 +36499,7 @@ 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 === 227) { + else if (node.parent.kind === 228) { 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 === 161) { @@ -36137,9 +36513,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 219: + case 220: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 214 + var isMisplacedContinueLabel = node.kind === 215 && !ts.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); @@ -36147,8 +36523,8 @@ var ts; return false; } break; - case 218: - if (node.kind === 215 && !node.label) { + case 219: + if (node.kind === 216 && !node.label) { return false; } break; @@ -36161,13 +36537,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 215 + var message = node.kind === 216 ? 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 === 215 + var message = node.kind === 216 ? 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); @@ -36193,7 +36569,7 @@ var ts; expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 212 && node.parent.parent.kind !== 213) { + if (node.parent.parent.kind !== 213 && node.parent.parent.kind !== 214) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -36250,15 +36626,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 208: case 209: case 210: - case 217: case 211: + case 218: case 212: case 213: + case 214: return false; - case 219: + case 220: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -36273,6 +36649,13 @@ var ts; } } } + function checkGrammarMetaProperty(node) { + if (node.keywordToken === 93) { + if (node.name.text !== "target") { + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + } + } + } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -36313,7 +36696,7 @@ var ts; return true; } } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 228) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -36334,13 +36717,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 227 || - node.kind === 228 || + if (node.kind === 228 || + node.kind === 229 || + node.kind === 236 || node.kind === 235 || - node.kind === 234 || + node.kind === 242 || node.kind === 241 || - node.kind === 240 || - node.kind === 233 || + node.kind === 234 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -36349,7 +36732,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 === 205) { + if (ts.isDeclaration(decl) || decl.kind === 206) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -36368,7 +36751,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 === 204 || node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 205 || node.parent.kind === 232 || node.parent.kind === 262) { 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); @@ -36379,8 +36762,22 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.isOctalLiteral && languageVersion >= 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + if (node.isOctalLiteral) { + var diagnosticMessage = void 0; + if (languageVersion >= 1) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 171)) { + diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 261)) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; + } + if (diagnosticMessage) { + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37; + var literal = (withMinus ? "-" : "") + "0o" + node.text; + return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); + } } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -36425,31 +36822,31 @@ var ts; _a[201] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[229] = [ + _a[230] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[230] = [ + _a[231] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[231] = [ + _a[232] = [ { name: "statements", test: ts.isStatement } ], - _a[234] = [ + _a[235] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[245] = [ + _a[246] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[260] = [ + _a[261] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -36475,11 +36872,11 @@ var ts; } var result = initial; switch (node.kind) { - case 203: - case 206: + case 204: + case 207: case 198: - case 222: - case 293: + case 223: + case 294: break; case 142: result = reduceNode(node.expression, cbNode, result); @@ -36620,72 +37017,72 @@ var ts; result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 202: + case 203: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 204: + case 205: result = reduceNodes(node.statements, cbNodes, result); break; - case 205: + case 206: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 207: + case 208: result = reduceNode(node.expression, cbNode, result); break; - case 208: + case 209: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 209: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; case 210: - case 217: - result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); break; case 211: + case 218: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 212: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 212: case 213: + case 214: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 216: - case 220: + case 217: + case 221: result = reduceNode(node.expression, cbNode, result); break; - case 218: + case 219: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 219: + case 220: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 221: + case 222: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 223: + case 224: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 224: + case 225: result = reduceNodes(node.declarations, cbNodes, result); break; - case 225: + case 226: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -36694,7 +37091,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 226: + case 227: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -36702,92 +37099,92 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 232: + case 233: result = reduceNodes(node.clauses, cbNodes, result); break; - case 235: + case 236: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 236: + case 237: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 237: - result = reduceNode(node.name, cbNode, result); - break; case 238: - case 242: - result = reduceNodes(node.elements, cbNodes, result); + result = reduceNode(node.name, cbNode, result); break; case 239: case 243: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 240: + case 244: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 240: + case 241: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 241: + case 242: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 246: + case 247: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 247: case 248: + case 249: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.attributes, cbNodes, result); break; - case 249: + case 250: result = reduceNode(node.tagName, cbNode, result); break; - case 250: + case 251: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 251: - result = reduceNode(node.expression, cbNode, result); - break; case 252: result = reduceNode(node.expression, cbNode, result); break; case 253: result = reduceNode(node.expression, cbNode, result); + break; case 254: + result = reduceNode(node.expression, cbNode, result); + case 255: result = reduceNodes(node.statements, cbNodes, result); break; - case 255: + case 256: result = reduceNodes(node.types, cbNodes, result); break; - case 256: + case 257: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 257: + case 258: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 258: + case 259: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 259: + case 260: result = reduceNode(node.expression, cbNode, result); break; - case 261: + case 262: result = reduceNodes(node.statements, cbNodes, result); break; - case 294: + case 295: result = reduceNode(node.expression, cbNode, result); break; default: @@ -36928,10 +37325,10 @@ var ts; return node; } switch (node.kind) { - case 203: - case 206: + case 204: + case 207: case 198: - case 222: + case 223: return node; case 142: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); @@ -36999,101 +37396,101 @@ var ts; return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); case 199: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 202: + case 203: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 204: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); case 205: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 206: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 207: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 208: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 209: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); case 210: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); case 211: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 212: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 213: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 214: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 215: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 216: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 217: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); case 218: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 219: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); case 220: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 221: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 222: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); - case 223: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 224: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 225: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); case 226: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 227: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 232: + case 233: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 235: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 236: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 237: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 238: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 239: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 240: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 241: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 242: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); case 243: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 244: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 246: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 247: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 248: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 249: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 250: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); case 251: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 252: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 253: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 254: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); case 255: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); case 256: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); case 257: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); case 258: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); case 259: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 260: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); - case 261: + case 262: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 294: + case 295: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -37181,7 +37578,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || ts.isTypeNode(node)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 199)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -37585,15 +37982,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 261: + case 262: + case 233: case 232: - case 231: - case 204: + case 205: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 227: case 226: - case 225: if (ts.hasModifier(node, 2)) { break; } @@ -37618,13 +38015,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 240: - return visitExportAssignment(node); case 241: + return visitExportAssignment(node); + case 242: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -37634,11 +38031,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 241 || - node.kind === 235 || + if (node.kind === 242 || node.kind === 236 || - (node.kind === 234 && - node.moduleReference.kind === 245)) { + node.kind === 237 || + (node.kind === 235 && + node.moduleReference.kind === 246)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -37662,7 +38059,7 @@ var ts; case 152: case 149: return visitorWorker(node); - case 203: + case 204: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -37719,18 +38116,18 @@ var ts; case 171: case 155: case 145: - case 228: + case 229: case 147: return undefined; case 150: return visitConstructor(node); - case 227: + case 228: return ts.createNotEmittedStatement(node); - case 226: + case 227: return visitClassDeclaration(node); case 197: return visitClassExpression(node); - case 255: + case 256: return visitHeritageClause(node); case 199: return visitExpressionWithTypeArguments(node); @@ -37740,7 +38137,7 @@ var ts; return visitGetAccessor(node); case 152: return visitSetAccessor(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -37759,15 +38156,15 @@ var ts; return visitNewExpression(node); case 201: return visitNonNullExpression(node); - case 229: - return visitEnumDeclaration(node); - case 205: - return visitVariableStatement(node); - case 223: - return visitVariableDeclaration(node); case 230: + return visitEnumDeclaration(node); + case 206: + return visitVariableStatement(node); + case 224: + return visitVariableDeclaration(node); + case 231: return visitModuleDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -37921,7 +38318,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -38206,7 +38603,7 @@ var ts; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 226: + case 227: case 197: return ts.getFirstConstructorWithBody(node) !== undefined; case 149: @@ -38224,7 +38621,7 @@ var ts; return serializeTypeNode(node.type); case 152: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 226: + case 227: case 197: case 149: return ts.createIdentifier("Function"); @@ -38281,6 +38678,9 @@ var ts; } switch (node.kind) { case 104: + case 137: + case 94: + case 129: return ts.createVoidZero(); case 166: return serializeTypeNode(node.type); @@ -38319,29 +38719,7 @@ var ts; return serializeTypeReferenceNode(node); case 165: case 164: - { - var unionOrIntersection = node; - var serializedUnion = void 0; - for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - var serializedIndividual = serializeTypeNode(typeNode); - if (serializedIndividual.kind !== 70) { - serializedUnion = undefined; - break; - } - if (serializedIndividual.text === "Object") { - return serializedIndividual; - } - if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { - serializedUnion = undefined; - break; - } - serializedUnion = serializedIndividual; - } - if (serializedUnion) { - return serializedUnion; - } - } + return serializeUnionOrIntersectionType(node); case 160: case 168: case 169: @@ -38356,6 +38734,32 @@ var ts; } return ts.createIdentifier("Object"); } + function serializeUnionOrIntersectionType(node) { + var serializedUnion; + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (ts.isVoidExpression(serializedIndividual)) { + if (!serializedUnion) { + serializedUnion = serializedIndividual; + } + } + else if (ts.isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") { + return serializedIndividual; + } + else if (serializedUnion && !ts.isVoidExpression(serializedUnion)) { + if (!ts.isIdentifier(serializedUnion) || + !ts.isIdentifier(serializedIndividual) || + serializedUnion.text !== serializedIndividual.text) { + return ts.createIdentifier("Object"); + } + } + else { + serializedUnion = serializedIndividual; + } + } + return serializedUnion; + } function serializeTypeReferenceNode(node) { switch (resolver.getTypeReferenceSerializationKind(node.typeName, currentScope)) { case ts.TypeReferenceSerializationKind.Unknown: @@ -38682,7 +39086,7 @@ var ts; ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 229) { + if (node.kind === 230) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -38742,8 +39146,8 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 231) { - ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); + if (body.kind === 232) { + saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; } @@ -38765,13 +39169,13 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 231) { + if (body.kind !== 232) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 230) { + if (moduleDeclaration.body.kind === 231) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -38791,7 +39195,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 237) { + if (node.kind === 238) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -38926,15 +39330,15 @@ var ts; if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(258); - context.enableEmitNotification(230); + context.enableSubstitution(259); + context.enableEmitNotification(231); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 230; + return ts.getOriginalNode(node).kind === 231; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 229; + return ts.getOriginalNode(node).kind === 230; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -39007,9 +39411,9 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 261) { - var substitute = (applicableSubstitutions & 2 && container.kind === 230) || - (applicableSubstitutions & 8 && container.kind === 229); + if (container && container.kind !== 262) { + var substitute = (applicableSubstitutions & 2 && container.kind === 231) || + (applicableSubstitutions & 8 && container.kind === 230); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -39124,11 +39528,11 @@ var ts; return visitObjectLiteralExpression(node); case 192: return visitBinaryExpression(node, noDestructuringValue); - case 223: + case 224: return visitVariableDeclaration(node); - case 213: + case 214: return visitForOfStatement(node); - case 211: + case 212: return visitForStatement(node); case 188: return visitVoidExpression(node); @@ -39140,7 +39544,7 @@ var ts; return visitGetAccessorDeclaration(node); case 152: return visitSetAccessorDeclaration(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -39148,7 +39552,7 @@ var ts; return visitArrowFunction(node); case 144: return visitParameter(node); - case 207: + case 208: return visitExpressionStatement(node); case 183: return visitParenthesizedExpression(node, noDestructuringValue); @@ -39161,7 +39565,7 @@ var ts; var objects = []; for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { var e = elements_3[_i]; - if (e.kind === 259) { + if (e.kind === 260) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -39173,7 +39577,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 257) { + if (e.kind === 258) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -39346,11 +39750,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 246: - return visitJsxElement(node, false); case 247: + return visitJsxElement(node, false); + case 248: return visitJsxSelfClosingElement(node, false); - case 252: + case 253: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -39360,11 +39764,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 252: + case 253: return visitJsxExpression(node); - case 246: - return visitJsxElement(node, true); case 247: + return visitJsxElement(node, true); + case 248: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -39418,7 +39822,10 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, node) : node; } - else if (node.kind === 252) { + else if (node.kind === 253) { + if (node.expression === undefined) { + return ts.createLiteral(true); + } return visitJsxExpression(node); } else { @@ -39483,7 +39890,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 246) { + if (node.kind === 247) { return getTagName(node.openingElement); } else { @@ -39802,7 +40209,7 @@ var ts; return visitAwaitExpression(node); case 149: return visitMethodDeclaration(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -39901,7 +40308,7 @@ var ts; context.enableSubstitution(179); context.enableSubstitution(177); context.enableSubstitution(178); - context.enableEmitNotification(226); + context.enableEmitNotification(227); context.enableEmitNotification(149); context.enableEmitNotification(151); context.enableEmitNotification(152); @@ -39957,7 +40364,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 226 + return kind === 227 || kind === 150 || kind === 149 || kind === 151 @@ -40096,15 +40503,7 @@ var ts; context.onSubstituteNode = onSubstituteNode; var currentSourceFile; var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - var isInConstructorWithCapturedSuper; + var hierarchyFacts; var convertedLoopState; var enabledSubstitutions; return transformSourceFile; @@ -40114,178 +40513,104 @@ var ts; } currentSourceFile = node; currentText = node.text; - var visited = saveStateAndInvoke(node, visitSourceFile); + var visited = visitSourceFile(node); ts.addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined; currentText = undefined; + hierarchyFacts = 0; return visited; } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); + function enterSubtree(excludeFacts, includeFacts) { + var ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383; + return ancestorFacts; } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - isInConstructorWithCapturedSuper = false; - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 185) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 131072)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - switch (currentNode.kind) { - case 205: - enclosingVariableStatement = currentNode; - break; - case 224: - case 223: - case 174: - case 172: - case 173: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function returnCapturedThis(node) { - return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 216 && !node.expression; + return hierarchyFacts & 4096 + && node.kind === 217 + && !node.expression; } - function shouldCheckNode(node) { - return (node.transformFlags & 64) !== 0 || - node.kind === 219 || - (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); + function shouldVisitNode(node) { + return (node.transformFlags & 128) !== 0 + || convertedLoopState !== undefined + || (hierarchyFacts & 4096 && ts.isStatement(node)) + || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } - function visitorWorker(node) { - if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { - return returnCapturedThis(node); - } - else if (shouldCheckNode(node)) { + function visitor(node) { + if (shouldVisitNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { - return ts.visitEachChild(node, visitor, context); - } else { return node; } } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function functionBodyVisitor(node) { + if (shouldVisitNode(node)) { + return visitBlock(node, true); } - else { - result = visitNodesInConvertedLoop(node); - } - return result; + return node; } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 216: - node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; - return visitReturnStatement(node); - case 205: - return visitVariableStatement(node); - case 218: - return visitSwitchStatement(node); - case 215: - case 214: - return visitBreakOrContinueStatement(node); - case 98: - return visitThisKeyword(node); - case 70: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); + function callExpressionVisitor(node) { + if (node.kind === 96) { + return visitSuperKeyword(true); } + return visitor(node); } function visitJavaScript(node) { switch (node.kind) { case 114: return undefined; - case 226: + case 227: return visitClassDeclaration(node); case 197: return visitClassExpression(node); case 144: return visitParameter(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 185: return visitArrowFunction(node); case 184: return visitFunctionExpression(node); - case 223: + case 224: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 224: + case 225: return visitVariableDeclarationList(node); case 219: + return visitSwitchStatement(node); + case 233: + return visitCaseBlock(node); + case 205: + return visitBlock(node, false); + case 216: + case 215: + return visitBreakOrContinueStatement(node); + case 220: return visitLabeledStatement(node); - case 209: - return visitDoStatement(node); case 210: - return visitWhileStatement(node); case 211: - return visitForStatement(node); + return visitDoOrWhileStatement(node, undefined); case 212: - return visitForInStatement(node); + return visitForStatement(node, undefined); case 213: - return visitForOfStatement(node); - case 207: + return visitForInStatement(node, undefined); + case 214: + return visitForOfStatement(node, undefined); + case 208: return visitExpressionStatement(node); case 176: return visitObjectLiteralExpression(node); - case 256: + case 257: return visitCatchClause(node); - case 258: + case 259: return visitShorthandPropertyAssignment(node); + case 142: + return visitComputedPropertyName(node); case 175: return visitArrayLiteralExpression(node); case 179: @@ -40310,51 +40635,80 @@ var ts; case 196: return visitSpreadElement(node); case 96: - return visitSuperKeyword(); - case 195: - return ts.visitEachChild(node, visitor, context); + return visitSuperKeyword(false); + case 98: + return visitThisKeyword(node); + case 202: + return visitMetaProperty(node); case 149: return visitMethodDeclaration(node); - case 205: + case 151: + case 152: + return visitAccessorDeclaration(node); + case 206: return visitVariableStatement(node); + case 217: + return visitReturnStatement(node); default: - ts.Debug.failBadSyntaxKind(node); return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { + var ancestorFacts = enterSubtree(3968, 64); var statements = []; startLexicalEnvironment(); var statementOffset = ts.addPrologueDirectives(statements, node.statements, false, visitor); addCaptureThisForNodeIfNeeded(statements, node); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); + exitSubtree(ancestorFacts, 0, 0); return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); } function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps |= 2; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; + if (convertedLoopState !== undefined) { + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps |= 2; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitCaseBlock(node) { + var ancestorFacts = enterSubtree(4032, 0); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8; + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + node = returnCapturedThis(node); + } + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 185) { - convertedLoopState.containsLexicalThis = true; - return node; + if (convertedLoopState) { + if (hierarchyFacts & 2) { + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + return node; } function visitIdentifier(node) { if (!convertedLoopState) { @@ -40370,13 +40724,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 215 ? 2 : 4; + var jump = node.kind === 216 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 215) { + if (node.kind === 216) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -40386,7 +40740,7 @@ var ts; } } else { - if (node.kind === 215) { + if (node.kind === 216) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -40485,6 +40839,9 @@ var ts; } } function addConstructor(statements, node, extendsClauseElement) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16278, 73); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); @@ -40492,6 +40849,8 @@ var ts; ts.setEmitFlags(constructorFunction, 8); } statements.push(constructorFunction); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; } function transformConstructorParameters(constructor, hasSynthesizedSuper) { return ts.visitParameterList(constructor && !hasSynthesizedSuper && constructor.parameters, visitor, context) @@ -40512,23 +40871,26 @@ var ts; addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94; + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); if (superCaptureStatus === 1 || superCaptureStatus === 2) { statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { - isInConstructorWithCapturedSuper = superCaptureStatus === 1; - return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); - }); - ts.addRange(statements, body); + if (superCaptureStatus === 1) { + hierarchyFacts |= 4096; + } + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset)); } - if (extendsClauseElement + if (isDerivedClass && superCaptureStatus !== 2 && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createIdentifier("_this"))); } ts.addRange(statements, endLexicalEnvironment()); + if (constructor) { + prependCaptureNewTargetIfNeeded(statements, constructor, false); + } var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); if (!constructor) { ts.setEmitFlags(block, 1536); @@ -40536,17 +40898,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 216) { + if (statement.kind === 217) { return true; } - else if (statement.kind === 208) { + else if (statement.kind === 209) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 204) { + else if (statement.kind === 205) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -40554,8 +40916,8 @@ var ts; } return false; } - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { - if (!hasExtendsClause) { + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, isDerivedClass, hasSynthesizedSuper, statementOffset) { + if (!isDerivedClass) { if (ctor) { addCaptureThisForNodeIfNeeded(statements, ctor); } @@ -40575,9 +40937,8 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 207 && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + if (firstStatement.kind === 208 && ts.isSuperCall(firstStatement.expression)) { + superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } if (superCallExpression @@ -40592,17 +40953,17 @@ var ts; statements.push(returnStatement); return 2; } - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); if (superCallExpression) { return 1; } return 0; } + function createActualThis() { + return ts.setEmitFlags(ts.createThis(), 4); + } function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 4); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); + return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createIdentifier("_super"), ts.createNull()), ts.createFunctionApply(ts.createIdentifier("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis()); } function visitParameter(node) { if (node.dotDotDotToken) { @@ -40698,21 +41059,53 @@ var ts; ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } + function prependCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { + if (hierarchyFacts & 16384) { + var newTarget = void 0; + switch (node.kind) { + case 185: + return statements; + case 149: + case 151: + case 152: + newTarget = ts.createVoidZero(); + break; + case 150: + newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); + break; + case 226: + case 184: + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 92, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + var captureNewTargetStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_newTarget", undefined, newTarget) + ])); + if (copyOnWrite) { + return [captureNewTargetStatement].concat(statements); + } + statements.unshift(captureNewTargetStatement); + } + return statements; + } function addClassMembers(statements, node) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 203: + case 204: statements.push(transformSemicolonClassElementToStatement(member)); break; case 149: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case 151: case 152: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; case 150: @@ -40726,26 +41119,29 @@ var ts; function transformSemicolonClassElementToStatement(member) { return ts.createEmptyStatement(member); } - function transformClassMethodDeclarationToStatement(receiver, member) { + function transformClassMethodDeclarationToStatement(receiver, member, container) { + var ancestorFacts = enterSubtree(0, 0); var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name); - var memberFunction = transformFunctionLikeToExpression(member, member, undefined); + var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container); ts.setEmitFlags(memberFunction, 1536); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); ts.setEmitFlags(statement, 48); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return statement; } - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), ts.getSourceMapRange(accessors.firstAccessor)); + function transformAccessorsToStatement(receiver, accessors, container) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, false), ts.getSourceMapRange(accessors.firstAccessor)); ts.setEmitFlags(statement, 1536); return statement; } - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var ancestorFacts = enterSubtree(0, 0); var target = ts.getMutableClone(receiver); ts.setEmitFlags(target, 1536 | 32); ts.setSourceMapRange(target, firstAccessor.name); @@ -40754,7 +41150,7 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); + var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); ts.setEmitFlags(getterFunction, 512); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -40762,7 +41158,7 @@ var ts; properties.push(getter); } if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); + var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); ts.setEmitFlags(setterFunction, 512); var setter = ts.createPropertyAssignment("set", setterFunction); @@ -40778,35 +41174,69 @@ var ts; if (startsOnNewLine) { call.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return call; } function visitArrowFunction(node) { if (node.transformFlags & 16384) { enableSubstitutionsForCapturedThis(); } + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16256, 66); var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8); + exitSubtree(ancestorFacts, 0, 0); + convertedLoopState = savedConvertedLoopState; return func; } function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var ancestorFacts = ts.getEmitFlags(node) & 131072 + ? enterSubtree(16278, 69) + : enterSubtree(16286, 65); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionExpression(node, undefined, name, undefined, parameters, undefined, body); } function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, parameters, undefined, body); } - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 185) { - enclosingNonArrowFunction = node; + function transformFunctionLikeToExpression(node, location, name, container) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32) + ? enterSubtree(16286, 65 | 8) + : enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (hierarchyFacts & 16384 && !name && (node.kind === 226 || node.kind === 184)) { + name = ts.getGeneratedNameForNode(node); } - var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body, location), node); } function transformFunctionBody(node) { var multiLine = false; @@ -40853,6 +41283,7 @@ var ts; } var lexicalEnvironment = context.endLexicalEnvironment(); ts.addRange(statements, lexicalEnvironment); + prependCaptureNewTargetIfNeeded(statements, node, false); if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; } @@ -40866,6 +41297,21 @@ var ts; ts.setOriginalNode(block, node.body); return block; } + function visitFunctionBodyDownLevel(node) { + var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); + return ts.updateBlock(updated, ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, true), updated.statements)); + } + function visitBlock(node, isFunctionBody) { + if (isFunctionBody) { + return ts.visitEachChild(node, visitor, context); + } + var ancestorFacts = hierarchyFacts & 256 + ? enterSubtree(4032, 512) + : enterSubtree(3904, 128); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } function visitExpressionStatement(node) { switch (node.expression.kind) { case 183: @@ -40890,9 +41336,12 @@ var ts; if (ts.isDestructuringAssignment(node)) { return ts.flattenDestructuringAssignment(node, visitor, context, 0, needsDestructuringValue); } + return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3) == 0) { + var ancestorFacts = enterSubtree(0, ts.hasModifier(node, 1) ? 32 : 0); + var updated; + if (convertedLoopState && (node.declarationList.flags & 3) === 0) { var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; @@ -40909,49 +41358,54 @@ var ts; } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); + updated = ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); } else { - return undefined; + updated = undefined; } } - return ts.visitEachChild(node, visitor, context); + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function visitVariableDeclarationList(node) { - if (node.flags & 3) { - enableSubstitutionsForBlockScopedBindings(); + if (node.transformFlags & 64) { + if (node.flags & 3) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations, node); + ts.setOriginalNode(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; + return ts.visitEachChild(node, visitor, context); } function shouldEmitExplicitInitializerForLetDeclaration(node) { var flags = resolver.getNodeCheckFlags(node); var isCapturedInFunction = flags & 131072; var isDeclaredInLoop = flags & 262144; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + var emittedAsTopLevel = (hierarchyFacts & 64) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); + && (hierarchyFacts & 512) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 212 - && enclosingBlockScopeContainer.kind !== 213 + && (hierarchyFacts & 2048) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, false))); + && (hierarchyFacts & (1024 | 2048)) === 0)); return emitExplicitInitializer; } function visitVariableDeclarationInLetDeclarationList(node) { @@ -40967,48 +41421,51 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableDeclaration(node) { + var ancestorFacts = enterSubtree(32, 0); + var updated; if (ts.isBindingPattern(node.name)) { - var hoistTempVariables = enclosingVariableStatement - && ts.hasModifier(enclosingVariableStatement, 1); - return ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, hoistTempVariables); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, (ancestorFacts & 32) !== 0); } else { - result = ts.visitEachChild(node, visitor, context); + updated = ts.visitEachChild(node, visitor, context); } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function recordLabel(node) { + convertedLoopState.labels[node.label.text] = node.label.text; + } + function resetLabel(node) { + convertedLoopState.labels[node.label.text] = undefined; + } + function visitLabeledStatement(node) { + if (convertedLoopState && !convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); } - return result; + var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, false) && shouldConvertIterationStatementBody(statement) + ? visitIterationStatement(statement, node) + : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { + var ancestorFacts = enterSubtree(excludeFacts, includeFacts); + var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); + exitSubtree(ancestorFacts, 0, 0); + return updated; } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitDoOrWhileStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(0, 256, node, outermostLabeledStatement); } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(3008, 1280, node, outermostLabeledStatement); } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForInStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement); } - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function visitForOfStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement, convertForOfToFor); } - function convertForOfToFor(node, convertedLoopBodyStatements) { + function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var initializer = node.initializer; var statements = []; @@ -41071,31 +41528,53 @@ var ts; ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) ], node.expression), 1048576), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); ts.setEmitFlags(forStatement, 256); - return forStatement; + return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); + } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 210: + case 211: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 212: + return visitForStatement(node, outermostLabeledStatement); + case 213: + return visitForInStatement(node, outermostLabeledStatement); + case 214: + return visitForOfStatement(node, outermostLabeledStatement); + } } function visitObjectLiteralExpression(node) { var properties = node.properties; var numProperties = properties.length; var numInitialProperties = numProperties; + var numInitialPropertiesWithoutYield = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 - || property.name.kind === 142) { + if ((property.transformFlags & 16777216 && hierarchyFacts & 4) + && i < numInitialPropertiesWithoutYield) { + numInitialPropertiesWithoutYield = i; + } + if (property.name.kind === 142) { numInitialProperties = i; break; } } - ts.Debug.assert(numInitialProperties !== numProperties); - var temp = ts.createTempVariable(hoistVariableDeclaration); - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); - if (node.multiLine) { - assignment.startsOnNewLine = true; + if (numInitialProperties !== numProperties) { + if (numInitialPropertiesWithoutYield < numInitialProperties) { + numInitialProperties = numInitialPropertiesWithoutYield; + } + var temp = ts.createTempVariable(hoistVariableDeclaration); + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); + return ts.visitEachChild(node, visitor, context); } function shouldConvertIterationStatementBody(node) { return (resolver.getNodeCheckFlags(node) & 65536) !== 0; @@ -41119,14 +41598,16 @@ var ts; } } } - function convertIterationStatementBodyIfNecessary(node, convert) { + function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) { if (!shouldConvertIterationStatementBody(node)) { var saveAllowedNonLabeledJumps = void 0; if (convertedLoopState) { saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; convertedLoopState.allowedNonLabeledJumps = 2 | 4; } - var result = convert ? convert(node, undefined) : ts.visitEachChild(node, visitor, context); + var result = convert + ? convert(node, outermostLabeledStatement, undefined) + : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); if (convertedLoopState) { convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } @@ -41135,11 +41616,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 211: case 212: case 213: + case 214: var initializer = node.initializer; - if (initializer && initializer.kind === 224) { + if (initializer && initializer.kind === 225) { loopInitializer = initializer; } break; @@ -41166,7 +41647,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -41178,11 +41659,13 @@ var ts; ts.addRange(statements_4, lexicalEnvironment); loopBody = ts.createBlock(statements_4, undefined, true); } - if (!ts.isBlock(loopBody)) { + if (ts.isBlock(loopBody)) { + loopBody.multiLine = true; + } + else { loopBody = ts.createBlock([loopBody], undefined, true); } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 131072) !== 0 + var isAsyncBlockContainingAwait = hierarchyFacts & 4 && (node.statement.transformFlags & 16777216) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -41241,19 +41724,18 @@ var ts; var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); var loop; if (convert) { - loop = convert(node, convertedLoopBodyStatements); + loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); } else { - loop = ts.getMutableClone(node); - loop.statement = undefined; - loop = ts.visitEachChild(loop, visitor, context); - loop.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); + var clone_4 = ts.getMutableClone(node); + clone_4.statement = undefined; + clone_4 = ts.visitEachChild(clone_4, visitor, context); + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); + clone_4.transformFlags = 0; + ts.aggregateTransformFlags(clone_4); + loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } - statements.push(currentParent.kind === 219 - ? ts.createLabel(currentParent.label, loop) - : loop); + statements.push(loop); return statements; } function copyOutParameter(outParam, copyDirection) { @@ -41367,17 +41849,17 @@ var ts; case 152: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 257: - expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); + case 149: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; case 258: - expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); + expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 149: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); + case 259: + expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: ts.Debug.failBadSyntaxKind(node); @@ -41399,21 +41881,31 @@ var ts; } return expression; } - function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined), method); + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { + var ancestorFacts = enterSubtree(0, 0); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container), method); if (startsOnNewLine) { expression.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return expression; } function visitCatchClause(node) { - ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); - var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); - var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); - var destructure = ts.createVariableStatement(undefined, list); - return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + var ancestorFacts = enterSubtree(4032, 0); + var updated; + if (ts.isBindingPattern(node.variableDeclaration.name)) { + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); + var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); + var destructure = ts.createVariableStatement(undefined, list); + updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); @@ -41421,21 +41913,43 @@ var ts; } function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); + var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined); ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression)); return ts.createPropertyAssignment(node.name, functionExpression, node); } + function visitAccessorDeclaration(node) { + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return updated; + } function visitShorthandPropertyAssignment(node) { return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), node); } + function visitComputedPropertyName(node) { + var ancestorFacts = enterSubtree(0, 8192); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 32768 : 0); + return updated; + } function visitYieldExpression(node) { return ts.visitEachChild(node, visitor, context); } function visitArrayLiteralExpression(node) { - return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + if (node.transformFlags & 64) { + return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + } + return ts.visitEachChild(node, visitor, context); } function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + if (node.transformFlags & 64) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + } + return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitImmediateSuperCallInBody(node) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); @@ -41447,25 +41961,27 @@ var ts; } var resultingCall; if (node.transformFlags & 524288) { - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } if (node.expression.kind === 96) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4); var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis + resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createIdentifier("_this"), initializer) : initializer; } - return resultingCall; + return ts.setOriginalNode(resultingCall, node); } function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 524288) !== 0); - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + if (node.transformFlags & 524288) { + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + } + return ts.visitEachChild(node, visitor, context); } function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { var numElements = elements.length; @@ -41563,21 +42079,34 @@ var ts; } } } - function visitSuperKeyword() { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 179 + function visitSuperKeyword(isExpressionOfCall) { + return hierarchyFacts & 8 + && !isExpressionOfCall ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } + function visitMetaProperty(node) { + if (node.keywordToken === 93 && node.name.text === "target") { + if (hierarchyFacts & 8192) { + hierarchyFacts |= 32768; + } + else { + hierarchyFacts |= 16384; + } + return ts.createIdentifier("_newTarget"); + } + return node; + } function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { - enclosingFunction = node; + var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8 + ? 65 | 16 + : 65); + previousOnEmitNode(emitContext, node, emitCallback); + exitSubtree(ancestorFacts, 0, 0); + return; } previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; } function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { @@ -41595,7 +42124,7 @@ var ts; context.enableEmitNotification(152); context.enableEmitNotification(185); context.enableEmitNotification(184); - context.enableEmitNotification(225); + context.enableEmitNotification(226); } } function onSubstituteNode(emitContext, node) { @@ -41621,9 +42150,9 @@ var ts; var parent = node.parent; switch (parent.kind) { case 174: - case 226: - case 229: - case 223: + case 227: + case 230: + case 224: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -41649,8 +42178,7 @@ var ts; } function substituteThisKeyword(node) { if (enabledSubstitutions & 1 - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 8) { + && hierarchyFacts & 16) { return ts.createIdentifier("_this", node); } return node; @@ -41667,7 +42195,7 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 207) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 208) { return false; } var statementExpression = statement.expression; @@ -41698,7 +42226,7 @@ var ts; name: "typescript:extends", scoped: false, priority: 0, - text: "\n var __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 };" + text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; })(ts || (ts = {})); var ts; @@ -41775,13 +42303,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 209: - return visitDoStatement(node); case 210: + return visitDoStatement(node); + case 211: return visitWhileStatement(node); - case 218: - return visitSwitchStatement(node); case 219: + return visitSwitchStatement(node); + case 220: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -41789,24 +42317,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); case 151: case 152: return visitAccessorDeclaration(node); - case 205: + case 206: return visitVariableStatement(node); - case 211: - return visitForStatement(node); case 212: + return visitForStatement(node); + case 213: return visitForInStatement(node); - case 215: - return visitBreakStatement(node); - case 214: - return visitContinueStatement(node); case 216: + return visitBreakStatement(node); + case 215: + return visitContinueStatement(node); + case 217: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -41844,7 +42372,7 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -42031,10 +42559,10 @@ var ts; else if (node.operatorToken.kind === 25) { return visitCommaExpression(node); } - var clone_4 = ts.getMutableClone(node); - clone_4.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_4.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_4; + var clone_5 = ts.getMutableClone(node); + clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_5; } return ts.visitEachChild(node, visitor, context); } @@ -42096,7 +42624,7 @@ var ts; emitYield(expression, node); } markLabel(resumeLabel); - return createGeneratorResume(); + return createGeneratorResume(node); } function visitArrayLiteralExpression(node) { return visitElements(node.elements, undefined, undefined, node.multiLine); @@ -42156,10 +42684,10 @@ var ts; } function visitElementAccessExpression(node) { if (containsYield(node.argumentExpression)) { - var clone_5 = ts.getMutableClone(node); - clone_5.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_5.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -42202,35 +42730,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 204: + case 205: return transformAndEmitBlock(node); - case 207: - return transformAndEmitExpressionStatement(node); case 208: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 209: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 210: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 211: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 212: + return transformAndEmitForStatement(node); + case 213: return transformAndEmitForInStatement(node); - case 214: - return transformAndEmitContinueStatement(node); case 215: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 216: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 217: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 218: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 219: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 220: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 221: + return transformAndEmitThrowStatement(node); + case 222: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -42250,7 +42778,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - hoistVariableDeclaration(variable.name); + var name_37 = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name_37, variable.name); + hoistVariableDeclaration(name_37); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -42280,7 +42810,7 @@ var ts; if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) { var endLabel = defineLabel(); var elseLabel = node.elseStatement ? defineLabel() : undefined; - emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression)); + emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), node.expression); transformAndEmitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { emitBreak(endLabel); @@ -42514,7 +43044,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 254 && defaultClauseIndex === -1) { + if (clause.kind === 255 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -42524,7 +43054,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 253) { + if (clause.kind === 254) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -42645,12 +43175,12 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_37) { - var clone_6 = ts.getMutableClone(name_37); - ts.setSourceMapRange(clone_6, node); - ts.setCommentRange(clone_6, node); - return clone_6; + var name_38 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_38) { + var clone_7 = ts.getMutableClone(name_38); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); + return clone_7; } } } @@ -43260,41 +43790,41 @@ var ts; function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), operationLocation)); + : [createInstruction(2)]), operationLocation), 384)); } function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation)); + ]), operationLocation), 384)); } function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384)), 1)); } function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384)), 1)); } function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4), expression] - : [createInstruction(4)]), operationLocation)); + : [createInstruction(4)]), operationLocation), 384)); } function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(5), expression - ]), operationLocation)); + ]), operationLocation), 384)); } function writeEndfinally() { lastOperationWasAbrupt = true; @@ -43319,15 +43849,40 @@ var ts; var ts; (function (ts) { function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(249); + context.enableEmitNotification(250); + context.enableEmitNotification(248); + noSubstitution = []; + } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; context.enableSubstitution(177); - context.enableSubstitution(257); + context.enableSubstitution(258); return transformSourceFile; function transformSourceFile(node) { return node; } + function onEmitNode(emitContext, node, emitCallback) { + switch (node.kind) { + case 249: + case 250: + case 248: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(emitContext, node, emitCallback); + } function onSubstituteNode(emitContext, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(emitContext, node); + } node = previousOnSubstituteNode(emitContext, node); if (ts.isPropertyAccessExpression(node)) { return substitutePropertyAccessExpression(node); @@ -43369,7 +43924,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(261); + context.enableEmitNotification(262); context.enableSubstitution(70); var currentSourceFile; return transformSourceFile; @@ -43394,9 +43949,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 234: + case 235: return undefined; - case 240: + case 241: return visitExportAssignment(node); } return node; @@ -43448,7 +44003,7 @@ var ts; context.enableSubstitution(192); context.enableSubstitution(190); context.enableSubstitution(191); - context.enableEmitNotification(261); + context.enableEmitNotification(262); var moduleInfoMap = ts.createMap(); var deferredExports = ts.createMap(); var exportFunctionsMap = ts.createMap(); @@ -43548,7 +44103,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 241 && externalImport.exportClause) { + if (externalImport.kind === 242 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -43571,7 +44126,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 241) { + if (externalImport.kind !== 242) { continue; } var exportDecl = externalImport; @@ -43623,15 +44178,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 235: + case 236: if (!entry.importClause) { break; } - case 234: + case 235: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 241: + case 242: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -43653,13 +44208,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 241: + case 242: return undefined; - case 240: + case 241: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -43780,7 +44335,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 1048576) === 0 - && (enclosingBlockScopedContainer.kind === 261 + && (enclosingBlockScopedContainer.kind === 262 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -43802,7 +44357,7 @@ var ts; : preventSubstitution(ts.createAssignment(name, value, location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -43835,10 +44390,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237: + case 238: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238: + case 239: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -43937,43 +44492,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 205: + case 206: return visitVariableStatement(node); - case 225: - return visitFunctionDeclaration(node); case 226: + return visitFunctionDeclaration(node); + case 227: return visitClassDeclaration(node); - case 211: - return visitForStatement(node); case 212: - return visitForInStatement(node); + return visitForStatement(node); case 213: + return visitForInStatement(node); + case 214: return visitForOfStatement(node); - case 209: - return visitDoStatement(node); case 210: + return visitDoStatement(node); + case 211: return visitWhileStatement(node); - case 219: + case 220: return visitLabeledStatement(node); - case 217: - return visitWithStatement(node); case 218: + return visitWithStatement(node); + case 219: return visitSwitchStatement(node); - case 232: + case 233: return visitCaseBlock(node); - case 253: - return visitCaseClause(node); case 254: + return visitCaseClause(node); + case 255: return visitDefaultClause(node); - case 221: + case 222: return visitTryStatement(node); - case 256: + case 257: return visitCatchClause(node); - case 204: + case 205: return visitBlock(node); - case 295: - return visitMergeDeclarationMarker(node); case 296: + return visitMergeDeclarationMarker(node); + case 297: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -44101,7 +44656,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 261; + return container !== undefined && container.kind === 262; } else { return false; @@ -44116,7 +44671,7 @@ var ts; return node; } function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { + if (node.kind === 262) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -44228,7 +44783,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 261) { + if (exportContainer && exportContainer.kind === 262) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -44271,8 +44826,8 @@ var ts; context.enableSubstitution(192); context.enableSubstitution(190); context.enableSubstitution(191); - context.enableSubstitution(258); - context.enableEmitNotification(261); + context.enableSubstitution(259); + context.enableEmitNotification(262); var moduleInfoMap = ts.createMap(); var deferredExports = ts.createMap(); var currentSourceFile; @@ -44310,14 +44865,7 @@ var ts; function transformAMDModule(node) { var define = ts.createIdentifier("define"); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, true); - } - function transformUMDModule(node) { - var define = ts.createRawExpression(umdHelper); - return transformAsynchronousModule(node, define, undefined, false); - } - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; return ts.updateSourceFileNode(node, ts.createNodeArray([ ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ @@ -44331,6 +44879,36 @@ var ts; ]))) ], node.statements)); } + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement(undefined, [ + ts.createVariableDeclaration("v", undefined, ts.createCall(ts.createIdentifier("factory"), undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], undefined, true)); + return ts.updateSourceFileNode(node, ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(undefined, undefined, undefined, "require"), + ts.createParameter(undefined, undefined, undefined, "exports") + ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ])) + ], node.statements)); + } function collectAsynchronousDependencies(node, includeNonAmdDependencies) { var aliasedModuleNames = []; var unaliasedModuleNames = []; @@ -44390,23 +44968,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 241: + case 242: return visitExportDeclaration(node); - case 240: + case 241: return visitExportAssignment(node); - case 205: + case 206: return visitVariableStatement(node); - case 225: - return visitFunctionDeclaration(node); case 226: + return visitFunctionDeclaration(node); + case 227: return visitClassDeclaration(node); - case 295: - return visitMergeDeclarationMarker(node); case 296: + return visitMergeDeclarationMarker(node); + case 297: return visitEndOfDeclarationMarker(node); default: return node; @@ -44604,7 +45182,7 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -44636,10 +45214,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237: + case 238: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238: + case 239: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -44747,7 +45325,7 @@ var ts; return node; } function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { + if (node.kind === 262) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = ts.createMap(); @@ -44807,7 +45385,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 261) { + if (exportContainer && exportContainer.kind === 262) { return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -44816,8 +45394,8 @@ var ts; return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_38 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_38), node); + var name_39 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_39), node); } } } @@ -44881,7 +45459,6 @@ var ts; scoped: true, text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" }; - var umdHelper = "\n (function (dependencies, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(dependencies, factory);\n }\n })"; })(ts || (ts = {})); var ts; (function (ts) { @@ -45245,7 +45822,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 293 + if (node.kind !== 294 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -45258,7 +45835,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 293 + if (node.kind !== 294 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -45402,7 +45979,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 293; + var isEmittedNode = node.kind !== 294; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0; if (!skipLeadingComments) { @@ -45416,7 +45993,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 224) { + if (node.kind === 225) { declarationListContainerEnd = end; } } @@ -45691,7 +46268,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 235); + ts.Debug.assert(aliasEmitInfo.node.kind === 236); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -45763,10 +46340,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 223) { + if (declaration.kind === 224) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 238 || declaration.kind === 239 || declaration.kind === 236) { + else if (declaration.kind === 239 || declaration.kind === 240 || declaration.kind === 237) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -45777,7 +46354,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 235) { + if (moduleElementEmitInfo.node.kind === 236) { moduleElementEmitInfo.isVisible = true; } else { @@ -45785,12 +46362,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 231) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 231) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -45961,7 +46538,7 @@ var ts; } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 234 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 235 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); @@ -46078,9 +46655,9 @@ var ts; var count = 0; while (true) { count++; - var name_39 = baseName + "_" + count; - if (!(name_39 in currentIdentifiers)) { - return name_39; + var name_40 = baseName + "_" + count; + if (!(name_40 in currentIdentifiers)) { + return name_40; } } } @@ -46124,10 +46701,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 234 || - (node.parent.kind === 261 && isCurrentFileExternalModule)) { + else if (node.kind === 235 || + (node.parent.kind === 262 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 262) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -46136,7 +46713,7 @@ var ts; }); } else { - if (node.kind === 235) { + if (node.kind === 236) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -46154,30 +46731,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 225: - return writeFunctionDeclaration(node); - case 205: - return writeVariableStatement(node); - case 227: - return writeInterfaceDeclaration(node); case 226: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 206: + return writeVariableStatement(node); case 228: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 227: + return writeClassDeclaration(node); case 229: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 230: + return writeEnumDeclaration(node); + case 231: return writeModuleDeclaration(node); - case 234: - return writeImportEqualsDeclaration(node); case 235: + return writeImportEqualsDeclaration(node); + case 236: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 261) { + if (node.parent.kind === 262) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -46185,7 +46762,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 227 && !noDeclare) { + else if (node.kind !== 228 && !noDeclare) { write("declare "); } } @@ -46235,7 +46812,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 237) { + if (namedBindings.kind === 238) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -46258,7 +46835,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 237) { + if (node.importClause.namedBindings.kind === 238) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -46275,13 +46852,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 231; var moduleSpecifier; - if (parent.kind === 234) { + if (parent.kind === 235) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 230) { + else if (parent.kind === 231) { moduleSpecifier = parent.name; } else { @@ -46349,7 +46926,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 231) { + while (node.body && node.body.kind !== 232) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -46447,10 +47024,10 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 226: + case 227: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 227: + case 228: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 154: @@ -46464,17 +47041,17 @@ var ts; if (ts.hasModifier(node.parent, 32)) { 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 === 226) { + else if (node.parent.parent.kind === 227) { 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 225: + case 226: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 228: + case 229: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -46511,7 +47088,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 226) { + if (node.parent.parent.kind === 227) { 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; @@ -46594,7 +47171,7 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 223 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 224 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -46617,7 +47194,7 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 223) { + if (node.kind === 224) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -46632,7 +47209,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 === 226) { + else if (node.parent.kind === 227) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -46792,13 +47369,13 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 225) { + if (node.kind === 226) { emitModuleElementDeclarationFlags(node); } else if (node.kind === 149 || node.kind === 150) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 225) { + if (node.kind === 226) { write("function "); writeTextOfNode(currentText, node.name); } @@ -46892,7 +47469,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 === 226) { + else if (node.parent.kind === 227) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -46905,7 +47482,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 225: + case 226: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -46982,7 +47559,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 === 226) { + else if (node.parent.parent.kind === 227) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -46994,7 +47571,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 225: + case 226: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47046,19 +47623,19 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 225: - case 230: - case 234: - case 227: case 226: - case 228: - case 229: - return emitModuleElement(node, isModuleElementVisible(node)); - case 205: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 231: case 235: + case 228: + case 227: + case 229: + case 230: + return emitModuleElement(node, isModuleElementVisible(node)); + case 206: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 236: return emitModuleElement(node, !node.importClause); - case 241: + case 242: return emitExportDeclaration(node); case 150: case 149: @@ -47074,11 +47651,11 @@ var ts; case 147: case 146: return emitPropertyDeclaration(node); - case 260: - return emitEnumMemberDeclaration(node); - case 240: - return emitExportAssignment(node); case 261: + return emitEnumMemberDeclaration(node); + case 241: + return emitExportAssignment(node); + case 262: return emitSourceFile(node); } } @@ -47286,7 +47863,7 @@ var ts; function pipelineEmitInSourceFileContext(node) { var kind = node.kind; switch (kind) { - case 261: + case 262: return emitSourceFile(node); } } @@ -47409,119 +47986,119 @@ var ts; return emitArrayBindingPattern(node); case 174: return emitBindingElement(node); - case 202: - return emitTemplateSpan(node); case 203: - return emitSemicolonClassElement(); + return emitTemplateSpan(node); case 204: - return emitBlock(node); + return emitSemicolonClassElement(); case 205: - return emitVariableStatement(node); + return emitBlock(node); case 206: - return emitEmptyStatement(); + return emitVariableStatement(node); case 207: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 208: - return emitIfStatement(node); + return emitExpressionStatement(node); case 209: - return emitDoStatement(node); + return emitIfStatement(node); case 210: - return emitWhileStatement(node); + return emitDoStatement(node); case 211: - return emitForStatement(node); + return emitWhileStatement(node); case 212: - return emitForInStatement(node); + return emitForStatement(node); case 213: - return emitForOfStatement(node); + return emitForInStatement(node); case 214: - return emitContinueStatement(node); + return emitForOfStatement(node); case 215: - return emitBreakStatement(node); + return emitContinueStatement(node); case 216: - return emitReturnStatement(node); + return emitBreakStatement(node); case 217: - return emitWithStatement(node); + return emitReturnStatement(node); case 218: - return emitSwitchStatement(node); + return emitWithStatement(node); case 219: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 220: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 221: - return emitTryStatement(node); + return emitThrowStatement(node); case 222: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 223: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 224: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 225: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 226: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 227: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 228: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 229: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 230: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 231: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 232: + return emitModuleBlock(node); + case 233: return emitCaseBlock(node); - case 234: - return emitImportEqualsDeclaration(node); case 235: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 236: - return emitImportClause(node); + return emitImportDeclaration(node); case 237: - return emitNamespaceImport(node); + return emitImportClause(node); case 238: - return emitNamedImports(node); + return emitNamespaceImport(node); case 239: - return emitImportSpecifier(node); + return emitNamedImports(node); case 240: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 241: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 242: - return emitNamedExports(node); + return emitExportDeclaration(node); case 243: - return emitExportSpecifier(node); + return emitNamedExports(node); case 244: - return; + return emitExportSpecifier(node); case 245: + return; + case 246: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 248: - return emitJsxOpeningElement(node); case 249: - return emitJsxClosingElement(node); + return emitJsxOpeningElement(node); case 250: - return emitJsxAttribute(node); + return emitJsxClosingElement(node); case 251: - return emitJsxSpreadAttribute(node); + return emitJsxAttribute(node); case 252: - return emitJsxExpression(node); + return emitJsxSpreadAttribute(node); case 253: - return emitCaseClause(node); + return emitJsxExpression(node); case 254: - return emitDefaultClause(node); + return emitCaseClause(node); case 255: - return emitHeritageClause(node); + return emitDefaultClause(node); case 256: - return emitCatchClause(node); + return emitHeritageClause(node); case 257: - return emitPropertyAssignment(node); + return emitCatchClause(node); case 258: - return emitShorthandPropertyAssignment(node); + return emitPropertyAssignment(node); case 259: - return emitSpreadAssignment(node); + return emitShorthandPropertyAssignment(node); case 260: + return emitSpreadAssignment(node); + case 261: return emitEnumMember(node); } if (ts.isExpression(node)) { @@ -47598,14 +48175,14 @@ var ts; return emitAsExpression(node); case 201: return emitNonNullExpression(node); - case 246: - return emitJsxElement(node); + case 202: + return emitMetaProperty(node); case 247: + return emitJsxElement(node); + case 248: return emitJsxSelfClosingElement(node); - case 294: + case 295: return emitPartiallyEmittedExpression(node); - case 297: - return writeLines(node.text); } } function emitNumericLiteral(node) { @@ -48050,6 +48627,11 @@ var ts; emitExpression(node.expression); write("!"); } + function emitMetaProperty(node) { + writeToken(node.keywordToken, node.pos); + write("."); + emit(node.name); + } function emitTemplateSpan(node) { emitExpression(node.expression); emit(node.literal); @@ -48092,27 +48674,27 @@ var ts; writeToken(18, openParenPos, node); emitExpression(node.expression); writeToken(19, node.expression.end, node); - emitEmbeddedStatement(node.thenStatement); + emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { - writeLine(); + writeLineOrSpace(node); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 208) { + if (node.elseStatement.kind === 209) { write(" "); emit(node.elseStatement); } else { - emitEmbeddedStatement(node.elseStatement); + emitEmbeddedStatement(node, node.elseStatement); } } } function emitDoStatement(node) { write("do"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { write(" "); } else { - writeLine(); + writeLineOrSpace(node); } write("while ("); emitExpression(node.expression); @@ -48122,7 +48704,7 @@ var ts; write("while ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -48134,7 +48716,7 @@ var ts; write(";"); emitExpressionWithPrefix(" ", node.incrementor); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -48144,7 +48726,7 @@ var ts; write(" in "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -48154,11 +48736,11 @@ var ts; write(" of "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 224) { + if (node.kind === 225) { emit(node); } else { @@ -48185,7 +48767,7 @@ var ts; write("with ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { var openParenPos = writeToken(97, node.pos); @@ -48209,9 +48791,12 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchClause); + if (node.catchClause) { + writeLineOrSpace(node); + emit(node.catchClause); + } if (node.finallyBlock) { - writeLine(); + writeLineOrSpace(node); write("finally "); emit(node.finallyBlock); } @@ -48387,7 +48972,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 230) { + while (body.kind === 231) { write("."); emit(body.name); body = body.body; @@ -48538,6 +49123,9 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); + if (node.dotDotDotToken) { + write("..."); + } emitExpression(node.expression); write("}"); } @@ -48737,8 +49325,8 @@ var ts; write(suffix); } } - function emitEmbeddedStatement(node) { - if (ts.isBlock(node)) { + function emitEmbeddedStatement(parent, node) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1) { write(" "); emit(node); } @@ -48867,6 +49455,14 @@ var ts; write(getClosingBracket(format)); } } + function writeLineOrSpace(node) { + if (ts.getEmitFlags(node) & 1) { + write(" "); + } + else { + writeLine(); + } + } function writeIfAny(nodes, text) { if (nodes && nodes.length > 0) { write(text); @@ -49047,21 +49643,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_40 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_40)) { + var name_41 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_41)) { tempFlags |= flags; - return name_40; + return name_41; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_41 = count < 26 + var name_42 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_41)) { - return name_41; + if (isUniqueName(name_42)) { + return name_42; } } } @@ -49095,22 +49691,32 @@ var ts; function generateNameForClassExpression() { return makeUniqueName("class"); } + function generateNameForMethodOrAccessor(node) { + if (ts.isIdentifier(node.name)) { + return generateNameForNodeCached(node.name); + } + return makeTempVariableName(0); + } function generateNameForNode(node) { switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); + case 231: case 230: - case 229: return generateNameForModuleOrEnum(node); - case 235: - case 241: + case 236: + case 242: return generateNameForImportOrExportDeclaration(node); - case 225: case 226: - case 240: + case 227: + case 241: return generateNameForExportDefault(); case 197: return generateNameForClassExpression(); + case 149: + case 151: + case 152: + return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); } @@ -49141,11 +49747,14 @@ var ts; } return node; } + function generateNameForNodeCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + } function getGeneratedIdentifier(name) { if (name.autoGenerateKind === 4) { var node = getNodeForGeneratedName(name); - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + return generateNameForNodeCached(node); } else { var autoGenerateId = name.autoGenerateId; @@ -49214,7 +49823,8 @@ var ts; commonPathComponents = sourcePathComponents; return; } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + var n = Math.min(commonPathComponents.length, sourcePathComponents.length); + for (var i = 0; i < n; i++) { if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { if (i === 0) { return true; @@ -49397,10 +50007,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_42 = names_1[_i]; - var result = name_42 in cache - ? cache[name_42] - : cache[name_42] = loader(name_42, containingFile); + var name_43 = names_1[_i]; + var result = name_43 in cache + ? cache[name_43] + : cache[name_43] = loader(name_43, containingFile); resolutions.push(result); } return resolutions; @@ -49425,6 +50035,7 @@ var ts; var currentDirectory = host.getCurrentDirectory(); var supportedExtensions = ts.getSupportedExtensions(options); var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); + var moduleResolutionCache; var resolveModuleNamesWorker; if (host.resolveModuleNames) { resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { @@ -49437,7 +50048,8 @@ var ts; }); }; } else { - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -49473,6 +50085,7 @@ var ts; } } } + moduleResolutionCache = undefined; oldProgram = undefined; program = { getRootFileNames: function () { return rootNames; }, @@ -49679,7 +50292,7 @@ var ts; newSourceFile.resolvedModules = oldSourceFile.resolvedModules; newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } - for (var i = 0, len = newSourceFiles.length; i < len; i++) { + for (var i = 0; i < newSourceFiles.length; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; @@ -49837,42 +50450,42 @@ var ts; case 151: case 152: case 184: - case 225: + case 226: case 185: - case 225: - case 223: + case 226: + case 224: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 234: + case 235: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 240: + case 241: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 255: + case 256: var heritageClause = node; if (heritageClause.token === 107) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 227: + case 228: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 230: + case 231: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 228: + case 229: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 229: + case 230: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; case 182: @@ -49890,23 +50503,23 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 226: + case 227: case 149: case 148: case 150: case 151: case 152: case 184: - case 225: + case 226: case 185: - case 225: + case 226: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 205: + case 206: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 205); + return checkModifiers(nodes, parent.kind === 206); } break; case 147: @@ -50018,7 +50631,7 @@ var ts; && !file.isDeclarationFile) { var externalHelpersModuleReference = ts.createSynthesizedNode(9); externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(235); + var importDecl = ts.createSynthesizedNode(236); importDecl.parent = file; externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; @@ -50036,9 +50649,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 236: case 235: - case 234: - case 241: + case 242: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -50050,7 +50663,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 230: + case 231: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -51207,9 +51820,9 @@ var ts; function serializeCompilerOptions(options) { var result = ts.createMap(); var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_43 in options) { - if (ts.hasProperty(options, name_43)) { - switch (name_43) { + for (var name_44 in options) { + if (ts.hasProperty(options, name_44)) { + switch (name_44) { case "init": case "watch": case "version": @@ -51217,12 +51830,12 @@ var ts; case "project": break; default: - var value = options[name_43]; - var optionDefinition = optionsNameMap[name_43.toLowerCase()]; + var value = options[name_44]; + var optionDefinition = optionsNameMap[name_44.toLowerCase()]; if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { - result[name_43] = value; + result[name_44] = value; } else { if (optionDefinition.type === "list") { @@ -51231,10 +51844,10 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_43] = convertedValue; + result[name_44] = convertedValue; } else { - result[name_43] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -51268,6 +51881,7 @@ var ts; if (resolutionStack === void 0) { resolutionStack = []; } if (extraFileExtensions === void 0) { extraFileExtensions = []; } var errors = []; + basePath = ts.normalizeSlashes(basePath); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -52084,17 +52698,17 @@ var ts; var nameSize = 0; var valueSize = 0; for (var _i = 0, statistics_1 = statistics; _i < statistics_1.length; _i++) { - var _a = statistics_1[_i], name_44 = _a.name, value = _a.value; - if (name_44.length > nameSize) { - nameSize = name_44.length; + var _a = statistics_1[_i], name_45 = _a.name, value = _a.value; + if (name_45.length > nameSize) { + nameSize = name_45.length; } if (value.length > valueSize) { valueSize = value.length; } } for (var _b = 0, statistics_2 = statistics; _b < statistics_2.length; _b++) { - var _c = statistics_2[_b], name_45 = _c.name, value = _c.value; - ts.sys.write(padRight(name_45 + ":", nameSize + 2) + padLeft(value.toString(), valueSize) + ts.sys.newLine); + var _c = statistics_2[_b], name_46 = _c.name, value = _c.value; + ts.sys.write(padRight(name_46 + ":", nameSize + 2) + padLeft(value.toString(), valueSize) + ts.sys.newLine); } } function reportStatisticalValue(name, value) { diff --git a/lib/tsserver.js b/lib/tsserver.js index 9c17684ed0a..10cfa276fec 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -13,11 +13,16 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ts; (function (ts) { var OperationCanceledException = (function () { @@ -206,7 +211,7 @@ var ts; ts.toPath = toPath; function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -225,7 +230,7 @@ var ts; ts.zipWith = zipWith; function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -235,7 +240,7 @@ var ts; } ts.every = every; function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -245,7 +250,7 @@ var ts; } ts.find = find; function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -268,7 +273,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -278,7 +283,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -981,6 +986,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -2475,7 +2481,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_be_declared_in_an_ambient_context_1086", message: "An accessor cannot be declared in an ambient context." }, _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", message: "'{0}' modifier cannot appear on a constructor declaration." }, _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_parameter_1090", message: "'{0}' modifier cannot appear on a parameter." }, @@ -2632,6 +2638,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "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_2301", message: "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_2302", message: "Static members cannot reference class type parameters." }, @@ -2861,6 +2868,8 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "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: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2870,6 +2879,7 @@ var ts; Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "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: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -2921,6 +2931,8 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "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_4002", message: "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_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -3089,6 +3101,7 @@ var ts; Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -3102,10 +3115,10 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, @@ -3154,6 +3167,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -3210,22 +3225,25 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); var ts; @@ -3606,7 +3624,7 @@ var ts; if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { var ch = text.charCodeAt(pos); if ((pos + mergeConflictMarkerLength) < text.length) { - for (var i = 0, n = mergeConflictMarkerLength; i < n; i++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -3792,7 +3810,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -5539,6 +5557,7 @@ var ts; if (resolutionStack === void 0) { resolutionStack = []; } if (extraFileExtensions === void 0) { extraFileExtensions = []; } var errors = []; + basePath = ts.normalizeSlashes(basePath); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -6093,197 +6112,6 @@ var ts; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var server; - (function (server) { - var LogLevel; - (function (LogLevel) { - LogLevel[LogLevel["terse"] = 0] = "terse"; - LogLevel[LogLevel["normal"] = 1] = "normal"; - LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; - LogLevel[LogLevel["verbose"] = 3] = "verbose"; - })(LogLevel = server.LogLevel || (server.LogLevel = {})); - server.emptyArray = []; - var Msg; - (function (Msg) { - Msg.Err = "Err"; - Msg.Info = "Info"; - Msg.Perf = "Perf"; - })(Msg = server.Msg || (server.Msg = {})); - function getProjectRootPath(project) { - switch (project.projectKind) { - case server.ProjectKind.Configured: - return ts.getDirectoryPath(project.getProjectName()); - case server.ProjectKind.Inferred: - return ""; - case server.ProjectKind.External: - var projectName = ts.normalizeSlashes(project.getProjectName()); - return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; - } - } - function createInstallTypingsRequest(project, typeAcquisition, unresolvedImports, cachePath) { - return { - projectName: project.getProjectName(), - fileNames: project.getFileNames(true), - compilerOptions: project.getCompilerOptions(), - typeAcquisition: typeAcquisition, - unresolvedImports: unresolvedImports, - projectRootPath: getProjectRootPath(project), - cachePath: cachePath, - kind: "discover" - }; - } - server.createInstallTypingsRequest = createInstallTypingsRequest; - var Errors; - (function (Errors) { - function ThrowNoProject() { - throw new Error("No Project."); - } - Errors.ThrowNoProject = ThrowNoProject; - function ThrowProjectLanguageServiceDisabled() { - throw new Error("The project's language service is disabled."); - } - Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; - function ThrowProjectDoesNotContainDocument(fileName, project) { - throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); - } - Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; - })(Errors = server.Errors || (server.Errors = {})); - function getDefaultFormatCodeSettings(host) { - return { - indentSize: 4, - tabSize: 4, - newLineCharacter: host.newLine || "\n", - convertTabsToSpaces: true, - indentStyle: ts.IndentStyle.Smart, - insertSpaceAfterCommaDelimiter: true, - insertSpaceAfterSemicolonInForStatements: true, - insertSpaceBeforeAndAfterBinaryOperators: true, - insertSpaceAfterKeywordsInControlFlowStatements: true, - insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, - placeOpenBraceOnNewLineForFunctions: false, - placeOpenBraceOnNewLineForControlBlocks: false, - }; - } - server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; - function mergeMaps(target, source) { - for (var key in source) { - if (ts.hasProperty(source, key)) { - target[key] = source[key]; - } - } - } - server.mergeMaps = mergeMaps; - function removeItemFromSet(items, itemToRemove) { - if (items.length === 0) { - return; - } - var index = items.indexOf(itemToRemove); - if (index < 0) { - return; - } - if (index === items.length - 1) { - items.pop(); - } - else { - items[index] = items.pop(); - } - } - server.removeItemFromSet = removeItemFromSet; - function toNormalizedPath(fileName) { - return ts.normalizePath(fileName); - } - server.toNormalizedPath = toNormalizedPath; - function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { - var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); - return getCanonicalFileName(f); - } - server.normalizedPathToPath = normalizedPathToPath; - function asNormalizedPath(fileName) { - return fileName; - } - server.asNormalizedPath = asNormalizedPath; - function createNormalizedPathMap() { - var map = Object.create(null); - return { - get: function (path) { - return map[path]; - }, - set: function (path, value) { - map[path] = value; - }, - contains: function (path) { - return ts.hasProperty(map, path); - }, - remove: function (path) { - delete map[path]; - } - }; - } - server.createNormalizedPathMap = createNormalizedPathMap; - function isInferredProjectName(name) { - return /dev\/null\/inferredProject\d+\*/.test(name); - } - server.isInferredProjectName = isInferredProjectName; - function makeInferredProjectName(counter) { - return "/dev/null/inferredProject" + counter + "*"; - } - server.makeInferredProjectName = makeInferredProjectName; - function toSortedReadonlyArray(arr) { - arr.sort(); - return arr; - } - server.toSortedReadonlyArray = toSortedReadonlyArray; - var ThrottledOperations = (function () { - function ThrottledOperations(host) { - this.host = host; - this.pendingTimeouts = ts.createMap(); - } - ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { - if (ts.hasProperty(this.pendingTimeouts, operationId)) { - this.host.clearTimeout(this.pendingTimeouts[operationId]); - } - this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); - }; - ThrottledOperations.run = function (self, operationId, cb) { - delete self.pendingTimeouts[operationId]; - cb(); - }; - return ThrottledOperations; - }()); - server.ThrottledOperations = ThrottledOperations; - var GcTimer = (function () { - function GcTimer(host, delay, logger) { - this.host = host; - this.delay = delay; - this.logger = logger; - } - GcTimer.prototype.scheduleCollect = function () { - if (!this.host.gc || this.timerId != undefined) { - return; - } - this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); - }; - GcTimer.run = function (self) { - self.timerId = undefined; - var log = self.logger.hasLevel(LogLevel.requestTime); - var before = log && self.host.getMemoryUsage(); - self.host.gc(); - if (log) { - var after = self.host.getMemoryUsage(); - self.logger.perftrc("GC::before " + before + ", after " + after); - } - }; - return GcTimer; - }()); - server.GcTimer = GcTimer; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; (function (ts) { function trace(host) { host.trace(ts.formatMessage.apply(undefined, arguments)); @@ -6293,6 +6121,12 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; + var Extensions; + (function (Extensions) { + Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; + Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; + Extensions[Extensions["DtsOnly"] = 2] = "DtsOnly"; + })(Extensions || (Extensions = {})); function resolvedTypeScriptOnly(resolved) { if (!resolved) { return undefined; @@ -6300,9 +6134,6 @@ var ts; ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); return resolved.path; } - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } function resolvedModuleFromResolved(_a, isExternalLibraryImport) { var path = _a.path, extension = _a.extension; return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; @@ -6314,13 +6145,13 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { + function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); switch (extensions) { - case 2: - case 0: + case Extensions.DtsOnly: + case Extensions.TypeScript: return tryReadFromField("typings") || tryReadFromField("types"); - case 1: + case Extensions.JavaScript: if (typeof jsonContent.main === "string") { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); @@ -6382,6 +6213,7 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } + return undefined; }); return typeRoots; } @@ -6436,7 +6268,11 @@ var ts; return ts.forEach(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); }); } else { @@ -6452,7 +6288,8 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -6493,31 +6330,115 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + if (!perModuleNameCache) { + moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent_1 = ts.getDirectoryPath(current); + if (parent_1 === current || directoryPathMap.contains(parent_1)) { + break; + } + directoryPathMap.set(parent_1, result); + current = parent_1; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache[moduleName]; + if (result) { if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache[moduleName] = result; + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; } if (traceEnabled) { if (result.resolvedModule) { @@ -6642,33 +6563,33 @@ var ts; return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0) || tryResolve(1); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } @@ -6685,10 +6606,33 @@ var ts; } function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); @@ -6716,11 +6660,11 @@ var ts; } } switch (extensions) { - case 2: + case Extensions.DtsOnly: return tryExtension(".d.ts", ts.Extension.Dts); - case 0: + case Extensions.TypeScript: return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1: + case Extensions.JavaScript: return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } function tryExtension(ext, extension) { @@ -6729,19 +6673,21 @@ var ts; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } } - failedLookupLocations.push(fileName); - return undefined; } + failedLookupLocations.push(fileName); + return undefined; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var packageJsonPath = pathToPackageJson(candidate); @@ -6750,16 +6696,22 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - return resolvedFromAnyFile(fromFile); + var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); + if (mainOrTypesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); + var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); + if (fromExactFile) { + var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); + if (resolved_3) { + return resolved_3; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } - var x = tryAddingExtensions(typesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; + var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved) { + return resolved; } } else { @@ -6769,73 +6721,117 @@ var ts; } } else { - if (state.traceEnabled) { + if (directoryExists && state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } failedLookupLocations.push(packageJsonPath); } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); } function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(2, moduleName, directory, failedLookupLocations, state, true); + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, true, undefined); } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); } }); } function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } - if (extensions !== 1) { - return loadModuleFromNodeModulesFolder(2, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0) || tryResolve(1); - return createResolvedModuleWithFailedLookupLocations(resolved, false, failedLookupLocations); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); if (resolvedUsingSettings) { - return resolvedUsingSettings; + return { value: resolvedUsingSettings }; } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { - var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); - if (resolved_3) { - return resolved_3; + if (resolved_4) { + return resolved_4; } - if (extensions === 0) { + if (extensions === Extensions.TypeScript) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); } } } @@ -6847,10 +6843,13 @@ var ts; } var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2, moduleName, globalCache, failedLookupLocations, state); + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } function forEachAncestorDirectory(directory, callback) { while (true) { var result = callback(directory); @@ -6981,7 +6980,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 261) { + while (node && node.kind !== 262) { node = node.parent; } return node; @@ -6989,11 +6988,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 204: - case 232: - case 211: + case 205: + case 233: case 212: case 213: + case 214: return true; } return false; @@ -7058,18 +7057,18 @@ var ts; if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 292 && node._children.length > 0) { + if (node.kind === 293 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 262 && node.kind <= 288; + return node.kind >= 263 && node.kind <= 289; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 278 && node.kind <= 291; + return node.kind >= 279 && node.kind <= 292; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -7163,11 +7162,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 223 && node.parent.kind === 256; + return node.kind === 224 && node.parent.kind === 257; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 230 && + return node && node.kind === 231 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -7176,11 +7175,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 230 && (!node.body); + return node.kind === 231 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 261 || - node.kind === 230 || + return node.kind === 262 || + node.kind === 231 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -7193,9 +7192,9 @@ var ts; return false; } switch (node.parent.kind) { - case 261: + case 262: return ts.isExternalModule(node.parent); - case 231: + case 232: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -7207,22 +7206,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 261: - case 232: - case 256: - case 230: - case 211: + case 262: + case 233: + case 257: + case 231: case 212: case 213: + case 214: case 150: case 149: case 151: case 152: - case 225: + case 226: case 184: case 185: return true; - case 204: + case 205: return parentNode && !isFunctionLike(parentNode); } return false; @@ -7300,7 +7299,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 204) { + if (node.body && node.body.kind === 205) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -7312,26 +7311,26 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 261: + case 262: 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 223: + case 224: case 174: - case 226: - case 197: case 227: + case 197: + case 228: + case 231: case 230: - case 229: - case 260: - case 225: + case 261: + case 226: case 184: case 149: case 151: case 152: - case 228: + case 229: errorNode = node.name; break; case 185: @@ -7355,7 +7354,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 229 && isConst(node); + return node.kind === 230 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -7372,7 +7371,7 @@ var ts; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 207 + return node.kind === 208 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -7429,24 +7428,24 @@ var ts; case 141: case 177: case 98: - var parent_1 = node.parent; - if (parent_1.kind === 160) { + var parent_2 = node.parent; + if (parent_2.kind === 160) { return false; } - if (156 <= parent_1.kind && parent_1.kind <= 171) { + if (156 <= parent_2.kind && parent_2.kind <= 171) { return true; } - switch (parent_1.kind) { + switch (parent_2.kind) { case 199: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); case 143: - return node === parent_1.constraint; + return node === parent_2.constraint; case 147: case 146: case 144: - case 223: - return node === parent_1.type; - case 225: + case 224: + return node === parent_2.type; + case 226: case 184: case 185: case 150: @@ -7454,16 +7453,16 @@ var ts; case 148: case 151: case 152: - return node === parent_1.type; + return node === parent_2.type; case 153: case 154: case 155: - return node === parent_1.type; + return node === parent_2.type; case 182: - return node === parent_1.type; + return node === parent_2.type; case 179: case 180: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; case 181: return false; } @@ -7471,27 +7470,41 @@ var ts; return false; } ts.isPartOfTypeNode = isPartOfTypeNode; + function isChildOfNodeWithKind(node, kind) { + while (node) { + if (node.kind === kind) { + return true; + } + node = node.parent; + } + return false; + } + ts.isChildOfNodeWithKind = isChildOfNodeWithKind; + function isPrefixUnaryExpression(node) { + return node.kind === 190; + } + ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 216: + case 217: return visitor(node); - case 232: - case 204: - case 208: + case 233: + case 205: case 209: case 210: case 211: case 212: case 213: - case 217: + case 214: case 218: - case 253: - case 254: case 219: - case 221: - case 256: + case 254: + case 255: + case 220: + case 222: + case 257: return ts.forEachChild(node, traverse); } } @@ -7507,11 +7520,11 @@ var ts; if (operand) { traverse(operand); } - case 229: - case 227: case 230: case 228: - case 226: + case 231: + case 229: + case 227: case 197: return; default: @@ -7545,13 +7558,13 @@ var ts; if (node) { switch (node.kind) { case 174: - case 260: + case 261: case 144: - case 257: + case 258: case 147: case 146: - case 258: - case 223: + case 259: + case 224: return true; } } @@ -7563,7 +7576,7 @@ var ts; } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 226 || node.kind === 197); + return node && (node.kind === 227 || node.kind === 197); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7574,7 +7587,7 @@ var ts; switch (kind) { case 150: case 184: - case 225: + case 226: case 185: case 149: case 148: @@ -7597,7 +7610,7 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 184: return true; } @@ -7606,20 +7619,32 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 211: case 212: case 213: - case 209: + case 214: case 210: + case 211: return true; - case 219: + case 220: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; + function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + while (true) { + if (beforeUnwrapLabelCallback) { + beforeUnwrapLabelCallback(node); + } + if (node.statement.kind !== 220) { + return node.statement; + } + node = node.statement; + } + } + ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 204 && isFunctionLike(node.parent); + return node && node.kind === 205 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { @@ -7683,9 +7708,9 @@ var ts; if (!includeArrowFunctions) { continue; } - case 225: + case 226: case 184: - case 230: + case 231: case 147: case 146: case 149: @@ -7696,13 +7721,26 @@ var ts; case 153: case 154: case 155: - case 229: - case 261: + case 230: + case 262: return node; } } } ts.getThisContainer = getThisContainer; + function getNewTargetContainer(node) { + var container = getThisContainer(node, false); + if (container) { + switch (container.kind) { + case 150: + case 226: + case 184: + return container; + } + } + return undefined; + } + ts.getNewTargetContainer = getNewTargetContainer; function getSuperContainer(node, stopOnFunctions) { while (true) { node = node.parent; @@ -7713,7 +7751,7 @@ var ts; case 142: node = node.parent; break; - case 225: + case 226: case 184: case 185: if (!stopOnFunctions) { @@ -7742,13 +7780,13 @@ var ts; function getImmediatelyInvokedFunctionExpression(func) { if (func.kind === 184 || func.kind === 185) { var prev = func; - var parent_2 = func.parent; - while (parent_2.kind === 183) { - prev = parent_2; - parent_2 = parent_2.parent; + var parent_3 = func.parent; + while (parent_3.kind === 183) { + prev = parent_3; + parent_3 = parent_3.parent; } - if (parent_2.kind === 179 && parent_2.expression === prev) { - return parent_2; + if (parent_3.kind === 179 && parent_3.expression === prev) { + return parent_3; } } } @@ -7762,7 +7800,7 @@ var ts; function getEntityNameFromTypeNode(node) { switch (node.kind) { case 157: - case 272: + case 273: return node.typeName; case 199: return isEntityNameExpression(node.expression) @@ -7796,21 +7834,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 226: + case 227: return true; case 147: - return node.parent.kind === 226; + return node.parent.kind === 227; case 151: case 152: case 149: return node.body !== undefined - && node.parent.kind === 226; + && node.parent.kind === 227; case 144: return node.parent.body !== undefined && (node.parent.kind === 150 || node.parent.kind === 149 || node.parent.kind === 152) - && node.parent.parent.kind === 226; + && node.parent.parent.kind === 227; } return false; } @@ -7826,7 +7864,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 226: + case 227: return ts.forEach(node.members, nodeOrChildIsDecorated); case 149: case 152: @@ -7836,9 +7874,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 248 || - parent.kind === 247 || - parent.kind === 249) { + if (parent.kind === 249 || + parent.kind === 248 || + parent.kind === 250) { return parent.tagName === node; } return false; @@ -7877,10 +7915,11 @@ var ts; case 194: case 12: case 198: - case 246: case 247: + case 248: case 195: case 189: + case 202: return true; case 141: while (node.parent.kind === 141) { @@ -7894,53 +7933,53 @@ var ts; case 8: case 9: case 98: - var parent_3 = node.parent; - switch (parent_3.kind) { - case 223: + var parent_4 = node.parent; + switch (parent_4.kind) { + case 224: case 144: case 147: case 146: - case 260: - case 257: + case 261: + case 258: case 174: - return parent_3.initializer === node; - case 207: + return parent_4.initializer === node; case 208: case 209: case 210: - case 216: + case 211: case 217: case 218: - case 253: - case 220: - case 218: - return parent_3.expression === node; - case 211: - var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 224) || + case 219: + case 254: + case 221: + case 219: + return parent_4.expression === node; + case 212: + var forStatement = parent_4; + return (forStatement.initializer === node && forStatement.initializer.kind !== 225) || forStatement.condition === node || forStatement.incrementor === node; - case 212: case 213: - var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224) || + case 214: + var forInStatement = parent_4; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 225) || forInStatement.expression === node; case 182: case 200: - return node === parent_3.expression; - case 202: - return node === parent_3.expression; + return node === parent_4.expression; + case 203: + return node === parent_4.expression; case 142: - return node === parent_3.expression; + return node === parent_4.expression; case 145: + case 253: case 252: - case 251: - case 259: + case 260: return true; case 199: - return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); + return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); default: - if (isPartOfExpression(parent_3)) { + if (isPartOfExpression(parent_4)) { return true; } } @@ -7955,7 +7994,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind === 245; + return node.kind === 235 && node.moduleReference.kind === 246; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7964,7 +8003,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind !== 245; + return node.kind === 235 && node.moduleReference.kind !== 246; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7988,7 +8027,7 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 223) { + if (s.valueDeclaration && s.valueDeclaration.kind === 224) { var declaration = s.valueDeclaration; return declaration.initializer && declaration.initializer.kind === 184; } @@ -8035,35 +8074,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 235) { + if (node.kind === 236) { return node.moduleSpecifier; } - if (node.kind === 234) { + if (node.kind === 235) { var reference = node.moduleReference; - if (reference.kind === 245) { + if (reference.kind === 246) { return reference.expression; } } - if (node.kind === 241) { + if (node.kind === 242) { return node.moduleSpecifier; } - if (node.kind === 230 && node.name.kind === 9) { + if (node.kind === 231 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 234) { + if (node.kind === 235) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 238) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 235 + return node.kind === 236 && node.importClause && !!node.importClause.name; } @@ -8074,8 +8113,8 @@ var ts; case 144: case 149: case 148: + case 259: case 258: - case 257: case 147: case 146: return node.questionToken !== undefined; @@ -8085,9 +8124,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 274 && + return node.kind === 275 && node.parameters.length > 0 && - node.parameters[0].type.kind === 276; + node.parameters[0].type.kind === 277; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { @@ -8100,7 +8139,7 @@ var ts; var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 281) { + if (doc.kind === 282) { if (doc.kind === kind) { result.push(doc); } @@ -8126,9 +8165,9 @@ var ts; var parent = node.parent; var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 205; + parent.parent.parent.kind === 206; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 205; + parent.parent.kind === 206; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -8138,13 +8177,13 @@ var ts; var isSourceOfAssignmentExpressionStatement = parent && parent.parent && parent.kind === 192 && parent.operatorToken.kind === 57 && - parent.parent.kind === 207; + parent.parent.kind === 208; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 230 && - parent && parent.kind === 230; - var isPropertyAssignmentExpression = parent && parent.kind === 257; + var isModuleDeclaration = node.kind === 231 && + parent && parent.kind === 231; + var isPropertyAssignmentExpression = parent && parent.kind === 258; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } @@ -8162,17 +8201,17 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 281); + var tags = getJSDocTags(func, 282); if (!param.name) { var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 281; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 282; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70) { var name_8 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 281 && tag.parameterName.text === name_8; }); + return ts.filter(tags, function (tag) { return tag.kind === 282 && tag.parameterName.text === name_8; }); } else { return undefined; @@ -8180,7 +8219,7 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 283); + var tag = getFirstJSDocTag(node, 284); if (!tag && node.kind === 144) { var paramTags = getJSDocParameterTags(node); if (paramTags) { @@ -8191,15 +8230,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 280); + return getFirstJSDocTag(node, 281); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 282); + return getFirstJSDocTag(node, 283); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 284); + return getFirstJSDocTag(node, 285); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -8212,8 +8251,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536)) { - if (node.type && node.type.kind === 275 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275; })) { + if (node.type && node.type.kind === 276 || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 276; })) { return true; } } @@ -8237,19 +8276,19 @@ var ts; case 191: var unaryOperator = parent.operator; return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; - case 212: case 213: + case 214: return parent.initializer === node ? 1 : 0; case 183: case 175: case 196: node = parent; break; - case 258: + case 259: if (parent.name !== node) { return 0; } - case 257: + case 258: node = parent.parent; break; default: @@ -8263,6 +8302,17 @@ var ts; return getAssignmentTargetKind(node) !== 0; } ts.isAssignmentTarget = isAssignmentTarget; + function isDeleteTarget(node) { + if (node.kind !== 177 && node.kind !== 178) { + return false; + } + node = node.parent; + while (node && node.kind === 183) { + node = node.parent; + } + return node && node.kind === 186; + } + ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { while (node) { if (node === ancestor) @@ -8274,7 +8324,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2) || (node.kind === 261 && node.isDeclarationFile)) { + if (hasModifier(node, 2) || (node.kind === 262 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -8287,7 +8337,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 239 || parent.kind === 243) { + if (parent.kind === 240 || parent.kind === 244) { if (parent.propertyName) { return true; } @@ -8313,8 +8363,8 @@ var ts; case 148: case 151: case 152: - case 260: - case 257: + case 261: + case 258: case 177: return parent.name === node; case 141: @@ -8326,22 +8376,22 @@ var ts; } return false; case 174: - case 239: + case 240: return parent.propertyName === node; - case 243: + case 244: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 234 || - node.kind === 233 || - node.kind === 236 && !!node.name || - node.kind === 237 || - node.kind === 239 || - node.kind === 243 || - node.kind === 240 && exportAssignmentIsAlias(node); + return node.kind === 235 || + node.kind === 234 || + node.kind === 237 && !!node.name || + node.kind === 238 || + node.kind === 240 || + node.kind === 244 || + node.kind === 241 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8521,13 +8571,13 @@ var ts; var kind = node.kind; return kind === 150 || kind === 184 - || kind === 225 + || kind === 226 || kind === 185 || kind === 149 || kind === 151 || kind === 152 - || kind === 230 - || kind === 261; + || kind === 231 + || kind === 262; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8649,14 +8699,13 @@ var ts; case 184: case 185: case 197: - case 246: case 247: + case 248: case 11: case 12: case 194: case 183: case 198: - case 297: return 19; case 181: case 177: @@ -8830,13 +8879,12 @@ var ts; "\u0085": "\\u0085" }); function escapeString(s) { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; - return s; - function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } + return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; + function getReplacement(c) { + return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); return ch.toLowerCase() === ch; @@ -9712,8 +9760,8 @@ var ts; var parseNode = getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 229: case 230: + case 231: return parseNode === parseNode.parent.name; } } @@ -9731,7 +9779,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 && declaration !== node) { + if (declaration.kind === 227 && declaration !== node) { return true; } } @@ -9782,6 +9830,10 @@ var ts; return node.kind === 70; } ts.isIdentifier = isIdentifier; + function isVoidExpression(node) { + return node.kind === 188; + } + ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { return isIdentifier(node) && node.autoGenerateKind > 0; } @@ -9849,18 +9901,18 @@ var ts; || kind === 151 || kind === 152 || kind === 155 - || kind === 203; + || kind === 204; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 257 - || kind === 258 + return kind === 258 || kind === 259 + || kind === 260 || kind === 149 || kind === 151 || kind === 152 - || kind === 244; + || kind === 245; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { @@ -9913,7 +9965,7 @@ var ts; ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 223: + case 224: case 144: case 174: return true; @@ -9991,8 +10043,8 @@ var ts; || kind === 178 || kind === 180 || kind === 179 - || kind === 246 || kind === 247 + || kind === 248 || kind === 181 || kind === 175 || kind === 183 @@ -10011,7 +10063,7 @@ var ts; || kind === 100 || kind === 96 || kind === 201 - || kind === 297; + || kind === 202; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); @@ -10039,7 +10091,6 @@ var ts; || kind === 196 || kind === 200 || kind === 198 - || kind === 297 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -10053,11 +10104,11 @@ var ts; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 294; + return node.kind === 295; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 293; + return node.kind === 294; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10070,11 +10121,11 @@ var ts; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 202; + return node.kind === 203; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 204; + return node.kind === 205; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -10092,121 +10143,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 223; + return node.kind === 224; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 224; + return node.kind === 225; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 232; + return node.kind === 233; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 231 - || kind === 230; + return kind === 232 + || kind === 231; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 234; + return node.kind === 235; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 236; + return node.kind === 237; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 238 - || kind === 237; + return kind === 239 + || kind === 238; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 239; + return node.kind === 240; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 242; + return node.kind === 243; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 243; + return node.kind === 244; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 230 || node.kind === 229; + return node.kind === 231 || node.kind === 230; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { return kind === 185 || kind === 174 - || kind === 226 + || kind === 227 || kind === 197 || kind === 150 - || kind === 229 - || kind === 260 - || kind === 243 - || kind === 225 + || kind === 230 + || kind === 261 + || kind === 244 + || kind === 226 || kind === 184 || kind === 151 - || kind === 236 - || kind === 234 - || kind === 239 - || kind === 227 + || kind === 237 + || kind === 235 + || kind === 240 + || kind === 228 || kind === 149 || kind === 148 - || kind === 230 - || kind === 233 - || kind === 237 + || kind === 231 + || kind === 234 + || kind === 238 || kind === 144 - || kind === 257 + || kind === 258 || kind === 147 || kind === 146 || kind === 152 - || kind === 258 - || kind === 228 + || kind === 259 + || kind === 229 || kind === 143 - || kind === 223 - || kind === 285; + || kind === 224 + || kind === 286; } function isDeclarationStatementKind(kind) { - return kind === 225 - || kind === 244 - || kind === 226 + return kind === 226 + || kind === 245 || kind === 227 || kind === 228 || kind === 229 || kind === 230 + || kind === 231 + || kind === 236 || kind === 235 - || kind === 234 + || kind === 242 || kind === 241 - || kind === 240 - || kind === 233; + || kind === 234; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 215 - || kind === 214 - || kind === 222 - || kind === 209 - || kind === 207 - || kind === 206 - || kind === 212 - || kind === 213 - || kind === 211 - || kind === 208 - || kind === 219 - || kind === 216 - || kind === 218 - || kind === 220 - || kind === 221 - || kind === 205 + return kind === 216 + || kind === 215 + || kind === 223 || kind === 210 + || kind === 208 + || kind === 207 + || kind === 213 + || kind === 214 + || kind === 212 + || kind === 209 + || kind === 220 || kind === 217 - || kind === 293 - || kind === 296 - || kind === 295; + || kind === 219 + || kind === 221 + || kind === 222 + || kind === 206 + || kind === 211 + || kind === 218 + || kind === 294 + || kind === 297 + || kind === 296; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10224,22 +10275,22 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 204; + || kind === 205; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 245 + return kind === 246 || kind === 141 || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 248; + return node.kind === 249; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 249; + return node.kind === 250; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { @@ -10251,60 +10302,60 @@ var ts; ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 246 - || kind === 252 - || kind === 247 + return kind === 247 + || kind === 253 + || kind === 248 || kind === 10; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 250 - || kind === 251; + return kind === 251 + || kind === 252; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 251; + return node.kind === 252; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 250; + return node.kind === 251; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 252; + || kind === 253; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 253 - || kind === 254; + return kind === 254 + || kind === 255; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 255; + return node.kind === 256; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 256; + return node.kind === 257; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 257; + return node.kind === 258; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 258; + return node.kind === 259; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isEnumMember(node) { - return node.kind === 260; + return node.kind === 261; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 261; + return node.kind === 262; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10445,7 +10496,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 143) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 227) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 228) { return current; } } @@ -10465,14 +10516,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 223) { + if (node.kind === 224) { node = node.parent; } - if (node && node.kind === 224) { + if (node && node.kind === 225) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 205) { + if (node && node.kind === 206) { flags |= ts.getModifierFlags(node); } return flags; @@ -10481,14 +10532,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 223) { + if (node.kind === 224) { node = node.parent; } - if (node && node.kind === 224) { + if (node && node.kind === 225) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 205) { + if (node && node.kind === 206) { flags |= node.flags; } return flags; @@ -10547,7 +10598,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 261 + var ConstructorForKind = kind === 262 ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -11243,7 +11294,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createTemplateSpan(expression, literal, location) { - var node = createNode(202, location); + var node = createNode(203, location); node.expression = expression; node.literal = literal; return node; @@ -11257,7 +11308,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, location, multiLine, flags) { - var block = createNode(204, location, flags); + var block = createNode(205, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -11273,7 +11324,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(205, location, flags); + var node = createNode(206, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -11288,7 +11339,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(224, location, flags); + var node = createNode(225, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -11301,7 +11352,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(223, location, flags); + var node = createNode(224, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11316,11 +11367,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(206, location); + return createNode(207, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(207, location, flags); + var node = createNode(208, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -11333,7 +11384,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(208, location); + var node = createNode(209, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11348,7 +11399,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(209, location); + var node = createNode(210, location); node.statement = statement; node.expression = expression; return node; @@ -11362,7 +11413,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(210, location); + var node = createNode(211, location); node.expression = expression; node.statement = statement; return node; @@ -11376,7 +11427,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(211, location, undefined); + var node = createNode(212, location, undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11392,7 +11443,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(212, location); + var node = createNode(213, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11407,7 +11458,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(213, location); + var node = createNode(214, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11422,7 +11473,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(214, location); + var node = createNode(215, location); if (label) { node.label = label; } @@ -11437,7 +11488,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(215, location); + var node = createNode(216, location); if (label) { node.label = label; } @@ -11452,7 +11503,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(216, location); + var node = createNode(217, location); node.expression = expression; return node; } @@ -11465,7 +11516,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(217, location); + var node = createNode(218, location); node.expression = expression; node.statement = statement; return node; @@ -11479,7 +11530,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(218, location); + var node = createNode(219, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11493,7 +11544,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(219, location); + var node = createNode(220, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11507,7 +11558,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(220, location); + var node = createNode(221, location); node.expression = expression; return node; } @@ -11520,7 +11571,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(221, location); + var node = createNode(222, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11535,7 +11586,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(232, location); + var node = createNode(233, location); node.clauses = createNodeArray(clauses); return node; } @@ -11548,7 +11599,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(225, location, flags); + var node = createNode(226, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11568,7 +11619,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(226, location); + var node = createNode(227, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11586,7 +11637,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(235, location); + var node = createNode(236, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11602,7 +11653,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(236, location); + var node = createNode(237, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11616,7 +11667,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(237, location); + var node = createNode(238, location); node.name = name; return node; } @@ -11629,7 +11680,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(238, location); + var node = createNode(239, location); node.elements = createNodeArray(elements); return node; } @@ -11642,7 +11693,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(239, location); + var node = createNode(240, location); node.propertyName = propertyName; node.name = name; return node; @@ -11656,7 +11707,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(240, location); + var node = createNode(241, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11672,7 +11723,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(241, location); + var node = createNode(242, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11688,7 +11739,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(242, location); + var node = createNode(243, location); node.elements = createNodeArray(elements); return node; } @@ -11701,7 +11752,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(243, location); + var node = createNode(244, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11715,7 +11766,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(246, location); + var node = createNode(247, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11730,7 +11781,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(247, location); + var node = createNode(248, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11744,7 +11795,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(248, location); + var node = createNode(249, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11758,7 +11809,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(249, location); + var node = createNode(250, location); node.tagName = tagName; return node; } @@ -11771,7 +11822,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(250, location); + var node = createNode(251, location); node.name = name; node.initializer = initializer; return node; @@ -11785,7 +11836,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(251, location); + var node = createNode(252, location); node.expression = expression; return node; } @@ -11797,21 +11848,22 @@ var ts; return node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, location) { - var node = createNode(252, location); + function createJsxExpression(expression, dotDotDotToken, location) { + var node = createNode(253, location); + node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node), node); + return updateNode(createJsxExpression(expression, node.dotDotDotToken, node), node); } return node; } ts.updateJsxExpression = updateJsxExpression; function createHeritageClause(token, types, location) { - var node = createNode(255, location); + var node = createNode(256, location); node.token = token; node.types = createNodeArray(types); return node; @@ -11825,7 +11877,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(253, location); + var node = createNode(254, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -11839,7 +11891,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(254, location); + var node = createNode(255, location); node.statements = createNodeArray(statements); return node; } @@ -11852,7 +11904,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(256, location); + var node = createNode(257, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11866,7 +11918,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer, location) { - var node = createNode(257, location); + var node = createNode(258, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11881,14 +11933,14 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(258, location); + var node = createNode(259, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; function createSpreadAssignment(expression, location) { - var node = createNode(259, location); + var node = createNode(260, location); node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; return node; } @@ -11909,7 +11961,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(261, node, node.flags); + var updated = createNode(262, node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -11969,27 +12021,27 @@ var ts; } ts.updateSourceFileNode = updateSourceFileNode; function createNotEmittedStatement(original) { - var node = createNode(293, original); + var node = createNode(294, original); node.original = original; return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createNode(296); + var node = createNode(297); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createNode(295); + var node = createNode(296); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(294, location || original); + var node = createNode(295, location || original); node.expression = expression; node.original = original; return node; @@ -12002,12 +12054,6 @@ var ts; return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; - function createRawExpression(text) { - var node = createNode(297); - node.text = text; - return node; - } - ts.createRawExpression = createRawExpression; function createComma(left, right) { return createBinary(left, 25, right); } @@ -12171,6 +12217,19 @@ var ts; return setEmitFlags(createIdentifier(name), 4096 | 2); } ts.getHelperName = getHelperName; + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 220 + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { @@ -12270,9 +12329,9 @@ var ts; case 151: case 152: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 257: - return createExpressionForPropertyAssignment(property, receiver); case 258: + return createExpressionForPropertyAssignment(property, receiver); + case 259: return createExpressionForShorthandPropertyAssignment(property, receiver); case 149: return createExpressionForMethodDeclaration(property, receiver); @@ -12630,7 +12689,7 @@ var ts; case 177: node = node.expression; continue; - case 294: + case 295: node = node.expression; continue; } @@ -12678,7 +12737,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 294) { + while (node.kind === 295) { node = node.expression; } return node; @@ -12738,7 +12797,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 261) { + if (node.kind === 262) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -12929,10 +12988,10 @@ var ts; var name_11 = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name_11) ? name_11 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 235 && node.importClause) { + if (node.kind === 236 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 241 && node.moduleSpecifier) { + if (node.kind === 242 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -12996,11 +13055,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 257: - return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 258: - return bindingElement.name; + return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 259: + return bindingElement.name; + case 260: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -13020,7 +13079,7 @@ var ts; case 174: return bindingElement.dotDotDotToken; case 196: - case 259: + case 260: return bindingElement; } return undefined; @@ -13036,7 +13095,7 @@ var ts; : propertyName; } break; - case 257: + case 258: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -13044,7 +13103,7 @@ var ts; : propertyName; } break; - case 259: + case 260: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -13149,15 +13208,15 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 235: + case 236: externalImports.push(node); break; - case 234: - if (node.moduleReference.kind === 245) { + case 235: + if (node.moduleReference.kind === 246) { externalImports.push(node); } break; - case 241: + case 242: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -13184,12 +13243,12 @@ var ts; } } break; - case 240: + case 241: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 205: + case 206: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -13197,7 +13256,7 @@ var ts; } } break; - case 225: + case 226: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -13215,7 +13274,7 @@ var ts; } } break; - case 226: + case 227: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -13263,7 +13322,7 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 261) { + if (kind === 262) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70) { @@ -13312,20 +13371,20 @@ var ts; return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 258: + case 259: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 259: + case 260: return visitNode(cbNode, node.expression); case 144: case 147: case 146: - case 257: - case 223: + case 258: + case 224: case 174: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -13351,7 +13410,7 @@ var ts; case 151: case 152: case 184: - case 225: + case 226: case 185: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -13443,6 +13502,8 @@ var ts; visitNode(cbNode, node.type); case 201: return visitNode(cbNode, node.expression); + case 202: + return visitNode(cbNode, node.name); case 193: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || @@ -13451,84 +13512,77 @@ var ts; visitNode(cbNode, node.whenFalse); case 196: return visitNode(cbNode, node.expression); - case 204: - case 231: + case 205: + case 232: return visitNodes(cbNodes, node.statements); - case 261: + case 262: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 205: + case 206: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 224: + case 225: return visitNodes(cbNodes, node.declarations); - case 207: - return visitNode(cbNode, node.expression); case 208: + return visitNode(cbNode, node.expression); + case 209: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 209: + case 210: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 210: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 211: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 212: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 213: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 214: - case 215: - return visitNode(cbNode, node.label); - case 216: - return visitNode(cbNode, node.expression); - case 217: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 215: + case 216: + return visitNode(cbNode, node.label); + case 217: + return visitNode(cbNode, node.expression); case 218: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 219: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 232: + case 233: return visitNodes(cbNodes, node.clauses); - case 253: + case 254: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 254: + case 255: return visitNodes(cbNodes, node.statements); - case 219: + case 220: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 220: - return visitNode(cbNode, node.expression); case 221: + return visitNode(cbNode, node.expression); + case 222: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 256: + case 257: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 145: return visitNode(cbNode, node.expression); - case 226: - case 197: - 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: + case 197: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13540,143 +13594,151 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 229: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 260: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 230: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 261: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 234: + case 235: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 235: + case 236: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 236: + case 237: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 233: - return visitNode(cbNode, node.name); - case 237: + case 234: return visitNode(cbNode, node.name); case 238: - case 242: + return visitNode(cbNode, node.name); + case 239: + case 243: return visitNodes(cbNodes, node.elements); - case 241: + case 242: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 239: - case 243: + case 240: + case 244: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 240: + case 241: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); case 194: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 202: + case 203: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 142: return visitNode(cbNode, node.expression); - case 255: + case 256: return visitNodes(cbNodes, node.types); case 199: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 245: - return visitNode(cbNode, node.expression); - case 244: - return visitNodes(cbNodes, node.decorators); case 246: + return visitNode(cbNode, node.expression); + case 245: + return visitNodes(cbNodes, node.decorators); + case 247: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 247: case 248: + case 249: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 250: + case 251: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 251: - return visitNode(cbNode, node.expression); case 252: return visitNode(cbNode, node.expression); - case 249: + case 253: + return visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.expression); + case 250: return visitNode(cbNode, node.tagName); - case 262: + case 263: return visitNode(cbNode, node.type); - case 266: - return visitNodes(cbNodes, node.types); case 267: return visitNodes(cbNodes, node.types); - case 265: + case 268: + return visitNodes(cbNodes, node.types); + case 266: return visitNode(cbNode, node.elementType); + case 270: + return visitNode(cbNode, node.type); case 269: return visitNode(cbNode, node.type); - case 268: - return visitNode(cbNode, node.type); - case 270: + case 271: return visitNode(cbNode, node.literal); - case 272: + case 273: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 273: - return visitNode(cbNode, node.type); case 274: + return visitNode(cbNode, node.type); + case 275: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 275: - return visitNode(cbNode, node.type); case 276: return visitNode(cbNode, node.type); case 277: return visitNode(cbNode, node.type); - case 271: + case 278: + return visitNode(cbNode, node.type); + case 272: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 278: + case 279: return visitNodes(cbNodes, node.tags); - case 281: + case 282: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 282: - return visitNode(cbNode, node.typeExpression); case 283: return visitNode(cbNode, node.typeExpression); - case 280: - return visitNode(cbNode, node.typeExpression); case 284: - return visitNodes(cbNodes, node.typeParameters); + return visitNode(cbNode, node.typeExpression); + case 281: + return visitNode(cbNode, node.typeExpression); case 285: + return visitNodes(cbNodes, node.typeParameters); + case 286: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 287: + case 288: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 286: + case 287: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 294: + case 295: return visitNode(cbNode, node.expression); - case 288: + case 289: return visitNode(cbNode, node.literal); } } @@ -13840,7 +13902,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(261, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(262, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -14459,7 +14521,7 @@ var ts; case 151: case 152: case 147: - case 203: + case 204: return true; case 149: var methodDeclaration = node; @@ -14473,8 +14535,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 253: case 254: + case 255: return true; } } @@ -14483,42 +14545,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 225: + case 226: + case 206: case 205: - case 204: + case 209: case 208: - case 207: - case 220: + case 221: + case 217: + case 219: case 216: - case 218: case 215: + case 213: case 214: case 212: - case 213: case 211: - case 210: - case 217: - case 206: - case 221: - case 219: - case 209: + case 218: + case 207: case 222: + case 220: + case 210: + case 223: + case 236: case 235: - case 234: + case 242: case 241: - case 240: - case 230: - case 226: + case 231: case 227: - case 229: case 228: + case 230: + case 229: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 260; + return node.kind === 261; } function isReusableTypeMember(node) { if (node) { @@ -14534,7 +14596,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 223) { + if (node.kind !== 224) { return false; } var variableDeclarator = node; @@ -14666,7 +14728,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(202); + var span = createNode(203); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -15791,8 +15853,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 248) { - var node = createNode(246, opening.pos); + if (opening.kind === 249) { + var node = createNode(247, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -15802,7 +15864,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 247); + ts.Debug.assert(opening.kind === 248); result = opening; } if (inExpressionContext && token() === 26) { @@ -15862,7 +15924,7 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token() === 28) { - node = createNode(248, fullStart); + node = createNode(249, fullStart); scanJsxText(); } else { @@ -15874,7 +15936,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(247, fullStart); + node = createNode(248, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -15893,9 +15955,10 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(252); + var node = createNode(253); parseExpected(16); if (token() !== 17) { + node.dotDotDotToken = parseOptionalToken(23); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { @@ -15912,7 +15975,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(250); + var node = createNode(251); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -15927,7 +15990,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(251); + var node = createNode(252); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -15935,7 +15998,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(249); + var node = createNode(250); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -16152,7 +16215,7 @@ var ts; var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23); if (dotDotDotToken) { - var spreadElement = createNode(259, fullStart); + var spreadElement = createNode(260, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -16171,7 +16234,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(258, fullStart); + var shorthandDeclaration = createNode(259, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -16182,7 +16245,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(257, fullStart); + var propertyAssignment = createNode(258, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -16228,8 +16291,15 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(180); + var fullStart = scanner.getStartPos(); parseExpected(93); + if (parseOptional(22)) { + var node_1 = createNode(202, fullStart); + node_1.keywordToken = 93; + node_1.name = parseIdentifierName(); + return finishNode(node_1); + } + var node = createNode(180, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18) { @@ -16238,7 +16308,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(204); + var node = createNode(205); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16269,12 +16339,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(206); + var node = createNode(207); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(208); + var node = createNode(209); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16284,7 +16354,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(209); + var node = createNode(210); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -16295,7 +16365,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(210); + var node = createNode(211); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16318,21 +16388,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(212, pos); + var forInStatement = createNode(213, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19); forOrForInOrForOfStatement = forInStatement; } else if (parseOptional(140)) { - var forOfStatement = createNode(213, pos); + var forOfStatement = createNode(214, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(211, pos); + var forStatement = createNode(212, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -16350,7 +16420,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 215 ? 71 : 76); + parseExpected(kind === 216 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16358,7 +16428,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(216); + var node = createNode(217); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -16367,7 +16437,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(217); + var node = createNode(218); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16376,7 +16446,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(253); + var node = createNode(254); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -16384,7 +16454,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(254); + var node = createNode(255); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -16394,12 +16464,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(218); + var node = createNode(219); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(232, scanner.getStartPos()); + var caseBlock = createNode(233, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -16407,14 +16477,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(220); + var node = createNode(221); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(221); + var node = createNode(222); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -16425,7 +16495,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(256); + var result = createNode(257); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -16435,7 +16505,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(222); + var node = createNode(223); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -16444,13 +16514,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(219, fullStart); + var labeledStatement = createNode(220, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(207, fullStart); + var expressionStatement = createNode(208, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -16602,9 +16672,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(214); - case 71: return parseBreakOrContinueStatement(215); + case 71: + return parseBreakOrContinueStatement(216); case 95: return parseReturnStatement(); case 106: @@ -16683,7 +16753,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(244, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(245, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -16755,7 +16825,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(223); + var node = createNode(224); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -16764,7 +16834,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(224); + var node = createNode(225); switch (token()) { case 103: break; @@ -16793,7 +16863,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(205, fullStart); + var node = createNode(206, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -16801,7 +16871,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -16986,7 +17056,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(203); + var result = createNode(204); nextToken(); return finishNode(result); } @@ -17020,7 +17090,7 @@ var ts; return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 197); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 227); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -17055,7 +17125,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 || token() === 107) { - var node = createNode(255); + var node = createNode(256); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -17078,7 +17148,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -17089,7 +17159,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228, fullStart); + var node = createNode(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(136); @@ -17101,13 +17171,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(260, scanner.getStartPos()); + var node = createNode(261, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -17122,7 +17192,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(231, scanner.getStartPos()); + var node = createNode(232, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -17133,7 +17203,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -17145,7 +17215,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (token() === 139) { @@ -17190,7 +17260,7 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(233, fullStart); + var exportDeclaration = createNode(234, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); @@ -17206,7 +17276,7 @@ var ts; if (isIdentifier()) { identifier = parseIdentifier(); if (token() !== 25 && token() !== 138) { - var importEqualsDeclaration = createNode(234, fullStart); + var importEqualsDeclaration = createNode(235, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -17216,7 +17286,7 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(235, fullStart); + var importDeclaration = createNode(236, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || @@ -17230,13 +17300,13 @@ var ts; return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(236, fullStart); + var importClause = createNode(237, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(238); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(239); } return finishNode(importClause); } @@ -17246,7 +17316,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(245); + var node = createNode(246); parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); @@ -17264,7 +17334,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(237); + var namespaceImport = createNode(238); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -17272,14 +17342,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 238 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 239 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(243); + return parseImportOrExportSpecifier(244); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(239); + return parseImportOrExportSpecifier(240); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17298,13 +17368,13 @@ var ts; else { node.name = identifierName; } - if (kind === 239 && checkIdentifierIsKeyword) { + if (kind === 240 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(241, fullStart); + var node = createNode(242, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38)) { @@ -17312,7 +17382,7 @@ var ts; node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(242); + node.exportClause = parseNamedImportsOrExports(243); if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { parseExpected(138); node.moduleSpecifier = parseModuleSpecifier(); @@ -17322,7 +17392,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(240, fullStart); + var node = createNode(241, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -17401,10 +17471,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 234 && node.moduleReference.kind === 245 - || node.kind === 235 - || node.kind === 240 + || node.kind === 235 && node.moduleReference.kind === 246 + || node.kind === 236 || node.kind === 241 + || node.kind === 242 ? node : undefined; }); @@ -17440,7 +17510,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(262, scanner.getTokenPos()); + var result = createNode(263, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -17451,12 +17521,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(266, type.pos); + var unionType = createNode(267, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(273, type.pos); + var optionalType = createNode(274, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -17467,20 +17537,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(265, type.pos); + var arrayType = createNode(266, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(268, type.pos); + var nullableType = createNode(269, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(269, type.pos); + var nonNullableType = createNode(270, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -17532,27 +17602,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(277); + var result = createNode(278); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(276); + var result = createNode(277); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(275); + var result = createNode(276); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(274); + var result = createNode(275); nextToken(); parseExpected(18); result.parameters = parseDelimitedList(23, parseJSDocParameter); @@ -17573,7 +17643,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(272); + var result = createNode(273); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -17613,18 +17683,18 @@ var ts; return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(270); + var result = createNode(271); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(269); + var result = createNode(270); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(267); + var result = createNode(268); nextToken(); result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); @@ -17638,7 +17708,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(266); + var result = createNode(267); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -17654,12 +17724,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(263); + var result = createNode(264); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(288); + var result = createNode(289); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -17672,11 +17742,11 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(264, pos); + var result = createNode(265, pos); return finishNode(result); } else { - var result = createNode(268, pos); + var result = createNode(269, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -17820,7 +17890,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(278, start); + var result = createNode(279, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -17930,7 +18000,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(279, atToken.pos); + var result = createNode(280, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -17985,7 +18055,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(281, atToken.pos); + var result = createNode(282, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -17996,20 +18066,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 282; })) { + if (ts.forEach(tags, function (t) { return t.kind === 283; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(282, atToken.pos); + var result = createNode(283, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283; })) { + if (ts.forEach(tags, function (t) { return t.kind === 284; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -18024,7 +18094,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(286, atToken.pos); + var result = createNode(287, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -18033,7 +18103,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(280, atToken.pos); + var result = createNode(281, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -18042,7 +18112,7 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(285, atToken.pos); + var typedefTag = createNode(286, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); @@ -18056,7 +18126,7 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 272) { + if (typeExpression.type.kind === 273) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { var name_16 = jsDocTypeReference.name; @@ -18074,7 +18144,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(287, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(288, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -18115,7 +18185,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(230, pos); + var jsDocNamespaceNode = createNode(231, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -18159,7 +18229,7 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284; })) { + if (ts.forEach(tags, function (t) { return t.kind === 285; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); @@ -18182,7 +18252,7 @@ var ts; break; } } - var result = createNode(284, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -18474,7 +18544,7 @@ var ts; } function visitArray(array) { if (position >= array.pos && position < array.end) { - for (var i = 0, n = array.length; i < n; i++) { + for (var i = 0; i < array.length; i++) { var child = array[i]; if (child) { if (child.pos === position) { @@ -18501,16 +18571,16 @@ var ts; var ts; (function (ts) { function getModuleInstanceState(node) { - if (node.kind === 227 || node.kind === 228) { + if (node.kind === 228 || node.kind === 229) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 235 || node.kind === 234) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 236 || node.kind === 235) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 231) { + else if (node.kind === 232) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -18526,7 +18596,7 @@ var ts; }); return state_1; } - else if (node.kind === 230) { + else if (node.kind === 231) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -18635,7 +18705,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 230)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 231)) { symbol.valueDeclaration = node; } } @@ -18666,9 +18736,9 @@ var ts; return "__new"; case 155: return "__index"; - case 241: + case 242: return "__export"; - case 240: + case 241: return node.isExportEquals ? "export=" : "default"; case 192: switch (ts.getSpecialPropertyAssignmentKind(node)) { @@ -18682,20 +18752,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 225: case 226: + case 227: return ts.hasModifier(node, 512) ? "default" : undefined; - case 274: + case 275: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; case 144: - ts.Debug.assert(node.parent.kind === 274); + ts.Debug.assert(node.parent.kind === 275); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 285: + case 286: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 205) { + if (parentNode && parentNode.kind === 206) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -18739,7 +18809,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 240 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 241 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -18759,7 +18829,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 243 || (node.kind === 234 && hasExportModifier)) { + if (node.kind === 244 || (node.kind === 235 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -18767,7 +18837,7 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 285 && + var isJSDocTypedefInJSDocNamespace = node.kind === 286 && node.name && node.name.kind === 70 && node.name.isInJSDocNamespace; @@ -18828,7 +18898,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 261) { + if (node.kind === 262) { node.flags |= emitFlags; } if (isIIFE) { @@ -18904,43 +18974,43 @@ var ts; return; } switch (node.kind) { - case 210: + case 211: bindWhileStatement(node); break; - case 209: + case 210: bindDoStatement(node); break; - case 211: + case 212: bindForStatement(node); break; - case 212: case 213: + case 214: bindForInOrForOfStatement(node); break; - case 208: + case 209: bindIfStatement(node); break; - case 216: - case 220: + case 217: + case 221: bindReturnOrThrow(node); break; + case 216: case 215: - case 214: bindBreakOrContinueStatement(node); break; - case 221: + case 222: bindTryStatement(node); break; - case 218: + case 219: bindSwitchStatement(node); break; - case 232: + case 233: bindCaseBlock(node); break; - case 253: + case 254: bindCaseClause(node); break; - case 219: + case 220: bindLabeledStatement(node); break; case 190: @@ -18958,7 +19028,7 @@ var ts; case 193: bindConditionalExpressionFlow(node); break; - case 223: + case 224: bindVariableDeclarationFlow(node); break; case 179: @@ -19124,11 +19194,11 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 208: - case 210: case 209: - return parent.expression === node; case 211: + case 210: + return parent.expression === node; + case 212: case 193: return parent.condition === node; } @@ -19192,7 +19262,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 219 + var enclosingLabeledStatement = node.parent.kind === 220 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -19227,7 +19297,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 224) { + if (node.initializer.kind !== 225) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -19249,7 +19319,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 216) { + if (node.kind === 217) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -19269,7 +19339,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 215 ? breakTarget : continueTarget; + var flowLabel = node.kind === 216 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -19326,7 +19396,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 254; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 255; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -19391,7 +19461,7 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 209) { + if (!node.statement || node.statement.kind !== 210) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } @@ -19422,13 +19492,13 @@ var ts; else if (node.kind === 176) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 257) { + if (p.kind === 258) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 258) { + else if (p.kind === 259) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 259) { + else if (p.kind === 260) { bindAssignmentTargetFlow(p.expression); } } @@ -19528,7 +19598,7 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 212 || node.parent.parent.kind === 213) { + if (node.initializer || node.parent.parent.kind === 213 || node.parent.parent.kind === 214) { bindInitializedVariableFlow(node); } } @@ -19555,28 +19625,28 @@ var ts; function getContainerFlags(node) { switch (node.kind) { case 197: - case 226: - case 229: + case 227: + case 230: case 176: case 161: - case 287: - case 270: + case 288: + case 271: return 1; - case 227: - return 1 | 64; - case 274: - case 230: case 228: + return 1 | 64; + case 275: + case 231: + case 229: case 170: return 1 | 32; - case 261: + case 262: return 1 | 4 | 32; case 149: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } case 150: - case 225: + case 226: case 148: case 151: case 152: @@ -19589,17 +19659,17 @@ var ts; case 184: case 185: return 1 | 4 | 32 | 8 | 16; - case 231: + case 232: return 4; case 147: return node.initializer ? 4 : 0; - case 256: - case 211: + case 257: case 212: case 213: - case 232: + case 214: + case 233: return 2; - case 204: + case 205: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -19615,20 +19685,20 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 230: + case 231: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 261: + case 262: return declareSourceFileMember(node, symbolFlags, symbolExcludes); case 197: - case 226: + case 227: return declareClassMember(node, symbolFlags, symbolExcludes); - case 229: + case 230: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 161: case 176: - case 227: - case 270: - case 287: + case 228: + case 271: + case 288: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); case 158: case 159: @@ -19640,11 +19710,11 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 184: case 185: - case 274: - case 228: + case 275: + case 229: case 170: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } @@ -19660,11 +19730,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 261 ? node : node.body; - if (body && (body.kind === 261 || body.kind === 231)) { + var body = node.kind === 262 ? node : node.body; + if (body && (body.kind === 262 || body.kind === 232)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 241 || stat.kind === 240) { + if (stat.kind === 242 || stat.kind === 241) { return true; } } @@ -19740,11 +19810,11 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 || prop.name.kind !== 70) { + if (prop.kind === 260 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 257 || prop.kind === 258 || prop.kind === 149 + var currentKind = prop.kind === 258 || prop.kind === 259 || prop.kind === 149 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -19766,10 +19836,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 230: + case 231: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 261: + case 262: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -19859,8 +19929,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 261 && - blockScopeContainer.kind !== 230 && + if (blockScopeContainer.kind !== 262 && + blockScopeContainer.kind !== 231 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -19943,14 +20013,14 @@ var ts; case 70: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 285) { + while (parentNode && parentNode.kind !== 286) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 258)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 259)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); @@ -19982,7 +20052,7 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 256: + case 257: return checkStrictModeCatchClause(node); case 186: return checkStrictModeDeleteExpression(node); @@ -19992,7 +20062,7 @@ var ts; return checkStrictModePostfixUnaryExpression(node); case 190: return checkStrictModePrefixUnaryExpression(node); - case 217: + case 218: return checkStrictModeWithStatement(node); case 167: seenThisKeyword = true; @@ -20003,22 +20073,22 @@ var ts; return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 144: return bindParameter(node); - case 223: + case 224: case 174: return bindVariableDeclarationOrBindingElement(node); case 147: case 146: - case 271: + case 272: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 286: + case 287: return bindJSDocProperty(node); - case 257: case 258: - return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 260: - return bindPropertyOrMethodOrAccessor(node, 8, 900095); case 259: - case 251: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 261: + return bindPropertyOrMethodOrAccessor(node, 8, 900095); + case 260: + case 252: var root = container; var hasRest = false; while (root.parent) { @@ -20039,7 +20109,7 @@ var ts; case 149: case 148: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 225: + case 226: return bindFunctionDeclaration(node); case 150: return declareSymbolAndAddToSymbolTable(node, 16384, 0); @@ -20049,12 +20119,12 @@ var ts; return bindPropertyOrMethodOrAccessor(node, 65536, 74687); case 158: case 159: - case 274: + case 275: return bindFunctionOrConstructorType(node); case 161: case 170: - case 287: - case 270: + case 288: + case 271: return bindAnonymousDeclaration(node, 2048, "__type"); case 176: return bindObjectLiteralExpression(node); @@ -20067,43 +20137,43 @@ var ts; } break; case 197: - case 226: + case 227: inStrictMode = true; return bindClassLikeDeclaration(node); - case 227: + case 228: return bindBlockScopedDeclaration(node, 64, 792968); - case 285: + case 286: if (!node.fullName || node.fullName.kind === 70) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 228: - return bindBlockScopedDeclaration(node, 524288, 793064); case 229: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 230: + return bindEnumDeclaration(node); + case 231: return bindModuleDeclaration(node); - case 234: - case 237: - case 239: - case 243: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 233: - return bindNamespaceExportDeclaration(node); - case 236: - return bindImportClause(node); - case 241: - return bindExportDeclaration(node); + case 235: + case 238: case 240: + case 244: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 234: + return bindNamespaceExportDeclaration(node); + case 237: + return bindImportClause(node); + case 242: + return bindExportDeclaration(node); + case 241: return bindExportAssignment(node); - case 261: + case 262: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 204: + case 205: if (!ts.isFunctionLike(node.parent)) { return; } - case 231: + case 232: return updateStrictModeStatementList(node.statements); } } @@ -20131,7 +20201,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 240 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 241 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -20141,17 +20211,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 261) { + if (node.parent.kind !== 262) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_4 = node.parent; - if (!ts.isExternalModule(parent_4)) { + var parent_5 = node.parent; + if (!ts.isExternalModule(parent_5)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_4.isDeclarationFile) { + if (!parent_5.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -20190,7 +20260,7 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 225 || container.kind === 184) { + if (container.kind === 226 || container.kind === 184) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } @@ -20226,7 +20296,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 226) { + if (node.kind === 227) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -20336,15 +20406,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 206) || - node.kind === 226 || - (node.kind === 230 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 229 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 207) || + node.kind === 227 || + (node.kind === 231 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 230 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 205 || + (node.kind !== 206 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -20362,13 +20432,13 @@ var ts; return computeCallExpression(node, subtreeFlags); case 180: return computeNewExpression(node, subtreeFlags); - case 230: + case 231: return computeModuleDeclaration(node, subtreeFlags); case 183: return computeParenthesizedExpression(node, subtreeFlags); case 192: return computeBinaryExpression(node, subtreeFlags); - case 207: + case 208: return computeExpressionStatement(node, subtreeFlags); case 144: return computeParameter(node, subtreeFlags); @@ -20376,23 +20446,23 @@ var ts; return computeArrowFunction(node, subtreeFlags); case 184: return computeFunctionExpression(node, subtreeFlags); - case 225: - return computeFunctionDeclaration(node, subtreeFlags); - case 223: - return computeVariableDeclaration(node, subtreeFlags); - case 224: - return computeVariableDeclarationList(node, subtreeFlags); - case 205: - return computeVariableStatement(node, subtreeFlags); - case 219: - return computeLabeledStatement(node, subtreeFlags); case 226: + return computeFunctionDeclaration(node, subtreeFlags); + case 224: + return computeVariableDeclaration(node, subtreeFlags); + case 225: + return computeVariableDeclarationList(node, subtreeFlags); + case 206: + return computeVariableStatement(node, subtreeFlags); + case 220: + return computeLabeledStatement(node, subtreeFlags); + case 227: return computeClassDeclaration(node, subtreeFlags); case 197: return computeClassExpression(node, subtreeFlags); - case 255: - return computeHeritageClause(node, subtreeFlags); case 256: + return computeHeritageClause(node, subtreeFlags); + case 257: return computeCatchClause(node, subtreeFlags); case 199: return computeExpressionWithTypeArguments(node, subtreeFlags); @@ -20405,7 +20475,7 @@ var ts; case 151: case 152: return computeAccessor(node, subtreeFlags); - case 234: + case 235: return computeImportEquals(node, subtreeFlags); case 177: return computePropertyAccess(node, subtreeFlags); @@ -20793,25 +20863,25 @@ var ts; case 116: case 123: case 75: - case 229: - case 260: + case 230: + case 261: case 182: case 200: case 201: case 130: transformFlags |= 3; break; - case 246: case 247: case 248: - case 10: case 249: + case 10: case 250: case 251: case 252: + case 253: transformFlags |= 4; break; - case 213: + case 214: transformFlags |= 8; case 12: case 13: @@ -20819,8 +20889,9 @@ var ts; case 15: case 194: case 181: - case 258: + case 259: case 114: + case 202: transformFlags |= 192; break; case 195: @@ -20850,8 +20921,8 @@ var ts; case 164: case 165: case 166: - case 227: case 228: + case 229: case 167: case 168: case 169: @@ -20869,7 +20940,7 @@ var ts; case 196: transformFlags |= 192 | 524288; break; - case 259: + case 260: transformFlags |= 8 | 1048576; break; case 96: @@ -20917,22 +20988,22 @@ var ts; transformFlags |= 192; } break; - case 209: case 210: case 211: case 212: + case 213: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 261: + case 262: if (subtreeFlags & 32768) { transformFlags |= 192; } break; - case 216: - case 214: + case 217: case 215: + case 216: transformFlags |= 33554432; break; } @@ -20948,18 +21019,18 @@ var ts; case 180: case 175: return 537396545; - case 230: + case 231: return 574674241; case 144: return 536872257; case 185: return 601249089; case 184: - case 225: - return 601281857; - case 224: - return 546309441; case 226: + return 601281857; + case 225: + return 546309441; + case 227: case 197: return 539358529; case 150: @@ -20981,12 +21052,12 @@ var ts; case 153: case 154: case 155: - case 227: case 228: + case 229: return -3; case 176: return 540087617; - case 256: + case 257: return 537920833; case 172: case 173: @@ -21056,9 +21127,11 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, + getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, + getTypeFromTypeNode: getTypeFromTypeNode, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -21067,6 +21140,7 @@ var ts; getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, + signatureToString: signatureToString, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -21089,7 +21163,8 @@ var ts; tryGetMemberInModuleExports: tryGetMemberInModuleExports, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { return tryFindAmbientModule(moduleName, false); - } + }, + getApparentType: getApparentType }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -21183,6 +21258,7 @@ var ts; var visitedFlowNodes = []; var visitedFlowTypes = []; var potentialThisCollisions = []; + var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var typeofEQFacts = ts.createMap({ @@ -21328,7 +21404,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 230 && source.valueDeclaration.kind !== 230))) { + (target.valueDeclaration.kind === 231 && source.valueDeclaration.kind !== 231))) { target.valueDeclaration = source.valueDeclaration; } ts.addRange(target.declarations, source.declarations); @@ -21423,7 +21499,7 @@ var ts; return type.flags & 32768 ? type.objectFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 261 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 262 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -21467,25 +21543,35 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 223 || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + if (declaration.kind === 174) { + var errorBindingElement = ts.getAncestor(usage, 174); + if (errorBindingElement) { + return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + declaration.pos < errorBindingElement.pos; + } + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 224), usage); + } + else if (declaration.kind === 224) { + return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); return isUsedInFunctionOrNonStaticProperty(usage, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 205: - case 211: - case 213: + case 206: + case 212: + case 214: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 212: case 213: + case 214: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } @@ -21512,6 +21598,15 @@ var ts; } return false; } + function getAncestorBindingPattern(node) { + while (node) { + if (ts.isBindingPattern(node)) { + return node; + } + node = node.parent; + } + return undefined; + } } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { var result; @@ -21525,7 +21620,7 @@ var ts; if (result = getSymbol(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 793064 && lastLocation.kind !== 278) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 279) { useResult = result.flags & 262144 ? lastLocation === location.type || lastLocation.kind === 144 || @@ -21548,13 +21643,13 @@ var ts; } } switch (location.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 230: + case 231: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 261 || ts.isAmbientModule(location)) { + if (location.kind === 262 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -21564,7 +21659,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 243)) { + ts.getDeclarationOfKind(moduleExports[name], 244)) { break; } } @@ -21572,7 +21667,7 @@ var ts; break loop; } break; - case 229: + case 230: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } @@ -21588,9 +21683,9 @@ var ts; } } break; - case 226: - case 197: case 227: + case 197: + case 228: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -21608,7 +21703,7 @@ var ts; break; case 142: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 227) { + if (ts.isClassLike(grandparent) || grandparent.kind === 228) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; @@ -21620,7 +21715,7 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 185: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; @@ -21684,7 +21779,7 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 233) { + if (decls && decls.length === 1 && decls[0].kind === 234) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -21764,7 +21859,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 223), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -21781,10 +21876,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 234) { + if (node.kind === 235) { return node; } - while (node && node.kind !== 235) { + while (node && node.kind !== 236) { node = node.parent; } return node; @@ -21794,7 +21889,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 245) { + if (node.moduleReference.kind === 246) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -21898,19 +21993,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 234: + case 235: return getTargetOfImportEqualsDeclaration(node); - case 236: - return getTargetOfImportClause(node); case 237: + return getTargetOfImportClause(node); + case 238: return getTargetOfNamespaceImport(node); - case 239: - return getTargetOfImportSpecifier(node); - case 243: - return getTargetOfExportSpecifier(node); case 240: + return getTargetOfImportSpecifier(node); + case 244: + return getTargetOfExportSpecifier(node); + case 241: return getTargetOfExportAssignment(node); - case 233: + case 234: return getTargetOfNamespaceExportDeclaration(node); } } @@ -21954,10 +22049,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 240) { + if (node.kind === 241) { checkExpressionCached(node.expression); } - else if (node.kind === 243) { + else if (node.kind === 244) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -21973,7 +22068,7 @@ var ts; return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 234); + ts.Debug.assert(entityName.parent.kind === 235); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -22270,11 +22365,11 @@ var ts; } } switch (location_1.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 230: + case 231: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -22318,7 +22413,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -22350,7 +22445,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -22423,7 +22518,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 261 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 262 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -22461,7 +22556,7 @@ var ts; meaning = 107455 | 1048576; } else if (entityName.kind === 141 || entityName.kind === 177 || - entityName.parent.kind === 234) { + entityName.parent.kind === 235) { meaning = 1920; } else { @@ -22556,7 +22651,7 @@ var ts; while (node.kind === 166) { node = node.parent; } - if (node.kind === 228) { + if (node.kind === 229) { return getSymbolOfNode(node); } } @@ -22564,7 +22659,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 231 && + node.parent.kind === 232 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -22633,9 +22728,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_5 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_5) { - walkSymbol(parent_5, getQualifiedLeftMeaning(meaning), false); + var parent_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_6) { + walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -22768,12 +22863,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_6 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_6); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_6, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -22832,7 +22927,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 261 || declaration.parent.kind === 231; + return declaration.parent.kind === 262 || declaration.parent.kind === 232; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -22845,25 +22940,6 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } - function writeIndexSignature(info, keyword) { - if (info) { - if (info.isReadonly) { - writeKeyword(writer, 130); - writeSpace(writer); - } - writePunctuation(writer, 20); - writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55); - writeSpace(writer); - writeKeyword(writer, keyword); - writePunctuation(writer, 21); - writePunctuation(writer, 55); - writeSpace(writer); - writeType(info.type, 0); - writePunctuation(writer, 24); - writer.writeLine(); - } - } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { writeKeyword(writer, 130); @@ -22946,8 +23022,8 @@ var ts; writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 134); - writeIndexSignature(resolved.numberIndexInfo, 132); + buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0, enclosingDeclaration, globalFlags, symbolStack); + buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, 1, enclosingDeclaration, globalFlags, symbolStack); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -23126,6 +23202,10 @@ var ts; buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + var returnType = getReturnTypeOfSignature(signature); + if (flags & 2048 && isTypeAny(returnType)) { + return; + } if (flags & 8) { writeSpace(writer); writePunctuation(writer, 35); @@ -23138,7 +23218,6 @@ var ts; buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); } else { - var returnType = getReturnTypeOfSignature(signature); buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } } @@ -23156,6 +23235,32 @@ var ts; buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } + function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 130); + writeSpace(writer); + } + writePunctuation(writer, 20); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 55); + writeSpace(writer); + switch (kind) { + case 1: + writeKeyword(writer, 132); + break; + case 0: + writeKeyword(writer, 134); + break; + } + writePunctuation(writer, 21); + writePunctuation(writer, 55); + writeSpace(writer); + buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); + writePunctuation(writer, 24); + writer.writeLine(); + } + } return _displayBuilder || (_displayBuilder = { buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, @@ -23166,6 +23271,7 @@ var ts; buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, + buildIndexSignatureDisplay: buildIndexSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay }); } @@ -23182,27 +23288,27 @@ var ts; switch (node.kind) { case 174: return isDeclarationVisible(node.parent.parent); - case 223: + case 224: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 230: - case 226: + case 231: case 227: case 228: - case 225: case 229: - case 234: + case 226: + case 230: + case 235: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_7 = getDeclarationContainer(node); + var parent_8 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 234 && parent_7.kind !== 261 && ts.isInAmbientContext(parent_7))) { - return isGlobalSourceFile(parent_7); + !(node.kind !== 235 && parent_8.kind !== 262 && ts.isInAmbientContext(parent_8))) { + return isGlobalSourceFile(parent_8); } - return isDeclarationVisible(parent_7); + return isDeclarationVisible(parent_8); case 147: case 146: case 151: @@ -23217,7 +23323,7 @@ var ts; case 153: case 155: case 144: - case 231: + case 232: case 158: case 159: case 161: @@ -23228,15 +23334,15 @@ var ts; case 165: case 166: return isDeclarationVisible(node.parent); - case 236: case 237: - case 239: + case 238: + case 240: return false; case 143: - case 261: - case 233: + case 262: + case 234: return true; - case 240: + case 241: return false; default: return false; @@ -23245,10 +23351,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 240) { + if (node.parent && node.parent.kind === 241) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 243) { + else if (node.parent.kind === 244) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -23326,12 +23432,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 223: case 224: + case 225: + case 240: case 239: case 238: case 237: - case 236: node = node.parent; break; default: @@ -23350,9 +23456,6 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1) !== 0; } - function isTypeNever(type) { - return type && (type.flags & 8192) !== 0; - } function getTypeForBindingElementParent(node) { var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); @@ -23487,11 +23590,11 @@ var ts; return type; } } - if (declaration.parent.parent.kind === 212) { + if (declaration.parent.parent.kind === 213) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 | 262144) ? indexType : stringType; } - if (declaration.parent.parent.kind === 213) { + if (declaration.parent.parent.kind === 214) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -23501,7 +23604,7 @@ var ts; return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && - declaration.kind === 223 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 224 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -23539,7 +23642,7 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 258) { + if (declaration.kind === 259) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -23614,7 +23717,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 257) { + if (declaration.kind === 258) { return type; } return getWidenedType(type); @@ -23642,10 +23745,10 @@ var ts; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 240) { + if (declaration.kind === 241) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 && declaration.kind === 286 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 287 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { @@ -23852,8 +23955,8 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 226 || node.kind === 197 || - node.kind === 225 || node.kind === 184 || + if (node.kind === 227 || node.kind === 197 || + node.kind === 226 || node.kind === 184 || node.kind === 149 || node.kind === 185) { var declarations = node.typeParameters; if (declarations) { @@ -23863,15 +23966,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 227); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 228); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 227 || node.kind === 226 || - node.kind === 197 || node.kind === 228) { + if (node.kind === 228 || node.kind === 227 || + node.kind === 197 || node.kind === 229) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -24004,7 +24107,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 228 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -24033,7 +24136,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227) { + if (declaration.kind === 228) { if (declaration.flags & 64) { return false; } @@ -24083,7 +24186,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 285); + var declaration = ts.getDeclarationOfKind(symbol, 286); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -24094,7 +24197,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 228); + declaration = ts.getDeclarationOfKind(symbol, 229); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -24126,7 +24229,7 @@ var ts; function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 230) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -24154,7 +24257,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 230) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -24629,8 +24732,8 @@ var ts; else { var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; @@ -24901,7 +25004,7 @@ var ts; } function isJSDocOptionalParameter(node) { if (node.flags & 65536) { - if (node.type && node.type.kind === 273) { + if (node.type && node.type.kind === 274) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -24912,7 +25015,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 273; + return paramTag.typeExpression.type.kind === 274; } } } @@ -24964,7 +25067,7 @@ var ts; var thisParameter = undefined; var hasThisParameter = void 0; var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); - for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { + for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) { @@ -25047,12 +25150,12 @@ var ts; if (!symbol) return emptyArray; var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { + for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { case 158: case 159: - case 225: + case 226: case 149: case 148: case 150: @@ -25063,7 +25166,7 @@ var ts; case 152: case 184: case 185: - case 274: + case 275: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -25335,7 +25438,7 @@ var ts; switch (node.kind) { case 157: return node.typeName; - case 272: + case 273: return node.name; case 199: var expr = node.expression; @@ -25361,7 +25464,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 272) { + if (symbol.flags & 107455 && node.kind === 273) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -25371,7 +25474,7 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 272) { + if (node.kind === 273) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); @@ -25406,9 +25509,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 226: case 227: - case 229: + case 228: + case 230: return declaration; } } @@ -25582,8 +25685,9 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; + if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } } @@ -25693,8 +25797,8 @@ var ts; } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; addTypeToIntersection(typeSet, type); } } @@ -25812,7 +25916,7 @@ var ts; getIndexInfoOfType(objectType, 0) || undefined; if (indexInfo) { - if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return unknownType; } @@ -25924,7 +26028,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 228 ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 229 ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -26047,7 +26151,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 227)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 228)) { if (!(ts.getModifierFlags(container) & 32) && (container.kind !== 150 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -26066,8 +26170,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118: - case 263: case 264: + case 265: return anyType; case 134: return stringType; @@ -26085,21 +26189,21 @@ var ts; return nullType; case 129: return neverType; - case 289: - return nullType; case 290: - return undefinedType; + return nullType; case 291: + return undefinedType; + case 292: return neverType; case 167: case 98: return getTypeFromThisTypeNode(node); case 171: return getTypeFromLiteralTypeNode(node); - case 288: + case 289: return getTypeFromLiteralTypeNode(node.literal); case 157: - case 272: + case 273: return getTypeFromTypeReference(node); case 156: return booleanType; @@ -26108,29 +26212,29 @@ var ts; case 160: return getTypeFromTypeQueryNode(node); case 162: - case 265: + case 266: return getTypeFromArrayTypeNode(node); case 163: return getTypeFromTupleTypeNode(node); case 164: - case 266: + case 267: return getTypeFromUnionTypeNode(node); case 165: return getTypeFromIntersectionTypeNode(node); case 166: - case 268: case 269: - case 276: - case 277: - case 273: - return getTypeFromTypeNode(node.type); case 270: + case 277: + case 278: + case 274: + return getTypeFromTypeNode(node.type); + case 271: return getTypeFromTypeNode(node.literal); case 158: case 159: case 161: - case 287: - case 274: + case 288: + case 275: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 168: return getTypeFromTypeOperatorNode(node); @@ -26142,9 +26246,9 @@ var ts; case 141: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 267: + case 268: return getTypeFromJSDocTupleType(node); - case 275: + case 276: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -26293,17 +26397,19 @@ var ts; var constraintType = getConstraintTypeFromMappedType(type); if (constraintType.flags & 262144) { var typeVariable_1 = constraintType.type; - var mappedTypeVariable = instantiateType(typeVariable_1, mapper); - if (typeVariable_1 !== mappedTypeVariable) { - return mapType(mappedTypeVariable, function (t) { - if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); - } - return t; - }); + if (typeVariable_1.flags & 16384) { + var mappedTypeVariable = instantiateType(typeVariable_1, mapper); + if (typeVariable_1 !== mappedTypeVariable) { + return mapType(mappedTypeVariable, function (t) { + if (isMappableType(t)) { + var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); + var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); + combinedMapper.mappedTypes = mapper.mappedTypes; + return instantiateMappedObjectType(type, combinedMapper); + } + return t; + }); + } } } return instantiateMappedObjectType(type, mapper); @@ -26324,12 +26430,12 @@ var ts; return false; } var mappedTypes = mapper.mappedTypes; - var node = symbol.declarations[0].parent; + var node = symbol.declarations[0]; while (node) { switch (node.kind) { case 158: case 159: - case 225: + case 226: case 149: case 148: case 150: @@ -26340,10 +26446,10 @@ var ts; case 152: case 184: case 185: - case 226: - case 197: case 227: + case 197: case 228: + case 229: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -26353,15 +26459,24 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 227) { + if (ts.isClassLike(node) || node.kind === 228) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 230: - case 261: + case 275: + var func = node; + for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { + var p = _c[_b]; + if (ts.contains(mappedTypes, getTypeOfNode(p))) { + return true; + } + } + break; + case 231: + case 262: return false; } node = node.parent; @@ -26371,7 +26486,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 261 || parentKind === 231; + return parentKind === 262 || parentKind === 232; } return false; } @@ -26438,7 +26553,7 @@ var ts; case 192: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 257: + case 258: return isContextSensitive(node.initializer); case 149: case 148: @@ -26494,7 +26609,7 @@ var ts; return isTypeRelatedTo(source, target, assignableRelation); } function isTypeInstanceOf(source, target) { - return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); } function isTypeComparableTo(source, target) { return isTypeRelatedTo(source, target, comparableRelation); @@ -27196,8 +27311,11 @@ var ts; } } } - else if (relation !== identityRelation && isEmptyObjectType(resolveStructuredTypeMembers(target))) { - return -1; + else if (relation !== identityRelation) { + var resolved = resolveStructuredTypeMembers(target); + if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1) { + return -1; + } } return 0; } @@ -27348,7 +27466,7 @@ var ts; return 0; } var result = -1; - for (var i = 0, len = sourceSignatures.length; i < len; i++) { + for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], false, false, false, isRelatedTo); if (!related) { return 0; @@ -27557,8 +27675,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var t = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var t = types_8[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -27566,8 +27684,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -27658,8 +27776,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; result |= getFalsyFlags(t); } return result; @@ -27818,7 +27936,7 @@ var ts; case 174: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 225: + case 226: case 149: case 148: case 151: @@ -28159,8 +28277,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -28276,7 +28394,7 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 223 || target.kind === 174) && + (target.kind === 224 || target.kind === 174) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; @@ -28374,8 +28492,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getTypeFacts(t); } return result; @@ -28461,7 +28579,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 || node.parent.kind === 257 ? + return node.parent.kind === 175 || node.parent.kind === 258 ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } @@ -28480,9 +28598,9 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 212: - return stringType; case 213: + return stringType; + case 214: return checkRightHandSideOfForOf(parent.expression) || unknownType; case 192: return getAssignedTypeOfBinaryExpression(parent); @@ -28492,9 +28610,9 @@ var ts; return getAssignedTypeOfArrayLiteralElement(parent, node); case 196: return getAssignedTypeOfSpreadExpression(parent); - case 257: - return getAssignedTypeOfPropertyAssignment(parent); case 258: + return getAssignedTypeOfPropertyAssignment(parent); + case 259: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -28517,26 +28635,26 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 212) { + if (node.parent.parent.kind === 213) { return stringType; } - if (node.parent.parent.kind === 213) { + if (node.parent.parent.kind === 214) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 223 ? + return node.kind === 224 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 223 || node.kind === 174 ? + return node.kind === 224 || node.kind === 174 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 223 && node.initializer && + return node.kind === 224 && node.initializer && isEmptyArrayLiteral(node.initializer) || node.kind !== 174 && node.parent.kind === 192 && isEmptyArrayLiteral(node.parent.right); @@ -28563,7 +28681,7 @@ var ts; getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 253) { + if (clause.kind === 254) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -28665,8 +28783,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -29208,8 +29326,8 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 231 || - node.kind === 261 || + node.kind === 232 || + node.kind === 262 || node.kind === 147) { return node; } @@ -29279,7 +29397,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; - if (declaration_1.kind === 226 + if (declaration_1.kind === 227 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -29307,6 +29425,7 @@ var ts; } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkCollisionWithCapturedNewTargetVariable(node, node); checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; @@ -29334,7 +29453,7 @@ var ts; flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0 || isInTypeQuery(node)) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); if (type === autoType || type === autoArrayType) { @@ -29365,7 +29484,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 256) { + symbol.valueDeclaration.parent.kind === 257) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -29383,8 +29502,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 211 && - ts.getAncestor(symbol.valueDeclaration, 224).parent === container && + if (container.kind === 212 && + ts.getAncestor(symbol.valueDeclaration, 225).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -29474,10 +29593,10 @@ var ts; needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 230: + case 231: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 229: + case 230: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; case 150: @@ -29535,9 +29654,9 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 274) { + if (jsdocType && jsdocType.kind === 275) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 277) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 278) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -29831,8 +29950,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -29902,13 +30021,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 250) { + if (attribute.kind === 251) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 251) { + else if (attribute.kind === 252) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -29926,14 +30045,14 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 223: + case 224: case 144: case 147: case 146: case 174: return getContextualTypeForInitializerExpression(node); case 185: - case 216: + case 217: return getContextualTypeForReturnExpression(node); case 195: return getContextualTypeForYieldOperand(parent); @@ -29945,22 +30064,22 @@ var ts; return getTypeFromTypeNode(parent.type); case 192: return getContextualTypeForBinaryOperand(node); - case 257: case 258: + case 259: return getContextualTypeForObjectLiteralElement(parent); case 175: return getContextualTypeForElementExpression(node); case 193: return getContextualTypeForConditionalOperand(node); - case 202: + case 203: ts.Debug.assert(parent.parent.kind === 194); return getContextualTypeForSubstitutionExpression(parent.parent, node); case 183: return getContextualType(parent); - case 252: + case 253: return getContextualType(parent); - case 250: case 251: + case 252: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -30012,8 +30131,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -30156,25 +30275,25 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 257 || - memberDecl.kind === 258 || + if (memberDecl.kind === 258 || + memberDecl.kind === 259 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 257) { + if (memberDecl.kind === 258) { type = checkPropertyAssignment(memberDecl, contextualMapper); } else if (memberDecl.kind === 149) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 258); + ts.Debug.assert(memberDecl.kind === 259); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 257 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 258 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 258 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 259 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912; } @@ -30200,7 +30319,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 259) { + else if (memberDecl.kind === 260) { if (languageVersion < 5) { checkExternalEmitHelpers(memberDecl, 2); } @@ -30300,13 +30419,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 252: + case 253: checkJsxExpression(child); break; - case 246: + case 247: checkJsxElement(child); break; - case 247: + case 248: checkJsxSelfClosingElement(child); break; } @@ -30601,11 +30720,11 @@ var ts; var nameTable = ts.createMap(); var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 250) { + if (node.attributes[i].kind === 251) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 251); + ts.Debug.assert(node.attributes[i].kind === 252); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -30624,7 +30743,11 @@ var ts; } function checkJsxExpression(node) { if (node.expression) { - return checkExpression(node.expression); + var type = checkExpression(node.expression); + if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { + error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); + } + return type; } else { return unknownType; @@ -30642,7 +30765,7 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 || node.kind === 223 ? + var errorNode = node.kind === 177 || node.kind === 224 ? node.name : node.right; if (left.kind === 96) { @@ -30788,7 +30911,7 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 224) { + if (initializer.kind === 225) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -30810,7 +30933,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 212 && + if (node.kind === 213 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -30906,19 +31029,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_8 = signature.declaration && signature.declaration.parent; + var parent_9 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_8 === lastParent) { + if (lastParent && parent_9 === lastParent) { index++; } else { - lastParent = parent_8; + lastParent = parent_9; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_8; + lastParent = parent_9; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -31138,7 +31261,7 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 145) { switch (node.parent.kind) { - case 226: + case 227: case 197: return 1; case 147: @@ -31159,7 +31282,7 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } @@ -31180,7 +31303,7 @@ var ts; return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } @@ -31217,7 +31340,7 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } @@ -31578,7 +31701,7 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 226: + case 227: case 197: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 144: @@ -31688,9 +31811,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 225 + ? 226 : resolvedRequire.flags & 3 - ? 223 + ? 224 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -31716,6 +31839,23 @@ var ts; function checkNonNullAssertion(node) { return getNonNullableType(checkExpression(node.expression)); } + function checkMetaProperty(node) { + checkGrammarMetaProperty(node); + ts.Debug.assert(node.keywordToken === 93 && node.name.text === "target", "Unrecognized meta-property."); + var container = ts.getNewTargetContainer(node); + if (!container) { + error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); + return unknownType; + } + else if (container.kind === 150) { + var symbol = getSymbolOfNode(container.parent); + return getTypeOfSymbol(symbol); + } + else { + var symbol = getSymbolOfNode(container); + return getTypeOfSymbol(symbol); + } + } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks) { @@ -31823,7 +31963,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 204) { + if (func.body.kind !== 205) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -31902,7 +32042,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 218 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 219 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -31948,7 +32088,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 204 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 205 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -32014,6 +32154,7 @@ var ts; if (produceDiagnostics && node.kind !== 149) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); } return type; } @@ -32028,7 +32169,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 204) { + if (node.body.kind === 205) { checkSourceElement(node.body); } else { @@ -32081,7 +32222,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 237; + return declaration && declaration.kind === 238; } } } @@ -32097,6 +32238,16 @@ var ts; } function checkDeleteExpression(node) { checkExpression(node.expression); + var expr = ts.skipParentheses(node.expression); + if (expr.kind !== 177 && expr.kind !== 178) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); + return booleanType; + } + var links = getNodeLinks(expr); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } return booleanType; } function checkTypeOfExpression(node) { @@ -32167,8 +32318,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -32182,8 +32333,8 @@ var ts; } if (type.flags & 65536) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -32192,8 +32343,8 @@ var ts; } if (type.flags & 131072) { var types = type.types; - for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { - var t = types_17[_a]; + for (var _a = 0, types_18 = types; _a < types_18.length; _a++) { + var t = types_18[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -32240,7 +32391,7 @@ var ts; return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 257 || property.kind === 258) { + if (property.kind === 258 || property.kind === 259) { var name_22 = property.name; if (name_22.kind === 142) { checkComputedPropertyName(name_22); @@ -32255,7 +32406,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 258) { + if (property.kind === 259) { return checkDestructuringAssignment(property, type); } else { @@ -32266,7 +32417,7 @@ var ts; error(name_22, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_22)); } } - else if (property.kind === 259) { + else if (property.kind === 260) { if (languageVersion < 5) { checkExternalEmitHelpers(property, 4); } @@ -32334,7 +32485,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 258) { + if (exprOrAssignment.kind === 259) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -32362,7 +32513,7 @@ var ts; } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 259 ? + var error = target.parent.kind === 260 ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -32391,8 +32542,8 @@ var ts; case 176: case 187: case 201: + case 248: case 247: - case 246: return true; case 193: return isSideEffectFree(node.whenTrue) && @@ -32826,6 +32977,8 @@ var ts; return checkAssertion(node); case 201: return checkNonNullAssertion(node); + case 202: + return checkMetaProperty(node); case 186: return checkDeleteExpression(node); case 188: @@ -32846,13 +32999,13 @@ var ts; return undefinedWideningType; case 195: return checkYieldExpression(node); - case 252: + case 253: return checkJsxExpression(node); - case 246: - return checkJsxElement(node); case 247: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 248: + return checkJsxSelfClosingElement(node); + case 249: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -32897,7 +33050,7 @@ var ts; return false; } return node.kind === 149 || - node.kind === 225 || + node.kind === 226 || node.kind === 184; } function getTypePredicateParameterIndex(parameterList, parameter) { @@ -32956,14 +33109,14 @@ var ts; switch (node.parent.kind) { case 185: case 153: - case 225: + case 226: case 184: case 158: case 149: case 148: - var parent_9 = node.parent; - if (node === parent_9.type) { - return parent_9; + var parent_10 = node.parent; + if (node === parent_10.type) { + return parent_10; } } } @@ -32991,7 +33144,7 @@ var ts; if (node.kind === 155) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 || node.kind === 225 || node.kind === 159 || + else if (node.kind === 158 || node.kind === 226 || node.kind === 159 || node.kind === 153 || node.kind === 150 || node.kind === 154) { checkGrammarFunctionLikeDeclaration(node); @@ -33113,7 +33266,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 227) { + if (node.kind === 228) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -33195,7 +33348,7 @@ var ts; if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 && n.kind !== 225) { + else if (n.kind !== 184 && n.kind !== 226) { ts.forEachChild(n, markThisReferencesAsErrors); } } @@ -33220,7 +33373,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -33369,8 +33522,8 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 227 && - n.parent.kind !== 226 && + if (n.parent.kind !== 228 && + n.parent.kind !== 227 && n.parent.kind !== 197 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { @@ -33481,11 +33634,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 227 || node.parent.kind === 161 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 228 || node.parent.kind === 161 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 225 || node.kind === 149 || node.kind === 148 || node.kind === 150) { + if (node.kind === 226 || node.kind === 149 || node.kind === 148 || node.kind === 150) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -33596,16 +33749,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 227: + case 228: return 2097152; - case 230: + case 231: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 226: - case 229: + case 227: + case 230: return 2097152 | 1048576; - case 234: + case 235: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -33617,7 +33770,8 @@ var ts; } function checkNonThenableType(type, location, message) { type = getWidenedType(type); - if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + var apparentType = getApparentType(type); + if ((apparentType.flags & (1 | 8192)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -33752,7 +33906,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 226: + case 227: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -33807,7 +33961,7 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 226: + case 227: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -33840,6 +33994,7 @@ var ts; checkFunctionOrMethodDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -33890,28 +34045,28 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 261: - case 230: + case 262: + case 231: checkUnusedModuleMembers(node); break; - case 226: + case 227: case 197: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 227: + case 228: checkUnusedTypeParameters(node); break; - case 204: - case 232: - case 211: + case 205: + case 233: case 212: case 213: + case 214: checkUnusedLocalsAndParameters(node); break; case 150: case 184: - case 225: + case 226: case 185: case 149: case 151: @@ -33935,7 +34090,7 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 227 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 228 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_2 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { @@ -33968,9 +34123,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 223 && - (declaration.parent.parent.kind === 212 || - declaration.parent.parent.kind === 213)) { + if (declaration.kind === 224 && + (declaration.parent.parent.kind === 213 || + declaration.parent.parent.kind === 214)) { return; } } @@ -34031,7 +34186,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - error(declaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + errorUnusedLocal(declaration.name, local.name); } } } @@ -34039,7 +34194,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 204) { + if (node.kind === 205) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -34083,6 +34238,11 @@ var ts; potentialThisCollisions.push(node); } } + function checkCollisionWithCapturedNewTargetVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_newTarget")) { + potentialNewTargetCollisions.push(node); + } + } function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; while (current) { @@ -34099,6 +34259,22 @@ var ts; current = current.parent; } } + function checkIfNewTargetIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 8) { + var isDeclaration_2 = node.kind !== 70; + if (isDeclaration_2) { + error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); + } + return; + } + current = current.parent; + } + } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -34108,8 +34284,8 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 70; - if (isDeclaration_2) { + var isDeclaration_3 = node.kind !== 70; + if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -34124,11 +34300,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 262 && ts.isExternalOrCommonJsModule(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)); } } @@ -34136,11 +34312,11 @@ var ts; if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 262 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -34148,7 +34324,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 223 && !node.initializer) { + if (node.kind === 224 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -34158,15 +34334,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 224); - var container = varDeclList.parent.kind === 205 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 225); + var container = varDeclList.parent.kind === 206 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 204 && ts.isFunctionLike(container.parent) || + (container.kind === 205 && ts.isFunctionLike(container.parent) || + container.kind === 232 || container.kind === 231 || - container.kind === 230 || - container.kind === 261); + container.kind === 262); if (!namesShareScope) { var name_25 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_25, name_25); @@ -34199,7 +34375,8 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144) { + if (symbol.valueDeclaration.kind === 144 || + symbol.valueDeclaration.kind === 174) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -34237,19 +34414,19 @@ var ts; } } if (node.kind === 174) { - if (node.parent.kind === 172 && languageVersion < 5) { + if (node.parent.kind === 172 && languageVersion < 5 && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4); } if (node.propertyName && node.propertyName.kind === 142) { checkComputedPropertyName(node.propertyName); } - var parent_10 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_10); + var parent_11 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_11); var name_26 = node.propertyName || node.name; var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_26)); markPropertyAsReferenced(property); - if (parent_10.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_10, parent_10.initializer, parentType, property); + if (parent_11.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { @@ -34260,7 +34437,7 @@ var ts; return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 213) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -34269,7 +34446,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 213) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -34289,18 +34466,19 @@ var ts; } if (node.kind !== 147 && node.kind !== 146) { checkExportsOnMergedDeclarations(node); - if (node.kind === 223 || node.kind === 174) { + if (node.kind === 224 || node.kind === 174) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 && right.kind === 223) || - (left.kind === 223 && right.kind === 144)) { + if ((left.kind === 144 && right.kind === 224) || + (left.kind === 224 && right.kind === 144)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -34346,7 +34524,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 206) { + if (node.thenStatement.kind === 207) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -34363,12 +34541,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 224) { + if (node.initializer && node.initializer.kind === 225) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -34386,7 +34564,7 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { checkForInOrForOfVariableDeclaration(node); } else { @@ -34411,7 +34589,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { 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); @@ -34668,7 +34846,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 254 && !hasDuplicateDefaultClause) { + if (clause.kind === 255 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -34680,7 +34858,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 253) { + if (produceDiagnostics && clause.kind === 254) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); var caseIsLiteral = isLiteralType(caseType); @@ -34706,7 +34884,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 219 && current.label.text === node.label.text) { + if (current.kind === 220 && 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; @@ -34829,7 +35007,7 @@ var ts; } function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { @@ -34849,7 +35027,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 || declaration.kind === 227) { + if (declaration.kind === 227 || declaration.kind === 228) { if (!firstDecl) { firstDecl = declaration; } @@ -34882,6 +35060,7 @@ var ts; if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -34917,7 +35096,7 @@ var ts; checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 226) { + baseType_1.symbol.valueDeclaration.kind === 227) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -35044,7 +35223,7 @@ var ts; if (!list1 || !list2 || list1.length !== list2.length) { return false; } - for (var i = 0, len = list1.length; i < len; i++) { + for (var i = 0; i < list1.length; i++) { var tp1 = list1[i]; var tp2 = list2[i]; if (tp1.name.text !== tp2.name.text) { @@ -35102,7 +35281,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 228); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -35233,6 +35412,7 @@ var ts; } return undefined; case 8: + checkGrammarNumericLiteral(e); return +e.text; case 183: return evalConstant(e.expression); @@ -35306,6 +35486,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); @@ -35326,7 +35507,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 229) { + if (declaration.kind !== 230) { return false; } var enumDeclaration = declaration; @@ -35349,8 +35530,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 226 || - (declaration.kind === 225 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 227 || + (declaration.kind === 226 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -35409,7 +35590,7 @@ 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, 226); + var mergedClass = ts.getDeclarationOfKind(symbol, 227); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -35452,22 +35633,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 205: + case 206: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 240: case 241: + case 242: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 234: case 235: + case 236: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; case 174: - case 223: + case 224: var name_27 = node.name; if (ts.isBindingPattern(name_27)) { for (var _b = 0, _c = name_27.elements; _b < _c.length; _b++) { @@ -35476,12 +35657,12 @@ var ts; } break; } - case 226: - case 229: - case 225: case 227: case 230: + case 226: case 228: + case 231: + case 229: if (isGlobalAugmentation) { return; } @@ -35517,9 +35698,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { - error(moduleName, node.kind === 241 ? + var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 && !inAmbientExternalModule) { + error(moduleName, node.kind === 242 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -35540,7 +35721,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 243 ? + var message = node.kind === 244 ? 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)); @@ -35567,7 +35748,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237) { + if (importClause.namedBindings.kind === 238) { checkImportBinding(importClause.namedBindings); } else { @@ -35618,8 +35799,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -35632,7 +35813,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 261 || node.parent.kind === 231 || node.parent.kind === 230; + var isInAppropriateContext = node.parent.kind === 262 || node.parent.kind === 232 || node.parent.kind === 231; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -35655,9 +35836,14 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 261 ? node.parent : node.parent.parent; - if (container.kind === 230 && !ts.isAmbientModule(container)) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + var container = node.parent.kind === 262 ? node.parent : node.parent.parent; + if (container.kind === 231 && !ts.isAmbientModule(container)) { + if (node.isExportEquals) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + } + else { + error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); + } return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { @@ -35723,7 +35909,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 225 && declaration.kind !== 149) || + return (declaration.kind !== 226 && declaration.kind !== 149) || !!declaration.body; } } @@ -35734,10 +35920,10 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 230: - case 226: + case 231: case 227: - case 225: + case 228: + case 226: cancellationToken.throwIfCancellationRequested(); } } @@ -35786,71 +35972,71 @@ var ts; return checkIndexedAccessType(node); case 170: return checkMappedType(node); - case 225: + case 226: return checkFunctionDeclaration(node); - case 204: - case 231: - return checkBlock(node); case 205: + case 232: + return checkBlock(node); + case 206: return checkVariableStatement(node); - case 207: - return checkExpressionStatement(node); case 208: - return checkIfStatement(node); + return checkExpressionStatement(node); case 209: - return checkDoStatement(node); + return checkIfStatement(node); case 210: - return checkWhileStatement(node); + return checkDoStatement(node); case 211: - return checkForStatement(node); + return checkWhileStatement(node); case 212: - return checkForInStatement(node); + return checkForStatement(node); case 213: - return checkForOfStatement(node); + return checkForInStatement(node); case 214: + return checkForOfStatement(node); case 215: - return checkBreakOrContinueStatement(node); case 216: - return checkReturnStatement(node); + return checkBreakOrContinueStatement(node); case 217: - return checkWithStatement(node); + return checkReturnStatement(node); case 218: - return checkSwitchStatement(node); + return checkWithStatement(node); case 219: - return checkLabeledStatement(node); + return checkSwitchStatement(node); case 220: - return checkThrowStatement(node); + return checkLabeledStatement(node); case 221: + return checkThrowStatement(node); + case 222: return checkTryStatement(node); - case 223: + case 224: return checkVariableDeclaration(node); case 174: return checkBindingElement(node); - case 226: - return checkClassDeclaration(node); case 227: - return checkInterfaceDeclaration(node); + return checkClassDeclaration(node); case 228: - return checkTypeAliasDeclaration(node); + return checkInterfaceDeclaration(node); case 229: - return checkEnumDeclaration(node); + return checkTypeAliasDeclaration(node); case 230: + return checkEnumDeclaration(node); + case 231: return checkModuleDeclaration(node); - case 235: + case 236: return checkImportDeclaration(node); - case 234: + case 235: return checkImportEqualsDeclaration(node); - case 241: + case 242: return checkExportDeclaration(node); - case 240: + case 241: return checkExportAssignment(node); - case 206: + case 207: checkGrammarStatementInAmbientContext(node); return; - case 222: + case 223: checkGrammarStatementInAmbientContext(node); return; - case 244: + case 245: return checkMissingDeclaration(node); } } @@ -35893,6 +36079,7 @@ var ts; } checkGrammarSourceFile(node); potentialThisCollisions.length = 0; + potentialNewTargetCollisions.length = 0; deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; ts.forEach(node.statements, checkSourceElement); @@ -35912,6 +36099,10 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } + if (potentialNewTargetCollisions.length) { + ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); + potentialNewTargetCollisions.length = 0; + } links.flags |= 1; } } @@ -35956,7 +36147,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 217 && node.parent.statement === node) { + if (node.parent.kind === 218 && node.parent.statement === node) { return true; } node = node.parent; @@ -35978,14 +36169,14 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230: + case 231: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 229: + case 230: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; case 197: @@ -35993,8 +36184,8 @@ var ts; if (className) { copySymbol(location.symbol, meaning); } - case 226: case 227: + case 228: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } @@ -36039,10 +36230,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 143: - case 226: case 227: case 228: case 229: + case 230: return true; } } @@ -36051,7 +36242,7 @@ var ts; while (node.parent && node.parent.kind === 141) { node = node.parent; } - return node.parent && (node.parent.kind === 157 || node.parent.kind === 272); + return node.parent && (node.parent.kind === 157 || node.parent.kind === 273); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; @@ -36078,10 +36269,10 @@ var ts; while (nodeOnRightSide.parent.kind === 141) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 234) { + if (nodeOnRightSide.parent.kind === 235) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 240) { + if (nodeOnRightSide.parent.kind === 241) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -36105,11 +36296,11 @@ var ts; default: } } - if (entityName.parent.kind === 240 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 241 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } if (entityName.kind !== 177 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 234); + var importEqualsDeclaration = ts.getAncestor(entityName, 235); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -36156,10 +36347,10 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 272) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 273) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 250) { + else if (entityName.parent.kind === 251) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 156) { @@ -36168,7 +36359,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 261) { + if (node.kind === 262) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -36221,7 +36412,7 @@ var ts; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 235 || node.parent.kind === 241) && + ((node.parent.kind === 236 || node.parent.kind === 242) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -36243,7 +36434,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 258) { + if (location && location.kind === 259) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -36294,7 +36485,7 @@ var ts; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { ts.Debug.assert(expr.kind === 176 || expr.kind === 175); - if (expr.parent.kind === 213) { + if (expr.parent.kind === 214) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -36302,7 +36493,7 @@ var ts; var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 257) { + if (expr.parent.kind === 258) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } @@ -36413,7 +36604,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 261) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 262) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -36451,7 +36642,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 204 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 205 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -36491,16 +36682,16 @@ var ts; return true; } switch (node.kind) { - case 234: - case 236: + case 235: case 237: - case 239: - case 243: + case 238: + case 240: + case 244: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 241: + case 242: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 240: + case 241: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -36510,7 +36701,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 261 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 262 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -36561,7 +36752,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 260) { + if (node.kind === 261) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -36655,9 +36846,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_11 = reference.parent; - if (ts.isDeclaration(parent_11) && reference === parent_11.name) { - location = getDeclarationContainer(parent_11); + var parent_12 = reference.parent; + if (ts.isDeclaration(parent_12) && reference === parent_12.name) { + location = getDeclarationContainer(parent_12); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -36770,15 +36961,15 @@ var ts; } var current = symbol; while (true) { - var parent_12 = getParentOfSymbol(current); - if (parent_12) { - current = parent_12; + var parent_13 = getParentOfSymbol(current); + if (parent_13) { + current = parent_13; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 261 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 262 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -36797,7 +36988,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 261); + return ts.getDeclarationOfKind(moduleSymbol, 262); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -36974,7 +37165,7 @@ var ts; } switch (modifier.kind) { case 75: - if (node.kind !== 229 && node.parent.kind === 226) { + if (node.kind !== 230 && node.parent.kind === 227) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -37000,7 +37191,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 232 || node.parent.kind === 262) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -37023,7 +37214,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 232 || node.parent.kind === 262) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 144) { @@ -37058,7 +37249,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 144) { @@ -37073,13 +37264,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 231) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 232) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -37089,14 +37280,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 226) { + if (node.kind !== 227) { if (node.kind !== 149 && node.kind !== 147 && node.kind !== 151 && node.kind !== 152) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 226 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 227 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -37138,7 +37329,7 @@ var ts; } return; } - else if ((node.kind === 235 || node.kind === 234) && flags & 2) { + else if ((node.kind === 236 || node.kind === 235) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 144 && (flags & 92) && ts.isBindingPattern(node.name)) { @@ -37168,29 +37359,29 @@ var ts; case 149: case 148: case 155: - case 230: + case 231: + case 236: case 235: - case 234: + case 242: case 241: - case 240: case 184: case 185: case 144: return false; default: - if (node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 232 || node.parent.kind === 262) { return false; } switch (node.kind) { - case 225: - return nodeHasAnyModifiersExcept(node, 119); case 226: - return nodeHasAnyModifiersExcept(node, 116); + return nodeHasAnyModifiersExcept(node, 119); case 227: - case 205: + return nodeHasAnyModifiersExcept(node, 116); case 228: - return true; + case 206: case 229: + return true; + case 230: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -37204,7 +37395,7 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 149: - case 225: + case 226: case 184: case 185: if (!node.asteriskToken) { @@ -37410,7 +37601,7 @@ var ts; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 225 || + ts.Debug.assert(node.kind === 226 || node.kind === 184 || node.kind === 149); if (ts.isInAmbientContext(node)) { @@ -37437,14 +37628,14 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259) { + if (prop.kind === 260) { continue; } var name_30 = prop.name; if (name_30.kind === 142) { checkGrammarComputedPropertyName(name_30); } - if (prop.kind === 258 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 259 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { @@ -37456,7 +37647,7 @@ var ts; } } var currentKind = void 0; - if (prop.kind === 257 || prop.kind === 258) { + if (prop.kind === 258 || prop.kind === 259) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_30.kind === 8) { checkGrammarNumericLiteral(name_30); @@ -37505,7 +37696,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 251) { + if (attr.kind === 252) { continue; } var jsxAttr = attr; @@ -37517,7 +37708,7 @@ var ts; return grammarErrorOnNode(name_31, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 252 && !initializer.expression) { + if (initializer && initializer.kind === 253 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -37526,7 +37717,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 224) { + if (forInOrOfStatement.initializer.kind === 225) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -37534,20 +37725,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? 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 = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? 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 === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? 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); @@ -37631,7 +37822,7 @@ 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 === 227) { + else if (node.parent.kind === 228) { 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 === 161) { @@ -37645,9 +37836,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 219: + case 220: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 214 + var isMisplacedContinueLabel = node.kind === 215 && !ts.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); @@ -37655,8 +37846,8 @@ var ts; return false; } break; - case 218: - if (node.kind === 215 && !node.label) { + case 219: + if (node.kind === 216 && !node.label) { return false; } break; @@ -37669,13 +37860,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 215 + var message = node.kind === 216 ? 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 === 215 + var message = node.kind === 216 ? 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); @@ -37701,7 +37892,7 @@ var ts; expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 212 && node.parent.parent.kind !== 213) { + if (node.parent.parent.kind !== 213 && node.parent.parent.kind !== 214) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -37758,15 +37949,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 208: case 209: case 210: - case 217: case 211: + case 218: case 212: case 213: + case 214: return false; - case 219: + case 220: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -37781,6 +37972,13 @@ var ts; } } } + function checkGrammarMetaProperty(node) { + if (node.keywordToken === 93) { + if (node.name.text !== "target") { + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + } + } + } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -37821,7 +38019,7 @@ var ts; return true; } } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 228) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -37842,13 +38040,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 227 || - node.kind === 228 || + if (node.kind === 228 || + node.kind === 229 || + node.kind === 236 || node.kind === 235 || - node.kind === 234 || + node.kind === 242 || node.kind === 241 || - node.kind === 240 || - node.kind === 233 || + node.kind === 234 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -37857,7 +38055,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 === 205) { + if (ts.isDeclaration(decl) || decl.kind === 206) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -37876,7 +38074,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 === 204 || node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 205 || node.parent.kind === 232 || node.parent.kind === 262) { 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); @@ -37887,8 +38085,22 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.isOctalLiteral && languageVersion >= 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + if (node.isOctalLiteral) { + var diagnosticMessage = void 0; + if (languageVersion >= 1) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 171)) { + diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 261)) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; + } + if (diagnosticMessage) { + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37; + var literal = (withMinus ? "-" : "") + "0o" + node.text; + return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); + } } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -37933,31 +38145,31 @@ var ts; _a[201] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[229] = [ + _a[230] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[230] = [ + _a[231] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[231] = [ + _a[232] = [ { name: "statements", test: ts.isStatement } ], - _a[234] = [ + _a[235] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[245] = [ + _a[246] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[260] = [ + _a[261] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -37983,11 +38195,11 @@ var ts; } var result = initial; switch (node.kind) { - case 203: - case 206: + case 204: + case 207: case 198: - case 222: - case 293: + case 223: + case 294: break; case 142: result = reduceNode(node.expression, cbNode, result); @@ -38128,72 +38340,72 @@ var ts; result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 202: + case 203: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 204: + case 205: result = reduceNodes(node.statements, cbNodes, result); break; - case 205: + case 206: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 207: + case 208: result = reduceNode(node.expression, cbNode, result); break; - case 208: + case 209: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 209: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; case 210: - case 217: - result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); break; case 211: + case 218: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 212: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 212: case 213: + case 214: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 216: - case 220: + case 217: + case 221: result = reduceNode(node.expression, cbNode, result); break; - case 218: + case 219: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 219: + case 220: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 221: + case 222: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 223: + case 224: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 224: + case 225: result = reduceNodes(node.declarations, cbNodes, result); break; - case 225: + case 226: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38202,7 +38414,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 226: + case 227: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38210,92 +38422,92 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 232: + case 233: result = reduceNodes(node.clauses, cbNodes, result); break; - case 235: + case 236: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 236: + case 237: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 237: - result = reduceNode(node.name, cbNode, result); - break; case 238: - case 242: - result = reduceNodes(node.elements, cbNodes, result); + result = reduceNode(node.name, cbNode, result); break; case 239: case 243: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 240: + case 244: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 240: + case 241: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 241: + case 242: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 246: + case 247: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 247: case 248: + case 249: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.attributes, cbNodes, result); break; - case 249: + case 250: result = reduceNode(node.tagName, cbNode, result); break; - case 250: + case 251: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 251: - result = reduceNode(node.expression, cbNode, result); - break; case 252: result = reduceNode(node.expression, cbNode, result); break; case 253: result = reduceNode(node.expression, cbNode, result); + break; case 254: + result = reduceNode(node.expression, cbNode, result); + case 255: result = reduceNodes(node.statements, cbNodes, result); break; - case 255: + case 256: result = reduceNodes(node.types, cbNodes, result); break; - case 256: + case 257: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 257: + case 258: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 258: + case 259: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 259: + case 260: result = reduceNode(node.expression, cbNode, result); break; - case 261: + case 262: result = reduceNodes(node.statements, cbNodes, result); break; - case 294: + case 295: result = reduceNode(node.expression, cbNode, result); break; default: @@ -38436,10 +38648,10 @@ var ts; return node; } switch (node.kind) { - case 203: - case 206: + case 204: + case 207: case 198: - case 222: + case 223: return node; case 142: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); @@ -38507,101 +38719,101 @@ var ts; return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); case 199: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 202: + case 203: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 204: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); case 205: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 206: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 207: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 208: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 209: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); case 210: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); case 211: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 212: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 213: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 214: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 215: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 216: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 217: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); case 218: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 219: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); case 220: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 221: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 222: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); - case 223: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 224: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 225: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); case 226: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 227: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 232: + case 233: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 235: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 236: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 237: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 238: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 239: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 240: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 241: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 242: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); case 243: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 244: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 246: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 247: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 248: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 249: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 250: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); case 251: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 252: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 253: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 254: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); case 255: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); case 256: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); case 257: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); case 258: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); case 259: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 260: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); - case 261: + case 262: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 294: + case 295: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -38689,7 +38901,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || ts.isTypeNode(node)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 199)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -39093,15 +39305,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 261: + case 262: + case 233: case 232: - case 231: - case 204: + case 205: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 227: case 226: - case 225: if (ts.hasModifier(node, 2)) { break; } @@ -39126,13 +39338,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 240: - return visitExportAssignment(node); case 241: + return visitExportAssignment(node); + case 242: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -39142,11 +39354,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 241 || - node.kind === 235 || + if (node.kind === 242 || node.kind === 236 || - (node.kind === 234 && - node.moduleReference.kind === 245)) { + node.kind === 237 || + (node.kind === 235 && + node.moduleReference.kind === 246)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -39170,7 +39382,7 @@ var ts; case 152: case 149: return visitorWorker(node); - case 203: + case 204: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -39227,18 +39439,18 @@ var ts; case 171: case 155: case 145: - case 228: + case 229: case 147: return undefined; case 150: return visitConstructor(node); - case 227: + case 228: return ts.createNotEmittedStatement(node); - case 226: + case 227: return visitClassDeclaration(node); case 197: return visitClassExpression(node); - case 255: + case 256: return visitHeritageClause(node); case 199: return visitExpressionWithTypeArguments(node); @@ -39248,7 +39460,7 @@ var ts; return visitGetAccessor(node); case 152: return visitSetAccessor(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -39267,15 +39479,15 @@ var ts; return visitNewExpression(node); case 201: return visitNonNullExpression(node); - case 229: - return visitEnumDeclaration(node); - case 205: - return visitVariableStatement(node); - case 223: - return visitVariableDeclaration(node); case 230: + return visitEnumDeclaration(node); + case 206: + return visitVariableStatement(node); + case 224: + return visitVariableDeclaration(node); + case 231: return visitModuleDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39429,7 +39641,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -39714,7 +39926,7 @@ var ts; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 226: + case 227: case 197: return ts.getFirstConstructorWithBody(node) !== undefined; case 149: @@ -39732,7 +39944,7 @@ var ts; return serializeTypeNode(node.type); case 152: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 226: + case 227: case 197: case 149: return ts.createIdentifier("Function"); @@ -39789,6 +40001,9 @@ var ts; } switch (node.kind) { case 104: + case 137: + case 94: + case 129: return ts.createVoidZero(); case 166: return serializeTypeNode(node.type); @@ -39827,29 +40042,7 @@ var ts; return serializeTypeReferenceNode(node); case 165: case 164: - { - var unionOrIntersection = node; - var serializedUnion = void 0; - for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - var serializedIndividual = serializeTypeNode(typeNode); - if (serializedIndividual.kind !== 70) { - serializedUnion = undefined; - break; - } - if (serializedIndividual.text === "Object") { - return serializedIndividual; - } - if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { - serializedUnion = undefined; - break; - } - serializedUnion = serializedIndividual; - } - if (serializedUnion) { - return serializedUnion; - } - } + return serializeUnionOrIntersectionType(node); case 160: case 168: case 169: @@ -39864,6 +40057,32 @@ var ts; } return ts.createIdentifier("Object"); } + function serializeUnionOrIntersectionType(node) { + var serializedUnion; + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (ts.isVoidExpression(serializedIndividual)) { + if (!serializedUnion) { + serializedUnion = serializedIndividual; + } + } + else if (ts.isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") { + return serializedIndividual; + } + else if (serializedUnion && !ts.isVoidExpression(serializedUnion)) { + if (!ts.isIdentifier(serializedUnion) || + !ts.isIdentifier(serializedIndividual) || + serializedUnion.text !== serializedIndividual.text) { + return ts.createIdentifier("Object"); + } + } + else { + serializedUnion = serializedIndividual; + } + } + return serializedUnion; + } function serializeTypeReferenceNode(node) { switch (resolver.getTypeReferenceSerializationKind(node.typeName, currentScope)) { case ts.TypeReferenceSerializationKind.Unknown: @@ -40190,7 +40409,7 @@ var ts; ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 229) { + if (node.kind === 230) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -40250,8 +40469,8 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 231) { - ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); + if (body.kind === 232) { + saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; } @@ -40273,13 +40492,13 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 231) { + if (body.kind !== 232) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 230) { + if (moduleDeclaration.body.kind === 231) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -40299,7 +40518,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 237) { + if (node.kind === 238) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -40434,15 +40653,15 @@ var ts; if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(258); - context.enableEmitNotification(230); + context.enableSubstitution(259); + context.enableEmitNotification(231); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 230; + return ts.getOriginalNode(node).kind === 231; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 229; + return ts.getOriginalNode(node).kind === 230; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -40515,9 +40734,9 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 261) { - var substitute = (applicableSubstitutions & 2 && container.kind === 230) || - (applicableSubstitutions & 8 && container.kind === 229); + if (container && container.kind !== 262) { + var substitute = (applicableSubstitutions & 2 && container.kind === 231) || + (applicableSubstitutions & 8 && container.kind === 230); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -40632,11 +40851,11 @@ var ts; return visitObjectLiteralExpression(node); case 192: return visitBinaryExpression(node, noDestructuringValue); - case 223: + case 224: return visitVariableDeclaration(node); - case 213: + case 214: return visitForOfStatement(node); - case 211: + case 212: return visitForStatement(node); case 188: return visitVoidExpression(node); @@ -40648,7 +40867,7 @@ var ts; return visitGetAccessorDeclaration(node); case 152: return visitSetAccessorDeclaration(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -40656,7 +40875,7 @@ var ts; return visitArrowFunction(node); case 144: return visitParameter(node); - case 207: + case 208: return visitExpressionStatement(node); case 183: return visitParenthesizedExpression(node, noDestructuringValue); @@ -40669,7 +40888,7 @@ var ts; var objects = []; for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { var e = elements_3[_i]; - if (e.kind === 259) { + if (e.kind === 260) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -40681,7 +40900,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 257) { + if (e.kind === 258) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -40854,11 +41073,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 246: - return visitJsxElement(node, false); case 247: + return visitJsxElement(node, false); + case 248: return visitJsxSelfClosingElement(node, false); - case 252: + case 253: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -40868,11 +41087,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 252: + case 253: return visitJsxExpression(node); - case 246: - return visitJsxElement(node, true); case 247: + return visitJsxElement(node, true); + case 248: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -40926,7 +41145,10 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, node) : node; } - else if (node.kind === 252) { + else if (node.kind === 253) { + if (node.expression === undefined) { + return ts.createLiteral(true); + } return visitJsxExpression(node); } else { @@ -40991,7 +41213,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 246) { + if (node.kind === 247) { return getTagName(node.openingElement); } else { @@ -41310,7 +41532,7 @@ var ts; return visitAwaitExpression(node); case 149: return visitMethodDeclaration(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -41409,7 +41631,7 @@ var ts; context.enableSubstitution(179); context.enableSubstitution(177); context.enableSubstitution(178); - context.enableEmitNotification(226); + context.enableEmitNotification(227); context.enableEmitNotification(149); context.enableEmitNotification(151); context.enableEmitNotification(152); @@ -41465,7 +41687,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 226 + return kind === 227 || kind === 150 || kind === 149 || kind === 151 @@ -41604,15 +41826,7 @@ var ts; context.onSubstituteNode = onSubstituteNode; var currentSourceFile; var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - var isInConstructorWithCapturedSuper; + var hierarchyFacts; var convertedLoopState; var enabledSubstitutions; return transformSourceFile; @@ -41622,178 +41836,104 @@ var ts; } currentSourceFile = node; currentText = node.text; - var visited = saveStateAndInvoke(node, visitSourceFile); + var visited = visitSourceFile(node); ts.addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined; currentText = undefined; + hierarchyFacts = 0; return visited; } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); + function enterSubtree(excludeFacts, includeFacts) { + var ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383; + return ancestorFacts; } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - isInConstructorWithCapturedSuper = false; - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 185) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 131072)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - switch (currentNode.kind) { - case 205: - enclosingVariableStatement = currentNode; - break; - case 224: - case 223: - case 174: - case 172: - case 173: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function returnCapturedThis(node) { - return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 216 && !node.expression; + return hierarchyFacts & 4096 + && node.kind === 217 + && !node.expression; } - function shouldCheckNode(node) { - return (node.transformFlags & 64) !== 0 || - node.kind === 219 || - (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); + function shouldVisitNode(node) { + return (node.transformFlags & 128) !== 0 + || convertedLoopState !== undefined + || (hierarchyFacts & 4096 && ts.isStatement(node)) + || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } - function visitorWorker(node) { - if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { - return returnCapturedThis(node); - } - else if (shouldCheckNode(node)) { + function visitor(node) { + if (shouldVisitNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { - return ts.visitEachChild(node, visitor, context); - } else { return node; } } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function functionBodyVisitor(node) { + if (shouldVisitNode(node)) { + return visitBlock(node, true); } - else { - result = visitNodesInConvertedLoop(node); - } - return result; + return node; } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 216: - node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; - return visitReturnStatement(node); - case 205: - return visitVariableStatement(node); - case 218: - return visitSwitchStatement(node); - case 215: - case 214: - return visitBreakOrContinueStatement(node); - case 98: - return visitThisKeyword(node); - case 70: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); + function callExpressionVisitor(node) { + if (node.kind === 96) { + return visitSuperKeyword(true); } + return visitor(node); } function visitJavaScript(node) { switch (node.kind) { case 114: return undefined; - case 226: + case 227: return visitClassDeclaration(node); case 197: return visitClassExpression(node); case 144: return visitParameter(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 185: return visitArrowFunction(node); case 184: return visitFunctionExpression(node); - case 223: + case 224: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 224: + case 225: return visitVariableDeclarationList(node); case 219: + return visitSwitchStatement(node); + case 233: + return visitCaseBlock(node); + case 205: + return visitBlock(node, false); + case 216: + case 215: + return visitBreakOrContinueStatement(node); + case 220: return visitLabeledStatement(node); - case 209: - return visitDoStatement(node); case 210: - return visitWhileStatement(node); case 211: - return visitForStatement(node); + return visitDoOrWhileStatement(node, undefined); case 212: - return visitForInStatement(node); + return visitForStatement(node, undefined); case 213: - return visitForOfStatement(node); - case 207: + return visitForInStatement(node, undefined); + case 214: + return visitForOfStatement(node, undefined); + case 208: return visitExpressionStatement(node); case 176: return visitObjectLiteralExpression(node); - case 256: + case 257: return visitCatchClause(node); - case 258: + case 259: return visitShorthandPropertyAssignment(node); + case 142: + return visitComputedPropertyName(node); case 175: return visitArrayLiteralExpression(node); case 179: @@ -41818,51 +41958,80 @@ var ts; case 196: return visitSpreadElement(node); case 96: - return visitSuperKeyword(); - case 195: - return ts.visitEachChild(node, visitor, context); + return visitSuperKeyword(false); + case 98: + return visitThisKeyword(node); + case 202: + return visitMetaProperty(node); case 149: return visitMethodDeclaration(node); - case 205: + case 151: + case 152: + return visitAccessorDeclaration(node); + case 206: return visitVariableStatement(node); + case 217: + return visitReturnStatement(node); default: - ts.Debug.failBadSyntaxKind(node); return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { + var ancestorFacts = enterSubtree(3968, 64); var statements = []; startLexicalEnvironment(); var statementOffset = ts.addPrologueDirectives(statements, node.statements, false, visitor); addCaptureThisForNodeIfNeeded(statements, node); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); + exitSubtree(ancestorFacts, 0, 0); return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); } function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps |= 2; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; + if (convertedLoopState !== undefined) { + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps |= 2; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitCaseBlock(node) { + var ancestorFacts = enterSubtree(4032, 0); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8; + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + node = returnCapturedThis(node); + } + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 185) { - convertedLoopState.containsLexicalThis = true; - return node; + if (convertedLoopState) { + if (hierarchyFacts & 2) { + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + return node; } function visitIdentifier(node) { if (!convertedLoopState) { @@ -41878,13 +42047,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 215 ? 2 : 4; + var jump = node.kind === 216 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 215) { + if (node.kind === 216) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -41894,7 +42063,7 @@ var ts; } } else { - if (node.kind === 215) { + if (node.kind === 216) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -41993,6 +42162,9 @@ var ts; } } function addConstructor(statements, node, extendsClauseElement) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16278, 73); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); @@ -42000,6 +42172,8 @@ var ts; ts.setEmitFlags(constructorFunction, 8); } statements.push(constructorFunction); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; } function transformConstructorParameters(constructor, hasSynthesizedSuper) { return ts.visitParameterList(constructor && !hasSynthesizedSuper && constructor.parameters, visitor, context) @@ -42020,23 +42194,26 @@ var ts; addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94; + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); if (superCaptureStatus === 1 || superCaptureStatus === 2) { statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { - isInConstructorWithCapturedSuper = superCaptureStatus === 1; - return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); - }); - ts.addRange(statements, body); + if (superCaptureStatus === 1) { + hierarchyFacts |= 4096; + } + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset)); } - if (extendsClauseElement + if (isDerivedClass && superCaptureStatus !== 2 && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createIdentifier("_this"))); } ts.addRange(statements, endLexicalEnvironment()); + if (constructor) { + prependCaptureNewTargetIfNeeded(statements, constructor, false); + } var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); if (!constructor) { ts.setEmitFlags(block, 1536); @@ -42044,17 +42221,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 216) { + if (statement.kind === 217) { return true; } - else if (statement.kind === 208) { + else if (statement.kind === 209) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 204) { + else if (statement.kind === 205) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -42062,8 +42239,8 @@ var ts; } return false; } - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { - if (!hasExtendsClause) { + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, isDerivedClass, hasSynthesizedSuper, statementOffset) { + if (!isDerivedClass) { if (ctor) { addCaptureThisForNodeIfNeeded(statements, ctor); } @@ -42083,9 +42260,8 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 207 && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + if (firstStatement.kind === 208 && ts.isSuperCall(firstStatement.expression)) { + superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } if (superCallExpression @@ -42100,17 +42276,17 @@ var ts; statements.push(returnStatement); return 2; } - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); if (superCallExpression) { return 1; } return 0; } + function createActualThis() { + return ts.setEmitFlags(ts.createThis(), 4); + } function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 4); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); + return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createIdentifier("_super"), ts.createNull()), ts.createFunctionApply(ts.createIdentifier("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis()); } function visitParameter(node) { if (node.dotDotDotToken) { @@ -42206,21 +42382,53 @@ var ts; ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } + function prependCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { + if (hierarchyFacts & 16384) { + var newTarget = void 0; + switch (node.kind) { + case 185: + return statements; + case 149: + case 151: + case 152: + newTarget = ts.createVoidZero(); + break; + case 150: + newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); + break; + case 226: + case 184: + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 92, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + var captureNewTargetStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_newTarget", undefined, newTarget) + ])); + if (copyOnWrite) { + return [captureNewTargetStatement].concat(statements); + } + statements.unshift(captureNewTargetStatement); + } + return statements; + } function addClassMembers(statements, node) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 203: + case 204: statements.push(transformSemicolonClassElementToStatement(member)); break; case 149: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case 151: case 152: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; case 150: @@ -42234,26 +42442,29 @@ var ts; function transformSemicolonClassElementToStatement(member) { return ts.createEmptyStatement(member); } - function transformClassMethodDeclarationToStatement(receiver, member) { + function transformClassMethodDeclarationToStatement(receiver, member, container) { + var ancestorFacts = enterSubtree(0, 0); var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name); - var memberFunction = transformFunctionLikeToExpression(member, member, undefined); + var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container); ts.setEmitFlags(memberFunction, 1536); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); ts.setEmitFlags(statement, 48); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return statement; } - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), ts.getSourceMapRange(accessors.firstAccessor)); + function transformAccessorsToStatement(receiver, accessors, container) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, false), ts.getSourceMapRange(accessors.firstAccessor)); ts.setEmitFlags(statement, 1536); return statement; } - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var ancestorFacts = enterSubtree(0, 0); var target = ts.getMutableClone(receiver); ts.setEmitFlags(target, 1536 | 32); ts.setSourceMapRange(target, firstAccessor.name); @@ -42262,7 +42473,7 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); + var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); ts.setEmitFlags(getterFunction, 512); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -42270,7 +42481,7 @@ var ts; properties.push(getter); } if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); + var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); ts.setEmitFlags(setterFunction, 512); var setter = ts.createPropertyAssignment("set", setterFunction); @@ -42286,35 +42497,69 @@ var ts; if (startsOnNewLine) { call.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return call; } function visitArrowFunction(node) { if (node.transformFlags & 16384) { enableSubstitutionsForCapturedThis(); } + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16256, 66); var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8); + exitSubtree(ancestorFacts, 0, 0); + convertedLoopState = savedConvertedLoopState; return func; } function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var ancestorFacts = ts.getEmitFlags(node) & 131072 + ? enterSubtree(16278, 69) + : enterSubtree(16286, 65); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionExpression(node, undefined, name, undefined, parameters, undefined, body); } function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, parameters, undefined, body); } - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 185) { - enclosingNonArrowFunction = node; + function transformFunctionLikeToExpression(node, location, name, container) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32) + ? enterSubtree(16286, 65 | 8) + : enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (hierarchyFacts & 16384 && !name && (node.kind === 226 || node.kind === 184)) { + name = ts.getGeneratedNameForNode(node); } - var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body, location), node); } function transformFunctionBody(node) { var multiLine = false; @@ -42361,6 +42606,7 @@ var ts; } var lexicalEnvironment = context.endLexicalEnvironment(); ts.addRange(statements, lexicalEnvironment); + prependCaptureNewTargetIfNeeded(statements, node, false); if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; } @@ -42374,6 +42620,21 @@ var ts; ts.setOriginalNode(block, node.body); return block; } + function visitFunctionBodyDownLevel(node) { + var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); + return ts.updateBlock(updated, ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, true), updated.statements)); + } + function visitBlock(node, isFunctionBody) { + if (isFunctionBody) { + return ts.visitEachChild(node, visitor, context); + } + var ancestorFacts = hierarchyFacts & 256 + ? enterSubtree(4032, 512) + : enterSubtree(3904, 128); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } function visitExpressionStatement(node) { switch (node.expression.kind) { case 183: @@ -42398,9 +42659,12 @@ var ts; if (ts.isDestructuringAssignment(node)) { return ts.flattenDestructuringAssignment(node, visitor, context, 0, needsDestructuringValue); } + return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3) == 0) { + var ancestorFacts = enterSubtree(0, ts.hasModifier(node, 1) ? 32 : 0); + var updated; + if (convertedLoopState && (node.declarationList.flags & 3) === 0) { var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; @@ -42417,49 +42681,54 @@ var ts; } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); + updated = ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); } else { - return undefined; + updated = undefined; } } - return ts.visitEachChild(node, visitor, context); + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function visitVariableDeclarationList(node) { - if (node.flags & 3) { - enableSubstitutionsForBlockScopedBindings(); + if (node.transformFlags & 64) { + if (node.flags & 3) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations, node); + ts.setOriginalNode(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; + return ts.visitEachChild(node, visitor, context); } function shouldEmitExplicitInitializerForLetDeclaration(node) { var flags = resolver.getNodeCheckFlags(node); var isCapturedInFunction = flags & 131072; var isDeclaredInLoop = flags & 262144; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + var emittedAsTopLevel = (hierarchyFacts & 64) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); + && (hierarchyFacts & 512) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 212 - && enclosingBlockScopeContainer.kind !== 213 + && (hierarchyFacts & 2048) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, false))); + && (hierarchyFacts & (1024 | 2048)) === 0)); return emitExplicitInitializer; } function visitVariableDeclarationInLetDeclarationList(node) { @@ -42475,48 +42744,51 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableDeclaration(node) { + var ancestorFacts = enterSubtree(32, 0); + var updated; if (ts.isBindingPattern(node.name)) { - var hoistTempVariables = enclosingVariableStatement - && ts.hasModifier(enclosingVariableStatement, 1); - return ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, hoistTempVariables); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, (ancestorFacts & 32) !== 0); } else { - result = ts.visitEachChild(node, visitor, context); + updated = ts.visitEachChild(node, visitor, context); } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function recordLabel(node) { + convertedLoopState.labels[node.label.text] = node.label.text; + } + function resetLabel(node) { + convertedLoopState.labels[node.label.text] = undefined; + } + function visitLabeledStatement(node) { + if (convertedLoopState && !convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); } - return result; + var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, false) && shouldConvertIterationStatementBody(statement) + ? visitIterationStatement(statement, node) + : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { + var ancestorFacts = enterSubtree(excludeFacts, includeFacts); + var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); + exitSubtree(ancestorFacts, 0, 0); + return updated; } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitDoOrWhileStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(0, 256, node, outermostLabeledStatement); } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(3008, 1280, node, outermostLabeledStatement); } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForInStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement); } - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function visitForOfStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement, convertForOfToFor); } - function convertForOfToFor(node, convertedLoopBodyStatements) { + function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var initializer = node.initializer; var statements = []; @@ -42579,31 +42851,53 @@ var ts; ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) ], node.expression), 1048576), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); ts.setEmitFlags(forStatement, 256); - return forStatement; + return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); + } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 210: + case 211: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 212: + return visitForStatement(node, outermostLabeledStatement); + case 213: + return visitForInStatement(node, outermostLabeledStatement); + case 214: + return visitForOfStatement(node, outermostLabeledStatement); + } } function visitObjectLiteralExpression(node) { var properties = node.properties; var numProperties = properties.length; var numInitialProperties = numProperties; + var numInitialPropertiesWithoutYield = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 - || property.name.kind === 142) { + if ((property.transformFlags & 16777216 && hierarchyFacts & 4) + && i < numInitialPropertiesWithoutYield) { + numInitialPropertiesWithoutYield = i; + } + if (property.name.kind === 142) { numInitialProperties = i; break; } } - ts.Debug.assert(numInitialProperties !== numProperties); - var temp = ts.createTempVariable(hoistVariableDeclaration); - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); - if (node.multiLine) { - assignment.startsOnNewLine = true; + if (numInitialProperties !== numProperties) { + if (numInitialPropertiesWithoutYield < numInitialProperties) { + numInitialProperties = numInitialPropertiesWithoutYield; + } + var temp = ts.createTempVariable(hoistVariableDeclaration); + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); + return ts.visitEachChild(node, visitor, context); } function shouldConvertIterationStatementBody(node) { return (resolver.getNodeCheckFlags(node) & 65536) !== 0; @@ -42627,14 +42921,16 @@ var ts; } } } - function convertIterationStatementBodyIfNecessary(node, convert) { + function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) { if (!shouldConvertIterationStatementBody(node)) { var saveAllowedNonLabeledJumps = void 0; if (convertedLoopState) { saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; convertedLoopState.allowedNonLabeledJumps = 2 | 4; } - var result = convert ? convert(node, undefined) : ts.visitEachChild(node, visitor, context); + var result = convert + ? convert(node, outermostLabeledStatement, undefined) + : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); if (convertedLoopState) { convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } @@ -42643,11 +42939,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 211: case 212: case 213: + case 214: var initializer = node.initializer; - if (initializer && initializer.kind === 224) { + if (initializer && initializer.kind === 225) { loopInitializer = initializer; } break; @@ -42674,7 +42970,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -42686,11 +42982,13 @@ var ts; ts.addRange(statements_4, lexicalEnvironment); loopBody = ts.createBlock(statements_4, undefined, true); } - if (!ts.isBlock(loopBody)) { + if (ts.isBlock(loopBody)) { + loopBody.multiLine = true; + } + else { loopBody = ts.createBlock([loopBody], undefined, true); } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 131072) !== 0 + var isAsyncBlockContainingAwait = hierarchyFacts & 4 && (node.statement.transformFlags & 16777216) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -42749,19 +43047,18 @@ var ts; var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); var loop; if (convert) { - loop = convert(node, convertedLoopBodyStatements); + loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); } else { - loop = ts.getMutableClone(node); - loop.statement = undefined; - loop = ts.visitEachChild(loop, visitor, context); - loop.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); + var clone_4 = ts.getMutableClone(node); + clone_4.statement = undefined; + clone_4 = ts.visitEachChild(clone_4, visitor, context); + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); + clone_4.transformFlags = 0; + ts.aggregateTransformFlags(clone_4); + loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } - statements.push(currentParent.kind === 219 - ? ts.createLabel(currentParent.label, loop) - : loop); + statements.push(loop); return statements; } function copyOutParameter(outParam, copyDirection) { @@ -42875,17 +43172,17 @@ var ts; case 152: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 257: - expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); + case 149: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; case 258: - expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); + expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 149: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); + case 259: + expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: ts.Debug.failBadSyntaxKind(node); @@ -42907,21 +43204,31 @@ var ts; } return expression; } - function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined), method); + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { + var ancestorFacts = enterSubtree(0, 0); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container), method); if (startsOnNewLine) { expression.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return expression; } function visitCatchClause(node) { - ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); - var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); - var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); - var destructure = ts.createVariableStatement(undefined, list); - return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + var ancestorFacts = enterSubtree(4032, 0); + var updated; + if (ts.isBindingPattern(node.variableDeclaration.name)) { + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); + var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); + var destructure = ts.createVariableStatement(undefined, list); + updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); @@ -42929,21 +43236,43 @@ var ts; } function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); + var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined); ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression)); return ts.createPropertyAssignment(node.name, functionExpression, node); } + function visitAccessorDeclaration(node) { + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return updated; + } function visitShorthandPropertyAssignment(node) { return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), node); } + function visitComputedPropertyName(node) { + var ancestorFacts = enterSubtree(0, 8192); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 32768 : 0); + return updated; + } function visitYieldExpression(node) { return ts.visitEachChild(node, visitor, context); } function visitArrayLiteralExpression(node) { - return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + if (node.transformFlags & 64) { + return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + } + return ts.visitEachChild(node, visitor, context); } function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + if (node.transformFlags & 64) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + } + return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitImmediateSuperCallInBody(node) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); @@ -42955,25 +43284,27 @@ var ts; } var resultingCall; if (node.transformFlags & 524288) { - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } if (node.expression.kind === 96) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4); var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis + resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createIdentifier("_this"), initializer) : initializer; } - return resultingCall; + return ts.setOriginalNode(resultingCall, node); } function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 524288) !== 0); - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + if (node.transformFlags & 524288) { + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + } + return ts.visitEachChild(node, visitor, context); } function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { var numElements = elements.length; @@ -43071,21 +43402,34 @@ var ts; } } } - function visitSuperKeyword() { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 179 + function visitSuperKeyword(isExpressionOfCall) { + return hierarchyFacts & 8 + && !isExpressionOfCall ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } + function visitMetaProperty(node) { + if (node.keywordToken === 93 && node.name.text === "target") { + if (hierarchyFacts & 8192) { + hierarchyFacts |= 32768; + } + else { + hierarchyFacts |= 16384; + } + return ts.createIdentifier("_newTarget"); + } + return node; + } function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { - enclosingFunction = node; + var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8 + ? 65 | 16 + : 65); + previousOnEmitNode(emitContext, node, emitCallback); + exitSubtree(ancestorFacts, 0, 0); + return; } previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; } function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { @@ -43103,7 +43447,7 @@ var ts; context.enableEmitNotification(152); context.enableEmitNotification(185); context.enableEmitNotification(184); - context.enableEmitNotification(225); + context.enableEmitNotification(226); } } function onSubstituteNode(emitContext, node) { @@ -43129,9 +43473,9 @@ var ts; var parent = node.parent; switch (parent.kind) { case 174: - case 226: - case 229: - case 223: + case 227: + case 230: + case 224: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -43157,8 +43501,7 @@ var ts; } function substituteThisKeyword(node) { if (enabledSubstitutions & 1 - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 8) { + && hierarchyFacts & 16) { return ts.createIdentifier("_this", node); } return node; @@ -43175,7 +43518,7 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 207) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 208) { return false; } var statementExpression = statement.expression; @@ -43206,7 +43549,7 @@ var ts; name: "typescript:extends", scoped: false, priority: 0, - text: "\n var __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 };" + text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; })(ts || (ts = {})); var ts; @@ -43283,13 +43626,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 209: - return visitDoStatement(node); case 210: + return visitDoStatement(node); + case 211: return visitWhileStatement(node); - case 218: - return visitSwitchStatement(node); case 219: + return visitSwitchStatement(node); + case 220: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -43297,24 +43640,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); case 151: case 152: return visitAccessorDeclaration(node); - case 205: + case 206: return visitVariableStatement(node); - case 211: - return visitForStatement(node); case 212: + return visitForStatement(node); + case 213: return visitForInStatement(node); - case 215: - return visitBreakStatement(node); - case 214: - return visitContinueStatement(node); case 216: + return visitBreakStatement(node); + case 215: + return visitContinueStatement(node); + case 217: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -43352,7 +43695,7 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -43539,10 +43882,10 @@ var ts; else if (node.operatorToken.kind === 25) { return visitCommaExpression(node); } - var clone_4 = ts.getMutableClone(node); - clone_4.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_4.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_4; + var clone_5 = ts.getMutableClone(node); + clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_5; } return ts.visitEachChild(node, visitor, context); } @@ -43604,7 +43947,7 @@ var ts; emitYield(expression, node); } markLabel(resumeLabel); - return createGeneratorResume(); + return createGeneratorResume(node); } function visitArrayLiteralExpression(node) { return visitElements(node.elements, undefined, undefined, node.multiLine); @@ -43664,10 +44007,10 @@ var ts; } function visitElementAccessExpression(node) { if (containsYield(node.argumentExpression)) { - var clone_5 = ts.getMutableClone(node); - clone_5.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_5.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -43710,35 +44053,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 204: + case 205: return transformAndEmitBlock(node); - case 207: - return transformAndEmitExpressionStatement(node); case 208: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 209: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 210: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 211: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 212: + return transformAndEmitForStatement(node); + case 213: return transformAndEmitForInStatement(node); - case 214: - return transformAndEmitContinueStatement(node); case 215: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 216: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 217: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 218: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 219: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 220: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 221: + return transformAndEmitThrowStatement(node); + case 222: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -43758,7 +44101,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - hoistVariableDeclaration(variable.name); + var name_39 = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name_39, variable.name); + hoistVariableDeclaration(name_39); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -43788,7 +44133,7 @@ var ts; if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) { var endLabel = defineLabel(); var elseLabel = node.elseStatement ? defineLabel() : undefined; - emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression)); + emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), node.expression); transformAndEmitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { emitBreak(endLabel); @@ -44022,7 +44367,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 254 && defaultClauseIndex === -1) { + if (clause.kind === 255 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -44032,7 +44377,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 253) { + if (clause.kind === 254) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -44153,12 +44498,12 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_39 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_39) { - var clone_6 = ts.getMutableClone(name_39); - ts.setSourceMapRange(clone_6, node); - ts.setCommentRange(clone_6, node); - return clone_6; + var name_40 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_40) { + var clone_7 = ts.getMutableClone(name_40); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); + return clone_7; } } } @@ -44768,41 +45113,41 @@ var ts; function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), operationLocation)); + : [createInstruction(2)]), operationLocation), 384)); } function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation)); + ]), operationLocation), 384)); } function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384)), 1)); } function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384)), 1)); } function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4), expression] - : [createInstruction(4)]), operationLocation)); + : [createInstruction(4)]), operationLocation), 384)); } function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(5), expression - ]), operationLocation)); + ]), operationLocation), 384)); } function writeEndfinally() { lastOperationWasAbrupt = true; @@ -44827,15 +45172,40 @@ var ts; var ts; (function (ts) { function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(249); + context.enableEmitNotification(250); + context.enableEmitNotification(248); + noSubstitution = []; + } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; context.enableSubstitution(177); - context.enableSubstitution(257); + context.enableSubstitution(258); return transformSourceFile; function transformSourceFile(node) { return node; } + function onEmitNode(emitContext, node, emitCallback) { + switch (node.kind) { + case 249: + case 250: + case 248: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(emitContext, node, emitCallback); + } function onSubstituteNode(emitContext, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(emitContext, node); + } node = previousOnSubstituteNode(emitContext, node); if (ts.isPropertyAccessExpression(node)) { return substitutePropertyAccessExpression(node); @@ -44892,8 +45262,8 @@ var ts; context.enableSubstitution(192); context.enableSubstitution(190); context.enableSubstitution(191); - context.enableSubstitution(258); - context.enableEmitNotification(261); + context.enableSubstitution(259); + context.enableEmitNotification(262); var moduleInfoMap = ts.createMap(); var deferredExports = ts.createMap(); var currentSourceFile; @@ -44931,14 +45301,7 @@ var ts; function transformAMDModule(node) { var define = ts.createIdentifier("define"); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, true); - } - function transformUMDModule(node) { - var define = ts.createRawExpression(umdHelper); - return transformAsynchronousModule(node, define, undefined, false); - } - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; return ts.updateSourceFileNode(node, ts.createNodeArray([ ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ @@ -44952,6 +45315,36 @@ var ts; ]))) ], node.statements)); } + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement(undefined, [ + ts.createVariableDeclaration("v", undefined, ts.createCall(ts.createIdentifier("factory"), undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], undefined, true)); + return ts.updateSourceFileNode(node, ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(undefined, undefined, undefined, "require"), + ts.createParameter(undefined, undefined, undefined, "exports") + ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ])) + ], node.statements)); + } function collectAsynchronousDependencies(node, includeNonAmdDependencies) { var aliasedModuleNames = []; var unaliasedModuleNames = []; @@ -45011,23 +45404,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 241: + case 242: return visitExportDeclaration(node); - case 240: + case 241: return visitExportAssignment(node); - case 205: + case 206: return visitVariableStatement(node); - case 225: - return visitFunctionDeclaration(node); case 226: + return visitFunctionDeclaration(node); + case 227: return visitClassDeclaration(node); - case 295: - return visitMergeDeclarationMarker(node); case 296: + return visitMergeDeclarationMarker(node); + case 297: return visitEndOfDeclarationMarker(node); default: return node; @@ -45225,7 +45618,7 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -45257,10 +45650,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237: + case 238: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238: + case 239: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -45368,7 +45761,7 @@ var ts; return node; } function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { + if (node.kind === 262) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = ts.createMap(); @@ -45428,7 +45821,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 261) { + if (exportContainer && exportContainer.kind === 262) { return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -45437,8 +45830,8 @@ var ts; return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_40 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_40), node); + var name_41 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_41), node); } } } @@ -45502,7 +45895,6 @@ var ts; scoped: true, text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" }; - var umdHelper = "\n (function (dependencies, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(dependencies, factory);\n }\n })"; })(ts || (ts = {})); var ts; (function (ts) { @@ -45519,7 +45911,7 @@ var ts; context.enableSubstitution(192); context.enableSubstitution(190); context.enableSubstitution(191); - context.enableEmitNotification(261); + context.enableEmitNotification(262); var moduleInfoMap = ts.createMap(); var deferredExports = ts.createMap(); var exportFunctionsMap = ts.createMap(); @@ -45619,7 +46011,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 241 && externalImport.exportClause) { + if (externalImport.kind === 242 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -45642,7 +46034,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 241) { + if (externalImport.kind !== 242) { continue; } var exportDecl = externalImport; @@ -45694,15 +46086,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 235: + case 236: if (!entry.importClause) { break; } - case 234: + case 235: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 241: + case 242: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -45724,13 +46116,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 241: + case 242: return undefined; - case 240: + case 241: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -45851,7 +46243,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 1048576) === 0 - && (enclosingBlockScopedContainer.kind === 261 + && (enclosingBlockScopedContainer.kind === 262 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -45873,7 +46265,7 @@ var ts; : preventSubstitution(ts.createAssignment(name, value, location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -45906,10 +46298,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237: + case 238: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238: + case 239: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -46008,43 +46400,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 205: + case 206: return visitVariableStatement(node); - case 225: - return visitFunctionDeclaration(node); case 226: + return visitFunctionDeclaration(node); + case 227: return visitClassDeclaration(node); - case 211: - return visitForStatement(node); case 212: - return visitForInStatement(node); + return visitForStatement(node); case 213: + return visitForInStatement(node); + case 214: return visitForOfStatement(node); - case 209: - return visitDoStatement(node); case 210: + return visitDoStatement(node); + case 211: return visitWhileStatement(node); - case 219: + case 220: return visitLabeledStatement(node); - case 217: - return visitWithStatement(node); case 218: + return visitWithStatement(node); + case 219: return visitSwitchStatement(node); - case 232: + case 233: return visitCaseBlock(node); - case 253: - return visitCaseClause(node); case 254: + return visitCaseClause(node); + case 255: return visitDefaultClause(node); - case 221: + case 222: return visitTryStatement(node); - case 256: + case 257: return visitCatchClause(node); - case 204: + case 205: return visitBlock(node); - case 295: - return visitMergeDeclarationMarker(node); case 296: + return visitMergeDeclarationMarker(node); + case 297: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -46172,7 +46564,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 261; + return container !== undefined && container.kind === 262; } else { return false; @@ -46187,7 +46579,7 @@ var ts; return node; } function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { + if (node.kind === 262) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -46299,7 +46691,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 261) { + if (exportContainer && exportContainer.kind === 262) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -46327,7 +46719,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(261); + context.enableEmitNotification(262); context.enableSubstitution(70); var currentSourceFile; return transformSourceFile; @@ -46352,9 +46744,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 234: + case 235: return undefined; - case 240: + case 241: return visitExportAssignment(node); } return node; @@ -46663,7 +47055,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 235); + ts.Debug.assert(aliasEmitInfo.node.kind === 236); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -46735,10 +47127,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 223) { + if (declaration.kind === 224) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 238 || declaration.kind === 239 || declaration.kind === 236) { + else if (declaration.kind === 239 || declaration.kind === 240 || declaration.kind === 237) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -46749,7 +47141,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 235) { + if (moduleElementEmitInfo.node.kind === 236) { moduleElementEmitInfo.isVisible = true; } else { @@ -46757,12 +47149,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 231) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 231) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -46933,7 +47325,7 @@ var ts; } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 234 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 235 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); @@ -47050,9 +47442,9 @@ var ts; var count = 0; while (true) { count++; - var name_41 = baseName + "_" + count; - if (!(name_41 in currentIdentifiers)) { - return name_41; + var name_42 = baseName + "_" + count; + if (!(name_42 in currentIdentifiers)) { + return name_42; } } } @@ -47096,10 +47488,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 234 || - (node.parent.kind === 261 && isCurrentFileExternalModule)) { + else if (node.kind === 235 || + (node.parent.kind === 262 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 262) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -47108,7 +47500,7 @@ var ts; }); } else { - if (node.kind === 235) { + if (node.kind === 236) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -47126,30 +47518,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 225: - return writeFunctionDeclaration(node); - case 205: - return writeVariableStatement(node); - case 227: - return writeInterfaceDeclaration(node); case 226: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 206: + return writeVariableStatement(node); case 228: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 227: + return writeClassDeclaration(node); case 229: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 230: + return writeEnumDeclaration(node); + case 231: return writeModuleDeclaration(node); - case 234: - return writeImportEqualsDeclaration(node); case 235: + return writeImportEqualsDeclaration(node); + case 236: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 261) { + if (node.parent.kind === 262) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -47157,7 +47549,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 227 && !noDeclare) { + else if (node.kind !== 228 && !noDeclare) { write("declare "); } } @@ -47207,7 +47599,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 237) { + if (namedBindings.kind === 238) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -47230,7 +47622,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 237) { + if (node.importClause.namedBindings.kind === 238) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -47247,13 +47639,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 231; var moduleSpecifier; - if (parent.kind === 234) { + if (parent.kind === 235) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 230) { + else if (parent.kind === 231) { moduleSpecifier = parent.name; } else { @@ -47321,7 +47713,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 231) { + while (node.body && node.body.kind !== 232) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -47419,10 +47811,10 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 226: + case 227: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 227: + case 228: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 154: @@ -47436,17 +47828,17 @@ var ts; if (ts.hasModifier(node.parent, 32)) { 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 === 226) { + else if (node.parent.parent.kind === 227) { 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 225: + case 226: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 228: + case 229: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -47483,7 +47875,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 226) { + if (node.parent.parent.kind === 227) { 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; @@ -47566,7 +47958,7 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 223 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 224 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -47589,7 +47981,7 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 223) { + if (node.kind === 224) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47604,7 +47996,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 === 226) { + else if (node.parent.kind === 227) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47764,13 +48156,13 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 225) { + if (node.kind === 226) { emitModuleElementDeclarationFlags(node); } else if (node.kind === 149 || node.kind === 150) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 225) { + if (node.kind === 226) { write("function "); writeTextOfNode(currentText, node.name); } @@ -47864,7 +48256,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 === 226) { + else if (node.parent.kind === 227) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -47877,7 +48269,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 225: + case 226: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -47954,7 +48346,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 === 226) { + else if (node.parent.parent.kind === 227) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -47966,7 +48358,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 225: + case 226: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -48018,19 +48410,19 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 225: - case 230: - case 234: - case 227: case 226: - case 228: - case 229: - return emitModuleElement(node, isModuleElementVisible(node)); - case 205: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 231: case 235: + case 228: + case 227: + case 229: + case 230: + return emitModuleElement(node, isModuleElementVisible(node)); + case 206: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 236: return emitModuleElement(node, !node.importClause); - case 241: + case 242: return emitExportDeclaration(node); case 150: case 149: @@ -48046,11 +48438,11 @@ var ts; case 147: case 146: return emitPropertyDeclaration(node); - case 260: - return emitEnumMemberDeclaration(node); - case 240: - return emitExportAssignment(node); case 261: + return emitEnumMemberDeclaration(node); + case 241: + return emitExportAssignment(node); + case 262: return emitSourceFile(node); } } @@ -48267,7 +48659,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 293 + if (node.kind !== 294 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -48280,7 +48672,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 293 + if (node.kind !== 294 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -48424,7 +48816,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 293; + var isEmittedNode = node.kind !== 294; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0; if (!skipLeadingComments) { @@ -48438,7 +48830,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 224) { + if (node.kind === 225) { declarationListContainerEnd = end; } } @@ -48794,7 +49186,7 @@ var ts; function pipelineEmitInSourceFileContext(node) { var kind = node.kind; switch (kind) { - case 261: + case 262: return emitSourceFile(node); } } @@ -48917,119 +49309,119 @@ var ts; return emitArrayBindingPattern(node); case 174: return emitBindingElement(node); - case 202: - return emitTemplateSpan(node); case 203: - return emitSemicolonClassElement(); + return emitTemplateSpan(node); case 204: - return emitBlock(node); + return emitSemicolonClassElement(); case 205: - return emitVariableStatement(node); + return emitBlock(node); case 206: - return emitEmptyStatement(); + return emitVariableStatement(node); case 207: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 208: - return emitIfStatement(node); + return emitExpressionStatement(node); case 209: - return emitDoStatement(node); + return emitIfStatement(node); case 210: - return emitWhileStatement(node); + return emitDoStatement(node); case 211: - return emitForStatement(node); + return emitWhileStatement(node); case 212: - return emitForInStatement(node); + return emitForStatement(node); case 213: - return emitForOfStatement(node); + return emitForInStatement(node); case 214: - return emitContinueStatement(node); + return emitForOfStatement(node); case 215: - return emitBreakStatement(node); + return emitContinueStatement(node); case 216: - return emitReturnStatement(node); + return emitBreakStatement(node); case 217: - return emitWithStatement(node); + return emitReturnStatement(node); case 218: - return emitSwitchStatement(node); + return emitWithStatement(node); case 219: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 220: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 221: - return emitTryStatement(node); + return emitThrowStatement(node); case 222: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 223: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 224: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 225: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 226: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 227: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 228: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 229: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 230: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 231: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 232: + return emitModuleBlock(node); + case 233: return emitCaseBlock(node); - case 234: - return emitImportEqualsDeclaration(node); case 235: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 236: - return emitImportClause(node); + return emitImportDeclaration(node); case 237: - return emitNamespaceImport(node); + return emitImportClause(node); case 238: - return emitNamedImports(node); + return emitNamespaceImport(node); case 239: - return emitImportSpecifier(node); + return emitNamedImports(node); case 240: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 241: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 242: - return emitNamedExports(node); + return emitExportDeclaration(node); case 243: - return emitExportSpecifier(node); + return emitNamedExports(node); case 244: - return; + return emitExportSpecifier(node); case 245: + return; + case 246: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 248: - return emitJsxOpeningElement(node); case 249: - return emitJsxClosingElement(node); + return emitJsxOpeningElement(node); case 250: - return emitJsxAttribute(node); + return emitJsxClosingElement(node); case 251: - return emitJsxSpreadAttribute(node); + return emitJsxAttribute(node); case 252: - return emitJsxExpression(node); + return emitJsxSpreadAttribute(node); case 253: - return emitCaseClause(node); + return emitJsxExpression(node); case 254: - return emitDefaultClause(node); + return emitCaseClause(node); case 255: - return emitHeritageClause(node); + return emitDefaultClause(node); case 256: - return emitCatchClause(node); + return emitHeritageClause(node); case 257: - return emitPropertyAssignment(node); + return emitCatchClause(node); case 258: - return emitShorthandPropertyAssignment(node); + return emitPropertyAssignment(node); case 259: - return emitSpreadAssignment(node); + return emitShorthandPropertyAssignment(node); case 260: + return emitSpreadAssignment(node); + case 261: return emitEnumMember(node); } if (ts.isExpression(node)) { @@ -49106,14 +49498,14 @@ var ts; return emitAsExpression(node); case 201: return emitNonNullExpression(node); - case 246: - return emitJsxElement(node); + case 202: + return emitMetaProperty(node); case 247: + return emitJsxElement(node); + case 248: return emitJsxSelfClosingElement(node); - case 294: + case 295: return emitPartiallyEmittedExpression(node); - case 297: - return writeLines(node.text); } } function emitNumericLiteral(node) { @@ -49558,6 +49950,11 @@ var ts; emitExpression(node.expression); write("!"); } + function emitMetaProperty(node) { + writeToken(node.keywordToken, node.pos); + write("."); + emit(node.name); + } function emitTemplateSpan(node) { emitExpression(node.expression); emit(node.literal); @@ -49600,27 +49997,27 @@ var ts; writeToken(18, openParenPos, node); emitExpression(node.expression); writeToken(19, node.expression.end, node); - emitEmbeddedStatement(node.thenStatement); + emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { - writeLine(); + writeLineOrSpace(node); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 208) { + if (node.elseStatement.kind === 209) { write(" "); emit(node.elseStatement); } else { - emitEmbeddedStatement(node.elseStatement); + emitEmbeddedStatement(node, node.elseStatement); } } } function emitDoStatement(node) { write("do"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { write(" "); } else { - writeLine(); + writeLineOrSpace(node); } write("while ("); emitExpression(node.expression); @@ -49630,7 +50027,7 @@ var ts; write("while ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49642,7 +50039,7 @@ var ts; write(";"); emitExpressionWithPrefix(" ", node.incrementor); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49652,7 +50049,7 @@ var ts; write(" in "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49662,11 +50059,11 @@ var ts; write(" of "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 224) { + if (node.kind === 225) { emit(node); } else { @@ -49693,7 +50090,7 @@ var ts; write("with ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { var openParenPos = writeToken(97, node.pos); @@ -49717,9 +50114,12 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchClause); + if (node.catchClause) { + writeLineOrSpace(node); + emit(node.catchClause); + } if (node.finallyBlock) { - writeLine(); + writeLineOrSpace(node); write("finally "); emit(node.finallyBlock); } @@ -49895,7 +50295,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 230) { + while (body.kind === 231) { write("."); emit(body.name); body = body.body; @@ -50046,6 +50446,9 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); + if (node.dotDotDotToken) { + write("..."); + } emitExpression(node.expression); write("}"); } @@ -50245,8 +50648,8 @@ var ts; write(suffix); } } - function emitEmbeddedStatement(node) { - if (ts.isBlock(node)) { + function emitEmbeddedStatement(parent, node) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1) { write(" "); emit(node); } @@ -50375,6 +50778,14 @@ var ts; write(getClosingBracket(format)); } } + function writeLineOrSpace(node) { + if (ts.getEmitFlags(node) & 1) { + write(" "); + } + else { + writeLine(); + } + } function writeIfAny(nodes, text) { if (nodes && nodes.length > 0) { write(text); @@ -50555,21 +50966,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_42 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_42)) { + var name_43 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_43)) { tempFlags |= flags; - return name_42; + return name_43; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_43 = count < 26 + var name_44 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_43)) { - return name_43; + if (isUniqueName(name_44)) { + return name_44; } } } @@ -50603,22 +51014,32 @@ var ts; function generateNameForClassExpression() { return makeUniqueName("class"); } + function generateNameForMethodOrAccessor(node) { + if (ts.isIdentifier(node.name)) { + return generateNameForNodeCached(node.name); + } + return makeTempVariableName(0); + } function generateNameForNode(node) { switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); + case 231: case 230: - case 229: return generateNameForModuleOrEnum(node); - case 235: - case 241: + case 236: + case 242: return generateNameForImportOrExportDeclaration(node); - case 225: case 226: - case 240: + case 227: + case 241: return generateNameForExportDefault(); case 197: return generateNameForClassExpression(); + case 149: + case 151: + case 152: + return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); } @@ -50649,11 +51070,14 @@ var ts; } return node; } + function generateNameForNodeCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + } function getGeneratedIdentifier(name) { if (name.autoGenerateKind === 4) { var node = getNodeForGeneratedName(name); - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + return generateNameForNodeCached(node); } else { var autoGenerateId = name.autoGenerateId; @@ -50722,7 +51146,8 @@ var ts; commonPathComponents = sourcePathComponents; return; } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + var n = Math.min(commonPathComponents.length, sourcePathComponents.length); + for (var i = 0; i < n; i++) { if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { if (i === 0) { return true; @@ -50905,10 +51330,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_44 = names_1[_i]; - var result = name_44 in cache - ? cache[name_44] - : cache[name_44] = loader(name_44, containingFile); + var name_45 = names_1[_i]; + var result = name_45 in cache + ? cache[name_45] + : cache[name_45] = loader(name_45, containingFile); resolutions.push(result); } return resolutions; @@ -50933,6 +51358,7 @@ var ts; var currentDirectory = host.getCurrentDirectory(); var supportedExtensions = ts.getSupportedExtensions(options); var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); + var moduleResolutionCache; var resolveModuleNamesWorker; if (host.resolveModuleNames) { resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { @@ -50945,7 +51371,8 @@ var ts; }); }; } else { - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -50981,6 +51408,7 @@ var ts; } } } + moduleResolutionCache = undefined; oldProgram = undefined; program = { getRootFileNames: function () { return rootNames; }, @@ -51187,7 +51615,7 @@ var ts; newSourceFile.resolvedModules = oldSourceFile.resolvedModules; newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } - for (var i = 0, len = newSourceFiles.length; i < len; i++) { + for (var i = 0; i < newSourceFiles.length; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; @@ -51345,42 +51773,42 @@ var ts; case 151: case 152: case 184: - case 225: + case 226: case 185: - case 225: - case 223: + case 226: + case 224: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 234: + case 235: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 240: + case 241: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 255: + case 256: var heritageClause = node; if (heritageClause.token === 107) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 227: + case 228: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 230: + case 231: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 228: + case 229: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 229: + case 230: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; case 182: @@ -51398,23 +51826,23 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 226: + case 227: case 149: case 148: case 150: case 151: case 152: case 184: - case 225: + case 226: case 185: - case 225: + case 226: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 205: + case 206: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 205); + return checkModifiers(nodes, parent.kind === 206); } break; case 147: @@ -51526,7 +51954,7 @@ var ts; && !file.isDeclarationFile) { var externalHelpersModuleReference = ts.createSynthesizedNode(9); externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(235); + var importDecl = ts.createSynthesizedNode(236); importDecl.parent = file; externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; @@ -51544,9 +51972,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 236: case 235: - case 234: - case 241: + case 242: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -51558,7 +51986,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 230: + case 231: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -52182,32 +52610,32 @@ var ts; function getMeaningFromDeclaration(node) { switch (node.kind) { case 144: - case 223: + case 224: case 174: case 147: case 146: - case 257: case 258: - case 260: + case 259: + case 261: case 149: case 148: case 150: case 151: case 152: - case 225: + case 226: case 184: case 185: - case 256: + case 257: return 1; case 143: - case 227: case 228: + case 229: case 161: return 2; - case 226: - case 229: - return 1 | 2; + case 227: case 230: + return 1 | 2; + case 231: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -52217,21 +52645,21 @@ var ts; else { return 4; } - case 238: case 239: - case 234: - case 235: case 240: + case 235: + case 236: case 241: + case 242: return 1 | 2 | 4; - case 261: + case 262: return 4 | 1; } return 1 | 2 | 4; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 240) { + if (node.parent.kind === 241) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -52255,7 +52683,7 @@ var ts; ts.Debug.assert(node.kind === 70); if (node.parent.kind === 141 && node.parent.right === node && - node.parent.parent.kind === 234) { + node.parent.parent.kind === 235) { return 1 | 2 | 4; } return 4; @@ -52289,10 +52717,10 @@ var ts; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 199 && root.parent.parent.kind === 255) { + if (!isLastClause && root.parent.kind === 199 && root.parent.parent.kind === 256) { var decl = root.parent.parent.parent; - return (decl.kind === 226 && root.parent.parent.token === 107) || - (decl.kind === 227 && root.parent.parent.token === 84); + return (decl.kind === 227 && root.parent.parent.token === 107) || + (decl.kind === 228 && root.parent.parent.token === 84); } return false; } @@ -52323,7 +52751,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 219 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 220 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -52333,13 +52761,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 && - (node.parent.kind === 215 || node.parent.kind === 214) && + (node.parent.kind === 216 || node.parent.kind === 215) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 && - node.parent.kind === 219 && + node.parent.kind === 220 && node.parent.label === node; } function isLabelName(node) { @@ -52355,7 +52783,7 @@ var ts; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 230 && node.parent.name === node; + return node.parent.kind === 231 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -52368,13 +52796,13 @@ var ts; switch (node.parent.kind) { case 147: case 146: - case 257: - case 260: + case 258: + case 261: case 149: case 148: case 151: case 152: - case 230: + case 231: return node.parent.name === node; case 178: return node.parent.argumentExpression === node; @@ -52422,17 +52850,17 @@ var ts; return undefined; } switch (node.kind) { - case 261: + case 262: case 149: case 148: - case 225: + case 226: case 184: case 151: case 152: - case 226: case 227: - case 229: + case 228: case 230: + case 231: return node; } } @@ -52440,22 +52868,22 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 261: + case 262: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 230: + case 231: return ts.ScriptElementKind.moduleElement; - case 226: + case 227: case 197: return ts.ScriptElementKind.classElement; - case 227: return ts.ScriptElementKind.interfaceElement; - case 228: return ts.ScriptElementKind.typeElement; - case 229: return ts.ScriptElementKind.enumElement; - case 223: + case 228: return ts.ScriptElementKind.interfaceElement; + case 229: return ts.ScriptElementKind.typeElement; + case 230: return ts.ScriptElementKind.enumElement; + case 224: return getKindOfVariableDeclaration(node); case 174: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); case 185: - case 225: + case 226: case 184: return ts.ScriptElementKind.functionElement; case 151: return ts.ScriptElementKind.memberGetAccessorElement; @@ -52471,15 +52899,15 @@ var ts; case 153: return ts.ScriptElementKind.callSignatureElement; case 150: return ts.ScriptElementKind.constructorImplementationElement; case 143: return ts.ScriptElementKind.typeParameterElement; - case 260: return ts.ScriptElementKind.enumMemberElement; + case 261: return ts.ScriptElementKind.enumMemberElement; case 144: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 234: - case 239: - case 236: - case 243: + case 235: + case 240: case 237: + case 244: + case 238: return ts.ScriptElementKind.alias; - case 285: + case 286: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -52551,19 +52979,19 @@ var ts; return false; } switch (n.kind) { - case 226: case 227: - case 229: + case 228: + case 230: case 176: case 172: case 161: - case 204: - case 231: + case 205: case 232: - case 238: - case 242: + case 233: + case 239: + case 243: return nodeEndsWith(n, 17, sourceFile); - case 256: + case 257: return isCompletedNode(n.block, sourceFile); case 180: if (!n.arguments) { @@ -52579,7 +53007,7 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 184: case 149: case 148: @@ -52593,14 +53021,14 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19, sourceFile); - case 230: + case 231: return n.body && isCompletedNode(n.body, sourceFile); - case 208: + case 209: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 207: + case 208: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24); case 175: @@ -52614,15 +53042,15 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21, sourceFile); - case 253: case 254: + case 255: return false; - case 211: case 212: case 213: - case 210: + case 214: + case 211: return isCompletedNode(n.statement, sourceFile); - case 209: + case 210: var hasWhileKeyword = findChildOfKind(n, 105, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 19, sourceFile); @@ -52642,10 +53070,10 @@ var ts; case 194: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 202: + case 203: return ts.nodeIsPresent(n.literal); - case 241: - case 235: + case 242: + case 236: return ts.nodeIsPresent(n.moduleSpecifier); case 190: return isCompletedNode(n.operand, sourceFile); @@ -52694,7 +53122,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 292 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 293 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -52749,8 +53177,8 @@ var ts; } } } - for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { - var child = current.getChildAt(i); + for (var _a = 0, _b = current.getChildren(); _a < _b.length; _a++) { + var child = _b[_a]; if (ts.isJSDocNode(child)) { continue; } @@ -52814,7 +53242,7 @@ var ts; return n; } var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; i++) { + for (var i = 0; i < children.length; i++) { var child = children[i]; if (position < child.end && (nodeHasTokens(child) || child.kind === 10)) { var start = child.getStart(sourceFile); @@ -52829,7 +53257,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 261); + ts.Debug.assert(startNode !== undefined || n.kind === 262); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -52874,13 +53302,13 @@ var ts; if (token.kind === 26 && token.parent.kind === 10) { return true; } - if (token.kind === 26 && token.parent.kind === 252) { + if (token.kind === 26 && token.parent.kind === 253) { return true; } - if (token && token.kind === 17 && token.parent.kind === 252) { + if (token && token.kind === 17 && token.parent.kind === 253) { return true; } - if (token.kind === 26 && token.parent.kind === 249) { + if (token.kind === 26 && token.parent.kind === 250) { return true; } return false; @@ -52974,7 +53402,7 @@ var ts; if (node.kind === 157 || node.kind === 179) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 226 || node.kind === 227) { + if (ts.isFunctionLike(node) || node.kind === 227 || node.kind === 228) { return node.typeParameters; } return undefined; @@ -53047,11 +53475,11 @@ var ts; node.parent.operatorToken.kind === 57) { return true; } - if (node.parent.kind === 213 && + if (node.parent.kind === 214 && node.parent.initializer === node) { return true; } - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 257 ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 258 ? node.parent.parent : node.parent)) { return true; } } @@ -53268,7 +53696,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 239 || location.parent.kind === 243) && + (location.parent.kind === 240 || location.parent.kind === 244) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -53325,6 +53753,10 @@ var ts; }; } ts.sanitizeConfigFile = sanitizeConfigFile; + function getOpenBraceEnd(constructor, sourceFile) { + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + ts.getOpenBraceEnd = getOpenBraceEnd; })(ts || (ts = {})); var ts; (function (ts) { @@ -53373,15 +53805,15 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 205: + case 206: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 223: + case 224: case 147: case 146: return spanInVariableDeclaration(node); case 144: return spanInParameterDeclaration(node); - case 225: + case 226: case 149: case 148: case 151: @@ -53390,72 +53822,72 @@ var ts; case 184: case 185: return spanInFunctionDeclaration(node); - case 204: + case 205: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 231: + case 232: return spanInBlock(node); - case 256: + case 257: return spanInBlock(node.block); - case 207: - return textSpan(node.expression); - case 216: - return textSpan(node.getChildAt(0), node.expression); - case 210: - return textSpanEndingAtNextToken(node, node.expression); - case 209: - return spanInNode(node.statement); - case 222: - return textSpan(node.getChildAt(0)); case 208: - return textSpanEndingAtNextToken(node, node.expression); - case 219: - return spanInNode(node.statement); - case 215: - case 214: - return textSpan(node.getChildAt(0), node.label); + return textSpan(node.expression); + case 217: + return textSpan(node.getChildAt(0), node.expression); case 211: - return spanInForStatement(node); - case 212: return textSpanEndingAtNextToken(node, node.expression); - case 213: - return spanInInitializerOfForLike(node); - case 218: + case 210: + return spanInNode(node.statement); + case 223: + return textSpan(node.getChildAt(0)); + case 209: return textSpanEndingAtNextToken(node, node.expression); - case 253: - case 254: - return spanInNode(node.statements[0]); - case 221: - return spanInBlock(node.tryBlock); case 220: + return spanInNode(node.statement); + case 216: + case 215: + return textSpan(node.getChildAt(0), node.label); + case 212: + return spanInForStatement(node); + case 213: + return textSpanEndingAtNextToken(node, node.expression); + case 214: + return spanInInitializerOfForLike(node); + case 219: + return textSpanEndingAtNextToken(node, node.expression); + case 254: + case 255: + return spanInNode(node.statements[0]); + case 222: + return spanInBlock(node.tryBlock); + case 221: return textSpan(node, node.expression); - case 240: - return textSpan(node, node.expression); - case 234: - return textSpan(node, node.moduleReference); - case 235: - return textSpan(node, node.moduleSpecifier); case 241: + return textSpan(node, node.expression); + case 235: + return textSpan(node, node.moduleReference); + case 236: return textSpan(node, node.moduleSpecifier); - case 230: + case 242: + return textSpan(node, node.moduleSpecifier); + case 231: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 226: - case 229: - case 260: + case 227: + case 230: + case 261: case 174: return textSpan(node); - case 217: + case 218: return spanInNode(node.statement); case 145: return spanInNodeArray(node.parent.decorators); case 172: case 173: return spanInBindingPattern(node); - case 227: case 228: + case 229: return undefined; case 24: case 1: @@ -53491,8 +53923,8 @@ var ts; } if ((node.kind === 70 || node.kind == 196 || - node.kind === 257 || - node.kind === 258) && + node.kind === 258 || + node.kind === 259) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } @@ -53511,12 +53943,12 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 209: + case 210: return spanInPreviousNode(node); case 145: return spanInNode(node.parent); - case 211: - case 213: + case 212: + case 214: return textSpan(node); case 192: if (node.parent.operatorToken.kind === 25) { @@ -53530,7 +53962,7 @@ var ts; break; } } - if (node.parent.kind === 257 && + if (node.parent.kind === 258 && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); @@ -53541,7 +53973,7 @@ var ts; if (ts.isFunctionLike(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); } - if ((node.parent.kind === 223 || + if ((node.parent.kind === 224 || node.parent.kind === 144)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || @@ -53571,7 +54003,7 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 212) { + if (variableDeclaration.parent.parent.kind === 213) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { @@ -53579,7 +54011,7 @@ var ts; } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 213) { + variableDeclaration.parent.parent.kind === 214) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -53611,7 +54043,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 226 && functionDeclaration.kind !== 150); + (functionDeclaration.parent.kind === 227 && functionDeclaration.kind !== 150); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -53631,22 +54063,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 230: + case 231: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 210: - case 208: - case 212: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); case 211: + case 209: case 213: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 212: + case 214: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 224) { + if (forLikeStatement.initializer.kind === 225) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -53690,33 +54122,33 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 229: + case 230: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 226: + case 227: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 232: + case 233: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 231: + case 232: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 229: - case 226: + case 230: + case 227: return textSpan(node); - case 204: + case 205: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 256: + case 257: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 232: + case 233: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { @@ -53748,7 +54180,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 209 || + if (node.parent.kind === 210 || node.parent.kind === 179 || node.parent.kind === 180) { return spanInPreviousNode(node); @@ -53761,17 +54193,17 @@ var ts; function spanInCloseParenToken(node) { switch (node.parent.kind) { case 184: - case 225: + case 226: case 185: case 149: case 148: case 151: case 152: case 150: - case 210: - case 209: case 211: - case 213: + case 210: + case 212: + case 214: case 179: case 180: case 183: @@ -53782,7 +54214,7 @@ var ts; } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || - node.parent.kind === 257 || + node.parent.kind === 258 || node.parent.kind === 144) { return spanInPreviousNode(node); } @@ -53795,13 +54227,13 @@ var ts; return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 209) { + if (node.parent.kind === 210) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 213) { + if (node.parent.kind === 214) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -53845,7 +54277,7 @@ var ts; var entries = []; var dense = classifications.spans; var lastEnd = 0; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; var length_4 = dense[i + 1]; var type = dense[i + 2]; @@ -54152,10 +54584,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { - case 230: - case 226: + case 231: case 227: - case 225: + case 228: + case 226: cancellationToken.throwIfCancellationRequested(); } } @@ -54199,7 +54631,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 230 && + return declaration.kind === 231 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -54256,7 +54688,7 @@ var ts; ts.Debug.assert(classifications.spans.length % 3 === 0); var dense = classifications.spans; var result = []; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { result.push({ textSpan: ts.createTextSpan(dense[i], dense[i + 1]), classificationType: getClassificationTypeName(dense[i + 2]) @@ -54340,16 +54772,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 281: + case 282: processJSDocParameterTag(tag); break; - case 284: + case 285: processJSDocTemplateTag(tag); break; - case 283: + case 284: processElement(tag.typeExpression); break; - case 282: + case 283: processElement(tag.typeExpression); break; } @@ -54430,22 +54862,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 248: + case 249: if (token.parent.tagName === token) { return 19; } break; - case 249: + case 250: if (token.parent.tagName === token) { return 20; } break; - case 247: + case 248: if (token.parent.tagName === token) { return 21; } break; - case 250: + case 251: if (token.parent.name === token) { return 22; } @@ -54465,10 +54897,10 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { if (tokenKind === 57) { - if (token.parent.kind === 223 || + if (token.parent.kind === 224 || token.parent.kind === 147 || token.parent.kind === 144 || - token.parent.kind === 250) { + token.parent.kind === 251) { return 5; } } @@ -54485,7 +54917,7 @@ var ts; return 4; } else if (tokenKind === 9) { - return token.parent.kind === 250 ? 24 : 6; + return token.parent.kind === 251 ? 24 : 6; } else if (tokenKind === 11) { return 6; @@ -54499,7 +54931,7 @@ var ts; else if (tokenKind === 70) { if (token) { switch (token.parent.kind) { - case 226: + case 227: if (token.parent.name === token) { return 11; } @@ -54509,17 +54941,17 @@ var ts; return 15; } return; - case 227: + case 228: if (token.parent.name === token) { return 13; } return; - case 229: + case 230: if (token.parent.name === token) { return 12; } return; - case 230: + case 231: if (token.parent.name === token) { return 14; } @@ -54540,9 +54972,8 @@ var ts; } if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { checkForClassificationCancellation(cancellationToken, element.kind); - var children = element.getChildren(sourceFile); - for (var i = 0, n = children.length; i < n; i++) { - var child = children[i]; + for (var _i = 0, _a = element.getChildren(sourceFile); _i < _a.length; _i++) { + var child = _a[_i]; if (!tryClassifyNode(child)) { processElement(child); } @@ -54579,7 +55010,7 @@ var ts; else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 && - location.parent && location.parent.kind === 249) { + location.parent && location.parent.kind === 250) { var tagName = location.parent.parent.openingElement.tagName; entries.push({ name: tagName.text, @@ -54601,13 +55032,13 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_45 in nameTable) { - if (nameTable[name_45] === position) { + for (var name_46 in nameTable) { + if (nameTable[name_46] === position) { continue; } - if (!uniqueNames[name_45]) { - uniqueNames[name_45] = name_45; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_45), compilerOptions.target, true); + if (!uniqueNames[name_46]) { + uniqueNames[name_46] = name_46; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_46), compilerOptions.target, true); if (displayName) { var entry = { name: displayName, @@ -54657,7 +55088,7 @@ var ts; if (!node || node.kind !== 9) { return undefined; } - if (node.parent.kind === 257 && + if (node.parent.kind === 258 && node.parent.parent.kind === 176 && node.parent.name === node) { return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); @@ -54665,7 +55096,7 @@ var ts; else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 235 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 236 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { return getStringLiteralCompletionEntriesFromModuleNames(node); } else { @@ -54725,6 +55156,9 @@ var ts; return undefined; } function addStringLiteralCompletionsFromType(type, result) { + if (type && type.flags & 16384) { + type = typeChecker.getApparentType(type); + } if (!type) { return; } @@ -55029,11 +55463,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_13 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_13) { + var parent_14 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_14) { break; } - currentDir = parent_13; + currentDir = parent_14; } else { break; @@ -55165,9 +55599,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 283: - case 281: + case 284: case 282: + case 283: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -55202,13 +55636,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_14 = contextToken.parent, kind = contextToken.kind; + var parent_15 = contextToken.parent, kind = contextToken.kind; if (kind === 22) { - if (parent_14.kind === 177) { + if (parent_15.kind === 177) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_14.kind === 141) { + else if (parent_15.kind === 141) { node = contextToken.parent.left; isRightOfDot = true; } @@ -55221,7 +55655,7 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 40 && contextToken.parent.kind === 249) { + else if (kind === 40 && contextToken.parent.kind === 250) { isStartingCloseTag = true; location = contextToken; } @@ -55312,7 +55746,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 247) || (jsxContainer.kind === 248)) { + if ((jsxContainer.kind === 248) || (jsxContainer.kind === 249)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); @@ -55333,9 +55767,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 261 || + scopeNode.kind === 262 || scopeNode.kind === 194 || - scopeNode.kind === 252 || + scopeNode.kind === 253 || ts.isStatement(scopeNode); } var symbolMeanings = 793064 | 107455 | 1920 | 8388608; @@ -55363,11 +55797,11 @@ var ts; return true; } if (contextToken.kind === 28 && contextToken.parent) { - if (contextToken.parent.kind === 248) { + if (contextToken.parent.kind === 249) { return true; } - if (contextToken.parent.kind === 249 || contextToken.parent.kind === 247) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 246; + if (contextToken.parent.kind === 250 || contextToken.parent.kind === 248) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 247; } } return false; @@ -55397,16 +55831,16 @@ var ts; case 128: return true; case 22: - return containingNodeKind === 230; + return containingNodeKind === 231; case 16: - return containingNodeKind === 226; + return containingNodeKind === 227; case 57: - return containingNodeKind === 223 + return containingNodeKind === 224 || containingNodeKind === 192; case 13: return containingNodeKind === 194; case 14: - return containingNodeKind === 202; + return containingNodeKind === 203; case 113: case 111: case 112: @@ -55482,9 +55916,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 238 ? - 235 : - 241; + var declarationKind = namedImportsOrExports.kind === 239 ? + 236 : + 242; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -55505,9 +55939,9 @@ var ts; switch (contextToken.kind) { case 16: case 25: - var parent_15 = contextToken.parent; - if (parent_15 && (parent_15.kind === 176 || parent_15.kind === 172)) { - return parent_15; + var parent_16 = contextToken.parent; + if (parent_16 && (parent_16.kind === 176 || parent_16.kind === 172)) { + return parent_16; } break; } @@ -55520,8 +55954,8 @@ var ts; case 16: case 25: switch (contextToken.parent.kind) { - case 238: - case 242: + case 239: + case 243: return contextToken.parent; } } @@ -55530,34 +55964,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_16 = contextToken.parent; + var parent_17 = contextToken.parent; switch (contextToken.kind) { case 27: case 40: case 70: - case 250: case 251: - if (parent_16 && (parent_16.kind === 247 || parent_16.kind === 248)) { - return parent_16; + case 252: + if (parent_17 && (parent_17.kind === 248 || parent_17.kind === 249)) { + return parent_17; } - else if (parent_16.kind === 250) { - return parent_16.parent; + else if (parent_17.kind === 251) { + return parent_17.parent; } break; case 9: - if (parent_16 && ((parent_16.kind === 250) || (parent_16.kind === 251))) { - return parent_16.parent; + if (parent_17 && ((parent_17.kind === 251) || (parent_17.kind === 252))) { + return parent_17.parent; } break; case 17: - if (parent_16 && - parent_16.kind === 252 && - parent_16.parent && - (parent_16.parent.kind === 250)) { - return parent_16.parent.parent; + if (parent_17 && + parent_17.kind === 253 && + parent_17.parent && + (parent_17.parent.kind === 251)) { + return parent_17.parent.parent; } - if (parent_16 && parent_16.kind === 251) { - return parent_16.parent; + if (parent_17 && parent_17.kind === 252) { + return parent_17.parent; } break; } @@ -55568,7 +56002,7 @@ var ts; switch (kind) { case 184: case 185: - case 225: + case 226: case 149: case 148: case 151: @@ -55584,16 +56018,16 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25: - return containingNodeKind === 223 || - containingNodeKind === 224 || - containingNodeKind === 205 || - containingNodeKind === 229 || + return containingNodeKind === 224 || + containingNodeKind === 225 || + containingNodeKind === 206 || + containingNodeKind === 230 || isFunction(containingNodeKind) || - containingNodeKind === 226 || - containingNodeKind === 197 || containingNodeKind === 227 || + containingNodeKind === 197 || + containingNodeKind === 228 || containingNodeKind === 173 || - containingNodeKind === 228; + containingNodeKind === 229; case 22: return containingNodeKind === 173; case 55: @@ -55601,22 +56035,22 @@ var ts; case 20: return containingNodeKind === 173; case 18: - return containingNodeKind === 256 || + return containingNodeKind === 257 || isFunction(containingNodeKind); case 16: - return containingNodeKind === 229 || - containingNodeKind === 227 || + return containingNodeKind === 230 || + containingNodeKind === 228 || containingNodeKind === 161; case 24: return containingNodeKind === 146 && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 227 || + (contextToken.parent.parent.kind === 228 || contextToken.parent.parent.kind === 161); case 26: - return containingNodeKind === 226 || + return containingNodeKind === 227 || containingNodeKind === 197 || - containingNodeKind === 227 || containingNodeKind === 228 || + containingNodeKind === 229 || isFunction(containingNodeKind); case 114: return containingNodeKind === 147; @@ -55629,9 +56063,9 @@ var ts; case 112: return containingNodeKind === 144; case 117: - return containingNodeKind === 239 || - containingNodeKind === 243 || - containingNodeKind === 237; + return containingNodeKind === 240 || + containingNodeKind === 244 || + containingNodeKind === 238; case 74: case 82: case 108: @@ -55680,8 +56114,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_46 = element.propertyName || element.name; - existingImportsOrExports[name_46.text] = true; + var name_47 = element.propertyName || element.name; + existingImportsOrExports[name_47.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -55695,8 +56129,8 @@ var ts; var existingMemberNames = ts.createMap(); for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; - if (m.kind !== 257 && - m.kind !== 258 && + if (m.kind !== 258 && + m.kind !== 259 && m.kind !== 174 && m.kind !== 149 && m.kind !== 151 && @@ -55726,7 +56160,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 250) { + if (attr.kind === 251) { seenNames[attr.name.text] = true; } } @@ -55875,58 +56309,58 @@ var ts; switch (node.kind) { case 89: case 81: - if (hasKind(node.parent, 208)) { + if (hasKind(node.parent, 209)) { return getIfElseOccurrences(node.parent); } break; case 95: - if (hasKind(node.parent, 216)) { + if (hasKind(node.parent, 217)) { return getReturnOccurrences(node.parent); } break; case 99: - if (hasKind(node.parent, 220)) { + if (hasKind(node.parent, 221)) { return getThrowOccurrences(node.parent); } break; case 73: - if (hasKind(parent(parent(node)), 221)) { + if (hasKind(parent(parent(node)), 222)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 101: case 86: - if (hasKind(parent(node), 221)) { + if (hasKind(parent(node), 222)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 97: - if (hasKind(node.parent, 218)) { + if (hasKind(node.parent, 219)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 72: case 78: - if (hasKind(parent(parent(parent(node))), 218)) { + if (hasKind(parent(parent(parent(node))), 219)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 71: case 76: - if (hasKind(node.parent, 215) || hasKind(node.parent, 214)) { + if (hasKind(node.parent, 216) || hasKind(node.parent, 215)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 87: - if (hasKind(node.parent, 211) || - hasKind(node.parent, 212) || - hasKind(node.parent, 213)) { + if (hasKind(node.parent, 212) || + hasKind(node.parent, 213) || + hasKind(node.parent, 214)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 105: case 80: - if (hasKind(node.parent, 210) || hasKind(node.parent, 209)) { + if (hasKind(node.parent, 211) || hasKind(node.parent, 210)) { return getLoopBreakContinueOccurrences(node.parent); } break; @@ -55943,7 +56377,7 @@ var ts; break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 205)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 206)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -55955,10 +56389,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 220) { + if (node.kind === 221) { statementAccumulator.push(node); } - else if (node.kind === 221) { + else if (node.kind === 222) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -55978,17 +56412,17 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_17 = child.parent; - if (ts.isFunctionBlock(parent_17) || parent_17.kind === 261) { - return parent_17; + var parent_18 = child.parent; + if (ts.isFunctionBlock(parent_18) || parent_18.kind === 262) { + return parent_18; } - if (parent_17.kind === 221) { - var tryStatement = parent_17; + if (parent_18.kind === 222) { + var tryStatement = parent_18; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_17; + child = parent_18; } return undefined; } @@ -55997,7 +56431,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 215 || node.kind === 214) { + if (node.kind === 216 || node.kind === 215) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -56010,23 +56444,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 218: - if (statement.kind === 214) { + for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { + switch (node_2.kind) { + case 219: + if (statement.kind === 215) { continue; } - case 211: case 212: case 213: + case 214: + case 211: case 210: - case 209: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; + 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; @@ -56037,24 +56471,24 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 226 || + if (!(container.kind === 227 || container.kind === 197 || (declaration.kind === 144 && hasKind(container, 150)))) { return undefined; } } else if (modifier === 114) { - if (!(container.kind === 226 || container.kind === 197)) { + if (!(container.kind === 227 || container.kind === 197)) { return undefined; } } else if (modifier === 83 || modifier === 123) { - if (!(container.kind === 231 || container.kind === 261)) { + if (!(container.kind === 232 || container.kind === 262)) { return undefined; } } else if (modifier === 116) { - if (!(container.kind === 226 || declaration.kind === 226)) { + if (!(container.kind === 227 || declaration.kind === 227)) { return undefined; } } @@ -56065,8 +56499,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 231: - case 261: + case 232: + case 262: if (modifierFlag & 128) { nodes = declaration.members.concat(declaration); } @@ -56077,7 +56511,7 @@ var ts; case 150: nodes = container.parameters.concat(container.parent.members); break; - case 226: + case 227: case 197: nodes = container.members; if (modifierFlag & 28) { @@ -56158,7 +56592,7 @@ var ts; function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { - if (loopNode.kind === 209) { + if (loopNode.kind === 210) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 105)) { @@ -56179,13 +56613,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 211: case 212: case 213: - case 209: + case 214: case 210: + case 211: return getLoopBreakContinueOccurrences(owner); - case 218: + case 219: return getSwitchCaseDefaultOccurrences(owner); } } @@ -56235,7 +56669,7 @@ var ts; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 204))) { + if (!(func && hasKind(func.body, 205))) { return undefined; } var keywords = []; @@ -56249,7 +56683,7 @@ var ts; } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 208) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 209) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { @@ -56260,7 +56694,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 208)) { + if (!hasKind(ifStatement.elseStatement, 209)) { break; } ifStatement = ifStatement.elseStatement; @@ -56295,7 +56729,7 @@ var ts; } DocumentHighlights.getDocumentHighlights = getDocumentHighlights; function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 219; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 220; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -56499,16 +56933,16 @@ var ts; } function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608) { - var defaultImport = ts.getDeclarationOfKind(symbol, 236); + var defaultImport = ts.getDeclarationOfKind(symbol, 237); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 239 || - declaration.kind === 243) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 240 || + declaration.kind === 244) ? declaration : undefined; }); if (importOrExportSpecifier && (!importOrExportSpecifier.propertyName || importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 239 ? + return importOrExportSpecifier.kind === 240 ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -56552,7 +56986,7 @@ var ts; if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 226); + return ts.getAncestor(privateDeclaration, 227); } } if (symbol.flags & 8388608) { @@ -56576,7 +57010,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 261 && !ts.isExternalModule(container)) { + if (container.kind === 262 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -56813,7 +57247,7 @@ var ts; result.push(getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === 70) { - if (refNode.parent.kind === 258) { + if (refNode.parent.kind === 259) { getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } var containingClass = getContainingClassIfInHeritageClause(refNode); @@ -56823,24 +57257,24 @@ var ts; } var containingTypeReference = getContainingTypeReference(refNode); if (containingTypeReference) { - var parent_18 = containingTypeReference.parent; - if (ts.isVariableLike(parent_18) && parent_18.type === containingTypeReference && parent_18.initializer && isImplementationExpression(parent_18.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_18.initializer)); + var parent_19 = containingTypeReference.parent; + if (ts.isVariableLike(parent_19) && parent_19.type === containingTypeReference && parent_19.initializer && isImplementationExpression(parent_19.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_19.initializer)); } - else if (ts.isFunctionLike(parent_18) && parent_18.type === containingTypeReference && parent_18.body) { - if (parent_18.body.kind === 204) { - ts.forEachReturnStatement(parent_18.body, function (returnStatement) { + else if (ts.isFunctionLike(parent_19) && parent_19.type === containingTypeReference && parent_19.body) { + if (parent_19.body.kind === 205) { + ts.forEachReturnStatement(parent_19.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); } }); } - else if (isImplementationExpression(parent_18.body)) { - maybeAdd(getReferenceEntryFromNode(parent_18.body)); + else if (isImplementationExpression(parent_19.body)) { + maybeAdd(getReferenceEntryFromNode(parent_19.body)); } } - else if (ts.isAssertionExpression(parent_18) && isImplementationExpression(parent_18.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_18.expression)); + else if (ts.isAssertionExpression(parent_19) && isImplementationExpression(parent_19.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_19.expression)); } } } @@ -56876,7 +57310,7 @@ var ts; function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { if (node.kind === 199 - && node.parent.kind === 255 + && node.parent.kind === 256 && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -56923,7 +57357,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 227) { + else if (declaration.kind === 228) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -56997,11 +57431,11 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; break; - case 261: + case 262: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 225: + case 226: case 184: break; default: @@ -57009,7 +57443,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 261) { + if (searchSpaceNode.kind === 262) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -57044,7 +57478,7 @@ var ts; var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { case 184: - case 225: + case 226: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } @@ -57056,13 +57490,13 @@ var ts; } break; case 197: - case 226: + case 227: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 261: - if (container.kind === 261 && !ts.isExternalModule(container)) { + case 262: + if (container.kind === 262 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -57097,13 +57531,13 @@ var ts; for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { var position = possiblePositions_1[_i]; cancellationToken.throwIfCancellationRequested(); - var node_2 = ts.getTouchingWord(sourceFile, position); - if (!node_2 || node_2.kind !== 9) { + var node_3 = ts.getTouchingWord(sourceFile, position); + if (!node_3 || node_3.kind !== 9) { return; } - var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + var type_1 = ts.getStringLiteralTypeForNode(node_3, typeChecker); if (type_1 === searchType) { - references.push(getReferenceEntryFromNode(node_2)); + references.push(getReferenceEntryFromNode(node_3)); } } } @@ -57111,7 +57545,7 @@ var ts; function populateSearchSymbolSet(symbol, location) { var result = [symbol]; var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 258) { + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 259) { var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); if (propertySymbol) { result.push(propertySymbol); @@ -57161,7 +57595,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 227) { + else if (declaration.kind === 228) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -57293,7 +57727,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 223) { + else if (node.kind === 224) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2); } @@ -57303,18 +57737,18 @@ var ts; } else { switch (node.kind) { - case 226: + case 227: case 197: - case 229: case 230: + case 231: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 205) { - ts.Debug.assert(node.parent.kind === 224); + if (node.parent && node.parent.parent && node.parent.parent.kind === 206) { + ts.Debug.assert(node.parent.kind === 225); return node.parent.parent; } } @@ -57384,8 +57818,8 @@ var ts; } function isObjectLiteralPropertyDeclaration(node) { switch (node.kind) { - case 257: case 258: + case 259: case 149: case 151: case 152: @@ -57447,11 +57881,11 @@ var ts; var declaration = symbol.declarations[0]; if (node.kind === 70 && (node.parent === declaration || - (declaration.kind === 239 && declaration.parent && declaration.parent.kind === 238))) { + (declaration.kind === 240 && declaration.parent && declaration.parent.kind === 239))) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 258) { + if (node.parent.kind === 259) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -57529,7 +57963,7 @@ var ts; var definition; ts.forEach(signatureDeclarations, function (d) { if ((selectConstructors && d.kind === 150) || - (!selectConstructors && (d.kind === 225 || d.kind === 149 || d.kind === 148))) { + (!selectConstructors && (d.kind === 226 || d.kind === 149 || d.kind === 148))) { declarations.push(d); if (d.body) definition = d; @@ -57605,7 +58039,7 @@ var ts; var GoToImplementation; (function (GoToImplementation) { function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { - if (node.parent.kind === 258) { + if (node.parent.kind === 259) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -57697,7 +58131,7 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function forEachUnique(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (ts.indexOf(array, array[i]) === i) { var result = callback(array[i], i); if (result) { @@ -57731,16 +58165,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 225: + case 226: case 149: case 150: - case 226: - case 205: + case 227: + case 206: break findOwner; - case 261: + case 262: return undefined; - case 230: - if (commentOwner.parent.kind === 230) { + case 231: + if (commentOwner.parent.kind === 231) { return undefined; } break findOwner; @@ -57755,7 +58189,7 @@ var ts; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; - for (var i = 0, numParams = parameters.length; i < numParams; i++) { + for (var i = 0; i < parameters.length; i++) { var currentName = parameters[i].name; var paramName = currentName.kind === 70 ? currentName.text : @@ -57780,7 +58214,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 205) { + if (commentOwner.kind === 206) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -57823,10 +58257,10 @@ var ts; return; } var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_47 in nameToDeclarations) { - var declarations = nameToDeclarations[name_47]; + for (var name_48 in nameToDeclarations) { + var declarations = nameToDeclarations[name_48]; if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_47); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_48); if (!matches) { continue; } @@ -57837,21 +58271,21 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_47); + matches = patternMatcher.getMatches(containers, name_48); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_47, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_48, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } }); rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 236 || decl.kind === 239 || decl.kind === 234) { + if (decl.kind === 237 || decl.kind === 240 || decl.kind === 235) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -58076,14 +58510,14 @@ var ts; addLeafNode(node); } break; - case 236: + case 237: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 237) { + if (namedBindings.kind === 238) { addLeafNode(namedBindings); } else { @@ -58095,11 +58529,11 @@ var ts; } break; case 174: - case 223: + case 224: var decl = node; - var name_48 = decl.name; - if (ts.isBindingPattern(name_48)) { - addChildrenRecursively(name_48); + var name_49 = decl.name; + if (ts.isBindingPattern(name_49)) { + addChildrenRecursively(name_49); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { addChildrenRecursively(decl.initializer); @@ -58109,11 +58543,11 @@ var ts; } break; case 185: - case 225: + case 226: case 184: addNodeWithRecursiveChild(node, node.body); break; - case 229: + case 230: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -58123,9 +58557,9 @@ var ts; } endNode(); break; - case 226: - case 197: case 227: + case 197: + case 228: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -58133,21 +58567,21 @@ var ts; } endNode(); break; - case 230: + case 231: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 243: - case 234: + case 244: + case 235: case 155: case 153: case 154: - case 228: + case 229: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 285) { + if (tag.kind === 286) { addLeafNode(tag); } }); @@ -58195,12 +58629,12 @@ var ts; } }); function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 230 || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 231 || areSameModule(a, b)); function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 230) { + if (a.body.kind !== 231) { return true; } return areSameModule(a.body, b.body); @@ -58251,7 +58685,7 @@ var ts; return a.length - b.length; }; function tryGetName(node) { - if (node.kind === 230) { + if (node.kind === 231) { return getModuleName(node); } var decl = node; @@ -58263,14 +58697,14 @@ var ts; case 185: case 197: return getFunctionOrClassName(node); - case 285: + case 286: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 230) { + if (node.kind === 231) { return getModuleName(node); } var name = node.name; @@ -58281,15 +58715,15 @@ var ts; } } switch (node.kind) { - case 261: + case 262: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; case 185: - case 225: - case 184: case 226: + case 184: + case 227: case 197: if (ts.getModifierFlags(node) & 512) { return "default"; @@ -58303,7 +58737,7 @@ var ts; return "()"; case 155: return "[]"; - case 285: + case 286: return getJSDocTypedefTagName(node); default: return ""; @@ -58315,7 +58749,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 205) { + if (parentNode && parentNode.kind === 206) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -58343,23 +58777,23 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 226: - case 197: - case 229: case 227: + case 197: case 230: - case 261: case 228: - case 285: + case 231: + case 262: + case 229: + case 286: return true; case 150: case 149: case 151: case 152: - case 223: + case 224: return hasSomeImportantChild(item); case 185: - case 225: + case 226: case 184: return isTopLevelFunctionDeclaration(item); default: @@ -58370,8 +58804,8 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 231: - case 261: + case 232: + case 262: case 149: case 150: return true; @@ -58382,7 +58816,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 223 && childKind !== 174; + return childKind !== 224 && childKind !== 174; }); } } @@ -58437,20 +58871,20 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 230) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 231) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } return result.join("."); } function getInteriorModule(decl) { - return decl.body.kind === 230 ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 231 ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { return !member.name || member.name.kind === 142; } function getNodeSpan(node) { - return node.kind === 261 + return node.kind === 262 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); } @@ -58458,14 +58892,14 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 223) { + else if (node.parent.kind === 224) { return ts.declarationNameToString(node.parent.name); } else if (node.parent.kind === 192 && node.parent.operatorToken.kind === 57) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 257 && node.parent.name) { + else if (node.parent.kind === 258 && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512) { @@ -58561,26 +58995,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 204: + case 205: if (!ts.isFunctionBlock(n)) { - var parent_19 = n.parent; + var parent_20 = n.parent; var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); - if (parent_19.kind === 209 || - parent_19.kind === 212 || - parent_19.kind === 213 || - parent_19.kind === 211 || - parent_19.kind === 208 || - parent_19.kind === 210 || - parent_19.kind === 217 || - parent_19.kind === 256) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + if (parent_20.kind === 210 || + parent_20.kind === 213 || + parent_20.kind === 214 || + parent_20.kind === 212 || + parent_20.kind === 209 || + parent_20.kind === 211 || + parent_20.kind === 218 || + parent_20.kind === 257) { + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_19.kind === 221) { - var tryStatement = parent_19; + if (parent_20.kind === 222) { + var tryStatement = parent_20; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -58600,17 +59034,17 @@ var ts; }); break; } - case 231: { + case 232: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 226: case 227: - case 229: + case 228: + case 230: case 176: - case 232: { + case 233: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); @@ -58878,7 +59312,8 @@ var ts; return str === str.toLowerCase(); } function indexOfIgnoringCase(string, value) { - for (var i = 0, n = string.length - value.length; i <= n; i++) { + var n = string.length - value.length; + for (var i = 0; i <= n; i++) { if (startsWithIgnoringCase(string, value, i)) { return i; } @@ -58886,7 +59321,7 @@ var ts; return -1; } function startsWithIgnoringCase(string, value, start) { - for (var i = 0, n = value.length; i < n; i++) { + for (var i = 0; i < value.length; i++) { var ch1 = toLowerCase(string.charCodeAt(i + start)); var ch2 = value.charCodeAt(i); if (ch1 !== ch2) { @@ -58954,7 +59389,7 @@ var ts; function breakIntoSpans(identifier, word) { var result = []; var wordStart = 0; - for (var i = 1, n = identifier.length; i < n; i++) { + for (var i = 1; i < identifier.length; i++) { var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); var currentIsDigit = isDigit(identifier.charCodeAt(i)); var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); @@ -59527,7 +59962,7 @@ var ts; var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 202 && node.parent.parent.parent.kind === 181) { + else if (node.parent.kind === 203 && node.parent.parent.parent.kind === 181) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; @@ -59604,7 +60039,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 261; n = n.parent) { + for (var n = node; n.kind !== 262; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -59966,7 +60401,7 @@ var ts; } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 230); + var declaration = ts.getDeclarationOfKind(symbol, 231); var isNamespace = declaration && declaration.name && declaration.name.kind === 70; displayParts.push(ts.keywordPart(isNamespace ? 128 : 127)); displayParts.push(ts.spacePart()); @@ -60001,7 +60436,7 @@ var ts; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } - else if (declaration.kind === 228) { + else if (declaration.kind === 229) { addInPrefix(); displayParts.push(ts.keywordPart(136)); displayParts.push(ts.spacePart()); @@ -60014,7 +60449,7 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 260) { + if (declaration.kind === 261) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -60026,7 +60461,7 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 233) { + if (symbol.declarations[0].kind === 234) { displayParts.push(ts.keywordPart(83)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(128)); @@ -60037,7 +60472,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 234) { + if (declaration.kind === 235) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -60105,7 +60540,7 @@ var ts; if (!documentation) { documentation = symbol.getDocumentationComment(); if (documentation.length === 0 && symbol.flags & 4) { - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 261; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 262; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!declaration.parent || declaration.parent.kind !== 192) { @@ -60191,11 +60626,11 @@ var ts; if (declaration.kind === 184) { return true; } - if (declaration.kind !== 223 && declaration.kind !== 225) { + if (declaration.kind !== 224 && declaration.kind !== 226) { return false; } - for (var parent_20 = declaration.parent; !ts.isFunctionBlock(parent_20); parent_20 = parent_20.parent) { - if (parent_20.kind === 261 || parent_20.kind === 231) { + for (var parent_21 = declaration.parent; !ts.isFunctionBlock(parent_21); parent_21 = parent_21.parent) { + if (parent_21.kind === 262 || parent_21.kind === 232) { return false; } } @@ -60386,10 +60821,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { + case 251: + case 249: case 250: case 248: - case 249: - case 247: return node.kind === 70; } } @@ -60722,10 +61157,10 @@ var ts; this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromRange(0, 140, [19])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17, 81), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17, 105), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([19, 21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); @@ -60736,10 +61171,10 @@ var ts; this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19, 3, 80, 101, 86, 81]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8)); this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8)); this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); @@ -60759,6 +61194,7 @@ var ts; this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([109, 75]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2)); this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); @@ -60767,9 +61203,10 @@ var ts; this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 133]), 70), 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127, 131]), 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 133, 114, 136, 138]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 130, 133, 114, 136, 138, 126]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 138])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); @@ -60797,6 +61234,7 @@ var ts; this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40, 28), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, @@ -60825,7 +61263,7 @@ var ts; this.NoSpaceBetweenTagAndTemplateString, this.SpaceBeforeJsxAttribute, this.SpaceBeforeSlashInJsxOpeningElement, this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement, this.NoSpaceBeforeEqualInJsxAttribute, this.NoSpaceAfterEqualInJsxAttribute, - this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, + this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, this.SpaceBeforeArrow, this.SpaceAfterArrow, @@ -60840,6 +61278,7 @@ var ts; this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, + this.NoSpaceBeforeNonNullAssertionOperator ]; this.LowPriorityCommonRules = [ this.NoSpaceBeforeSemicolon, @@ -60848,7 +61287,6 @@ var ts; this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, - this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2)); @@ -60889,15 +61327,15 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_49 in o) { - if (o[name_49] === rule) { - return name_49; + for (var name_50 in o) { + if (o[name_50] === rule) { + return name_50; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 211; + return context.contextNode.kind === 212; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); @@ -60907,24 +61345,25 @@ var ts; case 192: case 193: case 200: - case 243: - case 239: + case 244: + case 240: case 156: case 164: case 165: return true; case 174: - case 228: - case 234: - case 223: + case 229: + case 235: + case 224: case 144: - case 260: + case 261: case 147: case 146: return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; - case 212: - return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; case 213: + case 143: + return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; + case 214: return context.currentTokenSpan.kind === 140 || context.nextTokenSpan.kind === 140; } return false; @@ -60938,6 +61377,9 @@ var ts; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; + Rules.IsBraceWrappedContext = function (context) { + return context.contextNode.kind === 172 || Rules.IsSingleLineBlockContext(context); + }; Rules.IsBeforeMultilineBlockContext = function (context) { return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); }; @@ -60958,17 +61400,17 @@ var ts; return true; } switch (node.kind) { - case 204: - case 232: + case 205: + case 233: case 176: - case 231: + case 232: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 225: + case 226: case 149: case 148: case 151: @@ -60977,58 +61419,64 @@ var ts; case 184: case 150: case 185: - case 227: + case 228: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 225 || context.contextNode.kind === 184; + return context.contextNode.kind === 226 || context.contextNode.kind === 184; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 226: - case 197: case 227: - case 229: - case 161: + case 197: + case 228: case 230: - case 241: + case 161: + case 231: case 242: - case 235: - case 238: + case 243: + case 236: + case 239: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 226: - case 230: - case 229: - case 204: - case 256: + case 227: case 231: - case 218: + case 230: + case 257: + case 232: + case 219: return true; + case 205: { + var blockParent = context.currentTokenParent.parent; + if (blockParent.kind !== 185 && + blockParent.kind !== 184) { + return true; + } + } } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 208: - case 218: - case 211: + case 209: + case 219: case 212: case 213: + case 214: + case 211: + case 222: case 210: - case 221: - case 209: - case 217: - case 256: + case 218: + case 257: return true; default: return false; @@ -61059,19 +61507,19 @@ var ts; return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 246; + return context.contextNode.kind !== 247; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 252; + return context.contextNode.kind === 253; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 250; + return context.nextTokenParent.kind === 251; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 250; + return context.contextNode.kind === 251; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 247; + return context.contextNode.kind === 248; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -61089,14 +61537,14 @@ var ts; return node.kind === 145; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 224 && + return context.currentTokenParent.kind === 225 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 230; + return context.contextNode.kind === 231; }; Rules.IsObjectTypeContext = function (context) { return context.contextNode.kind === 161; @@ -61108,10 +61556,11 @@ var ts; switch (parent.kind) { case 157: case 182: - case 226: - case 197: + case 229: case 227: - case 225: + case 197: + case 228: + case 226: case 184: case 185: case 149: @@ -61139,6 +61588,9 @@ var ts; Rules.IsYieldOrYieldStarWithOperand = function (context) { return context.contextNode.kind === 195 && context.contextNode.expression !== undefined; }; + Rules.IsNonNullAssertionContext = function (context) { + return context.contextNode.kind === 201; + }; return Rules; }()); formatting.Rules = Rules; @@ -61423,6 +61875,12 @@ var ts; }; RulesProvider.prototype.createActiveRules = function (options) { var rules = this.globalRules.HighPriorityCommonRules.slice(0); + if (options.insertSpaceAfterConstructor) { + rules.push(this.globalRules.SpaceAfterConstructor); + } + else { + rules.push(this.globalRules.NoSpaceAfterConstructor); + } if (options.insertSpaceAfterCommaDelimiter) { rules.push(this.globalRules.SpaceAfterComma); } @@ -61501,6 +61959,12 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); rules.push(this.globalRules.NoSpaceAfterBinaryOperator); } + if (options.insertSpaceBeforeFunctionParenthesis) { + rules.push(this.globalRules.SpaceBeforeOpenParenInFuncDecl); + } + else { + rules.push(this.globalRules.NoSpaceBeforeOpenParenInFuncDecl); + } if (options.placeOpenBraceOnNewLineForControlBlocks) { rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); } @@ -61598,17 +62062,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 226: case 227: + case 228: return ts.rangeContainsRange(parent.members, node); - case 230: - var body = parent.body; - return body && body.kind === 231 && ts.rangeContainsRange(body.statements, node); - case 261: - case 204: case 231: + var body = parent.body; + return body && body.kind === 232 && ts.rangeContainsRange(body.statements, node); + case 262: + case 205: + case 232: return ts.rangeContainsRange(parent.statements, node); - case 256: + case 257: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -61764,10 +62228,10 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 226: return 74; - case 227: return 108; - case 225: return 88; - case 229: return 229; + case 227: return 74; + case 228: return 108; + case 226: return 88; + case 230: return 230; case 151: return 124; case 152: return 133; case 149: @@ -61799,17 +62263,30 @@ var ts; switch (kind) { case 16: case 17: - case 20: - case 21: case 18: case 19: case 81: case 105: case 56: return indentation; - default: - return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; + case 40: + case 28: { + if (container.kind === 249 || + container.kind === 250 || + container.kind === 248) { + return indentation; + } + break; + } + case 20: + case 21: { + if (container.kind !== 170) { + return indentation; + } + break; + } } + return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; }, getIndentation: function () { return indentation; }, getDelta: function (child) { return getEffectiveDelta(delta, child); }, @@ -61850,7 +62327,7 @@ var ts; if (tokenInfo.token.end > node.end) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); @@ -61880,7 +62357,7 @@ var ts; if (tokenInfo.token.end > childStartPos) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, node); } if (!formattingScanner.isOnToken()) { return inheritedIndentation; @@ -61915,10 +62392,10 @@ var ts; startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1, parent, parentDynamicIndentation, parentStartLine); listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } else { - consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); } } } @@ -61931,7 +62408,7 @@ var ts; if (formattingScanner.isOnToken()) { var tokenInfo = formattingScanner.readTokenInfo(parent); if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } } } @@ -62121,7 +62598,7 @@ var ts; startLine++; } var delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; i++, startLine++) { + for (var i = startIndex; i < parts.length; i++, startLine++) { var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart @@ -62212,7 +62689,7 @@ var ts; function getOpenTokenForList(node, list) { switch (node.kind) { case 150: - case 225: + case 226: case 184: case 149: case 148: @@ -62436,7 +62913,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 261 || !parentAndChildShareLine); + (parent.kind === 262 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -62460,7 +62937,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 208 && parent.elseStatement === child) { + if (parent.kind === 209 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -62482,7 +62959,7 @@ var ts; return node.parent.properties; case 175: return node.parent.elements; - case 225: + case 226: case 184: case 185: case 149: @@ -62604,35 +63081,36 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 207: - case 226: - case 197: + case 208: case 227: - case 229: + case 197: case 228: + case 230: + case 229: case 175: - case 204: - case 231: + case 205: + case 232: case 176: case 161: + case 170: case 163: - case 232: + case 233: + case 255: case 254: - case 253: case 183: case 177: case 179: case 180: - case 205: - case 223: - case 240: - case 216: + case 206: + case 224: + case 241: + case 217: case 193: case 173: case 172: + case 249: case 248: - case 247: - case 252: + case 253: case 148: case 153: case 154: @@ -62642,10 +63120,10 @@ var ts; case 166: case 181: case 189: - case 242: - case 238: case 243: case 239: + case 244: + case 240: return true; } return false; @@ -62653,27 +63131,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 209: case 210: - case 212: - case 213: case 211: - case 208: - case 225: + case 213: + case 214: + case 212: + case 209: + case 226: case 184: case 149: case 185: case 150: case 151: case 152: - return childKind !== 204; - case 241: - return childKind !== 242; - case 235: - return childKind !== 236 || - (child.namedBindings && child.namedBindings.kind !== 238); - case 246: - return childKind !== 249; + return childKind !== 205; + case 242: + return childKind !== 243; + case 236: + return childKind !== 237 || + (child.namedBindings && child.namedBindings.kind !== 239); + case 247: + return childKind !== 250; } return indentByDefault; } @@ -62723,24 +63201,120 @@ var ts; (function (ts) { var codefix; (function (codefix) { - function getOpenBraceEnd(constructor, sourceFile) { - return constructor.body.getFirstToken(sourceFile).getEnd(); - } codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 122) { - return undefined; - } - var newPosition = getOpenBraceEnd(token.parent, sourceFile); - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] - }]; - } + errorCodes: [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code], + getCodeActions: getActionForClassLikeIncorrectImplementsInterface }); + function getActionForClassLikeIncorrectImplementsInterface(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + var classDecl = ts.getContainingClass(token); + if (!classDecl) { + return undefined; + } + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDecl); + var hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, 1); + var hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, 0); + var result = []; + for (var _i = 0, implementedTypeNodes_2 = implementedTypeNodes; _i < implementedTypeNodes_2.length; _i++) { + var implementedTypeNode = implementedTypeNodes_2[_i]; + var implementedType = checker.getTypeFromTypeNode(implementedTypeNode); + var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); + var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8); }); + var insertion = getMissingIndexSignatureInsertion(implementedType, 1, classDecl, hasNumericIndexSignature); + insertion += getMissingIndexSignatureInsertion(implementedType, 0, classDecl, hasStringIndexSignature); + insertion += codefix.getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); + var message = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); + if (insertion) { + pushAction(result, insertion, message); + } + } + return result; + function getMissingIndexSignatureInsertion(type, kind, enclosingDeclaration, hasIndexSigOfKind) { + if (!hasIndexSigOfKind) { + var IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); + if (IndexInfoOfKind) { + var writer = ts.getSingleLineStringWriter(); + checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); + var result_7 = writer.string(); + ts.releaseStringWriter(writer); + return result_7; + } + } + return ""; + } + function pushAction(result, insertion, description) { + var newAction = { + description: description, + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }; + result.push(newAction); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + function getActionForClassLikeMissingAbstractMember(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + if (ts.isClassLike(token.parent)) { + var classDecl = token.parent; + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + var extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); + var abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); + var insertion = codefix.getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); + if (insertion.length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_inherited_abstract_class), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }]; + } + } + return undefined; + } + function symbolPointsToNonPrivateAndAbstractMember(symbol) { + var decls = symbol.getDeclarations(); + ts.Debug.assert(!!(decls && decls.length > 0)); + var flags = ts.getModifierFlags(decls[0]); + return !(flags & 8) && !!(flags & 128); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { codefix.registerCodeFix({ errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], getCodeActions: function (context) { @@ -62762,7 +63336,7 @@ var ts; } } } - var newPosition = getOpenBraceEnd(constructor, sourceFile); + var newPosition = ts.getOpenBraceEnd(constructor, sourceFile); var changes = [{ fileName: sourceFile.fileName, textChanges: [{ newText: superCall.getText(sourceFile), @@ -62778,7 +63352,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 207 && ts.isSuperCall(n.expression)) { + if (n.kind === 208 && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -62791,6 +63365,216 @@ var ts; })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 122) { + return undefined; + } + var newPosition = ts.getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var classDeclNode = ts.getContainingClass(token); + if (!(token.kind === 70 && ts.isClassLike(classDeclNode))) { + return undefined; + } + var heritageClauses = classDeclNode.heritageClauses; + if (!(heritageClauses && heritageClauses.length > 0)) { + return undefined; + } + var extendsToken = heritageClauses[0].getFirstToken(); + if (!(extendsToken && extendsToken.kind === 84)) { + return undefined; + } + var changeStart = extendsToken.getStart(sourceFile); + var changeEnd = extendsToken.getEnd(); + var textChanges = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + for (var i = 1; i < heritageClauses.length; i++) { + var keywordToken = heritageClauses[i].getFirstToken(); + if (keywordToken) { + changeStart = keywordToken.getStart(sourceFile); + changeEnd = keywordToken.getEnd(); + textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + } + } + var result = [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Change_extends_to_implements), + changes: [{ + fileName: sourceFile.fileName, + textChanges: textChanges + }] + }]; + return result; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ + ts.Diagnostics._0_is_declared_but_never_used.code, + ts.Diagnostics.Property_0_is_declared_but_never_used.code + ], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + if (token.kind === 20) { + token = ts.getTokenAtPosition(sourceFile, start + 1); + } + switch (token.kind) { + case 70: + switch (token.parent.kind) { + case 224: + switch (token.parent.parent.parent.kind) { + case 212: + var forStatement = token.parent.parent.parent; + var forInitializer = forStatement.initializer; + if (forInitializer.declarations.length === 1) { + return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); + } + else { + return removeSingleItem(forInitializer.declarations, token); + } + case 214: + var forOfStatement = token.parent.parent.parent; + if (forOfStatement.initializer.kind === 225) { + var forOfInitializer = forOfStatement.initializer; + return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); + } + break; + case 213: + return undefined; + case 257: + var catchClause = token.parent.parent; + var parameter = catchClause.variableDeclaration.getChildren()[0]; + return createCodeFix("", parameter.pos, parameter.end - parameter.pos); + default: + var variableStatement = token.parent.parent.parent; + if (variableStatement.declarationList.declarations.length === 1) { + return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); + } + else { + var declarations = variableStatement.declarationList.declarations; + return removeSingleItem(declarations, token); + } + } + case 143: + var typeParameters = token.parent.parent.typeParameters; + if (typeParameters.length === 1) { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + } + else { + return removeSingleItem(typeParameters, token); + } + case 144: + var functionDeclaration = token.parent.parent; + if (functionDeclaration.parameters.length === 1) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else { + return removeSingleItem(functionDeclaration.parameters, token); + } + case 235: + var importEquals = findImportDeclaration(token); + return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); + case 240: + var namedImports = token.parent.parent; + if (namedImports.elements.length === 1) { + var importSpec = findImportDeclaration(token); + return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); + } + else { + return removeSingleItem(namedImports.elements, token); + } + case 237: + var importClause = token.parent; + if (!importClause.namedBindings) { + var importDecl = findImportDeclaration(importClause); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); + } + case 238: + var namespaceImport = token.parent; + if (namespaceImport.name == token && !namespaceImport.parent.name) { + var importDecl = findImportDeclaration(namespaceImport); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + var start_4 = namespaceImport.parent.name.end; + return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); + } + } + break; + case 147: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + case 238: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + if (ts.isDeclarationName(token)) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else if (ts.isLiteralComputedPropertyDeclarationName(token)) { + return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); + } + else { + return undefined; + } + function findImportDeclaration(token) { + var importDecl = token; + while (importDecl.kind != 236 && importDecl.parent) { + importDecl = importDecl.parent; + } + return importDecl; + } + function createCodeFix(newText, start, length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ newText: newText, span: { start: start, length: length } }] + }] + }]; + } + function removeSingleItem(elements, token) { + if (elements[0] === token.parent) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + } + else { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + } + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var codefix; (function (codefix) { @@ -62876,7 +63660,10 @@ var ts; return ImportCodeActionMap; }()); codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Cannot_find_name_0.code], + errorCodes: [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ], getCodeActions: function (context) { var sourceFile = context.sourceFile; var checker = context.program.getTypeChecker(); @@ -62887,6 +63674,11 @@ var ts; var symbolIdActionMap = new ImportCodeActionMap(); var cachedImportDeclarations = ts.createMap(); var cachedNewImportInsertPosition; + var currentTokenMeaning = ts.getMeaningFromLocation(token); + if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { + var symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); + return getCodeActionForImport(symbol, false, true); + } var allPotentialModules = checker.getAmbientModules(); for (var _i = 0, allSourceFiles_1 = allSourceFiles; _i < allSourceFiles_1.length; _i++) { var otherSourceFile = allSourceFiles_1[_i]; @@ -62894,7 +63686,6 @@ var ts; allPotentialModules.push(otherSourceFile.symbol); } } - var currentTokenMeaning = ts.getMeaningFromLocation(token); for (var _a = 0, allPotentialModules_1 = allPotentialModules; _a < allPotentialModules_1.length; _a++) { var moduleSymbol = allPotentialModules_1[_a]; context.cancellationToken.throwIfCancellationRequested(); @@ -62931,10 +63722,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 235) { + if (node.kind === 236) { return node; } - if (node.kind === 234) { + if (node.kind === 235) { return node; } node = node.parent; @@ -62952,7 +63743,7 @@ var ts; var declarations = symbol.getDeclarations(); return declarations ? ts.some(symbol.declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }) : false; } - function getCodeActionForImport(moduleSymbol, isDefault) { + function getCodeActionForImport(moduleSymbol, isDefault, isNamespaceImport) { var existingDeclarations = getImportDeclarations(moduleSymbol); if (existingDeclarations.length > 0) { return getCodeActionsForExistingImport(existingDeclarations); @@ -62967,9 +63758,9 @@ var ts; var existingModuleSpecifier; for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { var declaration = declarations_11[_i]; - if (declaration.kind === 235) { + if (declaration.kind === 236) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 237) { + if (namedBindings && namedBindings.kind === 238) { namespaceImportDeclaration = declaration; } else { @@ -62985,7 +63776,7 @@ var ts; if (namespaceImportDeclaration) { actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); } - if (namedImportDeclaration && namedImportDeclaration.importClause && + if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause && (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { var textChange = getTextChangeForImportClause(namedImportDeclaration.importClause); var moduleSpecifierWithoutQuotes = ts.stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); @@ -62996,7 +63787,7 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 245) { + if (declaration.moduleReference && declaration.moduleReference.kind === 246) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); @@ -63029,7 +63820,7 @@ var ts; } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 235) { + if (declaration.kind === 236) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -63055,7 +63846,9 @@ var ts; var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); var importStatementText = isDefault ? "import " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" - : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; + : isNamespaceImport + ? "import * as " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" + : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; var newText = cachedNewImportInsertPosition === sourceFile.getStart() ? importStatementText + ";" + context.newLineCharacter + context.newLineCharacter : "" + context.newLineCharacter + importStatementText + ";"; @@ -63072,7 +63865,7 @@ var ts; tryGetModuleNameAsNodeModule() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 261) { + if (moduleSymbol.valueDeclaration.kind !== 262) { return moduleSymbol.name; } } @@ -63085,6 +63878,7 @@ var ts; if (!relativeName) { return undefined; } + var relativeNameWithIndex = ts.removeFileExtension(relativeName); relativeName = removeExtensionAndIndexPostFix(relativeName); if (options.paths) { for (var key in options.paths) { @@ -63104,7 +63898,7 @@ var ts; return key.replace("\*", matchedStar); } } - else if (pattern === relativeName) { + else if (pattern === relativeName || pattern === relativeNameWithIndex) { return key; } } @@ -63223,144 +64017,120 @@ var ts; (function (ts) { var codefix; (function (codefix) { - codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics._0_is_declared_but_never_used.code, - ts.Diagnostics.Property_0_is_declared_but_never_used.code - ], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var start = context.span.start; - var token = ts.getTokenAtPosition(sourceFile, start); - if (token.kind === 20) { - token = ts.getTokenAtPosition(sourceFile, start + 1); - } - switch (token.kind) { - case 70: - switch (token.parent.kind) { - case 223: - switch (token.parent.parent.parent.kind) { - case 211: - var forStatement = token.parent.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); - } - else { - return removeSingleItem(forInitializer.declarations, token); - } - case 213: - var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 224) { - var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); - } - break; - case 212: - return undefined; - case 256: - var catchClause = token.parent.parent; - var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); - default: - var variableStatement = token.parent.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); - } - else { - var declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); - } - } - case 143: - var typeParameters = token.parent.parent.typeParameters; - if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); - } - else { - return removeSingleItem(typeParameters, token); - } - case 144: - var functionDeclaration = token.parent.parent; - if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else { - return removeSingleItem(functionDeclaration.parameters, token); - } - case 234: - var importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); - case 239: - var namedImports = token.parent.parent; - if (namedImports.elements.length === 1) { - var importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); - } - else { - return removeSingleItem(namedImports.elements, token); - } - case 236: - var importClause = token.parent; - if (!importClause.namedBindings) { - var importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); - } - case 237: - var namespaceImport = token.parent; - if (namespaceImport.name == token && !namespaceImport.parent.name) { - var importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - var start_4 = namespaceImport.parent.name.end; - return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); - } - } - break; - case 147: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case 237: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - if (ts.isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); - } - else { - return undefined; - } - function findImportDeclaration(token) { - var importDecl = token; - while (importDecl.kind != 235 && importDecl.parent) { - importDecl = importDecl.parent; + function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { + var classMembers = classDeclaration.symbol.members; + var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !(symbol.getName() in classMembers); }); + var insertion = ""; + for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { + var symbol = missingMembers_1[_i]; + insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + } + return insertion; + } + codefix.getMissingMembersInsertion = getMissingMembersInsertion; + function getInsertionForMemberSymbol(symbol, enclosingDeclaration, checker, newlineChar) { + var type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + var declarations = symbol.getDeclarations(); + if (!(declarations && declarations.length)) { + return ""; + } + var declaration = declarations[0]; + var name = declaration.name ? declaration.name.getText() : undefined; + var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); + switch (declaration.kind) { + case 151: + case 152: + case 146: + case 147: + var typeString = checker.typeToString(type, enclosingDeclaration, 0); + return "" + visibility + name + ": " + typeString + ";" + newlineChar; + case 148: + case 149: + var signatures = checker.getSignaturesOfType(type, 0); + if (!(signatures && signatures.length > 0)) { + return ""; } - return importDecl; - } - function createCodeFix(newText, start, length) { - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText: newText, span: { start: start, length: length } }] - }] - }]; - } - function removeSingleItem(elements, token) { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + if (declarations.length === 1) { + ts.Debug.assert(signatures.length === 1); + var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048, 0); + return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar); + } + var result = ""; + for (var i = 0; i < signatures.length; i++) { + var sigString_2 = checker.signatureToString(signatures[i], enclosingDeclaration, 2048, 0); + result += "" + visibility + name + sigString_2 + ";" + newlineChar; + } + var bodySig = undefined; + if (declarations.length > signatures.length) { + bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); } else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + ts.Debug.assert(declarations.length === signatures.length); + bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); } + var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048, 0); + result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar); + return result; + default: + return ""; + } + } + function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { + var newSignatureDeclaration = ts.createNode(153); + newSignatureDeclaration.parent = enclosingDeclaration; + newSignatureDeclaration.name = signatures[0].getDeclaration().name; + var maxNonRestArgs = -1; + var maxArgsIndex = 0; + var minArgumentCount = signatures[0].minArgumentCount; + var hasRestParameter = false; + for (var i = 0; i < signatures.length; i++) { + var sig = signatures[i]; + minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); + hasRestParameter = hasRestParameter || sig.hasRestParameter; + var nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); + if (nonRestLength > maxNonRestArgs) { + maxNonRestArgs = nonRestLength; + maxArgsIndex = i; } } - }); + var maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(function (symbol) { return symbol.getName(); }); + var optionalToken = ts.createToken(54); + newSignatureDeclaration.parameters = ts.createNodeArray(); + for (var i = 0; i < maxNonRestArgs; i++) { + var newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); + newSignatureDeclaration.parameters.push(newParameter); + } + if (hasRestParameter) { + var restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); + restParameter.dotDotDotToken = ts.createToken(23); + newSignatureDeclaration.parameters.push(restParameter); + } + return checker.getSignatureFromDeclaration(newSignatureDeclaration); + function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { + var newParameter = ts.createNode(144); + newParameter.symbol = new SymbolConstructor(1, maxArgsParameterSymbolNames[index] || "rest"); + newParameter.symbol.valueDeclaration = newParameter; + newParameter.symbol.declarations = [newParameter]; + newParameter.parent = enclosingSignatureDeclaration; + if (index >= minArgCount) { + newParameter.questionToken = optionalToken; + } + return newParameter; + } + } + function getMethodBodyStub(newLineChar) { + return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar; + } + function getVisibilityPrefix(flags) { + if (flags & 4) { + return "public "; + } + else if (flags & 16) { + return "protected "; + } + return ""; + } + var SymbolConstructor = ts.objectAllocator.getSymbolConstructor(); })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; @@ -63425,7 +64195,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(292, nodes.pos, nodes.end, this); + var list = createNode(293, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -63448,7 +64218,7 @@ var ts; ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 278 && this.kind <= 291; + var useJSDocScanner_1 = this.kind >= 279 && this.kind <= 292; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -63721,9 +64491,9 @@ var ts; } function getDeclarationName(declaration) { if (declaration.name) { - var result_7 = getTextOfIdentifierOrLiteral(declaration.name); - if (result_7 !== undefined) { - return result_7; + var result_8 = getTextOfIdentifierOrLiteral(declaration.name); + if (result_8 !== undefined) { + return result_8; } if (declaration.name.kind === 142) { var expr = declaration.name.expression; @@ -63747,7 +64517,7 @@ var ts; } function visit(node) { switch (node.kind) { - case 225: + case 226: case 184: case 149: case 148: @@ -63767,18 +64537,18 @@ var ts; } ts.forEachChild(node, visit); break; - case 226: - case 197: case 227: + case 197: case 228: case 229: case 230: - case 234: - case 243: - case 239: - case 234: - case 236: + case 231: + case 235: + case 244: + case 240: + case 235: case 237: + case 238: case 151: case 152: case 161: @@ -63789,7 +64559,7 @@ var ts; if (!ts.hasModifier(node, 92)) { break; } - case 223: + case 224: case 174: { var decl = node; if (ts.isBindingPattern(decl.name)) { @@ -63799,24 +64569,24 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 260: + case 261: case 147: case 146: addDeclaration(node); break; - case 241: + case 242: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 235: + case 236: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237) { + if (importClause.namedBindings.kind === 238) { addDeclaration(importClause.namedBindings); } else { @@ -64411,7 +65181,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 230 && + if (nodeForStartPos.parent.parent.kind === 231 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -64600,7 +65370,7 @@ var ts; continue; } var descriptor = undefined; - for (var i = 0, n = descriptors.length; i < n; i++) { + for (var i = 0; i < descriptors.length; i++) { if (matchArray[i + firstDescriptorCaptureIndex]) { descriptor = descriptors[i]; } @@ -64709,7 +65479,7 @@ var ts; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 245 || + node.parent.kind === 246 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -64745,6 +65515,1047 @@ var ts; initializeServices(); })(ts || (ts = {})); var ts; +(function (ts) { + var server; + (function (server) { + var LogLevel; + (function (LogLevel) { + LogLevel[LogLevel["terse"] = 0] = "terse"; + LogLevel[LogLevel["normal"] = 1] = "normal"; + LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; + LogLevel[LogLevel["verbose"] = 3] = "verbose"; + })(LogLevel = server.LogLevel || (server.LogLevel = {})); + server.emptyArray = []; + var Msg; + (function (Msg) { + Msg.Err = "Err"; + Msg.Info = "Info"; + Msg.Perf = "Perf"; + })(Msg = server.Msg || (server.Msg = {})); + function getProjectRootPath(project) { + switch (project.projectKind) { + case server.ProjectKind.Configured: + return ts.getDirectoryPath(project.getProjectName()); + case server.ProjectKind.Inferred: + return ""; + case server.ProjectKind.External: + var projectName = ts.normalizeSlashes(project.getProjectName()); + return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; + } + } + function createInstallTypingsRequest(project, typeAcquisition, unresolvedImports, cachePath) { + return { + projectName: project.getProjectName(), + fileNames: project.getFileNames(true), + compilerOptions: project.getCompilerOptions(), + typeAcquisition: typeAcquisition, + unresolvedImports: unresolvedImports, + projectRootPath: getProjectRootPath(project), + cachePath: cachePath, + kind: "discover" + }; + } + server.createInstallTypingsRequest = createInstallTypingsRequest; + var Errors; + (function (Errors) { + function ThrowNoProject() { + throw new Error("No Project."); + } + Errors.ThrowNoProject = ThrowNoProject; + function ThrowProjectLanguageServiceDisabled() { + throw new Error("The project's language service is disabled."); + } + Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; + function ThrowProjectDoesNotContainDocument(fileName, project) { + throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + } + Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; + })(Errors = server.Errors || (server.Errors = {})); + function getDefaultFormatCodeSettings(host) { + return { + indentSize: 4, + tabSize: 4, + newLineCharacter: host.newLine || "\n", + convertTabsToSpaces: true, + indentStyle: ts.IndentStyle.Smart, + insertSpaceAfterConstructor: false, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + insertSpaceBeforeFunctionParenthesis: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false, + }; + } + server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; + function mergeMaps(target, source) { + for (var key in source) { + if (ts.hasProperty(source, key)) { + target[key] = source[key]; + } + } + } + server.mergeMaps = mergeMaps; + function removeItemFromSet(items, itemToRemove) { + if (items.length === 0) { + return; + } + var index = items.indexOf(itemToRemove); + if (index < 0) { + return; + } + if (index === items.length - 1) { + items.pop(); + } + else { + items[index] = items.pop(); + } + } + server.removeItemFromSet = removeItemFromSet; + function toNormalizedPath(fileName) { + return ts.normalizePath(fileName); + } + server.toNormalizedPath = toNormalizedPath; + function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { + var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); + return getCanonicalFileName(f); + } + server.normalizedPathToPath = normalizedPathToPath; + function asNormalizedPath(fileName) { + return fileName; + } + server.asNormalizedPath = asNormalizedPath; + function createNormalizedPathMap() { + var map = Object.create(null); + return { + get: function (path) { + return map[path]; + }, + set: function (path, value) { + map[path] = value; + }, + contains: function (path) { + return ts.hasProperty(map, path); + }, + remove: function (path) { + delete map[path]; + } + }; + } + server.createNormalizedPathMap = createNormalizedPathMap; + function isInferredProjectName(name) { + return /dev\/null\/inferredProject\d+\*/.test(name); + } + server.isInferredProjectName = isInferredProjectName; + function makeInferredProjectName(counter) { + return "/dev/null/inferredProject" + counter + "*"; + } + server.makeInferredProjectName = makeInferredProjectName; + function toSortedReadonlyArray(arr) { + arr.sort(); + return arr; + } + server.toSortedReadonlyArray = toSortedReadonlyArray; + var ThrottledOperations = (function () { + function ThrottledOperations(host) { + this.host = host; + this.pendingTimeouts = ts.createMap(); + } + ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { + if (ts.hasProperty(this.pendingTimeouts, operationId)) { + this.host.clearTimeout(this.pendingTimeouts[operationId]); + } + this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); + }; + ThrottledOperations.run = function (self, operationId, cb) { + delete self.pendingTimeouts[operationId]; + cb(); + }; + return ThrottledOperations; + }()); + server.ThrottledOperations = ThrottledOperations; + var GcTimer = (function () { + function GcTimer(host, delay, logger) { + this.host = host; + this.delay = delay; + this.logger = logger; + } + GcTimer.prototype.scheduleCollect = function () { + if (!this.host.gc || this.timerId != undefined) { + return; + } + this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); + }; + GcTimer.run = function (self) { + self.timerId = undefined; + var log = self.logger.hasLevel(LogLevel.requestTime); + var before = log && self.host.getMemoryUsage(); + self.host.gc(); + if (log) { + var after = self.host.getMemoryUsage(); + self.logger.perftrc("GC::before " + before + ", after " + after); + } + }; + return GcTimer; + }()); + server.GcTimer = GcTimer; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var lineCollectionCapacity = 4; + var CharRangeSection; + (function (CharRangeSection) { + CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; + CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; + CharRangeSection[CharRangeSection["Entire"] = 2] = "Entire"; + CharRangeSection[CharRangeSection["Mid"] = 3] = "Mid"; + CharRangeSection[CharRangeSection["End"] = 4] = "End"; + CharRangeSection[CharRangeSection["PostEnd"] = 5] = "PostEnd"; + })(CharRangeSection = server.CharRangeSection || (server.CharRangeSection = {})); + var BaseLineIndexWalker = (function () { + function BaseLineIndexWalker() { + this.goSubtree = true; + this.done = false; + } + BaseLineIndexWalker.prototype.leaf = function (_rangeStart, _rangeLength, _ll) { + }; + return BaseLineIndexWalker; + }()); + var EditWalker = (function (_super) { + __extends(EditWalker, _super); + function EditWalker() { + var _this = _super.call(this) || this; + _this.lineIndex = new LineIndex(); + _this.endBranch = []; + _this.state = CharRangeSection.Entire; + _this.initialText = ""; + _this.trailingText = ""; + _this.suppressTrailingText = false; + _this.lineIndex.root = new LineNode(); + _this.startPath = [_this.lineIndex.root]; + _this.stack = [_this.lineIndex.root]; + return _this; + } + EditWalker.prototype.insertLines = function (insertedText) { + if (this.suppressTrailingText) { + this.trailingText = ""; + } + if (insertedText) { + insertedText = this.initialText + insertedText + this.trailingText; + } + else { + insertedText = this.initialText + this.trailingText; + } + var lm = LineIndex.linesFromText(insertedText); + var lines = lm.lines; + if (lines.length > 1) { + if (lines[lines.length - 1] == "") { + lines.length--; + } + } + var branchParent; + var lastZeroCount; + for (var k = this.endBranch.length - 1; k >= 0; k--) { + this.endBranch[k].updateCounts(); + if (this.endBranch[k].charCount() === 0) { + lastZeroCount = this.endBranch[k]; + if (k > 0) { + branchParent = this.endBranch[k - 1]; + } + else { + branchParent = this.branchNode; + } + } + } + if (lastZeroCount) { + branchParent.remove(lastZeroCount); + } + var insertionNode = this.startPath[this.startPath.length - 2]; + var leafNode = this.startPath[this.startPath.length - 1]; + var len = lines.length; + if (len > 0) { + leafNode.text = lines[0]; + if (len > 1) { + var insertedNodes = new Array(len - 1); + var startNode = leafNode; + for (var i = 1; i < lines.length; i++) { + insertedNodes[i - 1] = new LineLeaf(lines[i]); + } + var pathIndex = this.startPath.length - 2; + while (pathIndex >= 0) { + insertionNode = this.startPath[pathIndex]; + insertedNodes = insertionNode.insertAt(startNode, insertedNodes); + pathIndex--; + startNode = insertionNode; + } + var insertedNodesLen = insertedNodes.length; + while (insertedNodesLen > 0) { + var newRoot = new LineNode(); + newRoot.add(this.lineIndex.root); + insertedNodes = newRoot.insertAt(this.lineIndex.root, insertedNodes); + insertedNodesLen = insertedNodes.length; + this.lineIndex.root = newRoot; + } + this.lineIndex.root.updateCounts(); + } + else { + for (var j = this.startPath.length - 2; j >= 0; j--) { + this.startPath[j].updateCounts(); + } + } + } + else { + insertionNode.remove(leafNode); + for (var j = this.startPath.length - 2; j >= 0; j--) { + this.startPath[j].updateCounts(); + } + } + return this.lineIndex; + }; + EditWalker.prototype.post = function (_relativeStart, _relativeLength, lineCollection) { + if (lineCollection === this.lineCollectionAtBranch) { + this.state = CharRangeSection.End; + } + this.stack.length--; + return undefined; + }; + 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)) { + this.state = CharRangeSection.Start; + this.branchNode = currentNode; + this.lineCollectionAtBranch = lineCollection; + } + var child; + function fresh(node) { + if (node.isLeaf()) { + return new LineLeaf(""); + } + else + return new LineNode(); + } + switch (nodeType) { + case CharRangeSection.PreStart: + this.goSubtree = false; + if (this.state !== CharRangeSection.End) { + currentNode.add(lineCollection); + } + break; + case CharRangeSection.Start: + if (this.state === CharRangeSection.End) { + this.goSubtree = false; + } + else { + child = fresh(lineCollection); + currentNode.add(child); + this.startPath[this.startPath.length] = child; + } + break; + case CharRangeSection.Entire: + if (this.state !== CharRangeSection.End) { + child = fresh(lineCollection); + currentNode.add(child); + this.startPath[this.startPath.length] = child; + } + else { + if (!lineCollection.isLeaf()) { + child = fresh(lineCollection); + currentNode.add(child); + this.endBranch[this.endBranch.length] = child; + } + } + break; + case CharRangeSection.Mid: + this.goSubtree = false; + break; + case CharRangeSection.End: + if (this.state !== CharRangeSection.End) { + this.goSubtree = false; + } + else { + if (!lineCollection.isLeaf()) { + child = fresh(lineCollection); + currentNode.add(child); + this.endBranch[this.endBranch.length] = child; + } + } + break; + case CharRangeSection.PostEnd: + this.goSubtree = false; + if (this.state !== CharRangeSection.Start) { + currentNode.add(lineCollection); + } + break; + } + if (this.goSubtree) { + this.stack[this.stack.length] = child; + } + return lineCollection; + }; + EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { + if (this.state === CharRangeSection.Start) { + this.initialText = ll.text.substring(0, relativeStart); + } + else if (this.state === CharRangeSection.Entire) { + this.initialText = ll.text.substring(0, relativeStart); + this.trailingText = ll.text.substring(relativeStart + relativeLength); + } + else { + this.trailingText = ll.text.substring(relativeStart + relativeLength); + } + }; + return EditWalker; + }(BaseLineIndexWalker)); + var TextChange = (function () { + function TextChange(pos, deleteLen, insertedText) { + this.pos = pos; + this.deleteLen = deleteLen; + this.insertedText = insertedText; + } + TextChange.prototype.getTextChangeRange = function () { + return ts.createTextChangeRange(ts.createTextSpan(this.pos, this.deleteLen), this.insertedText ? this.insertedText.length : 0); + }; + return TextChange; + }()); + server.TextChange = TextChange; + var ScriptVersionCache = (function () { + function ScriptVersionCache() { + this.changes = []; + this.versions = new Array(ScriptVersionCache.maxVersions); + this.minVersion = 0; + this.currentVersion = 0; + } + ScriptVersionCache.prototype.versionToIndex = function (version) { + if (version < this.minVersion || version > this.currentVersion) { + return undefined; + } + return version % ScriptVersionCache.maxVersions; + }; + ScriptVersionCache.prototype.currentVersionToIndex = function () { + return this.currentVersion % ScriptVersionCache.maxVersions; + }; + ScriptVersionCache.prototype.edit = function (pos, deleteLen, insertedText) { + this.changes[this.changes.length] = new TextChange(pos, deleteLen, insertedText); + if ((this.changes.length > ScriptVersionCache.changeNumberThreshold) || + (deleteLen > ScriptVersionCache.changeLengthThreshold) || + (insertedText && (insertedText.length > ScriptVersionCache.changeLengthThreshold))) { + this.getSnapshot(); + } + }; + ScriptVersionCache.prototype.latest = function () { + return this.versions[this.currentVersionToIndex()]; + }; + ScriptVersionCache.prototype.latestVersion = function () { + if (this.changes.length > 0) { + this.getSnapshot(); + } + return this.currentVersion; + }; + ScriptVersionCache.prototype.reloadFromFile = function (filename) { + var content = this.host.readFile(filename); + if (!content) { + content = ""; + } + this.reload(content); + }; + ScriptVersionCache.prototype.reload = function (script) { + this.currentVersion++; + this.changes = []; + var snap = new LineIndexSnapshot(this.currentVersion, this); + for (var i = 0; i < this.versions.length; i++) { + this.versions[i] = undefined; + } + this.versions[this.currentVersionToIndex()] = snap; + snap.index = new LineIndex(); + var lm = LineIndex.linesFromText(script); + snap.index.load(lm.lines); + this.minVersion = this.currentVersion; + }; + ScriptVersionCache.prototype.getSnapshot = function () { + var snap = this.versions[this.currentVersionToIndex()]; + if (this.changes.length > 0) { + var snapIndex = snap.index; + for (var _i = 0, _a = this.changes; _i < _a.length; _i++) { + var change = _a[_i]; + snapIndex = snapIndex.edit(change.pos, change.deleteLen, change.insertedText); + } + snap = new LineIndexSnapshot(this.currentVersion + 1, this); + snap.index = snapIndex; + snap.changesSincePreviousVersion = this.changes; + this.currentVersion = snap.version; + this.versions[this.currentVersionToIndex()] = snap; + this.changes = []; + if ((this.currentVersion - this.minVersion) >= ScriptVersionCache.maxVersions) { + this.minVersion = (this.currentVersion - ScriptVersionCache.maxVersions) + 1; + } + } + return snap; + }; + ScriptVersionCache.prototype.getTextChangesBetweenVersions = function (oldVersion, newVersion) { + if (oldVersion < newVersion) { + if (oldVersion >= this.minVersion) { + var textChangeRanges = []; + for (var i = oldVersion + 1; i <= newVersion; i++) { + var snap = this.versions[this.versionToIndex(i)]; + for (var _i = 0, _a = snap.changesSincePreviousVersion; _i < _a.length; _i++) { + var textChange = _a[_i]; + textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); + } + } + return ts.collapseTextChangeRangesAcrossMultipleVersions(textChangeRanges); + } + else { + return undefined; + } + } + else { + return ts.unchangedTextChangeRange; + } + }; + 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); + return svc; + }; + return ScriptVersionCache; + }()); + ScriptVersionCache.changeNumberThreshold = 8; + ScriptVersionCache.changeLengthThreshold = 256; + ScriptVersionCache.maxVersions = 8; + server.ScriptVersionCache = ScriptVersionCache; + var LineIndexSnapshot = (function () { + function LineIndexSnapshot(version, cache) { + this.version = version; + this.cache = cache; + this.changesSincePreviousVersion = []; + } + LineIndexSnapshot.prototype.getText = function (rangeStart, rangeEnd) { + return this.index.getText(rangeStart, rangeEnd - rangeStart); + }; + LineIndexSnapshot.prototype.getLength = function () { + return this.index.root.charCount(); + }; + LineIndexSnapshot.prototype.getLineStartPositions = function () { + var starts = [-1]; + var count = 1; + var pos = 0; + this.index.every(function (ll) { + starts[count] = pos; + count++; + pos += ll.text.length; + return true; + }, 0); + return starts; + }; + LineIndexSnapshot.prototype.getLineMapper = function () { + var _this = this; + return function (line) { + return _this.index.lineNumberToInfo(line).offset; + }; + }; + LineIndexSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { + if (this.version <= scriptVersion) { + return ts.unchangedTextChangeRange; + } + else { + return this.cache.getTextChangesBetweenVersions(scriptVersion, this.version); + } + }; + LineIndexSnapshot.prototype.getChangeRange = function (oldSnapshot) { + if (oldSnapshot instanceof LineIndexSnapshot && this.cache === oldSnapshot.cache) { + return this.getTextChangeRangeSinceVersion(oldSnapshot.version); + } + }; + return LineIndexSnapshot; + }()); + server.LineIndexSnapshot = LineIndexSnapshot; + var LineIndex = (function () { + function LineIndex() { + this.checkEdits = false; + } + LineIndex.prototype.charOffsetToLineNumberAndPos = function (charOffset) { + return this.root.charOffsetToLineNumberAndPos(1, charOffset); + }; + LineIndex.prototype.lineNumberToInfo = function (lineNumber) { + var lineCount = this.root.lineCount(); + if (lineNumber <= lineCount) { + var lineInfo = this.root.lineNumberToInfo(lineNumber, 0); + lineInfo.line = lineNumber; + return lineInfo; + } + else { + return { + line: lineNumber, + offset: this.root.charCount() + }; + } + }; + LineIndex.prototype.load = function (lines) { + if (lines.length > 0) { + var leaves = []; + for (var i = 0; i < lines.length; i++) { + leaves[i] = new LineLeaf(lines[i]); + } + this.root = LineIndex.buildTreeFromBottom(leaves); + } + else { + this.root = new LineNode(); + } + }; + LineIndex.prototype.walk = function (rangeStart, rangeLength, walkFns) { + this.root.walk(rangeStart, rangeLength, walkFns); + }; + LineIndex.prototype.getText = function (rangeStart, rangeLength) { + var accum = ""; + if ((rangeLength > 0) && (rangeStart < this.root.charCount())) { + this.walk(rangeStart, rangeLength, { + goSubtree: true, + done: false, + leaf: function (relativeStart, relativeLength, ll) { + accum = accum.concat(ll.text.substring(relativeStart, relativeStart + relativeLength)); + } + }); + } + return accum; + }; + LineIndex.prototype.getLength = function () { + return this.root.charCount(); + }; + LineIndex.prototype.every = function (f, rangeStart, rangeEnd) { + if (!rangeEnd) { + rangeEnd = this.root.charCount(); + } + var walkFns = { + goSubtree: true, + done: false, + leaf: function (relativeStart, relativeLength, ll) { + if (!f(ll, relativeStart, relativeLength)) { + this.done = true; + } + } + }; + this.walk(rangeStart, rangeEnd - rangeStart, walkFns); + return !walkFns.done; + }; + LineIndex.prototype.edit = function (pos, deleteLength, newText) { + function editFlat(source, s, dl, nt) { + if (nt === void 0) { nt = ""; } + return source.substring(0, s) + nt + source.substring(s + dl, source.length); + } + if (this.root.charCount() === 0) { + if (newText !== undefined) { + this.load(LineIndex.linesFromText(newText).lines); + return this; + } + } + else { + var checkText = void 0; + if (this.checkEdits) { + checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText); + } + var walker = new EditWalker(); + if (pos >= this.root.charCount()) { + pos = this.root.charCount() - 1; + var endString = this.getText(pos, 1); + if (newText) { + newText = endString + newText; + } + else { + newText = endString; + } + deleteLength = 0; + walker.suppressTrailingText = true; + } + else if (deleteLength > 0) { + var e = pos + deleteLength; + var lineInfo = this.charOffsetToLineNumberAndPos(e); + if ((lineInfo && (lineInfo.offset === 0))) { + deleteLength += lineInfo.text.length; + if (newText) { + newText = newText + lineInfo.text; + } + else { + newText = lineInfo.text; + } + } + } + if (pos < this.root.charCount()) { + this.root.walk(pos, deleteLength, walker); + walker.insertLines(newText); + } + if (this.checkEdits) { + var updatedText = this.getText(0, this.root.charCount()); + ts.Debug.assert(checkText == updatedText, "buffer edit mismatch"); + } + return walker.lineIndex; + } + }; + LineIndex.buildTreeFromBottom = function (nodes) { + var nodeCount = Math.ceil(nodes.length / lineCollectionCapacity); + var interiorNodes = []; + var nodeIndex = 0; + for (var i = 0; i < nodeCount; i++) { + interiorNodes[i] = new LineNode(); + var charCount = 0; + var lineCount = 0; + for (var j = 0; j < lineCollectionCapacity; j++) { + if (nodeIndex < nodes.length) { + interiorNodes[i].add(nodes[nodeIndex]); + charCount += nodes[nodeIndex].charCount(); + lineCount += nodes[nodeIndex].lineCount(); + } + else { + break; + } + nodeIndex++; + } + interiorNodes[i].totalChars = charCount; + interiorNodes[i].totalLines = lineCount; + } + if (interiorNodes.length === 1) { + return interiorNodes[0]; + } + else { + return this.buildTreeFromBottom(interiorNodes); + } + }; + LineIndex.linesFromText = function (text) { + var lineStarts = ts.computeLineStarts(text); + if (lineStarts.length === 0) { + return { lines: [], lineMap: lineStarts }; + } + var lines = new Array(lineStarts.length); + var lc = lineStarts.length - 1; + for (var lmi = 0; lmi < lc; lmi++) { + lines[lmi] = text.substring(lineStarts[lmi], lineStarts[lmi + 1]); + } + var endText = text.substring(lineStarts[lc]); + if (endText.length > 0) { + lines[lc] = endText; + } + else { + lines.length--; + } + return { lines: lines, lineMap: lineStarts }; + }; + return LineIndex; + }()); + server.LineIndex = LineIndex; + var LineNode = (function () { + function LineNode() { + this.totalChars = 0; + this.totalLines = 0; + this.children = []; + } + LineNode.prototype.isLeaf = function () { + return false; + }; + LineNode.prototype.updateCounts = function () { + this.totalChars = 0; + this.totalLines = 0; + for (var _i = 0, _a = this.children; _i < _a.length; _i++) { + var child = _a[_i]; + this.totalChars += child.charCount(); + this.totalLines += child.lineCount(); + } + }; + LineNode.prototype.execWalk = function (rangeStart, rangeLength, walkFns, childIndex, nodeType) { + if (walkFns.pre) { + walkFns.pre(rangeStart, rangeLength, this.children[childIndex], this, nodeType); + } + if (walkFns.goSubtree) { + this.children[childIndex].walk(rangeStart, rangeLength, walkFns); + if (walkFns.post) { + walkFns.post(rangeStart, rangeLength, this.children[childIndex], this, nodeType); + } + } + else { + walkFns.goSubtree = true; + } + return walkFns.done; + }; + LineNode.prototype.skipChild = function (relativeStart, relativeLength, childIndex, walkFns, nodeType) { + if (walkFns.pre && (!walkFns.done)) { + walkFns.pre(relativeStart, relativeLength, this.children[childIndex], this, nodeType); + walkFns.goSubtree = true; + } + }; + LineNode.prototype.walk = function (rangeStart, rangeLength, walkFns) { + var childIndex = 0; + var child = this.children[0]; + var childCharCount = child.charCount(); + var adjustedStart = rangeStart; + while (adjustedStart >= childCharCount) { + this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, CharRangeSection.PreStart); + adjustedStart -= childCharCount; + childIndex++; + child = this.children[childIndex]; + childCharCount = child.charCount(); + } + if ((adjustedStart + rangeLength) <= childCharCount) { + if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, CharRangeSection.Entire)) { + return; + } + } + else { + if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, CharRangeSection.Start)) { + return; + } + var adjustedLength = rangeLength - (childCharCount - adjustedStart); + childIndex++; + child = this.children[childIndex]; + childCharCount = child.charCount(); + while (adjustedLength > childCharCount) { + if (this.execWalk(0, childCharCount, walkFns, childIndex, CharRangeSection.Mid)) { + return; + } + adjustedLength -= childCharCount; + childIndex++; + child = this.children[childIndex]; + childCharCount = child.charCount(); + } + if (adjustedLength > 0) { + if (this.execWalk(0, adjustedLength, walkFns, childIndex, CharRangeSection.End)) { + return; + } + } + } + if (walkFns.pre) { + var clen = this.children.length; + if (childIndex < (clen - 1)) { + for (var ej = childIndex + 1; ej < clen; ej++) { + this.skipChild(0, 0, ej, walkFns, CharRangeSection.PostEnd); + } + } + } + }; + LineNode.prototype.charOffsetToLineNumberAndPos = function (lineNumber, charOffset) { + var childInfo = this.childFromCharOffset(lineNumber, charOffset); + if (!childInfo.child) { + return { + line: lineNumber, + offset: charOffset, + }; + } + else if (childInfo.childIndex < this.children.length) { + if (childInfo.child.isLeaf()) { + return { + line: childInfo.lineNumber, + offset: childInfo.charOffset, + text: (childInfo.child).text, + leaf: (childInfo.child) + }; + } + else { + var lineNode = (childInfo.child); + return lineNode.charOffsetToLineNumberAndPos(childInfo.lineNumber, childInfo.charOffset); + } + } + else { + var lineInfo = this.lineNumberToInfo(this.lineCount(), 0); + return { line: this.lineCount(), offset: lineInfo.leaf.charCount() }; + } + }; + LineNode.prototype.lineNumberToInfo = function (lineNumber, charOffset) { + var childInfo = this.childFromLineNumber(lineNumber, charOffset); + if (!childInfo.child) { + return { + line: lineNumber, + offset: charOffset + }; + } + else if (childInfo.child.isLeaf()) { + return { + line: lineNumber, + offset: childInfo.charOffset, + text: (childInfo.child).text, + leaf: (childInfo.child) + }; + } + else { + var lineNode = (childInfo.child); + return lineNode.lineNumberToInfo(childInfo.relativeLineNumber, childInfo.charOffset); + } + }; + LineNode.prototype.childFromLineNumber = function (lineNumber, charOffset) { + var child; + var relativeLineNumber = lineNumber; + var i; + var len; + for (i = 0, len = this.children.length; i < len; i++) { + child = this.children[i]; + var childLineCount = child.lineCount(); + if (childLineCount >= relativeLineNumber) { + break; + } + else { + relativeLineNumber -= childLineCount; + charOffset += child.charCount(); + } + } + return { + child: child, + childIndex: i, + relativeLineNumber: relativeLineNumber, + charOffset: charOffset + }; + }; + LineNode.prototype.childFromCharOffset = function (lineNumber, charOffset) { + var child; + var i; + var len; + for (i = 0, len = this.children.length; i < len; i++) { + child = this.children[i]; + if (child.charCount() > charOffset) { + break; + } + else { + charOffset -= child.charCount(); + lineNumber += child.lineCount(); + } + } + return { + child: child, + childIndex: i, + charOffset: charOffset, + lineNumber: lineNumber + }; + }; + LineNode.prototype.splitAfter = function (childIndex) { + var splitNode; + var clen = this.children.length; + childIndex++; + var endLength = childIndex; + if (childIndex < clen) { + splitNode = new LineNode(); + while (childIndex < clen) { + splitNode.add(this.children[childIndex]); + childIndex++; + } + splitNode.updateCounts(); + } + this.children.length = endLength; + return splitNode; + }; + LineNode.prototype.remove = function (child) { + var childIndex = this.findChildIndex(child); + var clen = this.children.length; + if (childIndex < (clen - 1)) { + for (var i = childIndex; i < (clen - 1); i++) { + this.children[i] = this.children[i + 1]; + } + } + this.children.length--; + }; + LineNode.prototype.findChildIndex = function (child) { + var childIndex = 0; + var clen = this.children.length; + while ((this.children[childIndex] !== child) && (childIndex < clen)) + childIndex++; + return childIndex; + }; + LineNode.prototype.insertAt = function (child, nodes) { + var childIndex = this.findChildIndex(child); + var clen = this.children.length; + var nodeCount = nodes.length; + if ((clen < lineCollectionCapacity) && (childIndex === (clen - 1)) && (nodeCount === 1)) { + this.add(nodes[0]); + this.updateCounts(); + return []; + } + else { + var shiftNode = this.splitAfter(childIndex); + var nodeIndex = 0; + childIndex++; + while ((childIndex < lineCollectionCapacity) && (nodeIndex < nodeCount)) { + this.children[childIndex] = nodes[nodeIndex]; + childIndex++; + nodeIndex++; + } + var splitNodes = []; + var splitNodeCount = 0; + if (nodeIndex < nodeCount) { + splitNodeCount = Math.ceil((nodeCount - nodeIndex) / lineCollectionCapacity); + splitNodes = new Array(splitNodeCount); + var splitNodeIndex = 0; + for (var i = 0; i < splitNodeCount; i++) { + splitNodes[i] = new LineNode(); + } + var splitNode = splitNodes[0]; + while (nodeIndex < nodeCount) { + splitNode.add(nodes[nodeIndex]); + nodeIndex++; + if (splitNode.children.length === lineCollectionCapacity) { + splitNodeIndex++; + splitNode = splitNodes[splitNodeIndex]; + } + } + for (var i = splitNodes.length - 1; i >= 0; i--) { + if (splitNodes[i].children.length === 0) { + splitNodes.length--; + } + } + } + if (shiftNode) { + splitNodes[splitNodes.length] = shiftNode; + } + this.updateCounts(); + for (var i = 0; i < splitNodeCount; i++) { + splitNodes[i].updateCounts(); + } + return splitNodes; + } + }; + LineNode.prototype.add = function (collection) { + this.children[this.children.length] = collection; + return (this.children.length < lineCollectionCapacity); + }; + LineNode.prototype.charCount = function () { + return this.totalChars; + }; + LineNode.prototype.lineCount = function () { + return this.totalLines; + }; + return LineNode; + }()); + server.LineNode = LineNode; + var LineLeaf = (function () { + function LineLeaf(text) { + this.text = text; + } + LineLeaf.prototype.isLeaf = function () { + return true; + }; + LineLeaf.prototype.walk = function (rangeStart, rangeLength, walkFns) { + walkFns.leaf(rangeStart, rangeLength, this); + }; + LineLeaf.prototype.charCount = function () { + return this.text.length; + }; + LineLeaf.prototype.lineCount = function () { + return 1; + }; + return LineLeaf; + }()); + server.LineLeaf = LineLeaf; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var server; (function (server) { @@ -65075,15 +66886,15 @@ var ts; var compilerOptions = this.getCompilationSettings(); var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_50 = names_2[_i]; - var resolution = newResolutions[name_50]; + var name_51 = names_2[_i]; + var resolution = newResolutions[name_51]; if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_50]; + var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_51]; if (moduleResolutionIsValid(existingResolution)) { resolution = existingResolution; } else { - newResolutions[name_50] = resolution = loader(name_50, containingFile, compilerOptions, this); + newResolutions[name_51] = resolution = loader(name_51, containingFile, compilerOptions, this); } if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { this.filesWithChangedSetOfUnresolvedImports.push(path); @@ -65123,6 +66934,9 @@ var ts; return resolution.failedLookupLocations.length === 0; } }; + LSHost.prototype.getNewLine = function () { + return this.host.newLine; + }; LSHost.prototype.getProjectVersion = function () { return this.project.getProjectVersion(); }; @@ -65328,7 +67142,7 @@ var ts; BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - if (statement.kind !== 230 || statement.name.kind !== 9) { + if (statement.kind !== 231 || statement.name.kind !== 9) { return false; } } @@ -65439,7 +67253,7 @@ var ts; var ModuleBuilderFileInfo = (function (_super) { __extends(ModuleBuilderFileInfo, _super); function ModuleBuilderFileInfo() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.references = []; _this.referencedBy = []; return _this; @@ -65802,7 +67616,7 @@ var ts; info.detachFromProject(this); } } - else { + if (!this.program || !this.languageServiceEnabled) { for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { var root = _c[_b]; root.detachFromProject(this); @@ -65948,9 +67762,9 @@ var ts; } var unresolvedImports; if (file.resolvedModules) { - for (var name_51 in file.resolvedModules) { - if (!file.resolvedModules[name_51] && !ts.isExternalModuleNameRelative(name_51)) { - var trimmed = name_51.trim(); + for (var name_52 in file.resolvedModules) { + if (!file.resolvedModules[name_52] && !ts.isExternalModuleNameRelative(name_52)) { + var trimmed = name_52.trim(); var i = trimmed.indexOf("/"); if (i !== -1 && trimmed.charCodeAt(0) === 64) { i = trimmed.indexOf("/", i + 1); @@ -68539,9 +70353,9 @@ var ts; if (simplifiedResult) { return completions.entries.reduce(function (result, entry) { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name_52 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; + var name_53 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; - result.push({ name: name_52, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); + result.push({ name: name_53, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); } return result; }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); @@ -68943,853 +70757,6 @@ var ts; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var server; - (function (server) { - var lineCollectionCapacity = 4; - var CharRangeSection; - (function (CharRangeSection) { - CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; - CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; - CharRangeSection[CharRangeSection["Entire"] = 2] = "Entire"; - CharRangeSection[CharRangeSection["Mid"] = 3] = "Mid"; - CharRangeSection[CharRangeSection["End"] = 4] = "End"; - CharRangeSection[CharRangeSection["PostEnd"] = 5] = "PostEnd"; - })(CharRangeSection = server.CharRangeSection || (server.CharRangeSection = {})); - var BaseLineIndexWalker = (function () { - function BaseLineIndexWalker() { - this.goSubtree = true; - this.done = false; - } - BaseLineIndexWalker.prototype.leaf = function (_rangeStart, _rangeLength, _ll) { - }; - return BaseLineIndexWalker; - }()); - var EditWalker = (function (_super) { - __extends(EditWalker, _super); - function EditWalker() { - var _this = _super.call(this) || this; - _this.lineIndex = new LineIndex(); - _this.endBranch = []; - _this.state = CharRangeSection.Entire; - _this.initialText = ""; - _this.trailingText = ""; - _this.suppressTrailingText = false; - _this.lineIndex.root = new LineNode(); - _this.startPath = [_this.lineIndex.root]; - _this.stack = [_this.lineIndex.root]; - return _this; - } - EditWalker.prototype.insertLines = function (insertedText) { - if (this.suppressTrailingText) { - this.trailingText = ""; - } - if (insertedText) { - insertedText = this.initialText + insertedText + this.trailingText; - } - else { - insertedText = this.initialText + this.trailingText; - } - var lm = LineIndex.linesFromText(insertedText); - var lines = lm.lines; - if (lines.length > 1) { - if (lines[lines.length - 1] == "") { - lines.length--; - } - } - var branchParent; - var lastZeroCount; - for (var k = this.endBranch.length - 1; k >= 0; k--) { - this.endBranch[k].updateCounts(); - if (this.endBranch[k].charCount() === 0) { - lastZeroCount = this.endBranch[k]; - if (k > 0) { - branchParent = this.endBranch[k - 1]; - } - else { - branchParent = this.branchNode; - } - } - } - if (lastZeroCount) { - branchParent.remove(lastZeroCount); - } - var insertionNode = this.startPath[this.startPath.length - 2]; - var leafNode = this.startPath[this.startPath.length - 1]; - var len = lines.length; - if (len > 0) { - leafNode.text = lines[0]; - if (len > 1) { - var insertedNodes = new Array(len - 1); - var startNode = leafNode; - for (var i = 1, len_1 = lines.length; i < len_1; i++) { - insertedNodes[i - 1] = new LineLeaf(lines[i]); - } - var pathIndex = this.startPath.length - 2; - while (pathIndex >= 0) { - insertionNode = this.startPath[pathIndex]; - insertedNodes = insertionNode.insertAt(startNode, insertedNodes); - pathIndex--; - startNode = insertionNode; - } - var insertedNodesLen = insertedNodes.length; - while (insertedNodesLen > 0) { - var newRoot = new LineNode(); - newRoot.add(this.lineIndex.root); - insertedNodes = newRoot.insertAt(this.lineIndex.root, insertedNodes); - insertedNodesLen = insertedNodes.length; - this.lineIndex.root = newRoot; - } - this.lineIndex.root.updateCounts(); - } - else { - for (var j = this.startPath.length - 2; j >= 0; j--) { - this.startPath[j].updateCounts(); - } - } - } - else { - insertionNode.remove(leafNode); - for (var j = this.startPath.length - 2; j >= 0; j--) { - this.startPath[j].updateCounts(); - } - } - return this.lineIndex; - }; - EditWalker.prototype.post = function (_relativeStart, _relativeLength, lineCollection) { - if (lineCollection === this.lineCollectionAtBranch) { - this.state = CharRangeSection.End; - } - this.stack.length--; - return undefined; - }; - 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)) { - this.state = CharRangeSection.Start; - this.branchNode = currentNode; - this.lineCollectionAtBranch = lineCollection; - } - var child; - function fresh(node) { - if (node.isLeaf()) { - return new LineLeaf(""); - } - else - return new LineNode(); - } - switch (nodeType) { - case CharRangeSection.PreStart: - this.goSubtree = false; - if (this.state !== CharRangeSection.End) { - currentNode.add(lineCollection); - } - break; - case CharRangeSection.Start: - if (this.state === CharRangeSection.End) { - this.goSubtree = false; - } - else { - child = fresh(lineCollection); - currentNode.add(child); - this.startPath[this.startPath.length] = child; - } - break; - case CharRangeSection.Entire: - if (this.state !== CharRangeSection.End) { - child = fresh(lineCollection); - currentNode.add(child); - this.startPath[this.startPath.length] = child; - } - else { - if (!lineCollection.isLeaf()) { - child = fresh(lineCollection); - currentNode.add(child); - this.endBranch[this.endBranch.length] = child; - } - } - break; - case CharRangeSection.Mid: - this.goSubtree = false; - break; - case CharRangeSection.End: - if (this.state !== CharRangeSection.End) { - this.goSubtree = false; - } - else { - if (!lineCollection.isLeaf()) { - child = fresh(lineCollection); - currentNode.add(child); - this.endBranch[this.endBranch.length] = child; - } - } - break; - case CharRangeSection.PostEnd: - this.goSubtree = false; - if (this.state !== CharRangeSection.Start) { - currentNode.add(lineCollection); - } - break; - } - if (this.goSubtree) { - this.stack[this.stack.length] = child; - } - return lineCollection; - }; - EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { - if (this.state === CharRangeSection.Start) { - this.initialText = ll.text.substring(0, relativeStart); - } - else if (this.state === CharRangeSection.Entire) { - this.initialText = ll.text.substring(0, relativeStart); - this.trailingText = ll.text.substring(relativeStart + relativeLength); - } - else { - this.trailingText = ll.text.substring(relativeStart + relativeLength); - } - }; - return EditWalker; - }(BaseLineIndexWalker)); - var TextChange = (function () { - function TextChange(pos, deleteLen, insertedText) { - this.pos = pos; - this.deleteLen = deleteLen; - this.insertedText = insertedText; - } - TextChange.prototype.getTextChangeRange = function () { - return ts.createTextChangeRange(ts.createTextSpan(this.pos, this.deleteLen), this.insertedText ? this.insertedText.length : 0); - }; - return TextChange; - }()); - server.TextChange = TextChange; - var ScriptVersionCache = (function () { - function ScriptVersionCache() { - this.changes = []; - this.versions = new Array(ScriptVersionCache.maxVersions); - this.minVersion = 0; - this.currentVersion = 0; - } - ScriptVersionCache.prototype.versionToIndex = function (version) { - if (version < this.minVersion || version > this.currentVersion) { - return undefined; - } - return version % ScriptVersionCache.maxVersions; - }; - ScriptVersionCache.prototype.currentVersionToIndex = function () { - return this.currentVersion % ScriptVersionCache.maxVersions; - }; - ScriptVersionCache.prototype.edit = function (pos, deleteLen, insertedText) { - this.changes[this.changes.length] = new TextChange(pos, deleteLen, insertedText); - if ((this.changes.length > ScriptVersionCache.changeNumberThreshold) || - (deleteLen > ScriptVersionCache.changeLengthThreshold) || - (insertedText && (insertedText.length > ScriptVersionCache.changeLengthThreshold))) { - this.getSnapshot(); - } - }; - ScriptVersionCache.prototype.latest = function () { - return this.versions[this.currentVersionToIndex()]; - }; - ScriptVersionCache.prototype.latestVersion = function () { - if (this.changes.length > 0) { - this.getSnapshot(); - } - return this.currentVersion; - }; - ScriptVersionCache.prototype.reloadFromFile = function (filename) { - var content = this.host.readFile(filename); - if (!content) { - content = ""; - } - this.reload(content); - }; - ScriptVersionCache.prototype.reload = function (script) { - this.currentVersion++; - this.changes = []; - var snap = new LineIndexSnapshot(this.currentVersion, this); - for (var i = 0; i < this.versions.length; i++) { - this.versions[i] = undefined; - } - this.versions[this.currentVersionToIndex()] = snap; - snap.index = new LineIndex(); - var lm = LineIndex.linesFromText(script); - snap.index.load(lm.lines); - this.minVersion = this.currentVersion; - }; - ScriptVersionCache.prototype.getSnapshot = function () { - var snap = this.versions[this.currentVersionToIndex()]; - if (this.changes.length > 0) { - var snapIndex = snap.index; - for (var i = 0, len = this.changes.length; i < len; i++) { - var change = this.changes[i]; - snapIndex = snapIndex.edit(change.pos, change.deleteLen, change.insertedText); - } - snap = new LineIndexSnapshot(this.currentVersion + 1, this); - snap.index = snapIndex; - snap.changesSincePreviousVersion = this.changes; - this.currentVersion = snap.version; - this.versions[this.currentVersionToIndex()] = snap; - this.changes = []; - if ((this.currentVersion - this.minVersion) >= ScriptVersionCache.maxVersions) { - this.minVersion = (this.currentVersion - ScriptVersionCache.maxVersions) + 1; - } - } - return snap; - }; - ScriptVersionCache.prototype.getTextChangesBetweenVersions = function (oldVersion, newVersion) { - if (oldVersion < newVersion) { - if (oldVersion >= this.minVersion) { - var textChangeRanges = []; - for (var i = oldVersion + 1; i <= newVersion; i++) { - var snap = this.versions[this.versionToIndex(i)]; - for (var j = 0, len = snap.changesSincePreviousVersion.length; j < len; j++) { - var textChange = snap.changesSincePreviousVersion[j]; - textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); - } - } - return ts.collapseTextChangeRangesAcrossMultipleVersions(textChangeRanges); - } - else { - return undefined; - } - } - else { - return ts.unchangedTextChangeRange; - } - }; - 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); - return svc; - }; - return ScriptVersionCache; - }()); - ScriptVersionCache.changeNumberThreshold = 8; - ScriptVersionCache.changeLengthThreshold = 256; - ScriptVersionCache.maxVersions = 8; - server.ScriptVersionCache = ScriptVersionCache; - var LineIndexSnapshot = (function () { - function LineIndexSnapshot(version, cache) { - this.version = version; - this.cache = cache; - this.changesSincePreviousVersion = []; - } - LineIndexSnapshot.prototype.getText = function (rangeStart, rangeEnd) { - return this.index.getText(rangeStart, rangeEnd - rangeStart); - }; - LineIndexSnapshot.prototype.getLength = function () { - return this.index.root.charCount(); - }; - LineIndexSnapshot.prototype.getLineStartPositions = function () { - var starts = [-1]; - var count = 1; - var pos = 0; - this.index.every(function (ll) { - starts[count] = pos; - count++; - pos += ll.text.length; - return true; - }, 0); - return starts; - }; - LineIndexSnapshot.prototype.getLineMapper = function () { - var _this = this; - return function (line) { - return _this.index.lineNumberToInfo(line).offset; - }; - }; - LineIndexSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { - if (this.version <= scriptVersion) { - return ts.unchangedTextChangeRange; - } - else { - return this.cache.getTextChangesBetweenVersions(scriptVersion, this.version); - } - }; - LineIndexSnapshot.prototype.getChangeRange = function (oldSnapshot) { - if (oldSnapshot instanceof LineIndexSnapshot && this.cache === oldSnapshot.cache) { - return this.getTextChangeRangeSinceVersion(oldSnapshot.version); - } - }; - return LineIndexSnapshot; - }()); - server.LineIndexSnapshot = LineIndexSnapshot; - var LineIndex = (function () { - function LineIndex() { - this.checkEdits = false; - } - LineIndex.prototype.charOffsetToLineNumberAndPos = function (charOffset) { - return this.root.charOffsetToLineNumberAndPos(1, charOffset); - }; - LineIndex.prototype.lineNumberToInfo = function (lineNumber) { - var lineCount = this.root.lineCount(); - if (lineNumber <= lineCount) { - var lineInfo = this.root.lineNumberToInfo(lineNumber, 0); - lineInfo.line = lineNumber; - return lineInfo; - } - else { - return { - line: lineNumber, - offset: this.root.charCount() - }; - } - }; - LineIndex.prototype.load = function (lines) { - if (lines.length > 0) { - var leaves = []; - for (var i = 0, len = lines.length; i < len; i++) { - leaves[i] = new LineLeaf(lines[i]); - } - this.root = LineIndex.buildTreeFromBottom(leaves); - } - else { - this.root = new LineNode(); - } - }; - LineIndex.prototype.walk = function (rangeStart, rangeLength, walkFns) { - this.root.walk(rangeStart, rangeLength, walkFns); - }; - LineIndex.prototype.getText = function (rangeStart, rangeLength) { - var accum = ""; - if ((rangeLength > 0) && (rangeStart < this.root.charCount())) { - this.walk(rangeStart, rangeLength, { - goSubtree: true, - done: false, - leaf: function (relativeStart, relativeLength, ll) { - accum = accum.concat(ll.text.substring(relativeStart, relativeStart + relativeLength)); - } - }); - } - return accum; - }; - LineIndex.prototype.getLength = function () { - return this.root.charCount(); - }; - LineIndex.prototype.every = function (f, rangeStart, rangeEnd) { - if (!rangeEnd) { - rangeEnd = this.root.charCount(); - } - var walkFns = { - goSubtree: true, - done: false, - leaf: function (relativeStart, relativeLength, ll) { - if (!f(ll, relativeStart, relativeLength)) { - this.done = true; - } - } - }; - this.walk(rangeStart, rangeEnd - rangeStart, walkFns); - return !walkFns.done; - }; - LineIndex.prototype.edit = function (pos, deleteLength, newText) { - function editFlat(source, s, dl, nt) { - if (nt === void 0) { nt = ""; } - return source.substring(0, s) + nt + source.substring(s + dl, source.length); - } - if (this.root.charCount() === 0) { - if (newText !== undefined) { - this.load(LineIndex.linesFromText(newText).lines); - return this; - } - } - else { - var checkText = void 0; - if (this.checkEdits) { - checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText); - } - var walker = new EditWalker(); - if (pos >= this.root.charCount()) { - pos = this.root.charCount() - 1; - var endString = this.getText(pos, 1); - if (newText) { - newText = endString + newText; - } - else { - newText = endString; - } - deleteLength = 0; - walker.suppressTrailingText = true; - } - else if (deleteLength > 0) { - var e = pos + deleteLength; - var lineInfo = this.charOffsetToLineNumberAndPos(e); - if ((lineInfo && (lineInfo.offset === 0))) { - deleteLength += lineInfo.text.length; - if (newText) { - newText = newText + lineInfo.text; - } - else { - newText = lineInfo.text; - } - } - } - if (pos < this.root.charCount()) { - this.root.walk(pos, deleteLength, walker); - walker.insertLines(newText); - } - if (this.checkEdits) { - var updatedText = this.getText(0, this.root.charCount()); - ts.Debug.assert(checkText == updatedText, "buffer edit mismatch"); - } - return walker.lineIndex; - } - }; - LineIndex.buildTreeFromBottom = function (nodes) { - var nodeCount = Math.ceil(nodes.length / lineCollectionCapacity); - var interiorNodes = []; - var nodeIndex = 0; - for (var i = 0; i < nodeCount; i++) { - interiorNodes[i] = new LineNode(); - var charCount = 0; - var lineCount = 0; - for (var j = 0; j < lineCollectionCapacity; j++) { - if (nodeIndex < nodes.length) { - interiorNodes[i].add(nodes[nodeIndex]); - charCount += nodes[nodeIndex].charCount(); - lineCount += nodes[nodeIndex].lineCount(); - } - else { - break; - } - nodeIndex++; - } - interiorNodes[i].totalChars = charCount; - interiorNodes[i].totalLines = lineCount; - } - if (interiorNodes.length === 1) { - return interiorNodes[0]; - } - else { - return this.buildTreeFromBottom(interiorNodes); - } - }; - LineIndex.linesFromText = function (text) { - var lineStarts = ts.computeLineStarts(text); - if (lineStarts.length === 0) { - return { lines: [], lineMap: lineStarts }; - } - var lines = new Array(lineStarts.length); - var lc = lineStarts.length - 1; - for (var lmi = 0; lmi < lc; lmi++) { - lines[lmi] = text.substring(lineStarts[lmi], lineStarts[lmi + 1]); - } - var endText = text.substring(lineStarts[lc]); - if (endText.length > 0) { - lines[lc] = endText; - } - else { - lines.length--; - } - return { lines: lines, lineMap: lineStarts }; - }; - return LineIndex; - }()); - server.LineIndex = LineIndex; - var LineNode = (function () { - function LineNode() { - this.totalChars = 0; - this.totalLines = 0; - this.children = []; - } - LineNode.prototype.isLeaf = function () { - return false; - }; - LineNode.prototype.updateCounts = function () { - this.totalChars = 0; - this.totalLines = 0; - for (var i = 0, len = this.children.length; i < len; i++) { - var child = this.children[i]; - this.totalChars += child.charCount(); - this.totalLines += child.lineCount(); - } - }; - LineNode.prototype.execWalk = function (rangeStart, rangeLength, walkFns, childIndex, nodeType) { - if (walkFns.pre) { - walkFns.pre(rangeStart, rangeLength, this.children[childIndex], this, nodeType); - } - if (walkFns.goSubtree) { - this.children[childIndex].walk(rangeStart, rangeLength, walkFns); - if (walkFns.post) { - walkFns.post(rangeStart, rangeLength, this.children[childIndex], this, nodeType); - } - } - else { - walkFns.goSubtree = true; - } - return walkFns.done; - }; - LineNode.prototype.skipChild = function (relativeStart, relativeLength, childIndex, walkFns, nodeType) { - if (walkFns.pre && (!walkFns.done)) { - walkFns.pre(relativeStart, relativeLength, this.children[childIndex], this, nodeType); - walkFns.goSubtree = true; - } - }; - LineNode.prototype.walk = function (rangeStart, rangeLength, walkFns) { - var childIndex = 0; - var child = this.children[0]; - var childCharCount = child.charCount(); - var adjustedStart = rangeStart; - while (adjustedStart >= childCharCount) { - this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, CharRangeSection.PreStart); - adjustedStart -= childCharCount; - childIndex++; - child = this.children[childIndex]; - childCharCount = child.charCount(); - } - if ((adjustedStart + rangeLength) <= childCharCount) { - if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, CharRangeSection.Entire)) { - return; - } - } - else { - if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, CharRangeSection.Start)) { - return; - } - var adjustedLength = rangeLength - (childCharCount - adjustedStart); - childIndex++; - child = this.children[childIndex]; - childCharCount = child.charCount(); - while (adjustedLength > childCharCount) { - if (this.execWalk(0, childCharCount, walkFns, childIndex, CharRangeSection.Mid)) { - return; - } - adjustedLength -= childCharCount; - childIndex++; - child = this.children[childIndex]; - childCharCount = child.charCount(); - } - if (adjustedLength > 0) { - if (this.execWalk(0, adjustedLength, walkFns, childIndex, CharRangeSection.End)) { - return; - } - } - } - if (walkFns.pre) { - var clen = this.children.length; - if (childIndex < (clen - 1)) { - for (var ej = childIndex + 1; ej < clen; ej++) { - this.skipChild(0, 0, ej, walkFns, CharRangeSection.PostEnd); - } - } - } - }; - LineNode.prototype.charOffsetToLineNumberAndPos = function (lineNumber, charOffset) { - var childInfo = this.childFromCharOffset(lineNumber, charOffset); - if (!childInfo.child) { - return { - line: lineNumber, - offset: charOffset, - }; - } - else if (childInfo.childIndex < this.children.length) { - if (childInfo.child.isLeaf()) { - return { - line: childInfo.lineNumber, - offset: childInfo.charOffset, - text: (childInfo.child).text, - leaf: (childInfo.child) - }; - } - else { - var lineNode = (childInfo.child); - return lineNode.charOffsetToLineNumberAndPos(childInfo.lineNumber, childInfo.charOffset); - } - } - else { - var lineInfo = this.lineNumberToInfo(this.lineCount(), 0); - return { line: this.lineCount(), offset: lineInfo.leaf.charCount() }; - } - }; - LineNode.prototype.lineNumberToInfo = function (lineNumber, charOffset) { - var childInfo = this.childFromLineNumber(lineNumber, charOffset); - if (!childInfo.child) { - return { - line: lineNumber, - offset: charOffset - }; - } - else if (childInfo.child.isLeaf()) { - return { - line: lineNumber, - offset: childInfo.charOffset, - text: (childInfo.child).text, - leaf: (childInfo.child) - }; - } - else { - var lineNode = (childInfo.child); - return lineNode.lineNumberToInfo(childInfo.relativeLineNumber, childInfo.charOffset); - } - }; - LineNode.prototype.childFromLineNumber = function (lineNumber, charOffset) { - var child; - var relativeLineNumber = lineNumber; - var i; - var len; - for (i = 0, len = this.children.length; i < len; i++) { - child = this.children[i]; - var childLineCount = child.lineCount(); - if (childLineCount >= relativeLineNumber) { - break; - } - else { - relativeLineNumber -= childLineCount; - charOffset += child.charCount(); - } - } - return { - child: child, - childIndex: i, - relativeLineNumber: relativeLineNumber, - charOffset: charOffset - }; - }; - LineNode.prototype.childFromCharOffset = function (lineNumber, charOffset) { - var child; - var i; - var len; - for (i = 0, len = this.children.length; i < len; i++) { - child = this.children[i]; - if (child.charCount() > charOffset) { - break; - } - else { - charOffset -= child.charCount(); - lineNumber += child.lineCount(); - } - } - return { - child: child, - childIndex: i, - charOffset: charOffset, - lineNumber: lineNumber - }; - }; - LineNode.prototype.splitAfter = function (childIndex) { - var splitNode; - var clen = this.children.length; - childIndex++; - var endLength = childIndex; - if (childIndex < clen) { - splitNode = new LineNode(); - while (childIndex < clen) { - splitNode.add(this.children[childIndex]); - childIndex++; - } - splitNode.updateCounts(); - } - this.children.length = endLength; - return splitNode; - }; - LineNode.prototype.remove = function (child) { - var childIndex = this.findChildIndex(child); - var clen = this.children.length; - if (childIndex < (clen - 1)) { - for (var i = childIndex; i < (clen - 1); i++) { - this.children[i] = this.children[i + 1]; - } - } - this.children.length--; - }; - LineNode.prototype.findChildIndex = function (child) { - var childIndex = 0; - var clen = this.children.length; - while ((this.children[childIndex] !== child) && (childIndex < clen)) - childIndex++; - return childIndex; - }; - LineNode.prototype.insertAt = function (child, nodes) { - var childIndex = this.findChildIndex(child); - var clen = this.children.length; - var nodeCount = nodes.length; - if ((clen < lineCollectionCapacity) && (childIndex === (clen - 1)) && (nodeCount === 1)) { - this.add(nodes[0]); - this.updateCounts(); - return []; - } - else { - var shiftNode = this.splitAfter(childIndex); - var nodeIndex = 0; - childIndex++; - while ((childIndex < lineCollectionCapacity) && (nodeIndex < nodeCount)) { - this.children[childIndex] = nodes[nodeIndex]; - childIndex++; - nodeIndex++; - } - var splitNodes = []; - var splitNodeCount = 0; - if (nodeIndex < nodeCount) { - splitNodeCount = Math.ceil((nodeCount - nodeIndex) / lineCollectionCapacity); - splitNodes = new Array(splitNodeCount); - var splitNodeIndex = 0; - for (var i = 0; i < splitNodeCount; i++) { - splitNodes[i] = new LineNode(); - } - var splitNode = splitNodes[0]; - while (nodeIndex < nodeCount) { - splitNode.add(nodes[nodeIndex]); - nodeIndex++; - if (splitNode.children.length === lineCollectionCapacity) { - splitNodeIndex++; - splitNode = splitNodes[splitNodeIndex]; - } - } - for (var i = splitNodes.length - 1; i >= 0; i--) { - if (splitNodes[i].children.length === 0) { - splitNodes.length--; - } - } - } - if (shiftNode) { - splitNodes[splitNodes.length] = shiftNode; - } - this.updateCounts(); - for (var i = 0; i < splitNodeCount; i++) { - splitNodes[i].updateCounts(); - } - return splitNodes; - } - }; - LineNode.prototype.add = function (collection) { - this.children[this.children.length] = collection; - return (this.children.length < lineCollectionCapacity); - }; - LineNode.prototype.charCount = function () { - return this.totalChars; - }; - LineNode.prototype.lineCount = function () { - return this.totalLines; - }; - return LineNode; - }()); - server.LineNode = LineNode; - var LineLeaf = (function () { - function LineLeaf(text) { - this.text = text; - } - LineLeaf.prototype.isLeaf = function () { - return true; - }; - LineLeaf.prototype.walk = function (rangeStart, rangeLength, walkFns) { - walkFns.leaf(rangeStart, rangeLength, this); - }; - LineLeaf.prototype.charCount = function () { - return this.text.length; - }; - LineLeaf.prototype.lineCount = function () { - return 1; - }; - return LineLeaf; - }()); - server.LineLeaf = LineLeaf; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; (function (ts) { var server; (function (server) { @@ -70044,7 +71011,7 @@ var ts; var IOSession = (function (_super) { __extends(IOSession, _super); function IOSession(host, cancellationToken, installerEventPort, canUseEvents, useSingleInferredProject, disableAutomaticTypingAcquisition, globalTypingsCacheLocation, telemetryEnabled, logger) { - var _this; + var _this = this; var typingsInstaller = disableAutomaticTypingAcquisition ? undefined : new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, host.newLine); @@ -70074,7 +71041,8 @@ var ts; function parseLoggingEnvironmentString(logEnvStr) { var logEnv = { logToFile: true }; var args = logEnvStr.split(" "); - for (var i = 0, len = args.length; i < (len - 1); i += 2) { + var len = args.length - 1; + for (var i = 0; i < len; i += 2) { var option = args[i]; var value = args[i + 1]; if (option && value) { @@ -70928,7 +71896,7 @@ var ts; this._shims.push(shim); }; TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { + for (var i = 0; i < this._shims.length; i++) { if (this._shims[i] === shim) { delete this._shims[i]; return; diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index e01f4393032..232684eedc6 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -1,873 +1,18 @@ -/// -declare namespace ts.server.protocol { - namespace CommandTypes { - type Brace = "brace"; - type BraceFull = "brace-full"; - type BraceCompletion = "braceCompletion"; - type Change = "change"; - type Close = "close"; - type Completions = "completions"; - type CompletionsFull = "completions-full"; - type CompletionDetails = "completionEntryDetails"; - type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; - type CompileOnSaveEmitFile = "compileOnSaveEmitFile"; - type Configure = "configure"; - type Definition = "definition"; - type DefinitionFull = "definition-full"; - type Implementation = "implementation"; - type ImplementationFull = "implementation-full"; - type Exit = "exit"; - type Format = "format"; - type Formatonkey = "formatonkey"; - type FormatFull = "format-full"; - type FormatonkeyFull = "formatonkey-full"; - type FormatRangeFull = "formatRange-full"; - type Geterr = "geterr"; - type GeterrForProject = "geterrForProject"; - type SemanticDiagnosticsSync = "semanticDiagnosticsSync"; - type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; - type NavBar = "navbar"; - type NavBarFull = "navbar-full"; - type Navto = "navto"; - type NavtoFull = "navto-full"; - type NavTree = "navtree"; - type NavTreeFull = "navtree-full"; - type Occurrences = "occurrences"; - type DocumentHighlights = "documentHighlights"; - type DocumentHighlightsFull = "documentHighlights-full"; - type Open = "open"; - type Quickinfo = "quickinfo"; - type QuickinfoFull = "quickinfo-full"; - type References = "references"; - type ReferencesFull = "references-full"; - type Reload = "reload"; - type Rename = "rename"; - type RenameInfoFull = "rename-full"; - type RenameLocationsFull = "renameLocations-full"; - type Saveto = "saveto"; - type SignatureHelp = "signatureHelp"; - type SignatureHelpFull = "signatureHelp-full"; - type TypeDefinition = "typeDefinition"; - type ProjectInfo = "projectInfo"; - type ReloadProjects = "reloadProjects"; - type Unknown = "unknown"; - type OpenExternalProject = "openExternalProject"; - type OpenExternalProjects = "openExternalProjects"; - type CloseExternalProject = "closeExternalProject"; - type SynchronizeProjectList = "synchronizeProjectList"; - type ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; - type EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; - type Cleanup = "cleanup"; - type OutliningSpans = "outliningSpans"; - type TodoComments = "todoComments"; - type Indentation = "indentation"; - type DocCommentTemplate = "docCommentTemplate"; - type CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; - type NameOrDottedNameSpan = "nameOrDottedNameSpan"; - type BreakpointStatement = "breakpointStatement"; - type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; - type GetCodeFixes = "getCodeFixes"; - type GetCodeFixesFull = "getCodeFixes-full"; - type GetSupportedCodeFixes = "getSupportedCodeFixes"; - } - interface Message { - seq: number; - type: "request" | "response" | "event"; - } - interface Request extends Message { - command: string; - arguments?: any; - } - interface ReloadProjectsRequest extends Message { - command: CommandTypes.ReloadProjects; - } - interface Event extends Message { - event: string; - body?: any; - } - interface Response extends Message { - request_seq: number; - success: boolean; - command: string; - message?: string; - body?: any; - } - interface FileRequestArgs { - file: string; - projectFileName?: string; - } - interface DocCommentTemplateRequest extends FileLocationRequest { - command: CommandTypes.DocCommentTemplate; - } - interface DocCommandTemplateResponse extends Response { - body?: TextInsertion; - } - interface TodoCommentRequest extends FileRequest { - command: CommandTypes.TodoComments; - arguments: TodoCommentRequestArgs; - } - interface TodoCommentRequestArgs extends FileRequestArgs { - descriptors: TodoCommentDescriptor[]; - } - interface TodoCommentsResponse extends Response { - body?: TodoComment[]; - } - interface OutliningSpansRequest extends FileRequest { - command: CommandTypes.OutliningSpans; - } - interface OutliningSpansResponse extends Response { - body?: OutliningSpan[]; - } - interface IndentationRequest extends FileLocationRequest { - command: CommandTypes.Indentation; - arguments: IndentationRequestArgs; - } - interface IndentationResponse extends Response { - body?: IndentationResult; - } - interface IndentationResult { - position: number; - indentation: number; - } - interface IndentationRequestArgs extends FileLocationRequestArgs { - options?: EditorSettings; - } - interface ProjectInfoRequestArgs extends FileRequestArgs { - needFileNameList: boolean; - } - interface ProjectInfoRequest extends Request { - command: CommandTypes.ProjectInfo; - arguments: ProjectInfoRequestArgs; - } - interface CompilerOptionsDiagnosticsRequest extends Request { - arguments: CompilerOptionsDiagnosticsRequestArgs; - } - interface CompilerOptionsDiagnosticsRequestArgs { - projectFileName: string; - } - interface ProjectInfo { - configFileName: string; - fileNames?: string[]; - languageServiceDisabled?: boolean; - } - interface DiagnosticWithLinePosition { - message: string; - start: number; - length: number; - startLocation: Location; - endLocation: Location; - category: string; - code: number; - } - interface ProjectInfoResponse extends Response { - body?: ProjectInfo; - } - interface FileRequest extends Request { - arguments: FileRequestArgs; - } - interface FileLocationRequestArgs extends FileRequestArgs { - line: number; - offset: number; - position?: number; - } - interface CodeFixRequest extends Request { - command: CommandTypes.GetCodeFixes; - arguments: CodeFixRequestArgs; - } - interface CodeFixRequestArgs extends FileRequestArgs { - startLine: number; - startOffset: number; - startPosition?: number; - endLine: number; - endOffset: number; - endPosition?: number; - errorCodes?: number[]; - } - interface GetCodeFixesResponse extends Response { - body?: CodeAction[]; - } - interface FileLocationRequest extends FileRequest { - arguments: FileLocationRequestArgs; - } - interface GetSupportedCodeFixesRequest extends Request { - command: CommandTypes.GetSupportedCodeFixes; - } - interface GetSupportedCodeFixesResponse extends Response { - body?: string[]; - } - interface EncodedSemanticClassificationsRequest extends FileRequest { - arguments: EncodedSemanticClassificationsRequestArgs; - } - interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { - start: number; - length: number; - } - interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { - filesToSearch: string[]; - } - interface DefinitionRequest extends FileLocationRequest { - command: CommandTypes.Definition; - } - interface TypeDefinitionRequest extends FileLocationRequest { - command: CommandTypes.TypeDefinition; - } - interface ImplementationRequest extends FileLocationRequest { - command: CommandTypes.Implementation; - } - interface Location { - line: number; - offset: number; - } - interface TextSpan { - start: Location; - end: Location; - } - interface FileSpan extends TextSpan { - file: string; - } - interface DefinitionResponse extends Response { - body?: FileSpan[]; - } - interface TypeDefinitionResponse extends Response { - body?: FileSpan[]; - } - interface ImplementationResponse extends Response { - body?: FileSpan[]; - } - interface BraceCompletionRequest extends FileLocationRequest { - command: CommandTypes.BraceCompletion; - arguments: BraceCompletionRequestArgs; - } - interface BraceCompletionRequestArgs extends FileLocationRequestArgs { - openingBrace: string; - } - interface OccurrencesRequest extends FileLocationRequest { - command: CommandTypes.Occurrences; - } - interface OccurrencesResponseItem extends FileSpan { - isWriteAccess: boolean; - } - interface OccurrencesResponse extends Response { - body?: OccurrencesResponseItem[]; - } - interface DocumentHighlightsRequest extends FileLocationRequest { - command: CommandTypes.DocumentHighlights; - arguments: DocumentHighlightsRequestArgs; - } - interface HighlightSpan extends TextSpan { - kind: string; - } - interface DocumentHighlightsItem { - file: string; - highlightSpans: HighlightSpan[]; - } - interface DocumentHighlightsResponse extends Response { - body?: DocumentHighlightsItem[]; - } - interface ReferencesRequest extends FileLocationRequest { - command: CommandTypes.References; - } - interface ReferencesResponseItem extends FileSpan { - lineText: string; - isWriteAccess: boolean; - isDefinition: boolean; - } - interface ReferencesResponseBody { - refs: ReferencesResponseItem[]; - symbolName: string; - symbolStartOffset: number; - symbolDisplayString: string; - } - interface ReferencesResponse extends Response { - body?: ReferencesResponseBody; - } - interface RenameRequestArgs extends FileLocationRequestArgs { - findInComments?: boolean; - findInStrings?: boolean; - } - interface RenameRequest extends FileLocationRequest { - command: CommandTypes.Rename; - arguments: RenameRequestArgs; - } - interface RenameInfo { - canRename: boolean; - localizedErrorMessage?: string; - displayName: string; - fullDisplayName: string; - kind: string; - kindModifiers: string; - } - interface SpanGroup { - file: string; - locs: TextSpan[]; - } - interface RenameResponseBody { - info: RenameInfo; - locs: SpanGroup[]; - } - interface RenameResponse extends Response { - body?: RenameResponseBody; - } - interface ExternalFile { - fileName: string; - scriptKind?: ScriptKindName | ts.ScriptKind; - hasMixedContent?: boolean; - content?: string; - } - interface ExternalProject { - projectFileName: string; - rootFiles: ExternalFile[]; - options: ExternalProjectCompilerOptions; - typingOptions?: TypeAcquisition; - typeAcquisition?: TypeAcquisition; - } - interface CompileOnSaveMixin { - compileOnSave?: boolean; - } - type ExternalProjectCompilerOptions = CompilerOptions & CompileOnSaveMixin; - interface ProjectVersionInfo { - projectName: string; - isInferred: boolean; - version: number; - options: ts.CompilerOptions; - languageServiceDisabled: boolean; - } - interface ProjectChanges { - added: string[]; - removed: string[]; - updated: string[]; - } - interface ProjectFiles { - info?: ProjectVersionInfo; - files?: string[]; - changes?: ProjectChanges; - } - interface ProjectFilesWithDiagnostics extends ProjectFiles { - projectErrors: DiagnosticWithLinePosition[]; - } - interface ChangedOpenFile { - fileName: string; - changes: ts.TextChange[]; - } - interface ConfigureRequestArguments { - hostInfo?: string; - file?: string; - formatOptions?: FormatCodeSettings; - extraFileExtensions?: FileExtensionInfo[]; - } - interface ConfigureRequest extends Request { - command: CommandTypes.Configure; - arguments: ConfigureRequestArguments; - } - interface ConfigureResponse extends Response { - } - interface OpenRequestArgs extends FileRequestArgs { - fileContent?: string; - scriptKindName?: ScriptKindName; - } - type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; - interface OpenRequest extends Request { - command: CommandTypes.Open; - arguments: OpenRequestArgs; - } - interface OpenExternalProjectRequest extends Request { - command: CommandTypes.OpenExternalProject; - arguments: OpenExternalProjectArgs; - } - type OpenExternalProjectArgs = ExternalProject; - interface OpenExternalProjectsRequest extends Request { - command: CommandTypes.OpenExternalProjects; - arguments: OpenExternalProjectsArgs; - } - interface OpenExternalProjectsArgs { - projects: ExternalProject[]; - } - interface OpenExternalProjectResponse extends Response { - } - interface OpenExternalProjectsResponse extends Response { - } - interface CloseExternalProjectRequest extends Request { - command: CommandTypes.CloseExternalProject; - arguments: CloseExternalProjectRequestArgs; - } - interface CloseExternalProjectRequestArgs { - projectFileName: string; - } - interface CloseExternalProjectResponse extends Response { - } - interface SynchronizeProjectListRequest extends Request { - arguments: SynchronizeProjectListRequestArgs; - } - interface SynchronizeProjectListRequestArgs { - knownProjects: protocol.ProjectVersionInfo[]; - } - interface ApplyChangedToOpenFilesRequest extends Request { - arguments: ApplyChangedToOpenFilesRequestArgs; - } - interface ApplyChangedToOpenFilesRequestArgs { - openFiles?: ExternalFile[]; - changedFiles?: ChangedOpenFile[]; - closedFiles?: string[]; - } - interface SetCompilerOptionsForInferredProjectsRequest extends Request { - command: CommandTypes.CompilerOptionsForInferredProjects; - arguments: SetCompilerOptionsForInferredProjectsArgs; - } - interface SetCompilerOptionsForInferredProjectsArgs { - options: ExternalProjectCompilerOptions; - } - interface SetCompilerOptionsForInferredProjectsResponse extends Response { - } - interface ExitRequest extends Request { - command: CommandTypes.Exit; - } - interface CloseRequest extends FileRequest { - command: CommandTypes.Close; - } - interface CompileOnSaveAffectedFileListRequest extends FileRequest { - command: CommandTypes.CompileOnSaveAffectedFileList; - } - interface CompileOnSaveAffectedFileListSingleProject { - projectFileName: string; - fileNames: string[]; - } - interface CompileOnSaveAffectedFileListResponse extends Response { - body: CompileOnSaveAffectedFileListSingleProject[]; - } - interface CompileOnSaveEmitFileRequest extends FileRequest { - command: CommandTypes.CompileOnSaveEmitFile; - arguments: CompileOnSaveEmitFileRequestArgs; - } - interface CompileOnSaveEmitFileRequestArgs extends FileRequestArgs { - forced?: boolean; - } - interface QuickInfoRequest extends FileLocationRequest { - command: CommandTypes.Quickinfo; - } - interface QuickInfoResponseBody { - kind: string; - kindModifiers: string; - start: Location; - end: Location; - displayString: string; - documentation: string; - } - interface QuickInfoResponse extends Response { - body?: QuickInfoResponseBody; - } - interface FormatRequestArgs extends FileLocationRequestArgs { - endLine: number; - endOffset: number; - endPosition?: number; - options?: FormatCodeSettings; - } - interface FormatRequest extends FileLocationRequest { - command: CommandTypes.Format; - arguments: FormatRequestArgs; - } - interface CodeEdit { - start: Location; - end: Location; - newText: string; - } - interface FileCodeEdits { - fileName: string; - textChanges: CodeEdit[]; - } - interface CodeFixResponse extends Response { - body?: CodeAction[]; - } - interface CodeAction { - description: string; - changes: FileCodeEdits[]; - } - interface FormatResponse extends Response { - body?: CodeEdit[]; - } - interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { - key: string; - options?: FormatCodeSettings; - } - interface FormatOnKeyRequest extends FileLocationRequest { - command: CommandTypes.Formatonkey; - arguments: FormatOnKeyRequestArgs; - } - interface CompletionsRequestArgs extends FileLocationRequestArgs { - prefix?: string; - } - interface CompletionsRequest extends FileLocationRequest { - command: CommandTypes.Completions; - arguments: CompletionsRequestArgs; - } - interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { - entryNames: string[]; - } - interface CompletionDetailsRequest extends FileLocationRequest { - command: CommandTypes.CompletionDetails; - arguments: CompletionDetailsRequestArgs; - } - interface SymbolDisplayPart { - text: string; - kind: string; - } - interface CompletionEntry { - name: string; - kind: string; - kindModifiers: string; - sortText: string; - replacementSpan?: TextSpan; - } - interface CompletionEntryDetails { - name: string; - kind: string; - kindModifiers: string; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - } - interface CompletionsResponse extends Response { - body?: CompletionEntry[]; - } - interface CompletionDetailsResponse extends Response { - body?: CompletionEntryDetails[]; - } - interface SignatureHelpParameter { - name: string; - documentation: SymbolDisplayPart[]; - displayParts: SymbolDisplayPart[]; - isOptional: boolean; - } - interface SignatureHelpItem { - isVariadic: boolean; - prefixDisplayParts: SymbolDisplayPart[]; - suffixDisplayParts: SymbolDisplayPart[]; - separatorDisplayParts: SymbolDisplayPart[]; - parameters: SignatureHelpParameter[]; - documentation: SymbolDisplayPart[]; - } - interface SignatureHelpItems { - items: SignatureHelpItem[]; - applicableSpan: TextSpan; - selectedItemIndex: number; - argumentIndex: number; - argumentCount: number; - } - interface SignatureHelpRequestArgs extends FileLocationRequestArgs { - } - interface SignatureHelpRequest extends FileLocationRequest { - command: CommandTypes.SignatureHelp; - arguments: SignatureHelpRequestArgs; - } - interface SignatureHelpResponse extends Response { - body?: SignatureHelpItems; - } - interface SemanticDiagnosticsSyncRequest extends FileRequest { - command: CommandTypes.SemanticDiagnosticsSync; - arguments: SemanticDiagnosticsSyncRequestArgs; - } - interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs { - includeLinePosition?: boolean; - } - interface SemanticDiagnosticsSyncResponse extends Response { - body?: Diagnostic[] | DiagnosticWithLinePosition[]; - } - interface SyntacticDiagnosticsSyncRequest extends FileRequest { - command: CommandTypes.SyntacticDiagnosticsSync; - arguments: SyntacticDiagnosticsSyncRequestArgs; - } - interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs { - includeLinePosition?: boolean; - } - interface SyntacticDiagnosticsSyncResponse extends Response { - body?: Diagnostic[] | DiagnosticWithLinePosition[]; - } - interface GeterrForProjectRequestArgs { - file: string; - delay: number; - } - interface GeterrForProjectRequest extends Request { - command: CommandTypes.GeterrForProject; - arguments: GeterrForProjectRequestArgs; - } - interface GeterrRequestArgs { - files: string[]; - delay: number; - } - interface GeterrRequest extends Request { - command: CommandTypes.Geterr; - arguments: GeterrRequestArgs; - } - interface Diagnostic { - start: Location; - end: Location; - text: string; - code?: number; - } - interface DiagnosticEventBody { - file: string; - diagnostics: Diagnostic[]; - } - interface DiagnosticEvent extends Event { - body?: DiagnosticEventBody; - } - interface ConfigFileDiagnosticEventBody { - triggerFile: string; - configFile: string; - diagnostics: Diagnostic[]; - } - interface ConfigFileDiagnosticEvent extends Event { - body?: ConfigFileDiagnosticEventBody; - event: "configFileDiag"; - } - type ProjectLanguageServiceStateEventName = "projectLanguageServiceState"; - interface ProjectLanguageServiceStateEvent extends Event { - event: ProjectLanguageServiceStateEventName; - body?: ProjectLanguageServiceStateEventBody; - } - interface ProjectLanguageServiceStateEventBody { - projectName: string; - languageServiceEnabled: boolean; - } - interface ReloadRequestArgs extends FileRequestArgs { - tmpfile: string; - } - interface ReloadRequest extends FileRequest { - command: CommandTypes.Reload; - arguments: ReloadRequestArgs; - } - interface ReloadResponse extends Response { - } - interface SavetoRequestArgs extends FileRequestArgs { - tmpfile: string; - } - interface SavetoRequest extends FileRequest { - command: CommandTypes.Saveto; - arguments: SavetoRequestArgs; - } - interface NavtoRequestArgs extends FileRequestArgs { - searchValue: string; - maxResultCount?: number; - currentFileOnly?: boolean; - projectFileName?: string; - } - interface NavtoRequest extends FileRequest { - command: CommandTypes.Navto; - arguments: NavtoRequestArgs; - } - interface NavtoItem { - name: string; - kind: string; - matchKind?: string; - isCaseSensitive?: boolean; - kindModifiers?: string; - file: string; - start: Location; - end: Location; - containerName?: string; - containerKind?: string; - } - interface NavtoResponse extends Response { - body?: NavtoItem[]; - } - interface ChangeRequestArgs extends FormatRequestArgs { - insertString?: string; - } - interface ChangeRequest extends FileLocationRequest { - command: CommandTypes.Change; - arguments: ChangeRequestArgs; - } - interface BraceResponse extends Response { - body?: TextSpan[]; - } - interface BraceRequest extends FileLocationRequest { - command: CommandTypes.Brace; - } - interface NavBarRequest extends FileRequest { - command: CommandTypes.NavBar; - } - interface NavTreeRequest extends FileRequest { - command: CommandTypes.NavTree; - } - interface NavigationBarItem { - text: string; - kind: string; - kindModifiers?: string; - spans: TextSpan[]; - childItems?: NavigationBarItem[]; - indent: number; - } - interface NavigationTree { - text: string; - kind: string; - kindModifiers: string; - spans: TextSpan[]; - childItems?: NavigationTree[]; - } - type TelemetryEventName = "telemetry"; - interface TelemetryEvent extends Event { - event: TelemetryEventName; - body: TelemetryEventBody; - } - interface TelemetryEventBody { - telemetryEventName: string; - payload: any; - } - type TypingsInstalledTelemetryEventName = "typingsInstalled"; - interface TypingsInstalledTelemetryEventBody extends TelemetryEventBody { - telemetryEventName: TypingsInstalledTelemetryEventName; - payload: TypingsInstalledTelemetryEventPayload; - } - interface TypingsInstalledTelemetryEventPayload { - installedPackages: string; - installSuccess: boolean; - typingsInstallerVersion: string; - } - type BeginInstallTypesEventName = "beginInstallTypes"; - type EndInstallTypesEventName = "endInstallTypes"; - interface BeginInstallTypesEvent extends Event { - event: BeginInstallTypesEventName; - body: BeginInstallTypesEventBody; - } - interface EndInstallTypesEvent extends Event { - event: EndInstallTypesEventName; - body: EndInstallTypesEventBody; - } - interface InstallTypesEventBody { - eventId: number; - packages: ReadonlyArray; - } - interface BeginInstallTypesEventBody extends InstallTypesEventBody { - } - interface EndInstallTypesEventBody extends InstallTypesEventBody { - success: boolean; - } - interface NavBarResponse extends Response { - body?: NavigationBarItem[]; - } - interface NavTreeResponse extends Response { - body?: NavigationTree; - } - namespace IndentStyle { - type None = "None"; - type Block = "Block"; - type Smart = "Smart"; - } - type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart; - interface EditorSettings { - baseIndentSize?: number; - indentSize?: number; - tabSize?: number; - newLineCharacter?: string; - convertTabsToSpaces?: boolean; - indentStyle?: IndentStyle | ts.IndentStyle; - } - interface FormatCodeSettings extends EditorSettings { - insertSpaceAfterCommaDelimiter?: boolean; - insertSpaceAfterSemicolonInForStatements?: boolean; - insertSpaceBeforeAndAfterBinaryOperators?: boolean; - insertSpaceAfterKeywordsInControlFlowStatements?: boolean; - insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; - placeOpenBraceOnNewLineForFunctions?: boolean; - placeOpenBraceOnNewLineForControlBlocks?: boolean; - } - interface CompilerOptions { - allowJs?: boolean; - allowSyntheticDefaultImports?: boolean; - allowUnreachableCode?: boolean; - allowUnusedLabels?: boolean; - baseUrl?: string; - charset?: string; - declaration?: boolean; - declarationDir?: string; - disableSizeLimit?: boolean; - emitBOM?: boolean; - emitDecoratorMetadata?: boolean; - experimentalDecorators?: boolean; - forceConsistentCasingInFileNames?: boolean; - inlineSourceMap?: boolean; - inlineSources?: boolean; - isolatedModules?: boolean; - jsx?: JsxEmit | ts.JsxEmit; - lib?: string[]; - locale?: string; - mapRoot?: string; - maxNodeModuleJsDepth?: number; - module?: ModuleKind | ts.ModuleKind; - moduleResolution?: ModuleResolutionKind | ts.ModuleResolutionKind; - newLine?: NewLineKind | ts.NewLineKind; - noEmit?: boolean; - noEmitHelpers?: boolean; - noEmitOnError?: boolean; - noErrorTruncation?: boolean; - noFallthroughCasesInSwitch?: boolean; - noImplicitAny?: boolean; - noImplicitReturns?: boolean; - noImplicitThis?: boolean; - noUnusedLocals?: boolean; - noUnusedParameters?: boolean; - noImplicitUseStrict?: boolean; - noLib?: boolean; - noResolve?: boolean; - out?: string; - outDir?: string; - outFile?: string; - paths?: MapLike; - preserveConstEnums?: boolean; - project?: string; - reactNamespace?: string; - removeComments?: boolean; - rootDir?: string; - rootDirs?: string[]; - skipLibCheck?: boolean; - skipDefaultLibCheck?: boolean; - sourceMap?: boolean; - sourceRoot?: string; - strictNullChecks?: boolean; - suppressExcessPropertyErrors?: boolean; - suppressImplicitAnyIndexErrors?: boolean; - target?: ScriptTarget | ts.ScriptTarget; - traceResolution?: boolean; - types?: string[]; - typeRoots?: string[]; - [option: string]: CompilerOptionsValue | undefined; - } - namespace JsxEmit { - type None = "None"; - type Preserve = "Preserve"; - type React = "React"; - } - type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React; - namespace ModuleKind { - type None = "None"; - type CommonJS = "CommonJS"; - type AMD = "AMD"; - type UMD = "UMD"; - type System = "System"; - type ES6 = "ES6"; - type ES2015 = "ES2015"; - } - type ModuleKind = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.AMD | ModuleKind.UMD | ModuleKind.System | ModuleKind.ES6 | ModuleKind.ES2015; - namespace ModuleResolutionKind { - type Classic = "Classic"; - type Node = "Node"; - } - type ModuleResolutionKind = ModuleResolutionKind.Classic | ModuleResolutionKind.Node; - namespace NewLineKind { - type Crlf = "Crlf"; - type Lf = "Lf"; - } - type NewLineKind = NewLineKind.Crlf | NewLineKind.Lf; - namespace ScriptTarget { - type ES3 = "ES3"; - type ES5 = "ES5"; - type ES6 = "ES6"; - type ES2015 = "ES2015"; - } - type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015; -} +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + declare namespace ts { interface MapLike { [index: string]: T; @@ -1094,102 +239,102 @@ declare namespace ts { ExpressionWithTypeArguments = 199, AsExpression = 200, NonNullExpression = 201, - TemplateSpan = 202, - SemicolonClassElement = 203, - Block = 204, - VariableStatement = 205, - EmptyStatement = 206, - ExpressionStatement = 207, - IfStatement = 208, - DoStatement = 209, - WhileStatement = 210, - ForStatement = 211, - ForInStatement = 212, - ForOfStatement = 213, - ContinueStatement = 214, - BreakStatement = 215, - ReturnStatement = 216, - WithStatement = 217, - SwitchStatement = 218, - LabeledStatement = 219, - ThrowStatement = 220, - TryStatement = 221, - DebuggerStatement = 222, - VariableDeclaration = 223, - VariableDeclarationList = 224, - FunctionDeclaration = 225, - ClassDeclaration = 226, - InterfaceDeclaration = 227, - TypeAliasDeclaration = 228, - EnumDeclaration = 229, - ModuleDeclaration = 230, - ModuleBlock = 231, - CaseBlock = 232, - NamespaceExportDeclaration = 233, - ImportEqualsDeclaration = 234, - ImportDeclaration = 235, - ImportClause = 236, - NamespaceImport = 237, - NamedImports = 238, - ImportSpecifier = 239, - ExportAssignment = 240, - ExportDeclaration = 241, - NamedExports = 242, - ExportSpecifier = 243, - MissingDeclaration = 244, - ExternalModuleReference = 245, - JsxElement = 246, - JsxSelfClosingElement = 247, - JsxOpeningElement = 248, - JsxClosingElement = 249, - JsxAttribute = 250, - JsxSpreadAttribute = 251, - JsxExpression = 252, - CaseClause = 253, - DefaultClause = 254, - HeritageClause = 255, - CatchClause = 256, - PropertyAssignment = 257, - ShorthandPropertyAssignment = 258, - SpreadAssignment = 259, - EnumMember = 260, - SourceFile = 261, - JSDocTypeExpression = 262, - JSDocAllType = 263, - JSDocUnknownType = 264, - JSDocArrayType = 265, - JSDocUnionType = 266, - JSDocTupleType = 267, - JSDocNullableType = 268, - JSDocNonNullableType = 269, - JSDocRecordType = 270, - JSDocRecordMember = 271, - JSDocTypeReference = 272, - JSDocOptionalType = 273, - JSDocFunctionType = 274, - JSDocVariadicType = 275, - JSDocConstructorType = 276, - JSDocThisType = 277, - JSDocComment = 278, - JSDocTag = 279, - JSDocAugmentsTag = 280, - JSDocParameterTag = 281, - JSDocReturnTag = 282, - JSDocTypeTag = 283, - JSDocTemplateTag = 284, - JSDocTypedefTag = 285, - JSDocPropertyTag = 286, - JSDocTypeLiteral = 287, - JSDocLiteralType = 288, - JSDocNullKeyword = 289, - JSDocUndefinedKeyword = 290, - JSDocNeverKeyword = 291, - SyntaxList = 292, - NotEmittedStatement = 293, - PartiallyEmittedExpression = 294, - MergeDeclarationMarker = 295, - EndOfDeclarationMarker = 296, - RawExpression = 297, + MetaProperty = 202, + TemplateSpan = 203, + SemicolonClassElement = 204, + Block = 205, + VariableStatement = 206, + EmptyStatement = 207, + ExpressionStatement = 208, + IfStatement = 209, + DoStatement = 210, + WhileStatement = 211, + ForStatement = 212, + ForInStatement = 213, + ForOfStatement = 214, + ContinueStatement = 215, + BreakStatement = 216, + ReturnStatement = 217, + WithStatement = 218, + SwitchStatement = 219, + LabeledStatement = 220, + ThrowStatement = 221, + TryStatement = 222, + DebuggerStatement = 223, + VariableDeclaration = 224, + VariableDeclarationList = 225, + FunctionDeclaration = 226, + ClassDeclaration = 227, + InterfaceDeclaration = 228, + TypeAliasDeclaration = 229, + EnumDeclaration = 230, + ModuleDeclaration = 231, + ModuleBlock = 232, + CaseBlock = 233, + NamespaceExportDeclaration = 234, + ImportEqualsDeclaration = 235, + ImportDeclaration = 236, + ImportClause = 237, + NamespaceImport = 238, + NamedImports = 239, + ImportSpecifier = 240, + ExportAssignment = 241, + ExportDeclaration = 242, + NamedExports = 243, + ExportSpecifier = 244, + MissingDeclaration = 245, + ExternalModuleReference = 246, + JsxElement = 247, + JsxSelfClosingElement = 248, + JsxOpeningElement = 249, + JsxClosingElement = 250, + JsxAttribute = 251, + JsxSpreadAttribute = 252, + JsxExpression = 253, + CaseClause = 254, + DefaultClause = 255, + HeritageClause = 256, + CatchClause = 257, + PropertyAssignment = 258, + ShorthandPropertyAssignment = 259, + SpreadAssignment = 260, + EnumMember = 261, + SourceFile = 262, + JSDocTypeExpression = 263, + JSDocAllType = 264, + JSDocUnknownType = 265, + JSDocArrayType = 266, + JSDocUnionType = 267, + JSDocTupleType = 268, + JSDocNullableType = 269, + JSDocNonNullableType = 270, + JSDocRecordType = 271, + JSDocRecordMember = 272, + JSDocTypeReference = 273, + JSDocOptionalType = 274, + JSDocFunctionType = 275, + JSDocVariadicType = 276, + JSDocConstructorType = 277, + JSDocThisType = 278, + JSDocComment = 279, + JSDocTag = 280, + JSDocAugmentsTag = 281, + JSDocParameterTag = 282, + JSDocReturnTag = 283, + JSDocTypeTag = 284, + JSDocTemplateTag = 285, + JSDocTypedefTag = 286, + JSDocPropertyTag = 287, + JSDocTypeLiteral = 288, + JSDocLiteralType = 289, + JSDocNullKeyword = 290, + JSDocUndefinedKeyword = 291, + JSDocNeverKeyword = 292, + SyntaxList = 293, + NotEmittedStatement = 294, + PartiallyEmittedExpression = 295, + MergeDeclarationMarker = 296, + EndOfDeclarationMarker = 297, Count = 298, FirstAssignment = 57, LastAssignment = 69, @@ -1216,10 +361,10 @@ declare namespace ts { FirstBinaryOperator = 26, LastBinaryOperator = 69, FirstNode = 141, - FirstJSDocNode = 262, - LastJSDocNode = 288, - FirstJSDocTagNode = 278, - LastJSDocTagNode = 291, + FirstJSDocNode = 263, + LastJSDocNode = 289, + FirstJSDocTagNode = 279, + LastJSDocTagNode = 292, } const enum NodeFlags { None = 0, @@ -1274,34 +419,15 @@ declare namespace ts { IntrinsicIndexedElement = 2, IntrinsicElement = 3, } - const enum RelationComparisonResult { - Succeeded = 1, - Failed = 2, - FailedAndReported = 3, - } interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; - modifierFlagsCache?: ModifierFlags; - transformFlags?: TransformFlags; decorators?: NodeArray; modifiers?: ModifiersArray; - id?: number; parent?: Node; - original?: Node; - startsOnNewLine?: boolean; - jsDoc?: JSDoc[]; - jsDocCache?: (JSDoc | JSDocTag)[]; - symbol?: Symbol; - locals?: SymbolTable; - nextContainer?: Node; - localSymbol?: Symbol; - flowNode?: FlowNode; - emitNode?: EmitNode; } interface NodeArray extends Array, TextRange { hasTrailingComma?: boolean; - transformFlags?: TransformFlags; } interface Token extends Node { kind: TKind; @@ -1317,27 +443,15 @@ declare namespace ts { type ReadonlyToken = Token; type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; type ModifiersArray = NodeArray; - const enum GeneratedIdentifierKind { - None = 0, - Auto = 1, - Loop = 2, - Unique = 3, - Node = 4, - } interface Identifier extends PrimaryExpression { kind: SyntaxKind.Identifier; text: string; originalKeywordKind?: SyntaxKind; - autoGenerateKind?: GeneratedIdentifierKind; - autoGenerateId?: number; isInJSDocNamespace?: boolean; } interface TransientIdentifier extends Identifier { resolvedSymbol: Symbol; } - interface GeneratedIdentifier extends Identifier { - autoGenerateKind: GeneratedIdentifierKind.Auto | GeneratedIdentifierKind.Loop | GeneratedIdentifierKind.Unique | GeneratedIdentifierKind.Node; - } interface QualifiedName extends Node { kind: SyntaxKind.QualifiedName; left: EntityName; @@ -1585,7 +699,6 @@ declare namespace ts { } interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; - textSourceNode?: Identifier | StringLiteral | NumericLiteral; } interface Expression extends Node { _expressionBrand: any; @@ -1594,10 +707,6 @@ declare namespace ts { interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; } - interface PartiallyEmittedExpression extends LeftHandSideExpression { - kind: SyntaxKind.PartiallyEmittedExpression; - expression: Expression; - } interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } @@ -1727,7 +836,6 @@ declare namespace ts { text: string; isUnterminated?: boolean; hasExtendedUnicodeEscape?: boolean; - isOctalLiteral?: boolean; } interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { _literalExpressionBrand: any; @@ -1769,7 +877,6 @@ declare namespace ts { interface ArrayLiteralExpression extends PrimaryExpression { kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray; - multiLine?: boolean; } interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; @@ -1780,7 +887,6 @@ declare namespace ts { } interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { kind: SyntaxKind.ObjectLiteralExpression; - multiLine?: boolean; } type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; @@ -1846,6 +952,11 @@ declare namespace ts { kind: SyntaxKind.NonNullExpression; expression: Expression; } + interface MetaProperty extends PrimaryExpression { + kind: SyntaxKind.MetaProperty; + keywordToken: SyntaxKind; + name: Identifier; + } interface JsxElement extends PrimaryExpression { kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; @@ -1880,6 +991,7 @@ declare namespace ts { } interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; + dotDotDotToken?: Token; expression?: Expression; } interface JsxText extends Node { @@ -1889,19 +1001,6 @@ declare namespace ts { interface Statement extends Node { _statementBrand: any; } - interface NotEmittedStatement extends Statement { - kind: SyntaxKind.NotEmittedStatement; - } - interface EndOfDeclarationMarker extends Statement { - kind: SyntaxKind.EndOfDeclarationMarker; - } - interface RawExpression extends PrimaryExpression { - kind: SyntaxKind.RawExpression; - text: string; - } - interface MergeDeclarationMarker extends Statement { - kind: SyntaxKind.MergeDeclarationMarker; - } interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } @@ -1912,11 +1011,10 @@ declare namespace ts { kind: SyntaxKind.MissingDeclaration; name?: Identifier; } - type BlockLike = SourceFile | Block | ModuleBlock | CaseClause; + type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; - multiLine?: boolean; } interface VariableStatement extends Statement { kind: SyntaxKind.VariableStatement; @@ -1926,9 +1024,6 @@ declare namespace ts { kind: SyntaxKind.ExpressionStatement; expression: Expression; } - interface PrologueDirective extends ExpressionStatement { - expression: StringLiteral; - } interface IfStatement extends Statement { kind: SyntaxKind.IfStatement; expression: Expression; @@ -2350,27 +1445,8 @@ declare namespace ts { typeReferenceDirectives: FileReference[]; languageVariant: LanguageVariant; isDeclarationFile: boolean; - renamedDependencies?: Map; hasNoDefaultLib: boolean; languageVersion: ScriptTarget; - scriptKind: ScriptKind; - externalModuleIndicator: Node; - commonJsModuleIndicator: Node; - identifiers: Map; - nodeCount: number; - identifierCount: number; - symbolCount: number; - parseDiagnostics: Diagnostic[]; - additionalSyntacticDiagnostics?: Diagnostic[]; - bindDiagnostics: Diagnostic[]; - lineMap: number[]; - classifiableNames?: Map; - resolvedModules: Map; - resolvedTypeReferenceDirectiveNames: Map; - imports: LiteralExpression[]; - moduleAugmentations: LiteralExpression[]; - patternAmbientModules?: PatternAmbientModule[]; - ambientModuleNames: string[]; } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; @@ -2403,18 +1479,6 @@ declare namespace ts { getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; getTypeChecker(): TypeChecker; - getCommonSourceDirectory(): string; - getDiagnosticsProducingTypeChecker(): TypeChecker; - dropDiagnosticsProducingTypeChecker(): void; - getClassifiableNames(): Map; - getNodeCount(): number; - getIdentifierCount(): number; - getSymbolCount(): number; - getTypeCount(): number; - getFileProcessingDiagnostics(): DiagnosticCollection; - getResolvedTypeReferenceDirectives(): Map; - isSourceFileFromExternalLibrary(file: SourceFile): boolean; - structureIsReused?: boolean; } interface SourceMapSpan { emittedLine: number; @@ -2445,19 +1509,13 @@ declare namespace ts { emitSkipped: boolean; diagnostics: Diagnostic[]; emittedFiles: string[]; - sourceMaps: SourceMapData[]; - } - interface TypeCheckerHost { - getCompilerOptions(): CompilerOptions; - getSourceFiles(): SourceFile[]; - getSourceFile(fileName: string): SourceFile; - getResolvedTypeReferenceDirectives(): Map; } interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol; + getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; getBaseTypes(type: InterfaceType): ObjectType[]; @@ -2470,6 +1528,8 @@ declare namespace ts { getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol; getTypeAtLocation(node: Node): Type; + getTypeFromTypeNode(node: TypeNode): Type; + signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string; typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; getSymbolDisplayBuilder(): SymbolDisplayBuilder; @@ -2492,19 +1552,13 @@ declare namespace ts { isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; - tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol; - getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getGlobalDiagnostics(): Diagnostic[]; - getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationToken): EmitResolver; - getNodeCount(): number; - getIdentifierCount(): number; - getSymbolCount(): number; - getTypeCount(): number; + getApparentType(type: Type): Type; } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; + buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -2542,21 +1596,13 @@ declare namespace ts { InFirstTypeArgument = 256, InTypeAlias = 512, UseTypeAliasValue = 1024, + SuppressAnyReturnType = 2048, } const enum SymbolFormatFlags { None = 0, WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, } - const enum SymbolAccessibility { - Accessible = 0, - NotAccessible = 1, - CannotBeNamed = 2, - } - const enum SyntheticSymbolKind { - UnionOrIntersection = 0, - Spread = 1, - } const enum TypePredicateKind { This = 0, Identifier = 1, @@ -2574,61 +1620,6 @@ declare namespace ts { parameterIndex: number; } type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; - type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; - interface SymbolVisibilityResult { - accessibility: SymbolAccessibility; - aliasesToMakeVisible?: AnyImportSyntax[]; - errorSymbolName?: string; - errorNode?: Node; - } - interface SymbolAccessibilityResult extends SymbolVisibilityResult { - errorModuleName?: string; - } - enum TypeReferenceSerializationKind { - Unknown = 0, - TypeWithConstructSignatureAndValue = 1, - VoidNullableOrNeverType = 2, - NumberLikeType = 3, - StringLikeType = 4, - BooleanType = 5, - ArrayLikeType = 6, - ESSymbolType = 7, - Promise = 8, - TypeWithCallSignature = 9, - ObjectType = 10, - } - interface EmitResolver { - hasGlobalName(name: string): boolean; - getReferencedExportContainer(node: Identifier, prefixLocals?: boolean): SourceFile | ModuleDeclaration | EnumDeclaration; - getReferencedImportDeclaration(node: Identifier): Declaration; - getReferencedDeclarationWithCollidingName(node: Identifier): Declaration; - isDeclarationWithCollidingName(node: Declaration): boolean; - isValueAliasDeclaration(node: Node): boolean; - isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; - isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; - getNodeCheckFlags(node: Node): NodeCheckFlags; - isDeclarationVisible(node: Declaration): boolean; - collectLinkedAliases(node: Identifier): Node[]; - isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; - writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - writeBaseConstructorTypeOfClass(node: ClassLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult; - isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult; - getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; - getReferencedValueDeclaration(reference: Identifier): Declaration; - getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind; - isOptionalParameter(node: ParameterDeclaration): boolean; - moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean; - isArgumentsLocalBinding(node: Identifier): boolean; - getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): SourceFile; - getTypeReferenceDirectivesForEntityName(name: EntityNameOrEntityNameExpression): string[]; - getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): string[]; - isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean; - writeLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration, writer: SymbolWriter): void; - getJsxFactoryEntity(): EntityName; - } const enum SymbolFlags { None = 0, FunctionScopedVariable = 1, @@ -2695,7 +1686,6 @@ declare namespace ts { PropertyOrAccessor = 98308, Export = 7340032, ClassMember = 106500, - Classifiable = 788448, } interface Symbol { flags: SymbolFlags; @@ -2705,86 +1695,8 @@ declare namespace ts { members?: SymbolTable; exports?: SymbolTable; globalExports?: SymbolTable; - isReadonly?: boolean; - id?: number; - mergeId?: number; - parent?: Symbol; - exportSymbol?: Symbol; - constEnumOnlyModule?: boolean; - isReferenced?: boolean; - isReplaceableByMethod?: boolean; - isAssigned?: boolean; - } - interface SymbolLinks { - target?: Symbol; - type?: Type; - declaredType?: Type; - typeParameters?: TypeParameter[]; - inferredClassType?: Type; - instantiations?: Map; - mapper?: TypeMapper; - referenced?: boolean; - containingType?: UnionOrIntersectionType; - leftSpread?: Symbol; - rightSpread?: Symbol; - hasNonUniformType?: boolean; - isPartial?: boolean; - isDiscriminantProperty?: boolean; - resolvedExports?: SymbolTable; - exportsChecked?: boolean; - isDeclarationWithCollidingName?: boolean; - bindingElement?: BindingElement; - exportsSomeValue?: boolean; - } - interface TransientSymbol extends Symbol, SymbolLinks { } type SymbolTable = Map; - interface Pattern { - prefix: string; - suffix: string; - } - interface PatternAmbientModule { - pattern: Pattern; - symbol: Symbol; - } - const enum NodeCheckFlags { - TypeChecked = 1, - LexicalThis = 2, - CaptureThis = 4, - SuperInstance = 256, - SuperStatic = 512, - ContextChecked = 1024, - AsyncMethodWithSuper = 2048, - AsyncMethodWithSuperBinding = 4096, - CaptureArguments = 8192, - EnumValuesComputed = 16384, - LexicalModuleMergesWithClass = 32768, - LoopWithCapturedBlockScopedBinding = 65536, - CapturedBlockScopedBinding = 131072, - BlockScopedBindingInLoop = 262144, - ClassWithBodyScopedClassBinding = 524288, - BodyScopedClassBinding = 1048576, - NeedsLoopOutParameter = 2097152, - AssignmentsMarked = 4194304, - ClassWithConstructorReference = 8388608, - ConstructorReferenceInClass = 16777216, - } - interface NodeLinks { - flags?: NodeCheckFlags; - resolvedType?: Type; - resolvedSignature?: Signature; - resolvedSymbol?: Symbol; - resolvedIndexInfo?: IndexInfo; - maybeTypePredicate?: boolean; - enumMemberValue?: number; - isVisible?: boolean; - hasReportedStatementInAmbientContext?: boolean; - jsxFlags?: JsxFlags; - resolvedJsxType?: Type; - hasSuperCall?: boolean; - superCall?: ExpressionStatement; - switchTypes?: Type[]; - } const enum TypeFlags { Any = 1, String = 2, @@ -2806,17 +1718,9 @@ declare namespace ts { Intersection = 131072, Index = 262144, IndexedAccess = 524288, - FreshLiteral = 1048576, - ContainsWideningType = 2097152, - ContainsObjectLiteral = 4194304, - ContainsAnyFunctionType = 8388608, - Nullable = 6144, Literal = 480, StringOrNumberLiteral = 96, - DefinitelyFalsy = 7392, PossiblyFalsy = 7406, - Intrinsic = 16015, - Primitive = 8190, StringLike = 262178, NumberLike = 340, BooleanLike = 136, @@ -2827,21 +1731,15 @@ declare namespace ts { TypeVariable = 540672, Narrowable = 1033215, NotUnionOrUnit = 33281, - RequiresWidening = 6291456, - PropagatingFlags = 14680064, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { flags: TypeFlags; - id: number; symbol?: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; aliasTypeArguments?: Type[]; } - interface IntrinsicType extends Type { - intrinsicName: string; - } interface LiteralType extends Type { text: string; freshType?: LiteralType; @@ -2874,8 +1772,6 @@ declare namespace ts { outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; thisType: TypeParameter; - resolvedBaseConstructorType?: Type; - resolvedBaseTypes: ObjectType[]; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -2889,59 +1785,23 @@ declare namespace ts { typeArguments: Type[]; } interface GenericType extends InterfaceType, TypeReference { - instantiations: Map; } interface UnionOrIntersectionType extends Type { types: Type[]; - resolvedProperties: SymbolTable; - resolvedIndexType: IndexType; - couldContainTypeVariables: boolean; } interface UnionType extends UnionOrIntersectionType { } interface IntersectionType extends UnionOrIntersectionType { } type StructuredType = ObjectType | UnionType | IntersectionType; - interface AnonymousType extends ObjectType { - target?: AnonymousType; - mapper?: TypeMapper; - } - interface MappedType extends ObjectType { - declaration: MappedTypeNode; - typeParameter?: TypeParameter; - constraintType?: Type; - templateType?: Type; - modifiersType?: Type; - mapper?: TypeMapper; - } interface EvolvingArrayType extends ObjectType { elementType: Type; finalArrayType?: Type; } - interface ResolvedType extends ObjectType, UnionOrIntersectionType { - members: SymbolTable; - properties: Symbol[]; - callSignatures: Signature[]; - constructSignatures: Signature[]; - stringIndexInfo?: IndexInfo; - numberIndexInfo?: IndexInfo; - } - interface FreshObjectLiteralType extends ResolvedType { - regularType: ResolvedType; - } - interface IterableOrIteratorType extends ObjectType, UnionType { - iterableElementType?: Type; - iteratorElementType?: Type; - } interface TypeVariable extends Type { - resolvedApparentType: Type; - resolvedIndexType: IndexType; } interface TypeParameter extends TypeVariable { constraint: Type; - target?: TypeParameter; - mapper?: TypeMapper; - isThisType?: boolean; } interface IndexedAccessType extends TypeVariable { objectType: Type; @@ -2959,18 +1819,6 @@ declare namespace ts { declaration: SignatureDeclaration; typeParameters: TypeParameter[]; parameters: Symbol[]; - thisParameter?: Symbol; - resolvedReturnType: Type; - minArgumentCount: number; - hasRestParameter: boolean; - hasLiteralTypes: boolean; - target?: Signature; - mapper?: TypeMapper; - unionSignatures?: Signature[]; - erasedSignatureCache?: Signature; - isolatedSignatureType?: ObjectType; - typePredicate?: TypePredicate; - instantiations?: Map; } const enum IndexKind { String = 0, @@ -2981,33 +1829,6 @@ declare namespace ts { isReadonly: boolean; declaration?: SignatureDeclaration; } - interface TypeMapper { - (t: TypeParameter): Type; - mappedTypes?: Type[]; - instantiations?: Type[]; - context?: InferenceContext; - } - interface TypeInferences { - primary: Type[]; - secondary: Type[]; - topLevel: boolean; - isFixed: boolean; - } - interface InferenceContext { - signature: Signature; - inferUnionTypes: boolean; - inferences: TypeInferences[]; - inferredTypes: Type[]; - mapper?: TypeMapper; - failedTypeParameterIndex?: number; - } - const enum SpecialPropertyAssignmentKind { - None = 0, - ExportsProperty = 1, - ModuleExports = 2, - PrototypeProperty = 3, - ThisProperty = 4, - } interface FileExtensionInfo { extension: string; scriptKind: ScriptKind; @@ -3045,33 +1866,25 @@ declare namespace ts { type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; interface CompilerOptions { allowJs?: boolean; - allowNonTsExtensions?: boolean; allowSyntheticDefaultImports?: boolean; allowUnreachableCode?: boolean; allowUnusedLabels?: boolean; alwaysStrict?: boolean; baseUrl?: string; charset?: string; - configFilePath?: string; declaration?: boolean; declarationDir?: string; - diagnostics?: boolean; - extendedDiagnostics?: boolean; disableSizeLimit?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; experimentalDecorators?: boolean; forceConsistentCasingInFileNames?: boolean; - help?: boolean; importHelpers?: boolean; - init?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; isolatedModules?: boolean; jsx?: JsxEmit; lib?: string[]; - listEmittedFiles?: boolean; - listFiles?: boolean; locale?: string; mapRoot?: string; maxNodeModuleJsDepth?: number; @@ -3079,7 +1892,6 @@ declare namespace ts { moduleResolution?: ModuleResolutionKind; newLine?: NewLineKind; noEmit?: boolean; - noEmitForJsFiles?: boolean; noEmitHelpers?: boolean; noEmitOnError?: boolean; noErrorTruncation?: boolean; @@ -3098,7 +1910,6 @@ declare namespace ts { paths?: MapLike; preserveConstEnums?: boolean; project?: string; - pretty?: DiagnosticStyle; reactNamespace?: string; jsxFactory?: string; removeComments?: boolean; @@ -3109,16 +1920,12 @@ declare namespace ts { sourceMap?: boolean; sourceRoot?: string; strictNullChecks?: boolean; - stripInternal?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; - suppressOutputPathCheck?: boolean; target?: ScriptTarget; traceResolution?: boolean; types?: string[]; typeRoots?: string[]; - version?: boolean; - watch?: boolean; [option: string]: CompilerOptionsValue | undefined; } interface TypeAcquisition { @@ -3178,10 +1985,6 @@ declare namespace ts { Standard = 0, JSX = 1, } - const enum DiagnosticStyle { - Simple = 0, - Pretty = 1, - } interface ParsedCommandLine { options: CompilerOptions; typeAcquisition?: TypeAcquisition; @@ -3199,156 +2002,6 @@ declare namespace ts { fileNames: string[]; wildcardDirectories: MapLike; } - interface CommandLineOptionBase { - name: string; - type: "string" | "number" | "boolean" | "object" | "list" | Map; - isFilePath?: boolean; - shortName?: string; - description?: DiagnosticMessage; - paramType?: DiagnosticMessage; - experimental?: boolean; - isTSConfigOnly?: boolean; - } - interface CommandLineOptionOfPrimitiveType extends CommandLineOptionBase { - type: "string" | "number" | "boolean"; - } - interface CommandLineOptionOfCustomType extends CommandLineOptionBase { - type: Map; - } - interface TsConfigOnlyOption extends CommandLineOptionBase { - type: "object"; - } - interface CommandLineOptionOfListType extends CommandLineOptionBase { - type: "list"; - element: CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType; - } - type CommandLineOption = CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType | TsConfigOnlyOption | CommandLineOptionOfListType; - const enum CharacterCodes { - nullCharacter = 0, - maxAsciiCharacter = 127, - lineFeed = 10, - carriageReturn = 13, - lineSeparator = 8232, - paragraphSeparator = 8233, - nextLine = 133, - space = 32, - nonBreakingSpace = 160, - enQuad = 8192, - emQuad = 8193, - enSpace = 8194, - emSpace = 8195, - threePerEmSpace = 8196, - fourPerEmSpace = 8197, - sixPerEmSpace = 8198, - figureSpace = 8199, - punctuationSpace = 8200, - thinSpace = 8201, - hairSpace = 8202, - zeroWidthSpace = 8203, - narrowNoBreakSpace = 8239, - ideographicSpace = 12288, - mathematicalSpace = 8287, - ogham = 5760, - _ = 95, - $ = 36, - _0 = 48, - _1 = 49, - _2 = 50, - _3 = 51, - _4 = 52, - _5 = 53, - _6 = 54, - _7 = 55, - _8 = 56, - _9 = 57, - a = 97, - b = 98, - c = 99, - d = 100, - e = 101, - f = 102, - g = 103, - h = 104, - i = 105, - j = 106, - k = 107, - l = 108, - m = 109, - n = 110, - o = 111, - p = 112, - q = 113, - r = 114, - s = 115, - t = 116, - u = 117, - v = 118, - w = 119, - x = 120, - y = 121, - z = 122, - A = 65, - B = 66, - C = 67, - D = 68, - E = 69, - F = 70, - G = 71, - H = 72, - I = 73, - J = 74, - K = 75, - L = 76, - M = 77, - N = 78, - O = 79, - P = 80, - Q = 81, - R = 82, - S = 83, - T = 84, - U = 85, - V = 86, - W = 87, - X = 88, - Y = 89, - Z = 90, - ampersand = 38, - asterisk = 42, - at = 64, - backslash = 92, - backtick = 96, - bar = 124, - caret = 94, - closeBrace = 125, - closeBracket = 93, - closeParen = 41, - colon = 58, - comma = 44, - dot = 46, - doubleQuote = 34, - equals = 61, - exclamation = 33, - greaterThan = 62, - hash = 35, - lessThan = 60, - minus = 45, - openBrace = 123, - openBracket = 91, - openParen = 40, - percent = 37, - plus = 43, - question = 63, - semicolon = 59, - singleQuote = 39, - slash = 47, - tilde = 126, - backspace = 8, - formFeed = 12, - byteOrderMark = 65279, - tab = 9, - verticalTab = 11, - } interface ModuleResolutionHost { fileExists(fileName: string): boolean; readFile(fileName: string): string; @@ -3375,7 +2028,6 @@ declare namespace ts { } interface ResolvedModuleWithFailedLookupLocations { resolvedModule: ResolvedModuleFull | undefined; - failedLookupLocations: string[]; } interface ResolvedTypeReferenceDirective { primary: boolean; @@ -3401,157 +2053,6 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; getEnvironmentVariable?(name: string): string; } - const enum TransformFlags { - None = 0, - TypeScript = 1, - ContainsTypeScript = 2, - ContainsJsx = 4, - ContainsESNext = 8, - ContainsES2017 = 16, - ContainsES2016 = 32, - ES2015 = 64, - ContainsES2015 = 128, - Generator = 256, - ContainsGenerator = 512, - DestructuringAssignment = 1024, - ContainsDestructuringAssignment = 2048, - ContainsDecorators = 4096, - ContainsPropertyInitializer = 8192, - ContainsLexicalThis = 16384, - ContainsCapturedLexicalThis = 32768, - ContainsLexicalThisInComputedPropertyName = 65536, - ContainsDefaultValueAssignments = 131072, - ContainsParameterPropertyAssignments = 262144, - ContainsSpread = 524288, - ContainsObjectSpread = 1048576, - ContainsRest = 524288, - ContainsObjectRest = 1048576, - ContainsComputedPropertyName = 2097152, - ContainsBlockScopedBinding = 4194304, - ContainsBindingPattern = 8388608, - ContainsYield = 16777216, - ContainsHoistedDeclarationOrCompletion = 33554432, - HasComputedFlags = 536870912, - AssertTypeScript = 3, - AssertJsx = 4, - AssertESNext = 8, - AssertES2017 = 16, - AssertES2016 = 32, - AssertES2015 = 192, - AssertGenerator = 768, - AssertDestructuringAssignment = 3072, - NodeExcludes = 536872257, - ArrowFunctionExcludes = 601249089, - FunctionExcludes = 601281857, - ConstructorExcludes = 601015617, - MethodOrAccessorExcludes = 601015617, - ClassExcludes = 539358529, - ModuleExcludes = 574674241, - TypeExcludes = -3, - ObjectLiteralExcludes = 540087617, - ArrayLiteralOrCallOrNewExcludes = 537396545, - VariableDeclarationListExcludes = 546309441, - ParameterExcludes = 536872257, - CatchClauseExcludes = 537920833, - BindingPatternExcludes = 537396545, - TypeScriptClassSyntaxMask = 274432, - ES2015FunctionSyntaxMask = 163840, - } - interface EmitNode { - annotatedNodes?: Node[]; - flags?: EmitFlags; - commentRange?: TextRange; - sourceMapRange?: TextRange; - tokenSourceMapRanges?: Map; - constantValue?: number; - externalHelpersModuleName?: Identifier; - helpers?: EmitHelper[]; - } - const enum EmitFlags { - SingleLine = 1, - AdviseOnEmitNode = 2, - NoSubstitution = 4, - CapturesThis = 8, - NoLeadingSourceMap = 16, - NoTrailingSourceMap = 32, - NoSourceMap = 48, - NoNestedSourceMaps = 64, - NoTokenLeadingSourceMaps = 128, - NoTokenTrailingSourceMaps = 256, - NoTokenSourceMaps = 384, - NoLeadingComments = 512, - NoTrailingComments = 1024, - NoComments = 1536, - NoNestedComments = 2048, - HelperName = 4096, - ExportName = 8192, - LocalName = 16384, - Indented = 32768, - NoIndentation = 65536, - AsyncFunctionBody = 131072, - ReuseTempVariableScope = 262144, - CustomPrologue = 524288, - NoHoisting = 1048576, - HasEndOfDeclarationMarker = 2097152, - } - interface EmitHelper { - readonly name: string; - readonly scoped: boolean; - readonly text: string; - readonly priority?: number; - } - const enum ExternalEmitHelpers { - Extends = 1, - Assign = 2, - Rest = 4, - Decorate = 8, - Metadata = 16, - Param = 32, - Awaiter = 64, - Generator = 128, - FirstEmitHelper = 1, - LastEmitHelper = 128, - } - const enum EmitContext { - SourceFile = 0, - Expression = 1, - IdentifierName = 2, - Unspecified = 3, - } - interface EmitHost extends ScriptReferenceHost { - getSourceFiles(): SourceFile[]; - isSourceFileFromExternalLibrary(file: SourceFile): boolean; - getCommonSourceDirectory(): string; - getCanonicalFileName(fileName: string): string; - getNewLine(): string; - isEmitBlocked(emitFileName: string): boolean; - writeFile: WriteFileCallback; - } - interface TransformationContext { - getCompilerOptions(): CompilerOptions; - getEmitResolver(): EmitResolver; - getEmitHost(): EmitHost; - startLexicalEnvironment(): void; - suspendLexicalEnvironment(): void; - resumeLexicalEnvironment(): void; - endLexicalEnvironment(): Statement[]; - hoistFunctionDeclaration(node: FunctionDeclaration): void; - hoistVariableDeclaration(node: Identifier): void; - requestEmitHelper(helper: EmitHelper): void; - readEmitHelpers(): EmitHelper[] | undefined; - enableSubstitution(kind: SyntaxKind): void; - isSubstitutionEnabled(node: Node): boolean; - onSubstituteNode?: (emitContext: EmitContext, node: Node) => Node; - enableEmitNotification(kind: SyntaxKind): void; - isEmitNotificationEnabled(node: Node): boolean; - onEmitNode?: (emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) => void; - } - interface TransformationResult { - transformed: SourceFile[]; - emitNodeWithSubstitution(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; - emitNodeWithNotification(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; - } - type Transformer = (context: TransformationContext) => (node: SourceFile) => SourceFile; interface TextSpan { start: number; length: number; @@ -3560,235 +2061,13 @@ declare namespace ts { span: TextSpan; newLength: number; } - interface DiagnosticCollection { - add(diagnostic: Diagnostic): void; - getGlobalDiagnostics(): Diagnostic[]; - getDiagnostics(fileName?: string): Diagnostic[]; - getModificationCount(): number; - reattachFileDiagnostics(newFile: SourceFile): void; - } interface SyntaxList extends Node { _children: Node[]; } } -declare namespace ts { - const timestamp: () => number; -} -declare namespace ts.performance { - function mark(markName: string): void; - function measure(measureName: string, startMarkName?: string, endMarkName?: string): void; - function getCount(markName: string): number; - function getDuration(measureName: string): number; - function forEachMeasure(cb: (measureName: string, duration: number) => void): void; - function enable(): void; - function disable(): void; -} declare namespace ts { const version = "2.2.0"; } -declare namespace ts { - const enum Ternary { - False = 0, - Maybe = 1, - True = -1, - } - const collator: { - compare(a: string, b: string): number; - }; - function createMap(template?: MapLike): Map; - function createFileMap(keyMapper?: (key: string) => string): FileMap; - function toPath(fileName: string, basePath: string, getCanonicalFileName: (path: string) => string): Path; - const enum Comparison { - LessThan = -1, - EqualTo = 0, - GreaterThan = 1, - } - function forEach(array: T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined; - function zipWith(arrayA: T[], arrayB: U[], callback: (a: T, b: U, index: number) => void): void; - function every(array: T[], callback: (element: T, index: number) => boolean): boolean; - function find(array: T[], predicate: (element: T, index: number) => boolean): T | undefined; - function findMap(array: T[], callback: (element: T, index: number) => U | undefined): U; - function contains(array: T[], value: T): boolean; - function indexOf(array: T[], value: T): number; - function indexOfAnyCharCode(text: string, charCodes: number[], start?: number): number; - function countWhere(array: T[], predicate: (x: T, i: number) => boolean): number; - function filter(array: T[], f: (x: T) => x is U): U[]; - function filter(array: T[], f: (x: T) => boolean): T[]; - function removeWhere(array: T[], f: (x: T) => boolean): boolean; - function filterMutate(array: T[], f: (x: T) => boolean): void; - function map(array: T[], f: (x: T, i: number) => U): U[]; - function sameMap(array: T[], f: (x: T, i: number) => T): T[]; - function flatten(array: (T | T[])[]): T[]; - function flatMap(array: T[], mapfn: (x: T, i: number) => U | U[]): U[]; - function span(array: T[], f: (x: T, i: number) => boolean): [T[], T[]]; - function spanMap(array: T[], keyfn: (x: T, i: number) => K, mapfn: (chunk: T[], key: K, start: number, end: number) => U): U[]; - function mapObject(object: MapLike, f: (key: string, x: T) => [string, U]): MapLike; - function some(array: T[], predicate?: (value: T) => boolean): boolean; - function concatenate(array1: T[], array2: T[]): T[]; - function deduplicate(array: T[], areEqual?: (a: T, b: T) => boolean): T[]; - function arrayIsEqualTo(array1: ReadonlyArray, array2: ReadonlyArray, equaler?: (a: T, b: T) => boolean): boolean; - function changesAffectModuleResolution(oldOptions: CompilerOptions, newOptions: CompilerOptions): boolean; - function compact(array: T[]): T[]; - function relativeComplement(arrayA: T[] | undefined, arrayB: T[] | undefined, comparer?: (x: T, y: T) => Comparison, offsetA?: number, offsetB?: number): T[] | undefined; - function sum(array: any[], prop: string): number; - function append(to: T[] | undefined, value: T | undefined): T[] | undefined; - function addRange(to: T[] | undefined, from: T[] | undefined): T[] | undefined; - function stableSort(array: T[], comparer?: (x: T, y: T) => Comparison): T[]; - function rangeEquals(array1: T[], array2: T[], pos: number, end: number): boolean; - function firstOrUndefined(array: T[]): T; - function lastOrUndefined(array: T[]): T; - function singleOrUndefined(array: T[]): T; - function singleOrMany(array: T[]): T | T[]; - function replaceElement(array: T[], index: number, value: T): T[]; - function binarySearch(array: T[], value: T, comparer?: (v1: T, v2: T) => number, offset?: number): number; - function reduceLeft(array: T[], f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U; - function reduceLeft(array: T[], f: (memo: T, value: T, i: number) => T): T; - function reduceRight(array: T[], f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U; - function reduceRight(array: T[], f: (memo: T, value: T, i: number) => T): T; - function hasProperty(map: MapLike, key: string): boolean; - function getProperty(map: MapLike, key: string): T | undefined; - function getOwnKeys(map: MapLike): string[]; - function forEachProperty(map: Map, callback: (value: T, key: string) => U): U; - function someProperties(map: Map, predicate?: (value: T, key: string) => boolean): boolean; - function copyProperties(source: Map, target: MapLike): void; - function appendProperty(map: Map, key: string | number, value: T): Map; - function assign, T2, T3>(t: T1, arg1: T2, arg2: T3): T1 & T2 & T3; - function assign, T2>(t: T1, arg1: T2): T1 & T2; - function assign>(t: T1, ...args: any[]): any; - function reduceProperties(map: Map, callback: (aggregate: U, value: T, key: string) => U, initial: U): U; - function equalOwnProperties(left: MapLike, right: MapLike, equalityComparer?: (left: T, right: T) => boolean): boolean; - function arrayToMap(array: T[], makeKey: (value: T) => string): Map; - function arrayToMap(array: T[], makeKey: (value: T) => string, makeValue: (value: T) => U): Map; - function isEmpty(map: Map): boolean; - function cloneMap(map: Map): Map; - function clone(object: T): T; - function extend(first: T1, second: T2): T1 & T2; - function multiMapAdd(map: Map, key: string | number, value: V): V[]; - function multiMapRemove(map: Map, key: string, value: V): void; - function isArray(value: any): value is any[]; - function noop(): void; - function notImplemented(): never; - function memoize(callback: () => T): () => T; - function chain(...args: ((t: T) => (u: U) => U)[]): (t: T) => (u: U) => U; - function compose(...args: ((t: T) => T)[]): (t: T) => T; - let localizedDiagnosticMessages: Map; - function getLocaleSpecificMessage(message: DiagnosticMessage): string; - function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic; - function formatMessage(_dummy: any, message: DiagnosticMessage): string; - function createCompilerDiagnostic(message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic; - function createCompilerDiagnosticFromMessageChain(chain: DiagnosticMessageChain): Diagnostic; - function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain; - function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain; - function compareValues(a: T, b: T): Comparison; - function compareStrings(a: string, b: string, ignoreCase?: boolean): Comparison; - function compareStringsCaseInsensitive(a: string, b: string): Comparison; - function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): Comparison; - function sortAndDeduplicateDiagnostics(diagnostics: Diagnostic[]): Diagnostic[]; - function deduplicateSortedDiagnostics(diagnostics: Diagnostic[]): Diagnostic[]; - function normalizeSlashes(path: string): string; - function getRootLength(path: string): number; - const directorySeparator = "/"; - function normalizePath(path: string): string; - function pathEndsWithDirectorySeparator(path: string): boolean; - function getDirectoryPath(path: Path): Path; - function getDirectoryPath(path: string): string; - function isUrl(path: string): boolean; - function isExternalModuleNameRelative(moduleName: string): boolean; - function getEmitScriptTarget(compilerOptions: CompilerOptions): ScriptTarget; - function getEmitModuleKind(compilerOptions: CompilerOptions): ModuleKind; - function getEmitModuleResolutionKind(compilerOptions: CompilerOptions): ModuleResolutionKind; - function hasZeroOrOneAsteriskCharacter(str: string): boolean; - function isRootedDiskPath(path: string): boolean; - function convertToRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string; - function getNormalizedPathComponents(path: string, currentDirectory: string): string[]; - function getNormalizedAbsolutePath(fileName: string, currentDirectory: string): string; - function getNormalizedPathFromPathComponents(pathComponents: string[]): string; - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean): string; - function getBaseFileName(path: string): string; - function combinePaths(path1: string, path2: string): string; - function removeTrailingDirectorySeparator(path: string): string; - function ensureTrailingDirectorySeparator(path: string): string; - function comparePaths(a: string, b: string, currentDirectory: string, ignoreCase?: boolean): Comparison; - function containsPath(parent: string, child: string, currentDirectory: string, ignoreCase?: boolean): boolean; - function startsWith(str: string, prefix: string): boolean; - function endsWith(str: string, suffix: string): boolean; - function hasExtension(fileName: string): boolean; - function fileExtensionIs(path: string, extension: string): boolean; - function fileExtensionIsAny(path: string, extensions: string[]): boolean; - function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude"): string; - function isImplicitGlob(lastPathComponent: string): boolean; - interface FileSystemEntries { - files: string[]; - directories: string[]; - } - interface FileMatcherPatterns { - includeFilePattern: string; - includeDirectoryPattern: string; - excludePattern: string; - basePaths: string[]; - } - function getFileMatcherPatterns(path: string, excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns; - function matchFiles(path: string, extensions: string[], excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string, getFileSystemEntries: (path: string) => FileSystemEntries): string[]; - function ensureScriptKind(fileName: string, scriptKind?: ScriptKind): ScriptKind; - function getScriptKindFromFileName(fileName: string): ScriptKind; - const supportedTypeScriptExtensions: string[]; - const supportedTypescriptExtensionsForExtractExtension: string[]; - const supportedJavascriptExtensions: string[]; - function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]): string[]; - function hasJavaScriptFileExtension(fileName: string): boolean; - function hasTypeScriptFileExtension(fileName: string): boolean; - function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]): boolean; - const enum ExtensionPriority { - TypeScriptFiles = 0, - DeclarationAndJavaScriptFiles = 2, - Limit = 5, - Highest = 0, - Lowest = 2, - } - function getExtensionPriority(path: string, supportedExtensions: string[]): ExtensionPriority; - function adjustExtensionPriority(extensionPriority: ExtensionPriority): ExtensionPriority; - function getNextLowestExtensionPriority(extensionPriority: ExtensionPriority): ExtensionPriority; - function removeFileExtension(path: string): string; - function tryRemoveExtension(path: string, extension: string): string | undefined; - function removeExtension(path: string, extension: string): string; - function changeExtension(path: T, newExtension: string): T; - interface ObjectAllocator { - getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node; - getTokenConstructor(): new (kind: TKind, pos?: number, end?: number) => Token; - getIdentifierConstructor(): new (kind: SyntaxKind.Identifier, pos?: number, end?: number) => Identifier; - getSourceFileConstructor(): new (kind: SyntaxKind.SourceFile, pos?: number, end?: number) => SourceFile; - getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol; - getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type; - getSignatureConstructor(): new (checker: TypeChecker) => Signature; - } - let objectAllocator: ObjectAllocator; - const enum AssertionLevel { - None = 0, - Normal = 1, - Aggressive = 2, - VeryAggressive = 3, - } - namespace Debug { - let currentAssertionLevel: AssertionLevel; - function shouldAssert(level: AssertionLevel): boolean; - function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void; - function fail(message?: string): void; - } - function orderedRemoveItem(array: T[], item: T): boolean; - function orderedRemoveItemAt(array: T[], index: number): void; - function unorderedRemoveItemAt(array: T[], index: number): void; - function unorderedRemoveItem(array: T[], item: T): void; - function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): (fileName: string) => string; - function matchPatternOrExact(patternStrings: string[], candidate: string): string | Pattern | undefined; - function patternText({prefix, suffix}: Pattern): string; - function matchedText(pattern: Pattern, candidate: string): string; - function findBestPatternMatch(values: T[], getPattern: (value: T) => Pattern, candidate: string): T | undefined; - function tryParsePattern(pattern: string): Pattern | undefined; - function positionIsSynthesized(pos: number): boolean; - function extensionIsTypeScript(ext: Extension): boolean; - function extensionFromPath(path: string): Extension; - function tryGetExtensionFromPath(path: string): Extension | undefined; -} declare namespace ts { type FileWatcherCallback = (fileName: string, removed?: boolean) => void; type DirectoryWatcherCallback = (fileName: string) => void; @@ -3820,8 +2099,6 @@ declare namespace ts { getMemoryUsage?(): number; exit(exitCode?: number): void; realpath?(path: string): string; - getEnvironmentVariable(name: string): string; - tryEnableSourceMapsForHost?(): void; setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; clearTimeout?(timeoutId: any): void; } @@ -3834,4863 +2111,10 @@ declare namespace ts { } let sys: System; } -declare namespace ts { - const Diagnostics: { - Unterminated_string_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Identifier_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_file_cannot_have_a_reference_to_itself: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Trailing_comma_not_allowed: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Asterisk_Slash_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unexpected_token: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_parameter_must_be_last_in_a_parameter_list: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_cannot_have_question_mark_and_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_required_parameter_cannot_follow_an_optional_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_cannot_have_a_rest_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_cannot_have_an_accessibility_modifier: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_cannot_have_a_question_mark: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_must_have_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_must_have_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_type_must_be_string_or_number: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Accessibility_modifier_already_seen: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_must_precede_1_modifier: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_already_seen: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_class_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_must_be_followed_by_an_argument_list_or_member_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_ambient_modules_can_use_quoted_names: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Statements_are_not_allowed_in_ambient_contexts: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializers_are_not_allowed_in_ambient_contexts: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_be_used_in_an_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_be_used_with_a_class_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_be_used_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_data_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_module_or_namespace_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_0_modifier_cannot_be_used_with_an_interface_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_parameter_cannot_be_optional: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_parameter_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_must_have_exactly_one_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_cannot_have_an_optional_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_parameter_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_cannot_have_rest_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_get_accessor_cannot_have_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_async_function_or_method_must_have_a_valid_awaitable_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Operand_for_await_does_not_have_a_valid_callable_then_member: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_member_must_have_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_assignment_cannot_be_used_in_a_namespace: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_type_member: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_an_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_0_modifier_cannot_be_used_with_an_import_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_reference_directive_syntax: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_accessor_cannot_be_declared_in_an_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_constructor_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameters_cannot_appear_on_a_constructor_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_annotation_cannot_appear_on_a_constructor_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_accessor_cannot_have_type_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_cannot_have_a_return_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_must_have_exactly_one_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_argument_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_use_of_0_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - with_statements_are_not_allowed_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - delete_cannot_be_called_on_an_identifier_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Jump_target_cannot_cross_function_boundary: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_return_statement_can_only_be_used_within_a_function_body: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_label_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_assignment_cannot_have_modifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Octal_literals_are_not_allowed_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_tuple_type_element_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_declaration_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Digit_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Hexadecimal_digit_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unexpected_end_of_text: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_character: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Declaration_or_statement_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Statement_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - case_or_default_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_or_signature_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_member_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_declaration_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Argument_expression_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_assignment_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_or_comma_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_declaration_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_declaration_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_argument_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - String_literal_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Line_break_not_permitted_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - or_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Declaration_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_declarations_in_a_namespace_cannot_reference_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_name_0_differs_from_already_included_file_name_1_only_in_casing: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_declarations_must_be_initialized: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_declarations_can_only_be_declared_inside_a_block: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - let_declarations_can_only_be_declared_inside_a_block: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unterminated_template_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unterminated_regular_expression_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_object_member_cannot_be_declared_optional: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_yield_expression_is_only_allowed_in_a_generator_body: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Computed_property_names_are_not_allowed_in_enums: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_comma_expression_is_not_allowed_in_a_computed_property_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - extends_clause_already_seen: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - extends_clause_must_precede_implements_clause: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Classes_can_only_extend_a_single_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - implements_clause_already_seen: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Interface_declaration_cannot_have_implements_clause: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Binary_digit_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Octal_digit_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unexpected_token_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_destructuring_pattern_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Array_element_destructuring_pattern_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_destructuring_declaration_must_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_implementation_cannot_be_declared_in_ambient_contexts: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Modifiers_cannot_appear_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Merge_conflict_marker_encountered: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_element_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_parameter_property_may_not_be_declared_using_a_binding_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_import_declaration_cannot_have_modifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_has_no_default_export: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_declaration_cannot_have_modifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Export_declarations_are_not_permitted_in_a_namespace: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Catch_clause_variable_cannot_have_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Catch_clause_variable_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unterminated_Unicode_escape_sequence: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Line_terminator_not_permitted_before_arrow: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Decorators_are_not_valid_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_declaration_without_the_default_modifier_must_have_a_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Identifier_expected_0_is_a_reserved_word_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Export_assignment_is_not_supported_when_module_flag_is_system: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generators_are_not_allowed_in_an_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_overload_signature_cannot_be_declared_as_a_generator: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_tag_already_specified: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Signature_0_must_have_a_type_predicate: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_parameter_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_predicate_0_is_not_assignable_to_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_is_not_in_the_same_position_as_parameter_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_predicate_cannot_reference_a_rest_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_assignment_can_only_be_used_in_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_import_declaration_can_only_be_used_in_a_namespace_or_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_declaration_can_only_be_used_in_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_be_used_with_1_modifier: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Abstract_methods_can_only_appear_within_an_abstract_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_interface_property_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_literal_property_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_member_cannot_have_the_0_keyword: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_decorator_can_only_decorate_a_method_implementation_not_an_overload: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - with_statements_are_not_allowed_in_an_async_function_block: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - await_expression_is_only_allowed_within_an_async_function: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_body_of_an_if_statement_cannot_be_the_empty_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_module_exports_may_only_appear_in_module_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_module_exports_may_only_appear_in_declaration_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_module_exports_may_only_appear_at_top_level: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_parameter_property_cannot_be_declared_using_a_rest_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_abstract_accessor_cannot_have_an_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Static_members_cannot_reference_class_type_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Circular_definition_of_import_alias_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_has_no_exported_member_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_is_not_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_module_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_recursively_references_itself_as_a_base_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_may_only_extend_another_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_interface_may_only_extend_a_class_or_another_interface: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_has_a_circular_constraint: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generic_type_0_requires_1_type_argument_s: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_generic: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_type_0_must_be_a_class_or_interface_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_type_0_must_have_1_type_parameter_s: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_global_type_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Named_property_0_of_types_1_and_2_are_not_identical: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Interface_0_cannot_simultaneously_extend_types_1_and_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Excessive_stack_depth_comparing_types_0_and_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_assignable_to_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_redeclare_exported_variable_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_missing_in_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_private_in_type_1_but_not_in_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Types_of_property_0_are_incompatible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_optional_in_type_1_but_required_in_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Types_of_parameters_0_and_1_are_incompatible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Index_signature_is_missing_in_type_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Index_signatures_are_incompatible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_a_module_or_namespace_body: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_current_location: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_constructor_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_a_static_property_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_can_only_be_referenced_in_a_derived_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_cannot_be_referenced_in_constructor_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_does_not_exist_on_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_private_and_only_accessible_within_class_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_does_not_satisfy_the_constraint_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Supplied_parameters_do_not_match_any_signature_of_call_target: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Untyped_function_calls_may_not_accept_type_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_a_void_function_can_be_called_with_the_new_keyword: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_cannot_be_converted_to_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Operator_0_cannot_be_applied_to_types_1_and_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_parameter_property_is_only_allowed_in_a_constructor_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_parameter_must_be_of_an_array_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_cannot_be_referenced_in_its_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_string_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_number_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Constructors_for_derived_classes_must_contain_a_super_call: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_get_accessor_must_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Getter_and_setter_accessors_do_not_agree_in_visibility: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - get_and_set_accessor_must_have_the_same_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_signature_with_an_implementation_cannot_use_a_string_literal_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_exported_or_non_exported: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_ambient_or_non_ambient: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_public_private_or_protected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_optional_or_required: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_overload_must_be_static: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_overload_must_not_be_static: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_implementation_name_must_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Constructor_implementation_is_missing: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_implementation_is_missing_or_not_immediately_following_the_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Multiple_constructor_implementations_are_not_allowed: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_function_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signature_is_not_compatible_with_function_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Declaration_name_conflicts_with_built_in_global_identifier_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Setters_cannot_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_incorrectly_extends_base_class_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_static_side_0_incorrectly_extends_base_class_static_side_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_incorrectly_implements_interface_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_may_only_implement_another_class_or_interface: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Interface_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - All_declarations_of_0_must_have_identical_type_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Interface_0_incorrectly_extends_interface_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Ambient_module_declaration_cannot_specify_relative_module_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_declaration_conflicts_with_local_declaration_of_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Types_have_separate_declarations_of_a_private_property_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_protected_in_type_1_but_public_in_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Block_scoped_variable_0_used_before_its_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_redeclare_block_scoped_variable_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_enum_member_cannot_have_a_numeric_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_0_is_used_before_being_assigned: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_alias_0_circularly_references_itself: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_alias_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_AMD_module_cannot_have_multiple_name_assignments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_has_no_property_1_and_no_string_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_has_no_property_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_an_array_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_element_must_be_last_in_a_destructuring_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_a_computed_property_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_cannot_be_referenced_in_a_computed_property_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_global_value_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_0_operator_cannot_be_applied_to_type_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_declarations_must_all_be_const_or_non_const: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - In_const_enum_declarations_member_initializer_must_be_constant_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_const_enum_member_can_only_be_accessed_using_a_string_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_does_not_exist_on_const_enum_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Export_declaration_conflicts_with_exported_declaration_of_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_iterator_must_have_a_next_method: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_redeclare_identifier_0_in_catch_clause: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_an_array_type_or_a_string_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_element_cannot_contain_a_binding_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_namespace_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_generator_cannot_have_a_void_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_a_constructor_function_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - No_base_constructor_has_the_specified_number_of_type_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Base_constructor_return_type_0_is_not_a_class_or_interface_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Base_constructors_must_all_have_the_same_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_create_an_instance_of_the_abstract_class_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_abstract_or_non_abstract: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Classes_containing_abstract_methods_must_be_marked_abstract: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - All_declarations_of_an_abstract_method_must_be_consecutive: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - yield_expressions_cannot_be_used_in_a_parameter_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - await_expressions_cannot_be_used_in_a_parameter_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_module_cannot_have_multiple_default_exports: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_incompatible_with_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_is_possibly_null: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_is_possibly_undefined: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_is_possibly_null_or_undefined: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_function_returning_never_cannot_have_a_reachable_end_point: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_type_0_has_members_with_initializers_that_are_not_literals: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_cannot_be_used_to_index_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_has_no_matching_index_signature_for_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_cannot_be_used_as_an_index_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_assign_to_0_because_it_is_not_a_variable: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Index_signature_in_type_0_only_permits_reading: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_attributes_type_0_may_not_be_a_union_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_in_type_1_is_not_assignable_to_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_global_type_JSX_0_may_not_have_more_than_one_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_emit_namespaced_JSX_elements_in_React: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_expressions_must_have_one_parent_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_provides_no_match_for_the_signature_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_name_0_Did_you_mean_the_static_member_1_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_name_0_Did_you_mean_the_instance_member_this_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_module_name_in_augmentation_module_0_cannot_be_found: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exports_and_export_assignments_are_not_permitted_in_module_augmentations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_assign_a_0_constructor_type_to_a_1_constructor_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_extend_a_class_0_Class_constructor_is_marked_as_private: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Accessors_must_both_be_abstract_or_non_abstract: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_comparable_to_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_this_parameter_must_be_the_first_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_constructor_cannot_have_a_this_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - get_and_set_accessor_must_have_the_same_this_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_this_types_of_each_signature_are_incompatible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - All_declarations_of_0_must_have_identical_modifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_type_definition_file_for_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_extend_an_interface_0_Did_you_mean_implements: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_must_be_declared_after_its_base_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Namespace_0_has_no_exported_member_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Left_side_of_comma_operator_is_unused_and_has_no_side_effects: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Spread_types_may_only_be_created_from_object_types: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Rest_types_may_only_be_created_from_object_types: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_declaration_0_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_variable_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_property_0_of_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_exported_function_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_exported_function_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_type_alias_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Default_export_of_the_module_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_current_host_does_not_support_the_0_option: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_the_common_subdirectory_path_for_the_input_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_read_file_0_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unsupported_file_encoding: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Failed_to_parse_file_0_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unknown_compiler_option_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Compiler_option_0_requires_a_value_of_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Could_not_write_file_0_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_cannot_be_specified_without_specifying_option_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_cannot_be_specified_with_option_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_tsconfig_json_file_is_already_defined_at_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_write_file_0_because_it_would_overwrite_input_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_specified_path_does_not_exist_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_paths_cannot_be_used_without_specifying_baseUrl_option: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Pattern_0_can_have_at_most_one_Asterisk_character: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Substitutions_for_pattern_0_should_be_an_array: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Substitutions_for_pattern_0_shouldn_t_be_an_empty_array: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Concatenate_and_emit_output_to_single_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generates_corresponding_d_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Watch_input_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Redirect_output_structure_to_the_directory: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_erase_const_enum_declarations_in_generated_code: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_outputs_if_any_errors_were_reported: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_comments_to_output: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_outputs: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Skip_type_checking_of_declaration_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Print_this_message: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Print_the_compiler_s_version: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Compile_the_project_in_the_given_directory: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Syntax_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - options: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Examples_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Options_Colon: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Version_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Insert_command_line_options_and_files_from_a_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_change_detected_Starting_incremental_compilation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - KIND: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - FILE: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - VERSION: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - LOCATION: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - DIRECTORY: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - STRATEGY: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Compilation_complete_Watching_for_file_changes: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generates_corresponding_map_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Compiler_option_0_expects_an_argument: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unterminated_quoted_string_in_response_file_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Argument_for_0_option_must_be_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unsupported_locale_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_open_file_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Corrupted_locale_file_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_not_found: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - NEWLINE: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_can_only_be_specified_in_tsconfig_json_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enables_experimental_support_for_ES7_decorators: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enables_experimental_support_for_emitting_type_metadata_for_decorators: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enables_experimental_support_for_ES7_async_functions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Successfully_created_a_tsconfig_json_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Suppress_excess_property_checks_for_object_literals: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Stylize_errors_and_messages_using_color_and_context_experimental: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_report_errors_on_unused_labels: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Report_error_when_not_all_code_paths_in_function_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Report_errors_for_fallthrough_cases_in_switch_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_report_errors_on_unreachable_code: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Disallow_inconsistently_cased_references_to_the_same_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_library_files_to_be_included_in_the_compilation_Colon: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_JSX_code_generation_Colon_preserve_or_react: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_amd_and_system_modules_are_supported_alongside_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Base_directory_to_resolve_non_absolute_module_names: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enable_tracing_of_the_name_resolution_process: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_module_0_from_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Explicitly_specified_module_resolution_kind_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_resolution_kind_is_not_specified_using_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_name_0_was_successfully_resolved_to_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_name_0_was_not_resolved: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_name_0_matched_pattern_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Trying_substitution_0_candidate_module_location_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_module_name_0_relative_to_base_url_1_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Loading_module_as_file_Slash_folder_candidate_module_location_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_does_not_exist: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_exist_use_it_as_a_name_resolution_result: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Loading_module_0_from_node_modules_folder: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Found_package_json_at_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - package_json_does_not_have_a_types_or_main_field: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - package_json_has_0_field_1_that_references_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Allow_javascript_files_to_be_compiled: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_should_have_array_of_strings_as_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Checking_if_0_is_the_longest_matching_prefix_for_1_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expected_type_of_0_field_in_package_json_to_be_string_got_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Longest_matching_prefix_for_0_is_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Loading_0_from_the_root_dir_1_candidate_location_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Trying_other_entries_in_rootDirs: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_resolution_using_rootDirs_has_failed: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_use_strict_directives_in_module_output: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enable_strict_null_checks: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unknown_option_excludes_Did_you_mean_exclude: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Raise_error_on_this_expressions_with_an_implied_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_type_reference_directive_0_containing_file_1_root_directory_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_using_primary_search_paths: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_from_node_modules_folder: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_reference_directive_0_was_not_resolved: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_with_primary_search_path_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Root_directory_cannot_be_determined_skipping_primary_search_paths: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_declaration_files_to_be_included_in_compilation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Looking_up_in_node_modules_folder_initial_location_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_config_file_0_found_doesn_t_contain_any_source_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_real_path_for_0_result_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_name_0_has_a_1_extension_stripping_it: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_declared_but_never_used: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Report_errors_on_unused_locals: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Report_errors_on_unused_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - No_types_specified_in_package_json_so_returning_main_value_of_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_declared_but_never_used: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_emit_helpers_from_tslib: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_was_resolved_to_1_but_jsx_is_not_set: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_was_resolved_to_1_but_allowJs_is_not_set: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Member_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_literal_s_property_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Rest_parameter_0_implicitly_has_an_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _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: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - 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: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unreachable_code_detected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unused_label: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Fallthrough_case_in_switch: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Not_all_code_paths_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Binding_element_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - You_cannot_rename_this_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - import_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - export_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - type_parameter_declarations_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - implements_clauses_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - interface_declarations_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - module_declarations_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - type_aliases_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - types_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - type_arguments_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - parameter_modifiers_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - enum_declarations_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - type_assertion_expressions_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - class_expressions_are_not_currently_supported: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Language_service_is_disabled: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_attributes_must_only_be_assigned_a_non_empty_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expected_corresponding_JSX_closing_tag_for_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_attribute_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_0_has_no_corresponding_closing_tag: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unknown_type_acquisition_option_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Circularity_detected_while_resolving_configuration_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_files_list_in_config_file_0_is_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Add_missing_super_call: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Make_super_call_the_first_statement_in_the_constructor: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Change_extends_to_implements: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Remove_unused_identifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implement_interface_on_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implement_interface_on_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implement_inherited_abstract_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_0_from_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Change_0_to_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Add_0_to_existing_import_declaration_from_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - }; -} declare namespace ts { interface ErrorCallback { (message: DiagnosticMessage, length: number): void; } - function tokenIsIdentifierOrKeyword(token: SyntaxKind): boolean; interface Scanner { getStartPos(): number; getToken(): SyntaxKind; @@ -8722,24 +2146,13 @@ declare namespace ts { scanRange(start: number, length: number, callback: () => T): T; tryScan(callback: () => T): T; } - function isUnicodeIdentifierStart(code: number, languageVersion: ScriptTarget): boolean; function tokenToString(t: SyntaxKind): string; - function stringToToken(s: string): SyntaxKind; - function computeLineStarts(text: string): number[]; function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number; - function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number; - function getLineStarts(sourceFile: SourceFile): number[]; - function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): { - line: number; - character: number; - }; function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; function isWhiteSpace(ch: number): boolean; function isWhiteSpaceSingleLine(ch: number): boolean; function isLineBreak(ch: number): boolean; - function isOctalDigit(ch: number): boolean; function couldStartTrivia(text: string, pos: number): boolean; - function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean, stopAtComments?: boolean): number; function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; @@ -8749,23 +2162,9 @@ declare namespace ts { function getShebang(text: string): string; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; - function isIdentifierText(name: string, languageVersion: ScriptTarget): boolean; function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } declare namespace ts { - const compileOnSaveCommandLineOption: CommandLineOption; - const optionDeclarations: CommandLineOption[]; - let typeAcquisitionDeclarations: CommandLineOption[]; - interface OptionNameMap { - optionNameMap: Map; - shortOptionNames: Map; - } - const defaultInitCompilerOptions: CompilerOptions; - function convertEnableAutoDiscoveryToEnable(typeAcquisition: TypeAcquisition): TypeAcquisition; - function getOptionNameMap(): OptionNameMap; - function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic; - function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]): string | number; - function parseListTypeOption(opt: CommandLineOptionOfListType, value: string, errors: Diagnostic[]): (string | number)[] | undefined; function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine; function readConfigFile(fileName: string, readFile: (path: string) => string): { config?: any; @@ -8775,9 +2174,6 @@ declare namespace ts { config?: any; error?: Diagnostic; }; - function generateTSConfig(options: CompilerOptions, fileNames: string[]): { - compilerOptions: Map; - }; function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: FileExtensionInfo[]): ParsedCommandLine; function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { @@ -8789,114 +2185,7 @@ declare namespace ts { errors: Diagnostic[]; }; } -declare namespace ts.JsTyping { - interface TypingResolutionHost { - directoryExists: (path: string) => boolean; - fileExists: (fileName: string) => boolean; - readFile: (path: string, encoding?: string) => string; - readDirectory: (rootDir: string, extensions: string[], excludes: string[], includes: string[], depth?: number) => string[]; - } - const nodeCoreModuleList: ReadonlyArray; - function discoverTypings(host: TypingResolutionHost, fileNames: string[], projectRootPath: Path, safeListPath: Path, packageNameToTypingLocation: Map, typeAcquisition: TypeAcquisition, unresolvedImports: ReadonlyArray): { - cachedTypingPaths: string[]; - newTypingNames: string[]; - filesToWatch: string[]; - }; -} -declare namespace ts.server { - const ActionSet: ActionSet; - const ActionInvalidate: ActionInvalidate; - const EventBeginInstallTypes: EventBeginInstallTypes; - const EventEndInstallTypes: EventEndInstallTypes; - namespace Arguments { - const GlobalCacheLocation = "--globalTypingsCacheLocation"; - const LogFile = "--logFile"; - const EnableTelemetry = "--enableTelemetry"; - } - function hasArgument(argumentName: string): boolean; - function findArgument(argumentName: string): string; -} -declare namespace ts.server { - enum LogLevel { - terse = 0, - normal = 1, - requestTime = 2, - verbose = 3, - } - const emptyArray: ReadonlyArray; - interface Logger { - close(): void; - hasLevel(level: LogLevel): boolean; - loggingEnabled(): boolean; - perftrc(s: string): void; - info(s: string): void; - startGroup(): void; - endGroup(): void; - msg(s: string, type?: Msg.Types): void; - getLogFileName(): string; - } - namespace Msg { - type Err = "Err"; - const Err: Err; - type Info = "Info"; - const Info: Info; - type Perf = "Perf"; - const Perf: Perf; - type Types = Err | Info | Perf; - } - function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, cachePath?: string): DiscoverTypings; - namespace Errors { - function ThrowNoProject(): never; - function ThrowProjectLanguageServiceDisabled(): never; - function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never; - } - function getDefaultFormatCodeSettings(host: ServerHost): FormatCodeSettings; - function mergeMaps(target: MapLike, source: MapLike): void; - function removeItemFromSet(items: T[], itemToRemove: T): void; - type NormalizedPath = string & { - __normalizedPathTag: any; - }; - function toNormalizedPath(fileName: string): NormalizedPath; - function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path; - function asNormalizedPath(fileName: string): NormalizedPath; - interface NormalizedPathMap { - get(path: NormalizedPath): T; - set(path: NormalizedPath, value: T): void; - contains(path: NormalizedPath): boolean; - remove(path: NormalizedPath): void; - } - function createNormalizedPathMap(): NormalizedPathMap; - interface ProjectOptions { - configHasFilesProperty?: boolean; - files?: string[]; - wildcardDirectories?: Map; - compilerOptions?: CompilerOptions; - typeAcquisition?: TypeAcquisition; - compileOnSave?: boolean; - } - function isInferredProjectName(name: string): boolean; - function makeInferredProjectName(counter: number): string; - function toSortedReadonlyArray(arr: string[]): SortedReadonlyArray; - class ThrottledOperations { - private readonly host; - private pendingTimeouts; - constructor(host: ServerHost); - schedule(operationId: string, delay: number, cb: () => void): void; - private static run(self, operationId, cb); - } - class GcTimer { - private readonly host; - private readonly delay; - private readonly logger; - private timerId; - constructor(host: ServerHost, delay: number, logger: Logger); - scheduleCollect(): void; - private static run(self); - } -} declare namespace ts { - function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void; - function isTraceEnabled(compilerOptions: CompilerOptions, host: ModuleResolutionHost): boolean; function moduleHasNonRelativeName(moduleName: string): boolean; function getEffectiveTypeRoots(options: CompilerOptions, host: { directoryExists?: (directoryName: string) => boolean; @@ -8904,392 +2193,20 @@ declare namespace ts { }): string[] | undefined; function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function directoryProbablyExists(directoryName: string, host: { - directoryExists?: (directoryName: string) => boolean; - }): boolean; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function loadModuleFromGlobalCache(moduleName: string, projectName: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, globalCache: string): ResolvedModuleWithFailedLookupLocations; -} -declare namespace ts { - const externalHelpersModuleNameText = "tslib"; - interface ReferencePathMatchResult { - fileReference?: FileReference; - diagnosticMessage?: DiagnosticMessage; - isNoDefaultLib?: boolean; - isTypeReferenceDirective?: boolean; + interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { + getOrCreateCacheForDirectory(directoryName: string): Map; } - function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration; - interface StringSymbolWriter extends SymbolWriter { - string(): string; + interface NonRelativeModuleNameResolutionCache { + getOrCreateCacheForModuleName(nonRelativeModuleName: string): PerModuleNameCache; } - function getSingleLineStringWriter(): StringSymbolWriter; - function releaseStringWriter(writer: StringSymbolWriter): void; - function getFullWidth(node: Node): number; - function hasResolvedModule(sourceFile: SourceFile, moduleNameText: string): boolean; - function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModuleFull; - function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModuleFull): void; - function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective): void; - function moduleResolutionIsEqualTo(oldResolution: ResolvedModuleFull, newResolution: ResolvedModuleFull): boolean; - function typeDirectiveIsEqualTo(oldResolution: ResolvedTypeReferenceDirective, newResolution: ResolvedTypeReferenceDirective): boolean; - function hasChangesInResolutions(names: string[], newResolutions: T[], oldResolutions: Map, comparer: (oldResolution: T, newResolution: T) => boolean): boolean; - function containsParseError(node: Node): boolean; - function getSourceFileOfNode(node: Node): SourceFile; - function isStatementWithLocals(node: Node): boolean; - function getStartPositionOfLine(line: number, sourceFile: SourceFile): number; - function nodePosToString(node: Node): string; - function getStartPosOfNode(node: Node): number; - function isDefined(value: any): boolean; - function getEndLinePosition(line: number, sourceFile: SourceFile): number; - function nodeIsMissing(node: Node): boolean; - function nodeIsPresent(node: Node): boolean; - function getTokenPosOfNode(node: Node, sourceFile?: SourceFile, includeJsDoc?: boolean): number; - function isJSDocNode(node: Node): boolean; - function isJSDocTag(node: Node): boolean; - function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFile): number; - function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node, includeTrivia?: boolean): string; - function getTextOfNodeFromSourceText(sourceText: string, node: Node): string; - function getTextOfNode(node: Node, includeTrivia?: boolean): string; - function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile, languageVersion: ScriptTarget): string; - function isBinaryOrOctalIntegerLiteral(node: LiteralLikeNode, text: string): boolean; - function escapeIdentifier(identifier: string): string; - function unescapeIdentifier(identifier: string): string; - function makeIdentifierFromModuleName(moduleName: string): string; - function isBlockOrCatchScoped(declaration: Declaration): boolean; - function isCatchClauseVariableDeclarationOrBindingElement(declaration: Declaration): boolean; - function isAmbientModule(node: Node): boolean; - function isShorthandAmbientModuleSymbol(moduleSymbol: Symbol): boolean; - function isBlockScopedContainerTopLevel(node: Node): boolean; - function isGlobalScopeAugmentation(module: ModuleDeclaration): boolean; - function isExternalModuleAugmentation(node: Node): boolean; - function isEffectiveExternalModule(node: SourceFile, compilerOptions: CompilerOptions): boolean; - function isBlockScope(node: Node, parentNode: Node): boolean; - function getEnclosingBlockScopeContainer(node: Node): Node; - function declarationNameToString(name: DeclarationName): string; - function getTextOfPropertyName(name: PropertyName): string; - function entityNameToString(name: EntityNameOrEntityNameExpression): string; - function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): Diagnostic; - function createDiagnosticForNodeInSourceFile(sourceFile: SourceFile, node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): Diagnostic; - function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain): Diagnostic; - function getSpanOfTokenAtPosition(sourceFile: SourceFile, pos: number): TextSpan; - function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan; - function isExternalOrCommonJsModule(file: SourceFile): boolean; - function isDeclarationFile(file: SourceFile): boolean; - function isConstEnumDeclaration(node: Node): boolean; - function isConst(node: Node): boolean; - function isLet(node: Node): boolean; - function isSuperCall(n: Node): n is SuperCall; - function isPrologueDirective(node: Node): node is PrologueDirective; - function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile): CommentRange[]; - function getLeadingCommentRangesOfNodeFromText(node: Node, text: string): CommentRange[]; - function getJSDocCommentRanges(node: Node, text: string): CommentRange[]; - let fullTripleSlashReferencePathRegEx: RegExp; - let fullTripleSlashReferenceTypeReferenceDirectiveRegEx: RegExp; - let fullTripleSlashAMDReferencePathRegEx: RegExp; - function isPartOfTypeNode(node: Node): boolean; - function forEachReturnStatement(body: Block, visitor: (stmt: ReturnStatement) => T): T; - function forEachYieldExpression(body: Block, visitor: (expr: YieldExpression) => void): void; - function getRestParameterElementType(node: TypeNode): TypeNode; - function isVariableLike(node: Node): node is VariableLikeDeclaration; - function isAccessor(node: Node): node is AccessorDeclaration; - function isClassLike(node: Node): node is ClassLikeDeclaration; - function isFunctionLike(node: Node): node is FunctionLikeDeclaration; - function isFunctionLikeKind(kind: SyntaxKind): boolean; - function introducesArgumentsExoticObject(node: Node): boolean; - function isIterationStatement(node: Node, lookInLabeledStatements: boolean): node is IterationStatement; - function isFunctionBlock(node: Node): boolean; - function isObjectLiteralMethod(node: Node): node is MethodDeclaration; - function isObjectLiteralOrClassExpressionMethod(node: Node): node is MethodDeclaration; - function isIdentifierTypePredicate(predicate: TypePredicate): predicate is IdentifierTypePredicate; - function isThisTypePredicate(predicate: TypePredicate): predicate is ThisTypePredicate; - function getContainingFunction(node: Node): FunctionLikeDeclaration; - function getContainingClass(node: Node): ClassLikeDeclaration; - function getThisContainer(node: Node, includeArrowFunctions: boolean): Node; - function getSuperContainer(node: Node, stopOnFunctions: boolean): Node; - function getImmediatelyInvokedFunctionExpression(func: Node): CallExpression; - function isSuperProperty(node: Node): node is SuperProperty; - function getEntityNameFromTypeNode(node: TypeNode): EntityNameOrEntityNameExpression; - function isCallLikeExpression(node: Node): node is CallLikeExpression; - function getInvokedExpression(node: CallLikeExpression): Expression; - function nodeCanBeDecorated(node: Node): boolean; - function nodeIsDecorated(node: Node): boolean; - function nodeOrChildIsDecorated(node: Node): boolean; - function childIsDecorated(node: Node): boolean; - function isJSXTagName(node: Node): boolean; - function isPartOfExpression(node: Node): boolean; - function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean; - function isExternalModuleImportEqualsDeclaration(node: Node): boolean; - function getExternalModuleImportEqualsDeclarationExpression(node: Node): Expression; - function isInternalModuleImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration; - function isSourceFileJavaScript(file: SourceFile): boolean; - function isInJavaScriptFile(node: Node): boolean; - function isRequireCall(expression: Node, checkArgumentIsStringLiteral: boolean): expression is CallExpression; - function isSingleOrDoubleQuote(charCode: number): boolean; - function isDeclarationOfFunctionExpression(s: Symbol): boolean; - function getSpecialPropertyAssignmentKind(expression: Node): SpecialPropertyAssignmentKind; - function getExternalModuleName(node: Node): Expression; - function getNamespaceDeclarationNode(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): ImportEqualsDeclaration | NamespaceImport; - function isDefaultImport(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): boolean; - function hasQuestionToken(node: Node): boolean; - function isJSDocConstructSignature(node: Node): boolean; - function getCommentsFromJSDoc(node: Node): string[]; - function getJSDocParameterTags(param: Node): JSDocParameterTag[]; - function getJSDocType(node: Node): JSDocType; - function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag; - function getJSDocReturnTag(node: Node): JSDocReturnTag; - function getJSDocTemplateTag(node: Node): JSDocTemplateTag; - function hasRestParameter(s: SignatureDeclaration): boolean; - function hasDeclaredRestParameter(s: SignatureDeclaration): boolean; - function isRestParameter(node: ParameterDeclaration): boolean; - function isDeclaredRestParam(node: ParameterDeclaration): boolean; - const enum AssignmentKind { - None = 0, - Definite = 1, - Compound = 2, + interface PerModuleNameCache { + get(directory: string): ResolvedModuleWithFailedLookupLocations; + set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; } - function getAssignmentTargetKind(node: Node): AssignmentKind; - function isAssignmentTarget(node: Node): boolean; - function isNodeDescendantOf(node: Node, ancestor: Node): boolean; - function isInAmbientContext(node: Node): boolean; - function isDeclarationName(name: Node): boolean; - function isLiteralComputedPropertyDeclarationName(node: Node): boolean; - function isIdentifierName(node: Identifier): boolean; - function isAliasSymbolDeclaration(node: Node): boolean; - function exportAssignmentIsAlias(node: ExportAssignment): boolean; - function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration | InterfaceDeclaration): ExpressionWithTypeArguments; - function getClassImplementsHeritageClauseElements(node: ClassLikeDeclaration): NodeArray; - function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray; - function getHeritageClause(clauses: NodeArray, kind: SyntaxKind): HeritageClause; - function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference): SourceFile; - function getAncestor(node: Node, kind: SyntaxKind): Node; - function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult; - function isKeyword(token: SyntaxKind): boolean; - function isTrivia(token: SyntaxKind): boolean; - function isAsyncFunctionLike(node: Node): boolean; - function isStringOrNumericLiteral(node: Node): node is StringLiteral | NumericLiteral; - function hasDynamicName(declaration: Declaration): boolean; - function isDynamicName(name: DeclarationName): boolean; - function isWellKnownSymbolSyntactically(node: Expression): boolean; - function getPropertyNameForPropertyNameNode(name: DeclarationName | ParameterDeclaration): string; - function getPropertyNameForKnownSymbolName(symbolName: string): string; - function isESSymbolIdentifier(node: Node): boolean; - function isPushOrUnshiftIdentifier(node: Identifier): boolean; - function isModifierKind(token: SyntaxKind): boolean; - function isParameterDeclaration(node: VariableLikeDeclaration): boolean; - function getRootDeclaration(node: Node): Node; - function nodeStartsNewLexicalEnvironment(node: Node): boolean; - function nodeIsSynthesized(node: TextRange): boolean; - function getOriginalNode(node: Node): Node; - function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; - function isParseTreeNode(node: Node): boolean; - function getParseTreeNode(node: Node): Node; - function getParseTreeNode(node: Node, nodeTest?: (node: Node) => node is T): T; - function getOriginalSourceFiles(sourceFiles: SourceFile[]): SourceFile[]; - function getOriginalNodeId(node: Node): number; - const enum Associativity { - Left = 0, - Right = 1, - } - function getExpressionAssociativity(expression: Expression): Associativity; - function getOperatorAssociativity(kind: SyntaxKind, operator: SyntaxKind, hasArguments?: boolean): Associativity; - function getExpressionPrecedence(expression: Expression): 0 | 1 | -1 | 2 | 4 | 3 | 16 | 10 | 5 | 6 | 11 | 8 | 19 | 18 | 17 | 15 | 14 | 13 | 12 | 9 | 7; - function getOperator(expression: Expression): SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.NumericLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.Identifier | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.LetKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.StaticKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AbstractKeyword | SyntaxKind.AsKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.GetKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.NumberKeyword | SyntaxKind.SetKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.TypeKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.FromKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.OfKeyword | SyntaxKind.QualifiedName | SyntaxKind.ComputedPropertyName | SyntaxKind.TypeParameter | SyntaxKind.Parameter | SyntaxKind.Decorator | SyntaxKind.PropertySignature | SyntaxKind.PropertyDeclaration | SyntaxKind.MethodSignature | SyntaxKind.MethodDeclaration | SyntaxKind.Constructor | SyntaxKind.GetAccessor | SyntaxKind.SetAccessor | SyntaxKind.CallSignature | SyntaxKind.ConstructSignature | SyntaxKind.IndexSignature | SyntaxKind.TypePredicate | SyntaxKind.TypeReference | SyntaxKind.FunctionType | SyntaxKind.ConstructorType | SyntaxKind.TypeQuery | SyntaxKind.TypeLiteral | SyntaxKind.ArrayType | SyntaxKind.TupleType | SyntaxKind.UnionType | SyntaxKind.IntersectionType | SyntaxKind.ParenthesizedType | SyntaxKind.ThisType | SyntaxKind.TypeOperator | SyntaxKind.IndexedAccessType | SyntaxKind.MappedType | SyntaxKind.LiteralType | SyntaxKind.ObjectBindingPattern | SyntaxKind.ArrayBindingPattern | SyntaxKind.BindingElement | SyntaxKind.ArrayLiteralExpression | SyntaxKind.ObjectLiteralExpression | SyntaxKind.PropertyAccessExpression | SyntaxKind.ElementAccessExpression | SyntaxKind.CallExpression | SyntaxKind.NewExpression | SyntaxKind.TaggedTemplateExpression | SyntaxKind.TypeAssertionExpression | SyntaxKind.ParenthesizedExpression | SyntaxKind.FunctionExpression | SyntaxKind.ArrowFunction | SyntaxKind.DeleteExpression | SyntaxKind.TypeOfExpression | SyntaxKind.VoidExpression | SyntaxKind.AwaitExpression | SyntaxKind.ConditionalExpression | SyntaxKind.TemplateExpression | SyntaxKind.YieldExpression | SyntaxKind.SpreadElement | SyntaxKind.ClassExpression | SyntaxKind.OmittedExpression | SyntaxKind.ExpressionWithTypeArguments | SyntaxKind.AsExpression | SyntaxKind.NonNullExpression | SyntaxKind.TemplateSpan | SyntaxKind.SemicolonClassElement | SyntaxKind.Block | SyntaxKind.VariableStatement | SyntaxKind.EmptyStatement | SyntaxKind.ExpressionStatement | SyntaxKind.IfStatement | SyntaxKind.DoStatement | SyntaxKind.WhileStatement | SyntaxKind.ForStatement | SyntaxKind.ForInStatement | SyntaxKind.ForOfStatement | SyntaxKind.ContinueStatement | SyntaxKind.BreakStatement | SyntaxKind.ReturnStatement | SyntaxKind.WithStatement | SyntaxKind.SwitchStatement | SyntaxKind.LabeledStatement | SyntaxKind.ThrowStatement | SyntaxKind.TryStatement | SyntaxKind.DebuggerStatement | SyntaxKind.VariableDeclaration | SyntaxKind.VariableDeclarationList | SyntaxKind.FunctionDeclaration | SyntaxKind.ClassDeclaration | SyntaxKind.InterfaceDeclaration | SyntaxKind.TypeAliasDeclaration | SyntaxKind.EnumDeclaration | SyntaxKind.ModuleDeclaration | SyntaxKind.ModuleBlock | SyntaxKind.CaseBlock | SyntaxKind.NamespaceExportDeclaration | SyntaxKind.ImportEqualsDeclaration | SyntaxKind.ImportDeclaration | SyntaxKind.ImportClause | SyntaxKind.NamespaceImport | SyntaxKind.NamedImports | SyntaxKind.ImportSpecifier | SyntaxKind.ExportAssignment | SyntaxKind.ExportDeclaration | SyntaxKind.NamedExports | SyntaxKind.ExportSpecifier | SyntaxKind.MissingDeclaration | SyntaxKind.ExternalModuleReference | SyntaxKind.JsxElement | SyntaxKind.JsxSelfClosingElement | SyntaxKind.JsxOpeningElement | SyntaxKind.JsxClosingElement | SyntaxKind.JsxAttribute | SyntaxKind.JsxSpreadAttribute | SyntaxKind.JsxExpression | SyntaxKind.CaseClause | SyntaxKind.DefaultClause | SyntaxKind.HeritageClause | SyntaxKind.CatchClause | SyntaxKind.PropertyAssignment | SyntaxKind.ShorthandPropertyAssignment | SyntaxKind.SpreadAssignment | SyntaxKind.EnumMember | SyntaxKind.SourceFile | SyntaxKind.JSDocTypeExpression | SyntaxKind.JSDocAllType | SyntaxKind.JSDocUnknownType | SyntaxKind.JSDocArrayType | SyntaxKind.JSDocUnionType | SyntaxKind.JSDocTupleType | SyntaxKind.JSDocNullableType | SyntaxKind.JSDocNonNullableType | SyntaxKind.JSDocRecordType | SyntaxKind.JSDocRecordMember | SyntaxKind.JSDocTypeReference | SyntaxKind.JSDocOptionalType | SyntaxKind.JSDocFunctionType | SyntaxKind.JSDocVariadicType | SyntaxKind.JSDocConstructorType | SyntaxKind.JSDocThisType | SyntaxKind.JSDocComment | SyntaxKind.JSDocTag | SyntaxKind.JSDocAugmentsTag | SyntaxKind.JSDocParameterTag | SyntaxKind.JSDocReturnTag | SyntaxKind.JSDocTypeTag | SyntaxKind.JSDocTemplateTag | SyntaxKind.JSDocTypedefTag | SyntaxKind.JSDocPropertyTag | SyntaxKind.JSDocTypeLiteral | SyntaxKind.JSDocLiteralType | SyntaxKind.JSDocNullKeyword | SyntaxKind.JSDocUndefinedKeyword | SyntaxKind.JSDocNeverKeyword | SyntaxKind.SyntaxList | SyntaxKind.NotEmittedStatement | SyntaxKind.PartiallyEmittedExpression | SyntaxKind.MergeDeclarationMarker | SyntaxKind.EndOfDeclarationMarker | SyntaxKind.RawExpression | SyntaxKind.Count; - function getOperatorPrecedence(nodeKind: SyntaxKind, operatorKind: SyntaxKind, hasArguments?: boolean): 0 | 1 | -1 | 2 | 4 | 3 | 16 | 10 | 5 | 6 | 11 | 8 | 19 | 18 | 17 | 15 | 14 | 13 | 12 | 9 | 7; - function createDiagnosticCollection(): DiagnosticCollection; - function escapeString(s: string): string; - function isIntrinsicJsxName(name: string): boolean; - function escapeNonAsciiCharacters(s: string): string; - interface EmitTextWriter { - write(s: string): void; - writeTextOfNode(text: string, node: Node): void; - writeLine(): void; - increaseIndent(): void; - decreaseIndent(): void; - getText(): string; - rawWrite(s: string): void; - writeLiteral(s: string): void; - getTextPos(): number; - getLine(): number; - getColumn(): number; - getIndent(): number; - isAtStartOfLine(): boolean; - reset(): void; - } - function getIndentString(level: number): string; - function getIndentSize(): number; - function createTextWriter(newLine: String): EmitTextWriter; - function getResolvedExternalModuleName(host: EmitHost, file: SourceFile): string; - function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): string; - function getExternalModuleNameFromPath(host: EmitHost, fileName: string): string; - function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string): string; - function getDeclarationEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost): string; - interface EmitFileNames { - jsFilePath: string; - sourceMapFilePath: string; - declarationFilePath: string; - } - function getSourceFilesToEmit(host: EmitHost, targetSourceFile?: SourceFile): SourceFile[]; - function filterSourceFilesInDirectory(sourceFiles: SourceFile[], isSourceFileFromExternalLibrary: (file: SourceFile) => boolean): SourceFile[]; - function forEachTransformedEmitFile(host: EmitHost, sourceFiles: SourceFile[], action: (jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) => void, emitOnlyDtsFiles?: boolean): void; - function forEachExpectedEmitFile(host: EmitHost, action: (emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean, emitOnlyDtsFiles: boolean) => void, targetSourceFile?: SourceFile, emitOnlyDtsFiles?: boolean): void; - function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string): string; - function writeFile(host: EmitHost, diagnostics: DiagnosticCollection, fileName: string, data: string, writeByteOrderMark: boolean, sourceFiles?: SourceFile[]): void; - function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number): number; - function getLineOfLocalPositionFromLineMap(lineMap: number[], pos: number): number; - function getFirstConstructorWithBody(node: ClassLikeDeclaration): ConstructorDeclaration; - function getSetAccessorTypeAnnotationNode(accessor: SetAccessorDeclaration): TypeNode; - function getThisParameter(signature: SignatureDeclaration): ParameterDeclaration | undefined; - function parameterIsThisKeyword(parameter: ParameterDeclaration): boolean; - function isThisIdentifier(node: Node | undefined): boolean; - function identifierIsThisKeyword(id: Identifier): boolean; - interface AllAccessorDeclarations { - firstAccessor: AccessorDeclaration; - secondAccessor: AccessorDeclaration; - getAccessor: AccessorDeclaration; - setAccessor: AccessorDeclaration; - } - function getAllAccessorDeclarations(declarations: NodeArray, accessor: AccessorDeclaration): AllAccessorDeclarations; - function emitNewLineBeforeLeadingComments(lineMap: number[], writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]): void; - function emitNewLineBeforeLeadingCommentsOfPosition(lineMap: number[], writer: EmitTextWriter, pos: number, leadingComments: CommentRange[]): void; - function emitNewLineBeforeLeadingCommentOfPosition(lineMap: number[], writer: EmitTextWriter, pos: number, commentPos: number): void; - function emitComments(text: string, lineMap: number[], writer: EmitTextWriter, comments: CommentRange[], leadingSeparator: boolean, trailingSeparator: boolean, newLine: string, writeComment: (text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) => void): void; - function emitDetachedComments(text: string, lineMap: number[], writer: EmitTextWriter, writeComment: (text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) => void, node: TextRange, newLine: string, removeComments: boolean): { - nodePos: number; - detachedCommentEndPos: number; - }; - function writeCommentRange(text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string): void; - function hasModifiers(node: Node): boolean; - function hasModifier(node: Node, flags: ModifierFlags): boolean; - function getModifierFlags(node: Node): ModifierFlags; - function modifierToFlag(token: SyntaxKind): ModifierFlags; - function isLogicalOperator(token: SyntaxKind): boolean; - function isAssignmentOperator(token: SyntaxKind): boolean; - function tryGetClassExtendingExpressionWithTypeArguments(node: Node): ClassLikeDeclaration | undefined; - function isAssignmentExpression(node: Node, excludeCompoundAssignment: true): node is AssignmentExpression; - function isAssignmentExpression(node: Node, excludeCompoundAssignment?: false): node is AssignmentExpression; - function isDestructuringAssignment(node: Node): node is DestructuringAssignment; - function isSupportedExpressionWithTypeArguments(node: ExpressionWithTypeArguments): boolean; - function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean; - function isEntityNameExpression(node: Expression): node is EntityNameExpression; - function isRightSideOfQualifiedNameOrPropertyAccess(node: Node): boolean; - function isEmptyObjectLiteralOrArrayLiteral(expression: Node): boolean; - function getLocalSymbolForExportDefault(symbol: Symbol): Symbol; - function tryExtractTypeScriptExtension(fileName: string): string | undefined; - function convertToBase64(input: string): string; - function getNewLineCharacter(options: CompilerOptions): string; - function isSimpleExpression(node: Expression): boolean; - function formatSyntaxKind(kind: SyntaxKind): string; - function movePos(pos: number, value: number): number; - function createRange(pos: number, end: number): TextRange; - function moveRangeEnd(range: TextRange, end: number): TextRange; - function moveRangePos(range: TextRange, pos: number): TextRange; - function moveRangePastDecorators(node: Node): TextRange; - function moveRangePastModifiers(node: Node): TextRange; - function isCollapsedRange(range: TextRange): boolean; - function collapseRangeToStart(range: TextRange): TextRange; - function collapseRangeToEnd(range: TextRange): TextRange; - function createTokenRange(pos: number, token: SyntaxKind): TextRange; - function rangeIsOnSingleLine(range: TextRange, sourceFile: SourceFile): boolean; - function rangeStartPositionsAreOnSameLine(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; - function rangeEndPositionsAreOnSameLine(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; - function rangeStartIsOnSameLineAsRangeEnd(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; - function rangeEndIsOnSameLineAsRangeStart(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; - function positionsAreOnSameLine(pos1: number, pos2: number, sourceFile: SourceFile): boolean; - function getStartPositionOfRange(range: TextRange, sourceFile: SourceFile): number; - function isDeclarationNameOfEnumOrNamespace(node: Identifier): boolean; - function getInitializedVariables(node: VariableDeclarationList): VariableDeclaration[]; - function isMergedWithClass(node: Node): boolean; - function isFirstDeclarationOfKind(node: Node, kind: SyntaxKind): boolean; - function isNodeArray(array: T[]): array is NodeArray; - function isNoSubstitutionTemplateLiteral(node: Node): node is LiteralExpression; - function isLiteralKind(kind: SyntaxKind): boolean; - function isTextualLiteralKind(kind: SyntaxKind): boolean; - function isLiteralExpression(node: Node): node is LiteralExpression; - function isTemplateLiteralKind(kind: SyntaxKind): boolean; - function isTemplateHead(node: Node): node is TemplateHead; - function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail; - function isIdentifier(node: Node): node is Identifier; - function isGeneratedIdentifier(node: Node): node is GeneratedIdentifier; - function isModifier(node: Node): node is Modifier; - function isQualifiedName(node: Node): node is QualifiedName; - function isComputedPropertyName(node: Node): node is ComputedPropertyName; - function isEntityName(node: Node): node is EntityName; - function isPropertyName(node: Node): node is PropertyName; - function isModuleName(node: Node): node is ModuleName; - function isBindingName(node: Node): node is BindingName; - function isTypeParameter(node: Node): node is TypeParameterDeclaration; - function isParameter(node: Node): node is ParameterDeclaration; - function isDecorator(node: Node): node is Decorator; - function isMethodDeclaration(node: Node): node is MethodDeclaration; - function isClassElement(node: Node): node is ClassElement; - function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike; - function isTypeNode(node: Node): node is TypeNode; - function isArrayBindingPattern(node: Node): node is ArrayBindingPattern; - function isObjectBindingPattern(node: Node): node is ObjectBindingPattern; - function isBindingPattern(node: Node): node is BindingPattern; - function isAssignmentPattern(node: Node): node is AssignmentPattern; - function isBindingElement(node: Node): node is BindingElement; - function isArrayBindingElement(node: Node): node is ArrayBindingElement; - function isDeclarationBindingElement(bindingElement: BindingOrAssignmentElement): bindingElement is VariableDeclaration | ParameterDeclaration | BindingElement; - function isBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is BindingOrAssignmentPattern; - function isObjectBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is ObjectBindingOrAssignmentPattern; - function isArrayBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is ArrayBindingOrAssignmentPattern; - function isArrayLiteralExpression(node: Node): node is ArrayLiteralExpression; - function isObjectLiteralExpression(node: Node): node is ObjectLiteralExpression; - function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression; - function isElementAccessExpression(node: Node): node is ElementAccessExpression; - function isBinaryExpression(node: Node): node is BinaryExpression; - function isConditionalExpression(node: Node): node is ConditionalExpression; - function isCallExpression(node: Node): node is CallExpression; - function isTemplateLiteral(node: Node): node is TemplateLiteral; - function isSpreadExpression(node: Node): node is SpreadElement; - function isExpressionWithTypeArguments(node: Node): node is ExpressionWithTypeArguments; - function isLeftHandSideExpression(node: Node): node is LeftHandSideExpression; - function isUnaryExpression(node: Node): node is UnaryExpression; - function isExpression(node: Node): node is Expression; - function isAssertionExpression(node: Node): node is AssertionExpression; - function isPartiallyEmittedExpression(node: Node): node is PartiallyEmittedExpression; - function isNotEmittedStatement(node: Node): node is NotEmittedStatement; - function isNotEmittedOrPartiallyEmittedNode(node: Node): node is NotEmittedStatement | PartiallyEmittedExpression; - function isOmittedExpression(node: Node): node is OmittedExpression; - function isTemplateSpan(node: Node): node is TemplateSpan; - function isBlock(node: Node): node is Block; - function isConciseBody(node: Node): node is ConciseBody; - function isFunctionBody(node: Node): node is FunctionBody; - function isForInitializer(node: Node): node is ForInitializer; - function isVariableDeclaration(node: Node): node is VariableDeclaration; - function isVariableDeclarationList(node: Node): node is VariableDeclarationList; - function isCaseBlock(node: Node): node is CaseBlock; - function isModuleBody(node: Node): node is ModuleBody; - function isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration; - function isImportClause(node: Node): node is ImportClause; - function isNamedImportBindings(node: Node): node is NamedImportBindings; - function isImportSpecifier(node: Node): node is ImportSpecifier; - function isNamedExports(node: Node): node is NamedExports; - function isExportSpecifier(node: Node): node is ExportSpecifier; - function isModuleOrEnumDeclaration(node: Node): node is ModuleDeclaration | EnumDeclaration; - function isDeclaration(node: Node): node is Declaration; - function isDeclarationStatement(node: Node): node is DeclarationStatement; - function isStatementButNotDeclaration(node: Node): node is Statement; - function isStatement(node: Node): node is Statement; - function isModuleReference(node: Node): node is ModuleReference; - function isJsxOpeningElement(node: Node): node is JsxOpeningElement; - function isJsxClosingElement(node: Node): node is JsxClosingElement; - function isJsxTagNameExpression(node: Node): node is JsxTagNameExpression; - function isJsxChild(node: Node): node is JsxChild; - function isJsxAttributeLike(node: Node): node is JsxAttributeLike; - function isJsxSpreadAttribute(node: Node): node is JsxSpreadAttribute; - function isJsxAttribute(node: Node): node is JsxAttribute; - function isStringLiteralOrJsxExpression(node: Node): node is StringLiteral | JsxExpression; - function isCaseOrDefaultClause(node: Node): node is CaseOrDefaultClause; - function isHeritageClause(node: Node): node is HeritageClause; - function isCatchClause(node: Node): node is CatchClause; - function isPropertyAssignment(node: Node): node is PropertyAssignment; - function isShorthandPropertyAssignment(node: Node): node is ShorthandPropertyAssignment; - function isEnumMember(node: Node): node is EnumMember; - function isSourceFile(node: Node): node is SourceFile; - function isWatchSet(options: CompilerOptions): boolean; + function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): ModuleResolutionCache; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -9322,317 +2239,6 @@ declare namespace ts { readFile(fileName: string): string; }, errors?: Diagnostic[]): void; } -declare namespace ts { - function updateNode(updated: T, original: T): T; - function createNodeArray(elements?: T[], location?: TextRange, hasTrailingComma?: boolean): NodeArray; - function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node; - function createSynthesizedNodeArray(elements?: T[]): NodeArray; - function getSynthesizedClone(node: T): T; - function getMutableClone(node: T): T; - function createLiteral(textSource: StringLiteral | NumericLiteral | Identifier, location?: TextRange): StringLiteral; - function createLiteral(value: string, location?: TextRange): StringLiteral; - function createLiteral(value: number, location?: TextRange): NumericLiteral; - function createLiteral(value: boolean, location?: TextRange): BooleanLiteral; - function createLiteral(value: string | number | boolean, location?: TextRange): PrimaryExpression; - function createIdentifier(text: string, location?: TextRange): Identifier; - function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, location?: TextRange): Identifier; - function createLoopVariable(location?: TextRange): Identifier; - function createUniqueName(text: string, location?: TextRange): Identifier; - function getGeneratedNameForNode(node: Node, location?: TextRange): Identifier; - function createToken(token: TKind): Token; - function createSuper(): PrimaryExpression; - function createThis(location?: TextRange): PrimaryExpression; - function createNull(): PrimaryExpression; - function createComputedPropertyName(expression: Expression, location?: TextRange): ComputedPropertyName; - function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; - function createParameter(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression, location?: TextRange, flags?: NodeFlags): ParameterDeclaration; - function updateParameter(node: ParameterDeclaration, decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: BindingName, type: TypeNode, initializer: Expression): ParameterDeclaration; - function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression, location?: TextRange): PropertyDeclaration; - function updateProperty(node: PropertyDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, type: TypeNode, initializer: Expression): PropertyDeclaration; - function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): MethodDeclaration; - function updateMethod(node: MethodDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; - function createConstructor(decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block, location?: TextRange, flags?: NodeFlags): ConstructorDeclaration; - function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; - function createGetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): GetAccessorDeclaration; - function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; - function createSetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], body: Block, location?: TextRange, flags?: NodeFlags): SetAccessorDeclaration; - function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; - function createObjectBindingPattern(elements: BindingElement[], location?: TextRange): ObjectBindingPattern; - function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]): ObjectBindingPattern; - function createArrayBindingPattern(elements: ArrayBindingElement[], location?: TextRange): ArrayBindingPattern; - function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ArrayBindingElement[]): ArrayBindingPattern; - function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression, location?: TextRange): BindingElement; - function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken, propertyName: PropertyName, name: BindingName, initializer: Expression): BindingElement; - function createArrayLiteral(elements?: Expression[], location?: TextRange, multiLine?: boolean): ArrayLiteralExpression; - function updateArrayLiteral(node: ArrayLiteralExpression, elements: Expression[]): ArrayLiteralExpression; - function createObjectLiteral(properties?: ObjectLiteralElementLike[], location?: TextRange, multiLine?: boolean): ObjectLiteralExpression; - function updateObjectLiteral(node: ObjectLiteralExpression, properties: ObjectLiteralElementLike[]): ObjectLiteralExpression; - function createPropertyAccess(expression: Expression, name: string | Identifier, location?: TextRange, flags?: NodeFlags): PropertyAccessExpression; - function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; - function createElementAccess(expression: Expression, index: number | Expression, location?: TextRange): ElementAccessExpression; - function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[], location?: TextRange, flags?: NodeFlags): CallExpression; - function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; - function createNew(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[], location?: TextRange, flags?: NodeFlags): NewExpression; - function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; - function createTaggedTemplate(tag: Expression, template: TemplateLiteral, location?: TextRange): TaggedTemplateExpression; - function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function createParen(expression: Expression, location?: TextRange): ParenthesizedExpression; - function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): FunctionExpression; - function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; - function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody, location?: TextRange, flags?: NodeFlags): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: ConciseBody): ArrowFunction; - function createDelete(expression: Expression, location?: TextRange): DeleteExpression; - function updateDelete(node: DeleteExpression, expression: Expression): Expression; - function createTypeOf(expression: Expression, location?: TextRange): TypeOfExpression; - function updateTypeOf(node: TypeOfExpression, expression: Expression): Expression; - function createVoid(expression: Expression, location?: TextRange): VoidExpression; - function updateVoid(node: VoidExpression, expression: Expression): VoidExpression; - function createAwait(expression: Expression, location?: TextRange): AwaitExpression; - function updateAwait(node: AwaitExpression, expression: Expression): AwaitExpression; - function createPrefix(operator: PrefixUnaryOperator, operand: Expression, location?: TextRange): PrefixUnaryExpression; - function updatePrefix(node: PrefixUnaryExpression, operand: Expression): PrefixUnaryExpression; - function createPostfix(operand: Expression, operator: PostfixUnaryOperator, location?: TextRange): PostfixUnaryExpression; - function updatePostfix(node: PostfixUnaryExpression, operand: Expression): PostfixUnaryExpression; - function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression, location?: TextRange): BinaryExpression; - function updateBinary(node: BinaryExpression, left: Expression, right: Expression): BinaryExpression; - function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression, location?: TextRange): ConditionalExpression; - function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression, location?: TextRange): ConditionalExpression; - function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; - function createTemplateExpression(head: TemplateHead, templateSpans: TemplateSpan[], location?: TextRange): TemplateExpression; - function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; - function createYield(asteriskToken: AsteriskToken, expression: Expression, location?: TextRange): YieldExpression; - function updateYield(node: YieldExpression, expression: Expression): YieldExpression; - function createSpread(expression: Expression, location?: TextRange): SpreadElement; - function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[], location?: TextRange): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; - function createOmittedExpression(location?: TextRange): OmittedExpression; - function createExpressionWithTypeArguments(typeArguments: TypeNode[], expression: Expression, location?: TextRange): ExpressionWithTypeArguments; - function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; - function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail, location?: TextRange): TemplateSpan; - function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; - function createBlock(statements: Statement[], location?: TextRange, multiLine?: boolean, flags?: NodeFlags): Block; - function updateBlock(node: Block, statements: Statement[]): Block; - function createVariableStatement(modifiers: Modifier[], declarationList: VariableDeclarationList | VariableDeclaration[], location?: TextRange, flags?: NodeFlags): VariableStatement; - function updateVariableStatement(node: VariableStatement, modifiers: Modifier[], declarationList: VariableDeclarationList): VariableStatement; - function createVariableDeclarationList(declarations: VariableDeclaration[], location?: TextRange, flags?: NodeFlags): VariableDeclarationList; - function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList; - function createVariableDeclaration(name: string | BindingPattern | Identifier, type?: TypeNode, initializer?: Expression, location?: TextRange, flags?: NodeFlags): VariableDeclaration; - function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode, initializer: Expression): VariableDeclaration; - function createEmptyStatement(location: TextRange): EmptyStatement; - function createStatement(expression: Expression, location?: TextRange, flags?: NodeFlags): ExpressionStatement; - function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; - function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement, location?: TextRange): IfStatement; - function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement): IfStatement; - function createDo(statement: Statement, expression: Expression, location?: TextRange): DoStatement; - function updateDo(node: DoStatement, statement: Statement, expression: Expression): DoStatement; - function createWhile(expression: Expression, statement: Statement, location?: TextRange): WhileStatement; - function updateWhile(node: WhileStatement, expression: Expression, statement: Statement): WhileStatement; - function createFor(initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement, location?: TextRange): ForStatement; - function updateFor(node: ForStatement, initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; - function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement, location?: TextRange): ForInStatement; - function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; - function createForOf(initializer: ForInitializer, expression: Expression, statement: Statement, location?: TextRange): ForOfStatement; - function updateForOf(node: ForOfStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; - function createContinue(label?: Identifier, location?: TextRange): ContinueStatement; - function updateContinue(node: ContinueStatement, label: Identifier): ContinueStatement; - function createBreak(label?: Identifier, location?: TextRange): BreakStatement; - function updateBreak(node: BreakStatement, label: Identifier): BreakStatement; - function createReturn(expression?: Expression, location?: TextRange): ReturnStatement; - function updateReturn(node: ReturnStatement, expression: Expression): ReturnStatement; - function createWith(expression: Expression, statement: Statement, location?: TextRange): WithStatement; - function updateWith(node: WithStatement, expression: Expression, statement: Statement): WithStatement; - function createSwitch(expression: Expression, caseBlock: CaseBlock, location?: TextRange): SwitchStatement; - function updateSwitch(node: SwitchStatement, expression: Expression, caseBlock: CaseBlock): SwitchStatement; - function createLabel(label: string | Identifier, statement: Statement, location?: TextRange): LabeledStatement; - function updateLabel(node: LabeledStatement, label: Identifier, statement: Statement): LabeledStatement; - function createThrow(expression: Expression, location?: TextRange): ThrowStatement; - function updateThrow(node: ThrowStatement, expression: Expression): ThrowStatement; - function createTry(tryBlock: Block, catchClause: CatchClause, finallyBlock: Block, location?: TextRange): TryStatement; - function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; - function createCaseBlock(clauses: CaseOrDefaultClause[], location?: TextRange): CaseBlock; - function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock; - function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): FunctionDeclaration; - function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; - function createClassDeclaration(decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[], location?: TextRange): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; - function createImportDeclaration(decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier?: Expression, location?: TextRange): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier: Expression): ImportDeclaration; - function createImportClause(name: Identifier, namedBindings: NamedImportBindings, location?: TextRange): ImportClause; - function updateImportClause(node: ImportClause, name: Identifier, namedBindings: NamedImportBindings): ImportClause; - function createNamespaceImport(name: Identifier, location?: TextRange): NamespaceImport; - function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; - function createNamedImports(elements: ImportSpecifier[], location?: TextRange): NamedImports; - function updateNamedImports(node: NamedImports, elements: ImportSpecifier[]): NamedImports; - function createImportSpecifier(propertyName: Identifier, name: Identifier, location?: TextRange): ImportSpecifier; - function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: Decorator[], modifiers: Modifier[], isExportEquals: boolean, expression: Expression, location?: TextRange): ExportAssignment; - function updateExportAssignment(node: ExportAssignment, decorators: Decorator[], modifiers: Modifier[], expression: Expression): ExportAssignment; - function createExportDeclaration(decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier?: Expression, location?: TextRange): ExportDeclaration; - function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier: Expression): ExportDeclaration; - function createNamedExports(elements: ExportSpecifier[], location?: TextRange): NamedExports; - function updateNamedExports(node: NamedExports, elements: ExportSpecifier[]): NamedExports; - function createExportSpecifier(name: string | Identifier, propertyName?: string | Identifier, location?: TextRange): ExportSpecifier; - function updateExportSpecifier(node: ExportSpecifier, name: Identifier, propertyName: Identifier): ExportSpecifier; - function createJsxElement(openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement, location?: TextRange): JsxElement; - function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; - function createJsxSelfClosingElement(tagName: JsxTagNameExpression, attributes: JsxAttributeLike[], location?: TextRange): JsxSelfClosingElement; - function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, attributes: JsxAttributeLike[]): JsxSelfClosingElement; - function createJsxOpeningElement(tagName: JsxTagNameExpression, attributes: JsxAttributeLike[], location?: TextRange): JsxOpeningElement; - function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, attributes: JsxAttributeLike[]): JsxOpeningElement; - function createJsxClosingElement(tagName: JsxTagNameExpression, location?: TextRange): JsxClosingElement; - function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; - function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression, location?: TextRange): JsxAttribute; - function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; - function createJsxSpreadAttribute(expression: Expression, location?: TextRange): JsxSpreadAttribute; - function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; - function createJsxExpression(expression: Expression, location?: TextRange): JsxExpression; - function updateJsxExpression(node: JsxExpression, expression: Expression): JsxExpression; - function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[], location?: TextRange): HeritageClause; - function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause; - function createCaseClause(expression: Expression, statements: Statement[], location?: TextRange): CaseClause; - function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]): CaseClause; - function createDefaultClause(statements: Statement[], location?: TextRange): DefaultClause; - function updateDefaultClause(node: DefaultClause, statements: Statement[]): DefaultClause; - function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block, location?: TextRange): CatchClause; - function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause; - function createPropertyAssignment(name: string | PropertyName, initializer: Expression, location?: TextRange): PropertyAssignment; - function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; - function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer: Expression, location?: TextRange): ShorthandPropertyAssignment; - function createSpreadAssignment(expression: Expression, location?: TextRange): SpreadAssignment; - function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; - function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; - function updateSourceFileNode(node: SourceFile, statements: Statement[]): SourceFile; - function createNotEmittedStatement(original: Node): NotEmittedStatement; - function createEndOfDeclarationMarker(original: Node): EndOfDeclarationMarker; - function createMergeDeclarationMarker(original: Node): MergeDeclarationMarker; - function createPartiallyEmittedExpression(expression: Expression, original?: Node, location?: TextRange): PartiallyEmittedExpression; - function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; - function createRawExpression(text: string): RawExpression; - function createComma(left: Expression, right: Expression): Expression; - function createLessThan(left: Expression, right: Expression, location?: TextRange): Expression; - function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression, location?: TextRange): DestructuringAssignment; - function createAssignment(left: Expression, right: Expression, location?: TextRange): BinaryExpression; - function createStrictEquality(left: Expression, right: Expression): BinaryExpression; - function createStrictInequality(left: Expression, right: Expression): BinaryExpression; - function createAdd(left: Expression, right: Expression): BinaryExpression; - function createSubtract(left: Expression, right: Expression): BinaryExpression; - function createPostfixIncrement(operand: Expression, location?: TextRange): PostfixUnaryExpression; - function createLogicalAnd(left: Expression, right: Expression): BinaryExpression; - function createLogicalOr(left: Expression, right: Expression): BinaryExpression; - function createLogicalNot(operand: Expression): PrefixUnaryExpression; - function createVoidZero(): VoidExpression; - type TypeOfTag = "undefined" | "number" | "boolean" | "string" | "symbol" | "object" | "function"; - function createTypeCheck(value: Expression, tag: TypeOfTag): BinaryExpression; - function createMemberAccessForPropertyName(target: Expression, memberName: PropertyName, location?: TextRange): MemberExpression; - function createFunctionCall(func: Expression, thisArg: Expression, argumentsList: Expression[], location?: TextRange): CallExpression; - function createFunctionApply(func: Expression, thisArg: Expression, argumentsExpression: Expression, location?: TextRange): CallExpression; - function createArraySlice(array: Expression, start?: number | Expression): CallExpression; - function createArrayConcat(array: Expression, values: Expression[]): CallExpression; - function createMathPow(left: Expression, right: Expression, location?: TextRange): CallExpression; - function createExpressionForJsxElement(jsxFactoryEntity: EntityName, reactNamespace: string, tagName: Expression, props: Expression, children: Expression[], parentElement: JsxOpeningLikeElement, location: TextRange): LeftHandSideExpression; - function createExportDefault(expression: Expression): ExportAssignment; - function createExternalModuleExport(exportName: Identifier): ExportDeclaration; - function createLetStatement(name: Identifier, initializer: Expression, location?: TextRange): VariableStatement; - function createLetDeclarationList(declarations: VariableDeclaration[], location?: TextRange): VariableDeclarationList; - function createConstDeclarationList(declarations: VariableDeclaration[], location?: TextRange): VariableDeclarationList; - function getHelperName(name: string): Identifier; - interface CallBinding { - target: LeftHandSideExpression; - thisArg: Expression; - } - function createCallBinding(expression: Expression, recordTempVariable: (temp: Identifier) => void, languageVersion?: ScriptTarget, cacheIdentifiers?: boolean): CallBinding; - function inlineExpressions(expressions: Expression[]): Expression; - function createExpressionFromEntityName(node: EntityName | Expression): Expression; - function createExpressionForPropertyName(memberName: PropertyName): Expression; - function createExpressionForObjectLiteralElementLike(node: ObjectLiteralExpression, property: ObjectLiteralElementLike, receiver: Expression): Expression; - function getLocalName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; - function isLocalName(node: Identifier): boolean; - function getExportName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; - function isExportName(node: Identifier): boolean; - function getDeclarationName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; - function getExternalModuleOrNamespaceExportName(ns: Identifier | undefined, node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier | PropertyAccessExpression; - function getNamespaceMemberName(ns: Identifier, name: Identifier, allowComments?: boolean, allowSourceMaps?: boolean): PropertyAccessExpression; - function convertToFunctionBody(node: ConciseBody, multiLine?: boolean): Block; - function addPrologueDirectives(target: Statement[], source: Statement[], ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult): number; - function startsWithUseStrict(statements: Statement[]): boolean; - function ensureUseStrict(statements: NodeArray): NodeArray; - function parenthesizeBinaryOperand(binaryOperator: SyntaxKind, operand: Expression, isLeftSideOfBinary: boolean, leftOperand?: Expression): Expression; - function parenthesizeForConditionalHead(condition: Expression): Expression; - function parenthesizeForNew(expression: Expression): LeftHandSideExpression; - function parenthesizeForAccess(expression: Expression): LeftHandSideExpression; - function parenthesizePostfixOperand(operand: Expression): LeftHandSideExpression; - function parenthesizePrefixOperand(operand: Expression): UnaryExpression; - function parenthesizeExpressionForList(expression: Expression): Expression; - function parenthesizeExpressionForExpressionStatement(expression: Expression): Expression; - function parenthesizeConciseBody(body: ConciseBody): ConciseBody; - const enum OuterExpressionKinds { - Parentheses = 1, - Assertions = 2, - PartiallyEmittedExpressions = 4, - All = 7, - } - function skipOuterExpressions(node: Expression, kinds?: OuterExpressionKinds): Expression; - function skipOuterExpressions(node: Node, kinds?: OuterExpressionKinds): Node; - function skipParentheses(node: Expression): Expression; - function skipParentheses(node: Node): Node; - function skipAssertions(node: Expression): Expression; - function skipAssertions(node: Node): Node; - function skipPartiallyEmittedExpressions(node: Expression): Expression; - function skipPartiallyEmittedExpressions(node: Node): Node; - function startOnNewLine(node: T): T; - function setOriginalNode(node: T, original: Node): T; - function disposeEmitNodes(sourceFile: SourceFile): void; - function getOrCreateEmitNode(node: Node): EmitNode; - function getEmitFlags(node: Node): EmitFlags; - function setEmitFlags(node: T, emitFlags: EmitFlags): T; - function getSourceMapRange(node: Node): TextRange; - function setSourceMapRange(node: T, range: TextRange): T; - function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange; - function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange): T; - function getCommentRange(node: Node): TextRange; - function setCommentRange(node: T, range: TextRange): T; - function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; - function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number): PropertyAccessExpression | ElementAccessExpression; - function getExternalHelpersModuleName(node: SourceFile): Identifier; - function getOrCreateExternalHelpersModuleNameIfNeeded(node: SourceFile, compilerOptions: CompilerOptions): Identifier; - function addEmitHelper(node: T, helper: EmitHelper): T; - function addEmitHelpers(node: T, helpers: EmitHelper[] | undefined): T; - function removeEmitHelper(node: Node, helper: EmitHelper): boolean; - function getEmitHelpers(node: Node): EmitHelper[] | undefined; - function moveEmitHelpers(source: Node, target: Node, predicate: (helper: EmitHelper) => boolean): void; - function compareEmitHelpers(x: EmitHelper, y: EmitHelper): Comparison; - function setTextRange(node: T, location: TextRange): T; - function setNodeFlags(node: T, flags: NodeFlags): T; - function setMultiLine(node: T, multiLine: boolean): T; - function setHasTrailingComma(nodes: NodeArray, hasTrailingComma: boolean): NodeArray; - function getLocalNameForExternalImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration, sourceFile: SourceFile): Identifier; - function getExternalModuleNameLiteral(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration, sourceFile: SourceFile, host: EmitHost, resolver: EmitResolver, compilerOptions: CompilerOptions): StringLiteral; - function tryGetModuleNameFromFile(file: SourceFile, host: EmitHost, options: CompilerOptions): StringLiteral; - function getInitializerOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): Expression | undefined; - function getTargetOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): BindingOrAssignmentElementTarget; - function getRestIndicatorOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): BindingOrAssignmentElementRestIndicator; - function getPropertyNameOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): PropertyName; - function getElementsOfBindingOrAssignmentPattern(name: BindingOrAssignmentPattern): BindingOrAssignmentElement[]; - function convertToArrayAssignmentElement(element: BindingOrAssignmentElement): Expression; - function convertToObjectAssignmentElement(element: BindingOrAssignmentElement): ObjectLiteralElementLike; - function convertToAssignmentPattern(node: BindingOrAssignmentPattern): AssignmentPattern; - function convertToObjectAssignmentPattern(node: ObjectBindingOrAssignmentPattern): ObjectLiteralExpression; - function convertToArrayAssignmentPattern(node: ArrayBindingOrAssignmentPattern): ArrayLiteralExpression; - function convertToAssignmentElementTarget(node: BindingOrAssignmentElementTarget): Expression; - interface ExternalModuleInfo { - externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; - externalHelpersImportDeclaration: ImportDeclaration | undefined; - exportSpecifiers: Map; - exportedBindings: Map; - exportedNames: Identifier[]; - exportEquals: ExportAssignment | undefined; - hasExportStarsToExportValues: boolean; - } - function collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver, compilerOptions: CompilerOptions): ExternalModuleInfo; -} declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; @@ -9640,140 +2246,10 @@ declare namespace ts { function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName; function isExternalModule(file: SourceFile): boolean; function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; - function parseIsolatedJSDocComment(content: string, start?: number, length?: number): { - jsDoc: JSDoc; - diagnostics: Diagnostic[]; - }; - function parseJSDocTypeExpressionForTests(content: string, start?: number, length?: number): { - jsDocTypeExpression: JSDocTypeExpression; - diagnostics: Diagnostic[]; - }; -} -declare namespace ts { - const enum ModuleInstanceState { - NonInstantiated = 0, - Instantiated = 1, - ConstEnumOnly = 2, - } - function getModuleInstanceState(node: Node): ModuleInstanceState; - function bindSourceFile(file: SourceFile, options: CompilerOptions): void; - function computeTransformFlagsForNode(node: Node, subtreeFlags: TransformFlags): TransformFlags; - function getTransformFlagsSubtreeExclusions(kind: SyntaxKind): TransformFlags; -} -declare namespace ts { - function getNodeId(node: Node): number; - function getSymbolId(symbol: Symbol): number; - function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker; -} -declare namespace ts { - type VisitResult = T | T[]; - function reduceEachChild(node: Node, initial: T, cbNode: (memo: T, node: Node) => T, cbNodeArray?: (memo: T, nodes: Node[]) => T): T; - function visitNode(node: T, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, optional?: boolean, lift?: (node: NodeArray) => T): T; - function visitNode(node: T, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, optional: boolean, lift: (node: NodeArray) => T, parenthesize: (node: Node, parentNode: Node) => Node, parentNode: Node): T; - function visitNodes(nodes: NodeArray, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, start?: number, count?: number): NodeArray; - function visitNodes(nodes: NodeArray, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, start: number, count: number, parenthesize: (node: Node, parentNode: Node) => Node, parentNode: Node): NodeArray; - function visitLexicalEnvironment(statements: NodeArray, visitor: (node: Node) => VisitResult, context: TransformationContext, start?: number, ensureUseStrict?: boolean): NodeArray; - function visitParameterList(nodes: NodeArray, visitor: (node: Node) => VisitResult, context: TransformationContext): NodeArray; - function visitFunctionBody(node: FunctionBody, visitor: (node: Node) => VisitResult, context: TransformationContext): FunctionBody; - function visitFunctionBody(node: ConciseBody, visitor: (node: Node) => VisitResult, context: TransformationContext): ConciseBody; - function visitEachChild(node: T, visitor: (node: Node) => VisitResult, context: TransformationContext): T; - function mergeLexicalEnvironment(statements: NodeArray, declarations: Statement[]): NodeArray; - function mergeLexicalEnvironment(statements: Statement[], declarations: Statement[]): Statement[]; - function mergeFunctionBodyLexicalEnvironment(body: FunctionBody, declarations: Statement[]): FunctionBody; - function mergeFunctionBodyLexicalEnvironment(body: ConciseBody, declarations: Statement[]): ConciseBody; - function liftToBlock(nodes: Node[]): Statement; - function aggregateTransformFlags(node: T): T; - namespace Debug { - const failNotOptional: typeof noop; - const failBadSyntaxKind: (node: Node, message?: string) => void; - const assertEachNode: (nodes: Node[], test: (node: Node) => boolean, message?: string) => void; - const assertNode: (node: Node, test: (node: Node) => boolean, message?: string) => void; - const assertOptionalNode: (node: Node, test: (node: Node) => boolean, message?: string) => void; - const assertOptionalToken: (node: Node, kind: SyntaxKind, message?: string) => void; - const assertMissingNode: (node: Node, message?: string) => void; - } -} -declare namespace ts { - const enum FlattenLevel { - All = 0, - ObjectRest = 1, - } - function flattenDestructuringAssignment(node: VariableDeclaration | DestructuringAssignment, visitor: ((node: Node) => VisitResult) | undefined, context: TransformationContext, level: FlattenLevel, needsValue?: boolean, createAssignmentCallback?: (name: Identifier, value: Expression, location?: TextRange) => Expression): Expression; - function flattenDestructuringBinding(node: VariableDeclaration | ParameterDeclaration, visitor: (node: Node) => VisitResult, context: TransformationContext, level: FlattenLevel, rval?: Expression, hoistTempVariables?: boolean, skipInitializer?: boolean): VariableDeclaration[]; -} -declare namespace ts { - function transformTypeScript(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformESNext(context: TransformationContext): (node: SourceFile) => SourceFile; - function createAssignHelper(context: TransformationContext, attributesSegments: Expression[]): CallExpression; -} -declare namespace ts { - function transformJsx(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES2017(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES2016(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES2015(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformGenerators(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES5(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformModule(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformSystemModule(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES2015Module(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function getTransformers(compilerOptions: CompilerOptions): Transformer[]; - function transformFiles(resolver: EmitResolver, host: EmitHost, sourceFiles: SourceFile[], transformers: Transformer[]): TransformationResult; -} -declare namespace ts { - function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[]; - function writeDeclarationFile(declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean, host: EmitHost, resolver: EmitResolver, emitterDiagnostics: DiagnosticCollection, emitOnlyDtsFiles: boolean): boolean; -} -declare namespace ts { - interface SourceMapWriter { - initialize(filePath: string, sourceMapFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean): void; - reset(): void; - setSourceFile(sourceFile: SourceFile): void; - emitPos(pos: number): void; - emitNodeWithSourceMap(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; - emitTokenWithSourceMap(node: Node, token: SyntaxKind, tokenStartPos: number, emitCallback: (token: SyntaxKind, tokenStartPos: number) => number): number; - getText(): string; - getSourceMappingURL(): string; - getSourceMapData(): SourceMapData; - } - function createSourceMapWriter(host: EmitHost, writer: EmitTextWriter): SourceMapWriter; -} -declare namespace ts { - interface CommentWriter { - reset(): void; - setSourceFile(sourceFile: SourceFile): void; - emitNodeWithComments(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; - emitBodyWithDetachedComments(node: Node, detachedRange: TextRange, emitCallback: (node: Node) => void): void; - emitTrailingCommentsOfPosition(pos: number): void; - } - function createCommentWriter(host: EmitHost, writer: EmitTextWriter, sourceMap: SourceMapWriter): CommentWriter; -} -declare namespace ts { - function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean): EmitResult; } declare namespace ts { function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; function resolveTripleslashReference(moduleName: string, containingFile: string): string; - function computeCommonSourceDirectoryOfFilenames(fileNames: string[], currentDirectory: string, getCanonicalFileName: (fileName: string) => string): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; interface FormatDiagnosticsHost { @@ -9784,7 +2260,6 @@ declare namespace ts { function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; - function getResolutionDiagnostic(options: CompilerOptions, {extension}: ResolvedModuleFull): DiagnosticMessage | undefined; } declare namespace ts { interface Node { @@ -9830,10 +2305,6 @@ declare namespace ts { getDocumentationComment(): SymbolDisplayPart[]; } interface SourceFile { - version: string; - scriptSnapshot: IScriptSnapshot; - nameTable: Map; - getNamedDeclarations(): Map; getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; getLineStarts(): number[]; @@ -9924,8 +2395,6 @@ declare namespace ts { getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program; - getNonBoundSourceFile(fileName: string): SourceFile; - getSourceFile(fileName: string): SourceFile; dispose(): void; } interface Classifications { @@ -10043,6 +2512,7 @@ declare namespace ts { InsertSpaceAfterCommaDelimiter: boolean; InsertSpaceAfterSemicolonInForStatements: boolean; InsertSpaceBeforeAndAfterBinaryOperators: boolean; + InsertSpaceAfterConstructor?: boolean; InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; @@ -10051,6 +2521,7 @@ declare namespace ts { InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; InsertSpaceAfterTypeAssertion?: boolean; + InsertSpaceBeforeFunctionParenthesis?: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; } @@ -10058,6 +2529,7 @@ declare namespace ts { insertSpaceAfterCommaDelimiter?: boolean; insertSpaceAfterSemicolonInForStatements?: boolean; insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterConstructor?: boolean; insertSpaceAfterKeywordsInControlFlowStatements?: boolean; insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; @@ -10066,6 +2538,7 @@ declare namespace ts { insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; insertSpaceAfterTypeAssertion?: boolean; + insertSpaceBeforeFunctionParenthesis?: boolean; placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; } @@ -10317,123 +2790,8 @@ declare namespace ts { jsxAttributeStringLiteralValue = 24, } } -declare namespace ts { - const scanner: Scanner; - const emptyArray: any[]; - const enum SemanticMeaning { - None = 0, - Value = 1, - Type = 2, - Namespace = 4, - All = 7, - } - function getMeaningFromDeclaration(node: Node): SemanticMeaning; - function getMeaningFromLocation(node: Node): SemanticMeaning; - function isCallExpressionTarget(node: Node): boolean; - function isNewExpressionTarget(node: Node): boolean; - function climbPastPropertyAccess(node: Node): Node; - function getTargetLabel(referenceNode: Node, labelName: string): Identifier; - function isJumpStatementTarget(node: Node): boolean; - function isLabelName(node: Node): boolean; - function isRightSideOfQualifiedName(node: Node): boolean; - function isRightSideOfPropertyAccess(node: Node): boolean; - function isNameOfModuleDeclaration(node: Node): boolean; - function isNameOfFunctionDeclaration(node: Node): boolean; - function isLiteralNameOfPropertyDeclarationOrIndexAccess(node: Node): boolean; - function isExpressionOfExternalModuleImportEqualsDeclaration(node: Node): boolean; - function isInsideComment(sourceFile: SourceFile, token: Node, position: number): boolean; - function getContainerNode(node: Node): Declaration; - function getNodeKind(node: Node): string; - function getStringLiteralTypeForNode(node: StringLiteral | LiteralTypeNode, typeChecker: TypeChecker): LiteralType; - function isThis(node: Node): boolean; - interface ListItemInfo { - listItemIndex: number; - list: Node; - } - function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number; - function rangeContainsRange(r1: TextRange, r2: TextRange): boolean; - function startEndContainsRange(start: number, end: number, range: TextRange): boolean; - function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean; - function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean; - function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean; - function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean; - function isCompletedNode(n: Node, sourceFile: SourceFile): boolean; - function findListItemInfo(node: Node): ListItemInfo; - function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean; - function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node; - function findContainingList(node: Node): Node; - function getTouchingWord(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - function getTouchingPropertyName(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - function getTouchingToken(sourceFile: SourceFile, position: number, includeItemAtEndPosition?: (n: Node) => boolean, includeJsDocComment?: boolean): Node; - function getTokenAtPosition(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node; - function findNextToken(previousToken: Node, parent: Node): Node; - function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node): Node; - function isInString(sourceFile: SourceFile, position: number): boolean; - function isInComment(sourceFile: SourceFile, position: number): boolean; - function isInsideJsxElementOrAttribute(sourceFile: SourceFile, position: number): boolean; - function isInTemplateString(sourceFile: SourceFile, position: number): boolean; - function isInCommentHelper(sourceFile: SourceFile, position: number, predicate?: (c: CommentRange) => boolean): boolean; - function hasDocComment(sourceFile: SourceFile, position: number): boolean; - function getJsDocTagAtPosition(sourceFile: SourceFile, position: number): JSDocTag; - function getNodeModifiers(node: Node): string; - function getTypeArgumentOrTypeParameterList(node: Node): NodeArray; - function isToken(n: Node): boolean; - function isWord(kind: SyntaxKind): boolean; - function isComment(kind: SyntaxKind): boolean; - function isStringOrRegularExpressionOrTemplateLiteral(kind: SyntaxKind): boolean; - function isPunctuation(kind: SyntaxKind): boolean; - function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean; - function isAccessibilityModifier(kind: SyntaxKind): boolean; - function compareDataObjects(dst: any, src: any): boolean; - function isArrayLiteralOrObjectLiteralDestructuringPattern(node: Node): boolean; - function hasTrailingDirectorySeparator(path: string): boolean; - function isInReferenceComment(sourceFile: SourceFile, position: number): boolean; - function isInNonReferenceComment(sourceFile: SourceFile, position: number): boolean; -} -declare namespace ts { - function isFirstDeclarationOfSymbolParameter(symbol: Symbol): boolean; - function symbolPart(text: string, symbol: Symbol): SymbolDisplayPart; - function displayPart(text: string, kind: SymbolDisplayPartKind): SymbolDisplayPart; - function spacePart(): SymbolDisplayPart; - function keywordPart(kind: SyntaxKind): SymbolDisplayPart; - function punctuationPart(kind: SyntaxKind): SymbolDisplayPart; - function operatorPart(kind: SyntaxKind): SymbolDisplayPart; - function textOrKeywordPart(text: string): SymbolDisplayPart; - function textPart(text: string): SymbolDisplayPart; - function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost): string; - function lineBreakPart(): SymbolDisplayPart; - function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[]; - function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; - function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): SymbolDisplayPart[]; - function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; - function getDeclaredName(typeChecker: TypeChecker, symbol: Symbol, location: Node): string; - function isImportOrExportSpecifierName(location: Node): boolean; - function stripQuotes(name: string): string; - function scriptKindIs(fileName: string, host: LanguageServiceHost, ...scriptKinds: ScriptKind[]): boolean; - function getScriptKind(fileName: string, host?: LanguageServiceHost): ScriptKind; - function sanitizeConfigFile(configFileName: string, content: string): { - configJsonObject: any; - diagnostics: Diagnostic[]; - }; -} -declare namespace ts.BreakpointResolver { - function spanInSourceFileAtLocation(sourceFile: SourceFile, position: number): TextSpan; -} declare namespace ts { function createClassifier(): Classifier; - function getSemanticClassifications(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, classifiableNames: Map, span: TextSpan): ClassifiedSpan[]; - function getEncodedSemanticClassifications(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, classifiableNames: Map, span: TextSpan): Classifications; - function getSyntacticClassifications(cancellationToken: CancellationToken, sourceFile: SourceFile, span: TextSpan): ClassifiedSpan[]; - function getEncodedSyntacticClassifications(cancellationToken: CancellationToken, sourceFile: SourceFile, span: TextSpan): Classifications; -} -declare namespace ts.Completions { - function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo; - function getCompletionEntryDetails(typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number, entryName: string): CompletionEntryDetails; - function getCompletionEntrySymbol(typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number, entryName: string): Symbol; -} -declare namespace ts.DocumentHighlights { - function getDocumentHighlights(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: SourceFile[]): DocumentHighlights[]; } declare namespace ts { interface DocumentRegistry { @@ -10451,88 +2809,9 @@ declare namespace ts { }; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry; } -declare namespace ts.FindAllReferences { - function findReferencedSymbols(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, findInStrings: boolean, findInComments: boolean): ReferencedSymbol[]; - function getReferencedSymbolsForNode(typeChecker: TypeChecker, cancellationToken: CancellationToken, node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean, implementations: boolean): ReferencedSymbol[]; - function convertReferences(referenceSymbols: ReferencedSymbol[]): ReferenceEntry[]; - function getReferenceEntriesForShorthandPropertyAssignment(node: Node, typeChecker: TypeChecker, result: ReferenceEntry[]): void; - function getReferenceEntryFromNode(node: Node): ReferenceEntry; -} -declare namespace ts.GoToDefinition { - function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number): DefinitionInfo[]; - function getTypeDefinitionAtPosition(typeChecker: TypeChecker, sourceFile: SourceFile, position: number): DefinitionInfo[]; -} -declare namespace ts.GoToImplementation { - function getImplementationAtPosition(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], node: Node): ImplementationLocation[]; -} -declare namespace ts.JsDoc { - function getJsDocCommentsFromDeclarations(declarations: Declaration[]): SymbolDisplayPart[]; - function getAllJsDocCompletionEntries(): CompletionEntry[]; - function getDocCommentTemplateAtPosition(newLine: string, sourceFile: SourceFile, position: number): TextInsertion; -} -declare namespace ts.NavigateTo { - function getNavigateToItems(sourceFiles: SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number, excludeDtsFiles: boolean): NavigateToItem[]; -} -declare namespace ts.NavigationBar { - function getNavigationBarItems(sourceFile: SourceFile): NavigationBarItem[]; - function getNavigationTree(sourceFile: SourceFile): NavigationTree; -} -declare namespace ts.OutliningElementsCollector { - function collectElements(sourceFile: SourceFile): OutliningSpan[]; -} -declare namespace ts { - enum PatternMatchKind { - exact = 0, - prefix = 1, - substring = 2, - camelCase = 3, - } - interface PatternMatch { - kind: PatternMatchKind; - camelCaseWeight?: number; - isCaseSensitive: boolean; - punctuationStripped: boolean; - } - interface PatternMatcher { - getMatchesForLastSegmentOfPattern(candidate: string): PatternMatch[]; - getMatches(candidateContainers: string[], candidate: string): PatternMatch[]; - patternContainsDots: boolean; - } - function createPatternMatcher(pattern: string): PatternMatcher; - function breakIntoCharacterSpans(identifier: string): TextSpan[]; - function breakIntoWordSpans(identifier: string): TextSpan[]; -} declare namespace ts { function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo; } -declare namespace ts.Rename { - function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: (fileName: string) => string, sourceFile: SourceFile, position: number): RenameInfo; -} -declare namespace ts.SignatureHelp { - const enum ArgumentListKind { - TypeArguments = 0, - CallArguments = 1, - TaggedTemplateArguments = 2, - } - interface ArgumentListInfo { - kind: ArgumentListKind; - invocation: CallLikeExpression; - argumentsSpan: TextSpan; - argumentIndex?: number; - argumentCount: number; - } - function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, cancellationToken: CancellationToken): SignatureHelpItems; - function getContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile): ArgumentListInfo; -} -declare namespace ts.SymbolDisplay { - function getSymbolKind(typeChecker: TypeChecker, symbol: Symbol, location: Node): string; - function getSymbolModifiers(symbol: Symbol): string; - function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker: TypeChecker, symbol: Symbol, sourceFile: SourceFile, enclosingDeclaration: Node, location: Node, semanticMeaning?: SemanticMeaning): { - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - symbolKind: string; - }; -} declare namespace ts { interface TranspileOptions { compilerOptions?: CompilerOptions; @@ -10549,444 +2828,11 @@ declare namespace ts { function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; } -declare namespace ts.formatting { - interface FormattingScanner { - advance(): void; - isOnToken(): boolean; - readTokenInfo(n: Node): TokenInfo; - getCurrentLeadingTrivia(): TextRangeWithKind[]; - lastTrailingTriviaWasNewLine(): boolean; - skipToEndOf(node: Node): void; - close(): void; - } - function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner; -} -declare namespace ts.formatting { - class FormattingContext { - sourceFile: SourceFile; - formattingRequestKind: FormattingRequestKind; - currentTokenSpan: TextRangeWithKind; - nextTokenSpan: TextRangeWithKind; - contextNode: Node; - currentTokenParent: Node; - nextTokenParent: Node; - private contextNodeAllOnSameLine; - private nextNodeAllOnSameLine; - private tokensAreOnSameLine; - private contextNodeBlockIsOnOneLine; - private nextNodeBlockIsOnOneLine; - constructor(sourceFile: SourceFile, formattingRequestKind: FormattingRequestKind); - updateContext(currentRange: TextRangeWithKind, currentTokenParent: Node, nextRange: TextRangeWithKind, nextTokenParent: Node, commonParent: Node): void; - ContextNodeAllOnSameLine(): boolean; - NextNodeAllOnSameLine(): boolean; - TokensAreOnSameLine(): boolean; - ContextNodeBlockIsOnOneLine(): boolean; - NextNodeBlockIsOnOneLine(): boolean; - private NodeIsOnOneLine(node); - private BlockIsOnOneLine(node); - } -} -declare namespace ts.formatting { - const enum FormattingRequestKind { - FormatDocument = 0, - FormatSelection = 1, - FormatOnEnter = 2, - FormatOnSemicolon = 3, - FormatOnClosingCurlyBrace = 4, - } -} -declare namespace ts.formatting { - class Rule { - Descriptor: RuleDescriptor; - Operation: RuleOperation; - Flag: RuleFlags; - constructor(Descriptor: RuleDescriptor, Operation: RuleOperation, Flag?: RuleFlags); - toString(): string; - } -} -declare namespace ts.formatting { - const enum RuleAction { - Ignore = 1, - Space = 2, - NewLine = 4, - Delete = 8, - } -} -declare namespace ts.formatting { - class RuleDescriptor { - LeftTokenRange: Shared.TokenRange; - RightTokenRange: Shared.TokenRange; - constructor(LeftTokenRange: Shared.TokenRange, RightTokenRange: Shared.TokenRange); - toString(): string; - static create1(left: SyntaxKind, right: SyntaxKind): RuleDescriptor; - static create2(left: Shared.TokenRange, right: SyntaxKind): RuleDescriptor; - static create3(left: SyntaxKind, right: Shared.TokenRange): RuleDescriptor; - static create4(left: Shared.TokenRange, right: Shared.TokenRange): RuleDescriptor; - } -} -declare namespace ts.formatting { - const enum RuleFlags { - None = 0, - CanDeleteNewLines = 1, - } -} -declare namespace ts.formatting { - class RuleOperation { - Context: RuleOperationContext; - Action: RuleAction; - constructor(Context: RuleOperationContext, Action: RuleAction); - toString(): string; - static create1(action: RuleAction): RuleOperation; - static create2(context: RuleOperationContext, action: RuleAction): RuleOperation; - } -} -declare namespace ts.formatting { - class RuleOperationContext { - private customContextChecks; - constructor(...funcs: { - (context: FormattingContext): boolean; - }[]); - static Any: RuleOperationContext; - IsAny(): boolean; - InContext(context: FormattingContext): boolean; - } -} -declare namespace ts.formatting { - class Rules { - getRuleName(rule: Rule): string; - [name: string]: any; - IgnoreBeforeComment: Rule; - IgnoreAfterLineComment: Rule; - NoSpaceBeforeSemicolon: Rule; - NoSpaceBeforeColon: Rule; - NoSpaceBeforeQuestionMark: Rule; - SpaceAfterColon: Rule; - SpaceAfterQuestionMarkInConditionalOperator: Rule; - NoSpaceAfterQuestionMark: Rule; - SpaceAfterSemicolon: Rule; - SpaceAfterCloseBrace: Rule; - SpaceBetweenCloseBraceAndElse: Rule; - SpaceBetweenCloseBraceAndWhile: Rule; - NoSpaceAfterCloseBrace: Rule; - NoSpaceBeforeDot: Rule; - NoSpaceAfterDot: Rule; - NoSpaceBeforeOpenBracket: Rule; - NoSpaceAfterCloseBracket: Rule; - SpaceAfterOpenBrace: Rule; - SpaceBeforeCloseBrace: Rule; - NoSpaceAfterOpenBrace: Rule; - NoSpaceBeforeCloseBrace: Rule; - NoSpaceBetweenEmptyBraceBrackets: Rule; - NewLineAfterOpenBraceInBlockContext: Rule; - NewLineBeforeCloseBraceInBlockContext: Rule; - NoSpaceAfterUnaryPrefixOperator: Rule; - NoSpaceAfterUnaryPreincrementOperator: Rule; - NoSpaceAfterUnaryPredecrementOperator: Rule; - NoSpaceBeforeUnaryPostincrementOperator: Rule; - NoSpaceBeforeUnaryPostdecrementOperator: Rule; - SpaceAfterPostincrementWhenFollowedByAdd: Rule; - SpaceAfterAddWhenFollowedByUnaryPlus: Rule; - SpaceAfterAddWhenFollowedByPreincrement: Rule; - SpaceAfterPostdecrementWhenFollowedBySubtract: Rule; - SpaceAfterSubtractWhenFollowedByUnaryMinus: Rule; - SpaceAfterSubtractWhenFollowedByPredecrement: Rule; - NoSpaceBeforeComma: Rule; - SpaceAfterCertainKeywords: Rule; - SpaceAfterLetConstInVariableDeclaration: Rule; - NoSpaceBeforeOpenParenInFuncCall: Rule; - SpaceAfterFunctionInFuncDecl: Rule; - NoSpaceBeforeOpenParenInFuncDecl: Rule; - SpaceAfterVoidOperator: Rule; - NoSpaceBetweenReturnAndSemicolon: Rule; - SpaceBetweenStatements: Rule; - SpaceAfterTryFinally: Rule; - SpaceAfterGetSetInMember: Rule; - SpaceBeforeBinaryKeywordOperator: Rule; - SpaceAfterBinaryKeywordOperator: Rule; - NoSpaceAfterConstructor: Rule; - NoSpaceAfterModuleImport: Rule; - SpaceAfterCertainTypeScriptKeywords: Rule; - SpaceBeforeCertainTypeScriptKeywords: Rule; - SpaceAfterModuleName: Rule; - SpaceBeforeArrow: Rule; - SpaceAfterArrow: Rule; - NoSpaceAfterEllipsis: Rule; - NoSpaceAfterOptionalParameters: Rule; - NoSpaceBeforeOpenAngularBracket: Rule; - NoSpaceBetweenCloseParenAndAngularBracket: Rule; - NoSpaceAfterOpenAngularBracket: Rule; - NoSpaceBeforeCloseAngularBracket: Rule; - NoSpaceAfterCloseAngularBracket: Rule; - NoSpaceBetweenEmptyInterfaceBraceBrackets: Rule; - HighPriorityCommonRules: Rule[]; - LowPriorityCommonRules: Rule[]; - SpaceAfterComma: Rule; - NoSpaceAfterComma: Rule; - SpaceBeforeBinaryOperator: Rule; - SpaceAfterBinaryOperator: Rule; - NoSpaceBeforeBinaryOperator: Rule; - NoSpaceAfterBinaryOperator: Rule; - SpaceAfterKeywordInControl: Rule; - NoSpaceAfterKeywordInControl: Rule; - FunctionOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInFunction: Rule; - NewLineBeforeOpenBraceInFunction: Rule; - TypeScriptOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; - NewLineBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; - ControlOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInControl: Rule; - NewLineBeforeOpenBraceInControl: Rule; - SpaceAfterSemicolonInFor: Rule; - NoSpaceAfterSemicolonInFor: Rule; - SpaceAfterOpenParen: Rule; - SpaceBeforeCloseParen: Rule; - NoSpaceBetweenParens: Rule; - NoSpaceAfterOpenParen: Rule; - NoSpaceBeforeCloseParen: Rule; - SpaceAfterOpenBracket: Rule; - SpaceBeforeCloseBracket: Rule; - NoSpaceBetweenBrackets: Rule; - NoSpaceAfterOpenBracket: Rule; - NoSpaceBeforeCloseBracket: Rule; - SpaceAfterAnonymousFunctionKeyword: Rule; - NoSpaceAfterAnonymousFunctionKeyword: Rule; - SpaceBeforeAt: Rule; - NoSpaceAfterAt: Rule; - SpaceAfterDecorator: Rule; - NoSpaceBetweenFunctionKeywordAndStar: Rule; - SpaceAfterStarInGeneratorDeclaration: Rule; - NoSpaceBetweenYieldKeywordAndStar: Rule; - SpaceBetweenYieldOrYieldStarAndOperand: Rule; - SpaceBetweenAsyncAndOpenParen: Rule; - SpaceBetweenAsyncAndFunctionKeyword: Rule; - NoSpaceBetweenTagAndTemplateString: Rule; - NoSpaceAfterTemplateHeadAndMiddle: Rule; - SpaceAfterTemplateHeadAndMiddle: Rule; - NoSpaceBeforeTemplateMiddleAndTail: Rule; - SpaceBeforeTemplateMiddleAndTail: Rule; - NoSpaceAfterOpenBraceInJsxExpression: Rule; - SpaceAfterOpenBraceInJsxExpression: Rule; - NoSpaceBeforeCloseBraceInJsxExpression: Rule; - SpaceBeforeCloseBraceInJsxExpression: Rule; - SpaceBeforeJsxAttribute: Rule; - SpaceBeforeSlashInJsxOpeningElement: Rule; - NoSpaceBeforeGreaterThanTokenInJsxOpeningElement: Rule; - NoSpaceBeforeEqualInJsxAttribute: Rule; - NoSpaceAfterEqualInJsxAttribute: Rule; - NoSpaceAfterTypeAssertion: Rule; - SpaceAfterTypeAssertion: Rule; - constructor(); - static IsForContext(context: FormattingContext): boolean; - static IsNotForContext(context: FormattingContext): boolean; - static IsBinaryOpContext(context: FormattingContext): boolean; - static IsNotBinaryOpContext(context: FormattingContext): boolean; - static IsConditionalOperatorContext(context: FormattingContext): boolean; - static IsSameLineTokenOrBeforeMultilineBlockContext(context: FormattingContext): boolean; - static IsBeforeMultilineBlockContext(context: FormattingContext): boolean; - static IsMultilineBlockContext(context: FormattingContext): boolean; - static IsSingleLineBlockContext(context: FormattingContext): boolean; - static IsBlockContext(context: FormattingContext): boolean; - static IsBeforeBlockContext(context: FormattingContext): boolean; - static NodeIsBlockContext(node: Node): boolean; - static IsFunctionDeclContext(context: FormattingContext): boolean; - static IsFunctionDeclarationOrFunctionExpressionContext(context: FormattingContext): boolean; - static IsTypeScriptDeclWithBlockContext(context: FormattingContext): boolean; - static NodeIsTypeScriptDeclWithBlockContext(node: Node): boolean; - static IsAfterCodeBlockContext(context: FormattingContext): boolean; - static IsControlDeclContext(context: FormattingContext): boolean; - static IsObjectContext(context: FormattingContext): boolean; - static IsFunctionCallContext(context: FormattingContext): boolean; - static IsNewContext(context: FormattingContext): boolean; - static IsFunctionCallOrNewContext(context: FormattingContext): boolean; - static IsPreviousTokenNotComma(context: FormattingContext): boolean; - static IsNextTokenNotCloseBracket(context: FormattingContext): boolean; - static IsArrowFunctionContext(context: FormattingContext): boolean; - static IsNonJsxSameLineTokenContext(context: FormattingContext): boolean; - static IsNonJsxElementContext(context: FormattingContext): boolean; - static IsJsxExpressionContext(context: FormattingContext): boolean; - static IsNextTokenParentJsxAttribute(context: FormattingContext): boolean; - static IsJsxAttributeContext(context: FormattingContext): boolean; - static IsJsxSelfClosingElementContext(context: FormattingContext): boolean; - static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean; - static IsEndOfDecoratorContextOnSameLine(context: FormattingContext): boolean; - static NodeIsInDecoratorContext(node: Node): boolean; - static IsStartOfVariableDeclarationList(context: FormattingContext): boolean; - static IsNotFormatOnEnter(context: FormattingContext): boolean; - static IsModuleDeclContext(context: FormattingContext): boolean; - static IsObjectTypeContext(context: FormattingContext): boolean; - static IsTypeArgumentOrParameterOrAssertion(token: TextRangeWithKind, parent: Node): boolean; - static IsTypeArgumentOrParameterOrAssertionContext(context: FormattingContext): boolean; - static IsTypeAssertionContext(context: FormattingContext): boolean; - static IsVoidOpContext(context: FormattingContext): boolean; - static IsYieldOrYieldStarWithOperand(context: FormattingContext): boolean; - } -} -declare namespace ts.formatting { - class RulesMap { - map: RulesBucket[]; - mapRowLength: number; - constructor(); - static create(rules: Rule[]): RulesMap; - Initialize(rules: Rule[]): RulesBucket[]; - FillRules(rules: Rule[], rulesBucketConstructionStateList: RulesBucketConstructionState[]): void; - private GetRuleBucketIndex(row, column); - private FillRule(rule, rulesBucketConstructionStateList); - GetRule(context: FormattingContext): Rule; - } - enum RulesPosition { - IgnoreRulesSpecific = 0, - IgnoreRulesAny, - ContextRulesSpecific, - ContextRulesAny, - NoContextRulesSpecific, - NoContextRulesAny, - } - class RulesBucketConstructionState { - private rulesInsertionIndexBitmap; - constructor(); - GetInsertionIndex(maskPosition: RulesPosition): number; - IncreaseInsertionIndex(maskPosition: RulesPosition): void; - } - class RulesBucket { - private rules; - constructor(); - Rules(): Rule[]; - AddRule(rule: Rule, specificTokens: boolean, constructionState: RulesBucketConstructionState[], rulesBucketIndex: number): void; - } -} -declare namespace ts.formatting { - namespace Shared { - interface ITokenAccess { - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenRangeAccess implements ITokenAccess { - private tokens; - constructor(from: SyntaxKind, to: SyntaxKind, except: SyntaxKind[]); - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenValuesAccess implements ITokenAccess { - private tokens; - constructor(tks: SyntaxKind[]); - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenSingleValueAccess implements ITokenAccess { - token: SyntaxKind; - constructor(token: SyntaxKind); - GetTokens(): SyntaxKind[]; - Contains(tokenValue: SyntaxKind): boolean; - } - class TokenAllAccess implements ITokenAccess { - GetTokens(): SyntaxKind[]; - Contains(): boolean; - toString(): string; - } - class TokenRange { - tokenAccess: ITokenAccess; - constructor(tokenAccess: ITokenAccess); - static FromToken(token: SyntaxKind): TokenRange; - static FromTokens(tokens: SyntaxKind[]): TokenRange; - static FromRange(f: SyntaxKind, to: SyntaxKind, except?: SyntaxKind[]): TokenRange; - static AllTokens(): TokenRange; - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - toString(): string; - static Any: TokenRange; - static AnyIncludingMultilineComments: TokenRange; - static Keywords: TokenRange; - static BinaryOperators: TokenRange; - static BinaryKeywordOperators: TokenRange; - static UnaryPrefixOperators: TokenRange; - static UnaryPrefixExpressions: TokenRange; - static UnaryPreincrementExpressions: TokenRange; - static UnaryPostincrementExpressions: TokenRange; - static UnaryPredecrementExpressions: TokenRange; - static UnaryPostdecrementExpressions: TokenRange; - static Comments: TokenRange; - static TypeNames: TokenRange; - } - } -} -declare namespace ts.formatting { - class RulesProvider { - private globalRules; - private options; - private activeRules; - private rulesMap; - constructor(); - getRuleName(rule: Rule): string; - getRuleByName(name: string): Rule; - getRulesMap(): RulesMap; - ensureUpToDate(options: ts.FormatCodeSettings): void; - private createActiveRules(options); - } -} -declare namespace ts.formatting { - interface TextRangeWithKind extends TextRange { - kind: SyntaxKind; - } - interface TokenInfo { - leadingTrivia: TextRangeWithKind[]; - token: TextRangeWithKind; - trailingTrivia: TextRangeWithKind[]; - } - function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function formatOnSemicolon(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function formatOnClosingCurly(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function formatDocument(sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function formatSelection(start: number, end: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function getIndentationString(indentation: number, options: EditorSettings): string; -} -declare namespace ts.formatting { - namespace SmartIndenter { - function getIndentation(position: number, sourceFile: SourceFile, options: EditorSettings): number; - function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: EditorSettings): number; - function getBaseIndentation(options: EditorSettings): number; - function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean; - function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings): { - column: number; - character: number; - }; - function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings): number; - function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean): boolean; - function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind): boolean; - } -} -declare namespace ts { - interface CodeFix { - errorCodes: number[]; - getCodeActions(context: CodeFixContext): CodeAction[] | undefined; - } - interface CodeFixContext { - errorCode: number; - sourceFile: SourceFile; - span: TextSpan; - program: Program; - newLineCharacter: string; - host: LanguageServiceHost; - cancellationToken: CancellationToken; - } - namespace codefix { - function registerCodeFix(action: CodeFix): void; - function getSupportedErrorCodes(): string[]; - function getFixes(context: CodeFixContext): CodeAction[]; - } -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} declare namespace ts { const servicesVersion = "0.5"; interface DisplayPartsSymbolWriter extends SymbolWriter { displayParts(): SymbolDisplayPart[]; } - function toEditorSettings(options: FormatCodeOptions | FormatCodeSettings): FormatCodeSettings; function toEditorSettings(options: EditorOptions | EditorSettings): EditorSettings; function displayPartsToString(displayParts: SymbolDisplayPart[]): string; function getDefaultCompilerOptions(): CompilerOptions; @@ -10995,600 +2841,965 @@ declare namespace ts { let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; - function getNameTable(sourceFile: SourceFile): Map; function getDefaultLibFilePath(options: CompilerOptions): string; } -declare namespace ts.server { - class TextStorage { - private readonly host; - private readonly fileName; - private svc; - private svcVersion; - private text; - private lineMap; - private textVersion; - constructor(host: ServerHost, fileName: NormalizedPath); - getVersion(): string; - hasScriptVersionCache(): boolean; - useScriptVersionCache(newText?: string): void; - useText(newText?: string): void; - edit(start: number, end: number, newText: string): void; - reload(text: string): void; - reloadFromFile(tempFileName?: string): void; - getSnapshot(): IScriptSnapshot; - getLineInfo(line: number): ILineInfo; - lineToTextSpan(line: number): TextSpan; - lineOffsetToPosition(line: number, offset: number): number; - positionToLineOffset(position: number): ILineInfo; - private getFileText(tempFileName?); - private ensureNoScriptVersionCache(); - private switchToScriptVersionCache(newText?); - private getOrLoadText(); - private getLineMap(); - private setText(newText); +declare namespace ts.server.protocol { + namespace CommandTypes { + type Brace = "brace"; + type BraceCompletion = "braceCompletion"; + type Change = "change"; + type Close = "close"; + type Completions = "completions"; + type CompletionDetails = "completionEntryDetails"; + type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + type CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + type Configure = "configure"; + type Definition = "definition"; + type Implementation = "implementation"; + type Exit = "exit"; + type Format = "format"; + type Formatonkey = "formatonkey"; + type Geterr = "geterr"; + type GeterrForProject = "geterrForProject"; + type SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + type NavBar = "navbar"; + type Navto = "navto"; + type NavTree = "navtree"; + type NavTreeFull = "navtree-full"; + type Occurrences = "occurrences"; + type DocumentHighlights = "documentHighlights"; + type Open = "open"; + type Quickinfo = "quickinfo"; + type References = "references"; + type Reload = "reload"; + type Rename = "rename"; + type Saveto = "saveto"; + type SignatureHelp = "signatureHelp"; + type TypeDefinition = "typeDefinition"; + type ProjectInfo = "projectInfo"; + type ReloadProjects = "reloadProjects"; + type Unknown = "unknown"; + type OpenExternalProject = "openExternalProject"; + type OpenExternalProjects = "openExternalProjects"; + type CloseExternalProject = "closeExternalProject"; + type TodoComments = "todoComments"; + type Indentation = "indentation"; + type DocCommentTemplate = "docCommentTemplate"; + type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + type GetCodeFixes = "getCodeFixes"; + type GetSupportedCodeFixes = "getSupportedCodeFixes"; } - class ScriptInfo { - private readonly host; - readonly fileName: NormalizedPath; - readonly scriptKind: ScriptKind; - hasMixedContent: boolean; - readonly containingProjects: Project[]; - private formatCodeSettings; - readonly path: Path; - private fileWatcher; - private textStorage; - private isOpen; - constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent?: boolean); - isScriptOpen(): boolean; - open(newText: string): void; - close(): void; - getSnapshot(): IScriptSnapshot; - getFormatCodeSettings(): FormatCodeSettings; - attachToProject(project: Project): boolean; - isAttached(project: Project): boolean; - detachFromProject(project: Project): void; - detachAllProjects(): void; - getDefaultProject(): Project; - registerFileUpdate(): void; - setFormatOptions(formatSettings: FormatCodeSettings): void; - setWatcher(watcher: FileWatcher): void; - stopWatcher(): void; - getLatestVersion(): string; - reload(script: string): void; - saveTo(fileName: string): void; - reloadFromFile(tempFileName?: NormalizedPath): void; - getLineInfo(line: number): ILineInfo; - editContent(start: number, end: number, newText: string): void; - markContainingProjectsAsDirty(): void; - lineToTextSpan(line: number): TextSpan; - lineOffsetToPosition(line: number, offset: number): number; - positionToLineOffset(position: number): ILineInfo; + interface Message { + seq: number; + type: "request" | "response" | "event"; } -} -declare namespace ts.server { - class LSHost implements ts.LanguageServiceHost, ModuleResolutionHost { - private readonly host; - private readonly project; - private readonly cancellationToken; - private compilationSettings; - private readonly resolvedModuleNames; - private readonly resolvedTypeReferenceDirectives; - private readonly getCanonicalFileName; - private filesWithChangedSetOfUnresolvedImports; - private readonly resolveModuleName; - readonly trace: (s: string) => void; - readonly realpath?: (path: string) => string; - constructor(host: ServerHost, project: Project, cancellationToken: HostCancellationToken); - startRecordingFilesWithChangedResolutions(): void; - finishRecordingFilesWithChangedResolutions(): Path[]; - private resolveNamesWithLocalCache(names, containingFile, cache, loader, getResult, getResultFileName, logChanges); - getProjectVersion(): string; - getCompilationSettings(): CompilerOptions; - useCaseSensitiveFileNames(): boolean; - getCancellationToken(): HostCancellationToken; - resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; - resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModuleFull[]; - getDefaultLibFileName(): string; - getScriptSnapshot(filename: string): ts.IScriptSnapshot; - getScriptFileNames(): string[]; - getTypeRootsVersion(): number; - getScriptKind(fileName: string): ScriptKind; - getScriptVersion(filename: string): string; - getCurrentDirectory(): string; - resolvePath(path: string): string; - fileExists(path: string): boolean; - readFile(fileName: string): string; - directoryExists(path: string): boolean; - readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; - getDirectories(path: string): string[]; - notifyFileRemoved(info: ScriptInfo): void; - setCompilationSettings(opt: ts.CompilerOptions): void; + interface Request extends Message { + command: string; + arguments?: any; } -} -declare namespace ts.server { - interface ITypingsInstaller { - enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray): void; - attach(projectService: ProjectService): void; - onProjectClosed(p: Project): void; - readonly globalTypingsCacheLocation: string; + interface ReloadProjectsRequest extends Message { + command: CommandTypes.ReloadProjects; } - const nullTypingsInstaller: ITypingsInstaller; - class TypingsCache { - private readonly installer; - private readonly perProjectCache; - constructor(installer: ITypingsInstaller); - getTypingsForProject(project: Project, unresolvedImports: SortedReadonlyArray, forceRefresh: boolean): SortedReadonlyArray; - updateTypingsForProject(projectName: string, compilerOptions: CompilerOptions, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, newTypings: string[]): void; - deleteTypingsForProject(projectName: string): void; - onProjectClosed(project: Project): void; + interface Event extends Message { + event: string; + body?: any; } -} -declare namespace ts.server { - function shouldEmitFile(scriptInfo: ScriptInfo): boolean; - class BuilderFileInfo { - readonly scriptInfo: ScriptInfo; - readonly project: Project; - private lastCheckedShapeSignature; - constructor(scriptInfo: ScriptInfo, project: Project); - isExternalModuleOrHasOnlyAmbientExternalModules(): boolean; - private containsOnlyAmbientModules(sourceFile); - private computeHash(text); - private getSourceFile(); - updateShapeSignature(): boolean; + interface Response extends Message { + request_seq: number; + success: boolean; + command: string; + message?: string; + body?: any; } - interface Builder { - readonly project: Project; - getFilesAffectedBy(scriptInfo: ScriptInfo): string[]; - onProjectUpdateGraph(): void; - emitFile(scriptInfo: ScriptInfo, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => void): boolean; - clear(): void; + interface FileRequestArgs { + file: string; + projectFileName?: string; } - function createBuilder(project: Project): Builder; -} -declare namespace ts.server { - enum ProjectKind { - Inferred = 0, - Configured = 1, - External = 2, + interface DocCommentTemplateRequest extends FileLocationRequest { + command: CommandTypes.DocCommentTemplate; } - function allRootFilesAreJsOrDts(project: Project): boolean; - function allFilesAreJsOrDts(project: Project): boolean; - interface ProjectFilesWithTSDiagnostics extends protocol.ProjectFiles { - projectErrors: Diagnostic[]; + interface DocCommandTemplateResponse extends Response { + body?: TextInsertion; } - class UnresolvedImportsMap { - readonly perFileMap: FileMap>; - private version; - clear(): void; - getVersion(): number; - remove(path: Path): void; - get(path: Path): ReadonlyArray; - set(path: Path, value: ReadonlyArray): void; + interface TodoCommentRequest extends FileRequest { + command: CommandTypes.TodoComments; + arguments: TodoCommentRequestArgs; } - abstract class Project { - private readonly projectName; - readonly projectKind: ProjectKind; - readonly projectService: ProjectService; - private documentRegistry; - private compilerOptions; - compileOnSaveEnabled: boolean; - private rootFiles; - private rootFilesMap; - private lsHost; - private program; - private cachedUnresolvedImportsPerFile; - private lastCachedUnresolvedImportsList; - private readonly languageService; - languageServiceEnabled: boolean; - builder: Builder; - private updatedFileNames; - private lastReportedFileNames; - private lastReportedVersion; - private projectStructureVersion; - private projectStateVersion; - private typingFiles; - protected projectErrors: Diagnostic[]; - typesVersion: number; - isNonTsProject(): boolean; - isJsOnlyProject(): boolean; - getCachedUnresolvedImportsPerFile_TestOnly(): UnresolvedImportsMap; - constructor(projectName: string, projectKind: ProjectKind, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, languageServiceEnabled: boolean, compilerOptions: CompilerOptions, compileOnSaveEnabled: boolean); - private setInternalCompilerOptionsForEmittingJsFiles(); - getProjectErrors(): Diagnostic[]; - getLanguageService(ensureSynchronized?: boolean): LanguageService; - getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[]; - getProjectVersion(): string; - enableLanguageService(): void; - disableLanguageService(): void; - getProjectName(): string; - abstract getProjectRootPath(): string | undefined; - abstract getTypeAcquisition(): TypeAcquisition; - getSourceFile(path: Path): SourceFile; - updateTypes(): void; - close(): void; - getCompilerOptions(): CompilerOptions; - hasRoots(): boolean; - getRootFiles(): NormalizedPath[]; - getRootFilesLSHost(): string[]; - getRootScriptInfos(): ScriptInfo[]; - getScriptInfos(): ScriptInfo[]; - getFileEmitOutput(info: ScriptInfo, emitOnlyDtsFiles: boolean): EmitOutput; - getFileNames(excludeFilesFromExternalLibraries?: boolean): NormalizedPath[]; - getAllEmittableFiles(): string[]; - containsScriptInfo(info: ScriptInfo): boolean; - containsFile(filename: NormalizedPath, requireOpen?: boolean): boolean; - isRoot(info: ScriptInfo): boolean; - addRoot(info: ScriptInfo): void; - removeFile(info: ScriptInfo, detachFromProject?: boolean): void; - registerFileUpdate(fileName: string): void; - markAsDirty(): void; - private extractUnresolvedImportsFromSourceFile(file, result); - updateGraph(): boolean; - private setTypings(typings); - private updateGraphWorker(); - getScriptInfoLSHost(fileName: string): ScriptInfo; - getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo; - getScriptInfo(uncheckedFileName: string): ScriptInfo; - filesToString(): string; - setCompilerOptions(compilerOptions: CompilerOptions): void; - reloadScript(filename: NormalizedPath, tempFileName?: NormalizedPath): boolean; - getChangesSinceVersion(lastKnownVersion?: number): ProjectFilesWithTSDiagnostics; - getReferencedFiles(path: Path): Path[]; - private removeRootFileIfNecessary(info); + interface TodoCommentRequestArgs extends FileRequestArgs { + descriptors: TodoCommentDescriptor[]; } - class InferredProject extends Project { - private static newName; - directoriesWatchedForTsconfig: string[]; - constructor(projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions); - getProjectRootPath(): string; - close(): void; - getTypeAcquisition(): TypeAcquisition; + interface TodoCommentsResponse extends Response { + body?: TodoComment[]; } - class ConfiguredProject extends Project { - private wildcardDirectories; - compileOnSaveEnabled: boolean; - private typeAcquisition; - private projectFileWatcher; - private directoryWatcher; - private directoriesWatchedForWildcards; - private typeRootsWatchers; - readonly canonicalConfigFilePath: NormalizedPath; - openRefCount: number; - constructor(configFileName: NormalizedPath, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, compilerOptions: CompilerOptions, wildcardDirectories: Map, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean); - getConfigFilePath(): string; - getProjectRootPath(): string; - setProjectErrors(projectErrors: Diagnostic[]): void; - setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; - getTypeAcquisition(): TypeAcquisition; - watchConfigFile(callback: (project: ConfiguredProject) => void): void; - watchTypeRoots(callback: (project: ConfiguredProject, path: string) => void): void; - watchConfigDirectory(callback: (project: ConfiguredProject, path: string) => void): void; - watchWildcards(callback: (project: ConfiguredProject, path: string) => void): void; - stopWatchingDirectory(): void; - close(): void; - addOpenRef(): void; - deleteOpenRef(): number; - getEffectiveTypeRoots(): string[]; + interface IndentationRequest extends FileLocationRequest { + command: CommandTypes.Indentation; + arguments: IndentationRequestArgs; } - class ExternalProject extends Project { - compileOnSaveEnabled: boolean; - private readonly projectFilePath; - private typeAcquisition; - constructor(externalProjectName: string, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean, projectFilePath?: string); - getProjectRootPath(): string; - getTypeAcquisition(): TypeAcquisition; - setProjectErrors(projectErrors: Diagnostic[]): void; - setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; + interface IndentationResponse extends Response { + body?: IndentationResult; } -} -declare namespace ts.server { - const maxProgramSizeForNonTsFiles: number; - const ContextEvent = "context"; - const ConfigFileDiagEvent = "configFileDiag"; - const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; - interface ContextEvent { - eventName: typeof ContextEvent; - data: { - project: Project; - fileName: NormalizedPath; - }; + interface IndentationResult { + position: number; + indentation: number; } - interface ConfigFileDiagEvent { - eventName: typeof ConfigFileDiagEvent; - data: { - triggerFile: string; - configFileName: string; - diagnostics: Diagnostic[]; - }; + interface IndentationRequestArgs extends FileLocationRequestArgs { + options?: EditorSettings; } - interface ProjectLanguageServiceStateEvent { - eventName: typeof ProjectLanguageServiceStateEvent; - data: { - project: Project; - languageServiceEnabled: boolean; - }; + interface ProjectInfoRequestArgs extends FileRequestArgs { + needFileNameList: boolean; } - type ProjectServiceEvent = ContextEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent; - interface ProjectServiceEventHandler { - (event: ProjectServiceEvent): void; + interface ProjectInfoRequest extends Request { + command: CommandTypes.ProjectInfo; + arguments: ProjectInfoRequestArgs; } - function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings; - function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin; - function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind; - function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind; - function combineProjectOutput(projects: Project[], action: (project: Project) => T[], comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean): T[]; - interface HostConfiguration { - formatCodeOptions: FormatCodeSettings; - hostInfo: string; + interface CompilerOptionsDiagnosticsRequest extends Request { + arguments: CompilerOptionsDiagnosticsRequestArgs; + } + interface CompilerOptionsDiagnosticsRequestArgs { + projectFileName: string; + } + interface ProjectInfo { + configFileName: string; + fileNames?: string[]; + languageServiceDisabled?: boolean; + } + interface DiagnosticWithLinePosition { + message: string; + start: number; + length: number; + startLocation: Location; + endLocation: Location; + category: string; + code: number; + } + interface ProjectInfoResponse extends Response { + body?: ProjectInfo; + } + interface FileRequest extends Request { + arguments: FileRequestArgs; + } + interface FileLocationRequestArgs extends FileRequestArgs { + line: number; + offset: number; + } + interface CodeFixRequest extends Request { + command: CommandTypes.GetCodeFixes; + arguments: CodeFixRequestArgs; + } + interface CodeFixRequestArgs extends FileRequestArgs { + startLine: number; + startOffset: number; + endLine: number; + endOffset: number; + errorCodes?: number[]; + } + interface GetCodeFixesResponse extends Response { + body?: CodeAction[]; + } + interface FileLocationRequest extends FileRequest { + arguments: FileLocationRequestArgs; + } + interface GetSupportedCodeFixesRequest extends Request { + command: CommandTypes.GetSupportedCodeFixes; + } + interface GetSupportedCodeFixesResponse extends Response { + body?: string[]; + } + interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { + start: number; + length: number; + } + interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { + filesToSearch: string[]; + } + interface DefinitionRequest extends FileLocationRequest { + command: CommandTypes.Definition; + } + interface TypeDefinitionRequest extends FileLocationRequest { + command: CommandTypes.TypeDefinition; + } + interface ImplementationRequest extends FileLocationRequest { + command: CommandTypes.Implementation; + } + interface Location { + line: number; + offset: number; + } + interface TextSpan { + start: Location; + end: Location; + } + interface FileSpan extends TextSpan { + file: string; + } + interface DefinitionResponse extends Response { + body?: FileSpan[]; + } + interface TypeDefinitionResponse extends Response { + body?: FileSpan[]; + } + interface ImplementationResponse extends Response { + body?: FileSpan[]; + } + interface BraceCompletionRequest extends FileLocationRequest { + command: CommandTypes.BraceCompletion; + arguments: BraceCompletionRequestArgs; + } + interface BraceCompletionRequestArgs extends FileLocationRequestArgs { + openingBrace: string; + } + interface OccurrencesRequest extends FileLocationRequest { + command: CommandTypes.Occurrences; + } + interface OccurrencesResponseItem extends FileSpan { + isWriteAccess: boolean; + } + interface OccurrencesResponse extends Response { + body?: OccurrencesResponseItem[]; + } + interface DocumentHighlightsRequest extends FileLocationRequest { + command: CommandTypes.DocumentHighlights; + arguments: DocumentHighlightsRequestArgs; + } + interface HighlightSpan extends TextSpan { + kind: string; + } + interface DocumentHighlightsItem { + file: string; + highlightSpans: HighlightSpan[]; + } + interface DocumentHighlightsResponse extends Response { + body?: DocumentHighlightsItem[]; + } + interface ReferencesRequest extends FileLocationRequest { + command: CommandTypes.References; + } + interface ReferencesResponseItem extends FileSpan { + lineText: string; + isWriteAccess: boolean; + isDefinition: boolean; + } + interface ReferencesResponseBody { + refs: ReferencesResponseItem[]; + symbolName: string; + symbolStartOffset: number; + symbolDisplayString: string; + } + interface ReferencesResponse extends Response { + body?: ReferencesResponseBody; + } + interface RenameRequestArgs extends FileLocationRequestArgs { + findInComments?: boolean; + findInStrings?: boolean; + } + interface RenameRequest extends FileLocationRequest { + command: CommandTypes.Rename; + arguments: RenameRequestArgs; + } + interface RenameInfo { + canRename: boolean; + localizedErrorMessage?: string; + displayName: string; + fullDisplayName: string; + kind: string; + kindModifiers: string; + } + interface SpanGroup { + file: string; + locs: TextSpan[]; + } + interface RenameResponseBody { + info: RenameInfo; + locs: SpanGroup[]; + } + interface RenameResponse extends Response { + body?: RenameResponseBody; + } + interface ExternalFile { + fileName: string; + scriptKind?: ScriptKindName | ts.ScriptKind; + hasMixedContent?: boolean; + content?: string; + } + interface ExternalProject { + projectFileName: string; + rootFiles: ExternalFile[]; + options: ExternalProjectCompilerOptions; + typingOptions?: TypeAcquisition; + typeAcquisition?: TypeAcquisition; + } + interface CompileOnSaveMixin { + compileOnSave?: boolean; + } + type ExternalProjectCompilerOptions = CompilerOptions & CompileOnSaveMixin; + interface ProjectChanges { + added: string[]; + removed: string[]; + updated: string[]; + } + interface ConfigureRequestArguments { + hostInfo?: string; + file?: string; + formatOptions?: FormatCodeSettings; extraFileExtensions?: FileExtensionInfo[]; } - interface OpenConfiguredProjectResult { - configFileName?: NormalizedPath; - configFileErrors?: Diagnostic[]; + interface ConfigureRequest extends Request { + command: CommandTypes.Configure; + arguments: ConfigureRequestArguments; } - class ProjectService { - readonly host: ServerHost; - readonly logger: Logger; - readonly cancellationToken: HostCancellationToken; - readonly useSingleInferredProject: boolean; - readonly typingsInstaller: ITypingsInstaller; - private readonly eventHandler; - readonly typingsCache: TypingsCache; - private readonly documentRegistry; - private readonly filenameToScriptInfo; - private readonly externalProjectToConfiguredProjectMap; - readonly externalProjects: ExternalProject[]; - readonly inferredProjects: InferredProject[]; - readonly configuredProjects: ConfiguredProject[]; - readonly openFiles: ScriptInfo[]; - private compilerOptionsForInferredProjects; - private compileOnSaveForInferredProjects; - private readonly directoryWatchers; - private readonly throttledOperations; - private readonly hostConfiguration; - private changedFiles; - readonly toCanonicalFileName: (f: string) => string; - lastDeletedFile: ScriptInfo; - constructor(host: ServerHost, logger: Logger, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller?: ITypingsInstaller, eventHandler?: ProjectServiceEventHandler); - getChangedFiles_TestOnly(): ScriptInfo[]; - ensureInferredProjectsUpToDate_TestOnly(): void; - getCompilerOptionsForInferredProjects(): CompilerOptions; - onUpdateLanguageServiceStateForProject(project: Project, languageServiceEnabled: boolean): void; - updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void; - setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void; - stopWatchingDirectory(directory: string): void; - findProject(projectName: string): Project; - getDefaultProjectForFile(fileName: NormalizedPath, refreshInferredProjects: boolean): Project; - private ensureInferredProjectsUpToDate(); - private findContainingExternalProject(fileName); - getFormatCodeOptions(file?: NormalizedPath): FormatCodeSettings; - private updateProjectGraphs(projects); - private onSourceFileChanged(fileName); - private handleDeletedFile(info); - private onTypeRootFileChanged(project, fileName); - private onSourceFileInDirectoryChangedForConfiguredProject(project, fileName); - private handleChangeInSourceFileForConfiguredProject(project, triggerFile); - private onConfigChangedForConfiguredProject(project); - private onConfigFileAddedForInferredProject(fileName); - private getCanonicalFileName(fileName); - private removeProject(project); - private assignScriptInfoToInferredProjectIfNecessary(info, addToListOfOpenFiles); - private closeOpenFile(info); - private openOrUpdateConfiguredProjectForFile(fileName); - private findConfigFile(searchPath); - private printProjects(); - private findConfiguredProjectByProjectName(configFileName); - private findExternalProjectByProjectName(projectFileName); - private convertConfigFileContentToProjectOptions(configFilename); - private exceededTotalSizeLimitForNonTsFiles(options, fileNames, propertyReader); - private createAndAddExternalProject(projectFileName, files, options, typeAcquisition); - private reportConfigFileDiagnostics(configFileName, diagnostics, triggerFile); - private createAndAddConfiguredProject(configFileName, projectOptions, configFileErrors, clientFileName?); - private watchConfigDirectoryForProject(project, options); - private addFilesToProjectAndUpdateGraph(project, files, propertyReader, clientFileName, typeAcquisition, configFileErrors); - private openConfigFile(configFileName, clientFileName?); - private updateNonInferredProject(project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave, configFileErrors); - private updateConfiguredProject(project); - createInferredProjectWithRootFileIfNecessary(root: ScriptInfo): InferredProject; - getOrCreateScriptInfo(uncheckedFileName: string, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind): ScriptInfo; - getScriptInfo(uncheckedFileName: string): ScriptInfo; - getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): ScriptInfo; - getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo; - getScriptInfoForPath(fileName: Path): ScriptInfo; - setHostConfiguration(args: protocol.ConfigureRequestArguments): void; - closeLog(): void; - reloadProjects(): void; - refreshInferredProjects(): void; - openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind): OpenConfiguredProjectResult; - openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): OpenConfiguredProjectResult; - closeClientFile(uncheckedFileName: string): void; - private collectChanges(lastKnownProjectVersions, currentProjects, result); - synchronizeProjectList(knownProjects: protocol.ProjectVersionInfo[]): ProjectFilesWithTSDiagnostics[]; - applyChangesInOpenFiles(openFiles: protocol.ExternalFile[], changedFiles: protocol.ChangedOpenFile[], closedFiles: string[]): void; - private closeConfiguredProject(configFile); - closeExternalProject(uncheckedFileName: string, suppressRefresh?: boolean): void; - openExternalProjects(projects: protocol.ExternalProject[]): void; - openExternalProject(proj: protocol.ExternalProject, suppressRefreshOfInferredProjects?: boolean): void; + interface ConfigureResponse extends Response { + } + interface OpenRequestArgs extends FileRequestArgs { + fileContent?: string; + scriptKindName?: ScriptKindName; + } + type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; + interface OpenRequest extends Request { + command: CommandTypes.Open; + arguments: OpenRequestArgs; + } + interface OpenExternalProjectRequest extends Request { + command: CommandTypes.OpenExternalProject; + arguments: OpenExternalProjectArgs; + } + type OpenExternalProjectArgs = ExternalProject; + interface OpenExternalProjectsRequest extends Request { + command: CommandTypes.OpenExternalProjects; + arguments: OpenExternalProjectsArgs; + } + interface OpenExternalProjectsArgs { + projects: ExternalProject[]; + } + interface OpenExternalProjectResponse extends Response { + } + interface OpenExternalProjectsResponse extends Response { + } + interface CloseExternalProjectRequest extends Request { + command: CommandTypes.CloseExternalProject; + arguments: CloseExternalProjectRequestArgs; + } + interface CloseExternalProjectRequestArgs { + projectFileName: string; + } + interface CloseExternalProjectResponse extends Response { + } + interface SetCompilerOptionsForInferredProjectsRequest extends Request { + command: CommandTypes.CompilerOptionsForInferredProjects; + arguments: SetCompilerOptionsForInferredProjectsArgs; + } + interface SetCompilerOptionsForInferredProjectsArgs { + options: ExternalProjectCompilerOptions; + } + interface SetCompilerOptionsForInferredProjectsResponse extends Response { + } + interface ExitRequest extends Request { + command: CommandTypes.Exit; + } + interface CloseRequest extends FileRequest { + command: CommandTypes.Close; + } + interface CompileOnSaveAffectedFileListRequest extends FileRequest { + command: CommandTypes.CompileOnSaveAffectedFileList; + } + interface CompileOnSaveAffectedFileListSingleProject { + projectFileName: string; + fileNames: string[]; + } + interface CompileOnSaveAffectedFileListResponse extends Response { + body: CompileOnSaveAffectedFileListSingleProject[]; + } + interface CompileOnSaveEmitFileRequest extends FileRequest { + command: CommandTypes.CompileOnSaveEmitFile; + arguments: CompileOnSaveEmitFileRequestArgs; + } + interface CompileOnSaveEmitFileRequestArgs extends FileRequestArgs { + forced?: boolean; + } + interface QuickInfoRequest extends FileLocationRequest { + command: CommandTypes.Quickinfo; + } + interface QuickInfoResponseBody { + kind: string; + kindModifiers: string; + start: Location; + end: Location; + displayString: string; + documentation: string; + } + interface QuickInfoResponse extends Response { + body?: QuickInfoResponseBody; + } + interface FormatRequestArgs extends FileLocationRequestArgs { + endLine: number; + endOffset: number; + options?: FormatCodeSettings; + } + interface FormatRequest extends FileLocationRequest { + command: CommandTypes.Format; + arguments: FormatRequestArgs; + } + interface CodeEdit { + start: Location; + end: Location; + newText: string; + } + interface FileCodeEdits { + fileName: string; + textChanges: CodeEdit[]; + } + interface CodeFixResponse extends Response { + body?: CodeAction[]; + } + interface CodeAction { + description: string; + changes: FileCodeEdits[]; + } + interface FormatResponse extends Response { + body?: CodeEdit[]; + } + interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { + key: string; + options?: FormatCodeSettings; + } + interface FormatOnKeyRequest extends FileLocationRequest { + command: CommandTypes.Formatonkey; + arguments: FormatOnKeyRequestArgs; + } + interface CompletionsRequestArgs extends FileLocationRequestArgs { + prefix?: string; + } + interface CompletionsRequest extends FileLocationRequest { + command: CommandTypes.Completions; + arguments: CompletionsRequestArgs; + } + interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { + entryNames: string[]; + } + interface CompletionDetailsRequest extends FileLocationRequest { + command: CommandTypes.CompletionDetails; + arguments: CompletionDetailsRequestArgs; + } + interface SymbolDisplayPart { + text: string; + kind: string; + } + interface CompletionEntry { + name: string; + kind: string; + kindModifiers: string; + sortText: string; + replacementSpan?: TextSpan; + } + interface CompletionEntryDetails { + name: string; + kind: string; + kindModifiers: string; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface CompletionsResponse extends Response { + body?: CompletionEntry[]; + } + interface CompletionDetailsResponse extends Response { + body?: CompletionEntryDetails[]; + } + interface SignatureHelpParameter { + name: string; + documentation: SymbolDisplayPart[]; + displayParts: SymbolDisplayPart[]; + isOptional: boolean; + } + interface SignatureHelpItem { + isVariadic: boolean; + prefixDisplayParts: SymbolDisplayPart[]; + suffixDisplayParts: SymbolDisplayPart[]; + separatorDisplayParts: SymbolDisplayPart[]; + parameters: SignatureHelpParameter[]; + documentation: SymbolDisplayPart[]; + } + interface SignatureHelpItems { + items: SignatureHelpItem[]; + applicableSpan: TextSpan; + selectedItemIndex: number; + argumentIndex: number; + argumentCount: number; + } + interface SignatureHelpRequestArgs extends FileLocationRequestArgs { + } + interface SignatureHelpRequest extends FileLocationRequest { + command: CommandTypes.SignatureHelp; + arguments: SignatureHelpRequestArgs; + } + interface SignatureHelpResponse extends Response { + body?: SignatureHelpItems; + } + interface SemanticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SemanticDiagnosticsSync; + arguments: SemanticDiagnosticsSyncRequestArgs; + } + interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs { + includeLinePosition?: boolean; + } + interface SemanticDiagnosticsSyncResponse extends Response { + body?: Diagnostic[] | DiagnosticWithLinePosition[]; + } + interface SyntacticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SyntacticDiagnosticsSync; + arguments: SyntacticDiagnosticsSyncRequestArgs; + } + interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs { + includeLinePosition?: boolean; + } + interface SyntacticDiagnosticsSyncResponse extends Response { + body?: Diagnostic[] | DiagnosticWithLinePosition[]; + } + interface GeterrForProjectRequestArgs { + file: string; + delay: number; + } + interface GeterrForProjectRequest extends Request { + command: CommandTypes.GeterrForProject; + arguments: GeterrForProjectRequestArgs; + } + interface GeterrRequestArgs { + files: string[]; + delay: number; + } + interface GeterrRequest extends Request { + command: CommandTypes.Geterr; + arguments: GeterrRequestArgs; + } + interface Diagnostic { + start: Location; + end: Location; + text: string; + code?: number; + } + interface DiagnosticEventBody { + file: string; + diagnostics: Diagnostic[]; + } + interface DiagnosticEvent extends Event { + body?: DiagnosticEventBody; + } + interface ConfigFileDiagnosticEventBody { + triggerFile: string; + configFile: string; + diagnostics: Diagnostic[]; + } + interface ConfigFileDiagnosticEvent extends Event { + body?: ConfigFileDiagnosticEventBody; + event: "configFileDiag"; + } + type ProjectLanguageServiceStateEventName = "projectLanguageServiceState"; + interface ProjectLanguageServiceStateEvent extends Event { + event: ProjectLanguageServiceStateEventName; + body?: ProjectLanguageServiceStateEventBody; + } + interface ProjectLanguageServiceStateEventBody { + projectName: string; + languageServiceEnabled: boolean; + } + interface ReloadRequestArgs extends FileRequestArgs { + tmpfile: string; + } + interface ReloadRequest extends FileRequest { + command: CommandTypes.Reload; + arguments: ReloadRequestArgs; + } + interface ReloadResponse extends Response { + } + interface SavetoRequestArgs extends FileRequestArgs { + tmpfile: string; + } + interface SavetoRequest extends FileRequest { + command: CommandTypes.Saveto; + arguments: SavetoRequestArgs; + } + interface NavtoRequestArgs extends FileRequestArgs { + searchValue: string; + maxResultCount?: number; + currentFileOnly?: boolean; + projectFileName?: string; + } + interface NavtoRequest extends FileRequest { + command: CommandTypes.Navto; + arguments: NavtoRequestArgs; + } + interface NavtoItem { + name: string; + kind: string; + matchKind?: string; + isCaseSensitive?: boolean; + kindModifiers?: string; + file: string; + start: Location; + end: Location; + containerName?: string; + containerKind?: string; + } + interface NavtoResponse extends Response { + body?: NavtoItem[]; + } + interface ChangeRequestArgs extends FormatRequestArgs { + insertString?: string; + } + interface ChangeRequest extends FileLocationRequest { + command: CommandTypes.Change; + arguments: ChangeRequestArgs; + } + interface BraceResponse extends Response { + body?: TextSpan[]; + } + interface BraceRequest extends FileLocationRequest { + command: CommandTypes.Brace; + } + interface NavBarRequest extends FileRequest { + command: CommandTypes.NavBar; + } + interface NavTreeRequest extends FileRequest { + command: CommandTypes.NavTree; + } + interface NavigationBarItem { + text: string; + kind: string; + kindModifiers?: string; + spans: TextSpan[]; + childItems?: NavigationBarItem[]; + indent: number; + } + interface NavigationTree { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems?: NavigationTree[]; + } + type TelemetryEventName = "telemetry"; + interface TelemetryEvent extends Event { + event: TelemetryEventName; + body: TelemetryEventBody; + } + interface TelemetryEventBody { + telemetryEventName: string; + payload: any; + } + type TypingsInstalledTelemetryEventName = "typingsInstalled"; + interface TypingsInstalledTelemetryEventBody extends TelemetryEventBody { + telemetryEventName: TypingsInstalledTelemetryEventName; + payload: TypingsInstalledTelemetryEventPayload; + } + interface TypingsInstalledTelemetryEventPayload { + installedPackages: string; + installSuccess: boolean; + typingsInstallerVersion: string; + } + type BeginInstallTypesEventName = "beginInstallTypes"; + type EndInstallTypesEventName = "endInstallTypes"; + interface BeginInstallTypesEvent extends Event { + event: BeginInstallTypesEventName; + body: BeginInstallTypesEventBody; + } + interface EndInstallTypesEvent extends Event { + event: EndInstallTypesEventName; + body: EndInstallTypesEventBody; + } + interface InstallTypesEventBody { + eventId: number; + packages: ReadonlyArray; + } + interface BeginInstallTypesEventBody extends InstallTypesEventBody { + } + interface EndInstallTypesEventBody extends InstallTypesEventBody { + success: boolean; + } + interface NavBarResponse extends Response { + body?: NavigationBarItem[]; + } + interface NavTreeResponse extends Response { + body?: NavigationTree; + } + namespace IndentStyle { + type None = "None"; + type Block = "Block"; + type Smart = "Smart"; + } + type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart; + interface EditorSettings { + baseIndentSize?: number; + indentSize?: number; + tabSize?: number; + newLineCharacter?: string; + convertTabsToSpaces?: boolean; + indentStyle?: IndentStyle | ts.IndentStyle; + } + interface FormatCodeSettings extends EditorSettings { + insertSpaceAfterCommaDelimiter?: boolean; + insertSpaceAfterSemicolonInForStatements?: boolean; + insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterConstructor?: boolean; + insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + insertSpaceBeforeFunctionParenthesis?: boolean; + placeOpenBraceOnNewLineForFunctions?: boolean; + placeOpenBraceOnNewLineForControlBlocks?: boolean; + } + interface CompilerOptions { + allowJs?: boolean; + allowSyntheticDefaultImports?: boolean; + allowUnreachableCode?: boolean; + allowUnusedLabels?: boolean; + baseUrl?: string; + charset?: string; + declaration?: boolean; + declarationDir?: string; + disableSizeLimit?: boolean; + emitBOM?: boolean; + emitDecoratorMetadata?: boolean; + experimentalDecorators?: boolean; + forceConsistentCasingInFileNames?: boolean; + inlineSourceMap?: boolean; + inlineSources?: boolean; + isolatedModules?: boolean; + jsx?: JsxEmit | ts.JsxEmit; + lib?: string[]; + locale?: string; + mapRoot?: string; + maxNodeModuleJsDepth?: number; + module?: ModuleKind | ts.ModuleKind; + moduleResolution?: ModuleResolutionKind | ts.ModuleResolutionKind; + newLine?: NewLineKind | ts.NewLineKind; + noEmit?: boolean; + noEmitHelpers?: boolean; + noEmitOnError?: boolean; + noErrorTruncation?: boolean; + noFallthroughCasesInSwitch?: boolean; + noImplicitAny?: boolean; + noImplicitReturns?: boolean; + noImplicitThis?: boolean; + noUnusedLocals?: boolean; + noUnusedParameters?: boolean; + noImplicitUseStrict?: boolean; + noLib?: boolean; + noResolve?: boolean; + out?: string; + outDir?: string; + outFile?: string; + paths?: MapLike; + preserveConstEnums?: boolean; + project?: string; + reactNamespace?: string; + removeComments?: boolean; + rootDir?: string; + rootDirs?: string[]; + skipLibCheck?: boolean; + skipDefaultLibCheck?: boolean; + sourceMap?: boolean; + sourceRoot?: string; + strictNullChecks?: boolean; + suppressExcessPropertyErrors?: boolean; + suppressImplicitAnyIndexErrors?: boolean; + target?: ScriptTarget | ts.ScriptTarget; + traceResolution?: boolean; + types?: string[]; + typeRoots?: string[]; + [option: string]: CompilerOptionsValue | undefined; + } + namespace JsxEmit { + type None = "None"; + type Preserve = "Preserve"; + type React = "React"; + } + type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React; + namespace ModuleKind { + type None = "None"; + type CommonJS = "CommonJS"; + type AMD = "AMD"; + type UMD = "UMD"; + type System = "System"; + type ES6 = "ES6"; + type ES2015 = "ES2015"; + } + type ModuleKind = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.AMD | ModuleKind.UMD | ModuleKind.System | ModuleKind.ES6 | ModuleKind.ES2015; + namespace ModuleResolutionKind { + type Classic = "Classic"; + type Node = "Node"; + } + type ModuleResolutionKind = ModuleResolutionKind.Classic | ModuleResolutionKind.Node; + namespace NewLineKind { + type Crlf = "Crlf"; + type Lf = "Lf"; + } + type NewLineKind = NewLineKind.Crlf | NewLineKind.Lf; + namespace ScriptTarget { + type ES3 = "ES3"; + type ES5 = "ES5"; + type ES6 = "ES6"; + type ES2015 = "ES2015"; + } + type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015; +} +declare namespace ts.server { + interface CompressedData { + length: number; + compressionKind: string; + data: any; + } + interface ServerHost extends System { + setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; + clearTimeout(timeoutId: any): void; + setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; + clearImmediate(timeoutId: any): void; + gc?(): void; + trace?(s: string): void; + } + interface SortedReadonlyArray extends ReadonlyArray { + " __sortedReadonlyArrayBrand": any; + } + interface TypingInstallerRequest { + readonly projectName: string; + readonly kind: "discover" | "closeProject"; + } + interface DiscoverTypings extends TypingInstallerRequest { + readonly fileNames: string[]; + readonly projectRootPath: ts.Path; + readonly compilerOptions: ts.CompilerOptions; + readonly typeAcquisition: ts.TypeAcquisition; + readonly unresolvedImports: SortedReadonlyArray; + readonly cachePath?: string; + readonly kind: "discover"; + } + interface CloseProject extends TypingInstallerRequest { + readonly kind: "closeProject"; + } + type ActionSet = "action::set"; + type ActionInvalidate = "action::invalidate"; + type EventBeginInstallTypes = "event::beginInstallTypes"; + type EventEndInstallTypes = "event::endInstallTypes"; + interface TypingInstallerResponse { + readonly kind: ActionSet | ActionInvalidate | EventBeginInstallTypes | EventEndInstallTypes; + } + interface ProjectResponse extends TypingInstallerResponse { + readonly projectName: string; + } + interface SetTypings extends ProjectResponse { + readonly typeAcquisition: ts.TypeAcquisition; + readonly compilerOptions: ts.CompilerOptions; + readonly typings: string[]; + readonly unresolvedImports: SortedReadonlyArray; + readonly kind: ActionSet; + } + interface InvalidateCachedTypings extends ProjectResponse { + readonly kind: ActionInvalidate; + } + interface InstallTypes extends ProjectResponse { + readonly kind: EventBeginInstallTypes | EventEndInstallTypes; + readonly eventId: number; + readonly typingsInstallerVersion: string; + readonly packagesToInstall: ReadonlyArray; + } + interface BeginInstallTypes extends InstallTypes { + readonly kind: EventBeginInstallTypes; + } + interface EndInstallTypes extends InstallTypes { + readonly kind: EventEndInstallTypes; + readonly installSuccess: boolean; } } declare namespace ts.server { - interface PendingErrorCheck { - fileName: NormalizedPath; - project: Project; + const ActionSet: ActionSet; + const ActionInvalidate: ActionInvalidate; + const EventBeginInstallTypes: EventBeginInstallTypes; + const EventEndInstallTypes: EventEndInstallTypes; + namespace Arguments { + const GlobalCacheLocation = "--globalTypingsCacheLocation"; + const LogFile = "--logFile"; + const EnableTelemetry = "--enableTelemetry"; } - interface EventSender { - event(payload: any, eventName: string): void; + function hasArgument(argumentName: string): boolean; + function findArgument(argumentName: string): string; +} +declare namespace ts.server { + enum LogLevel { + terse = 0, + normal = 1, + requestTime = 2, + verbose = 3, } - namespace CommandNames { - const Brace: protocol.CommandTypes.Brace; - const BraceFull: protocol.CommandTypes.BraceFull; - const BraceCompletion: protocol.CommandTypes.BraceCompletion; - const Change: protocol.CommandTypes.Change; - const Close: protocol.CommandTypes.Close; - const Completions: protocol.CommandTypes.Completions; - const CompletionsFull: protocol.CommandTypes.CompletionsFull; - const CompletionDetails: protocol.CommandTypes.CompletionDetails; - const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList; - const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile; - const Configure: protocol.CommandTypes.Configure; - const Definition: protocol.CommandTypes.Definition; - const DefinitionFull: protocol.CommandTypes.DefinitionFull; - const Exit: protocol.CommandTypes.Exit; - const Format: protocol.CommandTypes.Format; - const Formatonkey: protocol.CommandTypes.Formatonkey; - const FormatFull: protocol.CommandTypes.FormatFull; - const FormatonkeyFull: protocol.CommandTypes.FormatonkeyFull; - const FormatRangeFull: protocol.CommandTypes.FormatRangeFull; - const Geterr: protocol.CommandTypes.Geterr; - const GeterrForProject: protocol.CommandTypes.GeterrForProject; - const Implementation: protocol.CommandTypes.Implementation; - const ImplementationFull: protocol.CommandTypes.ImplementationFull; - const SemanticDiagnosticsSync: protocol.CommandTypes.SemanticDiagnosticsSync; - const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync; - const NavBar: protocol.CommandTypes.NavBar; - const NavBarFull: protocol.CommandTypes.NavBarFull; - const NavTree: protocol.CommandTypes.NavTree; - const NavTreeFull: protocol.CommandTypes.NavTreeFull; - const Navto: protocol.CommandTypes.Navto; - const NavtoFull: protocol.CommandTypes.NavtoFull; - const Occurrences: protocol.CommandTypes.Occurrences; - const DocumentHighlights: protocol.CommandTypes.DocumentHighlights; - const DocumentHighlightsFull: protocol.CommandTypes.DocumentHighlightsFull; - const Open: protocol.CommandTypes.Open; - const Quickinfo: protocol.CommandTypes.Quickinfo; - const QuickinfoFull: protocol.CommandTypes.QuickinfoFull; - const References: protocol.CommandTypes.References; - const ReferencesFull: protocol.CommandTypes.ReferencesFull; - const Reload: protocol.CommandTypes.Reload; - const Rename: protocol.CommandTypes.Rename; - const RenameInfoFull: protocol.CommandTypes.RenameInfoFull; - const RenameLocationsFull: protocol.CommandTypes.RenameLocationsFull; - const Saveto: protocol.CommandTypes.Saveto; - const SignatureHelp: protocol.CommandTypes.SignatureHelp; - const SignatureHelpFull: protocol.CommandTypes.SignatureHelpFull; - const TypeDefinition: protocol.CommandTypes.TypeDefinition; - const ProjectInfo: protocol.CommandTypes.ProjectInfo; - const ReloadProjects: protocol.CommandTypes.ReloadProjects; - const Unknown: protocol.CommandTypes.Unknown; - const OpenExternalProject: protocol.CommandTypes.OpenExternalProject; - const OpenExternalProjects: protocol.CommandTypes.OpenExternalProjects; - const CloseExternalProject: protocol.CommandTypes.CloseExternalProject; - const SynchronizeProjectList: protocol.CommandTypes.SynchronizeProjectList; - const ApplyChangedToOpenFiles: protocol.CommandTypes.ApplyChangedToOpenFiles; - const EncodedSemanticClassificationsFull: protocol.CommandTypes.EncodedSemanticClassificationsFull; - const Cleanup: protocol.CommandTypes.Cleanup; - const OutliningSpans: protocol.CommandTypes.OutliningSpans; - const TodoComments: protocol.CommandTypes.TodoComments; - const Indentation: protocol.CommandTypes.Indentation; - const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate; - const CompilerOptionsDiagnosticsFull: protocol.CommandTypes.CompilerOptionsDiagnosticsFull; - const NameOrDottedNameSpan: protocol.CommandTypes.NameOrDottedNameSpan; - const BreakpointStatement: protocol.CommandTypes.BreakpointStatement; - const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects; - const GetCodeFixes: protocol.CommandTypes.GetCodeFixes; - const GetCodeFixesFull: protocol.CommandTypes.GetCodeFixesFull; - const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes; + const emptyArray: ReadonlyArray; + interface Logger { + close(): void; + hasLevel(level: LogLevel): boolean; + loggingEnabled(): boolean; + perftrc(s: string): void; + info(s: string): void; + startGroup(): void; + endGroup(): void; + msg(s: string, type?: Msg.Types): void; + getLogFileName(): string; } - function formatMessage(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string; - class Session implements EventSender { - private host; - protected readonly typingsInstaller: ITypingsInstaller; - private byteLength; - private hrtime; - protected logger: Logger; - protected readonly canUseEvents: boolean; - private readonly gcTimer; - protected projectService: ProjectService; - private errorTimer; - private immediateId; - private changeSeq; - private eventHander; - constructor(host: ServerHost, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller: ITypingsInstaller, byteLength: (buf: string, encoding?: string) => number, hrtime: (start?: number[]) => number[], logger: Logger, canUseEvents: boolean, eventHandler?: ProjectServiceEventHandler); - private defaultEventHandler(event); - logError(err: Error, cmd: string): void; - send(msg: protocol.Message): void; - configFileDiagnosticEvent(triggerFile: string, configFile: string, diagnostics: ts.Diagnostic[]): void; - event(info: any, eventName: string): void; - output(info: any, cmdName: string, reqSeq?: number, errorMsg?: string): void; - private semanticCheck(file, project); - private syntacticCheck(file, project); - private updateProjectStructure(seq, matchSeq, ms?); - private updateErrorCheck(checkList, seq, matchSeq, ms?, followMs?, requireOpen?); - private cleanProjects(caption, projects); - private cleanup(); - private getEncodedSemanticClassifications(args); - private getProject(projectFileName); - private getCompilerOptionsDiagnostics(args); - private convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo); - private getDiagnosticsWorker(args, isSemantic, selector, includeLinePosition); - private getDefinition(args, simplifiedResult); - private getTypeDefinition(args); - private getImplementation(args, simplifiedResult); - private getOccurrences(args); - private getSyntacticDiagnosticsSync(args); - private getSemanticDiagnosticsSync(args); - private getDocumentHighlights(args, simplifiedResult); - private setCompilerOptionsForInferredProjects(args); - private getProjectInfo(args); - private getProjectInfoWorker(uncheckedFileName, projectFileName, needFileNameList); - private getRenameInfo(args); - private getProjects(args); - private getRenameLocations(args, simplifiedResult); - private getReferences(args, simplifiedResult); - private openClientFile(fileName, fileContent?, scriptKind?); - private getPosition(args, scriptInfo); - private getFileAndProject(args, errorOnMissingProject?); - private getFileAndProjectWithoutRefreshingInferredProjects(args, errorOnMissingProject?); - private getFileAndProjectWorker(uncheckedFileName, projectFileName, refreshInferredProjects, errorOnMissingProject); - private getOutliningSpans(args); - private getTodoComments(args); - private getDocCommentTemplate(args); - private getIndentation(args); - private getBreakpointStatement(args); - private getNameOrDottedNameSpan(args); - private isValidBraceCompletion(args); - private getQuickInfoWorker(args, simplifiedResult); - private getFormattingEditsForRange(args); - private getFormattingEditsForRangeFull(args); - private getFormattingEditsForDocumentFull(args); - private getFormattingEditsAfterKeystrokeFull(args); - private getFormattingEditsAfterKeystroke(args); - private getCompletions(args, simplifiedResult); - private getCompletionEntryDetails(args); - private getCompileOnSaveAffectedFileList(args); - private emitFile(args); - private getSignatureHelpItems(args, simplifiedResult); - private getDiagnostics(delay, fileNames); - private change(args); - private reload(args, reqSeq); - private saveToTmp(fileName, tempFileName); - private closeClientFile(fileName); - private decorateNavigationBarItems(items, scriptInfo); - private getNavigationBarItems(args, simplifiedResult); - private decorateNavigationTree(tree, scriptInfo); - private decorateSpan(span, scriptInfo); - private getNavigationTree(args, simplifiedResult); - private getNavigateToItems(args, simplifiedResult); - private getSupportedCodeFixes(); - private getCodeFixes(args, simplifiedResult); - private mapCodeAction(codeAction, scriptInfo); - private convertTextChangeToCodeEdit(change, scriptInfo); - private getBraceMatching(args, simplifiedResult); - getDiagnosticsForProject(delay: number, fileName: string): void; - getCanonicalFileName(fileName: string): string; - exit(): void; - private notRequired(); - private requiredResponse(response); - private handlers; - addProtocolHandler(command: string, handler: (request: protocol.Request) => { - response?: any; - responseRequired: boolean; - }): void; - executeCommand(request: protocol.Request): { - response?: any; - responseRequired?: boolean; - }; - onMessage(message: string): void; + namespace Msg { + type Err = "Err"; + const Err: Err; + type Info = "Info"; + const Info: Info; + type Perf = "Perf"; + const Perf: Perf; + type Types = Err | Info | Perf; + } + function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, cachePath?: string): DiscoverTypings; + namespace Errors { + function ThrowNoProject(): never; + function ThrowProjectLanguageServiceDisabled(): never; + function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never; + } + function getDefaultFormatCodeSettings(host: ServerHost): FormatCodeSettings; + function mergeMaps(target: MapLike, source: MapLike): void; + function removeItemFromSet(items: T[], itemToRemove: T): void; + type NormalizedPath = string & { + __normalizedPathTag: any; + }; + function toNormalizedPath(fileName: string): NormalizedPath; + function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path; + function asNormalizedPath(fileName: string): NormalizedPath; + interface NormalizedPathMap { + get(path: NormalizedPath): T; + set(path: NormalizedPath, value: T): void; + contains(path: NormalizedPath): boolean; + remove(path: NormalizedPath): void; + } + function createNormalizedPathMap(): NormalizedPathMap; + interface ProjectOptions { + configHasFilesProperty?: boolean; + files?: string[]; + wildcardDirectories?: Map; + compilerOptions?: CompilerOptions; + typeAcquisition?: TypeAcquisition; + compileOnSave?: boolean; + } + function isInferredProjectName(name: string): boolean; + function makeInferredProjectName(counter: number): string; + function toSortedReadonlyArray(arr: string[]): SortedReadonlyArray; + class ThrottledOperations { + private readonly host; + private pendingTimeouts; + constructor(host: ServerHost); + schedule(operationId: string, delay: number, cb: () => void): void; + private static run(self, operationId, cb); + } + class GcTimer { + private readonly host; + private readonly delay; + private readonly logger; + private timerId; + constructor(host: ServerHost, delay: number, logger: Logger); + scheduleCollect(): void; + private static run(self); } } declare namespace ts.server { @@ -11716,178 +3927,541 @@ declare namespace ts.server { lineCount(): number; } } -declare let debugObjectHost: any; -declare namespace ts { - interface ScriptSnapshotShim { - getText(start: number, end: number): string; - getLength(): number; - getChangeRange(oldSnapshot: ScriptSnapshotShim): string; - dispose?(): void; - } - interface Logger { - log(s: string): void; - trace(s: string): void; - error(s: string): void; - } - interface LanguageServiceShimHost extends Logger { - getCompilationSettings(): string; - getScriptFileNames(): string; - getScriptKind?(fileName: string): ScriptKind; - getScriptVersion(fileName: string): string; - getScriptSnapshot(fileName: string): ScriptSnapshotShim; - getLocalizedDiagnosticMessages(): string; - getCancellationToken(): HostCancellationToken; - getCurrentDirectory(): string; - getDirectories(path: string): string; - getDefaultLibFileName(options: string): string; - getNewLine?(): string; - getProjectVersion?(): string; - useCaseSensitiveFileNames?(): boolean; - getTypeRootsVersion?(): number; - readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; - readFile(path: string, encoding?: string): string; - fileExists(path: string): boolean; - getModuleResolutionsForFile?(fileName: string): string; - getTypeReferenceDirectiveResolutionsForFile?(fileName: string): string; - directoryExists(directoryName: string): boolean; - } - interface CoreServicesShimHost extends Logger { - directoryExists(directoryName: string): boolean; - fileExists(fileName: string): boolean; - getCurrentDirectory(): string; - getDirectories(path: string): string; - readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; - readFile(fileName: string): string; - realpath?(path: string): string; - trace(s: string): void; - useCaseSensitiveFileNames?(): boolean; - } - interface IFileReference { - path: string; - position: number; - length: number; - } - interface ShimFactory { - registerShim(shim: Shim): void; - unregisterShim(shim: Shim): void; - } - interface Shim { - dispose(_dummy: any): void; - } - interface LanguageServiceShim extends Shim { - languageService: LanguageService; - dispose(_dummy: any): void; - refresh(throwOnError: boolean): void; - cleanupSemanticCache(): void; - getSyntacticDiagnostics(fileName: string): string; - getSemanticDiagnostics(fileName: string): string; - getCompilerOptionsDiagnostics(): string; - getSyntacticClassifications(fileName: string, start: number, length: number): string; - getSemanticClassifications(fileName: string, start: number, length: number): string; - getEncodedSyntacticClassifications(fileName: string, start: number, length: number): string; - getEncodedSemanticClassifications(fileName: string, start: number, length: number): string; - getCompletionsAtPosition(fileName: string, position: number): string; - getCompletionEntryDetails(fileName: string, position: number, entryName: string): string; - getQuickInfoAtPosition(fileName: string, position: number): string; - getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): string; - getBreakpointStatementAtPosition(fileName: string, position: number): string; - getSignatureHelpItems(fileName: string, position: number): string; - getRenameInfo(fileName: string, position: number): string; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): string; - getDefinitionAtPosition(fileName: string, position: number): string; - getTypeDefinitionAtPosition(fileName: string, position: number): string; - getImplementationAtPosition(fileName: string, position: number): string; - getReferencesAtPosition(fileName: string, position: number): string; - findReferences(fileName: string, position: number): string; - getOccurrencesAtPosition(fileName: string, position: number): string; - getDocumentHighlights(fileName: string, position: number, filesToSearch: string): string; - getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string): string; - getNavigationBarItems(fileName: string): string; - getNavigationTree(fileName: string): string; - getOutliningSpans(fileName: string): string; - getTodoComments(fileName: string, todoCommentDescriptors: string): string; - getBraceMatchingAtPosition(fileName: string, position: number): string; - getIndentationAtPosition(fileName: string, position: number, options: string): string; - getFormattingEditsForRange(fileName: string, start: number, end: number, options: string): string; - getFormattingEditsForDocument(fileName: string, options: string): string; - getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: string): string; - getDocCommentTemplateAtPosition(fileName: string, position: number): string; - isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string; - getEmitOutput(fileName: string): string; - getEmitOutputObject(fileName: string): EmitOutput; - } - interface ClassifierShim extends Shim { - getEncodedLexicalClassifications(text: string, lexState: EndOfLineState, syntacticClassifierAbsent?: boolean): string; - getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent?: boolean): string; - } - interface CoreServicesShim extends Shim { - getAutomaticTypeDirectiveNames(compilerOptionsJson: string): string; - getPreProcessedFileInfo(fileName: string, sourceText: IScriptSnapshot): string; - getTSConfigFileInfo(fileName: string, sourceText: IScriptSnapshot): string; - getDefaultCompilationSettings(): string; - discoverTypings(discoverTypingsJson: string): string; - } - class LanguageServiceShimHostAdapter implements LanguageServiceHost { - private shimHost; - private files; - private loggingEnabled; - private tracingEnabled; - resolveModuleNames: (moduleName: string[], containingFile: string) => ResolvedModuleFull[]; - resolveTypeReferenceDirectives: (typeDirectiveNames: string[], containingFile: string) => ResolvedTypeReferenceDirective[]; - directoryExists: (directoryName: string) => boolean; - constructor(shimHost: LanguageServiceShimHost); - log(s: string): void; - trace(s: string): void; - error(s: string): void; - getProjectVersion(): string; - getTypeRootsVersion(): number; - useCaseSensitiveFileNames(): boolean; - getCompilationSettings(): CompilerOptions; - getScriptFileNames(): string[]; - getScriptSnapshot(fileName: string): IScriptSnapshot; - getScriptKind(fileName: string): ScriptKind; - getScriptVersion(fileName: string): string; - getLocalizedDiagnosticMessages(): any; - getCancellationToken(): HostCancellationToken; - getCurrentDirectory(): string; - getDirectories(path: string): string[]; - getDefaultLibFileName(options: CompilerOptions): string; - readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[], depth?: number): string[]; - readFile(path: string, encoding?: string): string; - fileExists(path: string): boolean; - } - class CoreServicesShimHostAdapter implements ParseConfigHost, ModuleResolutionHost { - private shimHost; - directoryExists: (directoryName: string) => boolean; - realpath: (path: string) => string; - useCaseSensitiveFileNames: boolean; - constructor(shimHost: CoreServicesShimHost); - readDirectory(rootDir: string, extensions: string[], exclude: string[], include: string[], depth?: number): string[]; - fileExists(fileName: string): boolean; - readFile(fileName: string): string; - private readDirectoryFallback(rootDir, extension, exclude); - getDirectories(path: string): string[]; - } - function realizeDiagnostics(diagnostics: Diagnostic[], newLine: string): { - message: string; - start: number; - length: number; - category: string; - code: number; - }[]; - class TypeScriptServicesFactory implements ShimFactory { - private _shims; - private documentRegistry; - getServicesVersion(): string; - createLanguageServiceShim(host: LanguageServiceShimHost): LanguageServiceShim; - createClassifierShim(logger: Logger): ClassifierShim; - createCoreServicesShim(host: CoreServicesShimHost): CoreServicesShim; +declare namespace ts.server { + class ScriptInfo { + private readonly host; + readonly fileName: NormalizedPath; + readonly scriptKind: ScriptKind; + hasMixedContent: boolean; + readonly containingProjects: Project[]; + private formatCodeSettings; + readonly path: Path; + private fileWatcher; + private textStorage; + private isOpen; + constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent?: boolean); + isScriptOpen(): boolean; + open(newText: string): void; close(): void; - registerShim(shim: Shim): void; - unregisterShim(shim: Shim): void; + getSnapshot(): IScriptSnapshot; + getFormatCodeSettings(): FormatCodeSettings; + attachToProject(project: Project): boolean; + isAttached(project: Project): boolean; + detachFromProject(project: Project): void; + detachAllProjects(): void; + getDefaultProject(): Project; + registerFileUpdate(): void; + setFormatOptions(formatSettings: FormatCodeSettings): void; + setWatcher(watcher: FileWatcher): void; + stopWatcher(): void; + getLatestVersion(): string; + reload(script: string): void; + saveTo(fileName: string): void; + reloadFromFile(tempFileName?: NormalizedPath): void; + getLineInfo(line: number): ILineInfo; + editContent(start: number, end: number, newText: string): void; + markContainingProjectsAsDirty(): void; + lineToTextSpan(line: number): TextSpan; + lineOffsetToPosition(line: number, offset: number): number; + positionToLineOffset(position: number): ILineInfo; } } -declare namespace TypeScript.Services { - const TypeScriptServicesFactory: typeof ts.TypeScriptServicesFactory; +declare namespace ts.server { + class LSHost implements ts.LanguageServiceHost, ModuleResolutionHost { + private readonly host; + private readonly project; + private readonly cancellationToken; + private compilationSettings; + private readonly resolvedModuleNames; + private readonly resolvedTypeReferenceDirectives; + private readonly getCanonicalFileName; + private filesWithChangedSetOfUnresolvedImports; + private readonly resolveModuleName; + readonly trace: (s: string) => void; + readonly realpath?: (path: string) => string; + constructor(host: ServerHost, project: Project, cancellationToken: HostCancellationToken); + startRecordingFilesWithChangedResolutions(): void; + finishRecordingFilesWithChangedResolutions(): Path[]; + private resolveNamesWithLocalCache(names, containingFile, cache, loader, getResult, getResultFileName, logChanges); + getNewLine(): string; + getProjectVersion(): string; + getCompilationSettings(): CompilerOptions; + useCaseSensitiveFileNames(): boolean; + getCancellationToken(): HostCancellationToken; + resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModuleFull[]; + getDefaultLibFileName(): string; + getScriptSnapshot(filename: string): ts.IScriptSnapshot; + getScriptFileNames(): string[]; + getTypeRootsVersion(): number; + getScriptKind(fileName: string): ScriptKind; + getScriptVersion(filename: string): string; + getCurrentDirectory(): string; + resolvePath(path: string): string; + fileExists(path: string): boolean; + readFile(fileName: string): string; + directoryExists(path: string): boolean; + readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; + getDirectories(path: string): string[]; + notifyFileRemoved(info: ScriptInfo): void; + setCompilationSettings(opt: ts.CompilerOptions): void; + } } -declare const toolsVersion = "2.2"; +declare namespace ts.server { + interface ITypingsInstaller { + enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray): void; + attach(projectService: ProjectService): void; + onProjectClosed(p: Project): void; + readonly globalTypingsCacheLocation: string; + } + const nullTypingsInstaller: ITypingsInstaller; + class TypingsCache { + private readonly installer; + private readonly perProjectCache; + constructor(installer: ITypingsInstaller); + getTypingsForProject(project: Project, unresolvedImports: SortedReadonlyArray, forceRefresh: boolean): SortedReadonlyArray; + updateTypingsForProject(projectName: string, compilerOptions: CompilerOptions, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, newTypings: string[]): void; + deleteTypingsForProject(projectName: string): void; + onProjectClosed(project: Project): void; + } +} +declare namespace ts.server { + enum ProjectKind { + Inferred = 0, + Configured = 1, + External = 2, + } + function allRootFilesAreJsOrDts(project: Project): boolean; + function allFilesAreJsOrDts(project: Project): boolean; + class UnresolvedImportsMap { + readonly perFileMap: FileMap>; + private version; + clear(): void; + getVersion(): number; + remove(path: Path): void; + get(path: Path): ReadonlyArray; + set(path: Path, value: ReadonlyArray): void; + } + abstract class Project { + private readonly projectName; + readonly projectKind: ProjectKind; + readonly projectService: ProjectService; + private documentRegistry; + private compilerOptions; + compileOnSaveEnabled: boolean; + private rootFiles; + private rootFilesMap; + private lsHost; + private program; + private cachedUnresolvedImportsPerFile; + private lastCachedUnresolvedImportsList; + private readonly languageService; + languageServiceEnabled: boolean; + builder: Builder; + private updatedFileNames; + private lastReportedFileNames; + private lastReportedVersion; + private projectStructureVersion; + private projectStateVersion; + private typingFiles; + protected projectErrors: Diagnostic[]; + typesVersion: number; + isNonTsProject(): boolean; + isJsOnlyProject(): boolean; + getCachedUnresolvedImportsPerFile_TestOnly(): UnresolvedImportsMap; + constructor(projectName: string, projectKind: ProjectKind, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, languageServiceEnabled: boolean, compilerOptions: CompilerOptions, compileOnSaveEnabled: boolean); + private setInternalCompilerOptionsForEmittingJsFiles(); + getProjectErrors(): Diagnostic[]; + getLanguageService(ensureSynchronized?: boolean): LanguageService; + getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[]; + getProjectVersion(): string; + enableLanguageService(): void; + disableLanguageService(): void; + getProjectName(): string; + abstract getProjectRootPath(): string | undefined; + abstract getTypeAcquisition(): TypeAcquisition; + getSourceFile(path: Path): SourceFile; + updateTypes(): void; + close(): void; + getCompilerOptions(): CompilerOptions; + hasRoots(): boolean; + getRootFiles(): NormalizedPath[]; + getRootFilesLSHost(): string[]; + getRootScriptInfos(): ScriptInfo[]; + getScriptInfos(): ScriptInfo[]; + getFileEmitOutput(info: ScriptInfo, emitOnlyDtsFiles: boolean): EmitOutput; + getFileNames(excludeFilesFromExternalLibraries?: boolean): NormalizedPath[]; + getAllEmittableFiles(): string[]; + containsScriptInfo(info: ScriptInfo): boolean; + containsFile(filename: NormalizedPath, requireOpen?: boolean): boolean; + isRoot(info: ScriptInfo): boolean; + addRoot(info: ScriptInfo): void; + removeFile(info: ScriptInfo, detachFromProject?: boolean): void; + registerFileUpdate(fileName: string): void; + markAsDirty(): void; + private extractUnresolvedImportsFromSourceFile(file, result); + updateGraph(): boolean; + private setTypings(typings); + private updateGraphWorker(); + getScriptInfoLSHost(fileName: string): ScriptInfo; + getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo; + getScriptInfo(uncheckedFileName: string): ScriptInfo; + filesToString(): string; + setCompilerOptions(compilerOptions: CompilerOptions): void; + reloadScript(filename: NormalizedPath, tempFileName?: NormalizedPath): boolean; + getReferencedFiles(path: Path): Path[]; + private removeRootFileIfNecessary(info); + } + class InferredProject extends Project { + private static newName; + directoriesWatchedForTsconfig: string[]; + constructor(projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions); + getProjectRootPath(): string; + close(): void; + getTypeAcquisition(): TypeAcquisition; + } + class ConfiguredProject extends Project { + private wildcardDirectories; + compileOnSaveEnabled: boolean; + private typeAcquisition; + private projectFileWatcher; + private directoryWatcher; + private directoriesWatchedForWildcards; + private typeRootsWatchers; + readonly canonicalConfigFilePath: NormalizedPath; + openRefCount: number; + constructor(configFileName: NormalizedPath, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, compilerOptions: CompilerOptions, wildcardDirectories: Map, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean); + getConfigFilePath(): string; + getProjectRootPath(): string; + setProjectErrors(projectErrors: Diagnostic[]): void; + setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; + getTypeAcquisition(): TypeAcquisition; + watchConfigFile(callback: (project: ConfiguredProject) => void): void; + watchTypeRoots(callback: (project: ConfiguredProject, path: string) => void): void; + watchConfigDirectory(callback: (project: ConfiguredProject, path: string) => void): void; + watchWildcards(callback: (project: ConfiguredProject, path: string) => void): void; + stopWatchingDirectory(): void; + close(): void; + addOpenRef(): void; + deleteOpenRef(): number; + getEffectiveTypeRoots(): string[]; + } + class ExternalProject extends Project { + compileOnSaveEnabled: boolean; + private readonly projectFilePath; + private typeAcquisition; + constructor(externalProjectName: string, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean, projectFilePath?: string); + getProjectRootPath(): string; + getTypeAcquisition(): TypeAcquisition; + setProjectErrors(projectErrors: Diagnostic[]): void; + setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; + } +} +declare namespace ts.server { + const maxProgramSizeForNonTsFiles: number; + const ContextEvent = "context"; + const ConfigFileDiagEvent = "configFileDiag"; + const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; + interface ContextEvent { + eventName: typeof ContextEvent; + data: { + project: Project; + fileName: NormalizedPath; + }; + } + interface ConfigFileDiagEvent { + eventName: typeof ConfigFileDiagEvent; + data: { + triggerFile: string; + configFileName: string; + diagnostics: Diagnostic[]; + }; + } + interface ProjectLanguageServiceStateEvent { + eventName: typeof ProjectLanguageServiceStateEvent; + data: { + project: Project; + languageServiceEnabled: boolean; + }; + } + type ProjectServiceEvent = ContextEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent; + interface ProjectServiceEventHandler { + (event: ProjectServiceEvent): void; + } + function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings; + function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin; + function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind; + function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind; + function combineProjectOutput(projects: Project[], action: (project: Project) => T[], comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean): T[]; + interface HostConfiguration { + formatCodeOptions: FormatCodeSettings; + hostInfo: string; + extraFileExtensions?: FileExtensionInfo[]; + } + interface OpenConfiguredProjectResult { + configFileName?: NormalizedPath; + configFileErrors?: Diagnostic[]; + } + class ProjectService { + readonly host: ServerHost; + readonly logger: Logger; + readonly cancellationToken: HostCancellationToken; + readonly useSingleInferredProject: boolean; + readonly typingsInstaller: ITypingsInstaller; + private readonly eventHandler; + readonly typingsCache: TypingsCache; + private readonly documentRegistry; + private readonly filenameToScriptInfo; + private readonly externalProjectToConfiguredProjectMap; + readonly externalProjects: ExternalProject[]; + readonly inferredProjects: InferredProject[]; + readonly configuredProjects: ConfiguredProject[]; + readonly openFiles: ScriptInfo[]; + private compilerOptionsForInferredProjects; + private compileOnSaveForInferredProjects; + private readonly directoryWatchers; + private readonly throttledOperations; + private readonly hostConfiguration; + private changedFiles; + readonly toCanonicalFileName: (f: string) => string; + lastDeletedFile: ScriptInfo; + constructor(host: ServerHost, logger: Logger, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller?: ITypingsInstaller, eventHandler?: ProjectServiceEventHandler); + ensureInferredProjectsUpToDate_TestOnly(): void; + getCompilerOptionsForInferredProjects(): CompilerOptions; + onUpdateLanguageServiceStateForProject(project: Project, languageServiceEnabled: boolean): void; + updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void; + setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void; + stopWatchingDirectory(directory: string): void; + findProject(projectName: string): Project; + getDefaultProjectForFile(fileName: NormalizedPath, refreshInferredProjects: boolean): Project; + private ensureInferredProjectsUpToDate(); + private findContainingExternalProject(fileName); + getFormatCodeOptions(file?: NormalizedPath): FormatCodeSettings; + private updateProjectGraphs(projects); + private onSourceFileChanged(fileName); + private handleDeletedFile(info); + private onTypeRootFileChanged(project, fileName); + private onSourceFileInDirectoryChangedForConfiguredProject(project, fileName); + private handleChangeInSourceFileForConfiguredProject(project, triggerFile); + private onConfigChangedForConfiguredProject(project); + private onConfigFileAddedForInferredProject(fileName); + private getCanonicalFileName(fileName); + private removeProject(project); + private assignScriptInfoToInferredProjectIfNecessary(info, addToListOfOpenFiles); + private closeOpenFile(info); + private openOrUpdateConfiguredProjectForFile(fileName); + private findConfigFile(searchPath); + private printProjects(); + private findConfiguredProjectByProjectName(configFileName); + private findExternalProjectByProjectName(projectFileName); + private convertConfigFileContentToProjectOptions(configFilename); + private exceededTotalSizeLimitForNonTsFiles(options, fileNames, propertyReader); + private createAndAddExternalProject(projectFileName, files, options, typeAcquisition); + private reportConfigFileDiagnostics(configFileName, diagnostics, triggerFile); + private createAndAddConfiguredProject(configFileName, projectOptions, configFileErrors, clientFileName?); + private watchConfigDirectoryForProject(project, options); + private addFilesToProjectAndUpdateGraph(project, files, propertyReader, clientFileName, typeAcquisition, configFileErrors); + private openConfigFile(configFileName, clientFileName?); + private updateNonInferredProject(project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave, configFileErrors); + private updateConfiguredProject(project); + createInferredProjectWithRootFileIfNecessary(root: ScriptInfo): InferredProject; + getOrCreateScriptInfo(uncheckedFileName: string, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind): ScriptInfo; + getScriptInfo(uncheckedFileName: string): ScriptInfo; + getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): ScriptInfo; + getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo; + getScriptInfoForPath(fileName: Path): ScriptInfo; + setHostConfiguration(args: protocol.ConfigureRequestArguments): void; + closeLog(): void; + reloadProjects(): void; + refreshInferredProjects(): void; + openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind): OpenConfiguredProjectResult; + openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): OpenConfiguredProjectResult; + closeClientFile(uncheckedFileName: string): void; + private collectChanges(lastKnownProjectVersions, currentProjects, result); + private closeConfiguredProject(configFile); + closeExternalProject(uncheckedFileName: string, suppressRefresh?: boolean): void; + openExternalProjects(projects: protocol.ExternalProject[]): void; + openExternalProject(proj: protocol.ExternalProject, suppressRefreshOfInferredProjects?: boolean): void; + } +} +declare namespace ts.server { + interface PendingErrorCheck { + fileName: NormalizedPath; + project: Project; + } + interface EventSender { + event(payload: any, eventName: string): void; + } + namespace CommandNames { + const Brace: protocol.CommandTypes.Brace; + const BraceCompletion: protocol.CommandTypes.BraceCompletion; + const Change: protocol.CommandTypes.Change; + const Close: protocol.CommandTypes.Close; + const Completions: protocol.CommandTypes.Completions; + const CompletionDetails: protocol.CommandTypes.CompletionDetails; + const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList; + const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile; + const Configure: protocol.CommandTypes.Configure; + const Definition: protocol.CommandTypes.Definition; + const Exit: protocol.CommandTypes.Exit; + const Format: protocol.CommandTypes.Format; + const Formatonkey: protocol.CommandTypes.Formatonkey; + const Geterr: protocol.CommandTypes.Geterr; + const GeterrForProject: protocol.CommandTypes.GeterrForProject; + const Implementation: protocol.CommandTypes.Implementation; + const SemanticDiagnosticsSync: protocol.CommandTypes.SemanticDiagnosticsSync; + const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync; + const NavBar: protocol.CommandTypes.NavBar; + const NavTree: protocol.CommandTypes.NavTree; + const NavTreeFull: protocol.CommandTypes.NavTreeFull; + const Navto: protocol.CommandTypes.Navto; + const Occurrences: protocol.CommandTypes.Occurrences; + const DocumentHighlights: protocol.CommandTypes.DocumentHighlights; + const Open: protocol.CommandTypes.Open; + const Quickinfo: protocol.CommandTypes.Quickinfo; + const References: protocol.CommandTypes.References; + const Reload: protocol.CommandTypes.Reload; + const Rename: protocol.CommandTypes.Rename; + const Saveto: protocol.CommandTypes.Saveto; + const SignatureHelp: protocol.CommandTypes.SignatureHelp; + const TypeDefinition: protocol.CommandTypes.TypeDefinition; + const ProjectInfo: protocol.CommandTypes.ProjectInfo; + const ReloadProjects: protocol.CommandTypes.ReloadProjects; + const Unknown: protocol.CommandTypes.Unknown; + const OpenExternalProject: protocol.CommandTypes.OpenExternalProject; + const OpenExternalProjects: protocol.CommandTypes.OpenExternalProjects; + const CloseExternalProject: protocol.CommandTypes.CloseExternalProject; + const TodoComments: protocol.CommandTypes.TodoComments; + const Indentation: protocol.CommandTypes.Indentation; + const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate; + const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects; + const GetCodeFixes: protocol.CommandTypes.GetCodeFixes; + const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes; + } + function formatMessage(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string; + class Session implements EventSender { + private host; + protected readonly typingsInstaller: ITypingsInstaller; + private byteLength; + private hrtime; + protected logger: Logger; + protected readonly canUseEvents: boolean; + private readonly gcTimer; + protected projectService: ProjectService; + private errorTimer; + private immediateId; + private changeSeq; + private eventHander; + constructor(host: ServerHost, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller: ITypingsInstaller, byteLength: (buf: string, encoding?: string) => number, hrtime: (start?: number[]) => number[], logger: Logger, canUseEvents: boolean, eventHandler?: ProjectServiceEventHandler); + private defaultEventHandler(event); + logError(err: Error, cmd: string): void; + send(msg: protocol.Message): void; + configFileDiagnosticEvent(triggerFile: string, configFile: string, diagnostics: ts.Diagnostic[]): void; + event(info: any, eventName: string): void; + output(info: any, cmdName: string, reqSeq?: number, errorMsg?: string): void; + private semanticCheck(file, project); + private syntacticCheck(file, project); + private updateProjectStructure(seq, matchSeq, ms?); + private updateErrorCheck(checkList, seq, matchSeq, ms?, followMs?, requireOpen?); + private cleanProjects(caption, projects); + private cleanup(); + private getEncodedSemanticClassifications(args); + private getProject(projectFileName); + private getCompilerOptionsDiagnostics(args); + private convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo); + private getDiagnosticsWorker(args, isSemantic, selector, includeLinePosition); + private getDefinition(args, simplifiedResult); + private getTypeDefinition(args); + private getImplementation(args, simplifiedResult); + private getOccurrences(args); + private getSyntacticDiagnosticsSync(args); + private getSemanticDiagnosticsSync(args); + private getDocumentHighlights(args, simplifiedResult); + private setCompilerOptionsForInferredProjects(args); + private getProjectInfo(args); + private getProjectInfoWorker(uncheckedFileName, projectFileName, needFileNameList); + private getRenameInfo(args); + private getProjects(args); + private getRenameLocations(args, simplifiedResult); + private getReferences(args, simplifiedResult); + private openClientFile(fileName, fileContent?, scriptKind?); + private getPosition(args, scriptInfo); + private getFileAndProject(args, errorOnMissingProject?); + private getFileAndProjectWithoutRefreshingInferredProjects(args, errorOnMissingProject?); + private getFileAndProjectWorker(uncheckedFileName, projectFileName, refreshInferredProjects, errorOnMissingProject); + private getOutliningSpans(args); + private getTodoComments(args); + private getDocCommentTemplate(args); + private getIndentation(args); + private getBreakpointStatement(args); + private getNameOrDottedNameSpan(args); + private isValidBraceCompletion(args); + private getQuickInfoWorker(args, simplifiedResult); + private getFormattingEditsForRange(args); + private getFormattingEditsForRangeFull(args); + private getFormattingEditsForDocumentFull(args); + private getFormattingEditsAfterKeystrokeFull(args); + private getFormattingEditsAfterKeystroke(args); + private getCompletions(args, simplifiedResult); + private getCompletionEntryDetails(args); + private getCompileOnSaveAffectedFileList(args); + private emitFile(args); + private getSignatureHelpItems(args, simplifiedResult); + private getDiagnostics(delay, fileNames); + private change(args); + private reload(args, reqSeq); + private saveToTmp(fileName, tempFileName); + private closeClientFile(fileName); + private decorateNavigationBarItems(items, scriptInfo); + private getNavigationBarItems(args, simplifiedResult); + private decorateNavigationTree(tree, scriptInfo); + private decorateSpan(span, scriptInfo); + private getNavigationTree(args, simplifiedResult); + private getNavigateToItems(args, simplifiedResult); + private getSupportedCodeFixes(); + private getCodeFixes(args, simplifiedResult); + private mapCodeAction(codeAction, scriptInfo); + private convertTextChangeToCodeEdit(change, scriptInfo); + private getBraceMatching(args, simplifiedResult); + getDiagnosticsForProject(delay: number, fileName: string): void; + getCanonicalFileName(fileName: string): string; + exit(): void; + private notRequired(); + private requiredResponse(response); + private handlers; + addProtocolHandler(command: string, handler: (request: protocol.Request) => { + response?: any; + responseRequired: boolean; + }): void; + executeCommand(request: protocol.Request): { + response?: any; + responseRequired?: boolean; + }; + onMessage(message: string): void; + } +} +declare namespace ts.server { + function shouldEmitFile(scriptInfo: ScriptInfo): boolean; + class BuilderFileInfo { + readonly scriptInfo: ScriptInfo; + readonly project: Project; + private lastCheckedShapeSignature; + constructor(scriptInfo: ScriptInfo, project: Project); + isExternalModuleOrHasOnlyAmbientExternalModules(): boolean; + private containsOnlyAmbientModules(sourceFile); + private computeHash(text); + private getSourceFile(); + updateShapeSignature(): boolean; + } + interface Builder { + readonly project: Project; + getFilesAffectedBy(scriptInfo: ScriptInfo): string[]; + onProjectUpdateGraph(): void; + emitFile(scriptInfo: ScriptInfo, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => void): boolean; + clear(): void; + } + function createBuilder(project: Project): Builder; +} + +export = ts; +export as namespace ts; \ No newline at end of file diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 842c5458a89..ab1a5cdfe05 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -13,11 +13,16 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ts; (function (ts) { var OperationCanceledException = (function () { @@ -206,7 +211,7 @@ var ts; ts.toPath = toPath; function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -225,7 +230,7 @@ var ts; ts.zipWith = zipWith; function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -235,7 +240,7 @@ var ts; } ts.every = every; function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -245,7 +250,7 @@ var ts; } ts.find = find; function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -268,7 +273,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -278,7 +283,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -981,6 +986,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -2475,7 +2481,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_be_declared_in_an_ambient_context_1086", message: "An accessor cannot be declared in an ambient context." }, _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", message: "'{0}' modifier cannot appear on a constructor declaration." }, _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_parameter_1090", message: "'{0}' modifier cannot appear on a parameter." }, @@ -2632,6 +2638,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "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_2301", message: "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_2302", message: "Static members cannot reference class type parameters." }, @@ -2861,6 +2868,8 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "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: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2870,6 +2879,7 @@ var ts; Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "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: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -2921,6 +2931,8 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "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_4002", message: "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_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -3089,6 +3101,7 @@ var ts; Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -3102,10 +3115,10 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, @@ -3154,6 +3167,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -3210,22 +3225,25 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); var ts; @@ -3606,7 +3624,7 @@ var ts; if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { var ch = text.charCodeAt(pos); if ((pos + mergeConflictMarkerLength) < text.length) { - for (var i = 0, n = mergeConflictMarkerLength; i < n; i++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -3792,7 +3810,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -5539,6 +5557,7 @@ var ts; if (resolutionStack === void 0) { resolutionStack = []; } if (extraFileExtensions === void 0) { extraFileExtensions = []; } var errors = []; + basePath = ts.normalizeSlashes(basePath); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -5905,385 +5924,6 @@ var ts; } })(ts || (ts = {})); var ts; -(function (ts) { - var JsTyping; - (function (JsTyping) { - ; - ; - var safeList; - var EmptySafeList = ts.createMap(); - JsTyping.nodeCoreModuleList = [ - "buffer", "querystring", "events", "http", "cluster", - "zlib", "os", "https", "punycode", "repl", "readline", - "vm", "child_process", "url", "dns", "net", - "dgram", "fs", "path", "string_decoder", "tls", - "crypto", "stream", "util", "assert", "tty", "domain", - "constants", "process", "v8", "timers", "console" - ]; - var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typeAcquisition, unresolvedImports) { - var inferredTypings = ts.createMap(); - if (!typeAcquisition || !typeAcquisition.enable) { - return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; - } - fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { - var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); - return kind === 1 || kind === 2; - }); - if (!safeList) { - var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = result.config ? ts.createMap(result.config) : EmptySafeList; - } - var filesToWatch = []; - var searchDirs = []; - var exclude = []; - mergeTypings(typeAcquisition.include); - exclude = typeAcquisition.exclude || []; - var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); - if (projectRootPath) { - possibleSearchDirs.push(projectRootPath); - } - searchDirs = ts.deduplicate(possibleSearchDirs); - for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { - var searchDir = searchDirs_1[_i]; - var packageJsonPath = ts.combinePaths(searchDir, "package.json"); - getTypingNamesFromJson(packageJsonPath, filesToWatch); - var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); - getTypingNamesFromJson(bowerJsonPath, filesToWatch); - var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); - getTypingNamesFromNodeModuleFolder(nodeModulesPath); - } - getTypingNamesFromSourceFileNames(fileNames); - if (unresolvedImports) { - for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { - var moduleId = unresolvedImports_1[_a]; - var typingName = moduleId in nodeCoreModules ? "node" : moduleId; - if (!(typingName in inferredTypings)) { - inferredTypings[typingName] = undefined; - } - } - } - for (var name_6 in packageNameToTypingLocation) { - if (name_6 in inferredTypings && !inferredTypings[name_6]) { - inferredTypings[name_6] = packageNameToTypingLocation[name_6]; - } - } - for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { - var excludeTypingName = exclude_1[_b]; - delete inferredTypings[excludeTypingName]; - } - var newTypingNames = []; - var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); - } - else { - newTypingNames.push(typing); - } - } - return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; - function mergeTypings(typingNames) { - if (!typingNames) { - return; - } - for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { - var typing = typingNames_1[_i]; - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; - } - } - } - function getTypingNamesFromJson(jsonPath, filesToWatch) { - if (host.fileExists(jsonPath)) { - filesToWatch.push(jsonPath); - } - var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); - if (result.config) { - var jsonConfig = result.config; - if (jsonConfig.dependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); - } - if (jsonConfig.devDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); - } - if (jsonConfig.optionalDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); - } - if (jsonConfig.peerDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); - } - } - } - function getTypingNamesFromSourceFileNames(fileNames) { - var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); - var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); - var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); - if (safeList !== EmptySafeList) { - mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); - } - var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); - if (hasJsxFile) { - mergeTypings(["react"]); - } - } - function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { - if (!host.directoryExists(nodeModulesPath)) { - return; - } - var typingNames = []; - var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); - for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { - var fileName = fileNames_2[_i]; - var normalizedFileName = ts.normalizePath(fileName); - if (ts.getBaseFileName(normalizedFileName) !== "package.json") { - continue; - } - var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); - if (!result.config) { - continue; - } - var packageJson = result.config; - if (packageJson._requiredBy && - ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { - continue; - } - if (!packageJson.name) { - continue; - } - if (packageJson.typings) { - var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; - } - else { - typingNames.push(packageJson.name); - } - } - mergeTypings(typingNames); - } - } - JsTyping.discoverTypings = discoverTypings; - })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - server.ActionSet = "action::set"; - server.ActionInvalidate = "action::invalidate"; - server.EventBeginInstallTypes = "event::beginInstallTypes"; - server.EventEndInstallTypes = "event::endInstallTypes"; - var Arguments; - (function (Arguments) { - Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation"; - Arguments.LogFile = "--logFile"; - Arguments.EnableTelemetry = "--enableTelemetry"; - })(Arguments = server.Arguments || (server.Arguments = {})); - function hasArgument(argumentName) { - return ts.sys.args.indexOf(argumentName) >= 0; - } - server.hasArgument = hasArgument; - function findArgument(argumentName) { - var index = ts.sys.args.indexOf(argumentName); - return index >= 0 && index < ts.sys.args.length - 1 - ? ts.sys.args[index + 1] - : undefined; - } - server.findArgument = findArgument; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - var LogLevel; - (function (LogLevel) { - LogLevel[LogLevel["terse"] = 0] = "terse"; - LogLevel[LogLevel["normal"] = 1] = "normal"; - LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; - LogLevel[LogLevel["verbose"] = 3] = "verbose"; - })(LogLevel = server.LogLevel || (server.LogLevel = {})); - server.emptyArray = []; - var Msg; - (function (Msg) { - Msg.Err = "Err"; - Msg.Info = "Info"; - Msg.Perf = "Perf"; - })(Msg = server.Msg || (server.Msg = {})); - function getProjectRootPath(project) { - switch (project.projectKind) { - case server.ProjectKind.Configured: - return ts.getDirectoryPath(project.getProjectName()); - case server.ProjectKind.Inferred: - return ""; - case server.ProjectKind.External: - var projectName = ts.normalizeSlashes(project.getProjectName()); - return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; - } - } - function createInstallTypingsRequest(project, typeAcquisition, unresolvedImports, cachePath) { - return { - projectName: project.getProjectName(), - fileNames: project.getFileNames(true), - compilerOptions: project.getCompilerOptions(), - typeAcquisition: typeAcquisition, - unresolvedImports: unresolvedImports, - projectRootPath: getProjectRootPath(project), - cachePath: cachePath, - kind: "discover" - }; - } - server.createInstallTypingsRequest = createInstallTypingsRequest; - var Errors; - (function (Errors) { - function ThrowNoProject() { - throw new Error("No Project."); - } - Errors.ThrowNoProject = ThrowNoProject; - function ThrowProjectLanguageServiceDisabled() { - throw new Error("The project's language service is disabled."); - } - Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; - function ThrowProjectDoesNotContainDocument(fileName, project) { - throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); - } - Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; - })(Errors = server.Errors || (server.Errors = {})); - function getDefaultFormatCodeSettings(host) { - return { - indentSize: 4, - tabSize: 4, - newLineCharacter: host.newLine || "\n", - convertTabsToSpaces: true, - indentStyle: ts.IndentStyle.Smart, - insertSpaceAfterCommaDelimiter: true, - insertSpaceAfterSemicolonInForStatements: true, - insertSpaceBeforeAndAfterBinaryOperators: true, - insertSpaceAfterKeywordsInControlFlowStatements: true, - insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, - placeOpenBraceOnNewLineForFunctions: false, - placeOpenBraceOnNewLineForControlBlocks: false, - }; - } - server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; - function mergeMaps(target, source) { - for (var key in source) { - if (ts.hasProperty(source, key)) { - target[key] = source[key]; - } - } - } - server.mergeMaps = mergeMaps; - function removeItemFromSet(items, itemToRemove) { - if (items.length === 0) { - return; - } - var index = items.indexOf(itemToRemove); - if (index < 0) { - return; - } - if (index === items.length - 1) { - items.pop(); - } - else { - items[index] = items.pop(); - } - } - server.removeItemFromSet = removeItemFromSet; - function toNormalizedPath(fileName) { - return ts.normalizePath(fileName); - } - server.toNormalizedPath = toNormalizedPath; - function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { - var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); - return getCanonicalFileName(f); - } - server.normalizedPathToPath = normalizedPathToPath; - function asNormalizedPath(fileName) { - return fileName; - } - server.asNormalizedPath = asNormalizedPath; - function createNormalizedPathMap() { - var map = Object.create(null); - return { - get: function (path) { - return map[path]; - }, - set: function (path, value) { - map[path] = value; - }, - contains: function (path) { - return ts.hasProperty(map, path); - }, - remove: function (path) { - delete map[path]; - } - }; - } - server.createNormalizedPathMap = createNormalizedPathMap; - function isInferredProjectName(name) { - return /dev\/null\/inferredProject\d+\*/.test(name); - } - server.isInferredProjectName = isInferredProjectName; - function makeInferredProjectName(counter) { - return "/dev/null/inferredProject" + counter + "*"; - } - server.makeInferredProjectName = makeInferredProjectName; - function toSortedReadonlyArray(arr) { - arr.sort(); - return arr; - } - server.toSortedReadonlyArray = toSortedReadonlyArray; - var ThrottledOperations = (function () { - function ThrottledOperations(host) { - this.host = host; - this.pendingTimeouts = ts.createMap(); - } - ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { - if (ts.hasProperty(this.pendingTimeouts, operationId)) { - this.host.clearTimeout(this.pendingTimeouts[operationId]); - } - this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); - }; - ThrottledOperations.run = function (self, operationId, cb) { - delete self.pendingTimeouts[operationId]; - cb(); - }; - return ThrottledOperations; - }()); - server.ThrottledOperations = ThrottledOperations; - var GcTimer = (function () { - function GcTimer(host, delay, logger) { - this.host = host; - this.delay = delay; - this.logger = logger; - } - GcTimer.prototype.scheduleCollect = function () { - if (!this.host.gc || this.timerId != undefined) { - return; - } - this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); - }; - GcTimer.run = function (self) { - self.timerId = undefined; - var log = self.logger.hasLevel(LogLevel.requestTime); - var before = log && self.host.getMemoryUsage(); - self.host.gc(); - if (log) { - var after = self.host.getMemoryUsage(); - self.logger.perftrc("GC::before " + before + ", after " + after); - } - }; - return GcTimer; - }()); - server.GcTimer = GcTimer; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; (function (ts) { function trace(host) { host.trace(ts.formatMessage.apply(undefined, arguments)); @@ -6293,6 +5933,12 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; + var Extensions; + (function (Extensions) { + Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; + Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; + Extensions[Extensions["DtsOnly"] = 2] = "DtsOnly"; + })(Extensions || (Extensions = {})); function resolvedTypeScriptOnly(resolved) { if (!resolved) { return undefined; @@ -6300,9 +5946,6 @@ var ts; ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); return resolved.path; } - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } function resolvedModuleFromResolved(_a, isExternalLibraryImport) { var path = _a.path, extension = _a.extension; return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; @@ -6314,13 +5957,13 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { + function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); switch (extensions) { - case 2: - case 0: + case Extensions.DtsOnly: + case Extensions.TypeScript: return tryReadFromField("typings") || tryReadFromField("types"); - case 1: + case Extensions.JavaScript: if (typeof jsonContent.main === "string") { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); @@ -6382,6 +6025,7 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } + return undefined; }); return typeRoots; } @@ -6436,7 +6080,11 @@ var ts; return ts.forEach(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); }); } else { @@ -6452,7 +6100,8 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -6493,31 +6142,115 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + if (!perModuleNameCache) { + moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent_1 = ts.getDirectoryPath(current); + if (parent_1 === current || directoryPathMap.contains(parent_1)) { + break; + } + directoryPathMap.set(parent_1, result); + current = parent_1; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache[moduleName]; + if (result) { if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache[moduleName] = result; + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; } if (traceEnabled) { if (result.resolvedModule) { @@ -6642,33 +6375,33 @@ var ts; return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0) || tryResolve(1); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } @@ -6685,10 +6418,33 @@ var ts; } function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); @@ -6716,11 +6472,11 @@ var ts; } } switch (extensions) { - case 2: + case Extensions.DtsOnly: return tryExtension(".d.ts", ts.Extension.Dts); - case 0: + case Extensions.TypeScript: return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1: + case Extensions.JavaScript: return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } function tryExtension(ext, extension) { @@ -6729,19 +6485,21 @@ var ts; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } } - failedLookupLocations.push(fileName); - return undefined; } + failedLookupLocations.push(fileName); + return undefined; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var packageJsonPath = pathToPackageJson(candidate); @@ -6750,16 +6508,22 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - return resolvedFromAnyFile(fromFile); + var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); + if (mainOrTypesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); + var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); + if (fromExactFile) { + var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); + if (resolved_3) { + return resolved_3; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } - var x = tryAddingExtensions(typesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; + var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved) { + return resolved; } } else { @@ -6769,73 +6533,117 @@ var ts; } } else { - if (state.traceEnabled) { + if (directoryExists && state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } failedLookupLocations.push(packageJsonPath); } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); } function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(2, moduleName, directory, failedLookupLocations, state, true); + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, true, undefined); } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); } }); } function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } - if (extensions !== 1) { - return loadModuleFromNodeModulesFolder(2, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0) || tryResolve(1); - return createResolvedModuleWithFailedLookupLocations(resolved, false, failedLookupLocations); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); if (resolvedUsingSettings) { - return resolvedUsingSettings; + return { value: resolvedUsingSettings }; } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { - var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); - if (resolved_3) { - return resolved_3; + if (resolved_4) { + return resolved_4; } - if (extensions === 0) { + if (extensions === Extensions.TypeScript) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); } } } @@ -6847,10 +6655,13 @@ var ts; } var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2, moduleName, globalCache, failedLookupLocations, state); + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } function forEachAncestorDirectory(directory, callback) { while (true) { var result = callback(directory); @@ -6981,7 +6792,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 261) { + while (node && node.kind !== 262) { node = node.parent; } return node; @@ -6989,11 +6800,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 204: - case 232: - case 211: + case 205: + case 233: case 212: case 213: + case 214: return true; } return false; @@ -7058,18 +6869,18 @@ var ts; if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 292 && node._children.length > 0) { + if (node.kind === 293 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 262 && node.kind <= 288; + return node.kind >= 263 && node.kind <= 289; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 278 && node.kind <= 291; + return node.kind >= 279 && node.kind <= 292; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -7163,11 +6974,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 223 && node.parent.kind === 256; + return node.kind === 224 && node.parent.kind === 257; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 230 && + return node && node.kind === 231 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -7176,11 +6987,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 230 && (!node.body); + return node.kind === 231 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 261 || - node.kind === 230 || + return node.kind === 262 || + node.kind === 231 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -7193,9 +7004,9 @@ var ts; return false; } switch (node.parent.kind) { - case 261: + case 262: return ts.isExternalModule(node.parent); - case 231: + case 232: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -7207,22 +7018,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 261: - case 232: - case 256: - case 230: - case 211: + case 262: + case 233: + case 257: + case 231: case 212: case 213: + case 214: case 150: case 149: case 151: case 152: - case 225: + case 226: case 184: case 185: return true; - case 204: + case 205: return parentNode && !isFunctionLike(parentNode); } return false; @@ -7300,7 +7111,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 204) { + if (node.body && node.body.kind === 205) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -7312,26 +7123,26 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 261: + case 262: 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 223: + case 224: case 174: - case 226: - case 197: case 227: + case 197: + case 228: + case 231: case 230: - case 229: - case 260: - case 225: + case 261: + case 226: case 184: case 149: case 151: case 152: - case 228: + case 229: errorNode = node.name; break; case 185: @@ -7355,7 +7166,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 229 && isConst(node); + return node.kind === 230 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -7372,7 +7183,7 @@ var ts; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 207 + return node.kind === 208 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -7429,24 +7240,24 @@ var ts; case 141: case 177: case 98: - var parent_1 = node.parent; - if (parent_1.kind === 160) { + var parent_2 = node.parent; + if (parent_2.kind === 160) { return false; } - if (156 <= parent_1.kind && parent_1.kind <= 171) { + if (156 <= parent_2.kind && parent_2.kind <= 171) { return true; } - switch (parent_1.kind) { + switch (parent_2.kind) { case 199: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); case 143: - return node === parent_1.constraint; + return node === parent_2.constraint; case 147: case 146: case 144: - case 223: - return node === parent_1.type; - case 225: + case 224: + return node === parent_2.type; + case 226: case 184: case 185: case 150: @@ -7454,16 +7265,16 @@ var ts; case 148: case 151: case 152: - return node === parent_1.type; + return node === parent_2.type; case 153: case 154: case 155: - return node === parent_1.type; + return node === parent_2.type; case 182: - return node === parent_1.type; + return node === parent_2.type; case 179: case 180: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; case 181: return false; } @@ -7471,27 +7282,41 @@ var ts; return false; } ts.isPartOfTypeNode = isPartOfTypeNode; + function isChildOfNodeWithKind(node, kind) { + while (node) { + if (node.kind === kind) { + return true; + } + node = node.parent; + } + return false; + } + ts.isChildOfNodeWithKind = isChildOfNodeWithKind; + function isPrefixUnaryExpression(node) { + return node.kind === 190; + } + ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 216: + case 217: return visitor(node); - case 232: - case 204: - case 208: + case 233: + case 205: case 209: case 210: case 211: case 212: case 213: - case 217: + case 214: case 218: - case 253: - case 254: case 219: - case 221: - case 256: + case 254: + case 255: + case 220: + case 222: + case 257: return ts.forEachChild(node, traverse); } } @@ -7507,18 +7332,18 @@ var ts; if (operand) { traverse(operand); } - case 229: - case 227: case 230: case 228: - case 226: + case 231: + case 229: + case 227: case 197: return; default: if (isFunctionLike(node)) { - var name_7 = node.name; - if (name_7 && name_7.kind === 142) { - traverse(name_7.expression); + var name_6 = node.name; + if (name_6 && name_6.kind === 142) { + traverse(name_6.expression); return; } } @@ -7545,13 +7370,13 @@ var ts; if (node) { switch (node.kind) { case 174: - case 260: + case 261: case 144: - case 257: + case 258: case 147: case 146: - case 258: - case 223: + case 259: + case 224: return true; } } @@ -7563,7 +7388,7 @@ var ts; } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 226 || node.kind === 197); + return node && (node.kind === 227 || node.kind === 197); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7574,7 +7399,7 @@ var ts; switch (kind) { case 150: case 184: - case 225: + case 226: case 185: case 149: case 148: @@ -7597,7 +7422,7 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 184: return true; } @@ -7606,20 +7431,32 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 211: case 212: case 213: - case 209: + case 214: case 210: + case 211: return true; - case 219: + case 220: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; + function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + while (true) { + if (beforeUnwrapLabelCallback) { + beforeUnwrapLabelCallback(node); + } + if (node.statement.kind !== 220) { + return node.statement; + } + node = node.statement; + } + } + ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 204 && isFunctionLike(node.parent); + return node && node.kind === 205 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { @@ -7683,9 +7520,9 @@ var ts; if (!includeArrowFunctions) { continue; } - case 225: + case 226: case 184: - case 230: + case 231: case 147: case 146: case 149: @@ -7696,13 +7533,26 @@ var ts; case 153: case 154: case 155: - case 229: - case 261: + case 230: + case 262: return node; } } } ts.getThisContainer = getThisContainer; + function getNewTargetContainer(node) { + var container = getThisContainer(node, false); + if (container) { + switch (container.kind) { + case 150: + case 226: + case 184: + return container; + } + } + return undefined; + } + ts.getNewTargetContainer = getNewTargetContainer; function getSuperContainer(node, stopOnFunctions) { while (true) { node = node.parent; @@ -7713,7 +7563,7 @@ var ts; case 142: node = node.parent; break; - case 225: + case 226: case 184: case 185: if (!stopOnFunctions) { @@ -7742,13 +7592,13 @@ var ts; function getImmediatelyInvokedFunctionExpression(func) { if (func.kind === 184 || func.kind === 185) { var prev = func; - var parent_2 = func.parent; - while (parent_2.kind === 183) { - prev = parent_2; - parent_2 = parent_2.parent; + var parent_3 = func.parent; + while (parent_3.kind === 183) { + prev = parent_3; + parent_3 = parent_3.parent; } - if (parent_2.kind === 179 && parent_2.expression === prev) { - return parent_2; + if (parent_3.kind === 179 && parent_3.expression === prev) { + return parent_3; } } } @@ -7762,7 +7612,7 @@ var ts; function getEntityNameFromTypeNode(node) { switch (node.kind) { case 157: - case 272: + case 273: return node.typeName; case 199: return isEntityNameExpression(node.expression) @@ -7796,21 +7646,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 226: + case 227: return true; case 147: - return node.parent.kind === 226; + return node.parent.kind === 227; case 151: case 152: case 149: return node.body !== undefined - && node.parent.kind === 226; + && node.parent.kind === 227; case 144: return node.parent.body !== undefined && (node.parent.kind === 150 || node.parent.kind === 149 || node.parent.kind === 152) - && node.parent.parent.kind === 226; + && node.parent.parent.kind === 227; } return false; } @@ -7826,7 +7676,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 226: + case 227: return ts.forEach(node.members, nodeOrChildIsDecorated); case 149: case 152: @@ -7836,9 +7686,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 248 || - parent.kind === 247 || - parent.kind === 249) { + if (parent.kind === 249 || + parent.kind === 248 || + parent.kind === 250) { return parent.tagName === node; } return false; @@ -7877,10 +7727,11 @@ var ts; case 194: case 12: case 198: - case 246: case 247: + case 248: case 195: case 189: + case 202: return true; case 141: while (node.parent.kind === 141) { @@ -7894,53 +7745,53 @@ var ts; case 8: case 9: case 98: - var parent_3 = node.parent; - switch (parent_3.kind) { - case 223: + var parent_4 = node.parent; + switch (parent_4.kind) { + case 224: case 144: case 147: case 146: - case 260: - case 257: + case 261: + case 258: case 174: - return parent_3.initializer === node; - case 207: + return parent_4.initializer === node; case 208: case 209: case 210: - case 216: + case 211: case 217: case 218: - case 253: - case 220: - case 218: - return parent_3.expression === node; - case 211: - var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 224) || + case 219: + case 254: + case 221: + case 219: + return parent_4.expression === node; + case 212: + var forStatement = parent_4; + return (forStatement.initializer === node && forStatement.initializer.kind !== 225) || forStatement.condition === node || forStatement.incrementor === node; - case 212: case 213: - var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224) || + case 214: + var forInStatement = parent_4; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 225) || forInStatement.expression === node; case 182: case 200: - return node === parent_3.expression; - case 202: - return node === parent_3.expression; + return node === parent_4.expression; + case 203: + return node === parent_4.expression; case 142: - return node === parent_3.expression; + return node === parent_4.expression; case 145: + case 253: case 252: - case 251: - case 259: + case 260: return true; case 199: - return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); + return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); default: - if (isPartOfExpression(parent_3)) { + if (isPartOfExpression(parent_4)) { return true; } } @@ -7955,7 +7806,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind === 245; + return node.kind === 235 && node.moduleReference.kind === 246; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7964,7 +7815,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind !== 245; + return node.kind === 235 && node.moduleReference.kind !== 246; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7988,7 +7839,7 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 223) { + if (s.valueDeclaration && s.valueDeclaration.kind === 224) { var declaration = s.valueDeclaration; return declaration.initializer && declaration.initializer.kind === 184; } @@ -8035,35 +7886,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 235) { + if (node.kind === 236) { return node.moduleSpecifier; } - if (node.kind === 234) { + if (node.kind === 235) { var reference = node.moduleReference; - if (reference.kind === 245) { + if (reference.kind === 246) { return reference.expression; } } - if (node.kind === 241) { + if (node.kind === 242) { return node.moduleSpecifier; } - if (node.kind === 230 && node.name.kind === 9) { + if (node.kind === 231 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 234) { + if (node.kind === 235) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 238) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 235 + return node.kind === 236 && node.importClause && !!node.importClause.name; } @@ -8074,8 +7925,8 @@ var ts; case 144: case 149: case 148: + case 259: case 258: - case 257: case 147: case 146: return node.questionToken !== undefined; @@ -8085,9 +7936,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 274 && + return node.kind === 275 && node.parameters.length > 0 && - node.parameters[0].type.kind === 276; + node.parameters[0].type.kind === 277; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { @@ -8100,7 +7951,7 @@ var ts; var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 281) { + if (doc.kind === 282) { if (doc.kind === kind) { result.push(doc); } @@ -8126,9 +7977,9 @@ var ts; var parent = node.parent; var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 205; + parent.parent.parent.kind === 206; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 205; + parent.parent.kind === 206; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -8138,13 +7989,13 @@ var ts; var isSourceOfAssignmentExpressionStatement = parent && parent.parent && parent.kind === 192 && parent.operatorToken.kind === 57 && - parent.parent.kind === 207; + parent.parent.kind === 208; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 230 && - parent && parent.kind === 230; - var isPropertyAssignmentExpression = parent && parent.kind === 257; + var isModuleDeclaration = node.kind === 231 && + parent && parent.kind === 231; + var isPropertyAssignmentExpression = parent && parent.kind === 258; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } @@ -8162,17 +8013,17 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 281); + var tags = getJSDocTags(func, 282); if (!param.name) { var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 281; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 282; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70) { - var name_8 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 281 && tag.parameterName.text === name_8; }); + var name_7 = param.name.text; + return ts.filter(tags, function (tag) { return tag.kind === 282 && tag.parameterName.text === name_7; }); } else { return undefined; @@ -8180,7 +8031,7 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 283); + var tag = getFirstJSDocTag(node, 284); if (!tag && node.kind === 144) { var paramTags = getJSDocParameterTags(node); if (paramTags) { @@ -8191,15 +8042,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 280); + return getFirstJSDocTag(node, 281); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 282); + return getFirstJSDocTag(node, 283); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 284); + return getFirstJSDocTag(node, 285); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -8212,8 +8063,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536)) { - if (node.type && node.type.kind === 275 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275; })) { + if (node.type && node.type.kind === 276 || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 276; })) { return true; } } @@ -8237,19 +8088,19 @@ var ts; case 191: var unaryOperator = parent.operator; return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; - case 212: case 213: + case 214: return parent.initializer === node ? 1 : 0; case 183: case 175: case 196: node = parent; break; - case 258: + case 259: if (parent.name !== node) { return 0; } - case 257: + case 258: node = parent.parent; break; default: @@ -8263,6 +8114,17 @@ var ts; return getAssignmentTargetKind(node) !== 0; } ts.isAssignmentTarget = isAssignmentTarget; + function isDeleteTarget(node) { + if (node.kind !== 177 && node.kind !== 178) { + return false; + } + node = node.parent; + while (node && node.kind === 183) { + node = node.parent; + } + return node && node.kind === 186; + } + ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { while (node) { if (node === ancestor) @@ -8274,7 +8136,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2) || (node.kind === 261 && node.isDeclarationFile)) { + if (hasModifier(node, 2) || (node.kind === 262 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -8287,7 +8149,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 239 || parent.kind === 243) { + if (parent.kind === 240 || parent.kind === 244) { if (parent.propertyName) { return true; } @@ -8313,8 +8175,8 @@ var ts; case 148: case 151: case 152: - case 260: - case 257: + case 261: + case 258: case 177: return parent.name === node; case 141: @@ -8326,22 +8188,22 @@ var ts; } return false; case 174: - case 239: + case 240: return parent.propertyName === node; - case 243: + case 244: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 234 || - node.kind === 233 || - node.kind === 236 && !!node.name || - node.kind === 237 || - node.kind === 239 || - node.kind === 243 || - node.kind === 240 && exportAssignmentIsAlias(node); + return node.kind === 235 || + node.kind === 234 || + node.kind === 237 && !!node.name || + node.kind === 238 || + node.kind === 240 || + node.kind === 244 || + node.kind === 241 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8521,13 +8383,13 @@ var ts; var kind = node.kind; return kind === 150 || kind === 184 - || kind === 225 + || kind === 226 || kind === 185 || kind === 149 || kind === 151 || kind === 152 - || kind === 230 - || kind === 261; + || kind === 231 + || kind === 262; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8649,14 +8511,13 @@ var ts; case 184: case 185: case 197: - case 246: case 247: + case 248: case 11: case 12: case 194: case 183: case 198: - case 297: return 19; case 181: case 177: @@ -8830,13 +8691,12 @@ var ts; "\u0085": "\\u0085" }); function escapeString(s) { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; - return s; - function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } + return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; + function getReplacement(c) { + return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); return ch.toLowerCase() === ch; @@ -9624,9 +9484,9 @@ var ts; if (syntaxKindCache[kind]) { return syntaxKindCache[kind]; } - for (var name_9 in syntaxKindEnum) { - if (syntaxKindEnum[name_9] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_9 + ")"; + for (var name_8 in syntaxKindEnum) { + if (syntaxKindEnum[name_8] === kind) { + return syntaxKindCache[kind] = kind.toString() + " (" + name_8 + ")"; } } } @@ -9712,8 +9572,8 @@ var ts; var parseNode = getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 229: case 230: + case 231: return parseNode === parseNode.parent.name; } } @@ -9731,7 +9591,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 && declaration !== node) { + if (declaration.kind === 227 && declaration !== node) { return true; } } @@ -9782,6 +9642,10 @@ var ts; return node.kind === 70; } ts.isIdentifier = isIdentifier; + function isVoidExpression(node) { + return node.kind === 188; + } + ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { return isIdentifier(node) && node.autoGenerateKind > 0; } @@ -9849,18 +9713,18 @@ var ts; || kind === 151 || kind === 152 || kind === 155 - || kind === 203; + || kind === 204; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 257 - || kind === 258 + return kind === 258 || kind === 259 + || kind === 260 || kind === 149 || kind === 151 || kind === 152 - || kind === 244; + || kind === 245; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { @@ -9913,7 +9777,7 @@ var ts; ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 223: + case 224: case 144: case 174: return true; @@ -9991,8 +9855,8 @@ var ts; || kind === 178 || kind === 180 || kind === 179 - || kind === 246 || kind === 247 + || kind === 248 || kind === 181 || kind === 175 || kind === 183 @@ -10011,7 +9875,7 @@ var ts; || kind === 100 || kind === 96 || kind === 201 - || kind === 297; + || kind === 202; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); @@ -10039,7 +9903,6 @@ var ts; || kind === 196 || kind === 200 || kind === 198 - || kind === 297 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -10053,11 +9916,11 @@ var ts; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 294; + return node.kind === 295; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 293; + return node.kind === 294; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10070,11 +9933,11 @@ var ts; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 202; + return node.kind === 203; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 204; + return node.kind === 205; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -10092,121 +9955,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 223; + return node.kind === 224; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 224; + return node.kind === 225; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 232; + return node.kind === 233; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 231 - || kind === 230; + return kind === 232 + || kind === 231; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 234; + return node.kind === 235; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 236; + return node.kind === 237; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 238 - || kind === 237; + return kind === 239 + || kind === 238; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 239; + return node.kind === 240; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 242; + return node.kind === 243; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 243; + return node.kind === 244; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 230 || node.kind === 229; + return node.kind === 231 || node.kind === 230; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { return kind === 185 || kind === 174 - || kind === 226 + || kind === 227 || kind === 197 || kind === 150 - || kind === 229 - || kind === 260 - || kind === 243 - || kind === 225 + || kind === 230 + || kind === 261 + || kind === 244 + || kind === 226 || kind === 184 || kind === 151 - || kind === 236 - || kind === 234 - || kind === 239 - || kind === 227 + || kind === 237 + || kind === 235 + || kind === 240 + || kind === 228 || kind === 149 || kind === 148 - || kind === 230 - || kind === 233 - || kind === 237 + || kind === 231 + || kind === 234 + || kind === 238 || kind === 144 - || kind === 257 + || kind === 258 || kind === 147 || kind === 146 || kind === 152 - || kind === 258 - || kind === 228 + || kind === 259 + || kind === 229 || kind === 143 - || kind === 223 - || kind === 285; + || kind === 224 + || kind === 286; } function isDeclarationStatementKind(kind) { - return kind === 225 - || kind === 244 - || kind === 226 + return kind === 226 + || kind === 245 || kind === 227 || kind === 228 || kind === 229 || kind === 230 + || kind === 231 + || kind === 236 || kind === 235 - || kind === 234 + || kind === 242 || kind === 241 - || kind === 240 - || kind === 233; + || kind === 234; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 215 - || kind === 214 - || kind === 222 - || kind === 209 - || kind === 207 - || kind === 206 - || kind === 212 - || kind === 213 - || kind === 211 - || kind === 208 - || kind === 219 - || kind === 216 - || kind === 218 - || kind === 220 - || kind === 221 - || kind === 205 + return kind === 216 + || kind === 215 + || kind === 223 || kind === 210 + || kind === 208 + || kind === 207 + || kind === 213 + || kind === 214 + || kind === 212 + || kind === 209 + || kind === 220 || kind === 217 - || kind === 293 - || kind === 296 - || kind === 295; + || kind === 219 + || kind === 221 + || kind === 222 + || kind === 206 + || kind === 211 + || kind === 218 + || kind === 294 + || kind === 297 + || kind === 296; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10224,22 +10087,22 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 204; + || kind === 205; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 245 + return kind === 246 || kind === 141 || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 248; + return node.kind === 249; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 249; + return node.kind === 250; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { @@ -10251,60 +10114,60 @@ var ts; ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 246 - || kind === 252 - || kind === 247 + return kind === 247 + || kind === 253 + || kind === 248 || kind === 10; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 250 - || kind === 251; + return kind === 251 + || kind === 252; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 251; + return node.kind === 252; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 250; + return node.kind === 251; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 252; + || kind === 253; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 253 - || kind === 254; + return kind === 254 + || kind === 255; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 255; + return node.kind === 256; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 256; + return node.kind === 257; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 257; + return node.kind === 258; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 258; + return node.kind === 259; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isEnumMember(node) { - return node.kind === 260; + return node.kind === 261; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 261; + return node.kind === 262; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10445,7 +10308,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 143) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 227) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 228) { return current; } } @@ -10465,14 +10328,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 223) { + if (node.kind === 224) { node = node.parent; } - if (node && node.kind === 224) { + if (node && node.kind === 225) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 205) { + if (node && node.kind === 206) { flags |= ts.getModifierFlags(node); } return flags; @@ -10481,14 +10344,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 223) { + if (node.kind === 224) { node = node.parent; } - if (node && node.kind === 224) { + if (node && node.kind === 225) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 205) { + if (node && node.kind === 206) { flags |= node.flags; } return flags; @@ -10547,7 +10410,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 261 + var ConstructorForKind = kind === 262 ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -11243,7 +11106,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createTemplateSpan(expression, literal, location) { - var node = createNode(202, location); + var node = createNode(203, location); node.expression = expression; node.literal = literal; return node; @@ -11257,7 +11120,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, location, multiLine, flags) { - var block = createNode(204, location, flags); + var block = createNode(205, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -11273,7 +11136,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(205, location, flags); + var node = createNode(206, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -11288,7 +11151,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(224, location, flags); + var node = createNode(225, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -11301,7 +11164,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(223, location, flags); + var node = createNode(224, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11316,11 +11179,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(206, location); + return createNode(207, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(207, location, flags); + var node = createNode(208, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -11333,7 +11196,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(208, location); + var node = createNode(209, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11348,7 +11211,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(209, location); + var node = createNode(210, location); node.statement = statement; node.expression = expression; return node; @@ -11362,7 +11225,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(210, location); + var node = createNode(211, location); node.expression = expression; node.statement = statement; return node; @@ -11376,7 +11239,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(211, location, undefined); + var node = createNode(212, location, undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11392,7 +11255,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(212, location); + var node = createNode(213, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11407,7 +11270,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(213, location); + var node = createNode(214, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11422,7 +11285,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(214, location); + var node = createNode(215, location); if (label) { node.label = label; } @@ -11437,7 +11300,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(215, location); + var node = createNode(216, location); if (label) { node.label = label; } @@ -11452,7 +11315,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(216, location); + var node = createNode(217, location); node.expression = expression; return node; } @@ -11465,7 +11328,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(217, location); + var node = createNode(218, location); node.expression = expression; node.statement = statement; return node; @@ -11479,7 +11342,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(218, location); + var node = createNode(219, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11493,7 +11356,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(219, location); + var node = createNode(220, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11507,7 +11370,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(220, location); + var node = createNode(221, location); node.expression = expression; return node; } @@ -11520,7 +11383,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(221, location); + var node = createNode(222, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11535,7 +11398,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(232, location); + var node = createNode(233, location); node.clauses = createNodeArray(clauses); return node; } @@ -11548,7 +11411,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(225, location, flags); + var node = createNode(226, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11568,7 +11431,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(226, location); + var node = createNode(227, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11586,7 +11449,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(235, location); + var node = createNode(236, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11602,7 +11465,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(236, location); + var node = createNode(237, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11616,7 +11479,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(237, location); + var node = createNode(238, location); node.name = name; return node; } @@ -11629,7 +11492,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(238, location); + var node = createNode(239, location); node.elements = createNodeArray(elements); return node; } @@ -11642,7 +11505,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(239, location); + var node = createNode(240, location); node.propertyName = propertyName; node.name = name; return node; @@ -11656,7 +11519,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(240, location); + var node = createNode(241, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11672,7 +11535,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(241, location); + var node = createNode(242, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11688,7 +11551,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(242, location); + var node = createNode(243, location); node.elements = createNodeArray(elements); return node; } @@ -11701,7 +11564,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(243, location); + var node = createNode(244, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11715,7 +11578,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(246, location); + var node = createNode(247, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11730,7 +11593,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(247, location); + var node = createNode(248, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11744,7 +11607,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(248, location); + var node = createNode(249, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11758,7 +11621,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(249, location); + var node = createNode(250, location); node.tagName = tagName; return node; } @@ -11771,7 +11634,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(250, location); + var node = createNode(251, location); node.name = name; node.initializer = initializer; return node; @@ -11785,7 +11648,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(251, location); + var node = createNode(252, location); node.expression = expression; return node; } @@ -11797,21 +11660,22 @@ var ts; return node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, location) { - var node = createNode(252, location); + function createJsxExpression(expression, dotDotDotToken, location) { + var node = createNode(253, location); + node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node), node); + return updateNode(createJsxExpression(expression, node.dotDotDotToken, node), node); } return node; } ts.updateJsxExpression = updateJsxExpression; function createHeritageClause(token, types, location) { - var node = createNode(255, location); + var node = createNode(256, location); node.token = token; node.types = createNodeArray(types); return node; @@ -11825,7 +11689,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(253, location); + var node = createNode(254, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -11839,7 +11703,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(254, location); + var node = createNode(255, location); node.statements = createNodeArray(statements); return node; } @@ -11852,7 +11716,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(256, location); + var node = createNode(257, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11866,7 +11730,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer, location) { - var node = createNode(257, location); + var node = createNode(258, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11881,14 +11745,14 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(258, location); + var node = createNode(259, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; function createSpreadAssignment(expression, location) { - var node = createNode(259, location); + var node = createNode(260, location); node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; return node; } @@ -11909,7 +11773,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(261, node, node.flags); + var updated = createNode(262, node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -11969,27 +11833,27 @@ var ts; } ts.updateSourceFileNode = updateSourceFileNode; function createNotEmittedStatement(original) { - var node = createNode(293, original); + var node = createNode(294, original); node.original = original; return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createNode(296); + var node = createNode(297); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createNode(295); + var node = createNode(296); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(294, location || original); + var node = createNode(295, location || original); node.expression = expression; node.original = original; return node; @@ -12002,12 +11866,6 @@ var ts; return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; - function createRawExpression(text) { - var node = createNode(297); - node.text = text; - return node; - } - ts.createRawExpression = createRawExpression; function createComma(left, right) { return createBinary(left, 25, right); } @@ -12171,6 +12029,19 @@ var ts; return setEmitFlags(createIdentifier(name), 4096 | 2); } ts.getHelperName = getHelperName; + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 220 + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { @@ -12270,9 +12141,9 @@ var ts; case 151: case 152: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 257: - return createExpressionForPropertyAssignment(property, receiver); case 258: + return createExpressionForPropertyAssignment(property, receiver); + case 259: return createExpressionForShorthandPropertyAssignment(property, receiver); case 149: return createExpressionForMethodDeclaration(property, receiver); @@ -12337,15 +12208,15 @@ var ts; ts.getDeclarationName = getDeclarationName; function getName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { - var name_10 = getMutableClone(node.name); + var name_9 = getMutableClone(node.name); emitFlags |= getEmitFlags(node.name); if (!allowSourceMaps) emitFlags |= 48; if (!allowComments) emitFlags |= 1536; if (emitFlags) - setEmitFlags(name_10, emitFlags); - return name_10; + setEmitFlags(name_9, emitFlags); + return name_9; } return getGeneratedNameForNode(node); } @@ -12630,7 +12501,7 @@ var ts; case 177: node = node.expression; continue; - case 294: + case 295: node = node.expression; continue; } @@ -12678,7 +12549,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 294) { + while (node.kind === 295) { node = node.expression; } return node; @@ -12738,7 +12609,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 261) { + if (node.kind === 262) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -12926,13 +12797,13 @@ var ts; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_11 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_11) ? name_11 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name_10 = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name_10) ? name_10 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 235 && node.importClause) { + if (node.kind === 236 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 241 && node.moduleSpecifier) { + if (node.kind === 242 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -12996,11 +12867,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 257: - return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 258: - return bindingElement.name; + return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 259: + return bindingElement.name; + case 260: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -13020,7 +12891,7 @@ var ts; case 174: return bindingElement.dotDotDotToken; case 196: - case 259: + case 260: return bindingElement; } return undefined; @@ -13036,7 +12907,7 @@ var ts; : propertyName; } break; - case 257: + case 258: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -13044,7 +12915,7 @@ var ts; : propertyName; } break; - case 259: + case 260: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -13149,15 +13020,15 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 235: + case 236: externalImports.push(node); break; - case 234: - if (node.moduleReference.kind === 245) { + case 235: + if (node.moduleReference.kind === 246) { externalImports.push(node); } break; - case 241: + case 242: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -13171,10 +13042,10 @@ var ts; for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; if (!uniqueExports[specifier.name.text]) { - var name_12 = specifier.propertyName || specifier.name; - ts.multiMapAdd(exportSpecifiers, name_12.text, specifier); - var decl = resolver.getReferencedImportDeclaration(name_12) - || resolver.getReferencedValueDeclaration(name_12); + var name_11 = specifier.propertyName || specifier.name; + ts.multiMapAdd(exportSpecifiers, name_11.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name_11) + || resolver.getReferencedValueDeclaration(name_11); if (decl) { ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); } @@ -13184,12 +13055,12 @@ var ts; } } break; - case 240: + case 241: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 205: + case 206: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -13197,7 +13068,25 @@ var ts; } } break; - case 225: + case 226: + if (ts.hasModifier(node, 1)) { + if (ts.hasModifier(node, 512)) { + if (!hasExportDefault) { + ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + hasExportDefault = true; + } + } + else { + var name_12 = node.name; + if (!uniqueExports[name_12.text]) { + ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_12); + uniqueExports[name_12.text] = true; + exportedNames = ts.append(exportedNames, name_12); + } + } + } + break; + case 227: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -13215,24 +13104,6 @@ var ts; } } break; - case 226: - if (ts.hasModifier(node, 1)) { - if (ts.hasModifier(node, 512)) { - if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); - hasExportDefault = true; - } - } - else { - var name_14 = node.name; - if (!uniqueExports[name_14.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_14); - uniqueExports[name_14.text] = true; - exportedNames = ts.append(exportedNames, name_14); - } - } - } - break; } } return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration }; @@ -13263,7 +13134,7 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 261) { + if (kind === 262) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70) { @@ -13312,20 +13183,20 @@ var ts; return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 258: + case 259: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 259: + case 260: return visitNode(cbNode, node.expression); case 144: case 147: case 146: - case 257: - case 223: + case 258: + case 224: case 174: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -13351,7 +13222,7 @@ var ts; case 151: case 152: case 184: - case 225: + case 226: case 185: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -13443,6 +13314,8 @@ var ts; visitNode(cbNode, node.type); case 201: return visitNode(cbNode, node.expression); + case 202: + return visitNode(cbNode, node.name); case 193: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || @@ -13451,84 +13324,77 @@ var ts; visitNode(cbNode, node.whenFalse); case 196: return visitNode(cbNode, node.expression); - case 204: - case 231: + case 205: + case 232: return visitNodes(cbNodes, node.statements); - case 261: + case 262: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 205: + case 206: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 224: + case 225: return visitNodes(cbNodes, node.declarations); - case 207: - return visitNode(cbNode, node.expression); case 208: + return visitNode(cbNode, node.expression); + case 209: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 209: + case 210: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 210: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 211: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 212: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 213: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 214: - case 215: - return visitNode(cbNode, node.label); - case 216: - return visitNode(cbNode, node.expression); - case 217: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 215: + case 216: + return visitNode(cbNode, node.label); + case 217: + return visitNode(cbNode, node.expression); case 218: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 219: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 232: + case 233: return visitNodes(cbNodes, node.clauses); - case 253: + case 254: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 254: + case 255: return visitNodes(cbNodes, node.statements); - case 219: + case 220: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 220: - return visitNode(cbNode, node.expression); case 221: + return visitNode(cbNode, node.expression); + case 222: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 256: + case 257: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 145: return visitNode(cbNode, node.expression); - case 226: - case 197: - 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: + case 197: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13540,143 +13406,151 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 229: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 260: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 230: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 261: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 234: + case 235: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 235: + case 236: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 236: + case 237: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 233: - return visitNode(cbNode, node.name); - case 237: + case 234: return visitNode(cbNode, node.name); case 238: - case 242: + return visitNode(cbNode, node.name); + case 239: + case 243: return visitNodes(cbNodes, node.elements); - case 241: + case 242: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 239: - case 243: + case 240: + case 244: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 240: + case 241: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); case 194: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 202: + case 203: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 142: return visitNode(cbNode, node.expression); - case 255: + case 256: return visitNodes(cbNodes, node.types); case 199: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 245: - return visitNode(cbNode, node.expression); - case 244: - return visitNodes(cbNodes, node.decorators); case 246: + return visitNode(cbNode, node.expression); + case 245: + return visitNodes(cbNodes, node.decorators); + case 247: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 247: case 248: + case 249: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 250: + case 251: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 251: - return visitNode(cbNode, node.expression); case 252: return visitNode(cbNode, node.expression); - case 249: + case 253: + return visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.expression); + case 250: return visitNode(cbNode, node.tagName); - case 262: + case 263: return visitNode(cbNode, node.type); - case 266: - return visitNodes(cbNodes, node.types); case 267: return visitNodes(cbNodes, node.types); - case 265: + case 268: + return visitNodes(cbNodes, node.types); + case 266: return visitNode(cbNode, node.elementType); + case 270: + return visitNode(cbNode, node.type); case 269: return visitNode(cbNode, node.type); - case 268: - return visitNode(cbNode, node.type); - case 270: + case 271: return visitNode(cbNode, node.literal); - case 272: + case 273: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 273: - return visitNode(cbNode, node.type); case 274: + return visitNode(cbNode, node.type); + case 275: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 275: - return visitNode(cbNode, node.type); case 276: return visitNode(cbNode, node.type); case 277: return visitNode(cbNode, node.type); - case 271: + case 278: + return visitNode(cbNode, node.type); + case 272: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 278: + case 279: return visitNodes(cbNodes, node.tags); - case 281: + case 282: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 282: - return visitNode(cbNode, node.typeExpression); case 283: return visitNode(cbNode, node.typeExpression); - case 280: - return visitNode(cbNode, node.typeExpression); case 284: - return visitNodes(cbNodes, node.typeParameters); + return visitNode(cbNode, node.typeExpression); + case 281: + return visitNode(cbNode, node.typeExpression); case 285: + return visitNodes(cbNodes, node.typeParameters); + case 286: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 287: + case 288: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 286: + case 287: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 294: + case 295: return visitNode(cbNode, node.expression); - case 288: + case 289: return visitNode(cbNode, node.literal); } } @@ -13840,7 +13714,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(261, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(262, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -14459,7 +14333,7 @@ var ts; case 151: case 152: case 147: - case 203: + case 204: return true; case 149: var methodDeclaration = node; @@ -14473,8 +14347,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 253: case 254: + case 255: return true; } } @@ -14483,42 +14357,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 225: + case 226: + case 206: case 205: - case 204: + case 209: case 208: - case 207: - case 220: + case 221: + case 217: + case 219: case 216: - case 218: case 215: + case 213: case 214: case 212: - case 213: case 211: - case 210: - case 217: - case 206: - case 221: - case 219: - case 209: + case 218: + case 207: case 222: + case 220: + case 210: + case 223: + case 236: case 235: - case 234: + case 242: case 241: - case 240: - case 230: - case 226: + case 231: case 227: - case 229: case 228: + case 230: + case 229: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 260; + return node.kind === 261; } function isReusableTypeMember(node) { if (node) { @@ -14534,7 +14408,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 223) { + if (node.kind !== 224) { return false; } var variableDeclarator = node; @@ -14666,7 +14540,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(202); + var span = createNode(203); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -15791,8 +15665,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 248) { - var node = createNode(246, opening.pos); + if (opening.kind === 249) { + var node = createNode(247, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -15802,7 +15676,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 247); + ts.Debug.assert(opening.kind === 248); result = opening; } if (inExpressionContext && token() === 26) { @@ -15862,7 +15736,7 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token() === 28) { - node = createNode(248, fullStart); + node = createNode(249, fullStart); scanJsxText(); } else { @@ -15874,7 +15748,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(247, fullStart); + node = createNode(248, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -15893,9 +15767,10 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(252); + var node = createNode(253); parseExpected(16); if (token() !== 17) { + node.dotDotDotToken = parseOptionalToken(23); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { @@ -15912,7 +15787,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(250); + var node = createNode(251); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -15927,7 +15802,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(251); + var node = createNode(252); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -15935,7 +15810,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(249); + var node = createNode(250); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -16152,7 +16027,7 @@ var ts; var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23); if (dotDotDotToken) { - var spreadElement = createNode(259, fullStart); + var spreadElement = createNode(260, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -16171,7 +16046,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(258, fullStart); + var shorthandDeclaration = createNode(259, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -16182,7 +16057,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(257, fullStart); + var propertyAssignment = createNode(258, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -16228,8 +16103,15 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(180); + var fullStart = scanner.getStartPos(); parseExpected(93); + if (parseOptional(22)) { + var node_1 = createNode(202, fullStart); + node_1.keywordToken = 93; + node_1.name = parseIdentifierName(); + return finishNode(node_1); + } + var node = createNode(180, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18) { @@ -16238,7 +16120,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(204); + var node = createNode(205); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16269,12 +16151,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(206); + var node = createNode(207); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(208); + var node = createNode(209); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16284,7 +16166,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(209); + var node = createNode(210); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -16295,7 +16177,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(210); + var node = createNode(211); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16318,21 +16200,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(212, pos); + var forInStatement = createNode(213, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19); forOrForInOrForOfStatement = forInStatement; } else if (parseOptional(140)) { - var forOfStatement = createNode(213, pos); + var forOfStatement = createNode(214, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(211, pos); + var forStatement = createNode(212, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -16350,7 +16232,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 215 ? 71 : 76); + parseExpected(kind === 216 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16358,7 +16240,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(216); + var node = createNode(217); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -16367,7 +16249,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(217); + var node = createNode(218); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16376,7 +16258,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(253); + var node = createNode(254); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -16384,7 +16266,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(254); + var node = createNode(255); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -16394,12 +16276,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(218); + var node = createNode(219); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(232, scanner.getStartPos()); + var caseBlock = createNode(233, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -16407,14 +16289,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(220); + var node = createNode(221); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(221); + var node = createNode(222); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -16425,7 +16307,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(256); + var result = createNode(257); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -16435,7 +16317,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(222); + var node = createNode(223); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -16444,13 +16326,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(219, fullStart); + var labeledStatement = createNode(220, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(207, fullStart); + var expressionStatement = createNode(208, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -16602,9 +16484,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(214); - case 71: return parseBreakOrContinueStatement(215); + case 71: + return parseBreakOrContinueStatement(216); case 95: return parseReturnStatement(); case 106: @@ -16683,7 +16565,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(244, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(245, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -16755,7 +16637,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(223); + var node = createNode(224); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -16764,7 +16646,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(224); + var node = createNode(225); switch (token()) { case 103: break; @@ -16793,7 +16675,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(205, fullStart); + var node = createNode(206, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -16801,7 +16683,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -16986,7 +16868,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(203); + var result = createNode(204); nextToken(); return finishNode(result); } @@ -17011,8 +16893,8 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_15 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_15, undefined); + var name_14 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_14, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } @@ -17020,7 +16902,7 @@ var ts; return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 197); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 227); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -17055,7 +16937,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 || token() === 107) { - var node = createNode(255); + var node = createNode(256); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -17078,7 +16960,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -17089,7 +16971,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228, fullStart); + var node = createNode(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(136); @@ -17101,13 +16983,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(260, scanner.getStartPos()); + var node = createNode(261, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -17122,7 +17004,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(231, scanner.getStartPos()); + var node = createNode(232, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -17133,7 +17015,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -17145,7 +17027,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (token() === 139) { @@ -17190,7 +17072,7 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(233, fullStart); + var exportDeclaration = createNode(234, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); @@ -17206,7 +17088,7 @@ var ts; if (isIdentifier()) { identifier = parseIdentifier(); if (token() !== 25 && token() !== 138) { - var importEqualsDeclaration = createNode(234, fullStart); + var importEqualsDeclaration = createNode(235, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -17216,7 +17098,7 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(235, fullStart); + var importDeclaration = createNode(236, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || @@ -17230,13 +17112,13 @@ var ts; return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(236, fullStart); + var importClause = createNode(237, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(238); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(239); } return finishNode(importClause); } @@ -17246,7 +17128,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(245); + var node = createNode(246); parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); @@ -17264,7 +17146,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(237); + var namespaceImport = createNode(238); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -17272,14 +17154,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 238 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 239 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(243); + return parseImportOrExportSpecifier(244); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(239); + return parseImportOrExportSpecifier(240); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17298,13 +17180,13 @@ var ts; else { node.name = identifierName; } - if (kind === 239 && checkIdentifierIsKeyword) { + if (kind === 240 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(241, fullStart); + var node = createNode(242, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38)) { @@ -17312,7 +17194,7 @@ var ts; node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(242); + node.exportClause = parseNamedImportsOrExports(243); if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { parseExpected(138); node.moduleSpecifier = parseModuleSpecifier(); @@ -17322,7 +17204,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(240, fullStart); + var node = createNode(241, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -17401,10 +17283,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 234 && node.moduleReference.kind === 245 - || node.kind === 235 - || node.kind === 240 + || node.kind === 235 && node.moduleReference.kind === 246 + || node.kind === 236 || node.kind === 241 + || node.kind === 242 ? node : undefined; }); @@ -17440,7 +17322,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(262, scanner.getTokenPos()); + var result = createNode(263, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -17451,12 +17333,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(266, type.pos); + var unionType = createNode(267, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(273, type.pos); + var optionalType = createNode(274, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -17467,20 +17349,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(265, type.pos); + var arrayType = createNode(266, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(268, type.pos); + var nullableType = createNode(269, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(269, type.pos); + var nonNullableType = createNode(270, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -17532,27 +17414,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(277); + var result = createNode(278); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(276); + var result = createNode(277); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(275); + var result = createNode(276); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(274); + var result = createNode(275); nextToken(); parseExpected(18); result.parameters = parseDelimitedList(23, parseJSDocParameter); @@ -17573,7 +17455,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(272); + var result = createNode(273); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -17613,18 +17495,18 @@ var ts; return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(270); + var result = createNode(271); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(269); + var result = createNode(270); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(267); + var result = createNode(268); nextToken(); result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); @@ -17638,7 +17520,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(266); + var result = createNode(267); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -17654,12 +17536,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(263); + var result = createNode(264); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(288); + var result = createNode(289); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -17672,11 +17554,11 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(264, pos); + var result = createNode(265, pos); return finishNode(result); } else { - var result = createNode(268, pos); + var result = createNode(269, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -17820,7 +17702,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(278, start); + var result = createNode(279, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -17930,7 +17812,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(279, atToken.pos); + var result = createNode(280, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -17985,7 +17867,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(281, atToken.pos); + var result = createNode(282, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -17996,20 +17878,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 282; })) { + if (ts.forEach(tags, function (t) { return t.kind === 283; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(282, atToken.pos); + var result = createNode(283, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283; })) { + if (ts.forEach(tags, function (t) { return t.kind === 284; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -18024,7 +17906,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(286, atToken.pos); + var result = createNode(287, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -18033,7 +17915,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(280, atToken.pos); + var result = createNode(281, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -18042,7 +17924,7 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(285, atToken.pos); + var typedefTag = createNode(286, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); @@ -18056,11 +17938,11 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 272) { + if (typeExpression.type.kind === 273) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { - var name_16 = jsDocTypeReference.name; - if (name_16.text === "Object") { + var name_15 = jsDocTypeReference.name; + if (name_15.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -18074,7 +17956,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(287, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(288, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -18115,7 +17997,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(230, pos); + var jsDocNamespaceNode = createNode(231, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -18159,19 +18041,19 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284; })) { + if (ts.forEach(tags, function (t) { return t.kind === 285; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); while (true) { - var name_17 = parseJSDocIdentifierName(); + var name_16 = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_17) { + if (!name_16) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(143, name_17.pos); - typeParameter.name = name_17; + var typeParameter = createNode(143, name_16.pos); + typeParameter.name = name_16; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25) { @@ -18182,7 +18064,7 @@ var ts; break; } } - var result = createNode(284, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -18474,7 +18356,7 @@ var ts; } function visitArray(array) { if (position >= array.pos && position < array.end) { - for (var i = 0, n = array.length; i < n; i++) { + for (var i = 0; i < array.length; i++) { var child = array[i]; if (child) { if (child.pos === position) { @@ -18501,16 +18383,16 @@ var ts; var ts; (function (ts) { function getModuleInstanceState(node) { - if (node.kind === 227 || node.kind === 228) { + if (node.kind === 228 || node.kind === 229) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 235 || node.kind === 234) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 236 || node.kind === 235) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 231) { + else if (node.kind === 232) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -18526,7 +18408,7 @@ var ts; }); return state_1; } - else if (node.kind === 230) { + else if (node.kind === 231) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -18635,7 +18517,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 230)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 231)) { symbol.valueDeclaration = node; } } @@ -18666,9 +18548,9 @@ var ts; return "__new"; case 155: return "__index"; - case 241: + case 242: return "__export"; - case 240: + case 241: return node.isExportEquals ? "export=" : "default"; case 192: switch (ts.getSpecialPropertyAssignmentKind(node)) { @@ -18682,20 +18564,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 225: case 226: + case 227: return ts.hasModifier(node, 512) ? "default" : undefined; - case 274: + case 275: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; case 144: - ts.Debug.assert(node.parent.kind === 274); + ts.Debug.assert(node.parent.kind === 275); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 285: + case 286: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 205) { + if (parentNode && parentNode.kind === 206) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -18739,7 +18621,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 240 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 241 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -18759,7 +18641,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 243 || (node.kind === 234 && hasExportModifier)) { + if (node.kind === 244 || (node.kind === 235 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -18767,7 +18649,7 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 285 && + var isJSDocTypedefInJSDocNamespace = node.kind === 286 && node.name && node.name.kind === 70 && node.name.isInJSDocNamespace; @@ -18828,7 +18710,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 261) { + if (node.kind === 262) { node.flags |= emitFlags; } if (isIIFE) { @@ -18904,43 +18786,43 @@ var ts; return; } switch (node.kind) { - case 210: + case 211: bindWhileStatement(node); break; - case 209: + case 210: bindDoStatement(node); break; - case 211: + case 212: bindForStatement(node); break; - case 212: case 213: + case 214: bindForInOrForOfStatement(node); break; - case 208: + case 209: bindIfStatement(node); break; - case 216: - case 220: + case 217: + case 221: bindReturnOrThrow(node); break; + case 216: case 215: - case 214: bindBreakOrContinueStatement(node); break; - case 221: + case 222: bindTryStatement(node); break; - case 218: + case 219: bindSwitchStatement(node); break; - case 232: + case 233: bindCaseBlock(node); break; - case 253: + case 254: bindCaseClause(node); break; - case 219: + case 220: bindLabeledStatement(node); break; case 190: @@ -18958,7 +18840,7 @@ var ts; case 193: bindConditionalExpressionFlow(node); break; - case 223: + case 224: bindVariableDeclarationFlow(node); break; case 179: @@ -19124,11 +19006,11 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 208: - case 210: case 209: - return parent.expression === node; case 211: + case 210: + return parent.expression === node; + case 212: case 193: return parent.condition === node; } @@ -19192,7 +19074,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 219 + var enclosingLabeledStatement = node.parent.kind === 220 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -19227,7 +19109,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 224) { + if (node.initializer.kind !== 225) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -19249,7 +19131,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 216) { + if (node.kind === 217) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -19269,7 +19151,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 215 ? breakTarget : continueTarget; + var flowLabel = node.kind === 216 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -19326,7 +19208,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 254; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 255; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -19391,7 +19273,7 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 209) { + if (!node.statement || node.statement.kind !== 210) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } @@ -19422,13 +19304,13 @@ var ts; else if (node.kind === 176) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 257) { + if (p.kind === 258) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 258) { + else if (p.kind === 259) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 259) { + else if (p.kind === 260) { bindAssignmentTargetFlow(p.expression); } } @@ -19528,7 +19410,7 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 212 || node.parent.parent.kind === 213) { + if (node.initializer || node.parent.parent.kind === 213 || node.parent.parent.kind === 214) { bindInitializedVariableFlow(node); } } @@ -19555,28 +19437,28 @@ var ts; function getContainerFlags(node) { switch (node.kind) { case 197: - case 226: - case 229: + case 227: + case 230: case 176: case 161: - case 287: - case 270: + case 288: + case 271: return 1; - case 227: - return 1 | 64; - case 274: - case 230: case 228: + return 1 | 64; + case 275: + case 231: + case 229: case 170: return 1 | 32; - case 261: + case 262: return 1 | 4 | 32; case 149: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } case 150: - case 225: + case 226: case 148: case 151: case 152: @@ -19589,17 +19471,17 @@ var ts; case 184: case 185: return 1 | 4 | 32 | 8 | 16; - case 231: + case 232: return 4; case 147: return node.initializer ? 4 : 0; - case 256: - case 211: + case 257: case 212: case 213: - case 232: + case 214: + case 233: return 2; - case 204: + case 205: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -19615,20 +19497,20 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 230: + case 231: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 261: + case 262: return declareSourceFileMember(node, symbolFlags, symbolExcludes); case 197: - case 226: + case 227: return declareClassMember(node, symbolFlags, symbolExcludes); - case 229: + case 230: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 161: case 176: - case 227: - case 270: - case 287: + case 228: + case 271: + case 288: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); case 158: case 159: @@ -19640,11 +19522,11 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 184: case 185: - case 274: - case 228: + case 275: + case 229: case 170: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } @@ -19660,11 +19542,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 261 ? node : node.body; - if (body && (body.kind === 261 || body.kind === 231)) { + var body = node.kind === 262 ? node : node.body; + if (body && (body.kind === 262 || body.kind === 232)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 241 || stat.kind === 240) { + if (stat.kind === 242 || stat.kind === 241) { return true; } } @@ -19740,11 +19622,11 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 || prop.name.kind !== 70) { + if (prop.kind === 260 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 257 || prop.kind === 258 || prop.kind === 149 + var currentKind = prop.kind === 258 || prop.kind === 259 || prop.kind === 149 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -19766,10 +19648,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 230: + case 231: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 261: + case 262: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -19859,8 +19741,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 261 && - blockScopeContainer.kind !== 230 && + if (blockScopeContainer.kind !== 262 && + blockScopeContainer.kind !== 231 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -19943,14 +19825,14 @@ var ts; case 70: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 285) { + while (parentNode && parentNode.kind !== 286) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 258)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 259)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); @@ -19982,7 +19864,7 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 256: + case 257: return checkStrictModeCatchClause(node); case 186: return checkStrictModeDeleteExpression(node); @@ -19992,7 +19874,7 @@ var ts; return checkStrictModePostfixUnaryExpression(node); case 190: return checkStrictModePrefixUnaryExpression(node); - case 217: + case 218: return checkStrictModeWithStatement(node); case 167: seenThisKeyword = true; @@ -20003,22 +19885,22 @@ var ts; return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 144: return bindParameter(node); - case 223: + case 224: case 174: return bindVariableDeclarationOrBindingElement(node); case 147: case 146: - case 271: + case 272: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 286: + case 287: return bindJSDocProperty(node); - case 257: case 258: - return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 260: - return bindPropertyOrMethodOrAccessor(node, 8, 900095); case 259: - case 251: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 261: + return bindPropertyOrMethodOrAccessor(node, 8, 900095); + case 260: + case 252: var root = container; var hasRest = false; while (root.parent) { @@ -20039,7 +19921,7 @@ var ts; case 149: case 148: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 225: + case 226: return bindFunctionDeclaration(node); case 150: return declareSymbolAndAddToSymbolTable(node, 16384, 0); @@ -20049,12 +19931,12 @@ var ts; return bindPropertyOrMethodOrAccessor(node, 65536, 74687); case 158: case 159: - case 274: + case 275: return bindFunctionOrConstructorType(node); case 161: case 170: - case 287: - case 270: + case 288: + case 271: return bindAnonymousDeclaration(node, 2048, "__type"); case 176: return bindObjectLiteralExpression(node); @@ -20067,43 +19949,43 @@ var ts; } break; case 197: - case 226: + case 227: inStrictMode = true; return bindClassLikeDeclaration(node); - case 227: + case 228: return bindBlockScopedDeclaration(node, 64, 792968); - case 285: + case 286: if (!node.fullName || node.fullName.kind === 70) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 228: - return bindBlockScopedDeclaration(node, 524288, 793064); case 229: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 230: + return bindEnumDeclaration(node); + case 231: return bindModuleDeclaration(node); - case 234: - case 237: - case 239: - case 243: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 233: - return bindNamespaceExportDeclaration(node); - case 236: - return bindImportClause(node); - case 241: - return bindExportDeclaration(node); + case 235: + case 238: case 240: + case 244: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 234: + return bindNamespaceExportDeclaration(node); + case 237: + return bindImportClause(node); + case 242: + return bindExportDeclaration(node); + case 241: return bindExportAssignment(node); - case 261: + case 262: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 204: + case 205: if (!ts.isFunctionLike(node.parent)) { return; } - case 231: + case 232: return updateStrictModeStatementList(node.statements); } } @@ -20131,7 +20013,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 240 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 241 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -20141,17 +20023,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 261) { + if (node.parent.kind !== 262) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_4 = node.parent; - if (!ts.isExternalModule(parent_4)) { + var parent_5 = node.parent; + if (!ts.isExternalModule(parent_5)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_4.isDeclarationFile) { + if (!parent_5.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -20190,7 +20072,7 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 225 || container.kind === 184) { + if (container.kind === 226 || container.kind === 184) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } @@ -20226,7 +20108,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 226) { + if (node.kind === 227) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -20336,15 +20218,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 206) || - node.kind === 226 || - (node.kind === 230 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 229 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 207) || + node.kind === 227 || + (node.kind === 231 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 230 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 205 || + (node.kind !== 206 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -20362,13 +20244,13 @@ var ts; return computeCallExpression(node, subtreeFlags); case 180: return computeNewExpression(node, subtreeFlags); - case 230: + case 231: return computeModuleDeclaration(node, subtreeFlags); case 183: return computeParenthesizedExpression(node, subtreeFlags); case 192: return computeBinaryExpression(node, subtreeFlags); - case 207: + case 208: return computeExpressionStatement(node, subtreeFlags); case 144: return computeParameter(node, subtreeFlags); @@ -20376,23 +20258,23 @@ var ts; return computeArrowFunction(node, subtreeFlags); case 184: return computeFunctionExpression(node, subtreeFlags); - case 225: - return computeFunctionDeclaration(node, subtreeFlags); - case 223: - return computeVariableDeclaration(node, subtreeFlags); - case 224: - return computeVariableDeclarationList(node, subtreeFlags); - case 205: - return computeVariableStatement(node, subtreeFlags); - case 219: - return computeLabeledStatement(node, subtreeFlags); case 226: + return computeFunctionDeclaration(node, subtreeFlags); + case 224: + return computeVariableDeclaration(node, subtreeFlags); + case 225: + return computeVariableDeclarationList(node, subtreeFlags); + case 206: + return computeVariableStatement(node, subtreeFlags); + case 220: + return computeLabeledStatement(node, subtreeFlags); + case 227: return computeClassDeclaration(node, subtreeFlags); case 197: return computeClassExpression(node, subtreeFlags); - case 255: - return computeHeritageClause(node, subtreeFlags); case 256: + return computeHeritageClause(node, subtreeFlags); + case 257: return computeCatchClause(node, subtreeFlags); case 199: return computeExpressionWithTypeArguments(node, subtreeFlags); @@ -20405,7 +20287,7 @@ var ts; case 151: case 152: return computeAccessor(node, subtreeFlags); - case 234: + case 235: return computeImportEquals(node, subtreeFlags); case 177: return computePropertyAccess(node, subtreeFlags); @@ -20793,25 +20675,25 @@ var ts; case 116: case 123: case 75: - case 229: - case 260: + case 230: + case 261: case 182: case 200: case 201: case 130: transformFlags |= 3; break; - case 246: case 247: case 248: - case 10: case 249: + case 10: case 250: case 251: case 252: + case 253: transformFlags |= 4; break; - case 213: + case 214: transformFlags |= 8; case 12: case 13: @@ -20819,8 +20701,9 @@ var ts; case 15: case 194: case 181: - case 258: + case 259: case 114: + case 202: transformFlags |= 192; break; case 195: @@ -20850,8 +20733,8 @@ var ts; case 164: case 165: case 166: - case 227: case 228: + case 229: case 167: case 168: case 169: @@ -20869,7 +20752,7 @@ var ts; case 196: transformFlags |= 192 | 524288; break; - case 259: + case 260: transformFlags |= 8 | 1048576; break; case 96: @@ -20917,22 +20800,22 @@ var ts; transformFlags |= 192; } break; - case 209: case 210: case 211: case 212: + case 213: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 261: + case 262: if (subtreeFlags & 32768) { transformFlags |= 192; } break; - case 216: - case 214: + case 217: case 215: + case 216: transformFlags |= 33554432; break; } @@ -20948,18 +20831,18 @@ var ts; case 180: case 175: return 537396545; - case 230: + case 231: return 574674241; case 144: return 536872257; case 185: return 601249089; case 184: - case 225: - return 601281857; - case 224: - return 546309441; case 226: + return 601281857; + case 225: + return 546309441; + case 227: case 197: return 539358529; case 150: @@ -20981,12 +20864,12 @@ var ts; case 153: case 154: case 155: - case 227: case 228: + case 229: return -3; case 176: return 540087617; - case 256: + case 257: return 537920833; case 172: case 173: @@ -21056,9 +20939,11 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, + getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, + getTypeFromTypeNode: getTypeFromTypeNode, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -21067,6 +20952,7 @@ var ts; getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, + signatureToString: signatureToString, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -21089,7 +20975,8 @@ var ts; tryGetMemberInModuleExports: tryGetMemberInModuleExports, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { return tryFindAmbientModule(moduleName, false); - } + }, + getApparentType: getApparentType }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -21183,6 +21070,7 @@ var ts; var visitedFlowNodes = []; var visitedFlowTypes = []; var potentialThisCollisions = []; + var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var typeofEQFacts = ts.createMap({ @@ -21328,7 +21216,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 230 && source.valueDeclaration.kind !== 230))) { + (target.valueDeclaration.kind === 231 && source.valueDeclaration.kind !== 231))) { target.valueDeclaration = source.valueDeclaration; } ts.addRange(target.declarations, source.declarations); @@ -21423,7 +21311,7 @@ var ts; return type.flags & 32768 ? type.objectFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 261 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 262 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -21467,25 +21355,35 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 223 || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + if (declaration.kind === 174) { + var errorBindingElement = ts.getAncestor(usage, 174); + if (errorBindingElement) { + return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + declaration.pos < errorBindingElement.pos; + } + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 224), usage); + } + else if (declaration.kind === 224) { + return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); return isUsedInFunctionOrNonStaticProperty(usage, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 205: - case 211: - case 213: + case 206: + case 212: + case 214: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 212: case 213: + case 214: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } @@ -21512,6 +21410,15 @@ var ts; } return false; } + function getAncestorBindingPattern(node) { + while (node) { + if (ts.isBindingPattern(node)) { + return node; + } + node = node.parent; + } + return undefined; + } } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { var result; @@ -21525,7 +21432,7 @@ var ts; if (result = getSymbol(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 793064 && lastLocation.kind !== 278) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 279) { useResult = result.flags & 262144 ? lastLocation === location.type || lastLocation.kind === 144 || @@ -21548,13 +21455,13 @@ var ts; } } switch (location.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 230: + case 231: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 261 || ts.isAmbientModule(location)) { + if (location.kind === 262 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -21564,7 +21471,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 243)) { + ts.getDeclarationOfKind(moduleExports[name], 244)) { break; } } @@ -21572,7 +21479,7 @@ var ts; break loop; } break; - case 229: + case 230: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } @@ -21588,9 +21495,9 @@ var ts; } } break; - case 226: - case 197: case 227: + case 197: + case 228: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -21608,7 +21515,7 @@ var ts; break; case 142: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 227) { + if (ts.isClassLike(grandparent) || grandparent.kind === 228) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; @@ -21620,7 +21527,7 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 185: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; @@ -21684,7 +21591,7 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 233) { + if (decls && decls.length === 1 && decls[0].kind === 234) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -21764,7 +21671,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 223), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -21781,10 +21688,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 234) { + if (node.kind === 235) { return node; } - while (node && node.kind !== 235) { + while (node && node.kind !== 236) { node = node.parent; } return node; @@ -21794,7 +21701,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 245) { + if (node.moduleReference.kind === 246) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -21855,28 +21762,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_18 = specifier.propertyName || specifier.name; - if (name_18.text) { + var name_17 = specifier.propertyName || specifier.name; + if (name_17.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_18.text); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_17.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_18.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_17.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_18.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_18.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name_17.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name_17.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_18, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_18)); + error(name_17, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_17)); } return symbol; } @@ -21898,19 +21805,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 234: + case 235: return getTargetOfImportEqualsDeclaration(node); - case 236: - return getTargetOfImportClause(node); case 237: + return getTargetOfImportClause(node); + case 238: return getTargetOfNamespaceImport(node); - case 239: - return getTargetOfImportSpecifier(node); - case 243: - return getTargetOfExportSpecifier(node); case 240: + return getTargetOfImportSpecifier(node); + case 244: + return getTargetOfExportSpecifier(node); + case 241: return getTargetOfExportAssignment(node); - case 233: + case 234: return getTargetOfNamespaceExportDeclaration(node); } } @@ -21954,10 +21861,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 240) { + if (node.kind === 241) { checkExpressionCached(node.expression); } - else if (node.kind === 243) { + else if (node.kind === 244) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -21973,7 +21880,7 @@ var ts; return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 234); + ts.Debug.assert(entityName.parent.kind === 235); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -22270,11 +22177,11 @@ var ts; } } switch (location_1.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 230: + case 231: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -22318,7 +22225,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -22350,7 +22257,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -22423,7 +22330,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 261 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 262 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -22461,7 +22368,7 @@ var ts; meaning = 107455 | 1048576; } else if (entityName.kind === 141 || entityName.kind === 177 || - entityName.parent.kind === 234) { + entityName.parent.kind === 235) { meaning = 1920; } else { @@ -22556,7 +22463,7 @@ var ts; while (node.kind === 166) { node = node.parent; } - if (node.kind === 228) { + if (node.kind === 229) { return getSymbolOfNode(node); } } @@ -22564,7 +22471,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 231 && + node.parent.kind === 232 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -22633,9 +22540,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_5 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_5) { - walkSymbol(parent_5, getQualifiedLeftMeaning(meaning), false); + var parent_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_6) { + walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -22768,12 +22675,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_6 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_6); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_6, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -22832,7 +22739,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 261 || declaration.parent.kind === 231; + return declaration.parent.kind === 262 || declaration.parent.kind === 232; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -22845,25 +22752,6 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } - function writeIndexSignature(info, keyword) { - if (info) { - if (info.isReadonly) { - writeKeyword(writer, 130); - writeSpace(writer); - } - writePunctuation(writer, 20); - writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55); - writeSpace(writer); - writeKeyword(writer, keyword); - writePunctuation(writer, 21); - writePunctuation(writer, 55); - writeSpace(writer); - writeType(info.type, 0); - writePunctuation(writer, 24); - writer.writeLine(); - } - } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { writeKeyword(writer, 130); @@ -22946,8 +22834,8 @@ var ts; writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 134); - writeIndexSignature(resolved.numberIndexInfo, 132); + buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0, enclosingDeclaration, globalFlags, symbolStack); + buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, 1, enclosingDeclaration, globalFlags, symbolStack); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -23126,6 +23014,10 @@ var ts; buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + var returnType = getReturnTypeOfSignature(signature); + if (flags & 2048 && isTypeAny(returnType)) { + return; + } if (flags & 8) { writeSpace(writer); writePunctuation(writer, 35); @@ -23138,7 +23030,6 @@ var ts; buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); } else { - var returnType = getReturnTypeOfSignature(signature); buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } } @@ -23156,6 +23047,32 @@ var ts; buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } + function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 130); + writeSpace(writer); + } + writePunctuation(writer, 20); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 55); + writeSpace(writer); + switch (kind) { + case 1: + writeKeyword(writer, 132); + break; + case 0: + writeKeyword(writer, 134); + break; + } + writePunctuation(writer, 21); + writePunctuation(writer, 55); + writeSpace(writer); + buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); + writePunctuation(writer, 24); + writer.writeLine(); + } + } return _displayBuilder || (_displayBuilder = { buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, @@ -23166,6 +23083,7 @@ var ts; buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, + buildIndexSignatureDisplay: buildIndexSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay }); } @@ -23182,27 +23100,27 @@ var ts; switch (node.kind) { case 174: return isDeclarationVisible(node.parent.parent); - case 223: + case 224: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 230: - case 226: + case 231: case 227: case 228: - case 225: case 229: - case 234: + case 226: + case 230: + case 235: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_7 = getDeclarationContainer(node); + var parent_8 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 234 && parent_7.kind !== 261 && ts.isInAmbientContext(parent_7))) { - return isGlobalSourceFile(parent_7); + !(node.kind !== 235 && parent_8.kind !== 262 && ts.isInAmbientContext(parent_8))) { + return isGlobalSourceFile(parent_8); } - return isDeclarationVisible(parent_7); + return isDeclarationVisible(parent_8); case 147: case 146: case 151: @@ -23217,7 +23135,7 @@ var ts; case 153: case 155: case 144: - case 231: + case 232: case 158: case 159: case 161: @@ -23228,15 +23146,15 @@ var ts; case 165: case 166: return isDeclarationVisible(node.parent); - case 236: case 237: - case 239: + case 238: + case 240: return false; case 143: - case 261: - case 233: + case 262: + case 234: return true; - case 240: + case 241: return false; default: return false; @@ -23245,10 +23163,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 240) { + if (node.parent && node.parent.kind === 241) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 243) { + else if (node.parent.kind === 244) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -23326,12 +23244,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 223: case 224: + case 225: + case 240: case 239: case 238: case 237: - case 236: node = node.parent; break; default: @@ -23350,9 +23268,6 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1) !== 0; } - function isTypeNever(type) { - return type && (type.flags & 8192) !== 0; - } function getTypeForBindingElementParent(node) { var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); @@ -23371,8 +23286,8 @@ var ts; var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name_19 = properties_2[_i]; - names[ts.getTextOfPropertyName(name_19)] = true; + var name_18 = properties_2[_i]; + names[ts.getTextOfPropertyName(name_18)] = true; } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; @@ -23417,19 +23332,19 @@ var ts; type = getRestType(parentType, literalMembers, declaration.symbol); } else { - var name_20 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_20)) { + var name_19 = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name_19)) { return anyType; } if (declaration.initializer) { getContextualType(declaration.initializer); } - var text = ts.getTextOfPropertyName(name_20); + var text = ts.getTextOfPropertyName(name_19); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_20)); + error(name_19, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_19)); return unknownType; } } @@ -23487,11 +23402,11 @@ var ts; return type; } } - if (declaration.parent.parent.kind === 212) { + if (declaration.parent.parent.kind === 213) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 | 262144) ? indexType : stringType; } - if (declaration.parent.parent.kind === 213) { + if (declaration.parent.parent.kind === 214) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -23501,7 +23416,7 @@ var ts; return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && - declaration.kind === 223 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 224 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -23539,7 +23454,7 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 258) { + if (declaration.kind === 259) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -23614,7 +23529,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 257) { + if (declaration.kind === 258) { return type; } return getWidenedType(type); @@ -23642,10 +23557,10 @@ var ts; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 240) { + if (declaration.kind === 241) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 && declaration.kind === 286 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 287 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { @@ -23852,8 +23767,8 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 226 || node.kind === 197 || - node.kind === 225 || node.kind === 184 || + if (node.kind === 227 || node.kind === 197 || + node.kind === 226 || node.kind === 184 || node.kind === 149 || node.kind === 185) { var declarations = node.typeParameters; if (declarations) { @@ -23863,15 +23778,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 227); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 228); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 227 || node.kind === 226 || - node.kind === 197 || node.kind === 228) { + if (node.kind === 228 || node.kind === 227 || + node.kind === 197 || node.kind === 229) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -24004,7 +23919,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 228 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -24033,7 +23948,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227) { + if (declaration.kind === 228) { if (declaration.flags & 64) { return false; } @@ -24083,7 +23998,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 285); + var declaration = ts.getDeclarationOfKind(symbol, 286); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -24094,7 +24009,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 228); + declaration = ts.getDeclarationOfKind(symbol, 229); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -24126,7 +24041,7 @@ var ts; function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 230) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -24154,7 +24069,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 230) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -24629,8 +24544,8 @@ var ts; else { var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; @@ -24901,7 +24816,7 @@ var ts; } function isJSDocOptionalParameter(node) { if (node.flags & 65536) { - if (node.type && node.type.kind === 273) { + if (node.type && node.type.kind === 274) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -24912,7 +24827,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 273; + return paramTag.typeExpression.type.kind === 274; } } } @@ -24964,7 +24879,7 @@ var ts; var thisParameter = undefined; var hasThisParameter = void 0; var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); - for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { + for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) { @@ -25047,12 +24962,12 @@ var ts; if (!symbol) return emptyArray; var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { + for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { case 158: case 159: - case 225: + case 226: case 149: case 148: case 150: @@ -25063,7 +24978,7 @@ var ts; case 152: case 184: case 185: - case 274: + case 275: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -25335,7 +25250,7 @@ var ts; switch (node.kind) { case 157: return node.typeName; - case 272: + case 273: return node.name; case 199: var expr = node.expression; @@ -25361,7 +25276,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 272) { + if (symbol.flags & 107455 && node.kind === 273) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -25371,7 +25286,7 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 272) { + if (node.kind === 273) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); @@ -25406,9 +25321,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 226: case 227: - case 229: + case 228: + case 230: return declaration; } } @@ -25582,8 +25497,9 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; + if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } } @@ -25693,8 +25609,8 @@ var ts; } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; addTypeToIntersection(typeSet, type); } } @@ -25812,7 +25728,7 @@ var ts; getIndexInfoOfType(objectType, 0) || undefined; if (indexInfo) { - if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return unknownType; } @@ -25924,7 +25840,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 228 ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 229 ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -26047,7 +25963,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 227)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 228)) { if (!(ts.getModifierFlags(container) & 32) && (container.kind !== 150 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -26066,8 +25982,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118: - case 263: case 264: + case 265: return anyType; case 134: return stringType; @@ -26085,21 +26001,21 @@ var ts; return nullType; case 129: return neverType; - case 289: - return nullType; case 290: - return undefinedType; + return nullType; case 291: + return undefinedType; + case 292: return neverType; case 167: case 98: return getTypeFromThisTypeNode(node); case 171: return getTypeFromLiteralTypeNode(node); - case 288: + case 289: return getTypeFromLiteralTypeNode(node.literal); case 157: - case 272: + case 273: return getTypeFromTypeReference(node); case 156: return booleanType; @@ -26108,29 +26024,29 @@ var ts; case 160: return getTypeFromTypeQueryNode(node); case 162: - case 265: + case 266: return getTypeFromArrayTypeNode(node); case 163: return getTypeFromTupleTypeNode(node); case 164: - case 266: + case 267: return getTypeFromUnionTypeNode(node); case 165: return getTypeFromIntersectionTypeNode(node); case 166: - case 268: case 269: - case 276: - case 277: - case 273: - return getTypeFromTypeNode(node.type); case 270: + case 277: + case 278: + case 274: + return getTypeFromTypeNode(node.type); + case 271: return getTypeFromTypeNode(node.literal); case 158: case 159: case 161: - case 287: - case 274: + case 288: + case 275: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 168: return getTypeFromTypeOperatorNode(node); @@ -26142,9 +26058,9 @@ var ts; case 141: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 267: + case 268: return getTypeFromJSDocTupleType(node); - case 275: + case 276: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -26293,17 +26209,19 @@ var ts; var constraintType = getConstraintTypeFromMappedType(type); if (constraintType.flags & 262144) { var typeVariable_1 = constraintType.type; - var mappedTypeVariable = instantiateType(typeVariable_1, mapper); - if (typeVariable_1 !== mappedTypeVariable) { - return mapType(mappedTypeVariable, function (t) { - if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); - } - return t; - }); + if (typeVariable_1.flags & 16384) { + var mappedTypeVariable = instantiateType(typeVariable_1, mapper); + if (typeVariable_1 !== mappedTypeVariable) { + return mapType(mappedTypeVariable, function (t) { + if (isMappableType(t)) { + var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); + var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); + combinedMapper.mappedTypes = mapper.mappedTypes; + return instantiateMappedObjectType(type, combinedMapper); + } + return t; + }); + } } } return instantiateMappedObjectType(type, mapper); @@ -26324,12 +26242,12 @@ var ts; return false; } var mappedTypes = mapper.mappedTypes; - var node = symbol.declarations[0].parent; + var node = symbol.declarations[0]; while (node) { switch (node.kind) { case 158: case 159: - case 225: + case 226: case 149: case 148: case 150: @@ -26340,10 +26258,10 @@ var ts; case 152: case 184: case 185: - case 226: - case 197: case 227: + case 197: case 228: + case 229: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -26353,15 +26271,24 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 227) { + if (ts.isClassLike(node) || node.kind === 228) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 230: - case 261: + case 275: + var func = node; + for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { + var p = _c[_b]; + if (ts.contains(mappedTypes, getTypeOfNode(p))) { + return true; + } + } + break; + case 231: + case 262: return false; } node = node.parent; @@ -26371,7 +26298,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 261 || parentKind === 231; + return parentKind === 262 || parentKind === 232; } return false; } @@ -26438,7 +26365,7 @@ var ts; case 192: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 257: + case 258: return isContextSensitive(node.initializer); case 149: case 148: @@ -26494,7 +26421,7 @@ var ts; return isTypeRelatedTo(source, target, assignableRelation); } function isTypeInstanceOf(source, target) { - return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); } function isTypeComparableTo(source, target) { return isTypeRelatedTo(source, target, comparableRelation); @@ -27196,8 +27123,11 @@ var ts; } } } - else if (relation !== identityRelation && isEmptyObjectType(resolveStructuredTypeMembers(target))) { - return -1; + else if (relation !== identityRelation) { + var resolved = resolveStructuredTypeMembers(target); + if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1) { + return -1; + } } return 0; } @@ -27348,7 +27278,7 @@ var ts; return 0; } var result = -1; - for (var i = 0, len = sourceSignatures.length; i < len; i++) { + for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], false, false, false, isRelatedTo); if (!related) { return 0; @@ -27557,8 +27487,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var t = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var t = types_8[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -27566,8 +27496,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -27658,8 +27588,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; result |= getFalsyFlags(t); } return result; @@ -27818,7 +27748,7 @@ var ts; case 174: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 225: + case 226: case 149: case 148: case 151: @@ -28159,8 +28089,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -28276,7 +28206,7 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 223 || target.kind === 174) && + (target.kind === 224 || target.kind === 174) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; @@ -28374,8 +28304,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getTypeFacts(t); } return result; @@ -28461,7 +28391,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 || node.parent.kind === 257 ? + return node.parent.kind === 175 || node.parent.kind === 258 ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } @@ -28480,9 +28410,9 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 212: - return stringType; case 213: + return stringType; + case 214: return checkRightHandSideOfForOf(parent.expression) || unknownType; case 192: return getAssignedTypeOfBinaryExpression(parent); @@ -28492,9 +28422,9 @@ var ts; return getAssignedTypeOfArrayLiteralElement(parent, node); case 196: return getAssignedTypeOfSpreadExpression(parent); - case 257: - return getAssignedTypeOfPropertyAssignment(parent); case 258: + return getAssignedTypeOfPropertyAssignment(parent); + case 259: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -28517,26 +28447,26 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 212) { + if (node.parent.parent.kind === 213) { return stringType; } - if (node.parent.parent.kind === 213) { + if (node.parent.parent.kind === 214) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 223 ? + return node.kind === 224 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 223 || node.kind === 174 ? + return node.kind === 224 || node.kind === 174 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 223 && node.initializer && + return node.kind === 224 && node.initializer && isEmptyArrayLiteral(node.initializer) || node.kind !== 174 && node.parent.kind === 192 && isEmptyArrayLiteral(node.parent.right); @@ -28563,7 +28493,7 @@ var ts; getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 253) { + if (clause.kind === 254) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -28665,8 +28595,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -29208,8 +29138,8 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 231 || - node.kind === 261 || + node.kind === 232 || + node.kind === 262 || node.kind === 147) { return node; } @@ -29279,7 +29209,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; - if (declaration_1.kind === 226 + if (declaration_1.kind === 227 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -29307,6 +29237,7 @@ var ts; } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkCollisionWithCapturedNewTargetVariable(node, node); checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; @@ -29334,7 +29265,7 @@ var ts; flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0 || isInTypeQuery(node)) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); if (type === autoType || type === autoArrayType) { @@ -29365,7 +29296,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 256) { + symbol.valueDeclaration.parent.kind === 257) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -29383,8 +29314,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 211 && - ts.getAncestor(symbol.valueDeclaration, 224).parent === container && + if (container.kind === 212 && + ts.getAncestor(symbol.valueDeclaration, 225).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -29474,10 +29405,10 @@ var ts; needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 230: + case 231: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 229: + case 230: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; case 150: @@ -29535,9 +29466,9 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 274) { + if (jsdocType && jsdocType.kind === 275) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 277) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 278) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -29724,11 +29655,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_21 = declaration.propertyName || declaration.name; + var name_20 = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_21)) { - var text = ts.getTextOfPropertyName(name_21); + !ts.isBindingPattern(name_20)) { + var text = ts.getTextOfPropertyName(name_20); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -29831,8 +29762,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -29902,13 +29833,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 250) { + if (attribute.kind === 251) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 251) { + else if (attribute.kind === 252) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -29926,14 +29857,14 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 223: + case 224: case 144: case 147: case 146: case 174: return getContextualTypeForInitializerExpression(node); case 185: - case 216: + case 217: return getContextualTypeForReturnExpression(node); case 195: return getContextualTypeForYieldOperand(parent); @@ -29945,22 +29876,22 @@ var ts; return getTypeFromTypeNode(parent.type); case 192: return getContextualTypeForBinaryOperand(node); - case 257: case 258: + case 259: return getContextualTypeForObjectLiteralElement(parent); case 175: return getContextualTypeForElementExpression(node); case 193: return getContextualTypeForConditionalOperand(node); - case 202: + case 203: ts.Debug.assert(parent.parent.kind === 194); return getContextualTypeForSubstitutionExpression(parent.parent, node); case 183: return getContextualType(parent); - case 252: + case 253: return getContextualType(parent); - case 250: case 251: + case 252: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -30012,8 +29943,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -30156,25 +30087,25 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 257 || - memberDecl.kind === 258 || + if (memberDecl.kind === 258 || + memberDecl.kind === 259 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 257) { + if (memberDecl.kind === 258) { type = checkPropertyAssignment(memberDecl, contextualMapper); } else if (memberDecl.kind === 149) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 258); + ts.Debug.assert(memberDecl.kind === 259); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 257 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 258 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 258 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 259 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912; } @@ -30200,7 +30131,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 259) { + else if (memberDecl.kind === 260) { if (languageVersion < 5) { checkExternalEmitHelpers(memberDecl, 2); } @@ -30300,13 +30231,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 252: + case 253: checkJsxExpression(child); break; - case 246: + case 247: checkJsxElement(child); break; - case 247: + case 248: checkJsxSelfClosingElement(child); break; } @@ -30601,11 +30532,11 @@ var ts; var nameTable = ts.createMap(); var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 250) { + if (node.attributes[i].kind === 251) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 251); + ts.Debug.assert(node.attributes[i].kind === 252); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -30624,7 +30555,11 @@ var ts; } function checkJsxExpression(node) { if (node.expression) { - return checkExpression(node.expression); + var type = checkExpression(node.expression); + if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { + error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); + } + return type; } else { return unknownType; @@ -30642,7 +30577,7 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 || node.kind === 223 ? + var errorNode = node.kind === 177 || node.kind === 224 ? node.name : node.right; if (left.kind === 96) { @@ -30788,7 +30723,7 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 224) { + if (initializer.kind === 225) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -30810,7 +30745,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 212 && + if (node.kind === 213 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -30906,19 +30841,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_8 = signature.declaration && signature.declaration.parent; + var parent_9 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_8 === lastParent) { + if (lastParent && parent_9 === lastParent) { index++; } else { - lastParent = parent_8; + lastParent = parent_9; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_8; + lastParent = parent_9; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -31138,7 +31073,7 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 145) { switch (node.parent.kind) { - case 226: + case 227: case 197: return 1; case 147: @@ -31159,7 +31094,7 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } @@ -31180,7 +31115,7 @@ var ts; return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } @@ -31217,7 +31152,7 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } @@ -31578,7 +31513,7 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 226: + case 227: case 197: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 144: @@ -31688,9 +31623,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 225 + ? 226 : resolvedRequire.flags & 3 - ? 223 + ? 224 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -31716,6 +31651,23 @@ var ts; function checkNonNullAssertion(node) { return getNonNullableType(checkExpression(node.expression)); } + function checkMetaProperty(node) { + checkGrammarMetaProperty(node); + ts.Debug.assert(node.keywordToken === 93 && node.name.text === "target", "Unrecognized meta-property."); + var container = ts.getNewTargetContainer(node); + if (!container) { + error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); + return unknownType; + } + else if (container.kind === 150) { + var symbol = getSymbolOfNode(container.parent); + return getTypeOfSymbol(symbol); + } + else { + var symbol = getSymbolOfNode(container); + return getTypeOfSymbol(symbol); + } + } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks) { @@ -31823,7 +31775,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 204) { + if (func.body.kind !== 205) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -31902,7 +31854,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 218 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 219 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -31948,7 +31900,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 204 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 205 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -32014,6 +31966,7 @@ var ts; if (produceDiagnostics && node.kind !== 149) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); } return type; } @@ -32028,7 +31981,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 204) { + if (node.body.kind === 205) { checkSourceElement(node.body); } else { @@ -32081,7 +32034,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 237; + return declaration && declaration.kind === 238; } } } @@ -32097,6 +32050,16 @@ var ts; } function checkDeleteExpression(node) { checkExpression(node.expression); + var expr = ts.skipParentheses(node.expression); + if (expr.kind !== 177 && expr.kind !== 178) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); + return booleanType; + } + var links = getNodeLinks(expr); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } return booleanType; } function checkTypeOfExpression(node) { @@ -32167,8 +32130,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -32182,8 +32145,8 @@ var ts; } if (type.flags & 65536) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -32192,8 +32155,8 @@ var ts; } if (type.flags & 131072) { var types = type.types; - for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { - var t = types_17[_a]; + for (var _a = 0, types_18 = types; _a < types_18.length; _a++) { + var t = types_18[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -32240,22 +32203,22 @@ var ts; return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 257 || property.kind === 258) { - var name_22 = property.name; - if (name_22.kind === 142) { - checkComputedPropertyName(name_22); + if (property.kind === 258 || property.kind === 259) { + var name_21 = property.name; + if (name_21.kind === 142) { + checkComputedPropertyName(name_21); } - if (isComputedNonLiteralName(name_22)) { + if (isComputedNonLiteralName(name_21)) { return undefined; } - var text = ts.getTextOfPropertyName(name_22); + var text = ts.getTextOfPropertyName(name_21); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 258) { + if (property.kind === 259) { return checkDestructuringAssignment(property, type); } else { @@ -32263,10 +32226,10 @@ var ts; } } else { - error(name_22, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_22)); + error(name_21, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_21)); } } - else if (property.kind === 259) { + else if (property.kind === 260) { if (languageVersion < 5) { checkExternalEmitHelpers(property, 4); } @@ -32334,7 +32297,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 258) { + if (exprOrAssignment.kind === 259) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -32362,7 +32325,7 @@ var ts; } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 259 ? + var error = target.parent.kind === 260 ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -32391,8 +32354,8 @@ var ts; case 176: case 187: case 201: + case 248: case 247: - case 246: return true; case 193: return isSideEffectFree(node.whenTrue) && @@ -32826,6 +32789,8 @@ var ts; return checkAssertion(node); case 201: return checkNonNullAssertion(node); + case 202: + return checkMetaProperty(node); case 186: return checkDeleteExpression(node); case 188: @@ -32846,13 +32811,13 @@ var ts; return undefinedWideningType; case 195: return checkYieldExpression(node); - case 252: + case 253: return checkJsxExpression(node); - case 246: - return checkJsxElement(node); case 247: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 248: + return checkJsxSelfClosingElement(node); + case 249: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -32897,7 +32862,7 @@ var ts; return false; } return node.kind === 149 || - node.kind === 225 || + node.kind === 226 || node.kind === 184; } function getTypePredicateParameterIndex(parameterList, parameter) { @@ -32939,9 +32904,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_23 = _a[_i].name; - if (ts.isBindingPattern(name_23) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_23, parameterName, typePredicate.parameterName)) { + var name_22 = _a[_i].name; + if (ts.isBindingPattern(name_22) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -32956,14 +32921,14 @@ var ts; switch (node.parent.kind) { case 185: case 153: - case 225: + case 226: case 184: case 158: case 149: case 148: - var parent_9 = node.parent; - if (node === parent_9.type) { - return parent_9; + var parent_10 = node.parent; + if (node === parent_10.type) { + return parent_10; } } } @@ -32973,15 +32938,15 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_24 = element.name; - if (name_24.kind === 70 && - name_24.text === predicateVariableName) { + var name_23 = element.name; + if (name_23.kind === 70 && + name_23.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_24.kind === 173 || - name_24.kind === 172) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_24, predicateVariableNode, predicateVariableName)) { + else if (name_23.kind === 173 || + name_23.kind === 172) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_23, predicateVariableNode, predicateVariableName)) { return true; } } @@ -32991,7 +32956,7 @@ var ts; if (node.kind === 155) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 || node.kind === 225 || node.kind === 159 || + else if (node.kind === 158 || node.kind === 226 || node.kind === 159 || node.kind === 153 || node.kind === 150 || node.kind === 154) { checkGrammarFunctionLikeDeclaration(node); @@ -33113,7 +33078,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 227) { + if (node.kind === 228) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -33195,7 +33160,7 @@ var ts; if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 && n.kind !== 225) { + else if (n.kind !== 184 && n.kind !== 226) { ts.forEachChild(n, markThisReferencesAsErrors); } } @@ -33220,7 +33185,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -33369,8 +33334,8 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 227 && - n.parent.kind !== 226 && + if (n.parent.kind !== 228 && + n.parent.kind !== 227 && n.parent.kind !== 197 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { @@ -33481,11 +33446,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 227 || node.parent.kind === 161 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 228 || node.parent.kind === 161 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 225 || node.kind === 149 || node.kind === 148 || node.kind === 150) { + if (node.kind === 226 || node.kind === 149 || node.kind === 148 || node.kind === 150) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -33596,16 +33561,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 227: + case 228: return 2097152; - case 230: + case 231: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 226: - case 229: + case 227: + case 230: return 2097152 | 1048576; - case 234: + case 235: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -33617,7 +33582,8 @@ var ts; } function checkNonThenableType(type, location, message) { type = getWidenedType(type); - if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + var apparentType = getApparentType(type); + if ((apparentType.flags & (1 | 8192)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -33752,7 +33718,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 226: + case 227: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -33807,7 +33773,7 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 226: + case 227: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -33840,6 +33806,7 @@ var ts; checkFunctionOrMethodDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -33890,28 +33857,28 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 261: - case 230: + case 262: + case 231: checkUnusedModuleMembers(node); break; - case 226: + case 227: case 197: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 227: + case 228: checkUnusedTypeParameters(node); break; - case 204: - case 232: - case 211: + case 205: + case 233: case 212: case 213: + case 214: checkUnusedLocalsAndParameters(node); break; case 150: case 184: - case 225: + case 226: case 185: case 149: case 151: @@ -33935,7 +33902,7 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 227 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 228 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_2 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { @@ -33968,9 +33935,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 223 && - (declaration.parent.parent.kind === 212 || - declaration.parent.parent.kind === 213)) { + if (declaration.kind === 224 && + (declaration.parent.parent.kind === 213 || + declaration.parent.parent.kind === 214)) { return; } } @@ -34031,7 +33998,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - error(declaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + errorUnusedLocal(declaration.name, local.name); } } } @@ -34039,7 +34006,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 204) { + if (node.kind === 205) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -34083,6 +34050,11 @@ var ts; potentialThisCollisions.push(node); } } + function checkCollisionWithCapturedNewTargetVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_newTarget")) { + potentialNewTargetCollisions.push(node); + } + } function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; while (current) { @@ -34099,6 +34071,22 @@ var ts; current = current.parent; } } + function checkIfNewTargetIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 8) { + var isDeclaration_2 = node.kind !== 70; + if (isDeclaration_2) { + error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); + } + return; + } + current = current.parent; + } + } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -34108,8 +34096,8 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 70; - if (isDeclaration_2) { + var isDeclaration_3 = node.kind !== 70; + if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -34124,11 +34112,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 262 && ts.isExternalOrCommonJsModule(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)); } } @@ -34136,11 +34124,11 @@ var ts; if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 262 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -34148,7 +34136,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 223 && !node.initializer) { + if (node.kind === 224 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -34158,18 +34146,18 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 224); - var container = varDeclList.parent.kind === 205 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 225); + var container = varDeclList.parent.kind === 206 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 204 && ts.isFunctionLike(container.parent) || + (container.kind === 205 && ts.isFunctionLike(container.parent) || + container.kind === 232 || container.kind === 231 || - container.kind === 230 || - container.kind === 261); + container.kind === 262); if (!namesShareScope) { - var name_25 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_25, name_25); + var name_24 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_24, name_24); } } } @@ -34199,7 +34187,8 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144) { + if (symbol.valueDeclaration.kind === 144 || + symbol.valueDeclaration.kind === 174) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -34237,19 +34226,19 @@ var ts; } } if (node.kind === 174) { - if (node.parent.kind === 172 && languageVersion < 5) { + if (node.parent.kind === 172 && languageVersion < 5 && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4); } if (node.propertyName && node.propertyName.kind === 142) { checkComputedPropertyName(node.propertyName); } - var parent_10 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_10); - var name_26 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_26)); + var parent_11 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_11); + var name_25 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_25)); markPropertyAsReferenced(property); - if (parent_10.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_10, parent_10.initializer, parentType, property); + if (parent_11.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { @@ -34260,7 +34249,7 @@ var ts; return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 213) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -34269,7 +34258,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 213) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -34289,18 +34278,19 @@ var ts; } if (node.kind !== 147 && node.kind !== 146) { checkExportsOnMergedDeclarations(node); - if (node.kind === 223 || node.kind === 174) { + if (node.kind === 224 || node.kind === 174) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 && right.kind === 223) || - (left.kind === 223 && right.kind === 144)) { + if ((left.kind === 144 && right.kind === 224) || + (left.kind === 224 && right.kind === 144)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -34346,7 +34336,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 206) { + if (node.thenStatement.kind === 207) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -34363,12 +34353,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 224) { + if (node.initializer && node.initializer.kind === 225) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -34386,7 +34376,7 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { checkForInOrForOfVariableDeclaration(node); } else { @@ -34411,7 +34401,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { 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); @@ -34668,7 +34658,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 254 && !hasDuplicateDefaultClause) { + if (clause.kind === 255 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -34680,7 +34670,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 253) { + if (produceDiagnostics && clause.kind === 254) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); var caseIsLiteral = isLiteralType(caseType); @@ -34706,7 +34696,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 219 && current.label.text === node.label.text) { + if (current.kind === 220 && 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; @@ -34829,7 +34819,7 @@ var ts; } function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { @@ -34849,7 +34839,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 || declaration.kind === 227) { + if (declaration.kind === 227 || declaration.kind === 228) { if (!firstDecl) { firstDecl = declaration; } @@ -34882,6 +34872,7 @@ var ts; if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -34917,7 +34908,7 @@ var ts; checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 226) { + baseType_1.symbol.valueDeclaration.kind === 227) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -35044,7 +35035,7 @@ var ts; if (!list1 || !list2 || list1.length !== list2.length) { return false; } - for (var i = 0, len = list1.length; i < len; i++) { + for (var i = 0; i < list1.length; i++) { var tp1 = list1[i]; var tp2 = list2[i]; if (tp1.name.text !== tp2.name.text) { @@ -35102,7 +35093,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 228); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -35233,6 +35224,7 @@ var ts; } return undefined; case 8: + checkGrammarNumericLiteral(e); return +e.text; case 183: return evalConstant(e.expression); @@ -35306,6 +35298,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); @@ -35326,7 +35319,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 229) { + if (declaration.kind !== 230) { return false; } var enumDeclaration = declaration; @@ -35349,8 +35342,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 226 || - (declaration.kind === 225 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 227 || + (declaration.kind === 226 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -35409,7 +35402,7 @@ 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, 226); + var mergedClass = ts.getDeclarationOfKind(symbol, 227); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -35452,36 +35445,36 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 205: + case 206: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 240: case 241: + case 242: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 234: case 235: + case 236: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; case 174: - case 223: - var name_27 = node.name; - if (ts.isBindingPattern(name_27)) { - for (var _b = 0, _c = name_27.elements; _b < _c.length; _b++) { + case 224: + var name_26 = node.name; + if (ts.isBindingPattern(name_26)) { + for (var _b = 0, _c = name_26.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } - case 226: - case 229: - case 225: case 227: case 230: + case 226: case 228: + case 231: + case 229: if (isGlobalAugmentation) { return; } @@ -35517,9 +35510,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { - error(moduleName, node.kind === 241 ? + var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 && !inAmbientExternalModule) { + error(moduleName, node.kind === 242 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -35540,7 +35533,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 243 ? + var message = node.kind === 244 ? 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)); @@ -35567,7 +35560,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237) { + if (importClause.namedBindings.kind === 238) { checkImportBinding(importClause.namedBindings); } else { @@ -35618,8 +35611,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -35632,7 +35625,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 261 || node.parent.kind === 231 || node.parent.kind === 230; + var isInAppropriateContext = node.parent.kind === 262 || node.parent.kind === 232 || node.parent.kind === 231; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -35655,9 +35648,14 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 261 ? node.parent : node.parent.parent; - if (container.kind === 230 && !ts.isAmbientModule(container)) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + var container = node.parent.kind === 262 ? node.parent : node.parent.parent; + if (container.kind === 231 && !ts.isAmbientModule(container)) { + if (node.isExportEquals) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + } + else { + error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); + } return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { @@ -35723,7 +35721,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 225 && declaration.kind !== 149) || + return (declaration.kind !== 226 && declaration.kind !== 149) || !!declaration.body; } } @@ -35734,10 +35732,10 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 230: - case 226: + case 231: case 227: - case 225: + case 228: + case 226: cancellationToken.throwIfCancellationRequested(); } } @@ -35786,71 +35784,71 @@ var ts; return checkIndexedAccessType(node); case 170: return checkMappedType(node); - case 225: + case 226: return checkFunctionDeclaration(node); - case 204: - case 231: - return checkBlock(node); case 205: + case 232: + return checkBlock(node); + case 206: return checkVariableStatement(node); - case 207: - return checkExpressionStatement(node); case 208: - return checkIfStatement(node); + return checkExpressionStatement(node); case 209: - return checkDoStatement(node); + return checkIfStatement(node); case 210: - return checkWhileStatement(node); + return checkDoStatement(node); case 211: - return checkForStatement(node); + return checkWhileStatement(node); case 212: - return checkForInStatement(node); + return checkForStatement(node); case 213: - return checkForOfStatement(node); + return checkForInStatement(node); case 214: + return checkForOfStatement(node); case 215: - return checkBreakOrContinueStatement(node); case 216: - return checkReturnStatement(node); + return checkBreakOrContinueStatement(node); case 217: - return checkWithStatement(node); + return checkReturnStatement(node); case 218: - return checkSwitchStatement(node); + return checkWithStatement(node); case 219: - return checkLabeledStatement(node); + return checkSwitchStatement(node); case 220: - return checkThrowStatement(node); + return checkLabeledStatement(node); case 221: + return checkThrowStatement(node); + case 222: return checkTryStatement(node); - case 223: + case 224: return checkVariableDeclaration(node); case 174: return checkBindingElement(node); - case 226: - return checkClassDeclaration(node); case 227: - return checkInterfaceDeclaration(node); + return checkClassDeclaration(node); case 228: - return checkTypeAliasDeclaration(node); + return checkInterfaceDeclaration(node); case 229: - return checkEnumDeclaration(node); + return checkTypeAliasDeclaration(node); case 230: + return checkEnumDeclaration(node); + case 231: return checkModuleDeclaration(node); - case 235: + case 236: return checkImportDeclaration(node); - case 234: + case 235: return checkImportEqualsDeclaration(node); - case 241: + case 242: return checkExportDeclaration(node); - case 240: + case 241: return checkExportAssignment(node); - case 206: + case 207: checkGrammarStatementInAmbientContext(node); return; - case 222: + case 223: checkGrammarStatementInAmbientContext(node); return; - case 244: + case 245: return checkMissingDeclaration(node); } } @@ -35893,6 +35891,7 @@ var ts; } checkGrammarSourceFile(node); potentialThisCollisions.length = 0; + potentialNewTargetCollisions.length = 0; deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; ts.forEach(node.statements, checkSourceElement); @@ -35912,6 +35911,10 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } + if (potentialNewTargetCollisions.length) { + ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); + potentialNewTargetCollisions.length = 0; + } links.flags |= 1; } } @@ -35956,7 +35959,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 217 && node.parent.statement === node) { + if (node.parent.kind === 218 && node.parent.statement === node) { return true; } node = node.parent; @@ -35978,14 +35981,14 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230: + case 231: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 229: + case 230: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; case 197: @@ -35993,8 +35996,8 @@ var ts; if (className) { copySymbol(location.symbol, meaning); } - case 226: case 227: + case 228: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } @@ -36039,10 +36042,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 143: - case 226: case 227: case 228: case 229: + case 230: return true; } } @@ -36051,7 +36054,7 @@ var ts; while (node.parent && node.parent.kind === 141) { node = node.parent; } - return node.parent && (node.parent.kind === 157 || node.parent.kind === 272); + return node.parent && (node.parent.kind === 157 || node.parent.kind === 273); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; @@ -36078,10 +36081,10 @@ var ts; while (nodeOnRightSide.parent.kind === 141) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 234) { + if (nodeOnRightSide.parent.kind === 235) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 240) { + if (nodeOnRightSide.parent.kind === 241) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -36105,11 +36108,11 @@ var ts; default: } } - if (entityName.parent.kind === 240 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 241 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } if (entityName.kind !== 177 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 234); + var importEqualsDeclaration = ts.getAncestor(entityName, 235); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -36156,10 +36159,10 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 272) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 273) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 250) { + else if (entityName.parent.kind === 251) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 156) { @@ -36168,7 +36171,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 261) { + if (node.kind === 262) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -36221,7 +36224,7 @@ var ts; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 235 || node.parent.kind === 241) && + ((node.parent.kind === 236 || node.parent.kind === 242) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -36243,7 +36246,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 258) { + if (location && location.kind === 259) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -36294,7 +36297,7 @@ var ts; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { ts.Debug.assert(expr.kind === 176 || expr.kind === 175); - if (expr.parent.kind === 213) { + if (expr.parent.kind === 214) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -36302,7 +36305,7 @@ var ts; var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 257) { + if (expr.parent.kind === 258) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } @@ -36342,9 +36345,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols_3 = []; - var name_28 = symbol.name; + var name_27 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_28); + var symbol = getPropertyOfType(t, name_27); if (symbol) { symbols_3.push(symbol); } @@ -36413,7 +36416,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 261) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 262) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -36451,7 +36454,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 204 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 205 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -36491,16 +36494,16 @@ var ts; return true; } switch (node.kind) { - case 234: - case 236: + case 235: case 237: - case 239: - case 243: + case 238: + case 240: + case 244: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 241: + case 242: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 240: + case 241: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -36510,7 +36513,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 261 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 262 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -36561,7 +36564,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 260) { + if (node.kind === 261) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -36655,9 +36658,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_11 = reference.parent; - if (ts.isDeclaration(parent_11) && reference === parent_11.name) { - location = getDeclarationContainer(parent_11); + var parent_12 = reference.parent; + if (ts.isDeclaration(parent_12) && reference === parent_12.name) { + location = getDeclarationContainer(parent_12); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -36770,15 +36773,15 @@ var ts; } var current = symbol; while (true) { - var parent_12 = getParentOfSymbol(current); - if (parent_12) { - current = parent_12; + var parent_13 = getParentOfSymbol(current); + if (parent_13) { + current = parent_13; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 261 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 262 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -36797,7 +36800,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 261); + return ts.getDeclarationOfKind(moduleSymbol, 262); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -36888,10 +36891,10 @@ var ts; var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1; helper <= 128; helper <<= 1) { if (uncheckedHelpers & helper) { - var name_29 = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_29), 107455); + var name_28 = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_28), 107455); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_29); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_28); } } } @@ -36974,7 +36977,7 @@ var ts; } switch (modifier.kind) { case 75: - if (node.kind !== 229 && node.parent.kind === 226) { + if (node.kind !== 230 && node.parent.kind === 227) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -37000,7 +37003,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 232 || node.parent.kind === 262) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -37023,7 +37026,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 232 || node.parent.kind === 262) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 144) { @@ -37058,7 +37061,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 144) { @@ -37073,13 +37076,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 231) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 232) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -37089,14 +37092,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 226) { + if (node.kind !== 227) { if (node.kind !== 149 && node.kind !== 147 && node.kind !== 151 && node.kind !== 152) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 226 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 227 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -37138,7 +37141,7 @@ var ts; } return; } - else if ((node.kind === 235 || node.kind === 234) && flags & 2) { + else if ((node.kind === 236 || node.kind === 235) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 144 && (flags & 92) && ts.isBindingPattern(node.name)) { @@ -37168,29 +37171,29 @@ var ts; case 149: case 148: case 155: - case 230: + case 231: + case 236: case 235: - case 234: + case 242: case 241: - case 240: case 184: case 185: case 144: return false; default: - if (node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 232 || node.parent.kind === 262) { return false; } switch (node.kind) { - case 225: - return nodeHasAnyModifiersExcept(node, 119); case 226: - return nodeHasAnyModifiersExcept(node, 116); + return nodeHasAnyModifiersExcept(node, 119); case 227: - case 205: + return nodeHasAnyModifiersExcept(node, 116); case 228: - return true; + case 206: case 229: + return true; + case 230: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -37204,7 +37207,7 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 149: - case 225: + case 226: case 184: case 185: if (!node.asteriskToken) { @@ -37410,7 +37413,7 @@ var ts; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 225 || + ts.Debug.assert(node.kind === 226 || node.kind === 184 || node.kind === 149); if (ts.isInAmbientContext(node)) { @@ -37437,14 +37440,14 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259) { + if (prop.kind === 260) { continue; } - var name_30 = prop.name; - if (name_30.kind === 142) { - checkGrammarComputedPropertyName(name_30); + var name_29 = prop.name; + if (name_29.kind === 142) { + checkGrammarComputedPropertyName(name_29); } - if (prop.kind === 258 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 259 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { @@ -37456,10 +37459,10 @@ var ts; } } var currentKind = void 0; - if (prop.kind === 257 || prop.kind === 258) { + if (prop.kind === 258 || prop.kind === 259) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_30.kind === 8) { - checkGrammarNumericLiteral(name_30); + if (name_29.kind === 8) { + checkGrammarNumericLiteral(name_29); } currentKind = Property; } @@ -37475,7 +37478,7 @@ var ts; else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_30); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_29); if (effectiveName === undefined) { continue; } @@ -37485,18 +37488,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_30, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_30)); + grammarErrorOnNode(name_29, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_29)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_29, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_29, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -37505,19 +37508,19 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 251) { + if (attr.kind === 252) { continue; } var jsxAttr = attr; - var name_31 = jsxAttr.name; - if (!seen[name_31.text]) { - seen[name_31.text] = true; + var name_30 = jsxAttr.name; + if (!seen[name_30.text]) { + seen[name_30.text] = true; } else { - return grammarErrorOnNode(name_31, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_30, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 252 && !initializer.expression) { + if (initializer && initializer.kind === 253 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -37526,7 +37529,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 224) { + if (forInOrOfStatement.initializer.kind === 225) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -37534,20 +37537,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? 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 = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? 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 === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? 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); @@ -37631,7 +37634,7 @@ 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 === 227) { + else if (node.parent.kind === 228) { 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 === 161) { @@ -37645,9 +37648,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 219: + case 220: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 214 + var isMisplacedContinueLabel = node.kind === 215 && !ts.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); @@ -37655,8 +37658,8 @@ var ts; return false; } break; - case 218: - if (node.kind === 215 && !node.label) { + case 219: + if (node.kind === 216 && !node.label) { return false; } break; @@ -37669,13 +37672,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 215 + var message = node.kind === 216 ? 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 === 215 + var message = node.kind === 216 ? 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); @@ -37701,7 +37704,7 @@ var ts; expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 212 && node.parent.parent.kind !== 213) { + if (node.parent.parent.kind !== 213 && node.parent.parent.kind !== 214) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -37758,15 +37761,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 208: case 209: case 210: - case 217: case 211: + case 218: case 212: case 213: + case 214: return false; - case 219: + case 220: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -37781,6 +37784,13 @@ var ts; } } } + function checkGrammarMetaProperty(node) { + if (node.keywordToken === 93) { + if (node.name.text !== "target") { + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + } + } + } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -37821,7 +37831,7 @@ var ts; return true; } } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 228) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -37842,13 +37852,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 227 || - node.kind === 228 || + if (node.kind === 228 || + node.kind === 229 || + node.kind === 236 || node.kind === 235 || - node.kind === 234 || + node.kind === 242 || node.kind === 241 || - node.kind === 240 || - node.kind === 233 || + node.kind === 234 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -37857,7 +37867,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 === 205) { + if (ts.isDeclaration(decl) || decl.kind === 206) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -37876,7 +37886,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 === 204 || node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 205 || node.parent.kind === 232 || node.parent.kind === 262) { 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); @@ -37887,8 +37897,22 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.isOctalLiteral && languageVersion >= 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + if (node.isOctalLiteral) { + var diagnosticMessage = void 0; + if (languageVersion >= 1) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 171)) { + diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 261)) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; + } + if (diagnosticMessage) { + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37; + var literal = (withMinus ? "-" : "") + "0o" + node.text; + return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); + } } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -37933,31 +37957,31 @@ var ts; _a[201] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[229] = [ + _a[230] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[230] = [ + _a[231] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[231] = [ + _a[232] = [ { name: "statements", test: ts.isStatement } ], - _a[234] = [ + _a[235] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[245] = [ + _a[246] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[260] = [ + _a[261] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -37983,11 +38007,11 @@ var ts; } var result = initial; switch (node.kind) { - case 203: - case 206: + case 204: + case 207: case 198: - case 222: - case 293: + case 223: + case 294: break; case 142: result = reduceNode(node.expression, cbNode, result); @@ -38128,72 +38152,72 @@ var ts; result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 202: + case 203: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 204: + case 205: result = reduceNodes(node.statements, cbNodes, result); break; - case 205: + case 206: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 207: + case 208: result = reduceNode(node.expression, cbNode, result); break; - case 208: + case 209: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 209: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; case 210: - case 217: - result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); break; case 211: + case 218: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 212: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 212: case 213: + case 214: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 216: - case 220: + case 217: + case 221: result = reduceNode(node.expression, cbNode, result); break; - case 218: + case 219: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 219: + case 220: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 221: + case 222: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 223: + case 224: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 224: + case 225: result = reduceNodes(node.declarations, cbNodes, result); break; - case 225: + case 226: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38202,7 +38226,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 226: + case 227: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38210,92 +38234,92 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 232: + case 233: result = reduceNodes(node.clauses, cbNodes, result); break; - case 235: + case 236: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 236: + case 237: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 237: - result = reduceNode(node.name, cbNode, result); - break; case 238: - case 242: - result = reduceNodes(node.elements, cbNodes, result); + result = reduceNode(node.name, cbNode, result); break; case 239: case 243: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 240: + case 244: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 240: + case 241: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 241: + case 242: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 246: + case 247: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 247: case 248: + case 249: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.attributes, cbNodes, result); break; - case 249: + case 250: result = reduceNode(node.tagName, cbNode, result); break; - case 250: + case 251: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 251: - result = reduceNode(node.expression, cbNode, result); - break; case 252: result = reduceNode(node.expression, cbNode, result); break; case 253: result = reduceNode(node.expression, cbNode, result); + break; case 254: + result = reduceNode(node.expression, cbNode, result); + case 255: result = reduceNodes(node.statements, cbNodes, result); break; - case 255: + case 256: result = reduceNodes(node.types, cbNodes, result); break; - case 256: + case 257: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 257: + case 258: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 258: + case 259: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 259: + case 260: result = reduceNode(node.expression, cbNode, result); break; - case 261: + case 262: result = reduceNodes(node.statements, cbNodes, result); break; - case 294: + case 295: result = reduceNode(node.expression, cbNode, result); break; default: @@ -38436,10 +38460,10 @@ var ts; return node; } switch (node.kind) { - case 203: - case 206: + case 204: + case 207: case 198: - case 222: + case 223: return node; case 142: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); @@ -38507,101 +38531,101 @@ var ts; return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); case 199: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 202: + case 203: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 204: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); case 205: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 206: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 207: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 208: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 209: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); case 210: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); case 211: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 212: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 213: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 214: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 215: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 216: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 217: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); case 218: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 219: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); case 220: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 221: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 222: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); - case 223: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 224: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 225: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); case 226: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 227: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 232: + case 233: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 235: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 236: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 237: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 238: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 239: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 240: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 241: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 242: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); case 243: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 244: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 246: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 247: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 248: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 249: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 250: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); case 251: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 252: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 253: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 254: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); case 255: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); case 256: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); case 257: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); case 258: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); case 259: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 260: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); - case 261: + case 262: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 294: + case 295: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -38689,7 +38713,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || ts.isTypeNode(node)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 199)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -38832,10 +38856,10 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_32 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name_32, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_31 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name_31, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); variable.original = original; - if (ts.isIdentifier(name_32)) { + if (ts.isIdentifier(name_31)) { ts.setEmitFlags(variable, 64); } ts.aggregateTransformFlags(variable); @@ -38981,8 +39005,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name_33 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); - return ts.createPropertyAccess(value, name_33); + var name_32 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name_32); } } function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) { @@ -39093,15 +39117,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 261: + case 262: + case 233: case 232: - case 231: - case 204: + case 205: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 227: case 226: - case 225: if (ts.hasModifier(node, 2)) { break; } @@ -39126,13 +39150,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 240: - return visitExportAssignment(node); case 241: + return visitExportAssignment(node); + case 242: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -39142,11 +39166,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 241 || - node.kind === 235 || + if (node.kind === 242 || node.kind === 236 || - (node.kind === 234 && - node.moduleReference.kind === 245)) { + node.kind === 237 || + (node.kind === 235 && + node.moduleReference.kind === 246)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -39170,7 +39194,7 @@ var ts; case 152: case 149: return visitorWorker(node); - case 203: + case 204: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -39227,18 +39251,18 @@ var ts; case 171: case 155: case 145: - case 228: + case 229: case 147: return undefined; case 150: return visitConstructor(node); - case 227: + case 228: return ts.createNotEmittedStatement(node); - case 226: + case 227: return visitClassDeclaration(node); case 197: return visitClassExpression(node); - case 255: + case 256: return visitHeritageClause(node); case 199: return visitExpressionWithTypeArguments(node); @@ -39248,7 +39272,7 @@ var ts; return visitGetAccessor(node); case 152: return visitSetAccessor(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -39267,15 +39291,15 @@ var ts; return visitNewExpression(node); case 201: return visitNonNullExpression(node); - case 229: - return visitEnumDeclaration(node); - case 205: - return visitVariableStatement(node); - case 223: - return visitVariableDeclaration(node); case 230: + return visitEnumDeclaration(node); + case 206: + return visitVariableStatement(node); + case 224: + return visitVariableDeclaration(node); + case 231: return visitModuleDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39429,7 +39453,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -39714,7 +39738,7 @@ var ts; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 226: + case 227: case 197: return ts.getFirstConstructorWithBody(node) !== undefined; case 149: @@ -39732,7 +39756,7 @@ var ts; return serializeTypeNode(node.type); case 152: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 226: + case 227: case 197: case 149: return ts.createIdentifier("Function"); @@ -39789,6 +39813,9 @@ var ts; } switch (node.kind) { case 104: + case 137: + case 94: + case 129: return ts.createVoidZero(); case 166: return serializeTypeNode(node.type); @@ -39827,29 +39854,7 @@ var ts; return serializeTypeReferenceNode(node); case 165: case 164: - { - var unionOrIntersection = node; - var serializedUnion = void 0; - for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - var serializedIndividual = serializeTypeNode(typeNode); - if (serializedIndividual.kind !== 70) { - serializedUnion = undefined; - break; - } - if (serializedIndividual.text === "Object") { - return serializedIndividual; - } - if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { - serializedUnion = undefined; - break; - } - serializedUnion = serializedIndividual; - } - if (serializedUnion) { - return serializedUnion; - } - } + return serializeUnionOrIntersectionType(node); case 160: case 168: case 169: @@ -39864,6 +39869,32 @@ var ts; } return ts.createIdentifier("Object"); } + function serializeUnionOrIntersectionType(node) { + var serializedUnion; + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (ts.isVoidExpression(serializedIndividual)) { + if (!serializedUnion) { + serializedUnion = serializedIndividual; + } + } + else if (ts.isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") { + return serializedIndividual; + } + else if (serializedUnion && !ts.isVoidExpression(serializedUnion)) { + if (!ts.isIdentifier(serializedUnion) || + !ts.isIdentifier(serializedIndividual) || + serializedUnion.text !== serializedIndividual.text) { + return ts.createIdentifier("Object"); + } + } + else { + serializedUnion = serializedIndividual; + } + } + return serializedUnion; + } function serializeTypeReferenceNode(node) { switch (resolver.getTypeReferenceSerializationKind(node.typeName, currentScope)) { case ts.TypeReferenceSerializationKind.Unknown: @@ -39898,14 +39929,14 @@ var ts; function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 70: - var name_34 = ts.getMutableClone(node); - name_34.flags &= ~8; - name_34.original = undefined; - name_34.parent = currentScope; + var name_33 = ts.getMutableClone(node); + name_33.flags &= ~8; + name_33.original = undefined; + name_33.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_34), ts.createLiteral("undefined")), name_34); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_33), ts.createLiteral("undefined")), name_33); } - return name_34; + return name_33; case 141: return serializeQualifiedNameAsExpression(node, useFallback); } @@ -40176,9 +40207,9 @@ var ts; } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_35 = node.symbol && node.symbol.name; - if (name_35) { - return currentScopeFirstDeclarationsOfName[name_35] === node; + var name_34 = node.symbol && node.symbol.name; + if (name_34) { + return currentScopeFirstDeclarationsOfName[name_34] === node; } } return false; @@ -40190,7 +40221,7 @@ var ts; ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 229) { + if (node.kind === 230) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -40250,8 +40281,8 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 231) { - ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); + if (body.kind === 232) { + saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; } @@ -40273,13 +40304,13 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 231) { + if (body.kind !== 232) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 230) { + if (moduleDeclaration.body.kind === 231) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -40299,7 +40330,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 237) { + if (node.kind === 238) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -40434,15 +40465,15 @@ var ts; if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(258); - context.enableEmitNotification(230); + context.enableSubstitution(259); + context.enableEmitNotification(231); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 230; + return ts.getOriginalNode(node).kind === 231; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 229; + return ts.getOriginalNode(node).kind === 230; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -40467,14 +40498,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_36 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_36); + var name_35 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_35); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_36, initializer, node); + return ts.createPropertyAssignment(name_35, initializer, node); } - return ts.createPropertyAssignment(name_36, exportedName, node); + return ts.createPropertyAssignment(name_35, exportedName, node); } } return node; @@ -40515,9 +40546,9 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 261) { - var substitute = (applicableSubstitutions & 2 && container.kind === 230) || - (applicableSubstitutions & 8 && container.kind === 229); + if (container && container.kind !== 262) { + var substitute = (applicableSubstitutions & 2 && container.kind === 231) || + (applicableSubstitutions & 8 && container.kind === 230); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -40632,11 +40663,11 @@ var ts; return visitObjectLiteralExpression(node); case 192: return visitBinaryExpression(node, noDestructuringValue); - case 223: + case 224: return visitVariableDeclaration(node); - case 213: + case 214: return visitForOfStatement(node); - case 211: + case 212: return visitForStatement(node); case 188: return visitVoidExpression(node); @@ -40648,7 +40679,7 @@ var ts; return visitGetAccessorDeclaration(node); case 152: return visitSetAccessorDeclaration(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -40656,7 +40687,7 @@ var ts; return visitArrowFunction(node); case 144: return visitParameter(node); - case 207: + case 208: return visitExpressionStatement(node); case 183: return visitParenthesizedExpression(node, noDestructuringValue); @@ -40669,7 +40700,7 @@ var ts; var objects = []; for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { var e = elements_3[_i]; - if (e.kind === 259) { + if (e.kind === 260) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -40681,7 +40712,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 257) { + if (e.kind === 258) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -40854,11 +40885,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 246: - return visitJsxElement(node, false); case 247: + return visitJsxElement(node, false); + case 248: return visitJsxSelfClosingElement(node, false); - case 252: + case 253: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -40868,11 +40899,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 252: + case 253: return visitJsxExpression(node); - case 246: - return visitJsxElement(node, true); case 247: + return visitJsxElement(node, true); + case 248: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -40926,7 +40957,10 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, node) : node; } - else if (node.kind === 252) { + else if (node.kind === 253) { + if (node.expression === undefined) { + return ts.createLiteral(true); + } return visitJsxExpression(node); } else { @@ -40991,16 +41025,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 246) { + if (node.kind === 247) { return getTagName(node.openingElement); } else { - var name_37 = node.tagName; - if (ts.isIdentifier(name_37) && ts.isIntrinsicJsxName(name_37.text)) { - return ts.createLiteral(name_37.text); + var name_36 = node.tagName; + if (ts.isIdentifier(name_36) && ts.isIntrinsicJsxName(name_36.text)) { + return ts.createLiteral(name_36.text); } else { - return ts.createExpressionFromEntityName(name_37); + return ts.createExpressionFromEntityName(name_36); } } } @@ -41310,7 +41344,7 @@ var ts; return visitAwaitExpression(node); case 149: return visitMethodDeclaration(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -41409,7 +41443,7 @@ var ts; context.enableSubstitution(179); context.enableSubstitution(177); context.enableSubstitution(178); - context.enableEmitNotification(226); + context.enableEmitNotification(227); context.enableEmitNotification(149); context.enableEmitNotification(151); context.enableEmitNotification(152); @@ -41465,7 +41499,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 226 + return kind === 227 || kind === 150 || kind === 149 || kind === 151 @@ -41604,15 +41638,7 @@ var ts; context.onSubstituteNode = onSubstituteNode; var currentSourceFile; var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - var isInConstructorWithCapturedSuper; + var hierarchyFacts; var convertedLoopState; var enabledSubstitutions; return transformSourceFile; @@ -41622,178 +41648,104 @@ var ts; } currentSourceFile = node; currentText = node.text; - var visited = saveStateAndInvoke(node, visitSourceFile); + var visited = visitSourceFile(node); ts.addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined; currentText = undefined; + hierarchyFacts = 0; return visited; } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); + function enterSubtree(excludeFacts, includeFacts) { + var ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383; + return ancestorFacts; } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - isInConstructorWithCapturedSuper = false; - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 185) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 131072)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - switch (currentNode.kind) { - case 205: - enclosingVariableStatement = currentNode; - break; - case 224: - case 223: - case 174: - case 172: - case 173: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function returnCapturedThis(node) { - return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 216 && !node.expression; + return hierarchyFacts & 4096 + && node.kind === 217 + && !node.expression; } - function shouldCheckNode(node) { - return (node.transformFlags & 64) !== 0 || - node.kind === 219 || - (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); + function shouldVisitNode(node) { + return (node.transformFlags & 128) !== 0 + || convertedLoopState !== undefined + || (hierarchyFacts & 4096 && ts.isStatement(node)) + || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } - function visitorWorker(node) { - if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { - return returnCapturedThis(node); - } - else if (shouldCheckNode(node)) { + function visitor(node) { + if (shouldVisitNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { - return ts.visitEachChild(node, visitor, context); - } else { return node; } } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function functionBodyVisitor(node) { + if (shouldVisitNode(node)) { + return visitBlock(node, true); } - else { - result = visitNodesInConvertedLoop(node); - } - return result; + return node; } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 216: - node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; - return visitReturnStatement(node); - case 205: - return visitVariableStatement(node); - case 218: - return visitSwitchStatement(node); - case 215: - case 214: - return visitBreakOrContinueStatement(node); - case 98: - return visitThisKeyword(node); - case 70: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); + function callExpressionVisitor(node) { + if (node.kind === 96) { + return visitSuperKeyword(true); } + return visitor(node); } function visitJavaScript(node) { switch (node.kind) { case 114: return undefined; - case 226: + case 227: return visitClassDeclaration(node); case 197: return visitClassExpression(node); case 144: return visitParameter(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 185: return visitArrowFunction(node); case 184: return visitFunctionExpression(node); - case 223: + case 224: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 224: + case 225: return visitVariableDeclarationList(node); case 219: + return visitSwitchStatement(node); + case 233: + return visitCaseBlock(node); + case 205: + return visitBlock(node, false); + case 216: + case 215: + return visitBreakOrContinueStatement(node); + case 220: return visitLabeledStatement(node); - case 209: - return visitDoStatement(node); case 210: - return visitWhileStatement(node); case 211: - return visitForStatement(node); + return visitDoOrWhileStatement(node, undefined); case 212: - return visitForInStatement(node); + return visitForStatement(node, undefined); case 213: - return visitForOfStatement(node); - case 207: + return visitForInStatement(node, undefined); + case 214: + return visitForOfStatement(node, undefined); + case 208: return visitExpressionStatement(node); case 176: return visitObjectLiteralExpression(node); - case 256: + case 257: return visitCatchClause(node); - case 258: + case 259: return visitShorthandPropertyAssignment(node); + case 142: + return visitComputedPropertyName(node); case 175: return visitArrayLiteralExpression(node); case 179: @@ -41818,51 +41770,80 @@ var ts; case 196: return visitSpreadElement(node); case 96: - return visitSuperKeyword(); - case 195: - return ts.visitEachChild(node, visitor, context); + return visitSuperKeyword(false); + case 98: + return visitThisKeyword(node); + case 202: + return visitMetaProperty(node); case 149: return visitMethodDeclaration(node); - case 205: + case 151: + case 152: + return visitAccessorDeclaration(node); + case 206: return visitVariableStatement(node); + case 217: + return visitReturnStatement(node); default: - ts.Debug.failBadSyntaxKind(node); return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { + var ancestorFacts = enterSubtree(3968, 64); var statements = []; startLexicalEnvironment(); var statementOffset = ts.addPrologueDirectives(statements, node.statements, false, visitor); addCaptureThisForNodeIfNeeded(statements, node); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); + exitSubtree(ancestorFacts, 0, 0); return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); } function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps |= 2; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; + if (convertedLoopState !== undefined) { + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps |= 2; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitCaseBlock(node) { + var ancestorFacts = enterSubtree(4032, 0); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8; + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + node = returnCapturedThis(node); + } + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 185) { - convertedLoopState.containsLexicalThis = true; - return node; + if (convertedLoopState) { + if (hierarchyFacts & 2) { + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + return node; } function visitIdentifier(node) { if (!convertedLoopState) { @@ -41878,13 +41859,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 215 ? 2 : 4; + var jump = node.kind === 216 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 215) { + if (node.kind === 216) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -41894,7 +41875,7 @@ var ts; } } else { - if (node.kind === 215) { + if (node.kind === 216) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -41993,6 +41974,9 @@ var ts; } } function addConstructor(statements, node, extendsClauseElement) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16278, 73); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); @@ -42000,6 +41984,8 @@ var ts; ts.setEmitFlags(constructorFunction, 8); } statements.push(constructorFunction); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; } function transformConstructorParameters(constructor, hasSynthesizedSuper) { return ts.visitParameterList(constructor && !hasSynthesizedSuper && constructor.parameters, visitor, context) @@ -42020,23 +42006,26 @@ var ts; addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94; + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); if (superCaptureStatus === 1 || superCaptureStatus === 2) { statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { - isInConstructorWithCapturedSuper = superCaptureStatus === 1; - return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); - }); - ts.addRange(statements, body); + if (superCaptureStatus === 1) { + hierarchyFacts |= 4096; + } + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset)); } - if (extendsClauseElement + if (isDerivedClass && superCaptureStatus !== 2 && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createIdentifier("_this"))); } ts.addRange(statements, endLexicalEnvironment()); + if (constructor) { + prependCaptureNewTargetIfNeeded(statements, constructor, false); + } var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); if (!constructor) { ts.setEmitFlags(block, 1536); @@ -42044,17 +42033,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 216) { + if (statement.kind === 217) { return true; } - else if (statement.kind === 208) { + else if (statement.kind === 209) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 204) { + else if (statement.kind === 205) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -42062,8 +42051,8 @@ var ts; } return false; } - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { - if (!hasExtendsClause) { + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, isDerivedClass, hasSynthesizedSuper, statementOffset) { + if (!isDerivedClass) { if (ctor) { addCaptureThisForNodeIfNeeded(statements, ctor); } @@ -42083,9 +42072,8 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 207 && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + if (firstStatement.kind === 208 && ts.isSuperCall(firstStatement.expression)) { + superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } if (superCallExpression @@ -42100,17 +42088,17 @@ var ts; statements.push(returnStatement); return 2; } - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); if (superCallExpression) { return 1; } return 0; } + function createActualThis() { + return ts.setEmitFlags(ts.createThis(), 4); + } function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 4); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); + return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createIdentifier("_super"), ts.createNull()), ts.createFunctionApply(ts.createIdentifier("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis()); } function visitParameter(node) { if (node.dotDotDotToken) { @@ -42135,15 +42123,15 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_38 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name_37 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_38)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_38, initializer); + if (ts.isBindingPattern(name_37)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_37, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_38, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name_37, initializer); } } } @@ -42206,21 +42194,53 @@ var ts; ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } + function prependCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { + if (hierarchyFacts & 16384) { + var newTarget = void 0; + switch (node.kind) { + case 185: + return statements; + case 149: + case 151: + case 152: + newTarget = ts.createVoidZero(); + break; + case 150: + newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); + break; + case 226: + case 184: + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 92, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + var captureNewTargetStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_newTarget", undefined, newTarget) + ])); + if (copyOnWrite) { + return [captureNewTargetStatement].concat(statements); + } + statements.unshift(captureNewTargetStatement); + } + return statements; + } function addClassMembers(statements, node) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 203: + case 204: statements.push(transformSemicolonClassElementToStatement(member)); break; case 149: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case 151: case 152: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; case 150: @@ -42234,26 +42254,29 @@ var ts; function transformSemicolonClassElementToStatement(member) { return ts.createEmptyStatement(member); } - function transformClassMethodDeclarationToStatement(receiver, member) { + function transformClassMethodDeclarationToStatement(receiver, member, container) { + var ancestorFacts = enterSubtree(0, 0); var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name); - var memberFunction = transformFunctionLikeToExpression(member, member, undefined); + var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container); ts.setEmitFlags(memberFunction, 1536); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); ts.setEmitFlags(statement, 48); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return statement; } - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), ts.getSourceMapRange(accessors.firstAccessor)); + function transformAccessorsToStatement(receiver, accessors, container) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, false), ts.getSourceMapRange(accessors.firstAccessor)); ts.setEmitFlags(statement, 1536); return statement; } - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var ancestorFacts = enterSubtree(0, 0); var target = ts.getMutableClone(receiver); ts.setEmitFlags(target, 1536 | 32); ts.setSourceMapRange(target, firstAccessor.name); @@ -42262,7 +42285,7 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); + var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); ts.setEmitFlags(getterFunction, 512); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -42270,7 +42293,7 @@ var ts; properties.push(getter); } if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); + var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); ts.setEmitFlags(setterFunction, 512); var setter = ts.createPropertyAssignment("set", setterFunction); @@ -42286,35 +42309,69 @@ var ts; if (startsOnNewLine) { call.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return call; } function visitArrowFunction(node) { if (node.transformFlags & 16384) { enableSubstitutionsForCapturedThis(); } + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16256, 66); var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8); + exitSubtree(ancestorFacts, 0, 0); + convertedLoopState = savedConvertedLoopState; return func; } function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var ancestorFacts = ts.getEmitFlags(node) & 131072 + ? enterSubtree(16278, 69) + : enterSubtree(16286, 65); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionExpression(node, undefined, name, undefined, parameters, undefined, body); } function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, parameters, undefined, body); } - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 185) { - enclosingNonArrowFunction = node; + function transformFunctionLikeToExpression(node, location, name, container) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32) + ? enterSubtree(16286, 65 | 8) + : enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (hierarchyFacts & 16384 && !name && (node.kind === 226 || node.kind === 184)) { + name = ts.getGeneratedNameForNode(node); } - var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body, location), node); } function transformFunctionBody(node) { var multiLine = false; @@ -42361,6 +42418,7 @@ var ts; } var lexicalEnvironment = context.endLexicalEnvironment(); ts.addRange(statements, lexicalEnvironment); + prependCaptureNewTargetIfNeeded(statements, node, false); if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; } @@ -42374,6 +42432,21 @@ var ts; ts.setOriginalNode(block, node.body); return block; } + function visitFunctionBodyDownLevel(node) { + var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); + return ts.updateBlock(updated, ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, true), updated.statements)); + } + function visitBlock(node, isFunctionBody) { + if (isFunctionBody) { + return ts.visitEachChild(node, visitor, context); + } + var ancestorFacts = hierarchyFacts & 256 + ? enterSubtree(4032, 512) + : enterSubtree(3904, 128); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } function visitExpressionStatement(node) { switch (node.expression.kind) { case 183: @@ -42398,9 +42471,12 @@ var ts; if (ts.isDestructuringAssignment(node)) { return ts.flattenDestructuringAssignment(node, visitor, context, 0, needsDestructuringValue); } + return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3) == 0) { + var ancestorFacts = enterSubtree(0, ts.hasModifier(node, 1) ? 32 : 0); + var updated; + if (convertedLoopState && (node.declarationList.flags & 3) === 0) { var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; @@ -42417,49 +42493,54 @@ var ts; } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); + updated = ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); } else { - return undefined; + updated = undefined; } } - return ts.visitEachChild(node, visitor, context); + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function visitVariableDeclarationList(node) { - if (node.flags & 3) { - enableSubstitutionsForBlockScopedBindings(); + if (node.transformFlags & 64) { + if (node.flags & 3) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations, node); + ts.setOriginalNode(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; + return ts.visitEachChild(node, visitor, context); } function shouldEmitExplicitInitializerForLetDeclaration(node) { var flags = resolver.getNodeCheckFlags(node); var isCapturedInFunction = flags & 131072; var isDeclaredInLoop = flags & 262144; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + var emittedAsTopLevel = (hierarchyFacts & 64) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); + && (hierarchyFacts & 512) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 212 - && enclosingBlockScopeContainer.kind !== 213 + && (hierarchyFacts & 2048) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, false))); + && (hierarchyFacts & (1024 | 2048)) === 0)); return emitExplicitInitializer; } function visitVariableDeclarationInLetDeclarationList(node) { @@ -42475,48 +42556,51 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableDeclaration(node) { + var ancestorFacts = enterSubtree(32, 0); + var updated; if (ts.isBindingPattern(node.name)) { - var hoistTempVariables = enclosingVariableStatement - && ts.hasModifier(enclosingVariableStatement, 1); - return ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, hoistTempVariables); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, (ancestorFacts & 32) !== 0); } else { - result = ts.visitEachChild(node, visitor, context); + updated = ts.visitEachChild(node, visitor, context); } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function recordLabel(node) { + convertedLoopState.labels[node.label.text] = node.label.text; + } + function resetLabel(node) { + convertedLoopState.labels[node.label.text] = undefined; + } + function visitLabeledStatement(node) { + if (convertedLoopState && !convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); } - return result; + var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, false) && shouldConvertIterationStatementBody(statement) + ? visitIterationStatement(statement, node) + : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { + var ancestorFacts = enterSubtree(excludeFacts, includeFacts); + var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); + exitSubtree(ancestorFacts, 0, 0); + return updated; } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitDoOrWhileStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(0, 256, node, outermostLabeledStatement); } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(3008, 1280, node, outermostLabeledStatement); } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForInStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement); } - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function visitForOfStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement, convertForOfToFor); } - function convertForOfToFor(node, convertedLoopBodyStatements) { + function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var initializer = node.initializer; var statements = []; @@ -42579,31 +42663,53 @@ var ts; ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) ], node.expression), 1048576), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); ts.setEmitFlags(forStatement, 256); - return forStatement; + return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); + } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 210: + case 211: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 212: + return visitForStatement(node, outermostLabeledStatement); + case 213: + return visitForInStatement(node, outermostLabeledStatement); + case 214: + return visitForOfStatement(node, outermostLabeledStatement); + } } function visitObjectLiteralExpression(node) { var properties = node.properties; var numProperties = properties.length; var numInitialProperties = numProperties; + var numInitialPropertiesWithoutYield = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 - || property.name.kind === 142) { + if ((property.transformFlags & 16777216 && hierarchyFacts & 4) + && i < numInitialPropertiesWithoutYield) { + numInitialPropertiesWithoutYield = i; + } + if (property.name.kind === 142) { numInitialProperties = i; break; } } - ts.Debug.assert(numInitialProperties !== numProperties); - var temp = ts.createTempVariable(hoistVariableDeclaration); - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); - if (node.multiLine) { - assignment.startsOnNewLine = true; + if (numInitialProperties !== numProperties) { + if (numInitialPropertiesWithoutYield < numInitialProperties) { + numInitialProperties = numInitialPropertiesWithoutYield; + } + var temp = ts.createTempVariable(hoistVariableDeclaration); + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); + return ts.visitEachChild(node, visitor, context); } function shouldConvertIterationStatementBody(node) { return (resolver.getNodeCheckFlags(node) & 65536) !== 0; @@ -42627,14 +42733,16 @@ var ts; } } } - function convertIterationStatementBodyIfNecessary(node, convert) { + function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) { if (!shouldConvertIterationStatementBody(node)) { var saveAllowedNonLabeledJumps = void 0; if (convertedLoopState) { saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; convertedLoopState.allowedNonLabeledJumps = 2 | 4; } - var result = convert ? convert(node, undefined) : ts.visitEachChild(node, visitor, context); + var result = convert + ? convert(node, outermostLabeledStatement, undefined) + : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); if (convertedLoopState) { convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } @@ -42643,11 +42751,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 211: case 212: case 213: + case 214: var initializer = node.initializer; - if (initializer && initializer.kind === 224) { + if (initializer && initializer.kind === 225) { loopInitializer = initializer; } break; @@ -42674,7 +42782,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -42686,11 +42794,13 @@ var ts; ts.addRange(statements_4, lexicalEnvironment); loopBody = ts.createBlock(statements_4, undefined, true); } - if (!ts.isBlock(loopBody)) { + if (ts.isBlock(loopBody)) { + loopBody.multiLine = true; + } + else { loopBody = ts.createBlock([loopBody], undefined, true); } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 131072) !== 0 + var isAsyncBlockContainingAwait = hierarchyFacts & 4 && (node.statement.transformFlags & 16777216) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -42749,19 +42859,18 @@ var ts; var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); var loop; if (convert) { - loop = convert(node, convertedLoopBodyStatements); + loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); } else { - loop = ts.getMutableClone(node); - loop.statement = undefined; - loop = ts.visitEachChild(loop, visitor, context); - loop.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); + var clone_4 = ts.getMutableClone(node); + clone_4.statement = undefined; + clone_4 = ts.visitEachChild(clone_4, visitor, context); + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); + clone_4.transformFlags = 0; + ts.aggregateTransformFlags(clone_4); + loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } - statements.push(currentParent.kind === 219 - ? ts.createLabel(currentParent.label, loop) - : loop); + statements.push(loop); return statements; } function copyOutParameter(outParam, copyDirection) { @@ -42875,17 +42984,17 @@ var ts; case 152: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 257: - expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); + case 149: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; case 258: - expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); + expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 149: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); + case 259: + expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: ts.Debug.failBadSyntaxKind(node); @@ -42907,21 +43016,31 @@ var ts; } return expression; } - function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined), method); + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { + var ancestorFacts = enterSubtree(0, 0); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container), method); if (startsOnNewLine) { expression.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return expression; } function visitCatchClause(node) { - ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); - var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); - var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); - var destructure = ts.createVariableStatement(undefined, list); - return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + var ancestorFacts = enterSubtree(4032, 0); + var updated; + if (ts.isBindingPattern(node.variableDeclaration.name)) { + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); + var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); + var destructure = ts.createVariableStatement(undefined, list); + updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); @@ -42929,21 +43048,43 @@ var ts; } function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); + var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined); ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression)); return ts.createPropertyAssignment(node.name, functionExpression, node); } + function visitAccessorDeclaration(node) { + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return updated; + } function visitShorthandPropertyAssignment(node) { return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), node); } + function visitComputedPropertyName(node) { + var ancestorFacts = enterSubtree(0, 8192); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 32768 : 0); + return updated; + } function visitYieldExpression(node) { return ts.visitEachChild(node, visitor, context); } function visitArrayLiteralExpression(node) { - return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + if (node.transformFlags & 64) { + return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + } + return ts.visitEachChild(node, visitor, context); } function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + if (node.transformFlags & 64) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + } + return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitImmediateSuperCallInBody(node) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); @@ -42955,25 +43096,27 @@ var ts; } var resultingCall; if (node.transformFlags & 524288) { - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } if (node.expression.kind === 96) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4); var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis + resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createIdentifier("_this"), initializer) : initializer; } - return resultingCall; + return ts.setOriginalNode(resultingCall, node); } function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 524288) !== 0); - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + if (node.transformFlags & 524288) { + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + } + return ts.visitEachChild(node, visitor, context); } function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { var numElements = elements.length; @@ -43071,21 +43214,34 @@ var ts; } } } - function visitSuperKeyword() { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 179 + function visitSuperKeyword(isExpressionOfCall) { + return hierarchyFacts & 8 + && !isExpressionOfCall ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } + function visitMetaProperty(node) { + if (node.keywordToken === 93 && node.name.text === "target") { + if (hierarchyFacts & 8192) { + hierarchyFacts |= 32768; + } + else { + hierarchyFacts |= 16384; + } + return ts.createIdentifier("_newTarget"); + } + return node; + } function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { - enclosingFunction = node; + var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8 + ? 65 | 16 + : 65); + previousOnEmitNode(emitContext, node, emitCallback); + exitSubtree(ancestorFacts, 0, 0); + return; } previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; } function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { @@ -43103,7 +43259,7 @@ var ts; context.enableEmitNotification(152); context.enableEmitNotification(185); context.enableEmitNotification(184); - context.enableEmitNotification(225); + context.enableEmitNotification(226); } } function onSubstituteNode(emitContext, node) { @@ -43129,9 +43285,9 @@ var ts; var parent = node.parent; switch (parent.kind) { case 174: - case 226: - case 229: - case 223: + case 227: + case 230: + case 224: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -43157,8 +43313,7 @@ var ts; } function substituteThisKeyword(node) { if (enabledSubstitutions & 1 - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 8) { + && hierarchyFacts & 16) { return ts.createIdentifier("_this", node); } return node; @@ -43175,7 +43330,7 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 207) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 208) { return false; } var statementExpression = statement.expression; @@ -43206,7 +43361,7 @@ var ts; name: "typescript:extends", scoped: false, priority: 0, - text: "\n var __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 };" + text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; })(ts || (ts = {})); var ts; @@ -43283,13 +43438,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 209: - return visitDoStatement(node); case 210: + return visitDoStatement(node); + case 211: return visitWhileStatement(node); - case 218: - return visitSwitchStatement(node); case 219: + return visitSwitchStatement(node); + case 220: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -43297,24 +43452,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); case 151: case 152: return visitAccessorDeclaration(node); - case 205: + case 206: return visitVariableStatement(node); - case 211: - return visitForStatement(node); case 212: + return visitForStatement(node); + case 213: return visitForInStatement(node); - case 215: - return visitBreakStatement(node); - case 214: - return visitContinueStatement(node); case 216: + return visitBreakStatement(node); + case 215: + return visitContinueStatement(node); + case 217: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -43352,7 +43507,7 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -43539,10 +43694,10 @@ var ts; else if (node.operatorToken.kind === 25) { return visitCommaExpression(node); } - var clone_4 = ts.getMutableClone(node); - clone_4.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_4.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_4; + var clone_5 = ts.getMutableClone(node); + clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_5; } return ts.visitEachChild(node, visitor, context); } @@ -43604,7 +43759,7 @@ var ts; emitYield(expression, node); } markLabel(resumeLabel); - return createGeneratorResume(); + return createGeneratorResume(node); } function visitArrayLiteralExpression(node) { return visitElements(node.elements, undefined, undefined, node.multiLine); @@ -43664,10 +43819,10 @@ var ts; } function visitElementAccessExpression(node) { if (containsYield(node.argumentExpression)) { - var clone_5 = ts.getMutableClone(node); - clone_5.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_5.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -43710,35 +43865,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 204: + case 205: return transformAndEmitBlock(node); - case 207: - return transformAndEmitExpressionStatement(node); case 208: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 209: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 210: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 211: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 212: + return transformAndEmitForStatement(node); + case 213: return transformAndEmitForInStatement(node); - case 214: - return transformAndEmitContinueStatement(node); case 215: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 216: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 217: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 218: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 219: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 220: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 221: + return transformAndEmitThrowStatement(node); + case 222: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -43758,7 +43913,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - hoistVariableDeclaration(variable.name); + var name_38 = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name_38, variable.name); + hoistVariableDeclaration(name_38); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -43788,7 +43945,7 @@ var ts; if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) { var endLabel = defineLabel(); var elseLabel = node.elseStatement ? defineLabel() : undefined; - emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression)); + emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), node.expression); transformAndEmitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { emitBreak(endLabel); @@ -44022,7 +44179,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 254 && defaultClauseIndex === -1) { + if (clause.kind === 255 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -44032,7 +44189,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 253) { + if (clause.kind === 254) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -44155,10 +44312,10 @@ var ts; if (declaration) { var name_39 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); if (name_39) { - var clone_6 = ts.getMutableClone(name_39); - ts.setSourceMapRange(clone_6, node); - ts.setCommentRange(clone_6, node); - return clone_6; + var clone_7 = ts.getMutableClone(name_39); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); + return clone_7; } } } @@ -44768,41 +44925,41 @@ var ts; function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), operationLocation)); + : [createInstruction(2)]), operationLocation), 384)); } function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation)); + ]), operationLocation), 384)); } function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384)), 1)); } function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384)), 1)); } function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4), expression] - : [createInstruction(4)]), operationLocation)); + : [createInstruction(4)]), operationLocation), 384)); } function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(5), expression - ]), operationLocation)); + ]), operationLocation), 384)); } function writeEndfinally() { lastOperationWasAbrupt = true; @@ -44827,15 +44984,40 @@ var ts; var ts; (function (ts) { function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(249); + context.enableEmitNotification(250); + context.enableEmitNotification(248); + noSubstitution = []; + } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; context.enableSubstitution(177); - context.enableSubstitution(257); + context.enableSubstitution(258); return transformSourceFile; function transformSourceFile(node) { return node; } + function onEmitNode(emitContext, node, emitCallback) { + switch (node.kind) { + case 249: + case 250: + case 248: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(emitContext, node, emitCallback); + } function onSubstituteNode(emitContext, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(emitContext, node); + } node = previousOnSubstituteNode(emitContext, node); if (ts.isPropertyAccessExpression(node)) { return substitutePropertyAccessExpression(node); @@ -44892,8 +45074,8 @@ var ts; context.enableSubstitution(192); context.enableSubstitution(190); context.enableSubstitution(191); - context.enableSubstitution(258); - context.enableEmitNotification(261); + context.enableSubstitution(259); + context.enableEmitNotification(262); var moduleInfoMap = ts.createMap(); var deferredExports = ts.createMap(); var currentSourceFile; @@ -44931,14 +45113,7 @@ var ts; function transformAMDModule(node) { var define = ts.createIdentifier("define"); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, true); - } - function transformUMDModule(node) { - var define = ts.createRawExpression(umdHelper); - return transformAsynchronousModule(node, define, undefined, false); - } - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; return ts.updateSourceFileNode(node, ts.createNodeArray([ ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ @@ -44952,6 +45127,36 @@ var ts; ]))) ], node.statements)); } + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement(undefined, [ + ts.createVariableDeclaration("v", undefined, ts.createCall(ts.createIdentifier("factory"), undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], undefined, true)); + return ts.updateSourceFileNode(node, ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(undefined, undefined, undefined, "require"), + ts.createParameter(undefined, undefined, undefined, "exports") + ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ])) + ], node.statements)); + } function collectAsynchronousDependencies(node, includeNonAmdDependencies) { var aliasedModuleNames = []; var unaliasedModuleNames = []; @@ -45011,23 +45216,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 241: + case 242: return visitExportDeclaration(node); - case 240: + case 241: return visitExportAssignment(node); - case 205: + case 206: return visitVariableStatement(node); - case 225: - return visitFunctionDeclaration(node); case 226: + return visitFunctionDeclaration(node); + case 227: return visitClassDeclaration(node); - case 295: - return visitMergeDeclarationMarker(node); case 296: + return visitMergeDeclarationMarker(node); + case 297: return visitEndOfDeclarationMarker(node); default: return node; @@ -45225,7 +45430,7 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -45257,10 +45462,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237: + case 238: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238: + case 239: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -45368,7 +45573,7 @@ var ts; return node; } function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { + if (node.kind === 262) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = ts.createMap(); @@ -45428,7 +45633,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 261) { + if (exportContainer && exportContainer.kind === 262) { return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -45502,7 +45707,6 @@ var ts; scoped: true, text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" }; - var umdHelper = "\n (function (dependencies, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(dependencies, factory);\n }\n })"; })(ts || (ts = {})); var ts; (function (ts) { @@ -45519,7 +45723,7 @@ var ts; context.enableSubstitution(192); context.enableSubstitution(190); context.enableSubstitution(191); - context.enableEmitNotification(261); + context.enableEmitNotification(262); var moduleInfoMap = ts.createMap(); var deferredExports = ts.createMap(); var exportFunctionsMap = ts.createMap(); @@ -45619,7 +45823,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 241 && externalImport.exportClause) { + if (externalImport.kind === 242 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -45642,7 +45846,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 241) { + if (externalImport.kind !== 242) { continue; } var exportDecl = externalImport; @@ -45694,15 +45898,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 235: + case 236: if (!entry.importClause) { break; } - case 234: + case 235: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 241: + case 242: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -45724,13 +45928,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 241: + case 242: return undefined; - case 240: + case 241: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -45851,7 +46055,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 1048576) === 0 - && (enclosingBlockScopedContainer.kind === 261 + && (enclosingBlockScopedContainer.kind === 262 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -45873,7 +46077,7 @@ var ts; : preventSubstitution(ts.createAssignment(name, value, location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -45906,10 +46110,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237: + case 238: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238: + case 239: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -46008,43 +46212,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 205: + case 206: return visitVariableStatement(node); - case 225: - return visitFunctionDeclaration(node); case 226: + return visitFunctionDeclaration(node); + case 227: return visitClassDeclaration(node); - case 211: - return visitForStatement(node); case 212: - return visitForInStatement(node); + return visitForStatement(node); case 213: + return visitForInStatement(node); + case 214: return visitForOfStatement(node); - case 209: - return visitDoStatement(node); case 210: + return visitDoStatement(node); + case 211: return visitWhileStatement(node); - case 219: + case 220: return visitLabeledStatement(node); - case 217: - return visitWithStatement(node); case 218: + return visitWithStatement(node); + case 219: return visitSwitchStatement(node); - case 232: + case 233: return visitCaseBlock(node); - case 253: - return visitCaseClause(node); case 254: + return visitCaseClause(node); + case 255: return visitDefaultClause(node); - case 221: + case 222: return visitTryStatement(node); - case 256: + case 257: return visitCatchClause(node); - case 204: + case 205: return visitBlock(node); - case 295: - return visitMergeDeclarationMarker(node); case 296: + return visitMergeDeclarationMarker(node); + case 297: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -46172,7 +46376,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 261; + return container !== undefined && container.kind === 262; } else { return false; @@ -46187,7 +46391,7 @@ var ts; return node; } function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { + if (node.kind === 262) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -46299,7 +46503,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 261) { + if (exportContainer && exportContainer.kind === 262) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -46327,7 +46531,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(261); + context.enableEmitNotification(262); context.enableSubstitution(70); var currentSourceFile; return transformSourceFile; @@ -46352,9 +46556,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 234: + case 235: return undefined; - case 240: + case 241: return visitExportAssignment(node); } return node; @@ -46663,7 +46867,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 235); + ts.Debug.assert(aliasEmitInfo.node.kind === 236); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -46735,10 +46939,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 223) { + if (declaration.kind === 224) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 238 || declaration.kind === 239 || declaration.kind === 236) { + else if (declaration.kind === 239 || declaration.kind === 240 || declaration.kind === 237) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -46749,7 +46953,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 235) { + if (moduleElementEmitInfo.node.kind === 236) { moduleElementEmitInfo.isVisible = true; } else { @@ -46757,12 +46961,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 231) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 231) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -46933,7 +47137,7 @@ var ts; } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 234 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 235 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); @@ -47096,10 +47300,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 234 || - (node.parent.kind === 261 && isCurrentFileExternalModule)) { + else if (node.kind === 235 || + (node.parent.kind === 262 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 262) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -47108,7 +47312,7 @@ var ts; }); } else { - if (node.kind === 235) { + if (node.kind === 236) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -47126,30 +47330,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 225: - return writeFunctionDeclaration(node); - case 205: - return writeVariableStatement(node); - case 227: - return writeInterfaceDeclaration(node); case 226: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 206: + return writeVariableStatement(node); case 228: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 227: + return writeClassDeclaration(node); case 229: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 230: + return writeEnumDeclaration(node); + case 231: return writeModuleDeclaration(node); - case 234: - return writeImportEqualsDeclaration(node); case 235: + return writeImportEqualsDeclaration(node); + case 236: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 261) { + if (node.parent.kind === 262) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -47157,7 +47361,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 227 && !noDeclare) { + else if (node.kind !== 228 && !noDeclare) { write("declare "); } } @@ -47207,7 +47411,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 237) { + if (namedBindings.kind === 238) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -47230,7 +47434,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 237) { + if (node.importClause.namedBindings.kind === 238) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -47247,13 +47451,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 231; var moduleSpecifier; - if (parent.kind === 234) { + if (parent.kind === 235) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 230) { + else if (parent.kind === 231) { moduleSpecifier = parent.name; } else { @@ -47321,7 +47525,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 231) { + while (node.body && node.body.kind !== 232) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -47419,10 +47623,10 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 226: + case 227: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 227: + case 228: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 154: @@ -47436,17 +47640,17 @@ var ts; if (ts.hasModifier(node.parent, 32)) { 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 === 226) { + else if (node.parent.parent.kind === 227) { 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 225: + case 226: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 228: + case 229: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -47483,7 +47687,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 226) { + if (node.parent.parent.kind === 227) { 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; @@ -47566,7 +47770,7 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 223 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 224 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -47589,7 +47793,7 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 223) { + if (node.kind === 224) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47604,7 +47808,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 === 226) { + else if (node.parent.kind === 227) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47764,13 +47968,13 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 225) { + if (node.kind === 226) { emitModuleElementDeclarationFlags(node); } else if (node.kind === 149 || node.kind === 150) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 225) { + if (node.kind === 226) { write("function "); writeTextOfNode(currentText, node.name); } @@ -47864,7 +48068,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 === 226) { + else if (node.parent.kind === 227) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -47877,7 +48081,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 225: + case 226: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -47954,7 +48158,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 === 226) { + else if (node.parent.parent.kind === 227) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -47966,7 +48170,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 225: + case 226: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -48018,19 +48222,19 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 225: - case 230: - case 234: - case 227: case 226: - case 228: - case 229: - return emitModuleElement(node, isModuleElementVisible(node)); - case 205: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 231: case 235: + case 228: + case 227: + case 229: + case 230: + return emitModuleElement(node, isModuleElementVisible(node)); + case 206: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 236: return emitModuleElement(node, !node.importClause); - case 241: + case 242: return emitExportDeclaration(node); case 150: case 149: @@ -48046,11 +48250,11 @@ var ts; case 147: case 146: return emitPropertyDeclaration(node); - case 260: - return emitEnumMemberDeclaration(node); - case 240: - return emitExportAssignment(node); case 261: + return emitEnumMemberDeclaration(node); + case 241: + return emitExportAssignment(node); + case 262: return emitSourceFile(node); } } @@ -48267,7 +48471,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 293 + if (node.kind !== 294 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -48280,7 +48484,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 293 + if (node.kind !== 294 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -48424,7 +48628,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 293; + var isEmittedNode = node.kind !== 294; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0; if (!skipLeadingComments) { @@ -48438,7 +48642,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 224) { + if (node.kind === 225) { declarationListContainerEnd = end; } } @@ -48794,7 +48998,7 @@ var ts; function pipelineEmitInSourceFileContext(node) { var kind = node.kind; switch (kind) { - case 261: + case 262: return emitSourceFile(node); } } @@ -48917,119 +49121,119 @@ var ts; return emitArrayBindingPattern(node); case 174: return emitBindingElement(node); - case 202: - return emitTemplateSpan(node); case 203: - return emitSemicolonClassElement(); + return emitTemplateSpan(node); case 204: - return emitBlock(node); + return emitSemicolonClassElement(); case 205: - return emitVariableStatement(node); + return emitBlock(node); case 206: - return emitEmptyStatement(); + return emitVariableStatement(node); case 207: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 208: - return emitIfStatement(node); + return emitExpressionStatement(node); case 209: - return emitDoStatement(node); + return emitIfStatement(node); case 210: - return emitWhileStatement(node); + return emitDoStatement(node); case 211: - return emitForStatement(node); + return emitWhileStatement(node); case 212: - return emitForInStatement(node); + return emitForStatement(node); case 213: - return emitForOfStatement(node); + return emitForInStatement(node); case 214: - return emitContinueStatement(node); + return emitForOfStatement(node); case 215: - return emitBreakStatement(node); + return emitContinueStatement(node); case 216: - return emitReturnStatement(node); + return emitBreakStatement(node); case 217: - return emitWithStatement(node); + return emitReturnStatement(node); case 218: - return emitSwitchStatement(node); + return emitWithStatement(node); case 219: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 220: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 221: - return emitTryStatement(node); + return emitThrowStatement(node); case 222: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 223: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 224: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 225: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 226: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 227: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 228: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 229: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 230: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 231: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 232: + return emitModuleBlock(node); + case 233: return emitCaseBlock(node); - case 234: - return emitImportEqualsDeclaration(node); case 235: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 236: - return emitImportClause(node); + return emitImportDeclaration(node); case 237: - return emitNamespaceImport(node); + return emitImportClause(node); case 238: - return emitNamedImports(node); + return emitNamespaceImport(node); case 239: - return emitImportSpecifier(node); + return emitNamedImports(node); case 240: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 241: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 242: - return emitNamedExports(node); + return emitExportDeclaration(node); case 243: - return emitExportSpecifier(node); + return emitNamedExports(node); case 244: - return; + return emitExportSpecifier(node); case 245: + return; + case 246: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 248: - return emitJsxOpeningElement(node); case 249: - return emitJsxClosingElement(node); + return emitJsxOpeningElement(node); case 250: - return emitJsxAttribute(node); + return emitJsxClosingElement(node); case 251: - return emitJsxSpreadAttribute(node); + return emitJsxAttribute(node); case 252: - return emitJsxExpression(node); + return emitJsxSpreadAttribute(node); case 253: - return emitCaseClause(node); + return emitJsxExpression(node); case 254: - return emitDefaultClause(node); + return emitCaseClause(node); case 255: - return emitHeritageClause(node); + return emitDefaultClause(node); case 256: - return emitCatchClause(node); + return emitHeritageClause(node); case 257: - return emitPropertyAssignment(node); + return emitCatchClause(node); case 258: - return emitShorthandPropertyAssignment(node); + return emitPropertyAssignment(node); case 259: - return emitSpreadAssignment(node); + return emitShorthandPropertyAssignment(node); case 260: + return emitSpreadAssignment(node); + case 261: return emitEnumMember(node); } if (ts.isExpression(node)) { @@ -49106,14 +49310,14 @@ var ts; return emitAsExpression(node); case 201: return emitNonNullExpression(node); - case 246: - return emitJsxElement(node); + case 202: + return emitMetaProperty(node); case 247: + return emitJsxElement(node); + case 248: return emitJsxSelfClosingElement(node); - case 294: + case 295: return emitPartiallyEmittedExpression(node); - case 297: - return writeLines(node.text); } } function emitNumericLiteral(node) { @@ -49558,6 +49762,11 @@ var ts; emitExpression(node.expression); write("!"); } + function emitMetaProperty(node) { + writeToken(node.keywordToken, node.pos); + write("."); + emit(node.name); + } function emitTemplateSpan(node) { emitExpression(node.expression); emit(node.literal); @@ -49600,27 +49809,27 @@ var ts; writeToken(18, openParenPos, node); emitExpression(node.expression); writeToken(19, node.expression.end, node); - emitEmbeddedStatement(node.thenStatement); + emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { - writeLine(); + writeLineOrSpace(node); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 208) { + if (node.elseStatement.kind === 209) { write(" "); emit(node.elseStatement); } else { - emitEmbeddedStatement(node.elseStatement); + emitEmbeddedStatement(node, node.elseStatement); } } } function emitDoStatement(node) { write("do"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { write(" "); } else { - writeLine(); + writeLineOrSpace(node); } write("while ("); emitExpression(node.expression); @@ -49630,7 +49839,7 @@ var ts; write("while ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49642,7 +49851,7 @@ var ts; write(";"); emitExpressionWithPrefix(" ", node.incrementor); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49652,7 +49861,7 @@ var ts; write(" in "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49662,11 +49871,11 @@ var ts; write(" of "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 224) { + if (node.kind === 225) { emit(node); } else { @@ -49693,7 +49902,7 @@ var ts; write("with ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { var openParenPos = writeToken(97, node.pos); @@ -49717,9 +49926,12 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchClause); + if (node.catchClause) { + writeLineOrSpace(node); + emit(node.catchClause); + } if (node.finallyBlock) { - writeLine(); + writeLineOrSpace(node); write("finally "); emit(node.finallyBlock); } @@ -49895,7 +50107,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 230) { + while (body.kind === 231) { write("."); emit(body.name); body = body.body; @@ -50046,6 +50258,9 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); + if (node.dotDotDotToken) { + write("..."); + } emitExpression(node.expression); write("}"); } @@ -50245,8 +50460,8 @@ var ts; write(suffix); } } - function emitEmbeddedStatement(node) { - if (ts.isBlock(node)) { + function emitEmbeddedStatement(parent, node) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1) { write(" "); emit(node); } @@ -50375,6 +50590,14 @@ var ts; write(getClosingBracket(format)); } } + function writeLineOrSpace(node) { + if (ts.getEmitFlags(node) & 1) { + write(" "); + } + else { + writeLine(); + } + } function writeIfAny(nodes, text) { if (nodes && nodes.length > 0) { write(text); @@ -50603,22 +50826,32 @@ var ts; function generateNameForClassExpression() { return makeUniqueName("class"); } + function generateNameForMethodOrAccessor(node) { + if (ts.isIdentifier(node.name)) { + return generateNameForNodeCached(node.name); + } + return makeTempVariableName(0); + } function generateNameForNode(node) { switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); + case 231: case 230: - case 229: return generateNameForModuleOrEnum(node); - case 235: - case 241: + case 236: + case 242: return generateNameForImportOrExportDeclaration(node); - case 225: case 226: - case 240: + case 227: + case 241: return generateNameForExportDefault(); case 197: return generateNameForClassExpression(); + case 149: + case 151: + case 152: + return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); } @@ -50649,11 +50882,14 @@ var ts; } return node; } + function generateNameForNodeCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + } function getGeneratedIdentifier(name) { if (name.autoGenerateKind === 4) { var node = getNodeForGeneratedName(name); - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + return generateNameForNodeCached(node); } else { var autoGenerateId = name.autoGenerateId; @@ -50722,7 +50958,8 @@ var ts; commonPathComponents = sourcePathComponents; return; } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + var n = Math.min(commonPathComponents.length, sourcePathComponents.length); + for (var i = 0; i < n; i++) { if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { if (i === 0) { return true; @@ -50933,6 +51170,7 @@ var ts; var currentDirectory = host.getCurrentDirectory(); var supportedExtensions = ts.getSupportedExtensions(options); var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); + var moduleResolutionCache; var resolveModuleNamesWorker; if (host.resolveModuleNames) { resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { @@ -50945,7 +51183,8 @@ var ts; }); }; } else { - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -50981,6 +51220,7 @@ var ts; } } } + moduleResolutionCache = undefined; oldProgram = undefined; program = { getRootFileNames: function () { return rootNames; }, @@ -51187,7 +51427,7 @@ var ts; newSourceFile.resolvedModules = oldSourceFile.resolvedModules; newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } - for (var i = 0, len = newSourceFiles.length; i < len; i++) { + for (var i = 0; i < newSourceFiles.length; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; @@ -51345,42 +51585,42 @@ var ts; case 151: case 152: case 184: - case 225: + case 226: case 185: - case 225: - case 223: + case 226: + case 224: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 234: + case 235: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 240: + case 241: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 255: + case 256: var heritageClause = node; if (heritageClause.token === 107) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 227: + case 228: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 230: + case 231: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 228: + case 229: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 229: + case 230: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; case 182: @@ -51398,23 +51638,23 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 226: + case 227: case 149: case 148: case 150: case 151: case 152: case 184: - case 225: + case 226: case 185: - case 225: + case 226: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 205: + case 206: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 205); + return checkModifiers(nodes, parent.kind === 206); } break; case 147: @@ -51526,7 +51766,7 @@ var ts; && !file.isDeclarationFile) { var externalHelpersModuleReference = ts.createSynthesizedNode(9); externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(235); + var importDecl = ts.createSynthesizedNode(236); importDecl.parent = file; externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; @@ -51544,9 +51784,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 236: case 235: - case 234: - case 241: + case 242: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -51558,7 +51798,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 230: + case 231: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -52182,32 +52422,32 @@ var ts; function getMeaningFromDeclaration(node) { switch (node.kind) { case 144: - case 223: + case 224: case 174: case 147: case 146: - case 257: case 258: - case 260: + case 259: + case 261: case 149: case 148: case 150: case 151: case 152: - case 225: + case 226: case 184: case 185: - case 256: + case 257: return 1; case 143: - case 227: case 228: + case 229: case 161: return 2; - case 226: - case 229: - return 1 | 2; + case 227: case 230: + return 1 | 2; + case 231: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -52217,21 +52457,21 @@ var ts; else { return 4; } - case 238: case 239: - case 234: - case 235: case 240: + case 235: + case 236: case 241: + case 242: return 1 | 2 | 4; - case 261: + case 262: return 4 | 1; } return 1 | 2 | 4; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 240) { + if (node.parent.kind === 241) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -52255,7 +52495,7 @@ var ts; ts.Debug.assert(node.kind === 70); if (node.parent.kind === 141 && node.parent.right === node && - node.parent.parent.kind === 234) { + node.parent.parent.kind === 235) { return 1 | 2 | 4; } return 4; @@ -52289,10 +52529,10 @@ var ts; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 199 && root.parent.parent.kind === 255) { + if (!isLastClause && root.parent.kind === 199 && root.parent.parent.kind === 256) { var decl = root.parent.parent.parent; - return (decl.kind === 226 && root.parent.parent.token === 107) || - (decl.kind === 227 && root.parent.parent.token === 84); + return (decl.kind === 227 && root.parent.parent.token === 107) || + (decl.kind === 228 && root.parent.parent.token === 84); } return false; } @@ -52323,7 +52563,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 219 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 220 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -52333,13 +52573,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 && - (node.parent.kind === 215 || node.parent.kind === 214) && + (node.parent.kind === 216 || node.parent.kind === 215) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 && - node.parent.kind === 219 && + node.parent.kind === 220 && node.parent.label === node; } function isLabelName(node) { @@ -52355,7 +52595,7 @@ var ts; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 230 && node.parent.name === node; + return node.parent.kind === 231 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -52368,13 +52608,13 @@ var ts; switch (node.parent.kind) { case 147: case 146: - case 257: - case 260: + case 258: + case 261: case 149: case 148: case 151: case 152: - case 230: + case 231: return node.parent.name === node; case 178: return node.parent.argumentExpression === node; @@ -52422,17 +52662,17 @@ var ts; return undefined; } switch (node.kind) { - case 261: + case 262: case 149: case 148: - case 225: + case 226: case 184: case 151: case 152: - case 226: case 227: - case 229: + case 228: case 230: + case 231: return node; } } @@ -52440,22 +52680,22 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 261: + case 262: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 230: + case 231: return ts.ScriptElementKind.moduleElement; - case 226: + case 227: case 197: return ts.ScriptElementKind.classElement; - case 227: return ts.ScriptElementKind.interfaceElement; - case 228: return ts.ScriptElementKind.typeElement; - case 229: return ts.ScriptElementKind.enumElement; - case 223: + case 228: return ts.ScriptElementKind.interfaceElement; + case 229: return ts.ScriptElementKind.typeElement; + case 230: return ts.ScriptElementKind.enumElement; + case 224: return getKindOfVariableDeclaration(node); case 174: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); case 185: - case 225: + case 226: case 184: return ts.ScriptElementKind.functionElement; case 151: return ts.ScriptElementKind.memberGetAccessorElement; @@ -52471,15 +52711,15 @@ var ts; case 153: return ts.ScriptElementKind.callSignatureElement; case 150: return ts.ScriptElementKind.constructorImplementationElement; case 143: return ts.ScriptElementKind.typeParameterElement; - case 260: return ts.ScriptElementKind.enumMemberElement; + case 261: return ts.ScriptElementKind.enumMemberElement; case 144: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 234: - case 239: - case 236: - case 243: + case 235: + case 240: case 237: + case 244: + case 238: return ts.ScriptElementKind.alias; - case 285: + case 286: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -52551,19 +52791,19 @@ var ts; return false; } switch (n.kind) { - case 226: case 227: - case 229: + case 228: + case 230: case 176: case 172: case 161: - case 204: - case 231: + case 205: case 232: - case 238: - case 242: + case 233: + case 239: + case 243: return nodeEndsWith(n, 17, sourceFile); - case 256: + case 257: return isCompletedNode(n.block, sourceFile); case 180: if (!n.arguments) { @@ -52579,7 +52819,7 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 184: case 149: case 148: @@ -52593,14 +52833,14 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19, sourceFile); - case 230: + case 231: return n.body && isCompletedNode(n.body, sourceFile); - case 208: + case 209: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 207: + case 208: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24); case 175: @@ -52614,15 +52854,15 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21, sourceFile); - case 253: case 254: + case 255: return false; - case 211: case 212: case 213: - case 210: + case 214: + case 211: return isCompletedNode(n.statement, sourceFile); - case 209: + case 210: var hasWhileKeyword = findChildOfKind(n, 105, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 19, sourceFile); @@ -52642,10 +52882,10 @@ var ts; case 194: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 202: + case 203: return ts.nodeIsPresent(n.literal); - case 241: - case 235: + case 242: + case 236: return ts.nodeIsPresent(n.moduleSpecifier); case 190: return isCompletedNode(n.operand, sourceFile); @@ -52694,7 +52934,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 292 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 293 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -52749,8 +52989,8 @@ var ts; } } } - for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { - var child = current.getChildAt(i); + for (var _a = 0, _b = current.getChildren(); _a < _b.length; _a++) { + var child = _b[_a]; if (ts.isJSDocNode(child)) { continue; } @@ -52814,7 +53054,7 @@ var ts; return n; } var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; i++) { + for (var i = 0; i < children.length; i++) { var child = children[i]; if (position < child.end && (nodeHasTokens(child) || child.kind === 10)) { var start = child.getStart(sourceFile); @@ -52829,7 +53069,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 261); + ts.Debug.assert(startNode !== undefined || n.kind === 262); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -52874,13 +53114,13 @@ var ts; if (token.kind === 26 && token.parent.kind === 10) { return true; } - if (token.kind === 26 && token.parent.kind === 252) { + if (token.kind === 26 && token.parent.kind === 253) { return true; } - if (token && token.kind === 17 && token.parent.kind === 252) { + if (token && token.kind === 17 && token.parent.kind === 253) { return true; } - if (token.kind === 26 && token.parent.kind === 249) { + if (token.kind === 26 && token.parent.kind === 250) { return true; } return false; @@ -52974,7 +53214,7 @@ var ts; if (node.kind === 157 || node.kind === 179) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 226 || node.kind === 227) { + if (ts.isFunctionLike(node) || node.kind === 227 || node.kind === 228) { return node.typeParameters; } return undefined; @@ -53047,11 +53287,11 @@ var ts; node.parent.operatorToken.kind === 57) { return true; } - if (node.parent.kind === 213 && + if (node.parent.kind === 214 && node.parent.initializer === node) { return true; } - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 257 ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 258 ? node.parent.parent : node.parent)) { return true; } } @@ -53268,7 +53508,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 239 || location.parent.kind === 243) && + (location.parent.kind === 240 || location.parent.kind === 244) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -53325,6 +53565,10 @@ var ts; }; } ts.sanitizeConfigFile = sanitizeConfigFile; + function getOpenBraceEnd(constructor, sourceFile) { + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + ts.getOpenBraceEnd = getOpenBraceEnd; })(ts || (ts = {})); var ts; (function (ts) { @@ -53373,15 +53617,15 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 205: + case 206: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 223: + case 224: case 147: case 146: return spanInVariableDeclaration(node); case 144: return spanInParameterDeclaration(node); - case 225: + case 226: case 149: case 148: case 151: @@ -53390,72 +53634,72 @@ var ts; case 184: case 185: return spanInFunctionDeclaration(node); - case 204: + case 205: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 231: + case 232: return spanInBlock(node); - case 256: + case 257: return spanInBlock(node.block); - case 207: - return textSpan(node.expression); - case 216: - return textSpan(node.getChildAt(0), node.expression); - case 210: - return textSpanEndingAtNextToken(node, node.expression); - case 209: - return spanInNode(node.statement); - case 222: - return textSpan(node.getChildAt(0)); case 208: - return textSpanEndingAtNextToken(node, node.expression); - case 219: - return spanInNode(node.statement); - case 215: - case 214: - return textSpan(node.getChildAt(0), node.label); + return textSpan(node.expression); + case 217: + return textSpan(node.getChildAt(0), node.expression); case 211: - return spanInForStatement(node); - case 212: return textSpanEndingAtNextToken(node, node.expression); - case 213: - return spanInInitializerOfForLike(node); - case 218: + case 210: + return spanInNode(node.statement); + case 223: + return textSpan(node.getChildAt(0)); + case 209: return textSpanEndingAtNextToken(node, node.expression); - case 253: - case 254: - return spanInNode(node.statements[0]); - case 221: - return spanInBlock(node.tryBlock); case 220: + return spanInNode(node.statement); + case 216: + case 215: + return textSpan(node.getChildAt(0), node.label); + case 212: + return spanInForStatement(node); + case 213: + return textSpanEndingAtNextToken(node, node.expression); + case 214: + return spanInInitializerOfForLike(node); + case 219: + return textSpanEndingAtNextToken(node, node.expression); + case 254: + case 255: + return spanInNode(node.statements[0]); + case 222: + return spanInBlock(node.tryBlock); + case 221: return textSpan(node, node.expression); - case 240: - return textSpan(node, node.expression); - case 234: - return textSpan(node, node.moduleReference); - case 235: - return textSpan(node, node.moduleSpecifier); case 241: + return textSpan(node, node.expression); + case 235: + return textSpan(node, node.moduleReference); + case 236: return textSpan(node, node.moduleSpecifier); - case 230: + case 242: + return textSpan(node, node.moduleSpecifier); + case 231: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 226: - case 229: - case 260: + case 227: + case 230: + case 261: case 174: return textSpan(node); - case 217: + case 218: return spanInNode(node.statement); case 145: return spanInNodeArray(node.parent.decorators); case 172: case 173: return spanInBindingPattern(node); - case 227: case 228: + case 229: return undefined; case 24: case 1: @@ -53491,8 +53735,8 @@ var ts; } if ((node.kind === 70 || node.kind == 196 || - node.kind === 257 || - node.kind === 258) && + node.kind === 258 || + node.kind === 259) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } @@ -53511,12 +53755,12 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 209: + case 210: return spanInPreviousNode(node); case 145: return spanInNode(node.parent); - case 211: - case 213: + case 212: + case 214: return textSpan(node); case 192: if (node.parent.operatorToken.kind === 25) { @@ -53530,7 +53774,7 @@ var ts; break; } } - if (node.parent.kind === 257 && + if (node.parent.kind === 258 && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); @@ -53541,7 +53785,7 @@ var ts; if (ts.isFunctionLike(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); } - if ((node.parent.kind === 223 || + if ((node.parent.kind === 224 || node.parent.kind === 144)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || @@ -53571,7 +53815,7 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 212) { + if (variableDeclaration.parent.parent.kind === 213) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { @@ -53579,7 +53823,7 @@ var ts; } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 213) { + variableDeclaration.parent.parent.kind === 214) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -53611,7 +53855,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 226 && functionDeclaration.kind !== 150); + (functionDeclaration.parent.kind === 227 && functionDeclaration.kind !== 150); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -53631,22 +53875,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 230: + case 231: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 210: - case 208: - case 212: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); case 211: + case 209: case 213: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 212: + case 214: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 224) { + if (forLikeStatement.initializer.kind === 225) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -53690,33 +53934,33 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 229: + case 230: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 226: + case 227: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 232: + case 233: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 231: + case 232: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 229: - case 226: + case 230: + case 227: return textSpan(node); - case 204: + case 205: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 256: + case 257: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 232: + case 233: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { @@ -53748,7 +53992,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 209 || + if (node.parent.kind === 210 || node.parent.kind === 179 || node.parent.kind === 180) { return spanInPreviousNode(node); @@ -53761,17 +54005,17 @@ var ts; function spanInCloseParenToken(node) { switch (node.parent.kind) { case 184: - case 225: + case 226: case 185: case 149: case 148: case 151: case 152: case 150: - case 210: - case 209: case 211: - case 213: + case 210: + case 212: + case 214: case 179: case 180: case 183: @@ -53782,7 +54026,7 @@ var ts; } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || - node.parent.kind === 257 || + node.parent.kind === 258 || node.parent.kind === 144) { return spanInPreviousNode(node); } @@ -53795,13 +54039,13 @@ var ts; return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 209) { + if (node.parent.kind === 210) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 213) { + if (node.parent.kind === 214) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -53845,7 +54089,7 @@ var ts; var entries = []; var dense = classifications.spans; var lastEnd = 0; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; var length_4 = dense[i + 1]; var type = dense[i + 2]; @@ -54152,10 +54396,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { - case 230: - case 226: + case 231: case 227: - case 225: + case 228: + case 226: cancellationToken.throwIfCancellationRequested(); } } @@ -54199,7 +54443,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 230 && + return declaration.kind === 231 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -54256,7 +54500,7 @@ var ts; ts.Debug.assert(classifications.spans.length % 3 === 0); var dense = classifications.spans; var result = []; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { result.push({ textSpan: ts.createTextSpan(dense[i], dense[i + 1]), classificationType: getClassificationTypeName(dense[i + 2]) @@ -54340,16 +54584,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 281: + case 282: processJSDocParameterTag(tag); break; - case 284: + case 285: processJSDocTemplateTag(tag); break; - case 283: + case 284: processElement(tag.typeExpression); break; - case 282: + case 283: processElement(tag.typeExpression); break; } @@ -54430,22 +54674,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 248: + case 249: if (token.parent.tagName === token) { return 19; } break; - case 249: + case 250: if (token.parent.tagName === token) { return 20; } break; - case 247: + case 248: if (token.parent.tagName === token) { return 21; } break; - case 250: + case 251: if (token.parent.name === token) { return 22; } @@ -54465,10 +54709,10 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { if (tokenKind === 57) { - if (token.parent.kind === 223 || + if (token.parent.kind === 224 || token.parent.kind === 147 || token.parent.kind === 144 || - token.parent.kind === 250) { + token.parent.kind === 251) { return 5; } } @@ -54485,7 +54729,7 @@ var ts; return 4; } else if (tokenKind === 9) { - return token.parent.kind === 250 ? 24 : 6; + return token.parent.kind === 251 ? 24 : 6; } else if (tokenKind === 11) { return 6; @@ -54499,7 +54743,7 @@ var ts; else if (tokenKind === 70) { if (token) { switch (token.parent.kind) { - case 226: + case 227: if (token.parent.name === token) { return 11; } @@ -54509,17 +54753,17 @@ var ts; return 15; } return; - case 227: + case 228: if (token.parent.name === token) { return 13; } return; - case 229: + case 230: if (token.parent.name === token) { return 12; } return; - case 230: + case 231: if (token.parent.name === token) { return 14; } @@ -54540,9 +54784,8 @@ var ts; } if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { checkForClassificationCancellation(cancellationToken, element.kind); - var children = element.getChildren(sourceFile); - for (var i = 0, n = children.length; i < n; i++) { - var child = children[i]; + for (var _i = 0, _a = element.getChildren(sourceFile); _i < _a.length; _i++) { + var child = _a[_i]; if (!tryClassifyNode(child)) { processElement(child); } @@ -54579,7 +54822,7 @@ var ts; else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 && - location.parent && location.parent.kind === 249) { + location.parent && location.parent.kind === 250) { var tagName = location.parent.parent.openingElement.tagName; entries.push({ name: tagName.text, @@ -54657,7 +54900,7 @@ var ts; if (!node || node.kind !== 9) { return undefined; } - if (node.parent.kind === 257 && + if (node.parent.kind === 258 && node.parent.parent.kind === 176 && node.parent.name === node) { return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); @@ -54665,7 +54908,7 @@ var ts; else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 235 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 236 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { return getStringLiteralCompletionEntriesFromModuleNames(node); } else { @@ -54725,6 +54968,9 @@ var ts; return undefined; } function addStringLiteralCompletionsFromType(type, result) { + if (type && type.flags & 16384) { + type = typeChecker.getApparentType(type); + } if (!type) { return; } @@ -55029,11 +55275,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_13 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_13) { + var parent_14 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_14) { break; } - currentDir = parent_13; + currentDir = parent_14; } else { break; @@ -55165,9 +55411,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 283: - case 281: + case 284: case 282: + case 283: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -55202,13 +55448,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_14 = contextToken.parent, kind = contextToken.kind; + var parent_15 = contextToken.parent, kind = contextToken.kind; if (kind === 22) { - if (parent_14.kind === 177) { + if (parent_15.kind === 177) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_14.kind === 141) { + else if (parent_15.kind === 141) { node = contextToken.parent.left; isRightOfDot = true; } @@ -55221,7 +55467,7 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 40 && contextToken.parent.kind === 249) { + else if (kind === 40 && contextToken.parent.kind === 250) { isStartingCloseTag = true; location = contextToken; } @@ -55312,7 +55558,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 247) || (jsxContainer.kind === 248)) { + if ((jsxContainer.kind === 248) || (jsxContainer.kind === 249)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); @@ -55333,9 +55579,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 261 || + scopeNode.kind === 262 || scopeNode.kind === 194 || - scopeNode.kind === 252 || + scopeNode.kind === 253 || ts.isStatement(scopeNode); } var symbolMeanings = 793064 | 107455 | 1920 | 8388608; @@ -55363,11 +55609,11 @@ var ts; return true; } if (contextToken.kind === 28 && contextToken.parent) { - if (contextToken.parent.kind === 248) { + if (contextToken.parent.kind === 249) { return true; } - if (contextToken.parent.kind === 249 || contextToken.parent.kind === 247) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 246; + if (contextToken.parent.kind === 250 || contextToken.parent.kind === 248) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 247; } } return false; @@ -55397,16 +55643,16 @@ var ts; case 128: return true; case 22: - return containingNodeKind === 230; + return containingNodeKind === 231; case 16: - return containingNodeKind === 226; + return containingNodeKind === 227; case 57: - return containingNodeKind === 223 + return containingNodeKind === 224 || containingNodeKind === 192; case 13: return containingNodeKind === 194; case 14: - return containingNodeKind === 202; + return containingNodeKind === 203; case 113: case 111: case 112: @@ -55482,9 +55728,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 238 ? - 235 : - 241; + var declarationKind = namedImportsOrExports.kind === 239 ? + 236 : + 242; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -55505,9 +55751,9 @@ var ts; switch (contextToken.kind) { case 16: case 25: - var parent_15 = contextToken.parent; - if (parent_15 && (parent_15.kind === 176 || parent_15.kind === 172)) { - return parent_15; + var parent_16 = contextToken.parent; + if (parent_16 && (parent_16.kind === 176 || parent_16.kind === 172)) { + return parent_16; } break; } @@ -55520,8 +55766,8 @@ var ts; case 16: case 25: switch (contextToken.parent.kind) { - case 238: - case 242: + case 239: + case 243: return contextToken.parent; } } @@ -55530,34 +55776,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_16 = contextToken.parent; + var parent_17 = contextToken.parent; switch (contextToken.kind) { case 27: case 40: case 70: - case 250: case 251: - if (parent_16 && (parent_16.kind === 247 || parent_16.kind === 248)) { - return parent_16; + case 252: + if (parent_17 && (parent_17.kind === 248 || parent_17.kind === 249)) { + return parent_17; } - else if (parent_16.kind === 250) { - return parent_16.parent; + else if (parent_17.kind === 251) { + return parent_17.parent; } break; case 9: - if (parent_16 && ((parent_16.kind === 250) || (parent_16.kind === 251))) { - return parent_16.parent; + if (parent_17 && ((parent_17.kind === 251) || (parent_17.kind === 252))) { + return parent_17.parent; } break; case 17: - if (parent_16 && - parent_16.kind === 252 && - parent_16.parent && - (parent_16.parent.kind === 250)) { - return parent_16.parent.parent; + if (parent_17 && + parent_17.kind === 253 && + parent_17.parent && + (parent_17.parent.kind === 251)) { + return parent_17.parent.parent; } - if (parent_16 && parent_16.kind === 251) { - return parent_16.parent; + if (parent_17 && parent_17.kind === 252) { + return parent_17.parent; } break; } @@ -55568,7 +55814,7 @@ var ts; switch (kind) { case 184: case 185: - case 225: + case 226: case 149: case 148: case 151: @@ -55584,16 +55830,16 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25: - return containingNodeKind === 223 || - containingNodeKind === 224 || - containingNodeKind === 205 || - containingNodeKind === 229 || + return containingNodeKind === 224 || + containingNodeKind === 225 || + containingNodeKind === 206 || + containingNodeKind === 230 || isFunction(containingNodeKind) || - containingNodeKind === 226 || - containingNodeKind === 197 || containingNodeKind === 227 || + containingNodeKind === 197 || + containingNodeKind === 228 || containingNodeKind === 173 || - containingNodeKind === 228; + containingNodeKind === 229; case 22: return containingNodeKind === 173; case 55: @@ -55601,22 +55847,22 @@ var ts; case 20: return containingNodeKind === 173; case 18: - return containingNodeKind === 256 || + return containingNodeKind === 257 || isFunction(containingNodeKind); case 16: - return containingNodeKind === 229 || - containingNodeKind === 227 || + return containingNodeKind === 230 || + containingNodeKind === 228 || containingNodeKind === 161; case 24: return containingNodeKind === 146 && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 227 || + (contextToken.parent.parent.kind === 228 || contextToken.parent.parent.kind === 161); case 26: - return containingNodeKind === 226 || + return containingNodeKind === 227 || containingNodeKind === 197 || - containingNodeKind === 227 || containingNodeKind === 228 || + containingNodeKind === 229 || isFunction(containingNodeKind); case 114: return containingNodeKind === 147; @@ -55629,9 +55875,9 @@ var ts; case 112: return containingNodeKind === 144; case 117: - return containingNodeKind === 239 || - containingNodeKind === 243 || - containingNodeKind === 237; + return containingNodeKind === 240 || + containingNodeKind === 244 || + containingNodeKind === 238; case 74: case 82: case 108: @@ -55695,8 +55941,8 @@ var ts; var existingMemberNames = ts.createMap(); for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; - if (m.kind !== 257 && - m.kind !== 258 && + if (m.kind !== 258 && + m.kind !== 259 && m.kind !== 174 && m.kind !== 149 && m.kind !== 151 && @@ -55726,7 +55972,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 250) { + if (attr.kind === 251) { seenNames[attr.name.text] = true; } } @@ -55875,58 +56121,58 @@ var ts; switch (node.kind) { case 89: case 81: - if (hasKind(node.parent, 208)) { + if (hasKind(node.parent, 209)) { return getIfElseOccurrences(node.parent); } break; case 95: - if (hasKind(node.parent, 216)) { + if (hasKind(node.parent, 217)) { return getReturnOccurrences(node.parent); } break; case 99: - if (hasKind(node.parent, 220)) { + if (hasKind(node.parent, 221)) { return getThrowOccurrences(node.parent); } break; case 73: - if (hasKind(parent(parent(node)), 221)) { + if (hasKind(parent(parent(node)), 222)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 101: case 86: - if (hasKind(parent(node), 221)) { + if (hasKind(parent(node), 222)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 97: - if (hasKind(node.parent, 218)) { + if (hasKind(node.parent, 219)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 72: case 78: - if (hasKind(parent(parent(parent(node))), 218)) { + if (hasKind(parent(parent(parent(node))), 219)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 71: case 76: - if (hasKind(node.parent, 215) || hasKind(node.parent, 214)) { + if (hasKind(node.parent, 216) || hasKind(node.parent, 215)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 87: - if (hasKind(node.parent, 211) || - hasKind(node.parent, 212) || - hasKind(node.parent, 213)) { + if (hasKind(node.parent, 212) || + hasKind(node.parent, 213) || + hasKind(node.parent, 214)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 105: case 80: - if (hasKind(node.parent, 210) || hasKind(node.parent, 209)) { + if (hasKind(node.parent, 211) || hasKind(node.parent, 210)) { return getLoopBreakContinueOccurrences(node.parent); } break; @@ -55943,7 +56189,7 @@ var ts; break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 205)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 206)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -55955,10 +56201,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 220) { + if (node.kind === 221) { statementAccumulator.push(node); } - else if (node.kind === 221) { + else if (node.kind === 222) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -55978,17 +56224,17 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_17 = child.parent; - if (ts.isFunctionBlock(parent_17) || parent_17.kind === 261) { - return parent_17; + var parent_18 = child.parent; + if (ts.isFunctionBlock(parent_18) || parent_18.kind === 262) { + return parent_18; } - if (parent_17.kind === 221) { - var tryStatement = parent_17; + if (parent_18.kind === 222) { + var tryStatement = parent_18; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_17; + child = parent_18; } return undefined; } @@ -55997,7 +56243,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 215 || node.kind === 214) { + if (node.kind === 216 || node.kind === 215) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -56010,23 +56256,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 218: - if (statement.kind === 214) { + for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { + switch (node_2.kind) { + case 219: + if (statement.kind === 215) { continue; } - case 211: case 212: case 213: + case 214: + case 211: case 210: - case 209: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; + 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; @@ -56037,24 +56283,24 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 226 || + if (!(container.kind === 227 || container.kind === 197 || (declaration.kind === 144 && hasKind(container, 150)))) { return undefined; } } else if (modifier === 114) { - if (!(container.kind === 226 || container.kind === 197)) { + if (!(container.kind === 227 || container.kind === 197)) { return undefined; } } else if (modifier === 83 || modifier === 123) { - if (!(container.kind === 231 || container.kind === 261)) { + if (!(container.kind === 232 || container.kind === 262)) { return undefined; } } else if (modifier === 116) { - if (!(container.kind === 226 || declaration.kind === 226)) { + if (!(container.kind === 227 || declaration.kind === 227)) { return undefined; } } @@ -56065,8 +56311,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 231: - case 261: + case 232: + case 262: if (modifierFlag & 128) { nodes = declaration.members.concat(declaration); } @@ -56077,7 +56323,7 @@ var ts; case 150: nodes = container.parameters.concat(container.parent.members); break; - case 226: + case 227: case 197: nodes = container.members; if (modifierFlag & 28) { @@ -56158,7 +56404,7 @@ var ts; function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { - if (loopNode.kind === 209) { + if (loopNode.kind === 210) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 105)) { @@ -56179,13 +56425,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 211: case 212: case 213: - case 209: + case 214: case 210: + case 211: return getLoopBreakContinueOccurrences(owner); - case 218: + case 219: return getSwitchCaseDefaultOccurrences(owner); } } @@ -56235,7 +56481,7 @@ var ts; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 204))) { + if (!(func && hasKind(func.body, 205))) { return undefined; } var keywords = []; @@ -56249,7 +56495,7 @@ var ts; } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 208) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 209) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { @@ -56260,7 +56506,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 208)) { + if (!hasKind(ifStatement.elseStatement, 209)) { break; } ifStatement = ifStatement.elseStatement; @@ -56295,7 +56541,7 @@ var ts; } DocumentHighlights.getDocumentHighlights = getDocumentHighlights; function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 219; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 220; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -56499,16 +56745,16 @@ var ts; } function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608) { - var defaultImport = ts.getDeclarationOfKind(symbol, 236); + var defaultImport = ts.getDeclarationOfKind(symbol, 237); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 239 || - declaration.kind === 243) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 240 || + declaration.kind === 244) ? declaration : undefined; }); if (importOrExportSpecifier && (!importOrExportSpecifier.propertyName || importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 239 ? + return importOrExportSpecifier.kind === 240 ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -56552,7 +56798,7 @@ var ts; if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 226); + return ts.getAncestor(privateDeclaration, 227); } } if (symbol.flags & 8388608) { @@ -56576,7 +56822,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 261 && !ts.isExternalModule(container)) { + if (container.kind === 262 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -56813,7 +57059,7 @@ var ts; result.push(getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === 70) { - if (refNode.parent.kind === 258) { + if (refNode.parent.kind === 259) { getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } var containingClass = getContainingClassIfInHeritageClause(refNode); @@ -56823,24 +57069,24 @@ var ts; } var containingTypeReference = getContainingTypeReference(refNode); if (containingTypeReference) { - var parent_18 = containingTypeReference.parent; - if (ts.isVariableLike(parent_18) && parent_18.type === containingTypeReference && parent_18.initializer && isImplementationExpression(parent_18.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_18.initializer)); + var parent_19 = containingTypeReference.parent; + if (ts.isVariableLike(parent_19) && parent_19.type === containingTypeReference && parent_19.initializer && isImplementationExpression(parent_19.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_19.initializer)); } - else if (ts.isFunctionLike(parent_18) && parent_18.type === containingTypeReference && parent_18.body) { - if (parent_18.body.kind === 204) { - ts.forEachReturnStatement(parent_18.body, function (returnStatement) { + else if (ts.isFunctionLike(parent_19) && parent_19.type === containingTypeReference && parent_19.body) { + if (parent_19.body.kind === 205) { + ts.forEachReturnStatement(parent_19.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); } }); } - else if (isImplementationExpression(parent_18.body)) { - maybeAdd(getReferenceEntryFromNode(parent_18.body)); + else if (isImplementationExpression(parent_19.body)) { + maybeAdd(getReferenceEntryFromNode(parent_19.body)); } } - else if (ts.isAssertionExpression(parent_18) && isImplementationExpression(parent_18.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_18.expression)); + else if (ts.isAssertionExpression(parent_19) && isImplementationExpression(parent_19.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_19.expression)); } } } @@ -56876,7 +57122,7 @@ var ts; function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { if (node.kind === 199 - && node.parent.kind === 255 + && node.parent.kind === 256 && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -56923,7 +57169,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 227) { + else if (declaration.kind === 228) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -56997,11 +57243,11 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; break; - case 261: + case 262: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 225: + case 226: case 184: break; default: @@ -57009,7 +57255,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 261) { + if (searchSpaceNode.kind === 262) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -57044,7 +57290,7 @@ var ts; var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { case 184: - case 225: + case 226: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } @@ -57056,13 +57302,13 @@ var ts; } break; case 197: - case 226: + case 227: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 261: - if (container.kind === 261 && !ts.isExternalModule(container)) { + case 262: + if (container.kind === 262 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -57097,13 +57343,13 @@ var ts; for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { var position = possiblePositions_1[_i]; cancellationToken.throwIfCancellationRequested(); - var node_2 = ts.getTouchingWord(sourceFile, position); - if (!node_2 || node_2.kind !== 9) { + var node_3 = ts.getTouchingWord(sourceFile, position); + if (!node_3 || node_3.kind !== 9) { return; } - var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + var type_1 = ts.getStringLiteralTypeForNode(node_3, typeChecker); if (type_1 === searchType) { - references.push(getReferenceEntryFromNode(node_2)); + references.push(getReferenceEntryFromNode(node_3)); } } } @@ -57111,7 +57357,7 @@ var ts; function populateSearchSymbolSet(symbol, location) { var result = [symbol]; var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 258) { + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 259) { var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); if (propertySymbol) { result.push(propertySymbol); @@ -57161,7 +57407,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 227) { + else if (declaration.kind === 228) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -57293,7 +57539,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 223) { + else if (node.kind === 224) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2); } @@ -57303,18 +57549,18 @@ var ts; } else { switch (node.kind) { - case 226: + case 227: case 197: - case 229: case 230: + case 231: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 205) { - ts.Debug.assert(node.parent.kind === 224); + if (node.parent && node.parent.parent && node.parent.parent.kind === 206) { + ts.Debug.assert(node.parent.kind === 225); return node.parent.parent; } } @@ -57384,8 +57630,8 @@ var ts; } function isObjectLiteralPropertyDeclaration(node) { switch (node.kind) { - case 257: case 258: + case 259: case 149: case 151: case 152: @@ -57447,11 +57693,11 @@ var ts; var declaration = symbol.declarations[0]; if (node.kind === 70 && (node.parent === declaration || - (declaration.kind === 239 && declaration.parent && declaration.parent.kind === 238))) { + (declaration.kind === 240 && declaration.parent && declaration.parent.kind === 239))) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 258) { + if (node.parent.kind === 259) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -57529,7 +57775,7 @@ var ts; var definition; ts.forEach(signatureDeclarations, function (d) { if ((selectConstructors && d.kind === 150) || - (!selectConstructors && (d.kind === 225 || d.kind === 149 || d.kind === 148))) { + (!selectConstructors && (d.kind === 226 || d.kind === 149 || d.kind === 148))) { declarations.push(d); if (d.body) definition = d; @@ -57605,7 +57851,7 @@ var ts; var GoToImplementation; (function (GoToImplementation) { function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { - if (node.parent.kind === 258) { + if (node.parent.kind === 259) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -57697,7 +57943,7 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function forEachUnique(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (ts.indexOf(array, array[i]) === i) { var result = callback(array[i], i); if (result) { @@ -57731,16 +57977,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 225: + case 226: case 149: case 150: - case 226: - case 205: + case 227: + case 206: break findOwner; - case 261: + case 262: return undefined; - case 230: - if (commentOwner.parent.kind === 230) { + case 231: + if (commentOwner.parent.kind === 231) { return undefined; } break findOwner; @@ -57755,7 +58001,7 @@ var ts; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; - for (var i = 0, numParams = parameters.length; i < numParams; i++) { + for (var i = 0; i < parameters.length; i++) { var currentName = parameters[i].name; var paramName = currentName.kind === 70 ? currentName.text : @@ -57780,7 +58026,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 205) { + if (commentOwner.kind === 206) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -57811,6 +58057,167 @@ var ts; })(JsDoc = ts.JsDoc || (ts.JsDoc = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var JsTyping; + (function (JsTyping) { + ; + ; + var safeList; + var EmptySafeList = ts.createMap(); + JsTyping.nodeCoreModuleList = [ + "buffer", "querystring", "events", "http", "cluster", + "zlib", "os", "https", "punycode", "repl", "readline", + "vm", "child_process", "url", "dns", "net", + "dgram", "fs", "path", "string_decoder", "tls", + "crypto", "stream", "util", "assert", "tty", "domain", + "constants", "process", "v8", "timers", "console" + ]; + var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typeAcquisition, unresolvedImports) { + var inferredTypings = ts.createMap(); + if (!typeAcquisition || !typeAcquisition.enable) { + return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; + } + fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { + var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); + return kind === 1 || kind === 2; + }); + if (!safeList) { + var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); + safeList = result.config ? ts.createMap(result.config) : EmptySafeList; + } + var filesToWatch = []; + var searchDirs = []; + var exclude = []; + mergeTypings(typeAcquisition.include); + exclude = typeAcquisition.exclude || []; + var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); + if (projectRootPath) { + possibleSearchDirs.push(projectRootPath); + } + searchDirs = ts.deduplicate(possibleSearchDirs); + for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { + var searchDir = searchDirs_1[_i]; + var packageJsonPath = ts.combinePaths(searchDir, "package.json"); + getTypingNamesFromJson(packageJsonPath, filesToWatch); + var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); + getTypingNamesFromJson(bowerJsonPath, filesToWatch); + var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); + getTypingNamesFromNodeModuleFolder(nodeModulesPath); + } + getTypingNamesFromSourceFileNames(fileNames); + if (unresolvedImports) { + for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { + var moduleId = unresolvedImports_1[_a]; + var typingName = moduleId in nodeCoreModules ? "node" : moduleId; + if (!(typingName in inferredTypings)) { + inferredTypings[typingName] = undefined; + } + } + } + for (var name_47 in packageNameToTypingLocation) { + if (name_47 in inferredTypings && !inferredTypings[name_47]) { + inferredTypings[name_47] = packageNameToTypingLocation[name_47]; + } + } + for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { + var excludeTypingName = exclude_1[_b]; + delete inferredTypings[excludeTypingName]; + } + var newTypingNames = []; + var cachedTypingPaths = []; + for (var typing in inferredTypings) { + if (inferredTypings[typing] !== undefined) { + cachedTypingPaths.push(inferredTypings[typing]); + } + else { + newTypingNames.push(typing); + } + } + return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; + function mergeTypings(typingNames) { + if (!typingNames) { + return; + } + for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { + var typing = typingNames_1[_i]; + if (!(typing in inferredTypings)) { + inferredTypings[typing] = undefined; + } + } + } + function getTypingNamesFromJson(jsonPath, filesToWatch) { + if (host.fileExists(jsonPath)) { + filesToWatch.push(jsonPath); + } + var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); + if (result.config) { + var jsonConfig = result.config; + if (jsonConfig.dependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); + } + if (jsonConfig.devDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); + } + if (jsonConfig.optionalDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); + } + if (jsonConfig.peerDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); + } + } + } + function getTypingNamesFromSourceFileNames(fileNames) { + var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); + var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); + var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); + if (safeList !== EmptySafeList) { + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); + } + var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); + if (hasJsxFile) { + mergeTypings(["react"]); + } + } + function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { + if (!host.directoryExists(nodeModulesPath)) { + return; + } + var typingNames = []; + var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); + for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { + var fileName = fileNames_2[_i]; + var normalizedFileName = ts.normalizePath(fileName); + if (ts.getBaseFileName(normalizedFileName) !== "package.json") { + continue; + } + var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); + if (!result.config) { + continue; + } + var packageJson = result.config; + if (packageJson._requiredBy && + ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { + continue; + } + if (!packageJson.name) { + continue; + } + if (packageJson.typings) { + var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); + inferredTypings[packageJson.name] = absolutePath; + } + else { + typingNames.push(packageJson.name); + } + } + mergeTypings(typingNames); + } + } + JsTyping.discoverTypings = discoverTypings; + })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var NavigateTo; (function (NavigateTo) { @@ -57823,10 +58230,10 @@ var ts; return; } var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_47 in nameToDeclarations) { - var declarations = nameToDeclarations[name_47]; + for (var name_48 in nameToDeclarations) { + var declarations = nameToDeclarations[name_48]; if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_47); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_48); if (!matches) { continue; } @@ -57837,21 +58244,21 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_47); + matches = patternMatcher.getMatches(containers, name_48); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_47, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_48, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } }); rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 236 || decl.kind === 239 || decl.kind === 234) { + if (decl.kind === 237 || decl.kind === 240 || decl.kind === 235) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -58076,14 +58483,14 @@ var ts; addLeafNode(node); } break; - case 236: + case 237: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 237) { + if (namedBindings.kind === 238) { addLeafNode(namedBindings); } else { @@ -58095,11 +58502,11 @@ var ts; } break; case 174: - case 223: + case 224: var decl = node; - var name_48 = decl.name; - if (ts.isBindingPattern(name_48)) { - addChildrenRecursively(name_48); + var name_49 = decl.name; + if (ts.isBindingPattern(name_49)) { + addChildrenRecursively(name_49); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { addChildrenRecursively(decl.initializer); @@ -58109,11 +58516,11 @@ var ts; } break; case 185: - case 225: + case 226: case 184: addNodeWithRecursiveChild(node, node.body); break; - case 229: + case 230: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -58123,9 +58530,9 @@ var ts; } endNode(); break; - case 226: - case 197: case 227: + case 197: + case 228: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -58133,21 +58540,21 @@ var ts; } endNode(); break; - case 230: + case 231: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 243: - case 234: + case 244: + case 235: case 155: case 153: case 154: - case 228: + case 229: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 285) { + if (tag.kind === 286) { addLeafNode(tag); } }); @@ -58195,12 +58602,12 @@ var ts; } }); function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 230 || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 231 || areSameModule(a, b)); function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 230) { + if (a.body.kind !== 231) { return true; } return areSameModule(a.body, b.body); @@ -58251,7 +58658,7 @@ var ts; return a.length - b.length; }; function tryGetName(node) { - if (node.kind === 230) { + if (node.kind === 231) { return getModuleName(node); } var decl = node; @@ -58263,14 +58670,14 @@ var ts; case 185: case 197: return getFunctionOrClassName(node); - case 285: + case 286: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 230) { + if (node.kind === 231) { return getModuleName(node); } var name = node.name; @@ -58281,15 +58688,15 @@ var ts; } } switch (node.kind) { - case 261: + case 262: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; case 185: - case 225: - case 184: case 226: + case 184: + case 227: case 197: if (ts.getModifierFlags(node) & 512) { return "default"; @@ -58303,7 +58710,7 @@ var ts; return "()"; case 155: return "[]"; - case 285: + case 286: return getJSDocTypedefTagName(node); default: return ""; @@ -58315,7 +58722,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 205) { + if (parentNode && parentNode.kind === 206) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -58343,23 +58750,23 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 226: - case 197: - case 229: case 227: + case 197: case 230: - case 261: case 228: - case 285: + case 231: + case 262: + case 229: + case 286: return true; case 150: case 149: case 151: case 152: - case 223: + case 224: return hasSomeImportantChild(item); case 185: - case 225: + case 226: case 184: return isTopLevelFunctionDeclaration(item); default: @@ -58370,8 +58777,8 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 231: - case 261: + case 232: + case 262: case 149: case 150: return true; @@ -58382,7 +58789,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 223 && childKind !== 174; + return childKind !== 224 && childKind !== 174; }); } } @@ -58437,20 +58844,20 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 230) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 231) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } return result.join("."); } function getInteriorModule(decl) { - return decl.body.kind === 230 ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 231 ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { return !member.name || member.name.kind === 142; } function getNodeSpan(node) { - return node.kind === 261 + return node.kind === 262 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); } @@ -58458,14 +58865,14 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 223) { + else if (node.parent.kind === 224) { return ts.declarationNameToString(node.parent.name); } else if (node.parent.kind === 192 && node.parent.operatorToken.kind === 57) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 257 && node.parent.name) { + else if (node.parent.kind === 258 && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512) { @@ -58561,26 +58968,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 204: + case 205: if (!ts.isFunctionBlock(n)) { - var parent_19 = n.parent; + var parent_20 = n.parent; var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); - if (parent_19.kind === 209 || - parent_19.kind === 212 || - parent_19.kind === 213 || - parent_19.kind === 211 || - parent_19.kind === 208 || - parent_19.kind === 210 || - parent_19.kind === 217 || - parent_19.kind === 256) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + if (parent_20.kind === 210 || + parent_20.kind === 213 || + parent_20.kind === 214 || + parent_20.kind === 212 || + parent_20.kind === 209 || + parent_20.kind === 211 || + parent_20.kind === 218 || + parent_20.kind === 257) { + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_19.kind === 221) { - var tryStatement = parent_19; + if (parent_20.kind === 222) { + var tryStatement = parent_20; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -58600,17 +59007,17 @@ var ts; }); break; } - case 231: { + case 232: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 226: case 227: - case 229: + case 228: + case 230: case 176: - case 232: { + case 233: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); @@ -58878,7 +59285,8 @@ var ts; return str === str.toLowerCase(); } function indexOfIgnoringCase(string, value) { - for (var i = 0, n = string.length - value.length; i <= n; i++) { + var n = string.length - value.length; + for (var i = 0; i <= n; i++) { if (startsWithIgnoringCase(string, value, i)) { return i; } @@ -58886,7 +59294,7 @@ var ts; return -1; } function startsWithIgnoringCase(string, value, start) { - for (var i = 0, n = value.length; i < n; i++) { + for (var i = 0; i < value.length; i++) { var ch1 = toLowerCase(string.charCodeAt(i + start)); var ch2 = value.charCodeAt(i); if (ch1 !== ch2) { @@ -58954,7 +59362,7 @@ var ts; function breakIntoSpans(identifier, word) { var result = []; var wordStart = 0; - for (var i = 1, n = identifier.length; i < n; i++) { + for (var i = 1; i < identifier.length; i++) { var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); var currentIsDigit = isDigit(identifier.charCodeAt(i)); var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); @@ -59527,7 +59935,7 @@ var ts; var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 202 && node.parent.parent.parent.kind === 181) { + else if (node.parent.kind === 203 && node.parent.parent.parent.kind === 181) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; @@ -59604,7 +60012,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 261; n = n.parent) { + for (var n = node; n.kind !== 262; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -59966,7 +60374,7 @@ var ts; } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 230); + var declaration = ts.getDeclarationOfKind(symbol, 231); var isNamespace = declaration && declaration.name && declaration.name.kind === 70; displayParts.push(ts.keywordPart(isNamespace ? 128 : 127)); displayParts.push(ts.spacePart()); @@ -60001,7 +60409,7 @@ var ts; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } - else if (declaration.kind === 228) { + else if (declaration.kind === 229) { addInPrefix(); displayParts.push(ts.keywordPart(136)); displayParts.push(ts.spacePart()); @@ -60014,7 +60422,7 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 260) { + if (declaration.kind === 261) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -60026,7 +60434,7 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 233) { + if (symbol.declarations[0].kind === 234) { displayParts.push(ts.keywordPart(83)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(128)); @@ -60037,7 +60445,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 234) { + if (declaration.kind === 235) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -60105,7 +60513,7 @@ var ts; if (!documentation) { documentation = symbol.getDocumentationComment(); if (documentation.length === 0 && symbol.flags & 4) { - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 261; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 262; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!declaration.parent || declaration.parent.kind !== 192) { @@ -60191,11 +60599,11 @@ var ts; if (declaration.kind === 184) { return true; } - if (declaration.kind !== 223 && declaration.kind !== 225) { + if (declaration.kind !== 224 && declaration.kind !== 226) { return false; } - for (var parent_20 = declaration.parent; !ts.isFunctionBlock(parent_20); parent_20 = parent_20.parent) { - if (parent_20.kind === 261 || parent_20.kind === 231) { + for (var parent_21 = declaration.parent; !ts.isFunctionBlock(parent_21); parent_21 = parent_21.parent) { + if (parent_21.kind === 262 || parent_21.kind === 232) { return false; } } @@ -60386,10 +60794,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { + case 251: + case 249: case 250: case 248: - case 249: - case 247: return node.kind === 70; } } @@ -60722,10 +61130,10 @@ var ts; this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromRange(0, 140, [19])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17, 81), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17, 105), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([19, 21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); @@ -60736,10 +61144,10 @@ var ts; this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19, 3, 80, 101, 86, 81]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8)); this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8)); this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); @@ -60759,6 +61167,7 @@ var ts; this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([109, 75]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2)); this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); @@ -60767,9 +61176,10 @@ var ts; this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 133]), 70), 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127, 131]), 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 133, 114, 136, 138]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 130, 133, 114, 136, 138, 126]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 138])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); @@ -60797,6 +61207,7 @@ var ts; this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40, 28), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, @@ -60825,7 +61236,7 @@ var ts; this.NoSpaceBetweenTagAndTemplateString, this.SpaceBeforeJsxAttribute, this.SpaceBeforeSlashInJsxOpeningElement, this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement, this.NoSpaceBeforeEqualInJsxAttribute, this.NoSpaceAfterEqualInJsxAttribute, - this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, + this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, this.SpaceBeforeArrow, this.SpaceAfterArrow, @@ -60840,6 +61251,7 @@ var ts; this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, + this.NoSpaceBeforeNonNullAssertionOperator ]; this.LowPriorityCommonRules = [ this.NoSpaceBeforeSemicolon, @@ -60848,7 +61260,6 @@ var ts; this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, - this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2)); @@ -60889,15 +61300,15 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_49 in o) { - if (o[name_49] === rule) { - return name_49; + for (var name_50 in o) { + if (o[name_50] === rule) { + return name_50; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 211; + return context.contextNode.kind === 212; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); @@ -60907,24 +61318,25 @@ var ts; case 192: case 193: case 200: - case 243: - case 239: + case 244: + case 240: case 156: case 164: case 165: return true; case 174: - case 228: - case 234: - case 223: + case 229: + case 235: + case 224: case 144: - case 260: + case 261: case 147: case 146: return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; - case 212: - return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; case 213: + case 143: + return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; + case 214: return context.currentTokenSpan.kind === 140 || context.nextTokenSpan.kind === 140; } return false; @@ -60938,6 +61350,9 @@ var ts; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; + Rules.IsBraceWrappedContext = function (context) { + return context.contextNode.kind === 172 || Rules.IsSingleLineBlockContext(context); + }; Rules.IsBeforeMultilineBlockContext = function (context) { return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); }; @@ -60958,17 +61373,17 @@ var ts; return true; } switch (node.kind) { - case 204: - case 232: + case 205: + case 233: case 176: - case 231: + case 232: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 225: + case 226: case 149: case 148: case 151: @@ -60977,58 +61392,64 @@ var ts; case 184: case 150: case 185: - case 227: + case 228: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 225 || context.contextNode.kind === 184; + return context.contextNode.kind === 226 || context.contextNode.kind === 184; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 226: - case 197: case 227: - case 229: - case 161: + case 197: + case 228: case 230: - case 241: + case 161: + case 231: case 242: - case 235: - case 238: + case 243: + case 236: + case 239: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 226: - case 230: - case 229: - case 204: - case 256: + case 227: case 231: - case 218: + case 230: + case 257: + case 232: + case 219: return true; + case 205: { + var blockParent = context.currentTokenParent.parent; + if (blockParent.kind !== 185 && + blockParent.kind !== 184) { + return true; + } + } } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 208: - case 218: - case 211: + case 209: + case 219: case 212: case 213: + case 214: + case 211: + case 222: case 210: - case 221: - case 209: - case 217: - case 256: + case 218: + case 257: return true; default: return false; @@ -61059,19 +61480,19 @@ var ts; return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 246; + return context.contextNode.kind !== 247; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 252; + return context.contextNode.kind === 253; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 250; + return context.nextTokenParent.kind === 251; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 250; + return context.contextNode.kind === 251; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 247; + return context.contextNode.kind === 248; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -61089,14 +61510,14 @@ var ts; return node.kind === 145; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 224 && + return context.currentTokenParent.kind === 225 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 230; + return context.contextNode.kind === 231; }; Rules.IsObjectTypeContext = function (context) { return context.contextNode.kind === 161; @@ -61108,10 +61529,11 @@ var ts; switch (parent.kind) { case 157: case 182: - case 226: - case 197: + case 229: case 227: - case 225: + case 197: + case 228: + case 226: case 184: case 185: case 149: @@ -61139,6 +61561,9 @@ var ts; Rules.IsYieldOrYieldStarWithOperand = function (context) { return context.contextNode.kind === 195 && context.contextNode.expression !== undefined; }; + Rules.IsNonNullAssertionContext = function (context) { + return context.contextNode.kind === 201; + }; return Rules; }()); formatting.Rules = Rules; @@ -61423,6 +61848,12 @@ var ts; }; RulesProvider.prototype.createActiveRules = function (options) { var rules = this.globalRules.HighPriorityCommonRules.slice(0); + if (options.insertSpaceAfterConstructor) { + rules.push(this.globalRules.SpaceAfterConstructor); + } + else { + rules.push(this.globalRules.NoSpaceAfterConstructor); + } if (options.insertSpaceAfterCommaDelimiter) { rules.push(this.globalRules.SpaceAfterComma); } @@ -61501,6 +61932,12 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); rules.push(this.globalRules.NoSpaceAfterBinaryOperator); } + if (options.insertSpaceBeforeFunctionParenthesis) { + rules.push(this.globalRules.SpaceBeforeOpenParenInFuncDecl); + } + else { + rules.push(this.globalRules.NoSpaceBeforeOpenParenInFuncDecl); + } if (options.placeOpenBraceOnNewLineForControlBlocks) { rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); } @@ -61598,17 +62035,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 226: case 227: + case 228: return ts.rangeContainsRange(parent.members, node); - case 230: - var body = parent.body; - return body && body.kind === 231 && ts.rangeContainsRange(body.statements, node); - case 261: - case 204: case 231: + var body = parent.body; + return body && body.kind === 232 && ts.rangeContainsRange(body.statements, node); + case 262: + case 205: + case 232: return ts.rangeContainsRange(parent.statements, node); - case 256: + case 257: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -61764,10 +62201,10 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 226: return 74; - case 227: return 108; - case 225: return 88; - case 229: return 229; + case 227: return 74; + case 228: return 108; + case 226: return 88; + case 230: return 230; case 151: return 124; case 152: return 133; case 149: @@ -61799,17 +62236,30 @@ var ts; switch (kind) { case 16: case 17: - case 20: - case 21: case 18: case 19: case 81: case 105: case 56: return indentation; - default: - return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; + case 40: + case 28: { + if (container.kind === 249 || + container.kind === 250 || + container.kind === 248) { + return indentation; + } + break; + } + case 20: + case 21: { + if (container.kind !== 170) { + return indentation; + } + break; + } } + return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; }, getIndentation: function () { return indentation; }, getDelta: function (child) { return getEffectiveDelta(delta, child); }, @@ -61850,7 +62300,7 @@ var ts; if (tokenInfo.token.end > node.end) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); @@ -61880,7 +62330,7 @@ var ts; if (tokenInfo.token.end > childStartPos) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, node); } if (!formattingScanner.isOnToken()) { return inheritedIndentation; @@ -61915,10 +62365,10 @@ var ts; startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1, parent, parentDynamicIndentation, parentStartLine); listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } else { - consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); } } } @@ -61931,7 +62381,7 @@ var ts; if (formattingScanner.isOnToken()) { var tokenInfo = formattingScanner.readTokenInfo(parent); if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } } } @@ -62121,7 +62571,7 @@ var ts; startLine++; } var delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; i++, startLine++) { + for (var i = startIndex; i < parts.length; i++, startLine++) { var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart @@ -62212,7 +62662,7 @@ var ts; function getOpenTokenForList(node, list) { switch (node.kind) { case 150: - case 225: + case 226: case 184: case 149: case 148: @@ -62436,7 +62886,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 261 || !parentAndChildShareLine); + (parent.kind === 262 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -62460,7 +62910,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 208 && parent.elseStatement === child) { + if (parent.kind === 209 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -62482,7 +62932,7 @@ var ts; return node.parent.properties; case 175: return node.parent.elements; - case 225: + case 226: case 184: case 185: case 149: @@ -62604,35 +63054,36 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 207: - case 226: - case 197: + case 208: case 227: - case 229: + case 197: case 228: + case 230: + case 229: case 175: - case 204: - case 231: + case 205: + case 232: case 176: case 161: + case 170: case 163: - case 232: + case 233: + case 255: case 254: - case 253: case 183: case 177: case 179: case 180: - case 205: - case 223: - case 240: - case 216: + case 206: + case 224: + case 241: + case 217: case 193: case 173: case 172: + case 249: case 248: - case 247: - case 252: + case 253: case 148: case 153: case 154: @@ -62642,10 +63093,10 @@ var ts; case 166: case 181: case 189: - case 242: - case 238: case 243: case 239: + case 244: + case 240: return true; } return false; @@ -62653,27 +63104,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 209: case 210: - case 212: - case 213: case 211: - case 208: - case 225: + case 213: + case 214: + case 212: + case 209: + case 226: case 184: case 149: case 185: case 150: case 151: case 152: - return childKind !== 204; - case 241: - return childKind !== 242; - case 235: - return childKind !== 236 || - (child.namedBindings && child.namedBindings.kind !== 238); - case 246: - return childKind !== 249; + return childKind !== 205; + case 242: + return childKind !== 243; + case 236: + return childKind !== 237 || + (child.namedBindings && child.namedBindings.kind !== 239); + case 247: + return childKind !== 250; } return indentByDefault; } @@ -62723,24 +63174,120 @@ var ts; (function (ts) { var codefix; (function (codefix) { - function getOpenBraceEnd(constructor, sourceFile) { - return constructor.body.getFirstToken(sourceFile).getEnd(); - } codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 122) { - return undefined; - } - var newPosition = getOpenBraceEnd(token.parent, sourceFile); - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] - }]; - } + errorCodes: [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code], + getCodeActions: getActionForClassLikeIncorrectImplementsInterface }); + function getActionForClassLikeIncorrectImplementsInterface(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + var classDecl = ts.getContainingClass(token); + if (!classDecl) { + return undefined; + } + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDecl); + var hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, 1); + var hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, 0); + var result = []; + for (var _i = 0, implementedTypeNodes_2 = implementedTypeNodes; _i < implementedTypeNodes_2.length; _i++) { + var implementedTypeNode = implementedTypeNodes_2[_i]; + var implementedType = checker.getTypeFromTypeNode(implementedTypeNode); + var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); + var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8); }); + var insertion = getMissingIndexSignatureInsertion(implementedType, 1, classDecl, hasNumericIndexSignature); + insertion += getMissingIndexSignatureInsertion(implementedType, 0, classDecl, hasStringIndexSignature); + insertion += codefix.getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); + var message = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); + if (insertion) { + pushAction(result, insertion, message); + } + } + return result; + function getMissingIndexSignatureInsertion(type, kind, enclosingDeclaration, hasIndexSigOfKind) { + if (!hasIndexSigOfKind) { + var IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); + if (IndexInfoOfKind) { + var writer = ts.getSingleLineStringWriter(); + checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); + var result_7 = writer.string(); + ts.releaseStringWriter(writer); + return result_7; + } + } + return ""; + } + function pushAction(result, insertion, description) { + var newAction = { + description: description, + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }; + result.push(newAction); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + function getActionForClassLikeMissingAbstractMember(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + if (ts.isClassLike(token.parent)) { + var classDecl = token.parent; + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + var extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); + var abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); + var insertion = codefix.getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); + if (insertion.length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_inherited_abstract_class), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }]; + } + } + return undefined; + } + function symbolPointsToNonPrivateAndAbstractMember(symbol) { + var decls = symbol.getDeclarations(); + ts.Debug.assert(!!(decls && decls.length > 0)); + var flags = ts.getModifierFlags(decls[0]); + return !(flags & 8) && !!(flags & 128); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { codefix.registerCodeFix({ errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], getCodeActions: function (context) { @@ -62762,7 +63309,7 @@ var ts; } } } - var newPosition = getOpenBraceEnd(constructor, sourceFile); + var newPosition = ts.getOpenBraceEnd(constructor, sourceFile); var changes = [{ fileName: sourceFile.fileName, textChanges: [{ newText: superCall.getText(sourceFile), @@ -62778,7 +63325,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 207 && ts.isSuperCall(n.expression)) { + if (n.kind === 208 && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -62791,6 +63338,216 @@ var ts; })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 122) { + return undefined; + } + var newPosition = ts.getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var classDeclNode = ts.getContainingClass(token); + if (!(token.kind === 70 && ts.isClassLike(classDeclNode))) { + return undefined; + } + var heritageClauses = classDeclNode.heritageClauses; + if (!(heritageClauses && heritageClauses.length > 0)) { + return undefined; + } + var extendsToken = heritageClauses[0].getFirstToken(); + if (!(extendsToken && extendsToken.kind === 84)) { + return undefined; + } + var changeStart = extendsToken.getStart(sourceFile); + var changeEnd = extendsToken.getEnd(); + var textChanges = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + for (var i = 1; i < heritageClauses.length; i++) { + var keywordToken = heritageClauses[i].getFirstToken(); + if (keywordToken) { + changeStart = keywordToken.getStart(sourceFile); + changeEnd = keywordToken.getEnd(); + textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + } + } + var result = [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Change_extends_to_implements), + changes: [{ + fileName: sourceFile.fileName, + textChanges: textChanges + }] + }]; + return result; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ + ts.Diagnostics._0_is_declared_but_never_used.code, + ts.Diagnostics.Property_0_is_declared_but_never_used.code + ], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + if (token.kind === 20) { + token = ts.getTokenAtPosition(sourceFile, start + 1); + } + switch (token.kind) { + case 70: + switch (token.parent.kind) { + case 224: + switch (token.parent.parent.parent.kind) { + case 212: + var forStatement = token.parent.parent.parent; + var forInitializer = forStatement.initializer; + if (forInitializer.declarations.length === 1) { + return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); + } + else { + return removeSingleItem(forInitializer.declarations, token); + } + case 214: + var forOfStatement = token.parent.parent.parent; + if (forOfStatement.initializer.kind === 225) { + var forOfInitializer = forOfStatement.initializer; + return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); + } + break; + case 213: + return undefined; + case 257: + var catchClause = token.parent.parent; + var parameter = catchClause.variableDeclaration.getChildren()[0]; + return createCodeFix("", parameter.pos, parameter.end - parameter.pos); + default: + var variableStatement = token.parent.parent.parent; + if (variableStatement.declarationList.declarations.length === 1) { + return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); + } + else { + var declarations = variableStatement.declarationList.declarations; + return removeSingleItem(declarations, token); + } + } + case 143: + var typeParameters = token.parent.parent.typeParameters; + if (typeParameters.length === 1) { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + } + else { + return removeSingleItem(typeParameters, token); + } + case 144: + var functionDeclaration = token.parent.parent; + if (functionDeclaration.parameters.length === 1) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else { + return removeSingleItem(functionDeclaration.parameters, token); + } + case 235: + var importEquals = findImportDeclaration(token); + return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); + case 240: + var namedImports = token.parent.parent; + if (namedImports.elements.length === 1) { + var importSpec = findImportDeclaration(token); + return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); + } + else { + return removeSingleItem(namedImports.elements, token); + } + case 237: + var importClause = token.parent; + if (!importClause.namedBindings) { + var importDecl = findImportDeclaration(importClause); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); + } + case 238: + var namespaceImport = token.parent; + if (namespaceImport.name == token && !namespaceImport.parent.name) { + var importDecl = findImportDeclaration(namespaceImport); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + var start_4 = namespaceImport.parent.name.end; + return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); + } + } + break; + case 147: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + case 238: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + if (ts.isDeclarationName(token)) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else if (ts.isLiteralComputedPropertyDeclarationName(token)) { + return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); + } + else { + return undefined; + } + function findImportDeclaration(token) { + var importDecl = token; + while (importDecl.kind != 236 && importDecl.parent) { + importDecl = importDecl.parent; + } + return importDecl; + } + function createCodeFix(newText, start, length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ newText: newText, span: { start: start, length: length } }] + }] + }]; + } + function removeSingleItem(elements, token) { + if (elements[0] === token.parent) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + } + else { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + } + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var codefix; (function (codefix) { @@ -62876,7 +63633,10 @@ var ts; return ImportCodeActionMap; }()); codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Cannot_find_name_0.code], + errorCodes: [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ], getCodeActions: function (context) { var sourceFile = context.sourceFile; var checker = context.program.getTypeChecker(); @@ -62887,6 +63647,11 @@ var ts; var symbolIdActionMap = new ImportCodeActionMap(); var cachedImportDeclarations = ts.createMap(); var cachedNewImportInsertPosition; + var currentTokenMeaning = ts.getMeaningFromLocation(token); + if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { + var symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); + return getCodeActionForImport(symbol, false, true); + } var allPotentialModules = checker.getAmbientModules(); for (var _i = 0, allSourceFiles_1 = allSourceFiles; _i < allSourceFiles_1.length; _i++) { var otherSourceFile = allSourceFiles_1[_i]; @@ -62894,7 +63659,6 @@ var ts; allPotentialModules.push(otherSourceFile.symbol); } } - var currentTokenMeaning = ts.getMeaningFromLocation(token); for (var _a = 0, allPotentialModules_1 = allPotentialModules; _a < allPotentialModules_1.length; _a++) { var moduleSymbol = allPotentialModules_1[_a]; context.cancellationToken.throwIfCancellationRequested(); @@ -62931,10 +63695,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 235) { + if (node.kind === 236) { return node; } - if (node.kind === 234) { + if (node.kind === 235) { return node; } node = node.parent; @@ -62952,7 +63716,7 @@ var ts; var declarations = symbol.getDeclarations(); return declarations ? ts.some(symbol.declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }) : false; } - function getCodeActionForImport(moduleSymbol, isDefault) { + function getCodeActionForImport(moduleSymbol, isDefault, isNamespaceImport) { var existingDeclarations = getImportDeclarations(moduleSymbol); if (existingDeclarations.length > 0) { return getCodeActionsForExistingImport(existingDeclarations); @@ -62967,9 +63731,9 @@ var ts; var existingModuleSpecifier; for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { var declaration = declarations_11[_i]; - if (declaration.kind === 235) { + if (declaration.kind === 236) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 237) { + if (namedBindings && namedBindings.kind === 238) { namespaceImportDeclaration = declaration; } else { @@ -62985,7 +63749,7 @@ var ts; if (namespaceImportDeclaration) { actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); } - if (namedImportDeclaration && namedImportDeclaration.importClause && + if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause && (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { var textChange = getTextChangeForImportClause(namedImportDeclaration.importClause); var moduleSpecifierWithoutQuotes = ts.stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); @@ -62996,7 +63760,7 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 245) { + if (declaration.moduleReference && declaration.moduleReference.kind === 246) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); @@ -63029,7 +63793,7 @@ var ts; } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 235) { + if (declaration.kind === 236) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -63055,7 +63819,9 @@ var ts; var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); var importStatementText = isDefault ? "import " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" - : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; + : isNamespaceImport + ? "import * as " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" + : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; var newText = cachedNewImportInsertPosition === sourceFile.getStart() ? importStatementText + ";" + context.newLineCharacter + context.newLineCharacter : "" + context.newLineCharacter + importStatementText + ";"; @@ -63072,7 +63838,7 @@ var ts; tryGetModuleNameAsNodeModule() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 261) { + if (moduleSymbol.valueDeclaration.kind !== 262) { return moduleSymbol.name; } } @@ -63085,6 +63851,7 @@ var ts; if (!relativeName) { return undefined; } + var relativeNameWithIndex = ts.removeFileExtension(relativeName); relativeName = removeExtensionAndIndexPostFix(relativeName); if (options.paths) { for (var key in options.paths) { @@ -63104,7 +63871,7 @@ var ts; return key.replace("\*", matchedStar); } } - else if (pattern === relativeName) { + else if (pattern === relativeName || pattern === relativeNameWithIndex) { return key; } } @@ -63223,144 +63990,120 @@ var ts; (function (ts) { var codefix; (function (codefix) { - codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics._0_is_declared_but_never_used.code, - ts.Diagnostics.Property_0_is_declared_but_never_used.code - ], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var start = context.span.start; - var token = ts.getTokenAtPosition(sourceFile, start); - if (token.kind === 20) { - token = ts.getTokenAtPosition(sourceFile, start + 1); - } - switch (token.kind) { - case 70: - switch (token.parent.kind) { - case 223: - switch (token.parent.parent.parent.kind) { - case 211: - var forStatement = token.parent.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); - } - else { - return removeSingleItem(forInitializer.declarations, token); - } - case 213: - var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 224) { - var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); - } - break; - case 212: - return undefined; - case 256: - var catchClause = token.parent.parent; - var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); - default: - var variableStatement = token.parent.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); - } - else { - var declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); - } - } - case 143: - var typeParameters = token.parent.parent.typeParameters; - if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); - } - else { - return removeSingleItem(typeParameters, token); - } - case 144: - var functionDeclaration = token.parent.parent; - if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else { - return removeSingleItem(functionDeclaration.parameters, token); - } - case 234: - var importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); - case 239: - var namedImports = token.parent.parent; - if (namedImports.elements.length === 1) { - var importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); - } - else { - return removeSingleItem(namedImports.elements, token); - } - case 236: - var importClause = token.parent; - if (!importClause.namedBindings) { - var importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); - } - case 237: - var namespaceImport = token.parent; - if (namespaceImport.name == token && !namespaceImport.parent.name) { - var importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - var start_4 = namespaceImport.parent.name.end; - return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); - } - } - break; - case 147: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case 237: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - if (ts.isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); - } - else { - return undefined; - } - function findImportDeclaration(token) { - var importDecl = token; - while (importDecl.kind != 235 && importDecl.parent) { - importDecl = importDecl.parent; + function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { + var classMembers = classDeclaration.symbol.members; + var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !(symbol.getName() in classMembers); }); + var insertion = ""; + for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { + var symbol = missingMembers_1[_i]; + insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + } + return insertion; + } + codefix.getMissingMembersInsertion = getMissingMembersInsertion; + function getInsertionForMemberSymbol(symbol, enclosingDeclaration, checker, newlineChar) { + var type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + var declarations = symbol.getDeclarations(); + if (!(declarations && declarations.length)) { + return ""; + } + var declaration = declarations[0]; + var name = declaration.name ? declaration.name.getText() : undefined; + var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); + switch (declaration.kind) { + case 151: + case 152: + case 146: + case 147: + var typeString = checker.typeToString(type, enclosingDeclaration, 0); + return "" + visibility + name + ": " + typeString + ";" + newlineChar; + case 148: + case 149: + var signatures = checker.getSignaturesOfType(type, 0); + if (!(signatures && signatures.length > 0)) { + return ""; } - return importDecl; - } - function createCodeFix(newText, start, length) { - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText: newText, span: { start: start, length: length } }] - }] - }]; - } - function removeSingleItem(elements, token) { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + if (declarations.length === 1) { + ts.Debug.assert(signatures.length === 1); + var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048, 0); + return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar); + } + var result = ""; + for (var i = 0; i < signatures.length; i++) { + var sigString_2 = checker.signatureToString(signatures[i], enclosingDeclaration, 2048, 0); + result += "" + visibility + name + sigString_2 + ";" + newlineChar; + } + var bodySig = undefined; + if (declarations.length > signatures.length) { + bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); } else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + ts.Debug.assert(declarations.length === signatures.length); + bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); } + var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048, 0); + result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar); + return result; + default: + return ""; + } + } + function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { + var newSignatureDeclaration = ts.createNode(153); + newSignatureDeclaration.parent = enclosingDeclaration; + newSignatureDeclaration.name = signatures[0].getDeclaration().name; + var maxNonRestArgs = -1; + var maxArgsIndex = 0; + var minArgumentCount = signatures[0].minArgumentCount; + var hasRestParameter = false; + for (var i = 0; i < signatures.length; i++) { + var sig = signatures[i]; + minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); + hasRestParameter = hasRestParameter || sig.hasRestParameter; + var nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); + if (nonRestLength > maxNonRestArgs) { + maxNonRestArgs = nonRestLength; + maxArgsIndex = i; } } - }); + var maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(function (symbol) { return symbol.getName(); }); + var optionalToken = ts.createToken(54); + newSignatureDeclaration.parameters = ts.createNodeArray(); + for (var i = 0; i < maxNonRestArgs; i++) { + var newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); + newSignatureDeclaration.parameters.push(newParameter); + } + if (hasRestParameter) { + var restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); + restParameter.dotDotDotToken = ts.createToken(23); + newSignatureDeclaration.parameters.push(restParameter); + } + return checker.getSignatureFromDeclaration(newSignatureDeclaration); + function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { + var newParameter = ts.createNode(144); + newParameter.symbol = new SymbolConstructor(1, maxArgsParameterSymbolNames[index] || "rest"); + newParameter.symbol.valueDeclaration = newParameter; + newParameter.symbol.declarations = [newParameter]; + newParameter.parent = enclosingSignatureDeclaration; + if (index >= minArgCount) { + newParameter.questionToken = optionalToken; + } + return newParameter; + } + } + function getMethodBodyStub(newLineChar) { + return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar; + } + function getVisibilityPrefix(flags) { + if (flags & 4) { + return "public "; + } + else if (flags & 16) { + return "protected "; + } + return ""; + } + var SymbolConstructor = ts.objectAllocator.getSymbolConstructor(); })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; @@ -63425,7 +64168,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(292, nodes.pos, nodes.end, this); + var list = createNode(293, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -63448,7 +64191,7 @@ var ts; ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 278 && this.kind <= 291; + var useJSDocScanner_1 = this.kind >= 279 && this.kind <= 292; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -63721,9 +64464,9 @@ var ts; } function getDeclarationName(declaration) { if (declaration.name) { - var result_7 = getTextOfIdentifierOrLiteral(declaration.name); - if (result_7 !== undefined) { - return result_7; + var result_8 = getTextOfIdentifierOrLiteral(declaration.name); + if (result_8 !== undefined) { + return result_8; } if (declaration.name.kind === 142) { var expr = declaration.name.expression; @@ -63747,7 +64490,7 @@ var ts; } function visit(node) { switch (node.kind) { - case 225: + case 226: case 184: case 149: case 148: @@ -63767,18 +64510,18 @@ var ts; } ts.forEachChild(node, visit); break; - case 226: - case 197: case 227: + case 197: case 228: case 229: case 230: - case 234: - case 243: - case 239: - case 234: - case 236: + case 231: + case 235: + case 244: + case 240: + case 235: case 237: + case 238: case 151: case 152: case 161: @@ -63789,7 +64532,7 @@ var ts; if (!ts.hasModifier(node, 92)) { break; } - case 223: + case 224: case 174: { var decl = node; if (ts.isBindingPattern(decl.name)) { @@ -63799,24 +64542,24 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 260: + case 261: case 147: case 146: addDeclaration(node); break; - case 241: + case 242: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 235: + case 236: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237) { + if (importClause.namedBindings.kind === 238) { addDeclaration(importClause.namedBindings); } else { @@ -64411,7 +65154,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 230 && + if (nodeForStartPos.parent.parent.kind === 231 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -64600,7 +65343,7 @@ var ts; continue; } var descriptor = undefined; - for (var i = 0, n = descriptors.length; i < n; i++) { + for (var i = 0; i < descriptors.length; i++) { if (matchArray[i + firstDescriptorCaptureIndex]) { descriptor = descriptors[i]; } @@ -64709,7 +65452,7 @@ var ts; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 245 || + node.parent.kind === 246 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -64745,6 +65488,1074 @@ var ts; initializeServices(); })(ts || (ts = {})); var ts; +(function (ts) { + var server; + (function (server) { + server.ActionSet = "action::set"; + server.ActionInvalidate = "action::invalidate"; + server.EventBeginInstallTypes = "event::beginInstallTypes"; + server.EventEndInstallTypes = "event::endInstallTypes"; + var Arguments; + (function (Arguments) { + Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation"; + Arguments.LogFile = "--logFile"; + Arguments.EnableTelemetry = "--enableTelemetry"; + })(Arguments = server.Arguments || (server.Arguments = {})); + function hasArgument(argumentName) { + return ts.sys.args.indexOf(argumentName) >= 0; + } + server.hasArgument = hasArgument; + function findArgument(argumentName) { + var index = ts.sys.args.indexOf(argumentName); + return index >= 0 && index < ts.sys.args.length - 1 + ? ts.sys.args[index + 1] + : undefined; + } + server.findArgument = findArgument; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var LogLevel; + (function (LogLevel) { + LogLevel[LogLevel["terse"] = 0] = "terse"; + LogLevel[LogLevel["normal"] = 1] = "normal"; + LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; + LogLevel[LogLevel["verbose"] = 3] = "verbose"; + })(LogLevel = server.LogLevel || (server.LogLevel = {})); + server.emptyArray = []; + var Msg; + (function (Msg) { + Msg.Err = "Err"; + Msg.Info = "Info"; + Msg.Perf = "Perf"; + })(Msg = server.Msg || (server.Msg = {})); + function getProjectRootPath(project) { + switch (project.projectKind) { + case server.ProjectKind.Configured: + return ts.getDirectoryPath(project.getProjectName()); + case server.ProjectKind.Inferred: + return ""; + case server.ProjectKind.External: + var projectName = ts.normalizeSlashes(project.getProjectName()); + return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; + } + } + function createInstallTypingsRequest(project, typeAcquisition, unresolvedImports, cachePath) { + return { + projectName: project.getProjectName(), + fileNames: project.getFileNames(true), + compilerOptions: project.getCompilerOptions(), + typeAcquisition: typeAcquisition, + unresolvedImports: unresolvedImports, + projectRootPath: getProjectRootPath(project), + cachePath: cachePath, + kind: "discover" + }; + } + server.createInstallTypingsRequest = createInstallTypingsRequest; + var Errors; + (function (Errors) { + function ThrowNoProject() { + throw new Error("No Project."); + } + Errors.ThrowNoProject = ThrowNoProject; + function ThrowProjectLanguageServiceDisabled() { + throw new Error("The project's language service is disabled."); + } + Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; + function ThrowProjectDoesNotContainDocument(fileName, project) { + throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + } + Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; + })(Errors = server.Errors || (server.Errors = {})); + function getDefaultFormatCodeSettings(host) { + return { + indentSize: 4, + tabSize: 4, + newLineCharacter: host.newLine || "\n", + convertTabsToSpaces: true, + indentStyle: ts.IndentStyle.Smart, + insertSpaceAfterConstructor: false, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + insertSpaceBeforeFunctionParenthesis: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false, + }; + } + server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; + function mergeMaps(target, source) { + for (var key in source) { + if (ts.hasProperty(source, key)) { + target[key] = source[key]; + } + } + } + server.mergeMaps = mergeMaps; + function removeItemFromSet(items, itemToRemove) { + if (items.length === 0) { + return; + } + var index = items.indexOf(itemToRemove); + if (index < 0) { + return; + } + if (index === items.length - 1) { + items.pop(); + } + else { + items[index] = items.pop(); + } + } + server.removeItemFromSet = removeItemFromSet; + function toNormalizedPath(fileName) { + return ts.normalizePath(fileName); + } + server.toNormalizedPath = toNormalizedPath; + function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { + var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); + return getCanonicalFileName(f); + } + server.normalizedPathToPath = normalizedPathToPath; + function asNormalizedPath(fileName) { + return fileName; + } + server.asNormalizedPath = asNormalizedPath; + function createNormalizedPathMap() { + var map = Object.create(null); + return { + get: function (path) { + return map[path]; + }, + set: function (path, value) { + map[path] = value; + }, + contains: function (path) { + return ts.hasProperty(map, path); + }, + remove: function (path) { + delete map[path]; + } + }; + } + server.createNormalizedPathMap = createNormalizedPathMap; + function isInferredProjectName(name) { + return /dev\/null\/inferredProject\d+\*/.test(name); + } + server.isInferredProjectName = isInferredProjectName; + function makeInferredProjectName(counter) { + return "/dev/null/inferredProject" + counter + "*"; + } + server.makeInferredProjectName = makeInferredProjectName; + function toSortedReadonlyArray(arr) { + arr.sort(); + return arr; + } + server.toSortedReadonlyArray = toSortedReadonlyArray; + var ThrottledOperations = (function () { + function ThrottledOperations(host) { + this.host = host; + this.pendingTimeouts = ts.createMap(); + } + ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { + if (ts.hasProperty(this.pendingTimeouts, operationId)) { + this.host.clearTimeout(this.pendingTimeouts[operationId]); + } + this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); + }; + ThrottledOperations.run = function (self, operationId, cb) { + delete self.pendingTimeouts[operationId]; + cb(); + }; + return ThrottledOperations; + }()); + server.ThrottledOperations = ThrottledOperations; + var GcTimer = (function () { + function GcTimer(host, delay, logger) { + this.host = host; + this.delay = delay; + this.logger = logger; + } + GcTimer.prototype.scheduleCollect = function () { + if (!this.host.gc || this.timerId != undefined) { + return; + } + this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); + }; + GcTimer.run = function (self) { + self.timerId = undefined; + var log = self.logger.hasLevel(LogLevel.requestTime); + var before = log && self.host.getMemoryUsage(); + self.host.gc(); + if (log) { + var after = self.host.getMemoryUsage(); + self.logger.perftrc("GC::before " + before + ", after " + after); + } + }; + return GcTimer; + }()); + server.GcTimer = GcTimer; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var lineCollectionCapacity = 4; + var CharRangeSection; + (function (CharRangeSection) { + CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; + CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; + CharRangeSection[CharRangeSection["Entire"] = 2] = "Entire"; + CharRangeSection[CharRangeSection["Mid"] = 3] = "Mid"; + CharRangeSection[CharRangeSection["End"] = 4] = "End"; + CharRangeSection[CharRangeSection["PostEnd"] = 5] = "PostEnd"; + })(CharRangeSection = server.CharRangeSection || (server.CharRangeSection = {})); + var BaseLineIndexWalker = (function () { + function BaseLineIndexWalker() { + this.goSubtree = true; + this.done = false; + } + BaseLineIndexWalker.prototype.leaf = function (_rangeStart, _rangeLength, _ll) { + }; + return BaseLineIndexWalker; + }()); + var EditWalker = (function (_super) { + __extends(EditWalker, _super); + function EditWalker() { + var _this = _super.call(this) || this; + _this.lineIndex = new LineIndex(); + _this.endBranch = []; + _this.state = CharRangeSection.Entire; + _this.initialText = ""; + _this.trailingText = ""; + _this.suppressTrailingText = false; + _this.lineIndex.root = new LineNode(); + _this.startPath = [_this.lineIndex.root]; + _this.stack = [_this.lineIndex.root]; + return _this; + } + EditWalker.prototype.insertLines = function (insertedText) { + if (this.suppressTrailingText) { + this.trailingText = ""; + } + if (insertedText) { + insertedText = this.initialText + insertedText + this.trailingText; + } + else { + insertedText = this.initialText + this.trailingText; + } + var lm = LineIndex.linesFromText(insertedText); + var lines = lm.lines; + if (lines.length > 1) { + if (lines[lines.length - 1] == "") { + lines.length--; + } + } + var branchParent; + var lastZeroCount; + for (var k = this.endBranch.length - 1; k >= 0; k--) { + this.endBranch[k].updateCounts(); + if (this.endBranch[k].charCount() === 0) { + lastZeroCount = this.endBranch[k]; + if (k > 0) { + branchParent = this.endBranch[k - 1]; + } + else { + branchParent = this.branchNode; + } + } + } + if (lastZeroCount) { + branchParent.remove(lastZeroCount); + } + var insertionNode = this.startPath[this.startPath.length - 2]; + var leafNode = this.startPath[this.startPath.length - 1]; + var len = lines.length; + if (len > 0) { + leafNode.text = lines[0]; + if (len > 1) { + var insertedNodes = new Array(len - 1); + var startNode = leafNode; + for (var i = 1; i < lines.length; i++) { + insertedNodes[i - 1] = new LineLeaf(lines[i]); + } + var pathIndex = this.startPath.length - 2; + while (pathIndex >= 0) { + insertionNode = this.startPath[pathIndex]; + insertedNodes = insertionNode.insertAt(startNode, insertedNodes); + pathIndex--; + startNode = insertionNode; + } + var insertedNodesLen = insertedNodes.length; + while (insertedNodesLen > 0) { + var newRoot = new LineNode(); + newRoot.add(this.lineIndex.root); + insertedNodes = newRoot.insertAt(this.lineIndex.root, insertedNodes); + insertedNodesLen = insertedNodes.length; + this.lineIndex.root = newRoot; + } + this.lineIndex.root.updateCounts(); + } + else { + for (var j = this.startPath.length - 2; j >= 0; j--) { + this.startPath[j].updateCounts(); + } + } + } + else { + insertionNode.remove(leafNode); + for (var j = this.startPath.length - 2; j >= 0; j--) { + this.startPath[j].updateCounts(); + } + } + return this.lineIndex; + }; + EditWalker.prototype.post = function (_relativeStart, _relativeLength, lineCollection) { + if (lineCollection === this.lineCollectionAtBranch) { + this.state = CharRangeSection.End; + } + this.stack.length--; + return undefined; + }; + 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)) { + this.state = CharRangeSection.Start; + this.branchNode = currentNode; + this.lineCollectionAtBranch = lineCollection; + } + var child; + function fresh(node) { + if (node.isLeaf()) { + return new LineLeaf(""); + } + else + return new LineNode(); + } + switch (nodeType) { + case CharRangeSection.PreStart: + this.goSubtree = false; + if (this.state !== CharRangeSection.End) { + currentNode.add(lineCollection); + } + break; + case CharRangeSection.Start: + if (this.state === CharRangeSection.End) { + this.goSubtree = false; + } + else { + child = fresh(lineCollection); + currentNode.add(child); + this.startPath[this.startPath.length] = child; + } + break; + case CharRangeSection.Entire: + if (this.state !== CharRangeSection.End) { + child = fresh(lineCollection); + currentNode.add(child); + this.startPath[this.startPath.length] = child; + } + else { + if (!lineCollection.isLeaf()) { + child = fresh(lineCollection); + currentNode.add(child); + this.endBranch[this.endBranch.length] = child; + } + } + break; + case CharRangeSection.Mid: + this.goSubtree = false; + break; + case CharRangeSection.End: + if (this.state !== CharRangeSection.End) { + this.goSubtree = false; + } + else { + if (!lineCollection.isLeaf()) { + child = fresh(lineCollection); + currentNode.add(child); + this.endBranch[this.endBranch.length] = child; + } + } + break; + case CharRangeSection.PostEnd: + this.goSubtree = false; + if (this.state !== CharRangeSection.Start) { + currentNode.add(lineCollection); + } + break; + } + if (this.goSubtree) { + this.stack[this.stack.length] = child; + } + return lineCollection; + }; + EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { + if (this.state === CharRangeSection.Start) { + this.initialText = ll.text.substring(0, relativeStart); + } + else if (this.state === CharRangeSection.Entire) { + this.initialText = ll.text.substring(0, relativeStart); + this.trailingText = ll.text.substring(relativeStart + relativeLength); + } + else { + this.trailingText = ll.text.substring(relativeStart + relativeLength); + } + }; + return EditWalker; + }(BaseLineIndexWalker)); + var TextChange = (function () { + function TextChange(pos, deleteLen, insertedText) { + this.pos = pos; + this.deleteLen = deleteLen; + this.insertedText = insertedText; + } + TextChange.prototype.getTextChangeRange = function () { + return ts.createTextChangeRange(ts.createTextSpan(this.pos, this.deleteLen), this.insertedText ? this.insertedText.length : 0); + }; + return TextChange; + }()); + server.TextChange = TextChange; + var ScriptVersionCache = (function () { + function ScriptVersionCache() { + this.changes = []; + this.versions = new Array(ScriptVersionCache.maxVersions); + this.minVersion = 0; + this.currentVersion = 0; + } + ScriptVersionCache.prototype.versionToIndex = function (version) { + if (version < this.minVersion || version > this.currentVersion) { + return undefined; + } + return version % ScriptVersionCache.maxVersions; + }; + ScriptVersionCache.prototype.currentVersionToIndex = function () { + return this.currentVersion % ScriptVersionCache.maxVersions; + }; + ScriptVersionCache.prototype.edit = function (pos, deleteLen, insertedText) { + this.changes[this.changes.length] = new TextChange(pos, deleteLen, insertedText); + if ((this.changes.length > ScriptVersionCache.changeNumberThreshold) || + (deleteLen > ScriptVersionCache.changeLengthThreshold) || + (insertedText && (insertedText.length > ScriptVersionCache.changeLengthThreshold))) { + this.getSnapshot(); + } + }; + ScriptVersionCache.prototype.latest = function () { + return this.versions[this.currentVersionToIndex()]; + }; + ScriptVersionCache.prototype.latestVersion = function () { + if (this.changes.length > 0) { + this.getSnapshot(); + } + return this.currentVersion; + }; + ScriptVersionCache.prototype.reloadFromFile = function (filename) { + var content = this.host.readFile(filename); + if (!content) { + content = ""; + } + this.reload(content); + }; + ScriptVersionCache.prototype.reload = function (script) { + this.currentVersion++; + this.changes = []; + var snap = new LineIndexSnapshot(this.currentVersion, this); + for (var i = 0; i < this.versions.length; i++) { + this.versions[i] = undefined; + } + this.versions[this.currentVersionToIndex()] = snap; + snap.index = new LineIndex(); + var lm = LineIndex.linesFromText(script); + snap.index.load(lm.lines); + this.minVersion = this.currentVersion; + }; + ScriptVersionCache.prototype.getSnapshot = function () { + var snap = this.versions[this.currentVersionToIndex()]; + if (this.changes.length > 0) { + var snapIndex = snap.index; + for (var _i = 0, _a = this.changes; _i < _a.length; _i++) { + var change = _a[_i]; + snapIndex = snapIndex.edit(change.pos, change.deleteLen, change.insertedText); + } + snap = new LineIndexSnapshot(this.currentVersion + 1, this); + snap.index = snapIndex; + snap.changesSincePreviousVersion = this.changes; + this.currentVersion = snap.version; + this.versions[this.currentVersionToIndex()] = snap; + this.changes = []; + if ((this.currentVersion - this.minVersion) >= ScriptVersionCache.maxVersions) { + this.minVersion = (this.currentVersion - ScriptVersionCache.maxVersions) + 1; + } + } + return snap; + }; + ScriptVersionCache.prototype.getTextChangesBetweenVersions = function (oldVersion, newVersion) { + if (oldVersion < newVersion) { + if (oldVersion >= this.minVersion) { + var textChangeRanges = []; + for (var i = oldVersion + 1; i <= newVersion; i++) { + var snap = this.versions[this.versionToIndex(i)]; + for (var _i = 0, _a = snap.changesSincePreviousVersion; _i < _a.length; _i++) { + var textChange = _a[_i]; + textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); + } + } + return ts.collapseTextChangeRangesAcrossMultipleVersions(textChangeRanges); + } + else { + return undefined; + } + } + else { + return ts.unchangedTextChangeRange; + } + }; + 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); + return svc; + }; + return ScriptVersionCache; + }()); + ScriptVersionCache.changeNumberThreshold = 8; + ScriptVersionCache.changeLengthThreshold = 256; + ScriptVersionCache.maxVersions = 8; + server.ScriptVersionCache = ScriptVersionCache; + var LineIndexSnapshot = (function () { + function LineIndexSnapshot(version, cache) { + this.version = version; + this.cache = cache; + this.changesSincePreviousVersion = []; + } + LineIndexSnapshot.prototype.getText = function (rangeStart, rangeEnd) { + return this.index.getText(rangeStart, rangeEnd - rangeStart); + }; + LineIndexSnapshot.prototype.getLength = function () { + return this.index.root.charCount(); + }; + LineIndexSnapshot.prototype.getLineStartPositions = function () { + var starts = [-1]; + var count = 1; + var pos = 0; + this.index.every(function (ll) { + starts[count] = pos; + count++; + pos += ll.text.length; + return true; + }, 0); + return starts; + }; + LineIndexSnapshot.prototype.getLineMapper = function () { + var _this = this; + return function (line) { + return _this.index.lineNumberToInfo(line).offset; + }; + }; + LineIndexSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { + if (this.version <= scriptVersion) { + return ts.unchangedTextChangeRange; + } + else { + return this.cache.getTextChangesBetweenVersions(scriptVersion, this.version); + } + }; + LineIndexSnapshot.prototype.getChangeRange = function (oldSnapshot) { + if (oldSnapshot instanceof LineIndexSnapshot && this.cache === oldSnapshot.cache) { + return this.getTextChangeRangeSinceVersion(oldSnapshot.version); + } + }; + return LineIndexSnapshot; + }()); + server.LineIndexSnapshot = LineIndexSnapshot; + var LineIndex = (function () { + function LineIndex() { + this.checkEdits = false; + } + LineIndex.prototype.charOffsetToLineNumberAndPos = function (charOffset) { + return this.root.charOffsetToLineNumberAndPos(1, charOffset); + }; + LineIndex.prototype.lineNumberToInfo = function (lineNumber) { + var lineCount = this.root.lineCount(); + if (lineNumber <= lineCount) { + var lineInfo = this.root.lineNumberToInfo(lineNumber, 0); + lineInfo.line = lineNumber; + return lineInfo; + } + else { + return { + line: lineNumber, + offset: this.root.charCount() + }; + } + }; + LineIndex.prototype.load = function (lines) { + if (lines.length > 0) { + var leaves = []; + for (var i = 0; i < lines.length; i++) { + leaves[i] = new LineLeaf(lines[i]); + } + this.root = LineIndex.buildTreeFromBottom(leaves); + } + else { + this.root = new LineNode(); + } + }; + LineIndex.prototype.walk = function (rangeStart, rangeLength, walkFns) { + this.root.walk(rangeStart, rangeLength, walkFns); + }; + LineIndex.prototype.getText = function (rangeStart, rangeLength) { + var accum = ""; + if ((rangeLength > 0) && (rangeStart < this.root.charCount())) { + this.walk(rangeStart, rangeLength, { + goSubtree: true, + done: false, + leaf: function (relativeStart, relativeLength, ll) { + accum = accum.concat(ll.text.substring(relativeStart, relativeStart + relativeLength)); + } + }); + } + return accum; + }; + LineIndex.prototype.getLength = function () { + return this.root.charCount(); + }; + LineIndex.prototype.every = function (f, rangeStart, rangeEnd) { + if (!rangeEnd) { + rangeEnd = this.root.charCount(); + } + var walkFns = { + goSubtree: true, + done: false, + leaf: function (relativeStart, relativeLength, ll) { + if (!f(ll, relativeStart, relativeLength)) { + this.done = true; + } + } + }; + this.walk(rangeStart, rangeEnd - rangeStart, walkFns); + return !walkFns.done; + }; + LineIndex.prototype.edit = function (pos, deleteLength, newText) { + function editFlat(source, s, dl, nt) { + if (nt === void 0) { nt = ""; } + return source.substring(0, s) + nt + source.substring(s + dl, source.length); + } + if (this.root.charCount() === 0) { + if (newText !== undefined) { + this.load(LineIndex.linesFromText(newText).lines); + return this; + } + } + else { + var checkText = void 0; + if (this.checkEdits) { + checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText); + } + var walker = new EditWalker(); + if (pos >= this.root.charCount()) { + pos = this.root.charCount() - 1; + var endString = this.getText(pos, 1); + if (newText) { + newText = endString + newText; + } + else { + newText = endString; + } + deleteLength = 0; + walker.suppressTrailingText = true; + } + else if (deleteLength > 0) { + var e = pos + deleteLength; + var lineInfo = this.charOffsetToLineNumberAndPos(e); + if ((lineInfo && (lineInfo.offset === 0))) { + deleteLength += lineInfo.text.length; + if (newText) { + newText = newText + lineInfo.text; + } + else { + newText = lineInfo.text; + } + } + } + if (pos < this.root.charCount()) { + this.root.walk(pos, deleteLength, walker); + walker.insertLines(newText); + } + if (this.checkEdits) { + var updatedText = this.getText(0, this.root.charCount()); + ts.Debug.assert(checkText == updatedText, "buffer edit mismatch"); + } + return walker.lineIndex; + } + }; + LineIndex.buildTreeFromBottom = function (nodes) { + var nodeCount = Math.ceil(nodes.length / lineCollectionCapacity); + var interiorNodes = []; + var nodeIndex = 0; + for (var i = 0; i < nodeCount; i++) { + interiorNodes[i] = new LineNode(); + var charCount = 0; + var lineCount = 0; + for (var j = 0; j < lineCollectionCapacity; j++) { + if (nodeIndex < nodes.length) { + interiorNodes[i].add(nodes[nodeIndex]); + charCount += nodes[nodeIndex].charCount(); + lineCount += nodes[nodeIndex].lineCount(); + } + else { + break; + } + nodeIndex++; + } + interiorNodes[i].totalChars = charCount; + interiorNodes[i].totalLines = lineCount; + } + if (interiorNodes.length === 1) { + return interiorNodes[0]; + } + else { + return this.buildTreeFromBottom(interiorNodes); + } + }; + LineIndex.linesFromText = function (text) { + var lineStarts = ts.computeLineStarts(text); + if (lineStarts.length === 0) { + return { lines: [], lineMap: lineStarts }; + } + var lines = new Array(lineStarts.length); + var lc = lineStarts.length - 1; + for (var lmi = 0; lmi < lc; lmi++) { + lines[lmi] = text.substring(lineStarts[lmi], lineStarts[lmi + 1]); + } + var endText = text.substring(lineStarts[lc]); + if (endText.length > 0) { + lines[lc] = endText; + } + else { + lines.length--; + } + return { lines: lines, lineMap: lineStarts }; + }; + return LineIndex; + }()); + server.LineIndex = LineIndex; + var LineNode = (function () { + function LineNode() { + this.totalChars = 0; + this.totalLines = 0; + this.children = []; + } + LineNode.prototype.isLeaf = function () { + return false; + }; + LineNode.prototype.updateCounts = function () { + this.totalChars = 0; + this.totalLines = 0; + for (var _i = 0, _a = this.children; _i < _a.length; _i++) { + var child = _a[_i]; + this.totalChars += child.charCount(); + this.totalLines += child.lineCount(); + } + }; + LineNode.prototype.execWalk = function (rangeStart, rangeLength, walkFns, childIndex, nodeType) { + if (walkFns.pre) { + walkFns.pre(rangeStart, rangeLength, this.children[childIndex], this, nodeType); + } + if (walkFns.goSubtree) { + this.children[childIndex].walk(rangeStart, rangeLength, walkFns); + if (walkFns.post) { + walkFns.post(rangeStart, rangeLength, this.children[childIndex], this, nodeType); + } + } + else { + walkFns.goSubtree = true; + } + return walkFns.done; + }; + LineNode.prototype.skipChild = function (relativeStart, relativeLength, childIndex, walkFns, nodeType) { + if (walkFns.pre && (!walkFns.done)) { + walkFns.pre(relativeStart, relativeLength, this.children[childIndex], this, nodeType); + walkFns.goSubtree = true; + } + }; + LineNode.prototype.walk = function (rangeStart, rangeLength, walkFns) { + var childIndex = 0; + var child = this.children[0]; + var childCharCount = child.charCount(); + var adjustedStart = rangeStart; + while (adjustedStart >= childCharCount) { + this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, CharRangeSection.PreStart); + adjustedStart -= childCharCount; + childIndex++; + child = this.children[childIndex]; + childCharCount = child.charCount(); + } + if ((adjustedStart + rangeLength) <= childCharCount) { + if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, CharRangeSection.Entire)) { + return; + } + } + else { + if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, CharRangeSection.Start)) { + return; + } + var adjustedLength = rangeLength - (childCharCount - adjustedStart); + childIndex++; + child = this.children[childIndex]; + childCharCount = child.charCount(); + while (adjustedLength > childCharCount) { + if (this.execWalk(0, childCharCount, walkFns, childIndex, CharRangeSection.Mid)) { + return; + } + adjustedLength -= childCharCount; + childIndex++; + child = this.children[childIndex]; + childCharCount = child.charCount(); + } + if (adjustedLength > 0) { + if (this.execWalk(0, adjustedLength, walkFns, childIndex, CharRangeSection.End)) { + return; + } + } + } + if (walkFns.pre) { + var clen = this.children.length; + if (childIndex < (clen - 1)) { + for (var ej = childIndex + 1; ej < clen; ej++) { + this.skipChild(0, 0, ej, walkFns, CharRangeSection.PostEnd); + } + } + } + }; + LineNode.prototype.charOffsetToLineNumberAndPos = function (lineNumber, charOffset) { + var childInfo = this.childFromCharOffset(lineNumber, charOffset); + if (!childInfo.child) { + return { + line: lineNumber, + offset: charOffset, + }; + } + else if (childInfo.childIndex < this.children.length) { + if (childInfo.child.isLeaf()) { + return { + line: childInfo.lineNumber, + offset: childInfo.charOffset, + text: (childInfo.child).text, + leaf: (childInfo.child) + }; + } + else { + var lineNode = (childInfo.child); + return lineNode.charOffsetToLineNumberAndPos(childInfo.lineNumber, childInfo.charOffset); + } + } + else { + var lineInfo = this.lineNumberToInfo(this.lineCount(), 0); + return { line: this.lineCount(), offset: lineInfo.leaf.charCount() }; + } + }; + LineNode.prototype.lineNumberToInfo = function (lineNumber, charOffset) { + var childInfo = this.childFromLineNumber(lineNumber, charOffset); + if (!childInfo.child) { + return { + line: lineNumber, + offset: charOffset + }; + } + else if (childInfo.child.isLeaf()) { + return { + line: lineNumber, + offset: childInfo.charOffset, + text: (childInfo.child).text, + leaf: (childInfo.child) + }; + } + else { + var lineNode = (childInfo.child); + return lineNode.lineNumberToInfo(childInfo.relativeLineNumber, childInfo.charOffset); + } + }; + LineNode.prototype.childFromLineNumber = function (lineNumber, charOffset) { + var child; + var relativeLineNumber = lineNumber; + var i; + var len; + for (i = 0, len = this.children.length; i < len; i++) { + child = this.children[i]; + var childLineCount = child.lineCount(); + if (childLineCount >= relativeLineNumber) { + break; + } + else { + relativeLineNumber -= childLineCount; + charOffset += child.charCount(); + } + } + return { + child: child, + childIndex: i, + relativeLineNumber: relativeLineNumber, + charOffset: charOffset + }; + }; + LineNode.prototype.childFromCharOffset = function (lineNumber, charOffset) { + var child; + var i; + var len; + for (i = 0, len = this.children.length; i < len; i++) { + child = this.children[i]; + if (child.charCount() > charOffset) { + break; + } + else { + charOffset -= child.charCount(); + lineNumber += child.lineCount(); + } + } + return { + child: child, + childIndex: i, + charOffset: charOffset, + lineNumber: lineNumber + }; + }; + LineNode.prototype.splitAfter = function (childIndex) { + var splitNode; + var clen = this.children.length; + childIndex++; + var endLength = childIndex; + if (childIndex < clen) { + splitNode = new LineNode(); + while (childIndex < clen) { + splitNode.add(this.children[childIndex]); + childIndex++; + } + splitNode.updateCounts(); + } + this.children.length = endLength; + return splitNode; + }; + LineNode.prototype.remove = function (child) { + var childIndex = this.findChildIndex(child); + var clen = this.children.length; + if (childIndex < (clen - 1)) { + for (var i = childIndex; i < (clen - 1); i++) { + this.children[i] = this.children[i + 1]; + } + } + this.children.length--; + }; + LineNode.prototype.findChildIndex = function (child) { + var childIndex = 0; + var clen = this.children.length; + while ((this.children[childIndex] !== child) && (childIndex < clen)) + childIndex++; + return childIndex; + }; + LineNode.prototype.insertAt = function (child, nodes) { + var childIndex = this.findChildIndex(child); + var clen = this.children.length; + var nodeCount = nodes.length; + if ((clen < lineCollectionCapacity) && (childIndex === (clen - 1)) && (nodeCount === 1)) { + this.add(nodes[0]); + this.updateCounts(); + return []; + } + else { + var shiftNode = this.splitAfter(childIndex); + var nodeIndex = 0; + childIndex++; + while ((childIndex < lineCollectionCapacity) && (nodeIndex < nodeCount)) { + this.children[childIndex] = nodes[nodeIndex]; + childIndex++; + nodeIndex++; + } + var splitNodes = []; + var splitNodeCount = 0; + if (nodeIndex < nodeCount) { + splitNodeCount = Math.ceil((nodeCount - nodeIndex) / lineCollectionCapacity); + splitNodes = new Array(splitNodeCount); + var splitNodeIndex = 0; + for (var i = 0; i < splitNodeCount; i++) { + splitNodes[i] = new LineNode(); + } + var splitNode = splitNodes[0]; + while (nodeIndex < nodeCount) { + splitNode.add(nodes[nodeIndex]); + nodeIndex++; + if (splitNode.children.length === lineCollectionCapacity) { + splitNodeIndex++; + splitNode = splitNodes[splitNodeIndex]; + } + } + for (var i = splitNodes.length - 1; i >= 0; i--) { + if (splitNodes[i].children.length === 0) { + splitNodes.length--; + } + } + } + if (shiftNode) { + splitNodes[splitNodes.length] = shiftNode; + } + this.updateCounts(); + for (var i = 0; i < splitNodeCount; i++) { + splitNodes[i].updateCounts(); + } + return splitNodes; + } + }; + LineNode.prototype.add = function (collection) { + this.children[this.children.length] = collection; + return (this.children.length < lineCollectionCapacity); + }; + LineNode.prototype.charCount = function () { + return this.totalChars; + }; + LineNode.prototype.lineCount = function () { + return this.totalLines; + }; + return LineNode; + }()); + server.LineNode = LineNode; + var LineLeaf = (function () { + function LineLeaf(text) { + this.text = text; + } + LineLeaf.prototype.isLeaf = function () { + return true; + }; + LineLeaf.prototype.walk = function (rangeStart, rangeLength, walkFns) { + walkFns.leaf(rangeStart, rangeLength, this); + }; + LineLeaf.prototype.charCount = function () { + return this.text.length; + }; + LineLeaf.prototype.lineCount = function () { + return 1; + }; + return LineLeaf; + }()); + server.LineLeaf = LineLeaf; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var server; (function (server) { @@ -65075,15 +66886,15 @@ var ts; var compilerOptions = this.getCompilationSettings(); var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_50 = names_2[_i]; - var resolution = newResolutions[name_50]; + var name_51 = names_2[_i]; + var resolution = newResolutions[name_51]; if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_50]; + var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_51]; if (moduleResolutionIsValid(existingResolution)) { resolution = existingResolution; } else { - newResolutions[name_50] = resolution = loader(name_50, containingFile, compilerOptions, this); + newResolutions[name_51] = resolution = loader(name_51, containingFile, compilerOptions, this); } if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { this.filesWithChangedSetOfUnresolvedImports.push(path); @@ -65123,6 +66934,9 @@ var ts; return resolution.failedLookupLocations.length === 0; } }; + LSHost.prototype.getNewLine = function () { + return this.host.newLine; + }; LSHost.prototype.getProjectVersion = function () { return this.project.getProjectVersion(); }; @@ -65309,314 +67123,6 @@ var ts; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var server; - (function (server) { - function shouldEmitFile(scriptInfo) { - return !scriptInfo.hasMixedContent; - } - server.shouldEmitFile = shouldEmitFile; - var BuilderFileInfo = (function () { - function BuilderFileInfo(scriptInfo, project) { - this.scriptInfo = scriptInfo; - this.project = project; - } - BuilderFileInfo.prototype.isExternalModuleOrHasOnlyAmbientExternalModules = function () { - var sourceFile = this.getSourceFile(); - return ts.isExternalModule(sourceFile) || this.containsOnlyAmbientModules(sourceFile); - }; - BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { - for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (statement.kind !== 230 || statement.name.kind !== 9) { - return false; - } - } - return true; - }; - BuilderFileInfo.prototype.computeHash = function (text) { - return this.project.projectService.host.createHash(text); - }; - BuilderFileInfo.prototype.getSourceFile = function () { - return this.project.getSourceFile(this.scriptInfo.path); - }; - BuilderFileInfo.prototype.updateShapeSignature = function () { - var sourceFile = this.getSourceFile(); - if (!sourceFile) { - return true; - } - var lastSignature = this.lastCheckedShapeSignature; - if (sourceFile.isDeclarationFile) { - this.lastCheckedShapeSignature = this.computeHash(sourceFile.text); - } - else { - var emitOutput = this.project.getFileEmitOutput(this.scriptInfo, true); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - this.lastCheckedShapeSignature = this.computeHash(emitOutput.outputFiles[0].text); - } - } - return !lastSignature || this.lastCheckedShapeSignature !== lastSignature; - }; - return BuilderFileInfo; - }()); - server.BuilderFileInfo = BuilderFileInfo; - var AbstractBuilder = (function () { - function AbstractBuilder(project, ctor) { - this.project = project; - this.ctor = ctor; - } - AbstractBuilder.prototype.getFileInfos = function () { - return this.fileInfos_doNotAccessDirectly || (this.fileInfos_doNotAccessDirectly = ts.createFileMap()); - }; - AbstractBuilder.prototype.clear = function () { - this.fileInfos_doNotAccessDirectly = undefined; - }; - AbstractBuilder.prototype.getFileInfo = function (path) { - return this.getFileInfos().get(path); - }; - AbstractBuilder.prototype.getOrCreateFileInfo = function (path) { - var fileInfo = this.getFileInfo(path); - if (!fileInfo) { - var scriptInfo = this.project.getScriptInfo(path); - fileInfo = new this.ctor(scriptInfo, this.project); - this.setFileInfo(path, fileInfo); - } - return fileInfo; - }; - AbstractBuilder.prototype.getFileInfoPaths = function () { - return this.getFileInfos().getKeys(); - }; - AbstractBuilder.prototype.setFileInfo = function (path, info) { - this.getFileInfos().set(path, info); - }; - AbstractBuilder.prototype.removeFileInfo = function (path) { - this.getFileInfos().remove(path); - }; - AbstractBuilder.prototype.forEachFileInfo = function (action) { - this.getFileInfos().forEachValue(function (_path, value) { return action(value); }); - }; - AbstractBuilder.prototype.emitFile = function (scriptInfo, writeFile) { - var fileInfo = this.getFileInfo(scriptInfo.path); - if (!fileInfo) { - return false; - } - var _a = this.project.getFileEmitOutput(fileInfo.scriptInfo, false), emitSkipped = _a.emitSkipped, outputFiles = _a.outputFiles; - if (!emitSkipped) { - var projectRootPath = this.project.getProjectRootPath(); - for (var _i = 0, outputFiles_1 = outputFiles; _i < outputFiles_1.length; _i++) { - var outputFile = outputFiles_1[_i]; - var outputFileAbsoluteFileName = ts.getNormalizedAbsolutePath(outputFile.name, projectRootPath ? projectRootPath : ts.getDirectoryPath(scriptInfo.fileName)); - writeFile(outputFileAbsoluteFileName, outputFile.text, outputFile.writeByteOrderMark); - } - } - return !emitSkipped; - }; - return AbstractBuilder; - }()); - var NonModuleBuilder = (function (_super) { - __extends(NonModuleBuilder, _super); - function NonModuleBuilder(project) { - var _this = _super.call(this, project, BuilderFileInfo) || this; - _this.project = project; - return _this; - } - NonModuleBuilder.prototype.onProjectUpdateGraph = function () { - }; - NonModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { - var info = this.getOrCreateFileInfo(scriptInfo.path); - var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; - if (info.updateShapeSignature()) { - var options = this.project.getCompilerOptions(); - if (options && (options.out || options.outFile)) { - return singleFileResult; - } - return this.project.getAllEmittableFiles(); - } - return singleFileResult; - }; - return NonModuleBuilder; - }(AbstractBuilder)); - var ModuleBuilderFileInfo = (function (_super) { - __extends(ModuleBuilderFileInfo, _super); - function ModuleBuilderFileInfo() { - var _this = _super.apply(this, arguments) || this; - _this.references = []; - _this.referencedBy = []; - return _this; - } - ModuleBuilderFileInfo.compareFileInfos = function (lf, rf) { - var l = lf.scriptInfo.fileName; - var r = rf.scriptInfo.fileName; - return (l < r ? -1 : (l > r ? 1 : 0)); - }; - ; - ModuleBuilderFileInfo.addToReferenceList = function (array, fileInfo) { - if (array.length === 0) { - array.push(fileInfo); - return; - } - var insertIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); - if (insertIndex < 0) { - array.splice(~insertIndex, 0, fileInfo); - } - }; - ModuleBuilderFileInfo.removeFromReferenceList = function (array, fileInfo) { - if (!array || array.length === 0) { - return; - } - if (array[0] === fileInfo) { - array.splice(0, 1); - return; - } - var removeIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); - if (removeIndex >= 0) { - array.splice(removeIndex, 1); - } - }; - ModuleBuilderFileInfo.prototype.addReferencedBy = function (fileInfo) { - ModuleBuilderFileInfo.addToReferenceList(this.referencedBy, fileInfo); - }; - ModuleBuilderFileInfo.prototype.removeReferencedBy = function (fileInfo) { - ModuleBuilderFileInfo.removeFromReferenceList(this.referencedBy, fileInfo); - }; - ModuleBuilderFileInfo.prototype.removeFileReferences = function () { - for (var _i = 0, _a = this.references; _i < _a.length; _i++) { - var reference = _a[_i]; - reference.removeReferencedBy(this); - } - this.references = []; - }; - return ModuleBuilderFileInfo; - }(BuilderFileInfo)); - var ModuleBuilder = (function (_super) { - __extends(ModuleBuilder, _super); - function ModuleBuilder(project) { - var _this = _super.call(this, project, ModuleBuilderFileInfo) || this; - _this.project = project; - return _this; - } - ModuleBuilder.prototype.clear = function () { - this.projectVersionForDependencyGraph = undefined; - _super.prototype.clear.call(this); - }; - ModuleBuilder.prototype.getReferencedFileInfos = function (fileInfo) { - var _this = this; - if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { - return []; - } - var referencedFilePaths = this.project.getReferencedFiles(fileInfo.scriptInfo.path); - if (referencedFilePaths.length > 0) { - return ts.map(referencedFilePaths, function (f) { return _this.getOrCreateFileInfo(f); }).sort(ModuleBuilderFileInfo.compareFileInfos); - } - return []; - }; - ModuleBuilder.prototype.onProjectUpdateGraph = function () { - this.ensureProjectDependencyGraphUpToDate(); - }; - ModuleBuilder.prototype.ensureProjectDependencyGraphUpToDate = function () { - var _this = this; - if (!this.projectVersionForDependencyGraph || this.project.getProjectVersion() !== this.projectVersionForDependencyGraph) { - var currentScriptInfos = this.project.getScriptInfos(); - for (var _i = 0, currentScriptInfos_1 = currentScriptInfos; _i < currentScriptInfos_1.length; _i++) { - var scriptInfo = currentScriptInfos_1[_i]; - var fileInfo = this.getOrCreateFileInfo(scriptInfo.path); - this.updateFileReferences(fileInfo); - } - this.forEachFileInfo(function (fileInfo) { - if (!_this.project.containsScriptInfo(fileInfo.scriptInfo)) { - fileInfo.removeFileReferences(); - _this.removeFileInfo(fileInfo.scriptInfo.path); - } - }); - this.projectVersionForDependencyGraph = this.project.getProjectVersion(); - } - }; - ModuleBuilder.prototype.updateFileReferences = function (fileInfo) { - if (fileInfo.scriptVersionForReferences === fileInfo.scriptInfo.getLatestVersion()) { - return; - } - var newReferences = this.getReferencedFileInfos(fileInfo); - var oldReferences = fileInfo.references; - var oldIndex = 0; - var newIndex = 0; - while (oldIndex < oldReferences.length && newIndex < newReferences.length) { - var oldReference = oldReferences[oldIndex]; - var newReference = newReferences[newIndex]; - var compare = ModuleBuilderFileInfo.compareFileInfos(oldReference, newReference); - if (compare < 0) { - oldReference.removeReferencedBy(fileInfo); - oldIndex++; - } - else if (compare > 0) { - newReference.addReferencedBy(fileInfo); - newIndex++; - } - else { - oldIndex++; - newIndex++; - } - } - for (var i = oldIndex; i < oldReferences.length; i++) { - oldReferences[i].removeReferencedBy(fileInfo); - } - for (var i = newIndex; i < newReferences.length; i++) { - newReferences[i].addReferencedBy(fileInfo); - } - fileInfo.references = newReferences; - fileInfo.scriptVersionForReferences = fileInfo.scriptInfo.getLatestVersion(); - }; - ModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { - this.ensureProjectDependencyGraphUpToDate(); - var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; - var fileInfo = this.getFileInfo(scriptInfo.path); - if (!fileInfo || !fileInfo.updateShapeSignature()) { - return singleFileResult; - } - if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { - return this.project.getAllEmittableFiles(); - } - var options = this.project.getCompilerOptions(); - if (options && (options.isolatedModules || options.out || options.outFile)) { - return singleFileResult; - } - var queue = fileInfo.referencedBy.slice(0); - var fileNameSet = ts.createMap(); - fileNameSet[scriptInfo.fileName] = scriptInfo; - while (queue.length > 0) { - var processingFileInfo = queue.pop(); - if (processingFileInfo.updateShapeSignature() && processingFileInfo.referencedBy.length > 0) { - for (var _i = 0, _a = processingFileInfo.referencedBy; _i < _a.length; _i++) { - var potentialFileInfo = _a[_i]; - if (!fileNameSet[potentialFileInfo.scriptInfo.fileName]) { - queue.push(potentialFileInfo); - } - } - } - fileNameSet[processingFileInfo.scriptInfo.fileName] = processingFileInfo.scriptInfo; - } - var result = []; - for (var fileName in fileNameSet) { - if (shouldEmitFile(fileNameSet[fileName])) { - result.push(fileName); - } - } - return result; - }; - return ModuleBuilder; - }(AbstractBuilder)); - function createBuilder(project) { - var moduleKind = project.getCompilerOptions().module; - switch (moduleKind) { - case ts.ModuleKind.None: - return new NonModuleBuilder(project); - default: - return new ModuleBuilder(project); - } - } - server.createBuilder = createBuilder; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; (function (ts) { var server; (function (server) { @@ -65802,7 +67308,7 @@ var ts; info.detachFromProject(this); } } - else { + if (!this.program || !this.languageServiceEnabled) { for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { var root = _c[_b]; root.detachFromProject(this); @@ -65948,9 +67454,9 @@ var ts; } var unresolvedImports; if (file.resolvedModules) { - for (var name_51 in file.resolvedModules) { - if (!file.resolvedModules[name_51] && !ts.isExternalModuleNameRelative(name_51)) { - var trimmed = name_51.trim(); + for (var name_52 in file.resolvedModules) { + if (!file.resolvedModules[name_52] && !ts.isExternalModuleNameRelative(name_52)) { + var trimmed = name_52.trim(); var i = trimmed.indexOf("/"); if (i !== -1 && trimmed.charCodeAt(0) === 64) { i = trimmed.indexOf("/", i + 1); @@ -68539,9 +70045,9 @@ var ts; if (simplifiedResult) { return completions.entries.reduce(function (result, entry) { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name_52 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; + var name_53 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; - result.push({ name: name_52, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); + result.push({ name: name_53, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); } return result; }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); @@ -68946,847 +70452,308 @@ var ts; (function (ts) { var server; (function (server) { - var lineCollectionCapacity = 4; - var CharRangeSection; - (function (CharRangeSection) { - CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; - CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; - CharRangeSection[CharRangeSection["Entire"] = 2] = "Entire"; - CharRangeSection[CharRangeSection["Mid"] = 3] = "Mid"; - CharRangeSection[CharRangeSection["End"] = 4] = "End"; - CharRangeSection[CharRangeSection["PostEnd"] = 5] = "PostEnd"; - })(CharRangeSection = server.CharRangeSection || (server.CharRangeSection = {})); - var BaseLineIndexWalker = (function () { - function BaseLineIndexWalker() { - this.goSubtree = true; - this.done = false; + function shouldEmitFile(scriptInfo) { + return !scriptInfo.hasMixedContent; + } + server.shouldEmitFile = shouldEmitFile; + var BuilderFileInfo = (function () { + function BuilderFileInfo(scriptInfo, project) { + this.scriptInfo = scriptInfo; + this.project = project; } - BaseLineIndexWalker.prototype.leaf = function (_rangeStart, _rangeLength, _ll) { + BuilderFileInfo.prototype.isExternalModuleOrHasOnlyAmbientExternalModules = function () { + var sourceFile = this.getSourceFile(); + return ts.isExternalModule(sourceFile) || this.containsOnlyAmbientModules(sourceFile); }; - return BaseLineIndexWalker; - }()); - var EditWalker = (function (_super) { - __extends(EditWalker, _super); - function EditWalker() { - var _this = _super.call(this) || this; - _this.lineIndex = new LineIndex(); - _this.endBranch = []; - _this.state = CharRangeSection.Entire; - _this.initialText = ""; - _this.trailingText = ""; - _this.suppressTrailingText = false; - _this.lineIndex.root = new LineNode(); - _this.startPath = [_this.lineIndex.root]; - _this.stack = [_this.lineIndex.root]; - return _this; - } - EditWalker.prototype.insertLines = function (insertedText) { - if (this.suppressTrailingText) { - this.trailingText = ""; - } - if (insertedText) { - insertedText = this.initialText + insertedText + this.trailingText; - } - else { - insertedText = this.initialText + this.trailingText; - } - var lm = LineIndex.linesFromText(insertedText); - var lines = lm.lines; - if (lines.length > 1) { - if (lines[lines.length - 1] == "") { - lines.length--; + BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { + for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (statement.kind !== 231 || statement.name.kind !== 9) { + return false; } } - var branchParent; - var lastZeroCount; - for (var k = this.endBranch.length - 1; k >= 0; k--) { - this.endBranch[k].updateCounts(); - if (this.endBranch[k].charCount() === 0) { - lastZeroCount = this.endBranch[k]; - if (k > 0) { - branchParent = this.endBranch[k - 1]; - } - else { - branchParent = this.branchNode; - } - } - } - if (lastZeroCount) { - branchParent.remove(lastZeroCount); - } - var insertionNode = this.startPath[this.startPath.length - 2]; - var leafNode = this.startPath[this.startPath.length - 1]; - var len = lines.length; - if (len > 0) { - leafNode.text = lines[0]; - if (len > 1) { - var insertedNodes = new Array(len - 1); - var startNode = leafNode; - for (var i = 1, len_1 = lines.length; i < len_1; i++) { - insertedNodes[i - 1] = new LineLeaf(lines[i]); - } - var pathIndex = this.startPath.length - 2; - while (pathIndex >= 0) { - insertionNode = this.startPath[pathIndex]; - insertedNodes = insertionNode.insertAt(startNode, insertedNodes); - pathIndex--; - startNode = insertionNode; - } - var insertedNodesLen = insertedNodes.length; - while (insertedNodesLen > 0) { - var newRoot = new LineNode(); - newRoot.add(this.lineIndex.root); - insertedNodes = newRoot.insertAt(this.lineIndex.root, insertedNodes); - insertedNodesLen = insertedNodes.length; - this.lineIndex.root = newRoot; - } - this.lineIndex.root.updateCounts(); - } - else { - for (var j = this.startPath.length - 2; j >= 0; j--) { - this.startPath[j].updateCounts(); - } - } - } - else { - insertionNode.remove(leafNode); - for (var j = this.startPath.length - 2; j >= 0; j--) { - this.startPath[j].updateCounts(); - } - } - return this.lineIndex; - }; - EditWalker.prototype.post = function (_relativeStart, _relativeLength, lineCollection) { - if (lineCollection === this.lineCollectionAtBranch) { - this.state = CharRangeSection.End; - } - this.stack.length--; - return undefined; - }; - 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)) { - this.state = CharRangeSection.Start; - this.branchNode = currentNode; - this.lineCollectionAtBranch = lineCollection; - } - var child; - function fresh(node) { - if (node.isLeaf()) { - return new LineLeaf(""); - } - else - return new LineNode(); - } - switch (nodeType) { - case CharRangeSection.PreStart: - this.goSubtree = false; - if (this.state !== CharRangeSection.End) { - currentNode.add(lineCollection); - } - break; - case CharRangeSection.Start: - if (this.state === CharRangeSection.End) { - this.goSubtree = false; - } - else { - child = fresh(lineCollection); - currentNode.add(child); - this.startPath[this.startPath.length] = child; - } - break; - case CharRangeSection.Entire: - if (this.state !== CharRangeSection.End) { - child = fresh(lineCollection); - currentNode.add(child); - this.startPath[this.startPath.length] = child; - } - else { - if (!lineCollection.isLeaf()) { - child = fresh(lineCollection); - currentNode.add(child); - this.endBranch[this.endBranch.length] = child; - } - } - break; - case CharRangeSection.Mid: - this.goSubtree = false; - break; - case CharRangeSection.End: - if (this.state !== CharRangeSection.End) { - this.goSubtree = false; - } - else { - if (!lineCollection.isLeaf()) { - child = fresh(lineCollection); - currentNode.add(child); - this.endBranch[this.endBranch.length] = child; - } - } - break; - case CharRangeSection.PostEnd: - this.goSubtree = false; - if (this.state !== CharRangeSection.Start) { - currentNode.add(lineCollection); - } - break; - } - if (this.goSubtree) { - this.stack[this.stack.length] = child; - } - return lineCollection; - }; - EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { - if (this.state === CharRangeSection.Start) { - this.initialText = ll.text.substring(0, relativeStart); - } - else if (this.state === CharRangeSection.Entire) { - this.initialText = ll.text.substring(0, relativeStart); - this.trailingText = ll.text.substring(relativeStart + relativeLength); - } - else { - this.trailingText = ll.text.substring(relativeStart + relativeLength); - } - }; - return EditWalker; - }(BaseLineIndexWalker)); - var TextChange = (function () { - function TextChange(pos, deleteLen, insertedText) { - this.pos = pos; - this.deleteLen = deleteLen; - this.insertedText = insertedText; - } - TextChange.prototype.getTextChangeRange = function () { - return ts.createTextChangeRange(ts.createTextSpan(this.pos, this.deleteLen), this.insertedText ? this.insertedText.length : 0); - }; - return TextChange; - }()); - server.TextChange = TextChange; - var ScriptVersionCache = (function () { - function ScriptVersionCache() { - this.changes = []; - this.versions = new Array(ScriptVersionCache.maxVersions); - this.minVersion = 0; - this.currentVersion = 0; - } - ScriptVersionCache.prototype.versionToIndex = function (version) { - if (version < this.minVersion || version > this.currentVersion) { - return undefined; - } - return version % ScriptVersionCache.maxVersions; - }; - ScriptVersionCache.prototype.currentVersionToIndex = function () { - return this.currentVersion % ScriptVersionCache.maxVersions; - }; - ScriptVersionCache.prototype.edit = function (pos, deleteLen, insertedText) { - this.changes[this.changes.length] = new TextChange(pos, deleteLen, insertedText); - if ((this.changes.length > ScriptVersionCache.changeNumberThreshold) || - (deleteLen > ScriptVersionCache.changeLengthThreshold) || - (insertedText && (insertedText.length > ScriptVersionCache.changeLengthThreshold))) { - this.getSnapshot(); - } - }; - ScriptVersionCache.prototype.latest = function () { - return this.versions[this.currentVersionToIndex()]; - }; - ScriptVersionCache.prototype.latestVersion = function () { - if (this.changes.length > 0) { - this.getSnapshot(); - } - return this.currentVersion; - }; - ScriptVersionCache.prototype.reloadFromFile = function (filename) { - var content = this.host.readFile(filename); - if (!content) { - content = ""; - } - this.reload(content); - }; - ScriptVersionCache.prototype.reload = function (script) { - this.currentVersion++; - this.changes = []; - var snap = new LineIndexSnapshot(this.currentVersion, this); - for (var i = 0; i < this.versions.length; i++) { - this.versions[i] = undefined; - } - this.versions[this.currentVersionToIndex()] = snap; - snap.index = new LineIndex(); - var lm = LineIndex.linesFromText(script); - snap.index.load(lm.lines); - this.minVersion = this.currentVersion; - }; - ScriptVersionCache.prototype.getSnapshot = function () { - var snap = this.versions[this.currentVersionToIndex()]; - if (this.changes.length > 0) { - var snapIndex = snap.index; - for (var i = 0, len = this.changes.length; i < len; i++) { - var change = this.changes[i]; - snapIndex = snapIndex.edit(change.pos, change.deleteLen, change.insertedText); - } - snap = new LineIndexSnapshot(this.currentVersion + 1, this); - snap.index = snapIndex; - snap.changesSincePreviousVersion = this.changes; - this.currentVersion = snap.version; - this.versions[this.currentVersionToIndex()] = snap; - this.changes = []; - if ((this.currentVersion - this.minVersion) >= ScriptVersionCache.maxVersions) { - this.minVersion = (this.currentVersion - ScriptVersionCache.maxVersions) + 1; - } - } - return snap; - }; - ScriptVersionCache.prototype.getTextChangesBetweenVersions = function (oldVersion, newVersion) { - if (oldVersion < newVersion) { - if (oldVersion >= this.minVersion) { - var textChangeRanges = []; - for (var i = oldVersion + 1; i <= newVersion; i++) { - var snap = this.versions[this.versionToIndex(i)]; - for (var j = 0, len = snap.changesSincePreviousVersion.length; j < len; j++) { - var textChange = snap.changesSincePreviousVersion[j]; - textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); - } - } - return ts.collapseTextChangeRangesAcrossMultipleVersions(textChangeRanges); - } - else { - return undefined; - } - } - else { - return ts.unchangedTextChangeRange; - } - }; - 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); - return svc; - }; - return ScriptVersionCache; - }()); - ScriptVersionCache.changeNumberThreshold = 8; - ScriptVersionCache.changeLengthThreshold = 256; - ScriptVersionCache.maxVersions = 8; - server.ScriptVersionCache = ScriptVersionCache; - var LineIndexSnapshot = (function () { - function LineIndexSnapshot(version, cache) { - this.version = version; - this.cache = cache; - this.changesSincePreviousVersion = []; - } - LineIndexSnapshot.prototype.getText = function (rangeStart, rangeEnd) { - return this.index.getText(rangeStart, rangeEnd - rangeStart); - }; - LineIndexSnapshot.prototype.getLength = function () { - return this.index.root.charCount(); - }; - LineIndexSnapshot.prototype.getLineStartPositions = function () { - var starts = [-1]; - var count = 1; - var pos = 0; - this.index.every(function (ll) { - starts[count] = pos; - count++; - pos += ll.text.length; - return true; - }, 0); - return starts; - }; - LineIndexSnapshot.prototype.getLineMapper = function () { - var _this = this; - return function (line) { - return _this.index.lineNumberToInfo(line).offset; - }; - }; - LineIndexSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { - if (this.version <= scriptVersion) { - return ts.unchangedTextChangeRange; - } - else { - return this.cache.getTextChangesBetweenVersions(scriptVersion, this.version); - } - }; - LineIndexSnapshot.prototype.getChangeRange = function (oldSnapshot) { - if (oldSnapshot instanceof LineIndexSnapshot && this.cache === oldSnapshot.cache) { - return this.getTextChangeRangeSinceVersion(oldSnapshot.version); - } - }; - return LineIndexSnapshot; - }()); - server.LineIndexSnapshot = LineIndexSnapshot; - var LineIndex = (function () { - function LineIndex() { - this.checkEdits = false; - } - LineIndex.prototype.charOffsetToLineNumberAndPos = function (charOffset) { - return this.root.charOffsetToLineNumberAndPos(1, charOffset); - }; - LineIndex.prototype.lineNumberToInfo = function (lineNumber) { - var lineCount = this.root.lineCount(); - if (lineNumber <= lineCount) { - var lineInfo = this.root.lineNumberToInfo(lineNumber, 0); - lineInfo.line = lineNumber; - return lineInfo; - } - else { - return { - line: lineNumber, - offset: this.root.charCount() - }; - } - }; - LineIndex.prototype.load = function (lines) { - if (lines.length > 0) { - var leaves = []; - for (var i = 0, len = lines.length; i < len; i++) { - leaves[i] = new LineLeaf(lines[i]); - } - this.root = LineIndex.buildTreeFromBottom(leaves); - } - else { - this.root = new LineNode(); - } - }; - LineIndex.prototype.walk = function (rangeStart, rangeLength, walkFns) { - this.root.walk(rangeStart, rangeLength, walkFns); - }; - LineIndex.prototype.getText = function (rangeStart, rangeLength) { - var accum = ""; - if ((rangeLength > 0) && (rangeStart < this.root.charCount())) { - this.walk(rangeStart, rangeLength, { - goSubtree: true, - done: false, - leaf: function (relativeStart, relativeLength, ll) { - accum = accum.concat(ll.text.substring(relativeStart, relativeStart + relativeLength)); - } - }); - } - return accum; - }; - LineIndex.prototype.getLength = function () { - return this.root.charCount(); - }; - LineIndex.prototype.every = function (f, rangeStart, rangeEnd) { - if (!rangeEnd) { - rangeEnd = this.root.charCount(); - } - var walkFns = { - goSubtree: true, - done: false, - leaf: function (relativeStart, relativeLength, ll) { - if (!f(ll, relativeStart, relativeLength)) { - this.done = true; - } - } - }; - this.walk(rangeStart, rangeEnd - rangeStart, walkFns); - return !walkFns.done; - }; - LineIndex.prototype.edit = function (pos, deleteLength, newText) { - function editFlat(source, s, dl, nt) { - if (nt === void 0) { nt = ""; } - return source.substring(0, s) + nt + source.substring(s + dl, source.length); - } - if (this.root.charCount() === 0) { - if (newText !== undefined) { - this.load(LineIndex.linesFromText(newText).lines); - return this; - } - } - else { - var checkText = void 0; - if (this.checkEdits) { - checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText); - } - var walker = new EditWalker(); - if (pos >= this.root.charCount()) { - pos = this.root.charCount() - 1; - var endString = this.getText(pos, 1); - if (newText) { - newText = endString + newText; - } - else { - newText = endString; - } - deleteLength = 0; - walker.suppressTrailingText = true; - } - else if (deleteLength > 0) { - var e = pos + deleteLength; - var lineInfo = this.charOffsetToLineNumberAndPos(e); - if ((lineInfo && (lineInfo.offset === 0))) { - deleteLength += lineInfo.text.length; - if (newText) { - newText = newText + lineInfo.text; - } - else { - newText = lineInfo.text; - } - } - } - if (pos < this.root.charCount()) { - this.root.walk(pos, deleteLength, walker); - walker.insertLines(newText); - } - if (this.checkEdits) { - var updatedText = this.getText(0, this.root.charCount()); - ts.Debug.assert(checkText == updatedText, "buffer edit mismatch"); - } - return walker.lineIndex; - } - }; - LineIndex.buildTreeFromBottom = function (nodes) { - var nodeCount = Math.ceil(nodes.length / lineCollectionCapacity); - var interiorNodes = []; - var nodeIndex = 0; - for (var i = 0; i < nodeCount; i++) { - interiorNodes[i] = new LineNode(); - var charCount = 0; - var lineCount = 0; - for (var j = 0; j < lineCollectionCapacity; j++) { - if (nodeIndex < nodes.length) { - interiorNodes[i].add(nodes[nodeIndex]); - charCount += nodes[nodeIndex].charCount(); - lineCount += nodes[nodeIndex].lineCount(); - } - else { - break; - } - nodeIndex++; - } - interiorNodes[i].totalChars = charCount; - interiorNodes[i].totalLines = lineCount; - } - if (interiorNodes.length === 1) { - return interiorNodes[0]; - } - else { - return this.buildTreeFromBottom(interiorNodes); - } - }; - LineIndex.linesFromText = function (text) { - var lineStarts = ts.computeLineStarts(text); - if (lineStarts.length === 0) { - return { lines: [], lineMap: lineStarts }; - } - var lines = new Array(lineStarts.length); - var lc = lineStarts.length - 1; - for (var lmi = 0; lmi < lc; lmi++) { - lines[lmi] = text.substring(lineStarts[lmi], lineStarts[lmi + 1]); - } - var endText = text.substring(lineStarts[lc]); - if (endText.length > 0) { - lines[lc] = endText; - } - else { - lines.length--; - } - return { lines: lines, lineMap: lineStarts }; - }; - return LineIndex; - }()); - server.LineIndex = LineIndex; - var LineNode = (function () { - function LineNode() { - this.totalChars = 0; - this.totalLines = 0; - this.children = []; - } - LineNode.prototype.isLeaf = function () { - return false; - }; - LineNode.prototype.updateCounts = function () { - this.totalChars = 0; - this.totalLines = 0; - for (var i = 0, len = this.children.length; i < len; i++) { - var child = this.children[i]; - this.totalChars += child.charCount(); - this.totalLines += child.lineCount(); - } - }; - LineNode.prototype.execWalk = function (rangeStart, rangeLength, walkFns, childIndex, nodeType) { - if (walkFns.pre) { - walkFns.pre(rangeStart, rangeLength, this.children[childIndex], this, nodeType); - } - if (walkFns.goSubtree) { - this.children[childIndex].walk(rangeStart, rangeLength, walkFns); - if (walkFns.post) { - walkFns.post(rangeStart, rangeLength, this.children[childIndex], this, nodeType); - } - } - else { - walkFns.goSubtree = true; - } - return walkFns.done; - }; - LineNode.prototype.skipChild = function (relativeStart, relativeLength, childIndex, walkFns, nodeType) { - if (walkFns.pre && (!walkFns.done)) { - walkFns.pre(relativeStart, relativeLength, this.children[childIndex], this, nodeType); - walkFns.goSubtree = true; - } - }; - LineNode.prototype.walk = function (rangeStart, rangeLength, walkFns) { - var childIndex = 0; - var child = this.children[0]; - var childCharCount = child.charCount(); - var adjustedStart = rangeStart; - while (adjustedStart >= childCharCount) { - this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, CharRangeSection.PreStart); - adjustedStart -= childCharCount; - childIndex++; - child = this.children[childIndex]; - childCharCount = child.charCount(); - } - if ((adjustedStart + rangeLength) <= childCharCount) { - if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, CharRangeSection.Entire)) { - return; - } - } - else { - if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, CharRangeSection.Start)) { - return; - } - var adjustedLength = rangeLength - (childCharCount - adjustedStart); - childIndex++; - child = this.children[childIndex]; - childCharCount = child.charCount(); - while (adjustedLength > childCharCount) { - if (this.execWalk(0, childCharCount, walkFns, childIndex, CharRangeSection.Mid)) { - return; - } - adjustedLength -= childCharCount; - childIndex++; - child = this.children[childIndex]; - childCharCount = child.charCount(); - } - if (adjustedLength > 0) { - if (this.execWalk(0, adjustedLength, walkFns, childIndex, CharRangeSection.End)) { - return; - } - } - } - if (walkFns.pre) { - var clen = this.children.length; - if (childIndex < (clen - 1)) { - for (var ej = childIndex + 1; ej < clen; ej++) { - this.skipChild(0, 0, ej, walkFns, CharRangeSection.PostEnd); - } - } - } - }; - LineNode.prototype.charOffsetToLineNumberAndPos = function (lineNumber, charOffset) { - var childInfo = this.childFromCharOffset(lineNumber, charOffset); - if (!childInfo.child) { - return { - line: lineNumber, - offset: charOffset, - }; - } - else if (childInfo.childIndex < this.children.length) { - if (childInfo.child.isLeaf()) { - return { - line: childInfo.lineNumber, - offset: childInfo.charOffset, - text: (childInfo.child).text, - leaf: (childInfo.child) - }; - } - else { - var lineNode = (childInfo.child); - return lineNode.charOffsetToLineNumberAndPos(childInfo.lineNumber, childInfo.charOffset); - } - } - else { - var lineInfo = this.lineNumberToInfo(this.lineCount(), 0); - return { line: this.lineCount(), offset: lineInfo.leaf.charCount() }; - } - }; - LineNode.prototype.lineNumberToInfo = function (lineNumber, charOffset) { - var childInfo = this.childFromLineNumber(lineNumber, charOffset); - if (!childInfo.child) { - return { - line: lineNumber, - offset: charOffset - }; - } - else if (childInfo.child.isLeaf()) { - return { - line: lineNumber, - offset: childInfo.charOffset, - text: (childInfo.child).text, - leaf: (childInfo.child) - }; - } - else { - var lineNode = (childInfo.child); - return lineNode.lineNumberToInfo(childInfo.relativeLineNumber, childInfo.charOffset); - } - }; - LineNode.prototype.childFromLineNumber = function (lineNumber, charOffset) { - var child; - var relativeLineNumber = lineNumber; - var i; - var len; - for (i = 0, len = this.children.length; i < len; i++) { - child = this.children[i]; - var childLineCount = child.lineCount(); - if (childLineCount >= relativeLineNumber) { - break; - } - else { - relativeLineNumber -= childLineCount; - charOffset += child.charCount(); - } - } - return { - child: child, - childIndex: i, - relativeLineNumber: relativeLineNumber, - charOffset: charOffset - }; - }; - LineNode.prototype.childFromCharOffset = function (lineNumber, charOffset) { - var child; - var i; - var len; - for (i = 0, len = this.children.length; i < len; i++) { - child = this.children[i]; - if (child.charCount() > charOffset) { - break; - } - else { - charOffset -= child.charCount(); - lineNumber += child.lineCount(); - } - } - return { - child: child, - childIndex: i, - charOffset: charOffset, - lineNumber: lineNumber - }; - }; - LineNode.prototype.splitAfter = function (childIndex) { - var splitNode; - var clen = this.children.length; - childIndex++; - var endLength = childIndex; - if (childIndex < clen) { - splitNode = new LineNode(); - while (childIndex < clen) { - splitNode.add(this.children[childIndex]); - childIndex++; - } - splitNode.updateCounts(); - } - this.children.length = endLength; - return splitNode; - }; - LineNode.prototype.remove = function (child) { - var childIndex = this.findChildIndex(child); - var clen = this.children.length; - if (childIndex < (clen - 1)) { - for (var i = childIndex; i < (clen - 1); i++) { - this.children[i] = this.children[i + 1]; - } - } - this.children.length--; - }; - LineNode.prototype.findChildIndex = function (child) { - var childIndex = 0; - var clen = this.children.length; - while ((this.children[childIndex] !== child) && (childIndex < clen)) - childIndex++; - return childIndex; - }; - LineNode.prototype.insertAt = function (child, nodes) { - var childIndex = this.findChildIndex(child); - var clen = this.children.length; - var nodeCount = nodes.length; - if ((clen < lineCollectionCapacity) && (childIndex === (clen - 1)) && (nodeCount === 1)) { - this.add(nodes[0]); - this.updateCounts(); - return []; - } - else { - var shiftNode = this.splitAfter(childIndex); - var nodeIndex = 0; - childIndex++; - while ((childIndex < lineCollectionCapacity) && (nodeIndex < nodeCount)) { - this.children[childIndex] = nodes[nodeIndex]; - childIndex++; - nodeIndex++; - } - var splitNodes = []; - var splitNodeCount = 0; - if (nodeIndex < nodeCount) { - splitNodeCount = Math.ceil((nodeCount - nodeIndex) / lineCollectionCapacity); - splitNodes = new Array(splitNodeCount); - var splitNodeIndex = 0; - for (var i = 0; i < splitNodeCount; i++) { - splitNodes[i] = new LineNode(); - } - var splitNode = splitNodes[0]; - while (nodeIndex < nodeCount) { - splitNode.add(nodes[nodeIndex]); - nodeIndex++; - if (splitNode.children.length === lineCollectionCapacity) { - splitNodeIndex++; - splitNode = splitNodes[splitNodeIndex]; - } - } - for (var i = splitNodes.length - 1; i >= 0; i--) { - if (splitNodes[i].children.length === 0) { - splitNodes.length--; - } - } - } - if (shiftNode) { - splitNodes[splitNodes.length] = shiftNode; - } - this.updateCounts(); - for (var i = 0; i < splitNodeCount; i++) { - splitNodes[i].updateCounts(); - } - return splitNodes; - } - }; - LineNode.prototype.add = function (collection) { - this.children[this.children.length] = collection; - return (this.children.length < lineCollectionCapacity); - }; - LineNode.prototype.charCount = function () { - return this.totalChars; - }; - LineNode.prototype.lineCount = function () { - return this.totalLines; - }; - return LineNode; - }()); - server.LineNode = LineNode; - var LineLeaf = (function () { - function LineLeaf(text) { - this.text = text; - } - LineLeaf.prototype.isLeaf = function () { return true; }; - LineLeaf.prototype.walk = function (rangeStart, rangeLength, walkFns) { - walkFns.leaf(rangeStart, rangeLength, this); + BuilderFileInfo.prototype.computeHash = function (text) { + return this.project.projectService.host.createHash(text); }; - LineLeaf.prototype.charCount = function () { - return this.text.length; + BuilderFileInfo.prototype.getSourceFile = function () { + return this.project.getSourceFile(this.scriptInfo.path); }; - LineLeaf.prototype.lineCount = function () { - return 1; + BuilderFileInfo.prototype.updateShapeSignature = function () { + var sourceFile = this.getSourceFile(); + if (!sourceFile) { + return true; + } + var lastSignature = this.lastCheckedShapeSignature; + if (sourceFile.isDeclarationFile) { + this.lastCheckedShapeSignature = this.computeHash(sourceFile.text); + } + else { + var emitOutput = this.project.getFileEmitOutput(this.scriptInfo, true); + if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { + this.lastCheckedShapeSignature = this.computeHash(emitOutput.outputFiles[0].text); + } + } + return !lastSignature || this.lastCheckedShapeSignature !== lastSignature; }; - return LineLeaf; + return BuilderFileInfo; }()); - server.LineLeaf = LineLeaf; + server.BuilderFileInfo = BuilderFileInfo; + var AbstractBuilder = (function () { + function AbstractBuilder(project, ctor) { + this.project = project; + this.ctor = ctor; + } + AbstractBuilder.prototype.getFileInfos = function () { + return this.fileInfos_doNotAccessDirectly || (this.fileInfos_doNotAccessDirectly = ts.createFileMap()); + }; + AbstractBuilder.prototype.clear = function () { + this.fileInfos_doNotAccessDirectly = undefined; + }; + AbstractBuilder.prototype.getFileInfo = function (path) { + return this.getFileInfos().get(path); + }; + AbstractBuilder.prototype.getOrCreateFileInfo = function (path) { + var fileInfo = this.getFileInfo(path); + if (!fileInfo) { + var scriptInfo = this.project.getScriptInfo(path); + fileInfo = new this.ctor(scriptInfo, this.project); + this.setFileInfo(path, fileInfo); + } + return fileInfo; + }; + AbstractBuilder.prototype.getFileInfoPaths = function () { + return this.getFileInfos().getKeys(); + }; + AbstractBuilder.prototype.setFileInfo = function (path, info) { + this.getFileInfos().set(path, info); + }; + AbstractBuilder.prototype.removeFileInfo = function (path) { + this.getFileInfos().remove(path); + }; + AbstractBuilder.prototype.forEachFileInfo = function (action) { + this.getFileInfos().forEachValue(function (_path, value) { return action(value); }); + }; + AbstractBuilder.prototype.emitFile = function (scriptInfo, writeFile) { + var fileInfo = this.getFileInfo(scriptInfo.path); + if (!fileInfo) { + return false; + } + var _a = this.project.getFileEmitOutput(fileInfo.scriptInfo, false), emitSkipped = _a.emitSkipped, outputFiles = _a.outputFiles; + if (!emitSkipped) { + var projectRootPath = this.project.getProjectRootPath(); + for (var _i = 0, outputFiles_1 = outputFiles; _i < outputFiles_1.length; _i++) { + var outputFile = outputFiles_1[_i]; + var outputFileAbsoluteFileName = ts.getNormalizedAbsolutePath(outputFile.name, projectRootPath ? projectRootPath : ts.getDirectoryPath(scriptInfo.fileName)); + writeFile(outputFileAbsoluteFileName, outputFile.text, outputFile.writeByteOrderMark); + } + } + return !emitSkipped; + }; + return AbstractBuilder; + }()); + var NonModuleBuilder = (function (_super) { + __extends(NonModuleBuilder, _super); + function NonModuleBuilder(project) { + var _this = _super.call(this, project, BuilderFileInfo) || this; + _this.project = project; + return _this; + } + NonModuleBuilder.prototype.onProjectUpdateGraph = function () { + }; + NonModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { + var info = this.getOrCreateFileInfo(scriptInfo.path); + var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + if (info.updateShapeSignature()) { + var options = this.project.getCompilerOptions(); + if (options && (options.out || options.outFile)) { + return singleFileResult; + } + return this.project.getAllEmittableFiles(); + } + return singleFileResult; + }; + return NonModuleBuilder; + }(AbstractBuilder)); + var ModuleBuilderFileInfo = (function (_super) { + __extends(ModuleBuilderFileInfo, _super); + function ModuleBuilderFileInfo() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.references = []; + _this.referencedBy = []; + return _this; + } + ModuleBuilderFileInfo.compareFileInfos = function (lf, rf) { + var l = lf.scriptInfo.fileName; + var r = rf.scriptInfo.fileName; + return (l < r ? -1 : (l > r ? 1 : 0)); + }; + ; + ModuleBuilderFileInfo.addToReferenceList = function (array, fileInfo) { + if (array.length === 0) { + array.push(fileInfo); + return; + } + var insertIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); + if (insertIndex < 0) { + array.splice(~insertIndex, 0, fileInfo); + } + }; + ModuleBuilderFileInfo.removeFromReferenceList = function (array, fileInfo) { + if (!array || array.length === 0) { + return; + } + if (array[0] === fileInfo) { + array.splice(0, 1); + return; + } + var removeIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); + if (removeIndex >= 0) { + array.splice(removeIndex, 1); + } + }; + ModuleBuilderFileInfo.prototype.addReferencedBy = function (fileInfo) { + ModuleBuilderFileInfo.addToReferenceList(this.referencedBy, fileInfo); + }; + ModuleBuilderFileInfo.prototype.removeReferencedBy = function (fileInfo) { + ModuleBuilderFileInfo.removeFromReferenceList(this.referencedBy, fileInfo); + }; + ModuleBuilderFileInfo.prototype.removeFileReferences = function () { + for (var _i = 0, _a = this.references; _i < _a.length; _i++) { + var reference = _a[_i]; + reference.removeReferencedBy(this); + } + this.references = []; + }; + return ModuleBuilderFileInfo; + }(BuilderFileInfo)); + var ModuleBuilder = (function (_super) { + __extends(ModuleBuilder, _super); + function ModuleBuilder(project) { + var _this = _super.call(this, project, ModuleBuilderFileInfo) || this; + _this.project = project; + return _this; + } + ModuleBuilder.prototype.clear = function () { + this.projectVersionForDependencyGraph = undefined; + _super.prototype.clear.call(this); + }; + ModuleBuilder.prototype.getReferencedFileInfos = function (fileInfo) { + var _this = this; + if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { + return []; + } + var referencedFilePaths = this.project.getReferencedFiles(fileInfo.scriptInfo.path); + if (referencedFilePaths.length > 0) { + return ts.map(referencedFilePaths, function (f) { return _this.getOrCreateFileInfo(f); }).sort(ModuleBuilderFileInfo.compareFileInfos); + } + return []; + }; + ModuleBuilder.prototype.onProjectUpdateGraph = function () { + this.ensureProjectDependencyGraphUpToDate(); + }; + ModuleBuilder.prototype.ensureProjectDependencyGraphUpToDate = function () { + var _this = this; + if (!this.projectVersionForDependencyGraph || this.project.getProjectVersion() !== this.projectVersionForDependencyGraph) { + var currentScriptInfos = this.project.getScriptInfos(); + for (var _i = 0, currentScriptInfos_1 = currentScriptInfos; _i < currentScriptInfos_1.length; _i++) { + var scriptInfo = currentScriptInfos_1[_i]; + var fileInfo = this.getOrCreateFileInfo(scriptInfo.path); + this.updateFileReferences(fileInfo); + } + this.forEachFileInfo(function (fileInfo) { + if (!_this.project.containsScriptInfo(fileInfo.scriptInfo)) { + fileInfo.removeFileReferences(); + _this.removeFileInfo(fileInfo.scriptInfo.path); + } + }); + this.projectVersionForDependencyGraph = this.project.getProjectVersion(); + } + }; + ModuleBuilder.prototype.updateFileReferences = function (fileInfo) { + if (fileInfo.scriptVersionForReferences === fileInfo.scriptInfo.getLatestVersion()) { + return; + } + var newReferences = this.getReferencedFileInfos(fileInfo); + var oldReferences = fileInfo.references; + var oldIndex = 0; + var newIndex = 0; + while (oldIndex < oldReferences.length && newIndex < newReferences.length) { + var oldReference = oldReferences[oldIndex]; + var newReference = newReferences[newIndex]; + var compare = ModuleBuilderFileInfo.compareFileInfos(oldReference, newReference); + if (compare < 0) { + oldReference.removeReferencedBy(fileInfo); + oldIndex++; + } + else if (compare > 0) { + newReference.addReferencedBy(fileInfo); + newIndex++; + } + else { + oldIndex++; + newIndex++; + } + } + for (var i = oldIndex; i < oldReferences.length; i++) { + oldReferences[i].removeReferencedBy(fileInfo); + } + for (var i = newIndex; i < newReferences.length; i++) { + newReferences[i].addReferencedBy(fileInfo); + } + fileInfo.references = newReferences; + fileInfo.scriptVersionForReferences = fileInfo.scriptInfo.getLatestVersion(); + }; + ModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { + this.ensureProjectDependencyGraphUpToDate(); + var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + var fileInfo = this.getFileInfo(scriptInfo.path); + if (!fileInfo || !fileInfo.updateShapeSignature()) { + return singleFileResult; + } + if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { + return this.project.getAllEmittableFiles(); + } + var options = this.project.getCompilerOptions(); + if (options && (options.isolatedModules || options.out || options.outFile)) { + return singleFileResult; + } + var queue = fileInfo.referencedBy.slice(0); + var fileNameSet = ts.createMap(); + fileNameSet[scriptInfo.fileName] = scriptInfo; + while (queue.length > 0) { + var processingFileInfo = queue.pop(); + if (processingFileInfo.updateShapeSignature() && processingFileInfo.referencedBy.length > 0) { + for (var _i = 0, _a = processingFileInfo.referencedBy; _i < _a.length; _i++) { + var potentialFileInfo = _a[_i]; + if (!fileNameSet[potentialFileInfo.scriptInfo.fileName]) { + queue.push(potentialFileInfo); + } + } + } + fileNameSet[processingFileInfo.scriptInfo.fileName] = processingFileInfo.scriptInfo; + } + var result = []; + for (var fileName in fileNameSet) { + if (shouldEmitFile(fileNameSet[fileName])) { + result.push(fileName); + } + } + return result; + }; + return ModuleBuilder; + }(AbstractBuilder)); + function createBuilder(project) { + var moduleKind = project.getCompilerOptions().module; + switch (moduleKind) { + case ts.ModuleKind.None: + return new NonModuleBuilder(project); + default: + return new ModuleBuilder(project); + } + } + server.createBuilder = createBuilder; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var debugObjectHost = (function () { return this; })(); @@ -70464,7 +71431,7 @@ var ts; this._shims.push(shim); }; TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { + for (var i = 0; i < this._shims.length; i++) { if (this._shims[i] === shim) { delete this._shims[i]; return; diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index c5cee20bdde..65a33f28c33 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -239,102 +239,102 @@ declare namespace ts { ExpressionWithTypeArguments = 199, AsExpression = 200, NonNullExpression = 201, - TemplateSpan = 202, - SemicolonClassElement = 203, - Block = 204, - VariableStatement = 205, - EmptyStatement = 206, - ExpressionStatement = 207, - IfStatement = 208, - DoStatement = 209, - WhileStatement = 210, - ForStatement = 211, - ForInStatement = 212, - ForOfStatement = 213, - ContinueStatement = 214, - BreakStatement = 215, - ReturnStatement = 216, - WithStatement = 217, - SwitchStatement = 218, - LabeledStatement = 219, - ThrowStatement = 220, - TryStatement = 221, - DebuggerStatement = 222, - VariableDeclaration = 223, - VariableDeclarationList = 224, - FunctionDeclaration = 225, - ClassDeclaration = 226, - InterfaceDeclaration = 227, - TypeAliasDeclaration = 228, - EnumDeclaration = 229, - ModuleDeclaration = 230, - ModuleBlock = 231, - CaseBlock = 232, - NamespaceExportDeclaration = 233, - ImportEqualsDeclaration = 234, - ImportDeclaration = 235, - ImportClause = 236, - NamespaceImport = 237, - NamedImports = 238, - ImportSpecifier = 239, - ExportAssignment = 240, - ExportDeclaration = 241, - NamedExports = 242, - ExportSpecifier = 243, - MissingDeclaration = 244, - ExternalModuleReference = 245, - JsxElement = 246, - JsxSelfClosingElement = 247, - JsxOpeningElement = 248, - JsxClosingElement = 249, - JsxAttribute = 250, - JsxSpreadAttribute = 251, - JsxExpression = 252, - CaseClause = 253, - DefaultClause = 254, - HeritageClause = 255, - CatchClause = 256, - PropertyAssignment = 257, - ShorthandPropertyAssignment = 258, - SpreadAssignment = 259, - EnumMember = 260, - SourceFile = 261, - JSDocTypeExpression = 262, - JSDocAllType = 263, - JSDocUnknownType = 264, - JSDocArrayType = 265, - JSDocUnionType = 266, - JSDocTupleType = 267, - JSDocNullableType = 268, - JSDocNonNullableType = 269, - JSDocRecordType = 270, - JSDocRecordMember = 271, - JSDocTypeReference = 272, - JSDocOptionalType = 273, - JSDocFunctionType = 274, - JSDocVariadicType = 275, - JSDocConstructorType = 276, - JSDocThisType = 277, - JSDocComment = 278, - JSDocTag = 279, - JSDocAugmentsTag = 280, - JSDocParameterTag = 281, - JSDocReturnTag = 282, - JSDocTypeTag = 283, - JSDocTemplateTag = 284, - JSDocTypedefTag = 285, - JSDocPropertyTag = 286, - JSDocTypeLiteral = 287, - JSDocLiteralType = 288, - JSDocNullKeyword = 289, - JSDocUndefinedKeyword = 290, - JSDocNeverKeyword = 291, - SyntaxList = 292, - NotEmittedStatement = 293, - PartiallyEmittedExpression = 294, - MergeDeclarationMarker = 295, - EndOfDeclarationMarker = 296, - RawExpression = 297, + MetaProperty = 202, + TemplateSpan = 203, + SemicolonClassElement = 204, + Block = 205, + VariableStatement = 206, + EmptyStatement = 207, + ExpressionStatement = 208, + IfStatement = 209, + DoStatement = 210, + WhileStatement = 211, + ForStatement = 212, + ForInStatement = 213, + ForOfStatement = 214, + ContinueStatement = 215, + BreakStatement = 216, + ReturnStatement = 217, + WithStatement = 218, + SwitchStatement = 219, + LabeledStatement = 220, + ThrowStatement = 221, + TryStatement = 222, + DebuggerStatement = 223, + VariableDeclaration = 224, + VariableDeclarationList = 225, + FunctionDeclaration = 226, + ClassDeclaration = 227, + InterfaceDeclaration = 228, + TypeAliasDeclaration = 229, + EnumDeclaration = 230, + ModuleDeclaration = 231, + ModuleBlock = 232, + CaseBlock = 233, + NamespaceExportDeclaration = 234, + ImportEqualsDeclaration = 235, + ImportDeclaration = 236, + ImportClause = 237, + NamespaceImport = 238, + NamedImports = 239, + ImportSpecifier = 240, + ExportAssignment = 241, + ExportDeclaration = 242, + NamedExports = 243, + ExportSpecifier = 244, + MissingDeclaration = 245, + ExternalModuleReference = 246, + JsxElement = 247, + JsxSelfClosingElement = 248, + JsxOpeningElement = 249, + JsxClosingElement = 250, + JsxAttribute = 251, + JsxSpreadAttribute = 252, + JsxExpression = 253, + CaseClause = 254, + DefaultClause = 255, + HeritageClause = 256, + CatchClause = 257, + PropertyAssignment = 258, + ShorthandPropertyAssignment = 259, + SpreadAssignment = 260, + EnumMember = 261, + SourceFile = 262, + JSDocTypeExpression = 263, + JSDocAllType = 264, + JSDocUnknownType = 265, + JSDocArrayType = 266, + JSDocUnionType = 267, + JSDocTupleType = 268, + JSDocNullableType = 269, + JSDocNonNullableType = 270, + JSDocRecordType = 271, + JSDocRecordMember = 272, + JSDocTypeReference = 273, + JSDocOptionalType = 274, + JSDocFunctionType = 275, + JSDocVariadicType = 276, + JSDocConstructorType = 277, + JSDocThisType = 278, + JSDocComment = 279, + JSDocTag = 280, + JSDocAugmentsTag = 281, + JSDocParameterTag = 282, + JSDocReturnTag = 283, + JSDocTypeTag = 284, + JSDocTemplateTag = 285, + JSDocTypedefTag = 286, + JSDocPropertyTag = 287, + JSDocTypeLiteral = 288, + JSDocLiteralType = 289, + JSDocNullKeyword = 290, + JSDocUndefinedKeyword = 291, + JSDocNeverKeyword = 292, + SyntaxList = 293, + NotEmittedStatement = 294, + PartiallyEmittedExpression = 295, + MergeDeclarationMarker = 296, + EndOfDeclarationMarker = 297, Count = 298, FirstAssignment = 57, LastAssignment = 69, @@ -361,10 +361,10 @@ declare namespace ts { FirstBinaryOperator = 26, LastBinaryOperator = 69, FirstNode = 141, - FirstJSDocNode = 262, - LastJSDocNode = 288, - FirstJSDocTagNode = 278, - LastJSDocTagNode = 291, + FirstJSDocNode = 263, + LastJSDocNode = 289, + FirstJSDocTagNode = 279, + LastJSDocTagNode = 292, } enum NodeFlags { None = 0, @@ -969,6 +969,11 @@ declare namespace ts { kind: SyntaxKind.NonNullExpression; expression: Expression; } + interface MetaProperty extends PrimaryExpression { + kind: SyntaxKind.MetaProperty; + keywordToken: SyntaxKind; + name: Identifier; + } interface JsxElement extends PrimaryExpression { kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; @@ -1003,6 +1008,7 @@ declare namespace ts { } interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; + dotDotDotToken?: Token; expression?: Expression; } interface JsxText extends Node { @@ -1022,7 +1028,7 @@ declare namespace ts { kind: SyntaxKind.MissingDeclaration; name?: Identifier; } - type BlockLike = SourceFile | Block | ModuleBlock | CaseClause; + type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; @@ -1569,6 +1575,7 @@ declare namespace ts { getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol; + getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; getBaseTypes(type: InterfaceType): ObjectType[]; @@ -1581,6 +1588,8 @@ declare namespace ts { getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol; getTypeAtLocation(node: Node): Type; + getTypeFromTypeNode(node: TypeNode): Type; + signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string; typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; getSymbolDisplayBuilder(): SymbolDisplayBuilder; @@ -1603,11 +1612,13 @@ declare namespace ts { isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; + getApparentType(type: Type): Type; } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; + buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1645,6 +1656,7 @@ declare namespace ts { InFirstTypeArgument = 256, InTypeAlias = 512, UseTypeAliasValue = 1024, + SuppressAnyReturnType = 2048, } enum SymbolFormatFlags { None = 0, @@ -1815,6 +1827,7 @@ declare namespace ts { interface ObjectType extends Type { objectFlags: ObjectFlags; } + /** Class and interface types (TypeFlags.Class and TypeFlags.Interface). */ interface InterfaceType extends ObjectType { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; @@ -1828,6 +1841,16 @@ declare namespace ts { declaredStringIndexInfo: IndexInfo; declaredNumberIndexInfo: IndexInfo; } + /** + * Type references (TypeFlags.Reference). When a class or interface has type parameters or + * a "this" type, references to the class or interface are made using type references. The + * typeArguments property specifies the types to substitute for the type parameters of the + * class or interface and optionally includes an extra element that specifies the type to + * substitute for "this" in the resulting instantiation. When no extra argument is present, + * the type reference itself is substituted for "this". The typeArguments property is undefined + * if the class or interface has no type parameters and the reference isn't specifying an + * explicit "this" argument. + */ interface TypeReference extends ObjectType { target: GenericType; typeArguments: Type[]; @@ -2106,7 +2129,6 @@ declare namespace ts { } interface ResolvedModuleWithFailedLookupLocations { resolvedModule: ResolvedModuleFull | undefined; - failedLookupLocations: string[]; } interface ResolvedTypeReferenceDirective { primary: boolean; @@ -2325,9 +2347,28 @@ declare namespace ts { * this list is only the set of defaults that are implicitly included. */ function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + /** + * Cached module resolutions per containing directory. + * This assumes that any module id will have the same resolution for sibling files located in the same folder. + */ + interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { + getOrCreateCacheForDirectory(directoryName: string): Map; + } + /** + * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory + * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. + */ + interface NonRelativeModuleNameResolutionCache { + getOrCreateCacheForModuleName(nonRelativeModuleName: string): PerModuleNameCache; + } + interface PerModuleNameCache { + get(directory: string): ResolvedModuleWithFailedLookupLocations; + set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; + } + function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): ModuleResolutionCache; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; @@ -2674,6 +2715,7 @@ declare namespace ts { InsertSpaceAfterCommaDelimiter: boolean; InsertSpaceAfterSemicolonInForStatements: boolean; InsertSpaceBeforeAndAfterBinaryOperators: boolean; + InsertSpaceAfterConstructor?: boolean; InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; @@ -2682,6 +2724,7 @@ declare namespace ts { InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; InsertSpaceAfterTypeAssertion?: boolean; + InsertSpaceBeforeFunctionParenthesis?: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; } @@ -2689,6 +2732,7 @@ declare namespace ts { insertSpaceAfterCommaDelimiter?: boolean; insertSpaceAfterSemicolonInForStatements?: boolean; insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterConstructor?: boolean; insertSpaceAfterKeywordsInControlFlowStatements?: boolean; insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; @@ -2697,6 +2741,7 @@ declare namespace ts { insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; insertSpaceAfterTypeAssertion?: boolean; + insertSpaceBeforeFunctionParenthesis?: boolean; placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; } diff --git a/lib/typescript.js b/lib/typescript.js index 7f41e5d07f5..bae2811e4de 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -13,11 +13,16 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ts; (function (ts) { // token > SyntaxKind.Identifer => token is a keyword @@ -244,115 +249,115 @@ var ts; SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 199] = "ExpressionWithTypeArguments"; SyntaxKind[SyntaxKind["AsExpression"] = 200] = "AsExpression"; SyntaxKind[SyntaxKind["NonNullExpression"] = 201] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 202] = "MetaProperty"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 202] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 203] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 203] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 204] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 204] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 205] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 206] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 207] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 208] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 209] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 210] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 211] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 212] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 213] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 214] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 215] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 216] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 217] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 218] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 219] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 220] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 221] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 222] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 223] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 224] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 225] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 226] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 227] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 228] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 229] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 230] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 231] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 232] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 233] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 234] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 235] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 236] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 237] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 238] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 239] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 240] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 241] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 242] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 243] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 244] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 205] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 206] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 207] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 208] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 209] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 210] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 211] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 212] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 213] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 214] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 215] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 216] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 217] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 218] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 219] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 220] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 221] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 222] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 223] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 225] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 226] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 227] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 228] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 229] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 230] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 231] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 232] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 233] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 234] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 235] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 236] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 237] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 238] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 239] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 240] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 241] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 242] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 243] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 244] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 245] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 246] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 246] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 247] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 248] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 249] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 250] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 251] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 252] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 247] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 248] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 249] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 250] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 251] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 252] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 253] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 253] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 254] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 255] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 256] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 254] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 255] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 256] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 257] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 257] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 258] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 259] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 258] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 259] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 260] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 260] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 261] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 261] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 262] = "SourceFile"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 262] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 263] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 263] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 264] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 264] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 265] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 266] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 267] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 268] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 269] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 270] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 271] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 272] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 273] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 274] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 275] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 276] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 277] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 278] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 279] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 280] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 281] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 282] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 283] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 284] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 285] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 286] = "JSDocPropertyTag"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 287] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocLiteralType"] = 288] = "JSDocLiteralType"; - SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 289] = "JSDocNullKeyword"; - SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 290] = "JSDocUndefinedKeyword"; - SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 291] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 265] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 266] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 267] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 268] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 269] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 270] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 271] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 272] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 273] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 274] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 275] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 276] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 277] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 278] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 279] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 280] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 281] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 282] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 283] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 284] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 285] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 286] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 287] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 288] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 289] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 290] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 291] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 292] = "JSDocNeverKeyword"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 292] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 293] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 293] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 294] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 295] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 296] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["RawExpression"] = 297] = "RawExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 294] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 295] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 296] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 297] = "EndOfDeclarationMarker"; // Enum value count SyntaxKind[SyntaxKind["Count"] = 298] = "Count"; // Markers @@ -381,10 +386,10 @@ var ts; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; SyntaxKind[SyntaxKind["FirstNode"] = 141] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 262] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 288] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 278] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 291] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 263] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 289] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 279] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 292] = "LastJSDocTagNode"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -511,6 +516,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 2048] = "SuppressAnyReturnType"; })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -647,6 +653,7 @@ var ts; NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["CaptureNewTarget"] = 8] = "CaptureNewTarget"; NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; @@ -1290,7 +1297,7 @@ var ts; */ function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -1314,7 +1321,7 @@ var ts; */ function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -1325,7 +1332,7 @@ var ts; ts.every = every; /** Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. */ function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -1339,7 +1346,7 @@ var ts; * This is like `forEach`, but never returns undefined. */ function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -1362,7 +1369,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -1372,7 +1379,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -2220,6 +2227,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -3915,7 +3923,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_be_declared_in_an_ambient_context_1086", message: "An accessor cannot be declared in an ambient context." }, _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", message: "'{0}' modifier cannot appear on a constructor declaration." }, _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_parameter_1090", message: "'{0}' modifier cannot appear on a parameter." }, @@ -4072,6 +4080,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "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_2301", message: "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_2302", message: "Static members cannot reference class type parameters." }, @@ -4301,6 +4310,8 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "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: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -4310,6 +4321,7 @@ var ts; Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "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: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -4361,6 +4373,8 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "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_4002", message: "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_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -4529,6 +4543,7 @@ var ts; Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -4542,10 +4557,10 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, @@ -4594,6 +4609,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -4650,22 +4667,25 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); /// @@ -5132,7 +5152,7 @@ var ts; if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { var ch = text.charCodeAt(pos); if ((pos + mergeConflictMarkerLength) < text.length) { - for (var i = 0, n = mergeConflictMarkerLength; i < n; i++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -5344,7 +5364,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -6524,7 +6544,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 261 /* SourceFile */) { + while (node && node.kind !== 262 /* SourceFile */) { node = node.parent; } return node; @@ -6532,11 +6552,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 204 /* Block */: - case 232 /* CaseBlock */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 205 /* Block */: + case 233 /* CaseBlock */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: return true; } return false; @@ -6627,18 +6647,18 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 292 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 293 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 262 /* FirstJSDocNode */ && node.kind <= 288 /* LastJSDocNode */; + return node.kind >= 263 /* FirstJSDocNode */ && node.kind <= 289 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 278 /* FirstJSDocTagNode */ && node.kind <= 291 /* LastJSDocTagNode */; + return node.kind >= 279 /* FirstJSDocTagNode */ && node.kind <= 292 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -6742,11 +6762,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 223 /* VariableDeclaration */ && node.parent.kind === 256 /* CatchClause */; + return node.kind === 224 /* VariableDeclaration */ && node.parent.kind === 257 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 230 /* ModuleDeclaration */ && + return node && node.kind === 231 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -6757,11 +6777,11 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node.kind === 230 /* ModuleDeclaration */ && (!node.body); + return node.kind === 231 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 261 /* SourceFile */ || - node.kind === 230 /* ModuleDeclaration */ || + return node.kind === 262 /* SourceFile */ || + node.kind === 231 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6777,9 +6797,9 @@ var ts; return false; } switch (node.parent.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: return ts.isExternalModule(node.parent); - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6791,22 +6811,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 261 /* SourceFile */: - case 232 /* CaseBlock */: - case 256 /* CatchClause */: - case 230 /* ModuleDeclaration */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 262 /* SourceFile */: + case 233 /* CaseBlock */: + case 257 /* CatchClause */: + case 231 /* ModuleDeclaration */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: case 150 /* Constructor */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: return true; - case 204 /* Block */: + case 205 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -6891,7 +6911,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 204 /* Block */) { + if (node.body && node.body.kind === 205 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6905,7 +6925,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -6914,20 +6934,20 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: - case 225 /* FunctionDeclaration */: + case 228 /* InterfaceDeclaration */: + case 231 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: + case 261 /* EnumMember */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: errorNode = node.name; break; case 185 /* ArrowFunction */: @@ -6953,7 +6973,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 229 /* EnumDeclaration */ && isConst(node); + return node.kind === 230 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -6970,7 +6990,7 @@ var ts; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 207 /* ExpressionStatement */ + return node.kind === 208 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -7053,9 +7073,9 @@ var ts; case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: case 144 /* Parameter */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return node === parent_1.type; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 150 /* Constructor */: @@ -7081,29 +7101,43 @@ var ts; return false; } ts.isPartOfTypeNode = isPartOfTypeNode; + function isChildOfNodeWithKind(node, kind) { + while (node) { + if (node.kind === kind) { + return true; + } + node = node.parent; + } + return false; + } + ts.isChildOfNodeWithKind = isChildOfNodeWithKind; + function isPrefixUnaryExpression(node) { + return node.kind === 190 /* PrefixUnaryExpression */; + } + ts.isPrefixUnaryExpression = isPrefixUnaryExpression; // Warning: This has the same semantics as the forEach family of functions, // in that traversal terminates in the event that 'visitor' supplies a truthy value. function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return visitor(node); - case 232 /* CaseBlock */: - case 204 /* Block */: - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 217 /* WithStatement */: - case 218 /* SwitchStatement */: - case 253 /* CaseClause */: - case 254 /* DefaultClause */: - case 219 /* LabeledStatement */: - case 221 /* TryStatement */: - case 256 /* CatchClause */: + case 233 /* CaseBlock */: + case 205 /* Block */: + case 209 /* IfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 218 /* WithStatement */: + case 219 /* SwitchStatement */: + case 254 /* CaseClause */: + case 255 /* DefaultClause */: + case 220 /* LabeledStatement */: + case 222 /* TryStatement */: + case 257 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -7119,11 +7153,11 @@ var ts; if (operand) { traverse(operand); } - case 229 /* EnumDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 226 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 228 /* InterfaceDeclaration */: + case 231 /* ModuleDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* 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 @@ -7170,13 +7204,13 @@ var ts; if (node) { switch (node.kind) { case 174 /* BindingElement */: - case 260 /* EnumMember */: + case 261 /* EnumMember */: case 144 /* Parameter */: - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 258 /* ShorthandPropertyAssignment */: - case 223 /* VariableDeclaration */: + case 259 /* ShorthandPropertyAssignment */: + case 224 /* VariableDeclaration */: return true; } } @@ -7188,7 +7222,7 @@ var ts; } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 226 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */); + return node && (node.kind === 227 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7199,7 +7233,7 @@ var ts; switch (kind) { case 150 /* Constructor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -7222,7 +7256,7 @@ var ts; case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: return true; } @@ -7231,20 +7265,32 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: return true; - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; + function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + while (true) { + if (beforeUnwrapLabelCallback) { + beforeUnwrapLabelCallback(node); + } + if (node.statement.kind !== 220 /* LabeledStatement */) { + return node.statement; + } + node = node.statement; + } + } + ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 204 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 205 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { @@ -7323,9 +7369,9 @@ var ts; continue; } // Fall through - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: case 149 /* MethodDeclaration */: @@ -7336,13 +7382,26 @@ var ts; case 153 /* CallSignature */: case 154 /* ConstructSignature */: case 155 /* IndexSignature */: - case 229 /* EnumDeclaration */: - case 261 /* SourceFile */: + case 230 /* EnumDeclaration */: + case 262 /* SourceFile */: return node; } } } ts.getThisContainer = getThisContainer; + function getNewTargetContainer(node) { + var container = getThisContainer(node, /*includeArrowFunctions*/ false); + if (container) { + switch (container.kind) { + case 150 /* Constructor */: + case 226 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + return container; + } + } + return undefined; + } + ts.getNewTargetContainer = getNewTargetContainer; /** * Given an super call/property node, returns the closest node where * - a super call/property access is legal in the node and not legal in the parent node the node. @@ -7361,7 +7420,7 @@ var ts; case 142 /* ComputedPropertyName */: node = node.parent; break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: if (!stopOnFunctions) { @@ -7418,7 +7477,7 @@ var ts; function getEntityNameFromTypeNode(node) { switch (node.kind) { case 157 /* TypeReference */: - case 272 /* JSDocTypeReference */: + case 273 /* JSDocTypeReference */: return node.typeName; case 199 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) @@ -7453,25 +7512,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: // classes are valid targets return true; case 147 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 226 /* ClassDeclaration */; + return node.parent.kind === 227 /* ClassDeclaration */; case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 149 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && node.parent.kind === 226 /* ClassDeclaration */; + && node.parent.kind === 227 /* ClassDeclaration */; case 144 /* 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 !== undefined && (node.parent.kind === 150 /* Constructor */ || node.parent.kind === 149 /* MethodDeclaration */ || node.parent.kind === 152 /* SetAccessor */) - && node.parent.parent.kind === 226 /* ClassDeclaration */; + && node.parent.parent.kind === 227 /* ClassDeclaration */; } return false; } @@ -7487,7 +7546,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); case 149 /* MethodDeclaration */: case 152 /* SetAccessor */: @@ -7497,9 +7556,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 248 /* JsxOpeningElement */ || - parent.kind === 247 /* JsxSelfClosingElement */ || - parent.kind === 249 /* JsxClosingElement */) { + if (parent.kind === 249 /* JsxOpeningElement */ || + parent.kind === 248 /* JsxSelfClosingElement */ || + parent.kind === 250 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -7538,10 +7597,11 @@ var ts; case 194 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: case 198 /* OmittedExpression */: - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: + case 247 /* JsxElement */: + case 248 /* JsxSelfClosingElement */: case 195 /* YieldExpression */: case 189 /* AwaitExpression */: + case 202 /* MetaProperty */: return true; case 141 /* QualifiedName */: while (node.parent.kind === 141 /* QualifiedName */) { @@ -7558,46 +7618,46 @@ var ts; case 98 /* ThisKeyword */: var parent_3 = node.parent; switch (parent_3.kind) { - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 144 /* Parameter */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 260 /* EnumMember */: - case 257 /* PropertyAssignment */: + case 261 /* EnumMember */: + case 258 /* PropertyAssignment */: case 174 /* BindingElement */: return parent_3.initializer === node; - case 207 /* ExpressionStatement */: - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 216 /* ReturnStatement */: - case 217 /* WithStatement */: - case 218 /* SwitchStatement */: - case 253 /* CaseClause */: - case 220 /* ThrowStatement */: - case 218 /* SwitchStatement */: + case 208 /* ExpressionStatement */: + case 209 /* IfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 217 /* ReturnStatement */: + case 218 /* WithStatement */: + case 219 /* SwitchStatement */: + case 254 /* CaseClause */: + case 221 /* ThrowStatement */: + case 219 /* SwitchStatement */: return parent_3.expression === node; - case 211 /* ForStatement */: + case 212 /* ForStatement */: var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 224 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 225 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 225 /* VariableDeclarationList */) || forInStatement.expression === node; case 182 /* TypeAssertionExpression */: case 200 /* AsExpression */: return node === parent_3.expression; - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return node === parent_3.expression; case 142 /* ComputedPropertyName */: return node === parent_3.expression; case 145 /* Decorator */: - case 252 /* JsxExpression */: - case 251 /* JsxSpreadAttribute */: - case 259 /* SpreadAssignment */: + case 253 /* JsxExpression */: + case 252 /* JsxSpreadAttribute */: + case 260 /* SpreadAssignment */: return true; case 199 /* ExpressionWithTypeArguments */: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); @@ -7617,7 +7677,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 245 /* ExternalModuleReference */; + return node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 246 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7626,7 +7686,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 245 /* ExternalModuleReference */; + return node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 246 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7660,7 +7720,7 @@ var ts; * This function does not test if the node is in a JavaScript file or not. */ function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 223 /* VariableDeclaration */) { + if (s.valueDeclaration && s.valueDeclaration.kind === 224 /* VariableDeclaration */) { var declaration = s.valueDeclaration; return declaration.initializer && declaration.initializer.kind === 184 /* FunctionExpression */; } @@ -7713,35 +7773,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 236 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 235 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 245 /* ExternalModuleReference */) { + if (reference.kind === 246 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 241 /* ExportDeclaration */) { + if (node.kind === 242 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 230 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 231 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 235 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 238 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 235 /* ImportDeclaration */ + return node.kind === 236 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7752,8 +7812,8 @@ var ts; case 144 /* Parameter */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: - case 258 /* ShorthandPropertyAssignment */: - case 257 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: + case 258 /* PropertyAssignment */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: return node.questionToken !== undefined; @@ -7763,9 +7823,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 274 /* JSDocFunctionType */ && + return node.kind === 275 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 276 /* JSDocConstructorType */; + node.parameters[0].type.kind === 277 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { @@ -7778,7 +7838,7 @@ var ts; var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 281 /* JSDocParameterTag */) { + if (doc.kind === 282 /* JSDocParameterTag */) { if (doc.kind === kind) { result.push(doc); } @@ -7810,9 +7870,9 @@ var ts; // var x = function(name) { return name.length; } var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 205 /* VariableStatement */; + parent.parent.parent.kind === 206 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 205 /* VariableStatement */; + parent.parent.kind === 206 /* VariableStatement */; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -7823,13 +7883,13 @@ var ts; var isSourceOfAssignmentExpressionStatement = parent && parent.parent && parent.kind === 192 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && - parent.parent.kind === 207 /* ExpressionStatement */; + parent.parent.kind === 208 /* ExpressionStatement */; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 230 /* ModuleDeclaration */ && - parent && parent.kind === 230 /* ModuleDeclaration */; - var isPropertyAssignmentExpression = parent && parent.kind === 257 /* PropertyAssignment */; + var isModuleDeclaration = node.kind === 231 /* ModuleDeclaration */ && + parent && parent.kind === 231 /* ModuleDeclaration */; + var isPropertyAssignmentExpression = parent && parent.kind === 258 /* PropertyAssignment */; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } @@ -7848,18 +7908,18 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 281 /* JSDocParameterTag */); + var tags = getJSDocTags(func, 282 /* JSDocParameterTag */); if (!param.name) { // this is an anonymous jsdoc param from a `function(type1, type2): type3` specification var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 281 /* JSDocParameterTag */; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 282 /* JSDocParameterTag */; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70 /* Identifier */) { var name_6 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 281 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); + return ts.filter(tags, function (tag) { return tag.kind === 282 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); } else { // TODO: it's a destructured parameter, so it should look up an "object type" series of multiple lines @@ -7869,7 +7929,7 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 283 /* JSDocTypeTag */); + var tag = getFirstJSDocTag(node, 284 /* JSDocTypeTag */); if (!tag && node.kind === 144 /* Parameter */) { var paramTags = getJSDocParameterTags(node); if (paramTags) { @@ -7880,15 +7940,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 280 /* JSDocAugmentsTag */); + return getFirstJSDocTag(node, 281 /* JSDocAugmentsTag */); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 282 /* JSDocReturnTag */); + return getFirstJSDocTag(node, 283 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 284 /* JSDocTemplateTag */); + return getFirstJSDocTag(node, 285 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -7901,8 +7961,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536 /* JavaScriptFile */)) { - if (node.type && node.type.kind === 275 /* JSDocVariadicType */ || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275 /* JSDocVariadicType */; })) { + if (node.type && node.type.kind === 276 /* JSDocVariadicType */ || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 276 /* JSDocVariadicType */; })) { return true; } } @@ -7932,20 +7992,20 @@ var ts; case 191 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 42 /* PlusPlusToken */ || unaryOperator === 43 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; case 183 /* ParenthesizedExpression */: case 175 /* ArrayLiteralExpression */: case 196 /* SpreadElement */: node = parent; break; - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } // Fall through - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: node = parent.parent; break; default: @@ -7962,6 +8022,18 @@ var ts; return getAssignmentTargetKind(node) !== 0 /* None */; } ts.isAssignmentTarget = isAssignmentTarget; + // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped + function isDeleteTarget(node) { + if (node.kind !== 177 /* PropertyAccessExpression */ && node.kind !== 178 /* ElementAccessExpression */) { + return false; + } + node = node.parent; + while (node && node.kind === 183 /* ParenthesizedExpression */) { + node = node.parent; + } + return node && node.kind === 186 /* DeleteExpression */; + } + ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { while (node) { if (node === ancestor) @@ -7973,7 +8045,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2 /* Ambient */) || (node.kind === 261 /* SourceFile */ && node.isDeclarationFile)) { + if (hasModifier(node, 2 /* Ambient */) || (node.kind === 262 /* SourceFile */ && node.isDeclarationFile)) { return true; } node = node.parent; @@ -7987,7 +8059,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 239 /* ImportSpecifier */ || parent.kind === 243 /* ExportSpecifier */) { + if (parent.kind === 240 /* ImportSpecifier */ || parent.kind === 244 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -8014,8 +8086,8 @@ var ts; case 148 /* MethodSignature */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 260 /* EnumMember */: - case 257 /* PropertyAssignment */: + case 261 /* EnumMember */: + case 258 /* PropertyAssignment */: case 177 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; @@ -8029,10 +8101,10 @@ var ts; } return false; case 174 /* BindingElement */: - case 239 /* ImportSpecifier */: + case 240 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 243 /* ExportSpecifier */: + case 244 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -8048,13 +8120,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ || - node.kind === 233 /* NamespaceExportDeclaration */ || - node.kind === 236 /* ImportClause */ && !!node.name || - node.kind === 237 /* NamespaceImport */ || - node.kind === 239 /* ImportSpecifier */ || - node.kind === 243 /* ExportSpecifier */ || - node.kind === 240 /* ExportAssignment */ && exportAssignmentIsAlias(node); + return node.kind === 235 /* ImportEqualsDeclaration */ || + node.kind === 234 /* NamespaceExportDeclaration */ || + node.kind === 237 /* ImportClause */ && !!node.name || + node.kind === 238 /* NamespaceImport */ || + node.kind === 240 /* ImportSpecifier */ || + node.kind === 244 /* ExportSpecifier */ || + node.kind === 241 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8249,13 +8321,13 @@ var ts; var kind = node.kind; return kind === 150 /* Constructor */ || kind === 184 /* FunctionExpression */ - || kind === 225 /* FunctionDeclaration */ + || kind === 226 /* FunctionDeclaration */ || kind === 185 /* ArrowFunction */ || kind === 149 /* MethodDeclaration */ || kind === 151 /* GetAccessor */ || kind === 152 /* SetAccessor */ - || kind === 230 /* ModuleDeclaration */ - || kind === 261 /* SourceFile */; + || kind === 231 /* ModuleDeclaration */ + || kind === 262 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8387,14 +8459,13 @@ var ts; case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 197 /* ClassExpression */: - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: + case 247 /* JsxElement */: + case 248 /* JsxSelfClosingElement */: case 11 /* RegularExpressionLiteral */: case 12 /* NoSubstitutionTemplateLiteral */: case 194 /* TemplateExpression */: case 183 /* ParenthesizedExpression */: case 198 /* OmittedExpression */: - case 297 /* RawExpression */: return 19; case 181 /* TaggedTemplateExpression */: case 177 /* PropertyAccessExpression */: @@ -8578,13 +8649,12 @@ var ts; * Note that this doesn't actually wrap the input in double quotes. */ function escapeString(s) { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; - return s; - function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } + return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; + function getReplacement(c) { + return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); return ch.toLowerCase() === ch; @@ -9638,8 +9708,8 @@ var ts; var parseNode = getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -9660,7 +9730,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 /* ClassDeclaration */ && declaration !== node) { + if (declaration.kind === 227 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9725,6 +9795,10 @@ var ts; return node.kind === 70 /* Identifier */; } ts.isIdentifier = isIdentifier; + function isVoidExpression(node) { + return node.kind === 188 /* VoidExpression */; + } + ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { // Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`. return isIdentifier(node) && node.autoGenerateKind > 0 /* None */; @@ -9797,18 +9871,18 @@ var ts; || kind === 151 /* GetAccessor */ || kind === 152 /* SetAccessor */ || kind === 155 /* IndexSignature */ - || kind === 203 /* SemicolonClassElement */; + || kind === 204 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 257 /* PropertyAssignment */ - || kind === 258 /* ShorthandPropertyAssignment */ - || kind === 259 /* SpreadAssignment */ + return kind === 258 /* PropertyAssignment */ + || kind === 259 /* ShorthandPropertyAssignment */ + || kind === 260 /* SpreadAssignment */ || kind === 149 /* MethodDeclaration */ || kind === 151 /* GetAccessor */ || kind === 152 /* SetAccessor */ - || kind === 244 /* MissingDeclaration */; + || kind === 245 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -9871,7 +9945,7 @@ var ts; */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 144 /* Parameter */: case 174 /* BindingElement */: return true; @@ -9959,8 +10033,8 @@ var ts; || kind === 178 /* ElementAccessExpression */ || kind === 180 /* NewExpression */ || kind === 179 /* CallExpression */ - || kind === 246 /* JsxElement */ - || kind === 247 /* JsxSelfClosingElement */ + || kind === 247 /* JsxElement */ + || kind === 248 /* JsxSelfClosingElement */ || kind === 181 /* TaggedTemplateExpression */ || kind === 175 /* ArrayLiteralExpression */ || kind === 183 /* ParenthesizedExpression */ @@ -9979,7 +10053,7 @@ var ts; || kind === 100 /* TrueKeyword */ || kind === 96 /* SuperKeyword */ || kind === 201 /* NonNullExpression */ - || kind === 297 /* RawExpression */; + || kind === 202 /* MetaProperty */; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); @@ -10007,7 +10081,6 @@ var ts; || kind === 196 /* SpreadElement */ || kind === 200 /* AsExpression */ || kind === 198 /* OmittedExpression */ - || kind === 297 /* RawExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -10021,11 +10094,11 @@ var ts; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 294 /* PartiallyEmittedExpression */; + return node.kind === 295 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 293 /* NotEmittedStatement */; + return node.kind === 294 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10039,12 +10112,12 @@ var ts; ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 202 /* TemplateSpan */; + return node.kind === 203 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 204 /* Block */; + return node.kind === 205 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -10062,121 +10135,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 223 /* VariableDeclaration */; + return node.kind === 224 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 224 /* VariableDeclarationList */; + return node.kind === 225 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 232 /* CaseBlock */; + return node.kind === 233 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 231 /* ModuleBlock */ - || kind === 230 /* ModuleDeclaration */; + return kind === 232 /* ModuleBlock */ + || kind === 231 /* ModuleDeclaration */; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */; + return node.kind === 235 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 236 /* ImportClause */; + return node.kind === 237 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 238 /* NamedImports */ - || kind === 237 /* NamespaceImport */; + return kind === 239 /* NamedImports */ + || kind === 238 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 239 /* ImportSpecifier */; + return node.kind === 240 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 242 /* NamedExports */; + return node.kind === 243 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 243 /* ExportSpecifier */; + return node.kind === 244 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 230 /* ModuleDeclaration */ || node.kind === 229 /* EnumDeclaration */; + return node.kind === 231 /* ModuleDeclaration */ || node.kind === 230 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { return kind === 185 /* ArrowFunction */ || kind === 174 /* BindingElement */ - || kind === 226 /* ClassDeclaration */ + || kind === 227 /* ClassDeclaration */ || kind === 197 /* ClassExpression */ || kind === 150 /* Constructor */ - || kind === 229 /* EnumDeclaration */ - || kind === 260 /* EnumMember */ - || kind === 243 /* ExportSpecifier */ - || kind === 225 /* FunctionDeclaration */ + || kind === 230 /* EnumDeclaration */ + || kind === 261 /* EnumMember */ + || kind === 244 /* ExportSpecifier */ + || kind === 226 /* FunctionDeclaration */ || kind === 184 /* FunctionExpression */ || kind === 151 /* GetAccessor */ - || kind === 236 /* ImportClause */ - || kind === 234 /* ImportEqualsDeclaration */ - || kind === 239 /* ImportSpecifier */ - || kind === 227 /* InterfaceDeclaration */ + || kind === 237 /* ImportClause */ + || kind === 235 /* ImportEqualsDeclaration */ + || kind === 240 /* ImportSpecifier */ + || kind === 228 /* InterfaceDeclaration */ || kind === 149 /* MethodDeclaration */ || kind === 148 /* MethodSignature */ - || kind === 230 /* ModuleDeclaration */ - || kind === 233 /* NamespaceExportDeclaration */ - || kind === 237 /* NamespaceImport */ + || kind === 231 /* ModuleDeclaration */ + || kind === 234 /* NamespaceExportDeclaration */ + || kind === 238 /* NamespaceImport */ || kind === 144 /* Parameter */ - || kind === 257 /* PropertyAssignment */ + || kind === 258 /* PropertyAssignment */ || kind === 147 /* PropertyDeclaration */ || kind === 146 /* PropertySignature */ || kind === 152 /* SetAccessor */ - || kind === 258 /* ShorthandPropertyAssignment */ - || kind === 228 /* TypeAliasDeclaration */ + || kind === 259 /* ShorthandPropertyAssignment */ + || kind === 229 /* TypeAliasDeclaration */ || kind === 143 /* TypeParameter */ - || kind === 223 /* VariableDeclaration */ - || kind === 285 /* JSDocTypedefTag */; + || kind === 224 /* VariableDeclaration */ + || kind === 286 /* JSDocTypedefTag */; } function isDeclarationStatementKind(kind) { - return kind === 225 /* FunctionDeclaration */ - || kind === 244 /* MissingDeclaration */ - || kind === 226 /* ClassDeclaration */ - || kind === 227 /* InterfaceDeclaration */ - || kind === 228 /* TypeAliasDeclaration */ - || kind === 229 /* EnumDeclaration */ - || kind === 230 /* ModuleDeclaration */ - || kind === 235 /* ImportDeclaration */ - || kind === 234 /* ImportEqualsDeclaration */ - || kind === 241 /* ExportDeclaration */ - || kind === 240 /* ExportAssignment */ - || kind === 233 /* NamespaceExportDeclaration */; + return kind === 226 /* FunctionDeclaration */ + || kind === 245 /* MissingDeclaration */ + || kind === 227 /* ClassDeclaration */ + || kind === 228 /* InterfaceDeclaration */ + || kind === 229 /* TypeAliasDeclaration */ + || kind === 230 /* EnumDeclaration */ + || kind === 231 /* ModuleDeclaration */ + || kind === 236 /* ImportDeclaration */ + || kind === 235 /* ImportEqualsDeclaration */ + || kind === 242 /* ExportDeclaration */ + || kind === 241 /* ExportAssignment */ + || kind === 234 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 215 /* BreakStatement */ - || kind === 214 /* ContinueStatement */ - || kind === 222 /* DebuggerStatement */ - || kind === 209 /* DoStatement */ - || kind === 207 /* ExpressionStatement */ - || kind === 206 /* EmptyStatement */ - || kind === 212 /* ForInStatement */ - || kind === 213 /* ForOfStatement */ - || kind === 211 /* ForStatement */ - || kind === 208 /* IfStatement */ - || kind === 219 /* LabeledStatement */ - || kind === 216 /* ReturnStatement */ - || kind === 218 /* SwitchStatement */ - || kind === 220 /* ThrowStatement */ - || kind === 221 /* TryStatement */ - || kind === 205 /* VariableStatement */ - || kind === 210 /* WhileStatement */ - || kind === 217 /* WithStatement */ - || kind === 293 /* NotEmittedStatement */ - || kind === 296 /* EndOfDeclarationMarker */ - || kind === 295 /* MergeDeclarationMarker */; + return kind === 216 /* BreakStatement */ + || kind === 215 /* ContinueStatement */ + || kind === 223 /* DebuggerStatement */ + || kind === 210 /* DoStatement */ + || kind === 208 /* ExpressionStatement */ + || kind === 207 /* EmptyStatement */ + || kind === 213 /* ForInStatement */ + || kind === 214 /* ForOfStatement */ + || kind === 212 /* ForStatement */ + || kind === 209 /* IfStatement */ + || kind === 220 /* LabeledStatement */ + || kind === 217 /* ReturnStatement */ + || kind === 219 /* SwitchStatement */ + || kind === 221 /* ThrowStatement */ + || kind === 222 /* TryStatement */ + || kind === 206 /* VariableStatement */ + || kind === 211 /* WhileStatement */ + || kind === 218 /* WithStatement */ + || kind === 294 /* NotEmittedStatement */ + || kind === 297 /* EndOfDeclarationMarker */ + || kind === 296 /* MergeDeclarationMarker */; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10197,24 +10270,24 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 204 /* Block */; + || kind === 205 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 245 /* ExternalModuleReference */ + return kind === 246 /* ExternalModuleReference */ || kind === 141 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 248 /* JsxOpeningElement */; + return node.kind === 249 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 249 /* JsxClosingElement */; + return node.kind === 250 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { @@ -10226,64 +10299,64 @@ var ts; ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 246 /* JsxElement */ - || kind === 252 /* JsxExpression */ - || kind === 247 /* JsxSelfClosingElement */ + return kind === 247 /* JsxElement */ + || kind === 253 /* JsxExpression */ + || kind === 248 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 250 /* JsxAttribute */ - || kind === 251 /* JsxSpreadAttribute */; + return kind === 251 /* JsxAttribute */ + || kind === 252 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 251 /* JsxSpreadAttribute */; + return node.kind === 252 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 250 /* JsxAttribute */; + return node.kind === 251 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 252 /* JsxExpression */; + || kind === 253 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 253 /* CaseClause */ - || kind === 254 /* DefaultClause */; + return kind === 254 /* CaseClause */ + || kind === 255 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 255 /* HeritageClause */; + return node.kind === 256 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 256 /* CatchClause */; + return node.kind === 257 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 257 /* PropertyAssignment */; + return node.kind === 258 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 258 /* ShorthandPropertyAssignment */; + return node.kind === 259 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; // Enum function isEnumMember(node) { - return node.kind === 260 /* EnumMember */; + return node.kind === 261 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 261 /* SourceFile */; + return node.kind === 262 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10515,7 +10588,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 143 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 227 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 228 /* InterfaceDeclaration */) { return current; } } @@ -10535,14 +10608,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 224 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 224 /* VariableDeclarationList */) { + if (node && node.kind === 225 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 205 /* VariableStatement */) { + if (node && node.kind === 206 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10558,14 +10631,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 224 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 224 /* VariableDeclarationList */) { + if (node && node.kind === 225 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 205 /* VariableStatement */) { + if (node && node.kind === 206 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -10634,7 +10707,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 261 /* SourceFile */ + var ConstructorForKind = kind === 262 /* SourceFile */ ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -11351,7 +11424,7 @@ var ts; ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; // Misc function createTemplateSpan(expression, literal, location) { - var node = createNode(202 /* TemplateSpan */, location); + var node = createNode(203 /* TemplateSpan */, location); node.expression = expression; node.literal = literal; return node; @@ -11366,7 +11439,7 @@ var ts; ts.updateTemplateSpan = updateTemplateSpan; // Element function createBlock(statements, location, multiLine, flags) { - var block = createNode(204 /* Block */, location, flags); + var block = createNode(205 /* Block */, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -11382,7 +11455,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(205 /* VariableStatement */, location, flags); + var node = createNode(206 /* VariableStatement */, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -11397,7 +11470,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(224 /* VariableDeclarationList */, location, flags); + var node = createNode(225 /* VariableDeclarationList */, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -11410,7 +11483,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(223 /* VariableDeclaration */, location, flags); + var node = createNode(224 /* VariableDeclaration */, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11425,11 +11498,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(206 /* EmptyStatement */, location); + return createNode(207 /* EmptyStatement */, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(207 /* ExpressionStatement */, location, flags); + var node = createNode(208 /* ExpressionStatement */, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -11442,7 +11515,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(208 /* IfStatement */, location); + var node = createNode(209 /* IfStatement */, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11457,7 +11530,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(209 /* DoStatement */, location); + var node = createNode(210 /* DoStatement */, location); node.statement = statement; node.expression = expression; return node; @@ -11471,7 +11544,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(210 /* WhileStatement */, location); + var node = createNode(211 /* WhileStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11485,7 +11558,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(211 /* ForStatement */, location, /*flags*/ undefined); + var node = createNode(212 /* ForStatement */, location, /*flags*/ undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11501,7 +11574,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(212 /* ForInStatement */, location); + var node = createNode(213 /* ForInStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11516,7 +11589,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(213 /* ForOfStatement */, location); + var node = createNode(214 /* ForOfStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11531,7 +11604,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(214 /* ContinueStatement */, location); + var node = createNode(215 /* ContinueStatement */, location); if (label) { node.label = label; } @@ -11546,7 +11619,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(215 /* BreakStatement */, location); + var node = createNode(216 /* BreakStatement */, location); if (label) { node.label = label; } @@ -11561,7 +11634,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(216 /* ReturnStatement */, location); + var node = createNode(217 /* ReturnStatement */, location); node.expression = expression; return node; } @@ -11574,7 +11647,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(217 /* WithStatement */, location); + var node = createNode(218 /* WithStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11588,7 +11661,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(218 /* SwitchStatement */, location); + var node = createNode(219 /* SwitchStatement */, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11602,7 +11675,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(219 /* LabeledStatement */, location); + var node = createNode(220 /* LabeledStatement */, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11616,7 +11689,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(220 /* ThrowStatement */, location); + var node = createNode(221 /* ThrowStatement */, location); node.expression = expression; return node; } @@ -11629,7 +11702,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(221 /* TryStatement */, location); + var node = createNode(222 /* TryStatement */, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11644,7 +11717,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(232 /* CaseBlock */, location); + var node = createNode(233 /* CaseBlock */, location); node.clauses = createNodeArray(clauses); return node; } @@ -11657,7 +11730,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(225 /* FunctionDeclaration */, location, flags); + var node = createNode(226 /* FunctionDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11677,7 +11750,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(226 /* ClassDeclaration */, location); + var node = createNode(227 /* ClassDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11695,7 +11768,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(235 /* ImportDeclaration */, location); + var node = createNode(236 /* ImportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11711,7 +11784,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(236 /* ImportClause */, location); + var node = createNode(237 /* ImportClause */, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11725,7 +11798,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(237 /* NamespaceImport */, location); + var node = createNode(238 /* NamespaceImport */, location); node.name = name; return node; } @@ -11738,7 +11811,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(238 /* NamedImports */, location); + var node = createNode(239 /* NamedImports */, location); node.elements = createNodeArray(elements); return node; } @@ -11751,7 +11824,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(239 /* ImportSpecifier */, location); + var node = createNode(240 /* ImportSpecifier */, location); node.propertyName = propertyName; node.name = name; return node; @@ -11765,7 +11838,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(240 /* ExportAssignment */, location); + var node = createNode(241 /* ExportAssignment */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11781,7 +11854,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(241 /* ExportDeclaration */, location); + var node = createNode(242 /* ExportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11797,7 +11870,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(242 /* NamedExports */, location); + var node = createNode(243 /* NamedExports */, location); node.elements = createNodeArray(elements); return node; } @@ -11810,7 +11883,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(243 /* ExportSpecifier */, location); + var node = createNode(244 /* ExportSpecifier */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11825,7 +11898,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // JSX function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(246 /* JsxElement */, location); + var node = createNode(247 /* JsxElement */, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11840,7 +11913,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(247 /* JsxSelfClosingElement */, location); + var node = createNode(248 /* JsxSelfClosingElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11854,7 +11927,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(248 /* JsxOpeningElement */, location); + var node = createNode(249 /* JsxOpeningElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11868,7 +11941,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(249 /* JsxClosingElement */, location); + var node = createNode(250 /* JsxClosingElement */, location); node.tagName = tagName; return node; } @@ -11881,7 +11954,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(250 /* JsxAttribute */, location); + var node = createNode(251 /* JsxAttribute */, location); node.name = name; node.initializer = initializer; return node; @@ -11895,7 +11968,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(251 /* JsxSpreadAttribute */, location); + var node = createNode(252 /* JsxSpreadAttribute */, location); node.expression = expression; return node; } @@ -11907,22 +11980,23 @@ var ts; return node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, location) { - var node = createNode(252 /* JsxExpression */, location); + function createJsxExpression(expression, dotDotDotToken, location) { + var node = createNode(253 /* JsxExpression */, location); + node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node), node); + return updateNode(createJsxExpression(expression, node.dotDotDotToken, node), node); } return node; } ts.updateJsxExpression = updateJsxExpression; // Clauses function createHeritageClause(token, types, location) { - var node = createNode(255 /* HeritageClause */, location); + var node = createNode(256 /* HeritageClause */, location); node.token = token; node.types = createNodeArray(types); return node; @@ -11936,7 +12010,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(253 /* CaseClause */, location); + var node = createNode(254 /* CaseClause */, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -11950,7 +12024,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(254 /* DefaultClause */, location); + var node = createNode(255 /* DefaultClause */, location); node.statements = createNodeArray(statements); return node; } @@ -11963,7 +12037,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(256 /* CatchClause */, location); + var node = createNode(257 /* CatchClause */, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11978,7 +12052,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer, location) { - var node = createNode(257 /* PropertyAssignment */, location); + var node = createNode(258 /* PropertyAssignment */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11993,14 +12067,14 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(258 /* ShorthandPropertyAssignment */, location); + var node = createNode(259 /* ShorthandPropertyAssignment */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; function createSpreadAssignment(expression, location) { - var node = createNode(259 /* SpreadAssignment */, location); + var node = createNode(260 /* SpreadAssignment */, location); node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; return node; } @@ -12022,7 +12096,7 @@ var ts; // Top-level nodes function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(261 /* SourceFile */, /*location*/ node, node.flags); + var updated = createNode(262 /* SourceFile */, /*location*/ node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -12089,7 +12163,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createNode(293 /* NotEmittedStatement */, /*location*/ original); + var node = createNode(294 /* NotEmittedStatement */, /*location*/ original); node.original = original; return node; } @@ -12099,7 +12173,7 @@ var ts; * order to properly emit exports. */ function createEndOfDeclarationMarker(original) { - var node = createNode(296 /* EndOfDeclarationMarker */); + var node = createNode(297 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12110,7 +12184,7 @@ var ts; * order to properly emit exports. */ function createMergeDeclarationMarker(original) { - var node = createNode(295 /* MergeDeclarationMarker */); + var node = createNode(296 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12125,7 +12199,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(294 /* PartiallyEmittedExpression */, /*location*/ location || original); + var node = createNode(295 /* PartiallyEmittedExpression */, /*location*/ location || original); node.expression = expression; node.original = original; return node; @@ -12138,19 +12212,6 @@ var ts; return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; - /** - * Creates a node that emits a string of raw text in an expression position. Raw text is never - * transformed, should be ES3 compliant, and should have the same precedence as - * PrimaryExpression. - * - * @param text The raw text of the node. - */ - function createRawExpression(text) { - var node = createNode(297 /* RawExpression */); - node.text = text; - return node; - } - ts.createRawExpression = createRawExpression; // Compound nodes function createComma(left, right) { return createBinary(left, 25 /* CommaToken */, right); @@ -12326,6 +12387,20 @@ var ts; return setEmitFlags(createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } ts.getHelperName = getHelperName; + // Utilities + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 220 /* LabeledStatement */ + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { @@ -12432,9 +12507,9 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); case 149 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); @@ -12999,7 +13074,7 @@ var ts; case 177 /* PropertyAccessExpression */: node = node.expression; continue; - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -13054,7 +13129,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 294 /* PartiallyEmittedExpression */) { + while (node.kind === 295 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -13133,7 +13208,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -13391,10 +13466,10 @@ var ts; var name_9 = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 235 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 236 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 241 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 242 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -13514,7 +13589,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -13526,11 +13601,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -13567,7 +13642,7 @@ var ts; // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; case 196 /* SpreadElement */: - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -13591,7 +13666,7 @@ var ts; : propertyName; } break; - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -13603,7 +13678,7 @@ var ts; : propertyName; } break; - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -13717,20 +13792,20 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); break; - case 234 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 245 /* ExternalModuleReference */) { + case 235 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 246 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -13760,13 +13835,13 @@ var ts; } } break; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -13774,7 +13849,7 @@ var ts; } } break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -13794,7 +13869,7 @@ var ts; } } break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -13847,7 +13922,7 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 261 /* SourceFile */) { + if (kind === 262 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70 /* Identifier */) { @@ -13903,20 +13978,20 @@ var ts; return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: return visitNode(cbNode, node.expression); case 144 /* Parameter */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 223 /* VariableDeclaration */: + case 258 /* PropertyAssignment */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -13942,7 +14017,7 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -14034,6 +14109,8 @@ var ts; visitNode(cbNode, node.type); case 201 /* NonNullExpression */: return visitNode(cbNode, node.expression); + case 202 /* MetaProperty */: + return visitNode(cbNode, node.name); case 193 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || @@ -14042,76 +14119,76 @@ var ts; visitNode(cbNode, node.whenFalse); case 196 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 204 /* Block */: - case 231 /* ModuleBlock */: + case 205 /* Block */: + case 232 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 261 /* SourceFile */: + case 262 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 215 /* ContinueStatement */: + case 216 /* BreakStatement */: return visitNode(cbNode, node.label); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 253 /* CaseClause */: + case 254 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 145 /* Decorator */: return visitNode(cbNode, node.expression); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -14119,155 +14196,156 @@ var ts; visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 227 /* InterfaceDeclaration */: + case 228 /* 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 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 260 /* EnumMember */: + case 261 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 233 /* NamespaceExportDeclaration */: + case 234 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 239 /* NamedImports */: + case 243 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); case 194 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 142 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: return visitNodes(cbNodes, node.types); case 199 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 245 /* ExternalModuleReference */: + case 246 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 244 /* MissingDeclaration */: + case 245 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 246 /* JsxElement */: + case 247 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 248 /* JsxSelfClosingElement */: + case 249 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 252 /* JsxExpression */: - return visitNode(cbNode, node.expression); - case 249 /* JsxClosingElement */: + case 253 /* JsxExpression */: + return visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.expression); + case 250 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 262 /* JSDocTypeExpression */: + case 263 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 266 /* JSDocUnionType */: + case 267 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 267 /* JSDocTupleType */: + case 268 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 265 /* JSDocArrayType */: + case 266 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 269 /* JSDocNonNullableType */: + case 270 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 268 /* JSDocNullableType */: + case 269 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 270 /* JSDocRecordType */: + case 271 /* JSDocRecordType */: return visitNode(cbNode, node.literal); - case 272 /* JSDocTypeReference */: + case 273 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 273 /* JSDocOptionalType */: + case 274 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 274 /* JSDocFunctionType */: + case 275 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 275 /* JSDocVariadicType */: + case 276 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 276 /* JSDocConstructorType */: + case 277 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 277 /* JSDocThisType */: + case 278 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 271 /* JSDocRecordMember */: + case 272 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 278 /* JSDocComment */: + case 279 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 281 /* JSDocParameterTag */: + case 282 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 282 /* JSDocReturnTag */: + case 283 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 283 /* JSDocTypeTag */: + case 284 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 280 /* JSDocAugmentsTag */: + case 281 /* JSDocAugmentsTag */: return visitNode(cbNode, node.typeExpression); - case 284 /* JSDocTemplateTag */: + case 285 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 287 /* JSDocTypeLiteral */: + case 288 /* JSDocTypeLiteral */: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 286 /* JSDocPropertyTag */: + case 287 /* JSDocPropertyTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); - case 288 /* JSDocLiteralType */: + case 289 /* JSDocLiteralType */: return visitNode(cbNode, node.literal); } } @@ -14539,7 +14617,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(261 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(262 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -15327,7 +15405,7 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 147 /* PropertyDeclaration */: - case 203 /* SemicolonClassElement */: + case 204 /* SemicolonClassElement */: return true; case 149 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal @@ -15344,8 +15422,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 254 /* CaseClause */: + case 255 /* DefaultClause */: return true; } } @@ -15354,42 +15432,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: - case 205 /* VariableStatement */: - case 204 /* Block */: - case 208 /* IfStatement */: - case 207 /* ExpressionStatement */: - case 220 /* ThrowStatement */: - case 216 /* ReturnStatement */: - case 218 /* SwitchStatement */: - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 211 /* ForStatement */: - case 210 /* WhileStatement */: - case 217 /* WithStatement */: - case 206 /* EmptyStatement */: - case 221 /* TryStatement */: - case 219 /* LabeledStatement */: - case 209 /* DoStatement */: - case 222 /* DebuggerStatement */: - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: - case 240 /* ExportAssignment */: - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 226 /* FunctionDeclaration */: + case 206 /* VariableStatement */: + case 205 /* Block */: + case 209 /* IfStatement */: + case 208 /* ExpressionStatement */: + case 221 /* ThrowStatement */: + case 217 /* ReturnStatement */: + case 219 /* SwitchStatement */: + case 216 /* BreakStatement */: + case 215 /* ContinueStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 212 /* ForStatement */: + case 211 /* WhileStatement */: + case 218 /* WithStatement */: + case 207 /* EmptyStatement */: + case 222 /* TryStatement */: + case 220 /* LabeledStatement */: + case 210 /* DoStatement */: + case 223 /* DebuggerStatement */: + case 236 /* ImportDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 242 /* ExportDeclaration */: + case 241 /* ExportAssignment */: + case 231 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: + case 229 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 260 /* EnumMember */; + return node.kind === 261 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { @@ -15405,7 +15483,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 223 /* VariableDeclaration */) { + if (node.kind !== 224 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -15590,7 +15668,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(202 /* TemplateSpan */); + var span = createNode(203 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17 /* CloseBraceToken */) { @@ -17179,8 +17257,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 248 /* JsxOpeningElement */) { - var node = createNode(246 /* JsxElement */, opening.pos); + if (opening.kind === 249 /* JsxOpeningElement */) { + var node = createNode(247 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -17190,7 +17268,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 247 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 248 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -17264,7 +17342,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(248 /* JsxOpeningElement */, fullStart); + node = createNode(249 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -17276,7 +17354,7 @@ var ts; parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(247 /* JsxSelfClosingElement */, fullStart); + node = createNode(248 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -17300,9 +17378,10 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(252 /* JsxExpression */); + var node = createNode(253 /* JsxExpression */); parseExpected(16 /* OpenBraceToken */); if (token() !== 17 /* CloseBraceToken */) { + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { @@ -17319,7 +17398,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(250 /* JsxAttribute */); + var node = createNode(251 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 57 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -17334,7 +17413,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(251 /* JsxSpreadAttribute */); + var node = createNode(252 /* JsxSpreadAttribute */); parseExpected(16 /* OpenBraceToken */); parseExpected(23 /* DotDotDotToken */); node.expression = parseExpression(); @@ -17342,7 +17421,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(249 /* JsxClosingElement */); + var node = createNode(250 /* JsxClosingElement */); parseExpected(27 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -17581,7 +17660,7 @@ var ts; var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); if (dotDotDotToken) { - var spreadElement = createNode(259 /* SpreadAssignment */, fullStart); + var spreadElement = createNode(260 /* SpreadAssignment */, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -17606,7 +17685,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 /* CommaToken */ || token() === 17 /* CloseBraceToken */ || token() === 57 /* EqualsToken */); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(258 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(259 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57 /* EqualsToken */); @@ -17617,7 +17696,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(257 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(258 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -17668,8 +17747,15 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(180 /* NewExpression */); + var fullStart = scanner.getStartPos(); parseExpected(93 /* NewKeyword */); + if (parseOptional(22 /* DotToken */)) { + var node_1 = createNode(202 /* MetaProperty */, fullStart); + node_1.keywordToken = 93 /* NewKeyword */; + node_1.name = parseIdentifierName(); + return finishNode(node_1); + } + var node = createNode(180 /* NewExpression */, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18 /* OpenParenToken */) { @@ -17679,7 +17765,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(204 /* Block */); + var node = createNode(205 /* Block */); if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17712,12 +17798,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(206 /* EmptyStatement */); + var node = createNode(207 /* EmptyStatement */); parseExpected(24 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(208 /* IfStatement */); + var node = createNode(209 /* IfStatement */); parseExpected(89 /* IfKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17727,7 +17813,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(209 /* DoStatement */); + var node = createNode(210 /* DoStatement */); parseExpected(80 /* DoKeyword */); node.statement = parseStatement(); parseExpected(105 /* WhileKeyword */); @@ -17742,7 +17828,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(210 /* WhileStatement */); + var node = createNode(211 /* WhileStatement */); parseExpected(105 /* WhileKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17765,21 +17851,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91 /* InKeyword */)) { - var forInStatement = createNode(212 /* ForInStatement */, pos); + var forInStatement = createNode(213 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else if (parseOptional(140 /* OfKeyword */)) { - var forOfStatement = createNode(213 /* ForOfStatement */, pos); + var forOfStatement = createNode(214 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(211 /* ForStatement */, pos); + var forStatement = createNode(212 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(24 /* SemicolonToken */); if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { @@ -17797,7 +17883,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 215 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); + parseExpected(kind === 216 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -17805,7 +17891,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(216 /* ReturnStatement */); + var node = createNode(217 /* ReturnStatement */); parseExpected(95 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -17814,7 +17900,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(217 /* WithStatement */); + var node = createNode(218 /* WithStatement */); parseExpected(106 /* WithKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17823,7 +17909,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(253 /* CaseClause */); + var node = createNode(254 /* CaseClause */); parseExpected(72 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(55 /* ColonToken */); @@ -17831,7 +17917,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(254 /* DefaultClause */); + var node = createNode(255 /* DefaultClause */); parseExpected(78 /* DefaultKeyword */); parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -17841,12 +17927,12 @@ var ts; return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(218 /* SwitchStatement */); + var node = createNode(219 /* SwitchStatement */); parseExpected(97 /* SwitchKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); - var caseBlock = createNode(232 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(233 /* CaseBlock */, scanner.getStartPos()); parseExpected(16 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(17 /* CloseBraceToken */); @@ -17861,7 +17947,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(220 /* ThrowStatement */); + var node = createNode(221 /* ThrowStatement */); parseExpected(99 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -17869,7 +17955,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(221 /* TryStatement */); + var node = createNode(222 /* TryStatement */); parseExpected(101 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 73 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -17882,7 +17968,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(256 /* CatchClause */); + var result = createNode(257 /* CatchClause */); parseExpected(73 /* CatchKeyword */); if (parseExpected(18 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -17892,7 +17978,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(222 /* DebuggerStatement */); + var node = createNode(223 /* DebuggerStatement */); parseExpected(77 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -17904,13 +17990,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 /* Identifier */ && parseOptional(55 /* ColonToken */)) { - var labeledStatement = createNode(219 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(220 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(207 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(208 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -18091,9 +18177,9 @@ var ts; case 87 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 76 /* ContinueKeyword */: - return parseBreakOrContinueStatement(214 /* ContinueStatement */); + return parseBreakOrContinueStatement(215 /* ContinueStatement */); case 71 /* BreakKeyword */: - return parseBreakOrContinueStatement(215 /* BreakStatement */); + return parseBreakOrContinueStatement(216 /* BreakStatement */); case 95 /* ReturnKeyword */: return parseReturnStatement(); case 106 /* WithKeyword */: @@ -18175,7 +18261,7 @@ var ts; 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(244 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(245 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -18248,7 +18334,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(223 /* VariableDeclaration */); + var node = createNode(224 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -18257,7 +18343,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(224 /* VariableDeclarationList */); + var node = createNode(225 /* VariableDeclarationList */); switch (token()) { case 103 /* VarKeyword */: break; @@ -18295,7 +18381,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(205 /* VariableStatement */, fullStart); + var node = createNode(206 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -18303,7 +18389,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225 /* FunctionDeclaration */, fullStart); + var node = createNode(226 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88 /* FunctionKeyword */); @@ -18527,7 +18613,7 @@ var ts; } function parseClassElement() { if (token() === 24 /* SemicolonToken */) { - var result = createNode(203 /* SemicolonClassElement */); + var result = createNode(204 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -18568,7 +18654,7 @@ var ts; /*modifiers*/ undefined, 197 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 227 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -18612,7 +18698,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */) { - var node = createNode(255 /* HeritageClause */); + var node = createNode(256 /* HeritageClause */); node.token = token(); nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -18635,7 +18721,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227 /* InterfaceDeclaration */, fullStart); + var node = createNode(228 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108 /* InterfaceKeyword */); @@ -18646,7 +18732,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228 /* TypeAliasDeclaration */, fullStart); + var node = createNode(229 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(136 /* TypeKeyword */); @@ -18662,13 +18748,13 @@ 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(260 /* EnumMember */, scanner.getStartPos()); + var node = createNode(261 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229 /* EnumDeclaration */, fullStart); + var node = createNode(230 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82 /* EnumKeyword */); @@ -18683,7 +18769,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(231 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(232 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(16 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(17 /* CloseBraceToken */); @@ -18694,7 +18780,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(230 /* ModuleDeclaration */, fullStart); + var node = createNode(231 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -18708,7 +18794,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230 /* ModuleDeclaration */, fullStart); + var node = createNode(231 /* ModuleDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (token() === 139 /* GlobalKeyword */) { @@ -18755,7 +18841,7 @@ var ts; return nextToken() === 40 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(233 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(234 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117 /* AsKeyword */); @@ -18774,7 +18860,7 @@ var ts; // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(234 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(235 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -18785,7 +18871,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(235 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(236 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: @@ -18808,7 +18894,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(236 /* ImportClause */, fullStart); + var importClause = createNode(237 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -18818,7 +18904,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(25 /* CommaToken */)) { - importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(238 /* NamedImports */); + importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(239 /* NamedImports */); } return finishNode(importClause); } @@ -18828,7 +18914,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(245 /* ExternalModuleReference */); + var node = createNode(246 /* ExternalModuleReference */); parseExpected(131 /* RequireKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -18851,7 +18937,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(237 /* NamespaceImport */); + var namespaceImport = createNode(238 /* NamespaceImport */); parseExpected(38 /* AsteriskToken */); parseExpected(117 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -18866,14 +18952,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 238 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 239 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(243 /* ExportSpecifier */); + return parseImportOrExportSpecifier(244 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(239 /* ImportSpecifier */); + return parseImportOrExportSpecifier(240 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -18898,14 +18984,14 @@ var ts; else { node.name = identifierName; } - if (kind === 239 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 240 /* 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(241 /* ExportDeclaration */, fullStart); + var node = createNode(242 /* ExportDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38 /* AsteriskToken */)) { @@ -18913,7 +18999,7 @@ var ts; node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(242 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(243 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. @@ -18926,7 +19012,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(240 /* ExportAssignment */, fullStart); + var node = createNode(241 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57 /* EqualsToken */)) { @@ -19008,10 +19094,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 245 /* ExternalModuleReference */ - || node.kind === 235 /* ImportDeclaration */ - || node.kind === 240 /* ExportAssignment */ - || node.kind === 241 /* ExportDeclaration */ + || node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 246 /* ExternalModuleReference */ + || node.kind === 236 /* ImportDeclaration */ + || node.kind === 241 /* ExportAssignment */ + || node.kind === 242 /* ExportDeclaration */ ? node : undefined; }); @@ -19086,7 +19172,7 @@ var ts; // Parses out a JSDoc type expression. /* @internal */ function parseJSDocTypeExpression() { - var result = createNode(262 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(263 /* JSDocTypeExpression */, scanner.getTokenPos()); parseExpected(16 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(17 /* CloseBraceToken */); @@ -19097,12 +19183,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48 /* BarToken */) { - var unionType = createNode(266 /* JSDocUnionType */, type.pos); + var unionType = createNode(267 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57 /* EqualsToken */) { - var optionalType = createNode(273 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(274 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -19113,20 +19199,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20 /* OpenBracketToken */) { - var arrayType = createNode(265 /* JSDocArrayType */, type.pos); + var arrayType = createNode(266 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token() === 54 /* QuestionToken */) { - var nullableType = createNode(268 /* JSDocNullableType */, type.pos); + var nullableType = createNode(269 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50 /* ExclamationToken */) { - var nonNullableType = createNode(269 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(270 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -19178,27 +19264,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(277 /* JSDocThisType */); + var result = createNode(278 /* JSDocThisType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(276 /* JSDocConstructorType */); + var result = createNode(277 /* JSDocConstructorType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(275 /* JSDocVariadicType */); + var result = createNode(276 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(274 /* JSDocFunctionType */); + var result = createNode(275 /* JSDocFunctionType */); nextToken(); parseExpected(18 /* OpenParenToken */); result.parameters = parseDelimitedList(23 /* JSDocFunctionParameters */, parseJSDocParameter); @@ -19220,7 +19306,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(272 /* JSDocTypeReference */); + var result = createNode(273 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); @@ -19261,18 +19347,18 @@ var ts; return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(270 /* JSDocRecordType */); + var result = createNode(271 /* JSDocRecordType */); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(269 /* JSDocNonNullableType */); + var result = createNode(270 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(267 /* JSDocTupleType */); + var result = createNode(268 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(26 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); @@ -19286,7 +19372,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(266 /* JSDocUnionType */); + var result = createNode(267 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19 /* CloseParenToken */); @@ -19302,12 +19388,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(263 /* JSDocAllType */); + var result = createNode(264 /* JSDocAllType */); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(288 /* JSDocLiteralType */); + var result = createNode(289 /* JSDocLiteralType */); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -19330,11 +19416,11 @@ var ts; token() === 28 /* GreaterThanToken */ || token() === 57 /* EqualsToken */ || token() === 48 /* BarToken */) { - var result = createNode(264 /* JSDocUnknownType */, pos); + var result = createNode(265 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(268 /* JSDocNullableType */, pos); + var result = createNode(269 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -19499,7 +19585,7 @@ var ts; content.charCodeAt(start + 3) !== 42 /* asterisk */; } function createJSDocComment() { - var result = createNode(278 /* JSDocComment */, start); + var result = createNode(279 /* JSDocComment */, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -19615,7 +19701,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(279 /* JSDocTag */, atToken.pos); + var result = createNode(280 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -19672,7 +19758,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(281 /* JSDocParameterTag */, atToken.pos); + var result = createNode(282 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -19683,20 +19769,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 282 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 283 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(282 /* JSDocReturnTag */, atToken.pos); + var result = createNode(283 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 284 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283 /* JSDocTypeTag */, atToken.pos); + var result = createNode(284 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -19711,7 +19797,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(286 /* JSDocPropertyTag */, atToken.pos); + var result = createNode(287 /* JSDocPropertyTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -19720,7 +19806,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(280 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(281 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -19729,7 +19815,7 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(285 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(286 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0); @@ -19743,7 +19829,7 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 272 /* JSDocTypeReference */) { + if (typeExpression.type.kind === 273 /* JSDocTypeReference */) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70 /* Identifier */) { var name_14 = jsDocTypeReference.name; @@ -19761,7 +19847,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(288 /* JSDocTypeLiteral */, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -19802,7 +19888,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22 /* DotToken */)) { - var jsDocNamespaceNode = createNode(230 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(231 /* ModuleDeclaration */, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4 /* NestedNamespace */); @@ -19848,7 +19934,7 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 285 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } // Type parameter list looks like '@template T,U,V' @@ -19872,7 +19958,7 @@ var ts; break; } } - var result = createNode(284 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(285 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -20346,7 +20432,7 @@ var ts; if (position >= array.pos && position < array.end) { // position was in this array. Search through this array to see if we find a // viable element. - for (var i = 0, n = array.length; i < n; i++) { + for (var i = 0; i < array.length; i++) { var child = array[i]; if (child) { if (child.pos === position) { @@ -20392,16 +20478,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 227 /* InterfaceDeclaration */ || node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 228 /* InterfaceDeclaration */ || node.kind === 229 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 235 /* ImportDeclaration */ || node.kind === 234 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { + else if ((node.kind === 236 /* ImportDeclaration */ || node.kind === 235 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 231 /* ModuleBlock */) { + else if (node.kind === 232 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -20420,7 +20506,7 @@ var ts; }); return state_1; } - else if (node.kind === 230 /* ModuleDeclaration */) { + else if (node.kind === 231 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } @@ -20561,7 +20647,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 230 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 231 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -20596,9 +20682,9 @@ var ts; return "__new"; case 155 /* IndexSignature */: return "__index"; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return "__export"; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; case 192 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { @@ -20615,22 +20701,22 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 225 /* FunctionDeclaration */: - case 226 /* ClassDeclaration */: + case 226 /* FunctionDeclaration */: + case 227 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; - case 274 /* JSDocFunctionType */: + case 275 /* JSDocFunctionType */: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; case 144 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 274 /* JSDocFunctionType */); + ts.Debug.assert(node.parent.kind === 275 /* JSDocFunctionType */); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 205 /* VariableStatement */) { + if (parentNode && parentNode.kind === 206 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -20717,7 +20803,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 240 /* ExportAssignment */ && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 241 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -20737,7 +20823,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 243 /* ExportSpecifier */ || (node.kind === 234 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 244 /* ExportSpecifier */ || (node.kind === 235 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -20760,7 +20846,7 @@ var ts; // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation // and this case is specially handled. Module augmentations should only be merged with original module definition // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. - var isJSDocTypedefInJSDocNamespace = node.kind === 285 /* JSDocTypedefTag */ && + var isJSDocTypedefInJSDocNamespace = node.kind === 286 /* JSDocTypedefTag */ && node.name && node.name.kind === 70 /* Identifier */ && node.name.isInJSDocNamespace; @@ -20847,7 +20933,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { node.flags |= emitFlags; } if (isIIFE) { @@ -20926,43 +21012,43 @@ var ts; return; } switch (node.kind) { - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: bindWhileStatement(node); break; - case 209 /* DoStatement */: + case 210 /* DoStatement */: bindDoStatement(node); break; - case 211 /* ForStatement */: + case 212 /* ForStatement */: bindForStatement(node); break; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 208 /* IfStatement */: + case 209 /* IfStatement */: bindIfStatement(node); break; - case 216 /* ReturnStatement */: - case 220 /* ThrowStatement */: + case 217 /* ReturnStatement */: + case 221 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: + case 216 /* BreakStatement */: + case 215 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 221 /* TryStatement */: + case 222 /* TryStatement */: bindTryStatement(node); break; - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: bindSwitchStatement(node); break; - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: bindCaseBlock(node); break; - case 253 /* CaseClause */: + case 254 /* CaseClause */: bindCaseClause(node); break; - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: bindLabeledStatement(node); break; case 190 /* PrefixUnaryExpression */: @@ -20980,7 +21066,7 @@ var ts; case 193 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; case 179 /* CallExpression */: @@ -21147,11 +21233,11 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 208 /* IfStatement */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: + case 209 /* IfStatement */: + case 211 /* WhileStatement */: + case 210 /* DoStatement */: return parent.expression === node; - case 211 /* ForStatement */: + case 212 /* ForStatement */: case 193 /* ConditionalExpression */: return parent.condition === node; } @@ -21215,7 +21301,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 219 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 220 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -21252,7 +21338,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 224 /* VariableDeclarationList */) { + if (node.initializer.kind !== 225 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -21274,7 +21360,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 216 /* ReturnStatement */) { + if (node.kind === 217 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -21294,7 +21380,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 215 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 216 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -21360,7 +21446,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 254 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 255 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -21427,7 +21513,7 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 209 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 210 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); @@ -21459,13 +21545,13 @@ var ts; else if (node.kind === 176 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 257 /* PropertyAssignment */) { + if (p.kind === 258 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 258 /* ShorthandPropertyAssignment */) { + else if (p.kind === 259 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 259 /* SpreadAssignment */) { + else if (p.kind === 260 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -21565,7 +21651,7 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 212 /* ForInStatement */ || node.parent.parent.kind === 213 /* ForOfStatement */) { + if (node.initializer || node.parent.parent.kind === 213 /* ForInStatement */ || node.parent.parent.kind === 214 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } @@ -21595,28 +21681,28 @@ var ts; function getContainerFlags(node) { switch (node.kind) { case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: case 176 /* ObjectLiteralExpression */: case 161 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 270 /* JSDocRecordType */: + case 288 /* JSDocTypeLiteral */: + case 271 /* JSDocRecordType */: return 1 /* IsContainer */; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 274 /* JSDocFunctionType */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 275 /* JSDocFunctionType */: + case 231 /* ModuleDeclaration */: + case 229 /* TypeAliasDeclaration */: case 170 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 261 /* SourceFile */: + case 262 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; case 149 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } case 150 /* Constructor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: @@ -21629,17 +21715,17 @@ var ts; case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; case 147 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 256 /* CatchClause */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 232 /* CaseBlock */: + case 257 /* CatchClause */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 233 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 204 /* Block */: + case 205 /* 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. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -21676,20 +21762,20 @@ var ts; // 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). We defer to specialized // handlers to take care of declaring these child members. - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 261 /* SourceFile */: + case 262 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 161 /* TypeLiteral */: case 176 /* ObjectLiteralExpression */: - case 227 /* InterfaceDeclaration */: - case 270 /* JSDocRecordType */: - case 287 /* JSDocTypeLiteral */: + case 228 /* InterfaceDeclaration */: + case 271 /* JSDocRecordType */: + case 288 /* JSDocTypeLiteral */: // 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 @@ -21706,11 +21792,11 @@ var ts; case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 274 /* JSDocFunctionType */: - case 228 /* TypeAliasDeclaration */: + case 275 /* JSDocFunctionType */: + case 229 /* TypeAliasDeclaration */: case 170 /* MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, @@ -21732,11 +21818,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 261 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 261 /* SourceFile */ || body.kind === 231 /* ModuleBlock */)) { + var body = node.kind === 262 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 262 /* SourceFile */ || body.kind === 232 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 241 /* ExportDeclaration */ || stat.kind === 240 /* ExportAssignment */) { + if (stat.kind === 242 /* ExportDeclaration */ || stat.kind === 241 /* ExportAssignment */) { return true; } } @@ -21829,7 +21915,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { + if (prop.kind === 260 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { continue; } var identifier = prop.name; @@ -21841,7 +21927,7 @@ var ts; // 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 === 257 /* PropertyAssignment */ || prop.kind === 258 /* ShorthandPropertyAssignment */ || prop.kind === 149 /* MethodDeclaration */ + var currentKind = prop.kind === 258 /* PropertyAssignment */ || prop.kind === 259 /* ShorthandPropertyAssignment */ || prop.kind === 149 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -21863,10 +21949,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -21977,8 +22063,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 261 /* SourceFile */ && - blockScopeContainer.kind !== 230 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 262 /* SourceFile */ && + blockScopeContainer.kind !== 231 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -22091,14 +22177,14 @@ var ts; // current "blockScopeContainer" needs to be set to its immediate namespace parent. if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 285 /* JSDocTypedefTag */) { + while (parentNode && parentNode.kind !== 286 /* JSDocTypedefTag */) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); break; } case 98 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 258 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 259 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); @@ -22131,7 +22217,7 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return checkStrictModeCatchClause(node); case 186 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); @@ -22141,7 +22227,7 @@ var ts; return checkStrictModePostfixUnaryExpression(node); case 190 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return checkStrictModeWithStatement(node); case 167 /* ThisType */: seenThisKeyword = true; @@ -22152,22 +22238,22 @@ var ts; return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530920 /* TypeParameterExcludes */); case 144 /* Parameter */: return bindParameter(node); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 271 /* JSDocRecordMember */: + case 272 /* JSDocRecordMember */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); - case 286 /* JSDocPropertyTag */: + case 287 /* JSDocPropertyTag */: return bindJSDocProperty(node); - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: + case 258 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 260 /* EnumMember */: + case 261 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 259 /* SpreadAssignment */: - case 251 /* JsxSpreadAttribute */: + case 260 /* SpreadAssignment */: + case 252 /* JsxSpreadAttribute */: var root = container; var hasRest = false; while (root.parent) { @@ -22192,7 +22278,7 @@ var ts; // 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) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return bindFunctionDeclaration(node); case 150 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); @@ -22202,12 +22288,12 @@ var ts; return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); case 158 /* FunctionType */: case 159 /* ConstructorType */: - case 274 /* JSDocFunctionType */: + case 275 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); case 161 /* TypeLiteral */: case 170 /* MappedType */: - case 287 /* JSDocTypeLiteral */: - case 270 /* JSDocRecordType */: + case 288 /* JSDocTypeLiteral */: + case 271 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); case 176 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); @@ -22221,46 +22307,46 @@ var ts; break; // Members of classes, interfaces, and modules case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: if (!node.fullName || node.fullName.kind === 70 /* Identifier */) { return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); } break; - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Imports and exports - case 234 /* ImportEqualsDeclaration */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 235 /* ImportEqualsDeclaration */: + case 238 /* NamespaceImport */: + case 240 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 233 /* NamespaceExportDeclaration */: + case 234 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return bindImportClause(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return bindExportDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return bindExportAssignment(node); - case 261 /* SourceFile */: + case 262 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 204 /* Block */: + case 205 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // Fall through - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } @@ -22292,7 +22378,7 @@ var ts; // An export default clause with an expression exports a value // We want to exclude both class and function here, this is necessary to issue an error when there are both // default export-assignment and default export function and class declaration. - var flags = node.kind === 240 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 241 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -22302,7 +22388,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 261 /* SourceFile */) { + if (node.parent.kind !== 262 /* SourceFile */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -22357,7 +22443,7 @@ var ts; function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); // Declare a 'member' if the container is an ES5 class or ES6 constructor - if (container.kind === 225 /* FunctionDeclaration */ || container.kind === 184 /* FunctionExpression */) { + if (container.kind === 226 /* FunctionDeclaration */ || container.kind === 184 /* FunctionExpression */) { container.symbol.members = container.symbol.members || ts.createMap(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); @@ -22405,7 +22491,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 227 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -22541,13 +22627,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 206 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 207 /* EmptyStatement */) || // report error on class declarations - node.kind === 226 /* ClassDeclaration */ || + node.kind === 227 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 230 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 231 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 229 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 230 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -22561,7 +22647,7 @@ var ts; // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 205 /* VariableStatement */ || + (node.kind !== 206 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -22585,13 +22671,13 @@ var ts; return computeCallExpression(node, subtreeFlags); case 180 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); case 183 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); case 192 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); case 144 /* Parameter */: return computeParameter(node, subtreeFlags); @@ -22599,23 +22685,23 @@ var ts; return computeArrowFunction(node, subtreeFlags); case 184 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); case 197 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return computeCatchClause(node, subtreeFlags); case 199 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); @@ -22628,7 +22714,7 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); case 177 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); @@ -23113,8 +23199,8 @@ var ts; case 116 /* AbstractKeyword */: case 123 /* DeclareKeyword */: case 75 /* ConstKeyword */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: + case 230 /* EnumDeclaration */: + case 261 /* EnumMember */: case 182 /* TypeAssertionExpression */: case 200 /* AsExpression */: case 201 /* NonNullExpression */: @@ -23122,18 +23208,18 @@ var ts; // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 247 /* JsxElement */: + case 248 /* JsxSelfClosingElement */: + case 249 /* JsxOpeningElement */: case 10 /* JsxText */: - case 249 /* JsxClosingElement */: - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: - case 252 /* JsxExpression */: + case 250 /* JsxClosingElement */: + case 251 /* JsxAttribute */: + case 252 /* JsxSpreadAttribute */: + case 253 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: // for-of might be ESNext if it has a rest destructuring transformFlags |= 8 /* AssertESNext */; // FALLTHROUGH @@ -23143,8 +23229,9 @@ var ts; case 15 /* TemplateTail */: case 194 /* TemplateExpression */: case 181 /* TaggedTemplateExpression */: - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: case 114 /* StaticKeyword */: + case 202 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; @@ -23176,8 +23263,8 @@ var ts; case 164 /* UnionType */: case 165 /* IntersectionType */: case 166 /* ParenthesizedType */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: case 167 /* ThisType */: case 168 /* TypeOperator */: case 169 /* IndexedAccessType */: @@ -23207,7 +23294,7 @@ var ts; case 196 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 96 /* SuperKeyword */: @@ -23266,23 +23353,23 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 216 /* ReturnStatement */: - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 217 /* ReturnStatement */: + case 215 /* ContinueStatement */: + case 216 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -23306,18 +23393,18 @@ var ts; case 180 /* NewExpression */: case 175 /* ArrayLiteralExpression */: return 537396545 /* ArrayLiteralOrCallOrNewExcludes */; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return 574674241 /* ModuleExcludes */; case 144 /* Parameter */: return 536872257 /* ParameterExcludes */; case 185 /* ArrowFunction */: return 601249089 /* ArrowFunctionExcludes */; case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return 601281857 /* FunctionExcludes */; - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return 546309441 /* VariableDeclarationListExcludes */; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return 539358529 /* ClassExcludes */; case 150 /* Constructor */: @@ -23339,12 +23426,12 @@ var ts; case 153 /* CallSignature */: case 154 /* ConstructSignature */: case 155 /* IndexSignature */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; case 176 /* ObjectLiteralExpression */: return 540087617 /* ObjectLiteralExcludes */; - case 256 /* CatchClause */: + case 257 /* CatchClause */: return 537920833 /* CatchClauseExcludes */; case 172 /* ObjectBindingPattern */: case 173 /* ArrayBindingPattern */: @@ -23386,10 +23473,6 @@ var ts; ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); return resolved.path; } - /** Create Resolved from a file with unknown extension. */ - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } /** Adds `isExernalLibraryImport` to a Resolved to get a ResolvedModule. */ function resolvedModuleFromResolved(_a, isExternalLibraryImport) { var path = _a.path, extension = _a.extension; @@ -23402,13 +23485,14 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { + /** Reads from "main" or "types"/"typings" depending on `extensions`. */ + function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); switch (extensions) { - case 2 /* DtsOnly */: - case 0 /* TypeScript */: + case Extensions.DtsOnly: + case Extensions.TypeScript: return tryReadFromField("typings") || tryReadFromField("types"); - case 1 /* JavaScript */: + case Extensions.JavaScript: if (typeof jsonContent.main === "string") { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); @@ -23475,6 +23559,7 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } + return undefined; }); return typeRoots; } @@ -23535,7 +23620,11 @@ var ts; return ts.forEach(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2 /* DtsOnly */, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); }); } else { @@ -23552,7 +23641,8 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2 /* DtsOnly */, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, /*cache*/ undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -23605,31 +23695,134 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + if (!perModuleNameCache) { + moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + /** + * At first this function add entry directory -> module resolution result to the table. + * Then it computes the set of parent folders for 'directory' that should have the same module resolution result + * and for every parent folder in set it adds entry: parent -> module resolution. . + * Lets say we first directory name: /a/b/c/d/e and resolution result is: /a/b/bar.ts. + * Set of parent folders that should have the same result will be: + * [ + * /a/b/c/d, /a/b/c, /a/b + * ] + * this means that request for module resolution from file in any of these folder will be immediately found in cache. + */ + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + // if entry is already in cache do nothing + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + // find common prefix between directory and resolved file name + // this common prefix should be the shorted path that has the same resolution + // directory: /a/b/c/d/e + // resolvedFileName: /a/b/foo.d.ts + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent_5 = ts.getDirectoryPath(current); + if (parent_5 === current || directoryPathMap.contains(parent_5)) { + break; + } + directoryPathMap.set(parent_5, result); + current = parent_5; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + // find first position where directory and resolution differs + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + // find last directory separator before position i + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache[moduleName]; + if (result) { if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache[moduleName] = result; + // put result in per-module name cache + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; } if (traceEnabled) { if (result.resolvedModule) { @@ -23822,34 +24015,34 @@ var ts; return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0 /* TypeScript */) || tryResolve(1 /* JavaScript */); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } @@ -23866,10 +24059,33 @@ var ts; } function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } /* @internal */ function directoryProbablyExists(directoryName, host) { @@ -23908,11 +24124,11 @@ var ts; } } switch (extensions) { - case 2 /* DtsOnly */: + case Extensions.DtsOnly: return tryExtension(".d.ts", ts.Extension.Dts); - case 0 /* TypeScript */: + case Extensions.TypeScript: return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1 /* JavaScript */: + case Extensions.JavaScript: return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } function tryExtension(ext, extension) { @@ -23922,19 +24138,21 @@ var ts; } /** Return the file if it exists. */ function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } } - failedLookupLocations.push(fileName); - return undefined; } + failedLookupLocations.push(fileName); + return undefined; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var packageJsonPath = pathToPackageJson(candidate); @@ -23943,18 +24161,23 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); + var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); + if (mainOrTypesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); // A package.json "typings" may specify an exact filename, or may choose to omit an extension. - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - // Note: this would allow a package.json to specify a ".js" file as typings. Maybe that should be forbidden. - return resolvedFromAnyFile(fromFile); + var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); + if (fromExactFile) { + var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); + if (resolved_3) { + return resolved_3; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } - var x = tryAddingExtensions(typesFile, 0 /* TypeScript */, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; + var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved) { + return resolved; } } else { @@ -23964,7 +24187,7 @@ var ts; } } else { - if (state.traceEnabled) { + if (directoryExists && state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results @@ -23972,70 +24195,116 @@ var ts; } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + /** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */ + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + /** True if `extension` is one of the supported `extensions`. */ + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ false, cache); } function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { // Extensions parameter here doesn't actually matter, because typesOnly ensures we're just doing @types lookup, which is always DtsOnly. - return loadModuleFromNodeModulesWorker(2 /* DtsOnly */, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ true); + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ true, /*cache*/ undefined); } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); } }); } /** Load a module from a single node_modules directory, but not from any ancestors' node_modules directories. */ function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } - if (extensions !== 1 /* JavaScript */) { - return loadModuleFromNodeModulesFolder(2 /* DtsOnly */, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0 /* TypeScript */) || tryResolve(1 /* JavaScript */); - return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ false, failedLookupLocations); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); if (resolvedUsingSettings) { - return resolvedUsingSettings; + return { value: resolvedUsingSettings }; } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { // Climb up parent directories looking for a module. - var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state)); }); - if (resolved_3) { - return resolved_3; + if (resolved_4) { + return resolved_4; } - if (extensions === 0 /* TypeScript */) { + if (extensions === Extensions.TypeScript) { // If we didn't find the file normally, look it up in @types. return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state)); } } } @@ -24052,10 +24321,17 @@ var ts; } var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2 /* DtsOnly */, moduleName, globalCache, failedLookupLocations, state); + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + /** + * Wraps value to SearchResult. + * @returns undefined if value is undefined or { value } otherwise + */ + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ function forEachAncestorDirectory(directory, callback) { while (true) { @@ -24142,9 +24418,11 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, + getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, + getTypeFromTypeNode: getTypeFromTypeNode, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -24153,6 +24431,7 @@ var ts; getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, + signatureToString: signatureToString, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -24177,7 +24456,8 @@ var ts; // we deliberately exclude augmentations // since we are only interested in declarations of the module itself return tryFindAmbientModule(moduleName, /*withAugmentations*/ false); - } + }, + getApparentType: getApparentType }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -24281,6 +24561,7 @@ var ts; var visitedFlowNodes = []; var visitedFlowTypes = []; var potentialThisCollisions = []; + var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var TypeFacts; @@ -24501,7 +24782,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 230 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 230 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 231 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 231 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -24606,7 +24887,7 @@ var ts; return type.flags & 32768 /* Object */ ? type.objectFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 261 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 262 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -24662,9 +24943,21 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - // still might be illegal if usage is in the initializer of the variable declaration - return declaration.kind !== 223 /* VariableDeclaration */ || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + if (declaration.kind === 174 /* BindingElement */) { + // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) + var errorBindingElement = ts.getAncestor(usage, 174 /* BindingElement */); + if (errorBindingElement) { + return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + declaration.pos < errorBindingElement.pos; + } + // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 224 /* VariableDeclaration */), usage); + } + else if (declaration.kind === 224 /* VariableDeclaration */) { + // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) + return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return true; } // declaration is after usage // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) @@ -24673,9 +24966,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 205 /* VariableStatement */: - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 206 /* VariableStatement */: + case 212 /* ForStatement */: + case 214 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -24684,8 +24977,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -24713,6 +25006,15 @@ var ts; } return false; } + function getAncestorBindingPattern(node) { + while (node) { + if (ts.isBindingPattern(node)) { + return node; + } + node = node.parent; + } + return undefined; + } } // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with @@ -24736,7 +25038,7 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 278 /* JSDocComment */) { + if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 279 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || lastLocation.kind === 144 /* Parameter */ || @@ -24763,13 +25065,13 @@ var ts; } } switch (location.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 261 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 262 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports["default"]) { @@ -24792,7 +25094,7 @@ var ts; // which is not the desired behavior. if (moduleExports[name] && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 243 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 244 /* ExportSpecifier */)) { break; } } @@ -24800,7 +25102,7 @@ var ts; break loop; } break; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } @@ -24823,9 +25125,9 @@ var ts; } } break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064 /* Type */)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -24854,7 +25156,7 @@ var ts; // case 142 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 227 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 228 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -24867,7 +25169,7 @@ var ts; case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; @@ -24960,7 +25262,7 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 107455 /* Value */) === 107455 /* Value */) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 233 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 234 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -25048,7 +25350,7 @@ var ts; // Block-scoped variables cannot be used before their definition var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 223 /* VariableDeclaration */), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -25069,10 +25371,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 235 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 235 /* ImportDeclaration */) { + while (node && node.kind !== 236 /* ImportDeclaration */) { node = node.parent; } return node; @@ -25082,7 +25384,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 245 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 246 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -25207,19 +25509,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return getTargetOfImportClause(node); - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 239 /* ImportSpecifier */: + case 240 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 243 /* ExportSpecifier */: + case 244 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return getTargetOfExportAssignment(node); - case 233 /* NamespaceExportDeclaration */: + case 234 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node); } } @@ -25266,11 +25568,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 240 /* ExportAssignment */) { + if (node.kind === 241 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 243 /* ExportSpecifier */) { + else if (node.kind === 244 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -25298,14 +25600,16 @@ var ts; else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 234 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 235 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol) { return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); } - // Resolves a qualified name and any involved aliases + /** + * Resolves a qualified name and any involved aliases. + */ function resolveEntityName(name, meaning, ignoreErrors, dontResolveAlias, location) { if (ts.nodeIsMissing(name)) { return undefined; @@ -25626,11 +25930,11 @@ var ts; } } switch (location_1.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -25682,7 +25986,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -25722,7 +26026,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -25821,7 +26125,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -25867,7 +26171,7 @@ var ts; meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } else if (entityName.kind === 141 /* QualifiedName */ || entityName.kind === 177 /* PropertyAccessExpression */ || - entityName.parent.kind === 234 /* ImportEqualsDeclaration */) { + entityName.parent.kind === 235 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -25966,7 +26270,7 @@ var ts; while (node.kind === 166 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 229 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -25974,7 +26278,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 231 /* ModuleBlock */ && + node.parent.kind === 232 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -26066,9 +26370,9 @@ var ts; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - var parent_5 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_5) { - walkSymbol(parent_5, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + var parent_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_6) { + walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); } } if (accessibleSymbolChain) { @@ -26218,14 +26522,14 @@ var ts; while (i < length_1) { // Find group of type arguments for type parameters with the same declaring container. var start = i; - var parent_6 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_6); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_6, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); writePunctuation(writer, 22 /* DotToken */); } } @@ -26291,7 +26595,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 261 /* SourceFile */ || declaration.parent.kind === 231 /* ModuleBlock */; + return declaration.parent.kind === 262 /* SourceFile */ || declaration.parent.kind === 232 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -26305,25 +26609,6 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } - function writeIndexSignature(info, keyword) { - if (info) { - if (info.isReadonly) { - writeKeyword(writer, 130 /* ReadonlyKeyword */); - writeSpace(writer); - } - writePunctuation(writer, 20 /* OpenBracketToken */); - writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, keyword); - writePunctuation(writer, 21 /* CloseBracketToken */); - writePunctuation(writer, 55 /* ColonToken */); - writeSpace(writer); - writeType(info.type, 0 /* None */); - writePunctuation(writer, 24 /* SemicolonToken */); - writer.writeLine(); - } - } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { writeKeyword(writer, 130 /* ReadonlyKeyword */); @@ -26407,8 +26692,8 @@ var ts; writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 134 /* StringKeyword */); - writeIndexSignature(resolved.numberIndexInfo, 132 /* NumberKeyword */); + buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0 /* String */, enclosingDeclaration, globalFlags, symbolStack); + buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, 1 /* Number */, enclosingDeclaration, globalFlags, symbolStack); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -26588,6 +26873,10 @@ var ts; buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + var returnType = getReturnTypeOfSignature(signature); + if (flags & 2048 /* SuppressAnyReturnType */ && isTypeAny(returnType)) { + return; + } if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); writePunctuation(writer, 35 /* EqualsGreaterThanToken */); @@ -26600,7 +26889,6 @@ var ts; buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); } else { - var returnType = getReturnTypeOfSignature(signature); buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } } @@ -26620,6 +26908,32 @@ var ts; buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } + function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 130 /* ReadonlyKeyword */); + writeSpace(writer); + } + writePunctuation(writer, 20 /* OpenBracketToken */); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 55 /* ColonToken */); + writeSpace(writer); + switch (kind) { + case 1 /* Number */: + writeKeyword(writer, 132 /* NumberKeyword */); + break; + case 0 /* String */: + writeKeyword(writer, 134 /* StringKeyword */); + break; + } + writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 55 /* ColonToken */); + writeSpace(writer); + buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); + writePunctuation(writer, 24 /* SemicolonToken */); + writer.writeLine(); + } + } return _displayBuilder || (_displayBuilder = { buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, @@ -26630,6 +26944,7 @@ var ts; buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, + buildIndexSignatureDisplay: buildIndexSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay }); } @@ -26646,32 +26961,32 @@ var ts; switch (node.kind) { case 174 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 223 /* VariableDeclaration */: + case 224 /* 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 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 225 /* FunctionDeclaration */: - case 229 /* EnumDeclaration */: - case 234 /* ImportEqualsDeclaration */: + case 231 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 226 /* FunctionDeclaration */: + case 230 /* EnumDeclaration */: + case 235 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_7 = getDeclarationContainer(node); + var parent_8 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 234 /* ImportEqualsDeclaration */ && parent_7.kind !== 261 /* SourceFile */ && ts.isInAmbientContext(parent_7))) { - return isGlobalSourceFile(parent_7); + !(node.kind !== 235 /* ImportEqualsDeclaration */ && parent_8.kind !== 262 /* SourceFile */ && ts.isInAmbientContext(parent_8))) { + return isGlobalSourceFile(parent_8); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible - return isDeclarationVisible(parent_7); + return isDeclarationVisible(parent_8); case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: case 151 /* GetAccessor */: @@ -26688,7 +27003,7 @@ var ts; case 153 /* CallSignature */: case 155 /* IndexSignature */: case 144 /* Parameter */: - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: case 158 /* FunctionType */: case 159 /* ConstructorType */: case 161 /* TypeLiteral */: @@ -26701,18 +27016,18 @@ var ts; return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 236 /* ImportClause */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: + case 237 /* ImportClause */: + case 238 /* NamespaceImport */: + case 240 /* ImportSpecifier */: return false; // Type parameters are always visible case 143 /* TypeParameter */: // Source file and namespace export are always visible - case 261 /* SourceFile */: - case 233 /* NamespaceExportDeclaration */: + case 262 /* SourceFile */: + case 234 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return false; default: return false; @@ -26721,10 +27036,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 240 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 241 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 243 /* ExportSpecifier */) { + else if (node.parent.kind === 244 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -26817,12 +27132,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 223 /* VariableDeclaration */: - case 224 /* VariableDeclarationList */: - case 239 /* ImportSpecifier */: - case 238 /* NamedImports */: - case 237 /* NamespaceImport */: - case 236 /* ImportClause */: + case 224 /* VariableDeclaration */: + case 225 /* VariableDeclarationList */: + case 240 /* ImportSpecifier */: + case 239 /* NamedImports */: + case 238 /* NamespaceImport */: + case 237 /* ImportClause */: node = node.parent; break; default: @@ -26846,9 +27161,6 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1 /* Any */) !== 0; } - function isTypeNever(type) { - return type && (type.flags & 8192 /* Never */) !== 0; - } // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node) { @@ -27007,11 +27319,11 @@ var ts; } // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (declaration.parent.parent.kind === 212 /* ForInStatement */) { + if (declaration.parent.parent.kind === 213 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 /* TypeParameter */ | 262144 /* Index */) ? indexType : stringType; } - if (declaration.parent.parent.kind === 213 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 214 /* 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, @@ -27026,7 +27338,7 @@ var ts; return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536 /* JavaScriptFile */) && - declaration.kind === 223 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 224 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -27074,7 +27386,7 @@ var ts; return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 258 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 259 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -27177,7 +27489,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. - if (declaration.kind === 257 /* PropertyAssignment */) { + if (declaration.kind === 258 /* PropertyAssignment */) { return type; } return getWidenedType(type); @@ -27210,10 +27522,10 @@ var ts; return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 240 /* ExportAssignment */) { + if (declaration.kind === 241 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 286 /* JSDocPropertyTag */ && declaration.typeExpression) { + if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 287 /* JSDocPropertyTag */ && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } // Handle variable, parameter or property @@ -27443,8 +27755,8 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 226 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */ || - node.kind === 225 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || + if (node.kind === 227 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */ || + node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 185 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { @@ -27455,7 +27767,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 227 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 228 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -27464,8 +27776,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 227 /* InterfaceDeclaration */ || node.kind === 226 /* ClassDeclaration */ || - node.kind === 197 /* ClassExpression */ || node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 228 /* InterfaceDeclaration */ || node.kind === 227 /* ClassDeclaration */ || + node.kind === 197 /* ClassExpression */ || node.kind === 229 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -27497,11 +27809,13 @@ var ts; } 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. + /** + * 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); @@ -27616,7 +27930,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 228 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -27648,7 +27962,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 /* InterfaceDeclaration */) { + if (declaration.kind === 228 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -27705,7 +28019,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 285 /* JSDocTypedefTag */); + var declaration = ts.getDeclarationOfKind(symbol, 286 /* JSDocTypedefTag */); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -27716,7 +28030,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 228 /* TypeAliasDeclaration */); + declaration = ts.getDeclarationOfKind(symbol, 229 /* TypeAliasDeclaration */); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -27750,7 +28064,7 @@ var ts; function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 /* EnumDeclaration */) { + if (declaration.kind === 230 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -27778,7 +28092,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 /* EnumDeclaration */) { + if (declaration.kind === 230 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -28176,6 +28490,9 @@ var ts; } setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } + /** + * Converts an AnonymousType to a ResolvedType. + */ function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; if (type.target) { @@ -28306,8 +28623,8 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is {}. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint.flags & 262144 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 262144 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; @@ -28618,7 +28935,7 @@ var ts; } function isJSDocOptionalParameter(node) { if (node.flags & 65536 /* JavaScriptFile */) { - if (node.type && node.type.kind === 273 /* JSDocOptionalType */) { + if (node.type && node.type.kind === 274 /* JSDocOptionalType */) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -28629,7 +28946,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 273 /* JSDocOptionalType */; + return paramTag.typeExpression.type.kind === 274 /* JSDocOptionalType */; } } } @@ -28685,7 +29002,7 @@ var ts; // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct // signature. - for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { + for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; // Include parameter symbol instead of property symbol in the signature @@ -28773,12 +29090,12 @@ var ts; if (!symbol) return emptyArray; var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { + for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { case 158 /* FunctionType */: case 159 /* ConstructorType */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 150 /* Constructor */: @@ -28789,7 +29106,7 @@ var ts; case 152 /* SetAccessor */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 274 /* JSDocFunctionType */: + case 275 /* JSDocFunctionType */: // 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). @@ -29080,7 +29397,7 @@ var ts; switch (node.kind) { case 157 /* TypeReference */: return node.typeName; - case 272 /* JSDocTypeReference */: + case 273 /* JSDocTypeReference */: return node.name; case 199 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other @@ -29108,7 +29425,7 @@ var ts; if (symbol.flags & 524288 /* TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 /* Value */ && node.kind === 272 /* JSDocTypeReference */) { + if (symbol.flags & 107455 /* Value */ && node.kind === 273 /* JSDocTypeReference */) { // A JSDocTypeReference may have resolved to a value (as opposed to a type). In // that case, the type of this reference is just the type of the value we resolved // to. @@ -29121,7 +29438,7 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 272 /* JSDocTypeReference */) { + if (node.kind === 273 /* JSDocTypeReference */) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); @@ -29163,9 +29480,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: return declaration; } } @@ -29358,8 +29675,9 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; + if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } } @@ -29479,8 +29797,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; addTypeToIntersection(typeSet, type); } } @@ -29618,7 +29936,7 @@ var ts; getIndexInfoOfType(objectType, 0 /* String */) || undefined; if (indexInfo) { - if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return unknownType; } @@ -29745,7 +30063,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 228 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 229 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -29875,7 +30193,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 227 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 228 /* InterfaceDeclaration */)) { if (!(ts.getModifierFlags(container) & 32 /* Static */) && (container.kind !== 150 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -29894,8 +30212,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118 /* AnyKeyword */: - case 263 /* JSDocAllType */: - case 264 /* JSDocUnknownType */: + case 264 /* JSDocAllType */: + case 265 /* JSDocUnknownType */: return anyType; case 134 /* StringKeyword */: return stringType; @@ -29913,21 +30231,21 @@ var ts; return nullType; case 129 /* NeverKeyword */: return neverType; - case 289 /* JSDocNullKeyword */: + case 290 /* JSDocNullKeyword */: return nullType; - case 290 /* JSDocUndefinedKeyword */: + case 291 /* JSDocUndefinedKeyword */: return undefinedType; - case 291 /* JSDocNeverKeyword */: + case 292 /* JSDocNeverKeyword */: return neverType; case 167 /* ThisType */: case 98 /* ThisKeyword */: return getTypeFromThisTypeNode(node); case 171 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 288 /* JSDocLiteralType */: + case 289 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); case 157 /* TypeReference */: - case 272 /* JSDocTypeReference */: + case 273 /* JSDocTypeReference */: return getTypeFromTypeReference(node); case 156 /* TypePredicate */: return booleanType; @@ -29936,29 +30254,29 @@ var ts; case 160 /* TypeQuery */: return getTypeFromTypeQueryNode(node); case 162 /* ArrayType */: - case 265 /* JSDocArrayType */: + case 266 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); case 163 /* TupleType */: return getTypeFromTupleTypeNode(node); case 164 /* UnionType */: - case 266 /* JSDocUnionType */: + case 267 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node); case 165 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); case 166 /* ParenthesizedType */: - case 268 /* JSDocNullableType */: - case 269 /* JSDocNonNullableType */: - case 276 /* JSDocConstructorType */: - case 277 /* JSDocThisType */: - case 273 /* JSDocOptionalType */: + case 269 /* JSDocNullableType */: + case 270 /* JSDocNonNullableType */: + case 277 /* JSDocConstructorType */: + case 278 /* JSDocThisType */: + case 274 /* JSDocOptionalType */: return getTypeFromTypeNode(node.type); - case 270 /* JSDocRecordType */: + case 271 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); case 158 /* FunctionType */: case 159 /* ConstructorType */: case 161 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 274 /* JSDocFunctionType */: + case 288 /* JSDocTypeLiteral */: + case 275 /* JSDocFunctionType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 168 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); @@ -29972,9 +30290,9 @@ var ts; case 141 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 267 /* JSDocTupleType */: + case 268 /* JSDocTupleType */: return getTypeFromJSDocTupleType(node); - case 275 /* JSDocVariadicType */: + case 276 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -30136,17 +30454,19 @@ var ts; var constraintType = getConstraintTypeFromMappedType(type); if (constraintType.flags & 262144 /* Index */) { var typeVariable_1 = constraintType.type; - var mappedTypeVariable = instantiateType(typeVariable_1, mapper); - if (typeVariable_1 !== mappedTypeVariable) { - return mapType(mappedTypeVariable, function (t) { - if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); - } - return t; - }); + if (typeVariable_1.flags & 16384 /* TypeParameter */) { + var mappedTypeVariable = instantiateType(typeVariable_1, mapper); + if (typeVariable_1 !== mappedTypeVariable) { + return mapType(mappedTypeVariable, function (t) { + if (isMappableType(t)) { + var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); + var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); + combinedMapper.mappedTypes = mapper.mappedTypes; + return instantiateMappedObjectType(type, combinedMapper); + } + return t; + }); + } } } return instantiateMappedObjectType(type, mapper); @@ -30170,12 +30490,12 @@ var ts; // Starting with the parent of the symbol's declaration, check if the mapper maps any of // the type parameters introduced by enclosing declarations. We just pick the first // declaration since multiple declarations will all have the same parent anyway. - var node = symbol.declarations[0].parent; + var node = symbol.declarations[0]; while (node) { switch (node.kind) { case 158 /* FunctionType */: case 159 /* ConstructorType */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 150 /* Constructor */: @@ -30186,10 +30506,10 @@ var ts; case 152 /* SetAccessor */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -30199,15 +30519,24 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 227 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 228 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 230 /* ModuleDeclaration */: - case 261 /* SourceFile */: + case 275 /* JSDocFunctionType */: + var func = node; + for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { + var p = _c[_b]; + if (ts.contains(mappedTypes, getTypeOfNode(p))) { + return true; + } + } + break; + case 231 /* ModuleDeclaration */: + case 262 /* SourceFile */: return false; } node = node.parent; @@ -30217,7 +30546,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 261 /* SourceFile */ || parentKind === 231 /* ModuleBlock */; + return parentKind === 262 /* SourceFile */ || parentKind === 232 /* ModuleBlock */; } return false; } @@ -30309,7 +30638,7 @@ var ts; case 192 /* BinaryExpression */: return node.operatorToken.kind === 53 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return isContextSensitive(node.initializer); case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -30376,7 +30705,7 @@ var ts; // subtype of T but not structurally identical to T. This specifically means that two distinct but // structurally identical types (such as two classes) are not considered instances of each other. function isTypeInstanceOf(source, target) { - return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); } /** * This is *not* a bi-directional relationship. @@ -30710,10 +31039,12 @@ var ts; } return false; } - // Compare two types and return - // Ternary.True if they are related with no assumptions, - // Ternary.Maybe if they are related with assumptions of other relationships, or - // Ternary.False if they are not related. + /** + * Compare two types and return + * * Ternary.True if they are related with no assumptions, + * * Ternary.Maybe if they are related with assumptions of other relationships, or + * * Ternary.False if they are not related. + */ function isRelatedTo(source, target, reportErrors, headMessage) { var result; if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 1048576 /* FreshLiteral */) { @@ -31177,8 +31508,11 @@ var ts; } } } - else if (relation !== identityRelation && isEmptyObjectType(resolveStructuredTypeMembers(target))) { - return -1 /* True */; + else if (relation !== identityRelation) { + var resolved = resolveStructuredTypeMembers(target); + if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1 /* Any */) { + return -1 /* True */; + } } return 0 /* False */; } @@ -31345,7 +31679,7 @@ var ts; return 0 /* False */; } var result = -1 /* True */; - for (var i = 0, len = sourceSignatures.length; i < len; i++) { + for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { return 0 /* False */; @@ -31584,8 +31918,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var t = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var t = types_8[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -31593,8 +31927,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -31700,8 +32034,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; result |= getFalsyFlags(t); } return result; @@ -31883,7 +32217,7 @@ var ts; case 174 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: @@ -32269,8 +32603,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -32411,7 +32745,7 @@ var ts; switch (source.kind) { case 70 /* Identifier */: return target.kind === 70 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 223 /* VariableDeclaration */ || target.kind === 174 /* BindingElement */) && + (target.kind === 224 /* VariableDeclaration */ || target.kind === 174 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98 /* ThisKeyword */: return target.kind === 98 /* ThisKeyword */; @@ -32516,8 +32850,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getTypeFacts(t); } return result; @@ -32605,7 +32939,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 /* ArrayLiteralExpression */ || node.parent.kind === 257 /* PropertyAssignment */ ? + return node.parent.kind === 175 /* ArrayLiteralExpression */ || node.parent.kind === 258 /* PropertyAssignment */ ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } @@ -32624,9 +32958,9 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return stringType; - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression) || unknownType; case 192 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); @@ -32636,9 +32970,9 @@ var ts; return getAssignedTypeOfArrayLiteralElement(parent, node); case 196 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -32664,26 +32998,26 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 212 /* ForInStatement */) { + if (node.parent.parent.kind === 213 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 213 /* ForOfStatement */) { + if (node.parent.parent.kind === 214 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 223 /* VariableDeclaration */ ? + return node.kind === 224 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 223 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */ ? + return node.kind === 224 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 223 /* VariableDeclaration */ && node.initializer && + return node.kind === 224 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || node.kind !== 174 /* BindingElement */ && node.parent.kind === 192 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); @@ -32710,7 +33044,7 @@ var ts; getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 253 /* CaseClause */) { + if (clause.kind === 254 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -32825,8 +33159,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; if (!(t.flags & 8192 /* Never */)) { if (!(getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -33461,8 +33795,8 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 231 /* ModuleBlock */ || - node.kind === 261 /* SourceFile */ || + node.kind === 232 /* ModuleBlock */ || + node.kind === 262 /* SourceFile */ || node.kind === 147 /* PropertyDeclaration */) { return node; } @@ -33542,7 +33876,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration_1.kind === 226 /* ClassDeclaration */ + if (declaration_1.kind === 227 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -33573,6 +33907,7 @@ var ts; } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkCollisionWithCapturedNewTargetVariable(node, node); checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; @@ -33611,7 +33946,7 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0 || isInTypeQuery(node)) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph @@ -33646,7 +33981,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 256 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 257 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -33671,8 +34006,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 211 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 224 /* VariableDeclarationList */).parent === container && + if (container.kind === 212 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 225 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -33793,11 +34128,11 @@ var ts; needToCaptureLexicalThis = (languageVersion < 2 /* ES2015 */); } switch (container.kind) { - case 230 /* ModuleDeclaration */: + case 231 /* 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 229 /* EnumDeclaration */: + case 230 /* 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; @@ -33861,9 +34196,9 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 274 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 275 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 277 /* JSDocThisType */) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 278 /* JSDocThisType */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -34254,8 +34589,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -34338,13 +34673,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 250 /* JsxAttribute */) { + if (attribute.kind === 251 /* JsxAttribute */) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 251 /* JsxSpreadAttribute */) { + else if (attribute.kind === 252 /* JsxSpreadAttribute */) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -34382,14 +34717,14 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 144 /* Parameter */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: case 174 /* BindingElement */: return getContextualTypeForInitializerExpression(node); case 185 /* ArrowFunction */: - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); case 195 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); @@ -34401,22 +34736,22 @@ var ts; return getTypeFromTypeNode(parent.type); case 192 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: + case 258 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); case 175 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); case 193 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: ts.Debug.assert(parent.parent.kind === 194 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); case 183 /* ParenthesizedExpression */: return getContextualType(parent); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return getContextualType(parent); - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: + case 251 /* JsxAttribute */: + case 252 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -34477,8 +34812,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -34683,18 +35018,18 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 257 /* PropertyAssignment */ || - memberDecl.kind === 258 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 258 /* PropertyAssignment */ || + memberDecl.kind === 259 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 257 /* PropertyAssignment */) { + if (memberDecl.kind === 258 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } else if (memberDecl.kind === 149 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 258 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 259 /* ShorthandPropertyAssignment */); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -34702,8 +35037,8 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 257 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 258 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 258 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 259 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912 /* Optional */; } @@ -34731,7 +35066,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 259 /* SpreadAssignment */) { + else if (memberDecl.kind === 260 /* SpreadAssignment */) { if (languageVersion < 5 /* ESNext */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -34842,13 +35177,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: checkJsxExpression(child); break; - case 246 /* JsxElement */: + case 247 /* JsxElement */: checkJsxElement(child); break; - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -35223,11 +35558,11 @@ var ts; // thus should have their types ignored var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 250 /* JsxAttribute */) { + if (node.attributes[i].kind === 251 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 251 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 252 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -35248,7 +35583,11 @@ var ts; } function checkJsxExpression(node) { if (node.expression) { - return checkExpression(node.expression); + var type = checkExpression(node.expression); + if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { + error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); + } + return type; } else { return unknownType; @@ -35276,7 +35615,7 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 /* PropertyAccessExpression */ || node.kind === 223 /* VariableDeclaration */ ? + var errorNode = node.kind === 177 /* PropertyAccessExpression */ || node.kind === 224 /* VariableDeclaration */ ? node.name : node.right; if (left.kind === 96 /* SuperKeyword */) { @@ -35453,7 +35792,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 224 /* VariableDeclarationList */) { + if (initializer.kind === 225 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -35482,7 +35821,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 212 /* ForInStatement */ && + if (node.kind === 213 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -35591,13 +35930,13 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_8 = signature.declaration && signature.declaration.parent; + var parent_9 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_8 === lastParent) { + if (lastParent && parent_9 === lastParent) { index++; } else { - lastParent = parent_8; + lastParent = parent_9; index = cutoffIndex; } } @@ -35605,7 +35944,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_8; + lastParent = parent_9; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -35909,7 +36248,7 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 145 /* Decorator */) { switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; @@ -35953,7 +36292,7 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 227 /* ClassDeclaration */) { // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); @@ -35998,7 +36337,7 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 227 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } @@ -36049,7 +36388,7 @@ var ts; function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 227 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } @@ -36554,7 +36893,7 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 144 /* Parameter */: @@ -36693,9 +37032,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 225 /* FunctionDeclaration */ + ? 226 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 223 /* VariableDeclaration */ + ? 224 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -36722,6 +37061,23 @@ var ts; function checkNonNullAssertion(node) { return getNonNullableType(checkExpression(node.expression)); } + function checkMetaProperty(node) { + checkGrammarMetaProperty(node); + ts.Debug.assert(node.keywordToken === 93 /* NewKeyword */ && node.name.text === "target", "Unrecognized meta-property."); + var container = ts.getNewTargetContainer(node); + if (!container) { + error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); + return unknownType; + } + else if (container.kind === 150 /* Constructor */) { + var symbol = getSymbolOfNode(container.parent); + return getTypeOfSymbol(symbol); + } + else { + var symbol = getSymbolOfNode(container); + return getTypeOfSymbol(symbol); + } + } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks) { @@ -36863,7 +37219,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 204 /* Block */) { + if (func.body.kind !== 205 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -36953,7 +37309,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 218 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 219 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -37015,7 +37371,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (ts.nodeIsMissing(func.body) || func.body.kind !== 204 /* Block */ || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 205 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -37095,6 +37451,7 @@ var ts; if (produceDiagnostics && node.kind !== 149 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); } return type; } @@ -37115,7 +37472,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 204 /* Block */) { + if (node.body.kind === 205 /* Block */) { checkSourceElement(node.body); } else { @@ -37184,7 +37541,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 237 /* NamespaceImport */; + return declaration && declaration.kind === 238 /* NamespaceImport */; } } } @@ -37201,6 +37558,16 @@ var ts; } function checkDeleteExpression(node) { checkExpression(node.expression); + var expr = ts.skipParentheses(node.expression); + if (expr.kind !== 177 /* PropertyAccessExpression */ && expr.kind !== 178 /* ElementAccessExpression */) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); + return booleanType; + } + var links = getNodeLinks(expr); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } return booleanType; } function checkTypeOfExpression(node) { @@ -37276,8 +37643,8 @@ var ts; } if (type.flags & 196608 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -37294,8 +37661,8 @@ var ts; } if (type.flags & 65536 /* Union */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -37304,8 +37671,8 @@ var ts; } if (type.flags & 131072 /* Intersection */) { var types = type.types; - for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { - var t = types_17[_a]; + for (var _a = 0, types_18 = types; _a < types_18.length; _a++) { + var t = types_18[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -37363,7 +37730,7 @@ var ts; } /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 257 /* PropertyAssignment */ || property.kind === 258 /* ShorthandPropertyAssignment */) { + if (property.kind === 258 /* PropertyAssignment */ || property.kind === 259 /* ShorthandPropertyAssignment */) { var name_20 = property.name; if (name_20.kind === 142 /* ComputedPropertyName */) { checkComputedPropertyName(name_20); @@ -37378,7 +37745,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 258 /* ShorthandPropertyAssignment */) { + if (property.kind === 259 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -37390,7 +37757,7 @@ var ts; error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); } } - else if (property.kind === 259 /* SpreadAssignment */) { + else if (property.kind === 260 /* SpreadAssignment */) { if (languageVersion < 5 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -37463,7 +37830,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 258 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 259 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -37493,7 +37860,7 @@ var ts; } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 259 /* SpreadAssignment */ ? + var error = target.parent.kind === 260 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -37530,8 +37897,8 @@ var ts; case 176 /* ObjectLiteralExpression */: case 187 /* TypeOfExpression */: case 201 /* NonNullExpression */: - case 247 /* JsxSelfClosingElement */: - case 246 /* JsxElement */: + case 248 /* JsxSelfClosingElement */: + case 247 /* JsxElement */: return true; case 193 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && @@ -38038,6 +38405,8 @@ var ts; return checkAssertion(node); case 201 /* NonNullExpression */: return checkNonNullAssertion(node); + case 202 /* MetaProperty */: + return checkMetaProperty(node); case 186 /* DeleteExpression */: return checkDeleteExpression(node); case 188 /* VoidExpression */: @@ -38058,13 +38427,13 @@ var ts; return undefinedWideningType; case 195 /* YieldExpression */: return checkYieldExpression(node); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return checkJsxExpression(node); - case 246 /* JsxElement */: + case 247 /* JsxElement */: return checkJsxElement(node); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 248 /* JsxOpeningElement */: + case 249 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -38118,7 +38487,7 @@ var ts; return false; } return node.kind === 149 /* MethodDeclaration */ || - node.kind === 225 /* FunctionDeclaration */ || + node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { @@ -38179,14 +38548,14 @@ var ts; switch (node.parent.kind) { case 185 /* ArrowFunction */: case 153 /* CallSignature */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 158 /* FunctionType */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: - var parent_9 = node.parent; - if (node === parent_9.type) { - return parent_9; + var parent_10 = node.parent; + if (node === parent_10.type) { + return parent_10; } } } @@ -38215,7 +38584,7 @@ var ts; if (node.kind === 155 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 /* FunctionType */ || node.kind === 225 /* FunctionDeclaration */ || node.kind === 159 /* ConstructorType */ || + else if (node.kind === 158 /* FunctionType */ || node.kind === 226 /* FunctionDeclaration */ || node.kind === 159 /* ConstructorType */ || node.kind === 153 /* CallSignature */ || node.kind === 150 /* Constructor */ || node.kind === 154 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); @@ -38349,7 +38718,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 227 /* InterfaceDeclaration */) { + if (node.kind === 228 /* 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 @@ -38445,7 +38814,7 @@ var ts; if (n.kind === 98 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 /* FunctionExpression */ && n.kind !== 225 /* FunctionDeclaration */) { + else if (n.kind !== 184 /* FunctionExpression */ && n.kind !== 226 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } @@ -38480,7 +38849,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -38641,8 +39010,8 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 227 /* InterfaceDeclaration */ && - n.parent.kind !== 226 /* ClassDeclaration */ && + if (n.parent.kind !== 228 /* InterfaceDeclaration */ && + n.parent.kind !== 227 /* ClassDeclaration */ && n.parent.kind !== 197 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { @@ -38770,7 +39139,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 227 /* InterfaceDeclaration */ || node.parent.kind === 161 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 228 /* InterfaceDeclaration */ || node.parent.kind === 161 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -38781,7 +39150,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 === 225 /* FunctionDeclaration */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */ || node.kind === 150 /* Constructor */) { + if (node.kind === 226 /* FunctionDeclaration */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */ || node.kind === 150 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -38903,16 +39272,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -38924,7 +39293,8 @@ var ts; } function checkNonThenableType(type, location, message) { type = getWidenedType(type); - if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + var apparentType = getApparentType(type); + if ((apparentType.flags & (1 /* Any */ | 8192 /* Never */)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -39175,7 +39545,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -39238,7 +39608,7 @@ var ts; checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -39271,6 +39641,7 @@ var ts; checkFunctionOrMethodDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -39342,28 +39713,28 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 261 /* SourceFile */: - case 230 /* ModuleDeclaration */: + case 262 /* SourceFile */: + case 231 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 204 /* Block */: - case 232 /* CaseBlock */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 205 /* Block */: + case 233 /* CaseBlock */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: checkUnusedLocalsAndParameters(node); break; case 150 /* Constructor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: @@ -39387,7 +39758,7 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 227 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 228 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_2 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { @@ -39420,9 +39791,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 223 /* VariableDeclaration */ && - (declaration.parent.parent.kind === 212 /* ForInStatement */ || - declaration.parent.parent.kind === 213 /* ForOfStatement */)) { + if (declaration.kind === 224 /* VariableDeclaration */ && + (declaration.parent.parent.kind === 213 /* ForInStatement */ || + declaration.parent.parent.kind === 214 /* ForOfStatement */)) { return; } } @@ -39485,7 +39856,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - error(declaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + errorUnusedLocal(declaration.name, local.name); } } } @@ -39494,7 +39865,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 204 /* Block */) { + if (node.kind === 205 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -39542,6 +39913,11 @@ var ts; potentialThisCollisions.push(node); } } + function checkCollisionWithCapturedNewTargetVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_newTarget")) { + potentialNewTargetCollisions.push(node); + } + } // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; @@ -39559,6 +39935,22 @@ var ts; current = current.parent; } } + function checkIfNewTargetIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { + var isDeclaration_2 = node.kind !== 70 /* Identifier */; + if (isDeclaration_2) { + error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); + } + return; + } + current = current.parent; + } + } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -39570,8 +39962,8 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 70 /* Identifier */; - if (isDeclaration_2) { + var isDeclaration_3 = node.kind !== 70 /* Identifier */; + if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -39588,12 +39980,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 230 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 231 /* 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 === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(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)); } @@ -39603,12 +39995,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 230 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 231 /* 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 === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -39643,7 +40035,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 === 223 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 224 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -39653,17 +40045,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 224 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 205 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 225 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 206 /* 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 === 204 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 231 /* ModuleBlock */ || - container.kind === 230 /* ModuleDeclaration */ || - container.kind === 261 /* SourceFile */); + (container.kind === 205 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 232 /* ModuleBlock */ || + container.kind === 231 /* ModuleDeclaration */ || + container.kind === 262 /* 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 @@ -39708,7 +40100,8 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144 /* Parameter */) { + if (symbol.valueDeclaration.kind === 144 /* Parameter */ || + symbol.valueDeclaration.kind === 174 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -39756,7 +40149,7 @@ var ts; } } if (node.kind === 174 /* BindingElement */) { - if (node.parent.kind === 172 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */) { + if (node.parent.kind === 172 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */ && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements @@ -39764,13 +40157,13 @@ var ts; checkComputedPropertyName(node.propertyName); } // check private/protected variable access - var parent_10 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_10); + var parent_11 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_11); var name_24 = node.propertyName || node.name; var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_24)); markPropertyAsReferenced(property); - if (parent_10.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_10, parent_10.initializer, parentType, property); + if (parent_11.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); } } // For a binding pattern, check contained binding elements @@ -39785,7 +40178,7 @@ var ts; // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 212 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 213 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -39796,7 +40189,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 212 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 213 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -39819,18 +40212,19 @@ var ts; if (node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 146 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 223 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */) { + if (node.kind === 224 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 /* Parameter */ && right.kind === 223 /* VariableDeclaration */) || - (left.kind === 223 /* VariableDeclaration */ && right.kind === 144 /* Parameter */)) { + if ((left.kind === 144 /* Parameter */ && right.kind === 224 /* VariableDeclaration */) || + (left.kind === 224 /* VariableDeclaration */ && right.kind === 144 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -39881,7 +40275,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 206 /* EmptyStatement */) { + if (node.thenStatement.kind === 207 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -39901,12 +40295,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 224 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 225 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 225 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -39929,7 +40323,7 @@ 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 === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 225 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { @@ -39968,7 +40362,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 === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 225 /* 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); @@ -40318,7 +40712,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 254 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 255 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -40330,7 +40724,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 253 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 254 /* 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 comparable @@ -40361,7 +40755,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 219 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 220 /* 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; @@ -40501,7 +40895,7 @@ var ts; /** Check each type parameter and check that type parameters have no duplicate type parameter declarations */ function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { @@ -40522,7 +40916,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 /* ClassDeclaration */ || declaration.kind === 227 /* InterfaceDeclaration */) { + if (declaration.kind === 227 /* ClassDeclaration */ || declaration.kind === 228 /* InterfaceDeclaration */) { if (!firstDecl) { firstDecl = declaration; } @@ -40555,6 +40949,7 @@ var ts; if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -40590,7 +40985,7 @@ var ts; checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 226 /* ClassDeclaration */) { + baseType_1.symbol.valueDeclaration.kind === 227 /* ClassDeclaration */) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -40751,7 +41146,7 @@ var ts; // TypeScript 1.0 spec (April 2014): // When a generic interface has multiple declarations, all declarations must have identical type parameter // lists, i.e. identical type parameter names with identical constraints in identical order. - for (var i = 0, len = list1.length; i < len; i++) { + for (var i = 0; i < list1.length; i++) { var tp1 = list1[i]; var tp2 = list2[i]; if (tp1.name.text !== tp2.name.text) { @@ -40811,7 +41206,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 228 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -40953,6 +41348,7 @@ var ts; } return undefined; case 8 /* NumericLiteral */: + checkGrammarNumericLiteral(e); return +e.text; case 183 /* ParenthesizedExpression */: return evalConstant(e.expression); @@ -41033,6 +41429,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); @@ -41061,7 +41458,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 229 /* EnumDeclaration */) { + if (declaration.kind !== 230 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -41084,8 +41481,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 226 /* ClassDeclaration */ || - (declaration.kind === 225 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 227 /* ClassDeclaration */ || + (declaration.kind === 226 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -41149,7 +41546,7 @@ 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, 226 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 227 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -41200,23 +41597,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 240 /* ExportAssignment */: - case 241 /* ExportDeclaration */: + case 241 /* ExportAssignment */: + case 242 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 234 /* ImportEqualsDeclaration */: - case 235 /* ImportDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; case 174 /* BindingElement */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: var name_25 = node.name; if (ts.isBindingPattern(name_25)) { for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { @@ -41227,12 +41624,12 @@ var ts; break; } // fallthrough - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 225 /* FunctionDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 226 /* FunctionDeclaration */: + case 228 /* InterfaceDeclaration */: + case 231 /* ModuleDeclaration */: + case 229 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -41273,9 +41670,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 231 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 241 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 232 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 242 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -41308,7 +41705,7 @@ var ts; (symbol.flags & 793064 /* Type */ ? 793064 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 243 /* ExportSpecifier */ ? + var message = node.kind === 244 /* 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)); @@ -41336,7 +41733,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 238 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -41393,8 +41790,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 231 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 232 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -41408,7 +41805,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 261 /* SourceFile */ || node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 230 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 262 /* SourceFile */ || node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 231 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -41434,9 +41831,14 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 261 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 230 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + var container = node.parent.kind === 262 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 231 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + if (node.isExportEquals) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + } + else { + error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); + } return; } // Grammar checking @@ -41510,7 +41912,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 225 /* FunctionDeclaration */ && declaration.kind !== 149 /* MethodDeclaration */) || + return (declaration.kind !== 226 /* FunctionDeclaration */ && declaration.kind !== 149 /* MethodDeclaration */) || !!declaration.body; } } @@ -41523,10 +41925,10 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: + case 231 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 226 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -41575,71 +41977,71 @@ var ts; return checkIndexedAccessType(node); case 170 /* MappedType */: return checkMappedType(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 204 /* Block */: - case 231 /* ModuleBlock */: + case 205 /* Block */: + case 232 /* ModuleBlock */: return checkBlock(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return checkVariableStatement(node); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return checkExpressionStatement(node); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return checkIfStatement(node); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return checkDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return checkWhileStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return checkForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return checkForInStatement(node); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return checkForOfStatement(node); - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 215 /* ContinueStatement */: + case 216 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return checkReturnStatement(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return checkWithStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return checkSwitchStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return checkLabeledStatement(node); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return checkThrowStatement(node); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return checkTryStatement(node); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return checkVariableDeclaration(node); case 174 /* BindingElement */: return checkBindingElement(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return checkClassDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return checkImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return checkExportDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return checkExportAssignment(node); - case 206 /* EmptyStatement */: + case 207 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 222 /* DebuggerStatement */: + case 223 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 244 /* MissingDeclaration */: + case 245 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -41696,6 +42098,7 @@ var ts; // Grammar checking checkGrammarSourceFile(node); potentialThisCollisions.length = 0; + potentialNewTargetCollisions.length = 0; deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; ts.forEach(node.statements, checkSourceElement); @@ -41715,6 +42118,10 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } + if (potentialNewTargetCollisions.length) { + ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); + potentialNewTargetCollisions.length = 0; + } links.flags |= 1 /* TypeChecked */; } } @@ -41772,7 +42179,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 217 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 218 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -41795,14 +42202,14 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; case 197 /* ClassExpression */: @@ -41812,8 +42219,8 @@ var ts; } // fall through; this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -41872,10 +42279,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 143 /* TypeParameter */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 230 /* EnumDeclaration */: return true; } } @@ -41885,7 +42292,7 @@ var ts; while (node.parent && node.parent.kind === 141 /* QualifiedName */) { node = node.parent; } - return node.parent && (node.parent.kind === 157 /* TypeReference */ || node.parent.kind === 272 /* JSDocTypeReference */); + return node.parent && (node.parent.kind === 157 /* TypeReference */ || node.parent.kind === 273 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; @@ -41912,10 +42319,10 @@ var ts; while (nodeOnRightSide.parent.kind === 141 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 234 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 235 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 240 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 241 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -41939,13 +42346,13 @@ var ts; default: } } - if (entityName.parent.kind === 240 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 241 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */); } if (entityName.kind !== 177 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 234 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 235 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -41995,10 +42402,10 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 /* TypeReference */ || entityName.parent.kind === 272 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = (entityName.parent.kind === 157 /* TypeReference */ || entityName.parent.kind === 273 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 250 /* JsxAttribute */) { + else if (entityName.parent.kind === 251 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 156 /* TypePredicate */) { @@ -42008,7 +42415,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -42066,7 +42473,7 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 235 /* ImportDeclaration */ || node.parent.kind === 241 /* ExportDeclaration */) && + ((node.parent.kind === 236 /* ImportDeclaration */ || node.parent.kind === 242 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -42093,7 +42500,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 === 258 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 259 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; @@ -42159,7 +42566,7 @@ var ts; // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 213 /* ForOfStatement */) { + if (expr.parent.kind === 214 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -42171,7 +42578,7 @@ var ts; } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 257 /* PropertyAssignment */) { + if (expr.parent.kind === 258 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } @@ -42312,7 +42719,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 261 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 262 /* SourceFile */) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -42369,7 +42776,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 204 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 205 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -42415,16 +42822,16 @@ var ts; return true; } switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: - case 236 /* ImportClause */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 235 /* ImportEqualsDeclaration */: + case 237 /* ImportClause */: + case 238 /* NamespaceImport */: + case 240 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return node.expression && node.expression.kind === 70 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -42434,7 +42841,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 261 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 262 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -42500,7 +42907,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 260 /* EnumMember */) { + if (node.kind === 261 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -42601,9 +43008,9 @@ var ts; if (startInDeclarationContainer) { // When resolving the name of a declaration as a value, we need to start resolution // at a point outside of the declaration. - var parent_11 = reference.parent; - if (ts.isDeclaration(parent_11) && reference === parent_11.name) { - location = getDeclarationContainer(parent_11); + var parent_12 = reference.parent; + if (ts.isDeclaration(parent_12) && reference === parent_12.name) { + location = getDeclarationContainer(parent_12); } } return resolveName(location, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -42732,15 +43139,15 @@ var ts; // external modules cannot define or contribute to type declaration files var current = symbol; while (true) { - var parent_12 = getParentOfSymbol(current); - if (parent_12) { - current = parent_12; + var parent_13 = getParentOfSymbol(current); + if (parent_13) { + current = parent_13; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 261 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 262 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -42760,7 +43167,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 261 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 262 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -42946,7 +43353,7 @@ var ts; } switch (modifier.kind) { case 75 /* ConstKeyword */: - if (node.kind !== 229 /* EnumDeclaration */ && node.parent.kind === 226 /* ClassDeclaration */) { + if (node.kind !== 230 /* EnumDeclaration */ && node.parent.kind === 227 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); } break; @@ -42972,7 +43379,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + else if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -42995,7 +43402,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + else if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 144 /* Parameter */) { @@ -43031,7 +43438,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 227 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 144 /* Parameter */) { @@ -43046,13 +43453,13 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 227 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === 144 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 231 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 232 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -43062,14 +43469,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 226 /* ClassDeclaration */) { + if (node.kind !== 227 /* ClassDeclaration */) { if (node.kind !== 149 /* MethodDeclaration */ && node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 151 /* GetAccessor */ && node.kind !== 152 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 226 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 227 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -43111,7 +43518,7 @@ var ts; } return; } - else if ((node.kind === 235 /* ImportDeclaration */ || node.kind === 234 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 236 /* ImportDeclaration */ || node.kind === 235 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 144 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { @@ -43145,29 +43552,29 @@ var ts; case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 155 /* IndexSignature */: - case 230 /* ModuleDeclaration */: - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: - case 240 /* ExportAssignment */: + case 231 /* ModuleDeclaration */: + case 236 /* ImportDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 242 /* ExportDeclaration */: + case 241 /* ExportAssignment */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 144 /* Parameter */: return false; default: - if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { return false; } switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); - case 227 /* InterfaceDeclaration */: - case 205 /* VariableStatement */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 206 /* VariableStatement */: + case 229 /* TypeAliasDeclaration */: return true; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); default: ts.Debug.fail(); @@ -43181,7 +43588,7 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 149 /* MethodDeclaration */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: if (!node.asteriskToken) { @@ -43392,7 +43799,7 @@ var ts; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 225 /* FunctionDeclaration */ || + ts.Debug.assert(node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || node.kind === 149 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { @@ -43419,7 +43826,7 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 /* SpreadAssignment */) { + if (prop.kind === 260 /* SpreadAssignment */) { continue; } var name_28 = prop.name; @@ -43427,7 +43834,7 @@ var ts; // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_28); } - if (prop.kind === 258 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 259 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -43450,7 +43857,7 @@ 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 === 257 /* PropertyAssignment */ || prop.kind === 258 /* ShorthandPropertyAssignment */) { + if (prop.kind === 258 /* PropertyAssignment */ || prop.kind === 259 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_28.kind === 8 /* NumericLiteral */) { @@ -43500,7 +43907,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 251 /* JsxSpreadAttribute */) { + if (attr.kind === 252 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; @@ -43512,7 +43919,7 @@ var ts; return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 252 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 253 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -43521,7 +43928,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 224 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 225 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -43536,20 +43943,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 213 /* 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 = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 213 /* 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 === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 213 /* 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); @@ -43642,7 +44049,7 @@ 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 === 227 /* InterfaceDeclaration */) { + else if (node.parent.kind === 228 /* 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 === 161 /* TypeLiteral */) { @@ -43656,11 +44063,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 219 /* LabeledStatement */: + case 220 /* 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 === 214 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 215 /* ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -43668,8 +44075,8 @@ var ts; return false; } break; - case 218 /* SwitchStatement */: - if (node.kind === 215 /* BreakStatement */ && !node.label) { + case 219 /* SwitchStatement */: + if (node.kind === 216 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -43684,13 +44091,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 215 /* BreakStatement */ + var message = node.kind === 216 /* 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 === 215 /* BreakStatement */ + var message = node.kind === 216 /* 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); @@ -43717,7 +44124,7 @@ var ts; expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 212 /* ForInStatement */ && node.parent.parent.kind !== 213 /* ForOfStatement */) { + if (node.parent.parent.kind !== 213 /* ForInStatement */ && node.parent.parent.kind !== 214 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -43782,15 +44189,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 217 /* WithStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 209 /* IfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 218 /* WithStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: return false; - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -43805,6 +44212,13 @@ var ts; } } } + function checkGrammarMetaProperty(node) { + if (node.keywordToken === 93 /* NewKeyword */) { + if (node.name.text !== "target") { + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + } + } + } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -43845,7 +44259,7 @@ var ts; return true; } } - else if (node.parent.kind === 227 /* InterfaceDeclaration */) { + else if (node.parent.kind === 228 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -43878,13 +44292,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 227 /* InterfaceDeclaration */ || - node.kind === 228 /* TypeAliasDeclaration */ || - node.kind === 235 /* ImportDeclaration */ || - node.kind === 234 /* ImportEqualsDeclaration */ || - node.kind === 241 /* ExportDeclaration */ || - node.kind === 240 /* ExportAssignment */ || - node.kind === 233 /* NamespaceExportDeclaration */ || + if (node.kind === 228 /* InterfaceDeclaration */ || + node.kind === 229 /* TypeAliasDeclaration */ || + node.kind === 236 /* ImportDeclaration */ || + node.kind === 235 /* ImportEqualsDeclaration */ || + node.kind === 242 /* ExportDeclaration */ || + node.kind === 241 /* ExportAssignment */ || + node.kind === 234 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -43893,7 +44307,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 === 205 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 206 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -43919,7 +44333,7 @@ var ts; // to prevent noisiness. 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 === 204 /* Block */ || node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + if (node.parent.kind === 205 /* Block */ || node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -43932,8 +44346,22 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.isOctalLiteral && languageVersion >= 1 /* ES5 */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + if (node.isOctalLiteral) { + var diagnosticMessage = void 0; + if (languageVersion >= 1 /* ES5 */) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 171 /* LiteralType */)) { + diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 261 /* EnumMember */)) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; + } + if (diagnosticMessage) { + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37 /* MinusToken */; + var literal = (withMinus ? "-" : "") + "0o" + node.text; + return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); + } } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -43997,31 +44425,31 @@ var ts; _a[201 /* NonNullExpression */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[229 /* EnumDeclaration */] = [ + _a[230 /* EnumDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[230 /* ModuleDeclaration */] = [ + _a[231 /* ModuleDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[231 /* ModuleBlock */] = [ + _a[232 /* ModuleBlock */] = [ { name: "statements", test: ts.isStatement } ], - _a[234 /* ImportEqualsDeclaration */] = [ + _a[235 /* ImportEqualsDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[245 /* ExternalModuleReference */] = [ + _a[246 /* ExternalModuleReference */] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[260 /* EnumMember */] = [ + _a[261 /* EnumMember */] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -44059,11 +44487,11 @@ var ts; var result = initial; switch (node.kind) { // Leaf nodes - case 203 /* SemicolonClassElement */: - case 206 /* EmptyStatement */: + case 204 /* SemicolonClassElement */: + case 207 /* EmptyStatement */: case 198 /* OmittedExpression */: - case 222 /* DebuggerStatement */: - case 293 /* NotEmittedStatement */: + case 223 /* DebuggerStatement */: + case 294 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -44211,73 +44639,73 @@ var ts; result = reduceNodes(node.typeArguments, cbNodes, result); break; // Misc - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 204 /* Block */: + case 205 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 208 /* IfStatement */: + case 209 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 209 /* DoStatement */: + case 210 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 210 /* WhileStatement */: - case 217 /* WithStatement */: + case 211 /* WhileStatement */: + case 218 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 211 /* ForStatement */: + case 212 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 216 /* ReturnStatement */: - case 220 /* ThrowStatement */: + case 217 /* ReturnStatement */: + case 221 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 221 /* TryStatement */: + case 222 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44286,7 +44714,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44294,97 +44722,97 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 236 /* ImportClause */: + case 237 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 239 /* NamedImports */: + case 243 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // JSX - case 246 /* JsxElement */: + case 247 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 248 /* JsxSelfClosingElement */: + case 249 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.attributes, cbNodes, result); break; - case 249 /* JsxClosingElement */: + case 250 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 253 /* CaseClause */: + case 254 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // fall-through - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 256 /* CatchClause */: + case 257 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Top-level nodes - case 261 /* SourceFile */: + case 262 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; default: @@ -44542,10 +44970,10 @@ var ts; return node; } switch (node.kind) { - case 203 /* SemicolonClassElement */: - case 206 /* EmptyStatement */: + case 204 /* SemicolonClassElement */: + case 207 /* EmptyStatement */: case 198 /* OmittedExpression */: - case 222 /* DebuggerStatement */: + case 223 /* DebuggerStatement */: // No need to visit nodes with no children. return node; // Names @@ -44620,107 +45048,107 @@ var ts; case 199 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 204 /* Block */: + case 205 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, /*optional*/ true, liftToBlock)); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 214 /* ContinueStatement */: + case 215 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 215 /* BreakStatement */: + case 216 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, /*optional*/ true), visitNode(node.finallyBlock, visitor, ts.isBlock, /*optional*/ true)); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true)); - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 238 /* NamedImports */: + case 239 /* NamedImports */: return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 239 /* ImportSpecifier */: + case 240 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, /*optional*/ true)); - case 242 /* NamedExports */: + case 243 /* NamedExports */: return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 243 /* ExportSpecifier */: + case 244 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); // JSX - case 246 /* JsxElement */: + case 247 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 248 /* JsxOpeningElement */: + case 249 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 249 /* JsxClosingElement */: + case 250 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 253 /* CaseClause */: + case 254 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Top-level nodes - case 261 /* SourceFile */: + case 262 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -44836,7 +45264,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || ts.isTypeNode(node)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 199 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -45412,15 +45840,15 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 261 /* SourceFile */: - case 232 /* CaseBlock */: - case 231 /* ModuleBlock */: - case 204 /* Block */: + case 262 /* SourceFile */: + case 233 /* CaseBlock */: + case 232 /* ModuleBlock */: + case 205 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 226 /* ClassDeclaration */: - case 225 /* FunctionDeclaration */: + case 227 /* ClassDeclaration */: + case 226 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -45467,13 +45895,13 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitExportAssignment(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -45493,11 +45921,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 241 /* ExportDeclaration */ || - node.kind === 235 /* ImportDeclaration */ || - node.kind === 236 /* ImportClause */ || - (node.kind === 234 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 245 /* ExternalModuleReference */)) { + if (node.kind === 242 /* ExportDeclaration */ || + node.kind === 236 /* ImportDeclaration */ || + node.kind === 237 /* ImportClause */ || + (node.kind === 235 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 246 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -45539,7 +45967,7 @@ var ts; case 149 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 203 /* SemicolonClassElement */: + case 204 /* SemicolonClassElement */: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -45608,18 +46036,18 @@ var ts; // TypeScript index signatures are elided. case 145 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. case 147 /* PropertyDeclaration */: // TypeScript property declarations are elided. return undefined; case 150 /* Constructor */: return visitConstructor(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -45641,7 +46069,7 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: @@ -45660,7 +46088,7 @@ var ts; case 152 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: @@ -45694,18 +46122,18 @@ var ts; case 201 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -46113,7 +46541,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -46622,7 +47050,7 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; case 149 /* MethodDeclaration */: @@ -46645,7 +47073,7 @@ var ts; return serializeTypeNode(node.type); case 152 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: case 149 /* MethodDeclaration */: return ts.createIdentifier("Function"); @@ -46730,6 +47158,9 @@ var ts; } switch (node.kind) { case 104 /* VoidKeyword */: + case 137 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 129 /* NeverKeyword */: return ts.createVoidZero(); case 166 /* ParenthesizedType */: return serializeTypeNode(node.type); @@ -46768,34 +47199,7 @@ var ts; return serializeTypeReferenceNode(node); case 165 /* IntersectionType */: case 164 /* UnionType */: - { - var unionOrIntersection = node; - var serializedUnion = void 0; - for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - var serializedIndividual = serializeTypeNode(typeNode); - // Non identifier - if (serializedIndividual.kind !== 70 /* Identifier */) { - serializedUnion = undefined; - break; - } - // One of the individual is global object, return immediately - if (serializedIndividual.text === "Object") { - return serializedIndividual; - } - // Different types - if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { - serializedUnion = undefined; - break; - } - serializedUnion = serializedIndividual; - } - // If we were able to find common type - if (serializedUnion) { - return serializedUnion; - } - } - // Fallthrough + return serializeUnionOrIntersectionType(node); case 160 /* TypeQuery */: case 168 /* TypeOperator */: case 169 /* IndexedAccessType */: @@ -46810,6 +47214,37 @@ var ts; } return ts.createIdentifier("Object"); } + function serializeUnionOrIntersectionType(node) { + var serializedUnion; + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (ts.isVoidExpression(serializedIndividual)) { + // If we dont have any other type already set, set the initial type + if (!serializedUnion) { + serializedUnion = serializedIndividual; + } + } + else if (ts.isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") { + // One of the individual is global object, return immediately + return serializedIndividual; + } + else if (serializedUnion && !ts.isVoidExpression(serializedUnion)) { + // Different types + if (!ts.isIdentifier(serializedUnion) || + !ts.isIdentifier(serializedIndividual) || + serializedUnion.text !== serializedIndividual.text) { + return ts.createIdentifier("Object"); + } + } + else { + // Initialize the union type + serializedUnion = serializedIndividual; + } + } + // If we were able to find common type, use it + return serializedUnion; + } /** * Serializes a TypeReferenceNode to an appropriate JS constructor value for use with * decorator type metadata. @@ -47411,7 +47846,7 @@ var ts; recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 229 /* EnumDeclaration */) { + if (node.kind === 230 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -47530,8 +47965,8 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 231 /* ModuleBlock */) { - ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); + if (body.kind === 232 /* ModuleBlock */) { + saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; } @@ -47576,13 +48011,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 231 /* ModuleBlock */) { + if (body.kind !== 232 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 230 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 231 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -47623,7 +48058,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 237 /* NamespaceImport */) { + if (node.kind === 238 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -47855,16 +48290,16 @@ var ts; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. context.enableSubstitution(70 /* Identifier */); - context.enableSubstitution(258 /* ShorthandPropertyAssignment */); + context.enableSubstitution(259 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(230 /* ModuleDeclaration */); + context.enableEmitNotification(231 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 230 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 231 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 229 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 230 /* EnumDeclaration */; } /** * Hook for node emit. @@ -47960,9 +48395,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 261 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 230 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 229 /* EnumDeclaration */); + if (container && container.kind !== 262 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 231 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 230 /* EnumDeclaration */); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, /*location*/ node); } @@ -48082,11 +48517,11 @@ var ts; return visitObjectLiteralExpression(node); case 192 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return visitForOfStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return visitForStatement(node); case 188 /* VoidExpression */: return visitVoidExpression(node); @@ -48098,7 +48533,7 @@ var ts; return visitGetAccessorDeclaration(node); case 152 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: return visitFunctionExpression(node); @@ -48106,7 +48541,7 @@ var ts; return visitArrowFunction(node); case 144 /* Parameter */: return visitParameter(node); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return visitExpressionStatement(node); case 183 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); @@ -48119,7 +48554,7 @@ var ts; var objects = []; for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { var e = elements_3[_i]; - if (e.kind === 259 /* SpreadAssignment */) { + if (e.kind === 260 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -48131,7 +48566,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 257 /* PropertyAssignment */) { + if (e.kind === 258 /* PropertyAssignment */) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -48361,11 +48796,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 246 /* JsxElement */: + case 247 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -48375,11 +48810,11 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return visitJsxExpression(node); - case 246 /* JsxElement */: + case 247 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); default: ts.Debug.failBadSyntaxKind(node); @@ -48440,7 +48875,10 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, /*location*/ node) : node; } - else if (node.kind === 252 /* JsxExpression */) { + else if (node.kind === 253 /* JsxExpression */) { + if (node.expression === undefined) { + return ts.createLiteral(true); + } return visitJsxExpression(node); } else { @@ -48522,7 +48960,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 246 /* JsxElement */) { + if (node.kind === 247 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -48868,7 +49306,7 @@ var ts; case 149 /* MethodDeclaration */: // ES2017 method declarations may be 'async' return visitMethodDeclaration(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: // ES2017 function declarations may be 'async' return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: @@ -49032,7 +49470,7 @@ var ts; context.enableSubstitution(177 /* PropertyAccessExpression */); context.enableSubstitution(178 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(226 /* ClassDeclaration */); + context.enableEmitNotification(227 /* ClassDeclaration */); context.enableEmitNotification(149 /* MethodDeclaration */); context.enableEmitNotification(151 /* GetAccessor */); context.enableEmitNotification(152 /* SetAccessor */); @@ -49089,7 +49527,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 226 /* ClassDeclaration */ + return kind === 227 /* ClassDeclaration */ || kind === 150 /* Constructor */ || kind === 149 /* MethodDeclaration */ || kind === 151 /* GetAccessor */ @@ -49299,6 +49737,82 @@ var ts; */ SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; })(SuperCaptureResult || (SuperCaptureResult = {})); + // Facts we track as we traverse the tree + var HierarchyFacts; + (function (HierarchyFacts) { + HierarchyFacts[HierarchyFacts["None"] = 0] = "None"; + // + // Ancestor facts + // + HierarchyFacts[HierarchyFacts["Function"] = 1] = "Function"; + HierarchyFacts[HierarchyFacts["ArrowFunction"] = 2] = "ArrowFunction"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBody"] = 4] = "AsyncFunctionBody"; + HierarchyFacts[HierarchyFacts["NonStaticClassElement"] = 8] = "NonStaticClassElement"; + HierarchyFacts[HierarchyFacts["CapturesThis"] = 16] = "CapturesThis"; + HierarchyFacts[HierarchyFacts["ExportedVariableStatement"] = 32] = "ExportedVariableStatement"; + HierarchyFacts[HierarchyFacts["TopLevel"] = 64] = "TopLevel"; + HierarchyFacts[HierarchyFacts["Block"] = 128] = "Block"; + HierarchyFacts[HierarchyFacts["IterationStatement"] = 256] = "IterationStatement"; + HierarchyFacts[HierarchyFacts["IterationStatementBlock"] = 512] = "IterationStatementBlock"; + HierarchyFacts[HierarchyFacts["ForStatement"] = 1024] = "ForStatement"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 2048] = "ForInOrForOfStatement"; + HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 4096] = "ConstructorWithCapturedSuper"; + HierarchyFacts[HierarchyFacts["ComputedPropertyName"] = 8192] = "ComputedPropertyName"; + // NOTE: do not add more ancestor flags without also updating AncestorFactsMask below. + // + // Ancestor masks + // + HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 16383] = "AncestorFactsMask"; + // We are always in *some* kind of block scope, but only specific block-scope containers are + // top-level or Blocks. + HierarchyFacts[HierarchyFacts["BlockScopeIncludes"] = 0] = "BlockScopeIncludes"; + HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 4032] = "BlockScopeExcludes"; + // A source file is a top-level block scope. + HierarchyFacts[HierarchyFacts["SourceFileIncludes"] = 64] = "SourceFileIncludes"; + HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 3968] = "SourceFileExcludes"; + // Functions, methods, and accessors are both new lexical scopes and new block scopes. + HierarchyFacts[HierarchyFacts["FunctionIncludes"] = 65] = "FunctionIncludes"; + HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 16286] = "FunctionExcludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyIncludes"] = 69] = "AsyncFunctionBodyIncludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 16278] = "AsyncFunctionBodyExcludes"; + // Arrow functions are lexically scoped to their container, but are new block scopes. + HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 66] = "ArrowFunctionIncludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 16256] = "ArrowFunctionExcludes"; + // Constructors are both new lexical scopes and new block scopes. Constructors are also + // always considered non-static members of a class. + HierarchyFacts[HierarchyFacts["ConstructorIncludes"] = 73] = "ConstructorIncludes"; + HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 16278] = "ConstructorExcludes"; + // 'do' and 'while' statements are not block scopes. We track that the subtree is contained + // within an IterationStatement to indicate whether the embedded statement is an + // IterationStatementBlock. + HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 256] = "DoOrWhileStatementIncludes"; + HierarchyFacts[HierarchyFacts["DoOrWhileStatementExcludes"] = 0] = "DoOrWhileStatementExcludes"; + // 'for' statements are new block scopes and have special handling for 'let' declarations. + HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 1280] = "ForStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 3008] = "ForStatementExcludes"; + // 'for-in' and 'for-of' statements are new block scopes and have special handling for + // 'let' declarations. + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 2304] = "ForInOrForOfStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 1984] = "ForInOrForOfStatementExcludes"; + // Blocks (other than function bodies) are new block scopes. + HierarchyFacts[HierarchyFacts["BlockIncludes"] = 128] = "BlockIncludes"; + HierarchyFacts[HierarchyFacts["BlockExcludes"] = 3904] = "BlockExcludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockIncludes"] = 512] = "IterationStatementBlockIncludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 4032] = "IterationStatementBlockExcludes"; + // Computed property names track subtree flags differently than their containing members. + HierarchyFacts[HierarchyFacts["ComputedPropertyNameIncludes"] = 8192] = "ComputedPropertyNameIncludes"; + HierarchyFacts[HierarchyFacts["ComputedPropertyNameExcludes"] = 0] = "ComputedPropertyNameExcludes"; + // + // Subtree facts + // + HierarchyFacts[HierarchyFacts["NewTarget"] = 16384] = "NewTarget"; + HierarchyFacts[HierarchyFacts["NewTargetInComputedPropertyName"] = 32768] = "NewTargetInComputedPropertyName"; + // + // Subtree masks + // + HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -16384] = "SubtreeFactsMask"; + HierarchyFacts[HierarchyFacts["PropagateNewTargetMask"] = 49152] = "PropagateNewTargetMask"; + })(HierarchyFacts || (HierarchyFacts = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -49308,15 +49822,7 @@ var ts; context.onSubstituteNode = onSubstituteNode; var currentSourceFile; var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - var isInConstructorWithCapturedSuper; + var hierarchyFacts; /** * Used to track if we are emitting body of the converted loop */ @@ -49334,185 +49840,116 @@ var ts; } currentSourceFile = node; currentText = node.text; - var visited = saveStateAndInvoke(node, visitSourceFile); + var visited = visitSourceFile(node); ts.addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined; currentText = undefined; + hierarchyFacts = 0 /* None */; return visited; } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); + /** + * Sets the `HierarchyFacts` for this node prior to visiting this node's subtree, returning the facts set prior to modification. + * @param excludeFacts The existing `HierarchyFacts` to reset before visiting the subtree. + * @param includeFacts The new `HierarchyFacts` to set before visiting the subtree. + **/ + function enterSubtree(excludeFacts, includeFacts) { + var ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383 /* AncestorFactsMask */; + return ancestorFacts; } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - // don't treat content of nodes that start new lexical environment as part of converted loop copy or constructor body - isInConstructorWithCapturedSuper = false; - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 185 /* ArrowFunction */) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 131072 /* AsyncFunctionBody */)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - // keep track of the enclosing variable statement when in the context of - // variable statements, variable declarations, binding elements, and binding - // patterns. - switch (currentNode.kind) { - case 205 /* VariableStatement */: - enclosingVariableStatement = currentNode; - break; - case 224 /* VariableDeclarationList */: - case 223 /* VariableDeclaration */: - case 174 /* BindingElement */: - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function returnCapturedThis(node) { - return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + /** + * Restores the `HierarchyFacts` for this node's ancestor after visiting this node's + * subtree, propagating specific facts from the subtree. + * @param ancestorFacts The `HierarchyFacts` of the ancestor to restore after visiting the subtree. + * @param excludeFacts The existing `HierarchyFacts` of the subtree that should not be propagated. + * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. + **/ + function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 /* SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 216 /* ReturnStatement */ && !node.expression; + return hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ + && node.kind === 217 /* ReturnStatement */ + && !node.expression; } - function shouldCheckNode(node) { - return (node.transformFlags & 64 /* ES2015 */) !== 0 || - node.kind === 219 /* LabeledStatement */ || - (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); + function shouldVisitNode(node) { + return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 + || convertedLoopState !== undefined + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && ts.isStatement(node)) + || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); } - function visitorWorker(node) { - if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { - return returnCapturedThis(node); - } - else if (shouldCheckNode(node)) { + function visitor(node) { + if (shouldVisitNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128 /* ContainsES2015 */ || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { - // we want to dive in this branch either if node has children with ES2015 specific syntax - // or we are inside constructor that captures result of the super call so all returns without expression should be - // rewritten. Note: we skip expressions since returns should never appear there - return ts.visitEachChild(node, visitor, context); - } else { return node; } } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function functionBodyVisitor(node) { + if (shouldVisitNode(node)) { + return visitBlock(node, /*isFunctionBody*/ true); } - else { - result = visitNodesInConvertedLoop(node); - } - return result; + return node; } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 216 /* ReturnStatement */: - node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; - return visitReturnStatement(node); - case 205 /* VariableStatement */: - return visitVariableStatement(node); - case 218 /* SwitchStatement */: - return visitSwitchStatement(node); - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: - return visitBreakOrContinueStatement(node); - case 98 /* ThisKeyword */: - return visitThisKeyword(node); - case 70 /* Identifier */: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); + function callExpressionVisitor(node) { + if (node.kind === 96 /* SuperKeyword */) { + return visitSuperKeyword(/*isExpressionOfCall*/ true); } + return visitor(node); } function visitJavaScript(node) { switch (node.kind) { case 114 /* StaticKeyword */: return undefined; // elide static keyword - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return visitClassDeclaration(node); case 197 /* ClassExpression */: return visitClassExpression(node); case 144 /* Parameter */: return visitParameter(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); case 185 /* ArrowFunction */: return visitArrowFunction(node); case 184 /* FunctionExpression */: return visitFunctionExpression(node); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return visitVariableDeclaration(node); case 70 /* Identifier */: return visitIdentifier(node); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 219 /* LabeledStatement */: + case 219 /* SwitchStatement */: + return visitSwitchStatement(node); + case 233 /* CaseBlock */: + return visitCaseBlock(node); + case 205 /* Block */: + return visitBlock(node, /*isFunctionBody*/ false); + case 216 /* BreakStatement */: + case 215 /* ContinueStatement */: + return visitBreakOrContinueStatement(node); + case 220 /* LabeledStatement */: return visitLabeledStatement(node); - case 209 /* DoStatement */: - return visitDoStatement(node); - case 210 /* WhileStatement */: - return visitWhileStatement(node); - case 211 /* ForStatement */: - return visitForStatement(node); - case 212 /* ForInStatement */: - return visitForInStatement(node); - case 213 /* ForOfStatement */: - return visitForOfStatement(node); - case 207 /* ExpressionStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); + case 212 /* ForStatement */: + return visitForStatement(node, /*outermostLabeledStatement*/ undefined); + case 213 /* ForInStatement */: + return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); + case 214 /* ForOfStatement */: + return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); + case 208 /* ExpressionStatement */: return visitExpressionStatement(node); case 176 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return visitCatchClause(node); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); + case 142 /* ComputedPropertyName */: + return visitComputedPropertyName(node); case 175 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); case 179 /* CallExpression */: @@ -49537,54 +49974,82 @@ var ts; case 196 /* SpreadElement */: return visitSpreadElement(node); case 96 /* SuperKeyword */: - return visitSuperKeyword(); - case 195 /* YieldExpression */: - // `yield` will be handled by a generators transform. - return ts.visitEachChild(node, visitor, context); + return visitSuperKeyword(/*isExpressionOfCall*/ false); + case 98 /* ThisKeyword */: + return visitThisKeyword(node); + case 202 /* MetaProperty */: + return visitMetaProperty(node); case 149 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 205 /* VariableStatement */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + return visitAccessorDeclaration(node); + case 206 /* VariableStatement */: return visitVariableStatement(node); + case 217 /* ReturnStatement */: + return visitReturnStatement(node); default: - ts.Debug.failBadSyntaxKind(node); return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { + var ancestorFacts = enterSubtree(3968 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); var statements = []; startLexicalEnvironment(); var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ false, visitor); addCaptureThisForNodeIfNeeded(statements, node); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); } function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; + if (convertedLoopState !== undefined) { + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + // for switch statement allow only non-labeled break + convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitCaseBlock(node) { + var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8 /* Return */; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8 /* Return */; + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + node = returnCapturedThis(node); + } + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 185 /* ArrowFunction */) { - // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. - convertedLoopState.containsLexicalThis = true; - return node; + if (convertedLoopState) { + if (hierarchyFacts & 2 /* ArrowFunction */) { + // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword. + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + return node; } function visitIdentifier(node) { if (!convertedLoopState) { @@ -49604,13 +50069,13 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 215 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 216 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 215 /* BreakStatement */) { + if (node.kind === 216 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -49621,7 +50086,7 @@ var ts; } } else { - if (node.kind === 215 /* BreakStatement */) { + if (node.kind === 216 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -49813,6 +50278,9 @@ var ts; * @param extendsClauseElement The expression for the class `extends` clause. */ function addConstructor(statements, node, extendsClauseElement) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16278 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = ts.createFunctionDeclaration( @@ -49826,6 +50294,8 @@ var ts; ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); } statements.push(constructorFunction); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; } /** * Transforms the parameters of the constructor declaration of a class. @@ -49871,26 +50341,31 @@ var ts; addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + // determine whether the class is known syntactically to be a derived class (e.g. a + // class that extends a value that is not syntactically known to be `null`). + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94 /* NullKeyword */; + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { - isInConstructorWithCapturedSuper = superCaptureStatus === 1 /* ReplaceSuperCapture */; - return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); - }); - ts.addRange(statements, body); + if (superCaptureStatus === 1 /* ReplaceSuperCapture */) { + hierarchyFacts |= 4096 /* ConstructorWithCapturedSuper */; + } + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset)); } // Return `_this` unless we're sure enough that it would be pointless to add a return statement. // If there's a constructor that we can tell returns in enough places, then we *do not* want to add a return. - if (extendsClauseElement + if (isDerivedClass && superCaptureStatus !== 2 /* ReplaceWithReturn */ && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createIdentifier("_this"))); } ts.addRange(statements, endLexicalEnvironment()); + if (constructor) { + prependCaptureNewTargetIfNeeded(statements, constructor, /*copyOnWrite*/ false); + } var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ constructor ? constructor.body.statements : node.members), /*location*/ constructor ? constructor.body : node, @@ -49907,17 +50382,17 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 216 /* ReturnStatement */) { + if (statement.kind === 217 /* ReturnStatement */) { return true; } - else if (statement.kind === 208 /* IfStatement */) { + else if (statement.kind === 209 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 204 /* Block */) { + else if (statement.kind === 205 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -49930,9 +50405,9 @@ var ts; * * @returns The new statement offset into the `statements` array. */ - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, isDerivedClass, hasSynthesizedSuper, statementOffset) { // If this isn't a derived class, just capture 'this' for arrow functions if necessary. - if (!hasExtendsClause) { + if (!isDerivedClass) { if (ctor) { addCaptureThisForNodeIfNeeded(statements, ctor); } @@ -49975,9 +50450,8 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + if (firstStatement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } // Return the result if we have an immediate super() call on the last statement, @@ -49996,18 +50470,18 @@ var ts; return 2 /* ReplaceWithReturn */; } // Perform the capture. - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); // If we're actually replacing the original statement, we need to signal this to the caller. if (superCallExpression) { return 1 /* ReplaceSuperCapture */; } return 0 /* NoReplacement */; } + function createActualThis() { + return ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */); + } function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); + return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createIdentifier("_super"), ts.createNull()), ts.createFunctionApply(ts.createIdentifier("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis()); } /** * Visits a parameter declaration. @@ -50202,6 +50676,46 @@ var ts; ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } + function prependCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { + if (hierarchyFacts & 16384 /* NewTarget */) { + var newTarget = void 0; + switch (node.kind) { + case 185 /* ArrowFunction */: + return statements; + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + // Methods and accessors cannot be constructors, so 'new.target' will + // always return 'undefined'. + newTarget = ts.createVoidZero(); + break; + case 150 /* Constructor */: + // Class constructors can only be called with `new`, so `this.constructor` + // should be relatively safe to use. + newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); + break; + case 226 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + // Functions can be called or constructed, and may have a `this` due to + // being a member or when calling an imported function via `other_1.f()`. + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 92 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + var captureNewTargetStatement = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_newTarget", + /*type*/ undefined, newTarget) + ])); + if (copyOnWrite) { + return [captureNewTargetStatement].concat(statements); + } + statements.unshift(captureNewTargetStatement); + } + return statements; + } /** * Adds statements to the class body function for a class to define the members of the * class. @@ -50213,17 +50727,17 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 203 /* SemicolonClassElement */: + case 204 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; case 149 /* MethodDeclaration */: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case 151 /* GetAccessor */: case 152 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; case 150 /* Constructor */: @@ -50249,11 +50763,12 @@ var ts; * @param receiver The receiver for the member. * @param member The MethodDeclaration node. */ - function transformClassMethodDeclarationToStatement(receiver, member) { + function transformClassMethodDeclarationToStatement(receiver, member, container) { + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); - var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined); + var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), @@ -50264,6 +50779,7 @@ var ts; // No source map should be emitted for this statement to align with the // old emitter. ts.setEmitFlags(statement, 48 /* NoSourceMap */); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return statement; } /** @@ -50272,8 +50788,8 @@ var ts; * @param receiver The receiver for the member. * @param accessors The set of related get/set accessors. */ - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, /*startsOnNewLine*/ false), + function transformAccessorsToStatement(receiver, accessors, container) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false), /*location*/ ts.getSourceMapRange(accessors.firstAccessor)); // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the @@ -50287,8 +50803,9 @@ var ts; * * @param receiver The receiver for the member. */ - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); // To align with source maps in the old emitter, the receiver and property name // arguments are both mapped contiguously to the accessor name. var target = ts.getMutableClone(receiver); @@ -50299,7 +50816,7 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); + var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -50307,7 +50824,7 @@ var ts; properties.push(getter); } if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); + var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); var setter = ts.createPropertyAssignment("set", setterFunction); @@ -50324,6 +50841,7 @@ var ts; if (startsOnNewLine) { call.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return call; } /** @@ -50335,6 +50853,9 @@ var ts; if (node.transformFlags & 16384 /* ContainsLexicalThis */) { enableSubstitutionsForCapturedThis(); } + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16256 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */); var func = ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -50343,6 +50864,8 @@ var ts; /*type*/ undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8 /* CapturesThis */); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; return func; } /** @@ -50351,12 +50874,24 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, - /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.transformFlags & 64 /* ES2015 */ + var ancestorFacts = ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */ + ? enterSubtree(16278 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) + : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 /* ES2015 */ ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 /* NewTarget */ + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionExpression(node, + /*modifiers*/ undefined, name, + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body); } /** * Visits a FunctionDeclaration node. @@ -50364,12 +50899,22 @@ var ts; * @param node a FunctionDeclaration node. */ function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, - /*decorators*/ undefined, node.modifiers, node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.transformFlags & 64 /* ES2015 */ + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 /* ES2015 */ ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 /* NewTarget */ + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionDeclaration(node, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body); } /** * Transforms a function-like node into a FunctionExpression. @@ -50378,18 +50923,24 @@ var ts; * @param location The source-map location for the new FunctionExpression. * @param name The name of the new FunctionExpression. */ - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 185 /* ArrowFunction */) { - enclosingNonArrowFunction = node; + function transformFunctionLikeToExpression(node, location, name, container) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32 /* Static */) + ? enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) + : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */)) { + name = ts.getGeneratedNameForNode(node); } - var expression = ts.setOriginalNode(ts.createFunctionExpression( + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.setOriginalNode(ts.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, saveStateAndInvoke(node, transformFunctionBody), location), + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body, location), /*original*/ node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; } /** * Transforms the body of a function-like node. @@ -50451,6 +51002,7 @@ var ts; } var lexicalEnvironment = context.endLexicalEnvironment(); ts.addRange(statements, lexicalEnvironment); + prependCaptureNewTargetIfNeeded(statements, node, /*copyOnWrite*/ false); // If we added any final generated statements, this must be a multi-line block if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; @@ -50465,6 +51017,23 @@ var ts; ts.setOriginalNode(block, node.body); return block; } + function visitFunctionBodyDownLevel(node) { + var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); + return ts.updateBlock(updated, ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, /*copyOnWrite*/ true), + /*location*/ updated.statements)); + } + function visitBlock(node, isFunctionBody) { + if (isFunctionBody) { + // A function body is not a block scope. + return ts.visitEachChild(node, visitor, context); + } + var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */ + ? enterSubtree(4032 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */) + : enterSubtree(3904 /* BlockExcludes */, 128 /* BlockIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } /** * Visits an ExpressionStatement that contains a destructuring assignment. * @@ -50511,9 +51080,12 @@ var ts; if (ts.isDestructuringAssignment(node)) { return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, needsDestructuringValue); } + return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) == 0) { + var ancestorFacts = enterSubtree(0 /* None */, ts.hasModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + var updated; + if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0) { // we are inside a converted loop - hoist variable declarations var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -50531,14 +51103,18 @@ var ts; } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); }), node); + updated = ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); }), node); } else { // none of declarations has initializer - the entire variable statement can be deleted - return undefined; + updated = undefined; } } - return ts.visitEachChild(node, visitor, context); + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } /** * Visits a VariableDeclarationList that is block scoped (e.g. `let` or `const`). @@ -50546,25 +51122,28 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); + if (node.transformFlags & 64 /* ES2015 */) { + if (node.flags & 3 /* BlockScoped */) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); + ts.setOriginalNode(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 /* ContainsBindingPattern */ + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + // If the first or last declaration is a binding pattern, we need to modify + // the source map range for the declaration list. + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 /* ContainsBindingPattern */ - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - // If the first or last declaration is a binding pattern, we need to modify - // the source map range for the declaration list. - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; + return ts.visitEachChild(node, visitor, context); } /** * Gets a value indicating whether we should emit an explicit initializer for a variable @@ -50615,18 +51194,16 @@ var ts; var flags = resolver.getNodeCheckFlags(node); var isCapturedInFunction = flags & 131072 /* CapturedBlockScopedBinding */; var isDeclaredInLoop = flags & 262144 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + var emittedAsTopLevel = (hierarchyFacts & 64 /* TopLevel */) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); + && (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 212 /* ForInStatement */ - && enclosingBlockScopeContainer.kind !== 213 /* ForOfStatement */ + && (hierarchyFacts & 2048 /* ForInOrForOfStatement */) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, /*lookInLabeledStatements*/ false))); + && (hierarchyFacts & (1024 /* ForStatement */ | 2048 /* ForInOrForOfStatement */)) === 0)); return emitExplicitInitializer; } /** @@ -50655,55 +51232,52 @@ var ts; * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { - // If we are here it is because the name contains a binding pattern. + var ancestorFacts = enterSubtree(32 /* ExportedVariableStatement */, 0 /* None */); + var updated; if (ts.isBindingPattern(node.name)) { - var hoistTempVariables = enclosingVariableStatement - && ts.hasModifier(enclosingVariableStatement, 1 /* Export */); - return ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, - /*value*/ undefined, hoistTempVariables); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, + /*value*/ undefined, (ancestorFacts & 32 /* ExportedVariableStatement */) !== 0); } else { - result = ts.visitEachChild(node, visitor, context); + updated = ts.visitEachChild(node, visitor, context); } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } + function recordLabel(node) { + convertedLoopState.labels[node.label.text] = node.label.text; + } + function resetLabel(node) { + convertedLoopState.labels[node.label.text] = undefined; + } + function visitLabeledStatement(node) { + if (convertedLoopState && !convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); } - return result; + var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(statement) + ? visitIterationStatement(statement, /*outermostLabeledStatement*/ node) + : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { + var ancestorFacts = enterSubtree(excludeFacts, includeFacts); + var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitDoOrWhileStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 256 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement); } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(3008 /* ForStatementExcludes */, 1280 /* ForStatementIncludes */, node, outermostLabeledStatement); } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForInStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } - /** - * Visits a ForOfStatement and converts it into a compatible ForStatement. - * - * @param node A ForOfStatement. - */ - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function visitForOfStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, convertForOfToFor); } - function convertForOfToFor(node, convertedLoopBodyStatements) { + function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: // // for (let v of expr) { } @@ -50815,7 +51389,20 @@ var ts; /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); - return forStatement; + return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); + } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 212 /* ForStatement */: + return visitForStatement(node, outermostLabeledStatement); + case 213 /* ForInStatement */: + return visitForInStatement(node, outermostLabeledStatement); + case 214 /* ForOfStatement */: + return visitForOfStatement(node, outermostLabeledStatement); + } } /** * Visits an ObjectLiteralExpression with computed propety names. @@ -50829,31 +51416,40 @@ var ts; // Find the first computed property. // Everything until that point can be emitted as part of the initial object literal. var numInitialProperties = numProperties; + var numInitialPropertiesWithoutYield = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 /* ContainsYield */ - || property.name.kind === 142 /* ComputedPropertyName */) { + if ((property.transformFlags & 16777216 /* ContainsYield */ && hierarchyFacts & 4 /* AsyncFunctionBody */) + && i < numInitialPropertiesWithoutYield) { + numInitialPropertiesWithoutYield = i; + } + if (property.name.kind === 142 /* ComputedPropertyName */) { numInitialProperties = i; break; } } - ts.Debug.assert(numInitialProperties !== numProperties); - // For computed properties, we need to create a unique handle to the object - // literal so we can modify it without risking internal assignments tainting the object. - var temp = ts.createTempVariable(hoistVariableDeclaration); - // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), - /*location*/ undefined, node.multiLine), 32768 /* Indented */)); - if (node.multiLine) { - assignment.startsOnNewLine = true; + if (numInitialProperties !== numProperties) { + if (numInitialPropertiesWithoutYield < numInitialProperties) { + numInitialProperties = numInitialPropertiesWithoutYield; + } + // For computed properties, we need to create a unique handle to the object + // literal so we can modify it without risking internal assignments tainting the object. + var temp = ts.createTempVariable(hoistVariableDeclaration); + // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), + /*location*/ undefined, node.multiLine), 32768 /* Indented */)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + // We need to clone the temporary identifier so that we can write it on a + // new line + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - // We need to clone the temporary identifier so that we can write it on a - // new line - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); + return ts.visitEachChild(node, visitor, context); } function shouldConvertIterationStatementBody(node) { return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; @@ -50880,7 +51476,7 @@ var ts; } } } - function convertIterationStatementBodyIfNecessary(node, convert) { + function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) { if (!shouldConvertIterationStatementBody(node)) { var saveAllowedNonLabeledJumps = void 0; if (convertedLoopState) { @@ -50889,7 +51485,9 @@ var ts; saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; } - var result = convert ? convert(node, /*convertedLoopBodyStatements*/ undefined) : ts.visitEachChild(node, visitor, context); + var result = convert + ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined) + : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); if (convertedLoopState) { convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } @@ -50898,11 +51496,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 224 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 225 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -50939,7 +51537,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -50951,11 +51549,13 @@ var ts; ts.addRange(statements_4, lexicalEnvironment); loopBody = ts.createBlock(statements_4, /*location*/ undefined, /*multiline*/ true); } - if (!ts.isBlock(loopBody)) { + if (ts.isBlock(loopBody)) { + loopBody.multiLine = true; + } + else { loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 131072 /* AsyncFunctionBody */) !== 0 + var isAsyncBlockContainingAwait = hierarchyFacts & 4 /* AsyncFunctionBody */ && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -51038,25 +51638,24 @@ var ts; var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); var loop; if (convert) { - loop = convert(node, convertedLoopBodyStatements); + loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); } else { - loop = ts.getMutableClone(node); + var clone_4 = ts.getMutableClone(node); // clean statement part - loop.statement = undefined; + clone_4.statement = undefined; // visit childnodes to transform initializer/condition/incrementor parts - loop = ts.visitEachChild(loop, visitor, context); + clone_4 = ts.visitEachChild(clone_4, visitor, context); // set loop statement - loop.statement = ts.createBlock(convertedLoopBodyStatements, + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, /*location*/ undefined, /*multiline*/ true); // reset and re-aggregate the transform flags - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); + clone_4.transformFlags = 0; + ts.aggregateTransformFlags(clone_4); + loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } - statements.push(currentParent.kind === 219 /* LabeledStatement */ - ? ts.createLabel(currentParent.label, loop) - : loop); + statements.push(loop); return statements; } function copyOutParameter(outParam, copyDirection) { @@ -51186,18 +51785,18 @@ var ts; case 152 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 257 /* PropertyAssignment */: + case 149 /* MethodDeclaration */: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); + break; + case 258 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 149 /* MethodDeclaration */: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); - break; default: ts.Debug.failBadSyntaxKind(node); break; @@ -51241,22 +51840,32 @@ var ts; * @param method The MethodDeclaration node. * @param receiver The receiver for the assignment. */ - function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined), + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined, container), /*location*/ method); if (startsOnNewLine) { expression.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return expression; } function visitCatchClause(node) { - ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); - var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); - var list = ts.createVariableDeclarationList(vars, /*location*/ node.variableDeclaration, /*flags*/ node.variableDeclaration.flags); - var destructure = ts.createVariableStatement(undefined, list); - return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var updated; + if (ts.isBindingPattern(node.variableDeclaration.name)) { + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); + var list = ts.createVariableDeclarationList(vars, /*location*/ node.variableDeclaration, /*flags*/ node.variableDeclaration.flags); + var destructure = ts.createVariableStatement(undefined, list); + updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); @@ -51273,11 +51882,26 @@ var ts; // Methods on classes are handled in visitClassDeclaration/visitClassExpression. // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined); + var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); return ts.createPropertyAssignment(node.name, functionExpression, /*location*/ node); } + /** + * Visits an AccessorDeclaration of an ObjectLiteralExpression. + * + * @param node An AccessorDeclaration node. + */ + function visitAccessorDeclaration(node) { + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return updated; + } /** * Visits a ShorthandPropertyAssignment and transforms it into a PropertyAssignment. * @@ -51287,6 +51911,12 @@ var ts; return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), /*location*/ node); } + function visitComputedPropertyName(node) { + var ancestorFacts = enterSubtree(0 /* ComputedPropertyNameExcludes */, 8192 /* ComputedPropertyNameIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 32768 /* NewTargetInComputedPropertyName */ : 0 /* None */); + return updated; + } /** * Visits a YieldExpression node. * @@ -51302,8 +51932,11 @@ var ts; * @param node An ArrayLiteralExpression node. */ function visitArrayLiteralExpression(node) { - // We are here because we contain a SpreadElementExpression. - return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + if (node.transformFlags & 64 /* ES2015 */) { + // We are here because we contain a SpreadElementExpression. + return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + } + return ts.visitEachChild(node, visitor, context); } /** * Visits a CallExpression that contains either a spread element or `super`. @@ -51311,7 +51944,11 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + if (node.transformFlags & 64 /* ES2015 */) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + } + return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), + /*typeArguments*/ undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitImmediateSuperCallInBody(node) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false); @@ -51338,7 +51975,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -51350,18 +51987,18 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } if (node.expression.kind === 96 /* SuperKeyword */) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis + resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createIdentifier("_this"), initializer) : initializer; } - return resultingCall; + return ts.setOriginalNode(resultingCall, node); } /** * Visits a NewExpression that contains a spread element. @@ -51369,16 +52006,18 @@ var ts; * @param node A NewExpression node. */ function visitNewExpression(node) { - // We are here because we contain a SpreadElementExpression. - ts.Debug.assert((node.transformFlags & 524288 /* ContainsSpread */) !== 0); - // [source] - // new C(...a) - // - // [output] - // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), - /*typeArguments*/ undefined, []); + if (node.transformFlags & 524288 /* ContainsSpread */) { + // We are here because we contain a SpreadElementExpression. + // [source] + // new C(...a) + // + // [output] + // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + /*typeArguments*/ undefined, []); + } + return ts.visitEachChild(node, visitor, context); } /** * Transforms an array of Expression nodes that contains a SpreadExpression. @@ -51581,27 +52220,40 @@ var ts; /** * Visits the `super` keyword */ - function visitSuperKeyword() { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) - && currentParent.kind !== 179 /* CallExpression */ + function visitSuperKeyword(isExpressionOfCall) { + return hierarchyFacts & 8 /* NonStaticClassElement */ + && !isExpressionOfCall ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } + function visitMetaProperty(node) { + if (node.keywordToken === 93 /* NewKeyword */ && node.name.text === "target") { + if (hierarchyFacts & 8192 /* ComputedPropertyName */) { + hierarchyFacts |= 32768 /* NewTargetInComputedPropertyName */; + } + else { + hierarchyFacts |= 16384 /* NewTarget */; + } + return ts.createIdentifier("_newTarget"); + } + return node; + } /** * Called by the printer just before a node is printed. * * @param node The node to be printed. */ function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - enclosingFunction = node; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ + ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ + : 65 /* FunctionIncludes */); + previousOnEmitNode(emitContext, node, emitCallback); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return; } previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; } /** * Enables a more costly code path for substitutions when we determine a source file @@ -51627,7 +52279,7 @@ var ts; context.enableEmitNotification(152 /* SetAccessor */); context.enableEmitNotification(185 /* ArrowFunction */); context.enableEmitNotification(184 /* FunctionExpression */); - context.enableEmitNotification(225 /* FunctionDeclaration */); + context.enableEmitNotification(226 /* FunctionDeclaration */); } } /** @@ -51670,9 +52322,9 @@ var ts; var parent = node.parent; switch (parent.kind) { case 174 /* BindingElement */: - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 223 /* VariableDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 224 /* VariableDeclaration */: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -51713,8 +52365,7 @@ var ts; */ function substituteThisKeyword(node) { if (enabledSubstitutions & 1 /* CapturedThis */ - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 8 /* CapturesThis */) { + && hierarchyFacts & 16 /* CapturesThis */) { return ts.createIdentifier("_this", /*location*/ node); } return node; @@ -51731,7 +52382,7 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 207 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 208 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; @@ -51763,7 +52414,7 @@ var ts; name: "typescript:extends", scoped: false, priority: 0, - text: "\n var __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 };" + text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; })(ts || (ts = {})); /// @@ -52036,13 +52687,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 209 /* DoStatement */: + case 210 /* DoStatement */: return visitDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return visitWhileStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return visitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -52055,24 +52706,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: return visitFunctionExpression(node); case 151 /* GetAccessor */: case 152 /* SetAccessor */: return visitAccessorDeclaration(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return visitVariableStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return visitForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return visitForInStatement(node); - case 215 /* BreakStatement */: + case 216 /* BreakStatement */: return visitBreakStatement(node); - case 214 /* ContinueStatement */: + case 215 /* ContinueStatement */: return visitContinueStatement(node); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -52120,7 +52771,7 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: return visitFunctionExpression(node); @@ -52405,10 +53056,10 @@ var ts; // _a = a(); // .yield resumeLabel // _a + %sent% + c() - var clone_4 = ts.getMutableClone(node); - clone_4.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_4.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_4; + var clone_5 = ts.getMutableClone(node); + clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_5; } return ts.visitEachChild(node, visitor, context); } @@ -52553,7 +53204,7 @@ var ts; emitYield(expression, /*location*/ node); } markLabel(resumeLabel); - return createGeneratorResume(); + return createGeneratorResume(/*location*/ node); } /** * Visits an ArrayLiteralExpression that contains a YieldExpression. @@ -52667,10 +53318,10 @@ var ts; // .yield resumeLabel // .mark resumeLabel // a = _a[%sent%] - var clone_5 = ts.getMutableClone(node); - clone_5.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_5.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -52737,35 +53388,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 204 /* Block */: + case 205 /* Block */: return transformAndEmitBlock(node); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return transformAndEmitIfStatement(node); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return transformAndEmitDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return transformAndEmitForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 214 /* ContinueStatement */: + case 215 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 215 /* BreakStatement */: + case 216 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return transformAndEmitWithStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); @@ -52785,7 +53436,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - hoistVariableDeclaration(variable.name); + var name_37 = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name_37, variable.name); + hoistVariableDeclaration(name_37); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -52828,7 +53481,7 @@ var ts; if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) { var endLabel = defineLabel(); var elseLabel = node.elseStatement ? defineLabel() : undefined; - emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression)); + emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), /*location*/ node.expression); transformAndEmitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { emitBreak(endLabel); @@ -53185,7 +53838,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 254 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 255 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -53198,7 +53851,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 253 /* CaseClause */) { + if (clause.kind === 254 /* CaseClause */) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -53359,12 +54012,12 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_37) { - var clone_6 = ts.getMutableClone(name_37); - ts.setSourceMapRange(clone_6, node); - ts.setCommentRange(clone_6, node); - return clone_6; + var name_38 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_38) { + var clone_7 = ts.getMutableClone(name_38); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); + return clone_7; } } } @@ -54249,9 +54902,9 @@ var ts; function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)]), operationLocation)); + : [createInstruction(2 /* Return */)]), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -54261,10 +54914,10 @@ var ts; */ function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation)); + ]), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -54274,10 +54927,10 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -54287,10 +54940,10 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -54300,9 +54953,9 @@ var ts; */ function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)]), operationLocation)); + : [createInstruction(4 /* Yield */)]), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -54312,10 +54965,10 @@ var ts; */ function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(5 /* YieldStar */), expression - ]), operationLocation)); + ]), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -54411,10 +55064,22 @@ var ts; * @param context Context and state information for the transformation. */ function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + // enable emit notification only if using --jsx preserve + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1 /* Preserve */) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(249 /* JsxOpeningElement */); + context.enableEmitNotification(250 /* JsxClosingElement */); + context.enableEmitNotification(248 /* JsxSelfClosingElement */); + noSubstitution = []; + } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; context.enableSubstitution(177 /* PropertyAccessExpression */); - context.enableSubstitution(257 /* PropertyAssignment */); + context.enableSubstitution(258 /* PropertyAssignment */); return transformSourceFile; /** * Transforms an ES5 source file to ES3. @@ -54424,6 +55089,22 @@ var ts; function transformSourceFile(node) { return node; } + /** + * Called by the printer just before a node is printed. + * + * @param node The node to be printed. + */ + function onEmitNode(emitContext, node, emitCallback) { + switch (node.kind) { + case 249 /* JsxOpeningElement */: + case 250 /* JsxClosingElement */: + case 248 /* JsxSelfClosingElement */: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(emitContext, node, emitCallback); + } /** * Hooks node substitutions. * @@ -54431,6 +55112,9 @@ var ts; * @param node The node to substitute. */ function onSubstituteNode(emitContext, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(emitContext, node); + } node = previousOnSubstituteNode(emitContext, node); if (ts.isPropertyAccessExpression(node)) { return substitutePropertyAccessExpression(node); @@ -54490,7 +55174,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(261 /* SourceFile */); + context.enableEmitNotification(262 /* SourceFile */); context.enableSubstitution(70 /* Identifier */); var currentSourceFile; return transformSourceFile; @@ -54517,10 +55201,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -54595,7 +55279,7 @@ var ts; context.enableSubstitution(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(261 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableEmitNotification(262 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = ts.createMap(); // The export function associated with a source file. @@ -54815,7 +55499,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 241 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 242 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -54840,7 +55524,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 241 /* ExportDeclaration */) { + if (externalImport.kind !== 242 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -54921,19 +55605,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // fall-through - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -54983,15 +55667,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -55169,7 +55853,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 1048576 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 261 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 262 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -55233,7 +55917,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -55289,10 +55973,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238 /* NamedImports */: + case 239 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -55471,43 +56155,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return visitClassDeclaration(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return visitForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return visitForInStatement(node); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return visitForOfStatement(node); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return visitDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return visitWhileStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return visitLabeledStatement(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return visitWithStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return visitSwitchStatement(node); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return visitCaseBlock(node); - case 253 /* CaseClause */: + case 254 /* CaseClause */: return visitCaseClause(node); - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: return visitDefaultClause(node); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return visitTryStatement(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return visitCatchClause(node); - case 204 /* Block */: + case 205 /* Block */: return visitBlock(node); - case 295 /* MergeDeclarationMarker */: + case 296 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 296 /* EndOfDeclarationMarker */: + case 297 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -55735,7 +56419,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 261 /* SourceFile */; + return container !== undefined && container.kind === 262 /* SourceFile */; } else { return false; @@ -55768,7 +56452,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -55941,7 +56625,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 261 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 262 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -55997,8 +56681,8 @@ var ts; context.enableSubstitution(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(258 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(261 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(259 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(262 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -56052,26 +56736,6 @@ var ts; function transformAMDModule(node) { var define = ts.createIdentifier("define"); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); - } - /** - * Transforms a SourceFile into a UMD module. - * - * @param node The SourceFile node. - */ - function transformUMDModule(node) { - var define = ts.createRawExpression(umdHelper); - return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); - } - /** - * Transforms a SourceFile into an AMD or UMD module. - * - * @param node The SourceFile node. - * @param define The expression used to define the module. - * @param moduleName An expression for the module name, if available. - * @param includeNonAmdDependencies A value indicating whether to incldue any non-AMD dependencies. - */ - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { // An AMD define function has the following shape: // // define(id?, dependencies?, factory); @@ -56092,7 +56756,7 @@ var ts; // /// // // we need to add modules without alias names to the end of the dependencies list - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; // Create an updated SourceFile: // // define(moduleName?, ["module1", "module2"], function ... @@ -56122,6 +56786,73 @@ var ts; ], /*location*/ node.statements)); } + /** + * Transforms a SourceFile into a UMD module. + * + * @param node The SourceFile node. + */ + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "factory")], + /*type*/ undefined, ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement( + /*modifiers*/ undefined, [ + ts.createVariableDeclaration("v", + /*type*/ undefined, ts.createCall(ts.createIdentifier("factory"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), + /*typeArguments*/ undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], + /*location*/ undefined, + /*multiLine*/ true)); + // Create an updated SourceFile: + // + // (function (factory) { + // if (typeof module === "object" && typeof module.exports === "object") { + // var v = factory(require, exports); + // if (v !== undefined) module.exports = v; + // } + // else if (typeof define === 'function' && define.amd) { + // define(["require", "exports"], factory); + // } + // })(function ...) + return ts.updateSourceFileNode(node, ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, + /*typeArguments*/ undefined, [ + // Add the module body function argument: + // + // function (require, exports) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ])) + ], + /*location*/ node.statements)); + } /** * Collect the additional asynchronous dependencies for the module. * @@ -56226,23 +56957,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return visitExportDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitExportAssignment(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return visitClassDeclaration(node); - case 295 /* MergeDeclarationMarker */: + case 296 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 296 /* EndOfDeclarationMarker */: + case 297 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: // This visitor does not descend into the tree, as export/import statements @@ -56554,7 +57285,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -56609,10 +57340,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238 /* NamedImports */: + case 239 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -56811,7 +57542,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = ts.createMap(); @@ -56899,7 +57630,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 261 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 262 /* SourceFile */) { return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), /*location*/ node); } @@ -56910,8 +57641,8 @@ var ts; /*location*/ node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_38 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_38), + var name_39 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_39), /*location*/ node); } } @@ -57013,8 +57744,6 @@ var ts; scoped: true, text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" }; - // emit output for the UMD helper function. - var umdHelper = "\n (function (dependencies, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(dependencies, factory);\n }\n })"; })(ts || (ts = {})); /// /// @@ -57521,7 +58250,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 293 /* NotEmittedStatement */ + if (node.kind !== 294 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -57534,7 +58263,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 293 /* NotEmittedStatement */ + if (node.kind !== 294 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -57713,7 +58442,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 293 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 294 /* NotEmittedStatement */; var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; // Emit leading comments if the position is not synthesized and the node @@ -57732,7 +58461,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 224 /* VariableDeclarationList */) { + if (node.kind === 225 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -58045,7 +58774,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 235 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 236 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -58120,10 +58849,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 223 /* VariableDeclaration */) { + if (declaration.kind === 224 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 238 /* NamedImports */ || declaration.kind === 239 /* ImportSpecifier */ || declaration.kind === 236 /* ImportClause */) { + else if (declaration.kind === 239 /* NamedImports */ || declaration.kind === 240 /* ImportSpecifier */ || declaration.kind === 237 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -58141,7 +58870,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 === 235 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 236 /* 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; @@ -58151,12 +58880,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 230 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 231 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 230 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 231 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -58334,7 +59063,7 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 234 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 235 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); @@ -58456,9 +59185,9 @@ var ts; var count = 0; while (true) { count++; - var name_39 = baseName + "_" + count; - if (!(name_39 in currentIdentifiers)) { - return name_39; + var name_40 = baseName + "_" + count; + if (!(name_40 in currentIdentifiers)) { + return name_40; } } } @@ -58505,10 +59234,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 234 /* ImportEqualsDeclaration */ || - (node.parent.kind === 261 /* SourceFile */ && isCurrentFileExternalModule)) { + else if (node.kind === 235 /* ImportEqualsDeclaration */ || + (node.parent.kind === 262 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 262 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -58518,7 +59247,7 @@ var ts; }); } else { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 236 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -58536,23 +59265,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return writeVariableStatement(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return writeClassDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -58560,7 +59289,7 @@ var ts; } function emitModuleElementDeclarationFlags(node) { // If the node is parented in the current source file we need to emit export declare or just export - if (node.parent.kind === 261 /* SourceFile */) { + if (node.parent.kind === 262 /* SourceFile */) { var modifiers = ts.getModifierFlags(node); // If the node is exported if (modifiers & 1 /* Export */) { @@ -58569,7 +59298,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 227 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 228 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -58621,7 +59350,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings.kind === 238 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -58645,7 +59374,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 238 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -58666,13 +59395,13 @@ var ts; // the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered // external modules since they are indistinguishable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' // so compiler will treat them as external modules. - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 231 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 234 /* ImportEqualsDeclaration */) { + if (parent.kind === 235 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 230 /* ModuleDeclaration */) { + else if (parent.kind === 231 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -58742,7 +59471,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 231 /* ModuleBlock */) { + while (node.body && node.body.kind !== 232 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -58842,10 +59571,10 @@ 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 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 154 /* ConstructSignature */: @@ -58859,17 +59588,17 @@ var ts; if (ts.hasModifier(node.parent, 32 /* 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 === 226 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 227 /* 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 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -58907,7 +59636,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 226 /* ClassDeclaration */) { + if (node.parent.parent.kind === 227 /* 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 : @@ -58994,7 +59723,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 !== 223 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 224 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -59022,7 +59751,7 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 224 /* VariableDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59038,7 +59767,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 === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 227 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -59212,13 +59941,13 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 225 /* FunctionDeclaration */) { + if (node.kind === 226 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } else if (node.kind === 149 /* MethodDeclaration */ || node.kind === 150 /* Constructor */) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 225 /* FunctionDeclaration */) { + if (node.kind === 226 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } @@ -59323,7 +60052,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 === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 227 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -59337,7 +60066,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -59420,7 +60149,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 === 226 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 227 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -59433,7 +60162,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 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59509,20 +60238,20 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: - case 230 /* ModuleDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 227 /* InterfaceDeclaration */: - case 226 /* ClassDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: + case 226 /* FunctionDeclaration */: + case 231 /* ModuleDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 228 /* InterfaceDeclaration */: + case 227 /* ClassDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 230 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return emitExportDeclaration(node); case 150 /* Constructor */: case 149 /* MethodDeclaration */: @@ -59538,11 +60267,11 @@ var ts; case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: return emitPropertyDeclaration(node); - case 260 /* EnumMember */: + case 261 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return emitExportAssignment(node); - case 261 /* SourceFile */: + case 262 /* SourceFile */: return emitSourceFile(node); } } @@ -59835,7 +60564,7 @@ var ts; var kind = node.kind; switch (kind) { // Top-level nodes - case 261 /* SourceFile */: + case 262 /* SourceFile */: return emitSourceFile(node); } } @@ -59983,126 +60712,126 @@ var ts; case 174 /* BindingElement */: return emitBindingElement(node); // Misc - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return emitTemplateSpan(node); - case 203 /* SemicolonClassElement */: + case 204 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 204 /* Block */: + case 205 /* Block */: return emitBlock(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return emitVariableStatement(node); - case 206 /* EmptyStatement */: + case 207 /* EmptyStatement */: return emitEmptyStatement(); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return emitExpressionStatement(node); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return emitIfStatement(node); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return emitDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return emitWhileStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return emitForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return emitForInStatement(node); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return emitForOfStatement(node); - case 214 /* ContinueStatement */: + case 215 /* ContinueStatement */: return emitContinueStatement(node); - case 215 /* BreakStatement */: + case 216 /* BreakStatement */: return emitBreakStatement(node); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return emitReturnStatement(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return emitWithStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return emitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return emitLabeledStatement(node); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return emitThrowStatement(node); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return emitTryStatement(node); - case 222 /* DebuggerStatement */: + case 223 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return emitClassDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return emitModuleBlock(node); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return emitCaseBlock(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return emitImportDeclaration(node); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return emitImportClause(node); - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: return emitNamespaceImport(node); - case 238 /* NamedImports */: + case 239 /* NamedImports */: return emitNamedImports(node); - case 239 /* ImportSpecifier */: + case 240 /* ImportSpecifier */: return emitImportSpecifier(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return emitExportAssignment(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return emitExportDeclaration(node); - case 242 /* NamedExports */: + case 243 /* NamedExports */: return emitNamedExports(node); - case 243 /* ExportSpecifier */: + case 244 /* ExportSpecifier */: return emitExportSpecifier(node); - case 244 /* MissingDeclaration */: + case 245 /* MissingDeclaration */: return; // Module references - case 245 /* ExternalModuleReference */: + case 246 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 248 /* JsxOpeningElement */: + case 249 /* JsxOpeningElement */: return emitJsxOpeningElement(node); - case 249 /* JsxClosingElement */: + case 250 /* JsxClosingElement */: return emitJsxClosingElement(node); - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: return emitJsxAttribute(node); - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 253 /* CaseClause */: + case 254 /* CaseClause */: return emitCaseClause(node); - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: return emitDefaultClause(node); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: return emitHeritageClause(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 260 /* EnumMember */: + case 261 /* EnumMember */: return emitEnumMember(node); } // If the node is an expression, try to emit it as an expression with @@ -60191,16 +60920,16 @@ var ts; return emitAsExpression(node); case 201 /* NonNullExpression */: return emitNonNullExpression(node); + case 202 /* MetaProperty */: + return emitMetaProperty(node); // JSX - case 246 /* JsxElement */: + case 247 /* JsxElement */: return emitJsxElement(node); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 297 /* RawExpression */: - return writeLines(node.text); } } // @@ -60693,6 +61422,11 @@ var ts; emitExpression(node.expression); write("!"); } + function emitMetaProperty(node) { + writeToken(node.keywordToken, node.pos); + write("."); + emit(node.name); + } // // Misc // @@ -60741,27 +61475,27 @@ var ts; writeToken(18 /* OpenParenToken */, openParenPos, node); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end, node); - emitEmbeddedStatement(node.thenStatement); + emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { - writeLine(); + writeLineOrSpace(node); writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 208 /* IfStatement */) { + if (node.elseStatement.kind === 209 /* IfStatement */) { write(" "); emit(node.elseStatement); } else { - emitEmbeddedStatement(node.elseStatement); + emitEmbeddedStatement(node, node.elseStatement); } } } function emitDoStatement(node) { write("do"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { write(" "); } else { - writeLine(); + writeLineOrSpace(node); } write("while ("); emitExpression(node.expression); @@ -60771,7 +61505,7 @@ var ts; write("while ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60783,7 +61517,7 @@ var ts; write(";"); emitExpressionWithPrefix(" ", node.incrementor); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60793,7 +61527,7 @@ var ts; write(" in "); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60803,11 +61537,11 @@ var ts; write(" of "); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 224 /* VariableDeclarationList */) { + if (node.kind === 225 /* VariableDeclarationList */) { emit(node); } else { @@ -60834,7 +61568,7 @@ var ts; write("with ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { var openParenPos = writeToken(97 /* SwitchKeyword */, node.pos); @@ -60858,9 +61592,12 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchClause); + if (node.catchClause) { + writeLineOrSpace(node); + emit(node.catchClause); + } if (node.finallyBlock) { - writeLine(); + writeLineOrSpace(node); write("finally "); emit(node.finallyBlock); } @@ -61046,7 +61783,7 @@ var ts; write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 230 /* ModuleDeclaration */) { + while (body.kind === 231 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -61203,6 +61940,9 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); + if (node.dotDotDotToken) { + write("..."); + } emitExpression(node.expression); write("}"); } @@ -61438,8 +62178,8 @@ var ts; write(suffix); } } - function emitEmbeddedStatement(node) { - if (ts.isBlock(node)) { + function emitEmbeddedStatement(parent, node) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* SingleLine */) { write(" "); emit(node); } @@ -61580,6 +62320,14 @@ var ts; write(getClosingBracket(format)); } } + function writeLineOrSpace(node) { + if (ts.getEmitFlags(node) & 1 /* SingleLine */) { + write(" "); + } + else { + writeLine(); + } + } function writeIfAny(nodes, text) { if (nodes && nodes.length > 0) { write(text); @@ -61771,10 +62519,10 @@ var ts; */ function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_40 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_40)) { + var name_41 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_41)) { tempFlags |= flags; - return name_40; + return name_41; } } while (true) { @@ -61782,11 +62530,11 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_41 = count < 26 + var name_42 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_41)) { - return name_41; + if (isUniqueName(name_42)) { + return name_42; } } } @@ -61826,6 +62574,12 @@ var ts; function generateNameForClassExpression() { return makeUniqueName("class"); } + function generateNameForMethodOrAccessor(node) { + if (ts.isIdentifier(node.name)) { + return generateNameForNodeCached(node.name); + } + return makeTempVariableName(0 /* Auto */); + } /** * Generates a unique name from a node. * @@ -61835,18 +62589,22 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 235 /* ImportDeclaration */: - case 241 /* ExportDeclaration */: + case 236 /* ImportDeclaration */: + case 242 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 225 /* FunctionDeclaration */: - case 226 /* ClassDeclaration */: - case 240 /* ExportAssignment */: + case 226 /* FunctionDeclaration */: + case 227 /* ClassDeclaration */: + case 241 /* ExportAssignment */: return generateNameForExportDefault(); case 197 /* ClassExpression */: return generateNameForClassExpression(); + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); } @@ -61890,6 +62648,10 @@ var ts; // otherwise, return the original node for the source; return node; } + function generateNameForNodeCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + } /** * Gets the generated identifier text from a generated identifier. * @@ -61900,8 +62662,7 @@ var ts; // Generated names generate unique names based on their original node // and are cached based on that node's id var node = getNodeForGeneratedName(name); - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + return generateNameForNodeCached(node); } else { // Auto, Loop, and Unique names are cached based on their unique @@ -62046,7 +62807,8 @@ var ts; commonPathComponents = sourcePathComponents; return; } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + var n = Math.min(commonPathComponents.length, sourcePathComponents.length); + for (var i = 0; i < n; i++) { if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { if (i === 0) { // Failed to find any common path component @@ -62237,10 +62999,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_42 = names_1[_i]; - var result = name_42 in cache - ? cache[name_42] - : cache[name_42] = loader(name_42, containingFile); + var name_43 = names_1[_i]; + var result = name_43 in cache + ? cache[name_43] + : cache[name_43] = loader(name_43, containingFile); resolutions.push(result); } return resolutions; @@ -62276,6 +63038,7 @@ var ts; var supportedExtensions = ts.getSupportedExtensions(options); // Map storing if there is emit blocking diagnostics for given input var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); + var moduleResolutionCache; var resolveModuleNamesWorker; if (host.resolveModuleNames) { resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { @@ -62289,7 +63052,8 @@ var ts; }); }; } else { - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -62335,6 +63099,8 @@ var ts; } } } + // unconditionally set moduleResolutionCache to undefined to avoid unnecessary leaks + moduleResolutionCache = undefined; // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; program = { @@ -62600,7 +63366,7 @@ var ts; newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } // update fileName -> file mapping - for (var i = 0, len = newSourceFiles.length; i < len; i++) { + for (var i = 0; i < newSourceFiles.length; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; @@ -62787,10 +63553,10 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: - case 223 /* VariableDeclaration */: + case 226 /* FunctionDeclaration */: + case 224 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -62798,32 +63564,32 @@ var ts; } } switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 107 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; case 182 /* TypeAssertionExpression */: @@ -62841,26 +63607,26 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // pass through - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 205 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 206 /* VariableStatement */); } break; case 147 /* PropertyDeclaration */: @@ -62983,7 +63749,7 @@ var ts; // synthesize 'import "tslib"' declaration var externalHelpersModuleReference = ts.createSynthesizedNode(9 /* StringLiteral */); externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(235 /* ImportDeclaration */); + var importDecl = ts.createSynthesizedNode(236 /* ImportDeclaration */); importDecl.parent = file; externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; @@ -63001,9 +63767,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: + case 236 /* ImportDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 242 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -63018,7 +63784,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2 /* Ambient */) || ts.isDeclarationFile(file))) { var moduleName = node.name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -64281,11 +65047,11 @@ var ts; function serializeCompilerOptions(options) { var result = ts.createMap(); var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_43 in options) { - if (ts.hasProperty(options, name_43)) { + for (var name_44 in options) { + if (ts.hasProperty(options, name_44)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - switch (name_43) { + switch (name_44) { case "init": case "watch": case "version": @@ -64293,14 +65059,14 @@ var ts; case "project": break; default: - var value = options[name_43]; - var optionDefinition = optionsNameMap[name_43.toLowerCase()]; + var value = options[name_44]; + var optionDefinition = optionsNameMap[name_44.toLowerCase()]; if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { // There is no map associated with this compiler option then use the value as-is // This is the case if the value is expect to be string, number, boolean or list of string - result[name_43] = value; + result[name_44] = value; } else { if (optionDefinition.type === "list") { @@ -64309,11 +65075,11 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_43] = convertedValue; + result[name_44] = convertedValue; } else { // There is a typeMap associated with this command-line option so use it to map value back to its name - result[name_43] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -64361,6 +65127,7 @@ var ts; if (resolutionStack === void 0) { resolutionStack = []; } if (extraFileExtensions === void 0) { extraFileExtensions = []; } var errors = []; + basePath = ts.normalizeSlashes(basePath); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -65130,32 +65897,32 @@ var ts; function getMeaningFromDeclaration(node) { switch (node.kind) { case 144 /* Parameter */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: - case 260 /* EnumMember */: + case 258 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: + case 261 /* EnumMember */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 256 /* CatchClause */: + case 257 /* CatchClause */: return 1 /* Value */; case 143 /* TypeParameter */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: case 161 /* TypeLiteral */: return 2 /* Type */; - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -65165,22 +65932,22 @@ var ts; else { return 4 /* Namespace */; } - case 238 /* NamedImports */: - case 239 /* ImportSpecifier */: - case 234 /* ImportEqualsDeclaration */: - case 235 /* ImportDeclaration */: - case 240 /* ExportAssignment */: - case 241 /* ExportDeclaration */: + case 239 /* NamedImports */: + case 240 /* ImportSpecifier */: + case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportDeclaration */: + case 241 /* ExportAssignment */: + case 242 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 261 /* SourceFile */: + case 262 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 240 /* ExportAssignment */) { + if (node.parent.kind === 241 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -65207,7 +65974,7 @@ var ts; // import a = |b.c|.d; // Namespace if (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 234 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 235 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; @@ -65241,10 +66008,10 @@ var ts; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 199 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 255 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 199 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 256 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 226 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || - (decl.kind === 227 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); + return (decl.kind === 227 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || + (decl.kind === 228 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); } return false; } @@ -65275,7 +66042,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 219 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 220 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -65285,13 +66052,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 /* Identifier */ && - (node.parent.kind === 215 /* BreakStatement */ || node.parent.kind === 214 /* ContinueStatement */) && + (node.parent.kind === 216 /* BreakStatement */ || node.parent.kind === 215 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 /* Identifier */ && - node.parent.kind === 219 /* LabeledStatement */ && + node.parent.kind === 220 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -65307,7 +66074,7 @@ var ts; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 230 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 231 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -65320,13 +66087,13 @@ var ts; switch (node.parent.kind) { case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 260 /* EnumMember */: + case 258 /* PropertyAssignment */: + case 261 /* EnumMember */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return node.parent.name === node; case 178 /* ElementAccessExpression */: return node.parent.argumentExpression === node; @@ -65379,17 +66146,17 @@ var ts; return undefined; } switch (node.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: return node; } } @@ -65397,22 +66164,22 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return ts.ScriptElementKind.classElement; - case 227 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; - case 228 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; - case 229 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; - case 223 /* VariableDeclaration */: + case 228 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 229 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 230 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 224 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); case 174 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: return ts.ScriptElementKind.functionElement; case 151 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; @@ -65428,15 +66195,15 @@ var ts; case 153 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; case 150 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; case 143 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; - case 260 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 261 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; case 144 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 234 /* ImportEqualsDeclaration */: - case 239 /* ImportSpecifier */: - case 236 /* ImportClause */: - case 243 /* ExportSpecifier */: - case 237 /* NamespaceImport */: + case 235 /* ImportEqualsDeclaration */: + case 240 /* ImportSpecifier */: + case 237 /* ImportClause */: + case 244 /* ExportSpecifier */: + case 238 /* NamespaceImport */: return ts.ScriptElementKind.alias; - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -65511,19 +66278,19 @@ var ts; return false; } switch (n.kind) { - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: case 176 /* ObjectLiteralExpression */: case 172 /* ObjectBindingPattern */: case 161 /* TypeLiteral */: - case 204 /* Block */: - case 231 /* ModuleBlock */: - case 232 /* CaseBlock */: - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 205 /* Block */: + case 232 /* ModuleBlock */: + case 233 /* CaseBlock */: + case 239 /* NamedImports */: + case 243 /* NamedExports */: return nodeEndsWith(n, 17 /* CloseBraceToken */, sourceFile); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return isCompletedNode(n.block, sourceFile); case 180 /* NewExpression */: if (!n.arguments) { @@ -65540,7 +66307,7 @@ var ts; case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -65556,14 +66323,14 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 19 /* CloseParenToken */, sourceFile); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 208 /* IfStatement */: + case 209 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24 /* SemicolonToken */); case 175 /* ArrayLiteralExpression */: @@ -65577,16 +66344,16 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 254 /* CaseClause */: + case 255 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 211 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 209 /* DoStatement */: + case 210 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 105 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { @@ -65607,10 +66374,10 @@ var ts; case 194 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 241 /* ExportDeclaration */: - case 235 /* ImportDeclaration */: + case 242 /* ExportDeclaration */: + case 236 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); case 190 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); @@ -65672,7 +66439,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 === 292 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 293 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -65739,8 +66506,8 @@ var ts; } } // find the child that contains 'position' - for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { - var child = current.getChildAt(i); + for (var _a = 0, _b = current.getChildren(); _a < _b.length; _a++) { + var child = _b[_a]; // all jsDocComment nodes were already visited if (ts.isJSDocNode(child)) { continue; @@ -65819,7 +66586,7 @@ var ts; return n; } var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; i++) { + for (var i = 0; i < children.length; i++) { var child = children[i]; // condition 'position < child.end' checks if child node end after the position // in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc' @@ -65844,7 +66611,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 261 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 262 /* 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. @@ -65903,17 +66670,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 252 /* JsxExpression */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 253 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 252 /* JsxExpression */) { + if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 253 /* JsxExpression */) { return true; } //
|
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 249 /* JsxClosingElement */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 250 /* JsxClosingElement */) { return true; } return false; @@ -66028,7 +66795,7 @@ var ts; if (node.kind === 157 /* TypeReference */ || node.kind === 179 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 226 /* ClassDeclaration */ || node.kind === 227 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 227 /* ClassDeclaration */ || node.kind === 228 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -66105,7 +66872,7 @@ var ts; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 213 /* ForOfStatement */ && + if (node.parent.kind === 214 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -66113,7 +66880,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 257 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 258 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -66339,7 +67106,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 239 /* ImportSpecifier */ || location.parent.kind === 243 /* ExportSpecifier */) && + (location.parent.kind === 240 /* ImportSpecifier */ || location.parent.kind === 244 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -66406,6 +67173,11 @@ var ts; }; } ts.sanitizeConfigFile = sanitizeConfigFile; + function getOpenBraceEnd(constructor, sourceFile) { + // First token is the open curly, this is where we want to put the 'super' call. + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + ts.getOpenBraceEnd = getOpenBraceEnd; })(ts || (ts = {})); var ts; (function (ts) { @@ -66473,7 +67245,7 @@ var ts; var entries = []; var dense = classifications.spans; var lastEnd = 0; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; var length_4 = dense[i + 1]; var type = dense[i + 2]; @@ -66845,10 +67617,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: + case 231 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 226 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -66899,7 +67671,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 230 /* ModuleDeclaration */ && + return declaration.kind === 231 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -66960,7 +67732,7 @@ var ts; ts.Debug.assert(classifications.spans.length % 3 === 0); var dense = classifications.spans; var result = []; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { result.push({ textSpan: ts.createTextSpan(dense[i], dense[i + 1]), classificationType: getClassificationTypeName(dense[i + 2]) @@ -67063,16 +67835,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 281 /* JSDocParameterTag */: + case 282 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 284 /* JSDocTemplateTag */: + case 285 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 283 /* JSDocTypeTag */: + case 284 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 282 /* JSDocReturnTag */: + case 283 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -67159,22 +67931,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 248 /* JsxOpeningElement */: + case 249 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 249 /* JsxClosingElement */: + case 250 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -67202,10 +67974,10 @@ var ts; if (token) { if (tokenKind === 57 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 223 /* VariableDeclaration */ || + if (token.parent.kind === 224 /* VariableDeclaration */ || token.parent.kind === 147 /* PropertyDeclaration */ || token.parent.kind === 144 /* Parameter */ || - token.parent.kind === 250 /* JsxAttribute */) { + token.parent.kind === 251 /* JsxAttribute */) { return 5 /* operator */; } } @@ -67222,7 +67994,7 @@ var ts; return 4 /* numericLiteral */; } else if (tokenKind === 9 /* StringLiteral */) { - return token.parent.kind === 250 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 251 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 11 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -67238,7 +68010,7 @@ var ts; else if (tokenKind === 70 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } @@ -67248,17 +68020,17 @@ var ts; return 15 /* typeParameterName */; } return; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } @@ -67280,9 +68052,8 @@ var ts; // Ignore nodes that don't intersect the original span to classify. if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { checkForClassificationCancellation(cancellationToken, element.kind); - var children = element.getChildren(sourceFile); - for (var i = 0, n = children.length; i < n; i++) { - var child = children[i]; + for (var _i = 0, _a = element.getChildren(sourceFile); _i < _a.length; _i++) { + var child = _a[_i]; if (!tryClassifyNode(child)) { // Recurse into our child nodes. processElement(child); @@ -67323,7 +68094,7 @@ var ts; else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 /* JSX */ && - location.parent && location.parent.kind === 249 /* JsxClosingElement */) { + location.parent && location.parent.kind === 250 /* JsxClosingElement */) { // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. // For example: @@ -67350,14 +68121,14 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_44 in nameTable) { + for (var name_45 in nameTable) { // Skip identifiers produced only from the current location - if (nameTable[name_44] === position) { + if (nameTable[name_45] === position) { continue; } - if (!uniqueNames[name_44]) { - uniqueNames[name_44] = name_44; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_44), compilerOptions.target, /*performCharacterChecks*/ true); + if (!uniqueNames[name_45]) { + uniqueNames[name_45] = name_45; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_45), compilerOptions.target, /*performCharacterChecks*/ true); if (displayName) { var entry = { name: displayName, @@ -67417,7 +68188,7 @@ var ts; if (!node || node.kind !== 9 /* StringLiteral */) { return undefined; } - if (node.parent.kind === 257 /* PropertyAssignment */ && + if (node.parent.kind === 258 /* PropertyAssignment */ && node.parent.parent.kind === 176 /* ObjectLiteralExpression */ && node.parent.name === node) { // Get quoted name of properties of the object literal expression @@ -67443,7 +68214,7 @@ var ts; // a['/*completion position*/'] return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 235 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 236 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // import x = require("/*completion position*/"); @@ -67512,6 +68283,9 @@ var ts; return undefined; } function addStringLiteralCompletionsFromType(type, result) { + if (type && type.flags & 16384 /* TypeParameter */) { + type = typeChecker.getApparentType(type); + } if (!type) { return; } @@ -67870,11 +68644,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_13 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_13) { + var parent_14 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_14) { break; } - currentDir = parent_13; + currentDir = parent_14; } else { break; @@ -68026,9 +68800,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 283 /* JSDocTypeTag */: - case 281 /* JSDocParameterTag */: - case 282 /* JSDocReturnTag */: + case 284 /* JSDocTypeTag */: + case 282 /* JSDocParameterTag */: + case 283 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -68073,13 +68847,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_14 = contextToken.parent, kind = contextToken.kind; + var parent_15 = contextToken.parent, kind = contextToken.kind; if (kind === 22 /* DotToken */) { - if (parent_14.kind === 177 /* PropertyAccessExpression */) { + if (parent_15.kind === 177 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_14.kind === 141 /* QualifiedName */) { + else if (parent_15.kind === 141 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -68094,7 +68868,7 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 249 /* JsxClosingElement */) { + else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 250 /* JsxClosingElement */) { isStartingCloseTag = true; location = contextToken; } @@ -68199,7 +68973,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 247 /* JsxSelfClosingElement */) || (jsxContainer.kind === 248 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 248 /* JsxSelfClosingElement */) || (jsxContainer.kind === 249 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -68247,9 +69021,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 261 /* SourceFile */ || + scopeNode.kind === 262 /* SourceFile */ || scopeNode.kind === 194 /* TemplateExpression */ || - scopeNode.kind === 252 /* JsxExpression */ || + scopeNode.kind === 253 /* JsxExpression */ || ts.isStatement(scopeNode); } /// TODO filter meaning based on the current context @@ -68282,11 +69056,11 @@ var ts; return true; } if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 248 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 249 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 249 /* JsxClosingElement */ || contextToken.parent.kind === 247 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 246 /* JsxElement */; + if (contextToken.parent.kind === 250 /* JsxClosingElement */ || contextToken.parent.kind === 248 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 247 /* JsxElement */; } } return false; @@ -68316,16 +69090,16 @@ var ts; case 128 /* NamespaceKeyword */: return true; case 22 /* DotToken */: - return containingNodeKind === 230 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 231 /* ModuleDeclaration */; // module A.| case 16 /* OpenBraceToken */: - return containingNodeKind === 226 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 227 /* ClassDeclaration */; // class A{ | case 57 /* EqualsToken */: - return containingNodeKind === 223 /* VariableDeclaration */ // const x = a| + return containingNodeKind === 224 /* VariableDeclaration */ // const x = a| || containingNodeKind === 192 /* BinaryExpression */; // x = a| case 13 /* TemplateHead */: return containingNodeKind === 194 /* TemplateExpression */; // `aa ${| case 14 /* TemplateMiddle */: - return containingNodeKind === 202 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 203 /* TemplateSpan */; // `aa ${10} dd ${| case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: @@ -68439,9 +69213,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 238 /* NamedImports */ ? - 235 /* ImportDeclaration */ : - 241 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 239 /* NamedImports */ ? + 236 /* ImportDeclaration */ : + 242 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -68466,9 +69240,9 @@ var ts; switch (contextToken.kind) { case 16 /* OpenBraceToken */: // const x = { | case 25 /* CommaToken */: - var parent_15 = contextToken.parent; - if (parent_15 && (parent_15.kind === 176 /* ObjectLiteralExpression */ || parent_15.kind === 172 /* ObjectBindingPattern */)) { - return parent_15; + var parent_16 = contextToken.parent; + if (parent_16 && (parent_16.kind === 176 /* ObjectLiteralExpression */ || parent_16.kind === 172 /* ObjectBindingPattern */)) { + return parent_16; } break; } @@ -68485,8 +69259,8 @@ var ts; case 16 /* OpenBraceToken */: // import { | case 25 /* CommaToken */: switch (contextToken.parent.kind) { - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 239 /* NamedImports */: + case 243 /* NamedExports */: return contextToken.parent; } } @@ -68495,37 +69269,37 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_16 = contextToken.parent; + var parent_17 = contextToken.parent; switch (contextToken.kind) { case 27 /* LessThanSlashToken */: case 40 /* SlashToken */: case 70 /* Identifier */: - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: - if (parent_16 && (parent_16.kind === 247 /* JsxSelfClosingElement */ || parent_16.kind === 248 /* JsxOpeningElement */)) { - return parent_16; + case 251 /* JsxAttribute */: + case 252 /* JsxSpreadAttribute */: + if (parent_17 && (parent_17.kind === 248 /* JsxSelfClosingElement */ || parent_17.kind === 249 /* JsxOpeningElement */)) { + return parent_17; } - else if (parent_16.kind === 250 /* JsxAttribute */) { - return parent_16.parent; + else if (parent_17.kind === 251 /* JsxAttribute */) { + return parent_17.parent; } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_16 && ((parent_16.kind === 250 /* JsxAttribute */) || (parent_16.kind === 251 /* JsxSpreadAttribute */))) { - return parent_16.parent; + if (parent_17 && ((parent_17.kind === 251 /* JsxAttribute */) || (parent_17.kind === 252 /* JsxSpreadAttribute */))) { + return parent_17.parent; } break; case 17 /* CloseBraceToken */: - if (parent_16 && - parent_16.kind === 252 /* JsxExpression */ && - parent_16.parent && - (parent_16.parent.kind === 250 /* JsxAttribute */)) { - return parent_16.parent.parent; + if (parent_17 && + parent_17.kind === 253 /* JsxExpression */ && + parent_17.parent && + (parent_17.parent.kind === 251 /* JsxAttribute */)) { + return parent_17.parent.parent; } - if (parent_16 && parent_16.kind === 251 /* JsxSpreadAttribute */) { - return parent_16.parent; + if (parent_17 && parent_17.kind === 252 /* JsxSpreadAttribute */) { + return parent_17.parent; } break; } @@ -68536,7 +69310,7 @@ var ts; switch (kind) { case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: @@ -68555,16 +69329,16 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25 /* CommaToken */: - return containingNodeKind === 223 /* VariableDeclaration */ || - containingNodeKind === 224 /* VariableDeclarationList */ || - containingNodeKind === 205 /* VariableStatement */ || - containingNodeKind === 229 /* EnumDeclaration */ || + return containingNodeKind === 224 /* VariableDeclaration */ || + containingNodeKind === 225 /* VariableDeclarationList */ || + containingNodeKind === 206 /* VariableStatement */ || + containingNodeKind === 230 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 226 /* ClassDeclaration */ || + containingNodeKind === 227 /* ClassDeclaration */ || containingNodeKind === 197 /* ClassExpression */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || + containingNodeKind === 228 /* InterfaceDeclaration */ || containingNodeKind === 173 /* ArrayBindingPattern */ || - containingNodeKind === 228 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 229 /* TypeAliasDeclaration */; // type Map, K, | case 22 /* DotToken */: return containingNodeKind === 173 /* ArrayBindingPattern */; // var [.| case 55 /* ColonToken */: @@ -68572,22 +69346,22 @@ var ts; case 20 /* OpenBracketToken */: return containingNodeKind === 173 /* ArrayBindingPattern */; // var [x| case 18 /* OpenParenToken */: - return containingNodeKind === 256 /* CatchClause */ || + return containingNodeKind === 257 /* CatchClause */ || isFunction(containingNodeKind); case 16 /* OpenBraceToken */: - return containingNodeKind === 229 /* EnumDeclaration */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || + return containingNodeKind === 230 /* EnumDeclaration */ || + containingNodeKind === 228 /* InterfaceDeclaration */ || containingNodeKind === 161 /* TypeLiteral */; // const x : { | case 24 /* SemicolonToken */: return containingNodeKind === 146 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 227 /* InterfaceDeclaration */ || + (contextToken.parent.parent.kind === 228 /* InterfaceDeclaration */ || contextToken.parent.parent.kind === 161 /* TypeLiteral */); // const x : { a; | case 26 /* LessThanToken */: - return containingNodeKind === 226 /* ClassDeclaration */ || + return containingNodeKind === 227 /* ClassDeclaration */ || containingNodeKind === 197 /* ClassExpression */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || - containingNodeKind === 228 /* TypeAliasDeclaration */ || + containingNodeKind === 228 /* InterfaceDeclaration */ || + containingNodeKind === 229 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); case 114 /* StaticKeyword */: return containingNodeKind === 147 /* PropertyDeclaration */; @@ -68600,9 +69374,9 @@ var ts; case 112 /* ProtectedKeyword */: return containingNodeKind === 144 /* Parameter */; case 117 /* AsKeyword */: - return containingNodeKind === 239 /* ImportSpecifier */ || - containingNodeKind === 243 /* ExportSpecifier */ || - containingNodeKind === 237 /* NamespaceImport */; + return containingNodeKind === 240 /* ImportSpecifier */ || + containingNodeKind === 244 /* ExportSpecifier */ || + containingNodeKind === 238 /* NamespaceImport */; case 74 /* ClassKeyword */: case 82 /* EnumKeyword */: case 108 /* InterfaceKeyword */: @@ -68662,8 +69436,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_45 = element.propertyName || element.name; - existingImportsOrExports[name_45.text] = true; + var name_46 = element.propertyName || element.name; + existingImportsOrExports[name_46.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -68684,8 +69458,8 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 257 /* PropertyAssignment */ && - m.kind !== 258 /* ShorthandPropertyAssignment */ && + if (m.kind !== 258 /* PropertyAssignment */ && + m.kind !== 259 /* ShorthandPropertyAssignment */ && m.kind !== 174 /* BindingElement */ && m.kind !== 149 /* MethodDeclaration */ && m.kind !== 151 /* GetAccessor */ && @@ -68727,7 +69501,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 250 /* JsxAttribute */) { + if (attr.kind === 251 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -68908,58 +69682,58 @@ var ts; switch (node.kind) { case 89 /* IfKeyword */: case 81 /* ElseKeyword */: - if (hasKind(node.parent, 208 /* IfStatement */)) { + if (hasKind(node.parent, 209 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 95 /* ReturnKeyword */: - if (hasKind(node.parent, 216 /* ReturnStatement */)) { + if (hasKind(node.parent, 217 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 99 /* ThrowKeyword */: - if (hasKind(node.parent, 220 /* ThrowStatement */)) { + if (hasKind(node.parent, 221 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 73 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 221 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 222 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 101 /* TryKeyword */: case 86 /* FinallyKeyword */: - if (hasKind(parent(node), 221 /* TryStatement */)) { + if (hasKind(parent(node), 222 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 97 /* SwitchKeyword */: - if (hasKind(node.parent, 218 /* SwitchStatement */)) { + if (hasKind(node.parent, 219 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 72 /* CaseKeyword */: case 78 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 218 /* SwitchStatement */)) { + if (hasKind(parent(parent(parent(node))), 219 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 71 /* BreakKeyword */: case 76 /* ContinueKeyword */: - if (hasKind(node.parent, 215 /* BreakStatement */) || hasKind(node.parent, 214 /* ContinueStatement */)) { + if (hasKind(node.parent, 216 /* BreakStatement */) || hasKind(node.parent, 215 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 87 /* ForKeyword */: - if (hasKind(node.parent, 211 /* ForStatement */) || - hasKind(node.parent, 212 /* ForInStatement */) || - hasKind(node.parent, 213 /* ForOfStatement */)) { + if (hasKind(node.parent, 212 /* ForStatement */) || + hasKind(node.parent, 213 /* ForInStatement */) || + hasKind(node.parent, 214 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 105 /* WhileKeyword */: case 80 /* DoKeyword */: - if (hasKind(node.parent, 210 /* WhileStatement */) || hasKind(node.parent, 209 /* DoStatement */)) { + if (hasKind(node.parent, 211 /* WhileStatement */) || hasKind(node.parent, 210 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; @@ -68976,7 +69750,7 @@ var ts; break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 205 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 206 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -68992,10 +69766,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 220 /* ThrowStatement */) { + if (node.kind === 221 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 221 /* TryStatement */) { + else if (node.kind === 222 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -69022,19 +69796,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_17 = child.parent; - if (ts.isFunctionBlock(parent_17) || parent_17.kind === 261 /* SourceFile */) { - return parent_17; + var parent_18 = child.parent; + if (ts.isFunctionBlock(parent_18) || parent_18.kind === 262 /* SourceFile */) { + return parent_18; } // 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_17.kind === 221 /* TryStatement */) { - var tryStatement = parent_17; + if (parent_18.kind === 222 /* TryStatement */) { + var tryStatement = parent_18; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_17; + child = parent_18; } return undefined; } @@ -69043,7 +69817,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 215 /* BreakStatement */ || node.kind === 214 /* ContinueStatement */) { + if (node.kind === 216 /* BreakStatement */ || node.kind === 215 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -69056,25 +69830,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 218 /* SwitchStatement */: - if (statement.kind === 214 /* ContinueStatement */) { + for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { + switch (node_2.kind) { + case 219 /* SwitchStatement */: + if (statement.kind === 215 /* ContinueStatement */) { continue; } // Fall through. - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 211 /* WhileStatement */: + case 210 /* 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; @@ -69086,24 +69860,24 @@ 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 === 226 /* ClassDeclaration */ || + if (!(container.kind === 227 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */ || (declaration.kind === 144 /* Parameter */ && hasKind(container, 150 /* Constructor */)))) { return undefined; } } else if (modifier === 114 /* StaticKeyword */) { - if (!(container.kind === 226 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */)) { + if (!(container.kind === 227 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */)) { return undefined; } } else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { - if (!(container.kind === 231 /* ModuleBlock */ || container.kind === 261 /* SourceFile */)) { + if (!(container.kind === 232 /* ModuleBlock */ || container.kind === 262 /* SourceFile */)) { return undefined; } } else if (modifier === 116 /* AbstractKeyword */) { - if (!(container.kind === 226 /* ClassDeclaration */ || declaration.kind === 226 /* ClassDeclaration */)) { + if (!(container.kind === 227 /* ClassDeclaration */ || declaration.kind === 227 /* ClassDeclaration */)) { return undefined; } } @@ -69115,8 +69889,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 231 /* ModuleBlock */: - case 261 /* SourceFile */: + case 232 /* ModuleBlock */: + case 262 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -69128,7 +69902,7 @@ var ts; case 150 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search @@ -69212,7 +69986,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87 /* ForKeyword */, 105 /* WhileKeyword */, 80 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 209 /* DoStatement */) { + if (loopNode.kind === 210 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { @@ -69233,13 +70007,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -69293,7 +70067,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, 204 /* Block */))) { + if (!(func && hasKind(func.body, 205 /* Block */))) { return undefined; } var keywords = []; @@ -69309,7 +70083,7 @@ var ts; function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 208 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 209 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -69322,7 +70096,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 208 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 209 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -69365,7 +70139,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 219 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 220 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -69599,12 +70373,12 @@ var ts; function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608 /* Alias */) { // Default import get alias - var defaultImport = ts.getDeclarationOfKind(symbol, 236 /* ImportClause */); + var defaultImport = ts.getDeclarationOfKind(symbol, 237 /* ImportClause */); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 239 /* ImportSpecifier */ || - declaration.kind === 243 /* ExportSpecifier */) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 240 /* ImportSpecifier */ || + declaration.kind === 244 /* ExportSpecifier */) ? declaration : undefined; }); if (importOrExportSpecifier && // export { a } (!importOrExportSpecifier.propertyName || @@ -69612,7 +70386,7 @@ var ts; importOrExportSpecifier.propertyName === location)) { // If Import specifier -> get alias // else Export specifier -> get local target - return importOrExportSpecifier.kind === 239 /* ImportSpecifier */ ? + return importOrExportSpecifier.kind === 240 /* ImportSpecifier */ ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -69671,7 +70445,7 @@ var ts; if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 226 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 227 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -69702,7 +70476,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 261 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 262 /* 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; @@ -69978,7 +70752,7 @@ var ts; result.push(getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === 70 /* Identifier */) { - if (refNode.parent.kind === 258 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 259 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } @@ -69991,24 +70765,24 @@ var ts; // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface var containingTypeReference = getContainingTypeReference(refNode); if (containingTypeReference) { - var parent_18 = containingTypeReference.parent; - if (ts.isVariableLike(parent_18) && parent_18.type === containingTypeReference && parent_18.initializer && isImplementationExpression(parent_18.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_18.initializer)); + var parent_19 = containingTypeReference.parent; + if (ts.isVariableLike(parent_19) && parent_19.type === containingTypeReference && parent_19.initializer && isImplementationExpression(parent_19.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_19.initializer)); } - else if (ts.isFunctionLike(parent_18) && parent_18.type === containingTypeReference && parent_18.body) { - if (parent_18.body.kind === 204 /* Block */) { - ts.forEachReturnStatement(parent_18.body, function (returnStatement) { + else if (ts.isFunctionLike(parent_19) && parent_19.type === containingTypeReference && parent_19.body) { + if (parent_19.body.kind === 205 /* Block */) { + ts.forEachReturnStatement(parent_19.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); } }); } - else if (isImplementationExpression(parent_18.body)) { - maybeAdd(getReferenceEntryFromNode(parent_18.body)); + else if (isImplementationExpression(parent_19.body)) { + maybeAdd(getReferenceEntryFromNode(parent_19.body)); } } - else if (ts.isAssertionExpression(parent_18) && isImplementationExpression(parent_18.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_18.expression)); + else if (ts.isAssertionExpression(parent_19) && isImplementationExpression(parent_19.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_19.expression)); } } } @@ -70049,7 +70823,7 @@ var ts; function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { if (node.kind === 199 /* ExpressionWithTypeArguments */ - && node.parent.kind === 255 /* HeritageClause */ + && node.parent.kind === 256 /* HeritageClause */ && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -70120,7 +70894,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 227 /* InterfaceDeclaration */) { + else if (declaration.kind === 228 /* InterfaceDeclaration */) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -70200,12 +70974,12 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, @@ -70215,7 +70989,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 261 /* SourceFile */) { + if (searchSpaceNode.kind === 262 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -70250,7 +71024,7 @@ var ts; var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } @@ -70262,15 +71036,15 @@ var ts; } break; case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: + case 227 /* 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 && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 261 /* SourceFile */: - if (container.kind === 261 /* SourceFile */ && !ts.isExternalModule(container)) { + case 262 /* SourceFile */: + if (container.kind === 262 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -70306,13 +71080,13 @@ var ts; for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { var position = possiblePositions_1[_i]; cancellationToken.throwIfCancellationRequested(); - var node_2 = ts.getTouchingWord(sourceFile, position); - if (!node_2 || node_2.kind !== 9 /* StringLiteral */) { + var node_3 = ts.getTouchingWord(sourceFile, position); + if (!node_3 || node_3.kind !== 9 /* StringLiteral */) { return; } - var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + var type_1 = ts.getStringLiteralTypeForNode(node_3, typeChecker); if (type_1 === searchType) { - references.push(getReferenceEntryFromNode(node_2)); + references.push(getReferenceEntryFromNode(node_3)); } } } @@ -70324,7 +71098,7 @@ var ts; // Search the property symbol // for ( { property: p2 } of elems) { } var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 258 /* ShorthandPropertyAssignment */) { + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 259 /* ShorthandPropertyAssignment */) { var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); if (propertySymbol) { result.push(propertySymbol); @@ -70427,7 +71201,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 227 /* InterfaceDeclaration */) { + else if (declaration.kind === 228 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -70593,7 +71367,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 223 /* VariableDeclaration */) { + else if (node.kind === 224 /* VariableDeclaration */) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } @@ -70603,18 +71377,18 @@ var ts; } else { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 205 /* VariableStatement */) { - ts.Debug.assert(node.parent.kind === 224 /* VariableDeclarationList */); + if (node.parent && node.parent.parent && node.parent.parent.kind === 206 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 225 /* VariableDeclarationList */); return node.parent.parent; } } @@ -70689,8 +71463,8 @@ var ts; } function isObjectLiteralPropertyDeclaration(node) { switch (node.kind) { - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: + case 258 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: @@ -70768,7 +71542,7 @@ var ts; // if (node.kind === 70 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 239 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 238 /* NamedImports */))) { + (declaration.kind === 240 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 239 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -70777,7 +71551,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 === 258 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 259 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -70861,7 +71635,7 @@ var ts; var definition; ts.forEach(signatureDeclarations, function (d) { if ((selectConstructors && d.kind === 150 /* Constructor */) || - (!selectConstructors && (d.kind === 225 /* FunctionDeclaration */ || d.kind === 149 /* MethodDeclaration */ || d.kind === 148 /* MethodSignature */))) { + (!selectConstructors && (d.kind === 226 /* FunctionDeclaration */ || d.kind === 149 /* MethodDeclaration */ || d.kind === 148 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -70941,7 +71715,7 @@ var ts; function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 258 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 259 /* ShorthandPropertyAssignment */) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -71048,7 +71822,7 @@ var ts; */ function forEachUnique(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (ts.indexOf(array, array[i]) === i) { var result = callback(array[i], i); if (result) { @@ -71108,19 +71882,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 150 /* Constructor */: - case 226 /* ClassDeclaration */: - case 205 /* VariableStatement */: + case 227 /* ClassDeclaration */: + case 206 /* VariableStatement */: break findOwner; - case 261 /* SourceFile */: + case 262 /* SourceFile */: return undefined; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - if (commentOwner.parent.kind === 230 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 231 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -71135,7 +71909,7 @@ var ts; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; - for (var i = 0, numParams = parameters.length; i < numParams; i++) { + for (var i = 0; i < parameters.length; i++) { var currentName = parameters[i].name; var paramName = currentName.kind === 70 /* Identifier */ ? currentName.text : @@ -71167,7 +71941,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 205 /* VariableStatement */) { + if (commentOwner.kind === 206 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -71287,9 +72061,9 @@ var ts; } } // Add the cached typing locations for inferred typings that are already installed - for (var name_46 in packageNameToTypingLocation) { - if (name_46 in inferredTypings && !inferredTypings[name_46]) { - inferredTypings[name_46] = packageNameToTypingLocation[name_46]; + for (var name_47 in packageNameToTypingLocation) { + if (name_47 in inferredTypings && !inferredTypings[name_47]) { + inferredTypings[name_47] = packageNameToTypingLocation[name_47]; } } // Remove typings that the user has added to the exclude list @@ -71427,12 +72201,12 @@ var ts; return; } var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_47 in nameToDeclarations) { - var declarations = nameToDeclarations[name_47]; + for (var name_48 in nameToDeclarations) { + var declarations = nameToDeclarations[name_48]; 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_47); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_48); if (!matches) { continue; } @@ -71445,14 +72219,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_47); + matches = patternMatcher.getMatches(containers, name_48); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_47, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_48, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -71460,7 +72234,7 @@ var ts; // Remove imports when the imported declaration is already in the list and has the same name. rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 236 /* ImportClause */ || decl.kind === 239 /* ImportSpecifier */ || decl.kind === 234 /* ImportEqualsDeclaration */) { + if (decl.kind === 237 /* ImportClause */ || decl.kind === 240 /* ImportSpecifier */ || decl.kind === 235 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -71715,7 +72489,7 @@ var ts; addLeafNode(node); } break; - case 236 /* ImportClause */: + case 237 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -71727,7 +72501,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings.kind === 238 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -71739,11 +72513,11 @@ var ts; } break; case 174 /* BindingElement */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: var decl = node; - var name_48 = decl.name; - if (ts.isBindingPattern(name_48)) { - addChildrenRecursively(name_48); + var name_49 = decl.name; + if (ts.isBindingPattern(name_49)) { + addChildrenRecursively(name_49); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { // For `const x = function() {}`, just use the function node, not the const. @@ -71754,11 +72528,11 @@ var ts; } break; case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -71768,9 +72542,9 @@ var ts; } endNode(); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -71778,21 +72552,21 @@ var ts; } endNode(); break; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 243 /* ExportSpecifier */: - case 234 /* ImportEqualsDeclaration */: + case 244 /* ExportSpecifier */: + case 235 /* ImportEqualsDeclaration */: case 155 /* IndexSignature */: case 153 /* CallSignature */: case 154 /* ConstructSignature */: - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 285 /* JSDocTypedefTag */) { + if (tag.kind === 286 /* JSDocTypedefTag */) { addLeafNode(tag); } }); @@ -71843,14 +72617,14 @@ var ts; }); /** a and b have the same name, but they may not be mergeable. */ function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 230 /* ModuleDeclaration */ || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 231 /* ModuleDeclaration */ || areSameModule(a, b)); // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 230 /* ModuleDeclaration */) { + if (a.body.kind !== 231 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -71910,7 +72684,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 230 /* ModuleDeclaration */) { + if (node.kind === 231 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -71922,14 +72696,14 @@ var ts; case 185 /* ArrowFunction */: case 197 /* ClassExpression */: return getFunctionOrClassName(node); - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 230 /* ModuleDeclaration */) { + if (node.kind === 231 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -71940,15 +72714,15 @@ var ts; } } switch (node.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; @@ -71965,7 +72739,7 @@ var ts; return "()"; case 155 /* IndexSignature */: return "[]"; - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return ""; @@ -71977,7 +72751,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 205 /* VariableStatement */) { + if (parentNode && parentNode.kind === 206 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -72006,23 +72780,23 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 229 /* EnumDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 261 /* SourceFile */: - case 228 /* TypeAliasDeclaration */: - case 285 /* JSDocTypedefTag */: + case 230 /* EnumDeclaration */: + case 228 /* InterfaceDeclaration */: + case 231 /* ModuleDeclaration */: + case 262 /* SourceFile */: + case 229 /* TypeAliasDeclaration */: + case 286 /* JSDocTypedefTag */: return true; case 150 /* Constructor */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return hasSomeImportantChild(item); case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: @@ -72033,8 +72807,8 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 231 /* ModuleBlock */: - case 261 /* SourceFile */: + case 232 /* ModuleBlock */: + case 262 /* SourceFile */: case 149 /* MethodDeclaration */: case 150 /* Constructor */: return true; @@ -72045,7 +72819,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 223 /* VariableDeclaration */ && childKind !== 174 /* BindingElement */; + return childKind !== 224 /* VariableDeclaration */ && childKind !== 174 /* BindingElement */; }); } } @@ -72103,7 +72877,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 === 230 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 231 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -72114,13 +72888,13 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 230 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 231 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { return !member.name || member.name.kind === 142 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 261 /* SourceFile */ + return node.kind === 262 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); } @@ -72128,14 +72902,14 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 223 /* VariableDeclaration */) { + else if (node.parent.kind === 224 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } else if (node.parent.kind === 192 /* BinaryExpression */ && node.parent.operatorToken.kind === 57 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 257 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 258 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512 /* Default */) { @@ -72248,30 +73022,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 204 /* Block */: + case 205 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_19 = n.parent; + var parent_20 = n.parent; var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent_19.kind === 209 /* DoStatement */ || - parent_19.kind === 212 /* ForInStatement */ || - parent_19.kind === 213 /* ForOfStatement */ || - parent_19.kind === 211 /* ForStatement */ || - parent_19.kind === 208 /* IfStatement */ || - parent_19.kind === 210 /* WhileStatement */ || - parent_19.kind === 217 /* WithStatement */ || - parent_19.kind === 256 /* CatchClause */) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + if (parent_20.kind === 210 /* DoStatement */ || + parent_20.kind === 213 /* ForInStatement */ || + parent_20.kind === 214 /* ForOfStatement */ || + parent_20.kind === 212 /* ForStatement */ || + parent_20.kind === 209 /* IfStatement */ || + parent_20.kind === 211 /* WhileStatement */ || + parent_20.kind === 218 /* WithStatement */ || + parent_20.kind === 257 /* CatchClause */) { + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_19.kind === 221 /* TryStatement */) { + if (parent_20.kind === 222 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_19; + var tryStatement = parent_20; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -72294,17 +73068,17 @@ var ts; break; } // Fallthrough. - case 231 /* ModuleBlock */: { + case 232 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: case 176 /* ObjectLiteralExpression */: - case 232 /* CaseBlock */: { + case 233 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); @@ -72690,7 +73464,8 @@ var ts; } // Assumes 'value' is already lowercase. function indexOfIgnoringCase(string, value) { - for (var i = 0, n = string.length - value.length; i <= n; i++) { + var n = string.length - value.length; + for (var i = 0; i <= n; i++) { if (startsWithIgnoringCase(string, value, i)) { return i; } @@ -72699,7 +73474,7 @@ var ts; } // Assumes 'value' is already lowercase. function startsWithIgnoringCase(string, value, start) { - for (var i = 0, n = value.length; i < n; i++) { + for (var i = 0; i < value.length; i++) { var ch1 = toLowerCase(string.charCodeAt(i + start)); var ch2 = value.charCodeAt(i); if (ch1 !== ch2) { @@ -72771,7 +73546,7 @@ var ts; function breakIntoSpans(identifier, word) { var result = []; var wordStart = 0; - for (var i = 1, n = identifier.length; i < n; i++) { + for (var i = 1; i < identifier.length; i++) { var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); var currentIsDigit = isDigit(identifier.charCodeAt(i)); var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); @@ -73597,7 +74372,7 @@ var ts; var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 202 /* TemplateSpan */ && node.parent.parent.parent.kind === 181 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 203 /* TemplateSpan */ && node.parent.parent.parent.kind === 181 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; @@ -73728,7 +74503,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 261 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 262 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -74124,7 +74899,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 230 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 231 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 70 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 128 /* NamespaceKeyword */ : 127 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -74161,7 +74936,7 @@ var ts; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 228 /* TypeAliasDeclaration */) { + else if (declaration.kind === 229 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -74177,7 +74952,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 260 /* EnumMember */) { + if (declaration.kind === 261 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -74189,7 +74964,7 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 233 /* NamespaceExportDeclaration */) { + if (symbol.declarations[0].kind === 234 /* NamespaceExportDeclaration */) { displayParts.push(ts.keywordPart(83 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(128 /* NamespaceKeyword */)); @@ -74200,7 +74975,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 234 /* ImportEqualsDeclaration */) { + if (declaration.kind === 235 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -74273,7 +75048,7 @@ var ts; // For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 261 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 262 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!declaration.parent || declaration.parent.kind !== 192 /* BinaryExpression */) { @@ -74360,13 +75135,13 @@ var ts; if (declaration.kind === 184 /* FunctionExpression */) { return true; } - if (declaration.kind !== 223 /* VariableDeclaration */ && declaration.kind !== 225 /* FunctionDeclaration */) { + if (declaration.kind !== 224 /* VariableDeclaration */ && declaration.kind !== 226 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_20 = declaration.parent; !ts.isFunctionBlock(parent_20); parent_20 = parent_20.parent) { + for (var parent_21 = declaration.parent; !ts.isFunctionBlock(parent_21); parent_21 = parent_21.parent) { // Reached source file or module block - if (parent_20.kind === 261 /* SourceFile */ || parent_20.kind === 231 /* ModuleBlock */) { + if (parent_21.kind === 262 /* SourceFile */ || parent_21.kind === 232 /* ModuleBlock */) { return false; } } @@ -74604,10 +75379,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 250 /* JsxAttribute */: - case 248 /* JsxOpeningElement */: - case 249 /* JsxClosingElement */: - case 247 /* JsxSelfClosingElement */: + case 251 /* JsxAttribute */: + case 249 /* JsxOpeningElement */: + case 250 /* JsxClosingElement */: + case 248 /* JsxSelfClosingElement */: return node.kind === 70 /* Identifier */; } } @@ -75019,11 +75794,11 @@ var ts; this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Space after }. - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromRange(0 /* FirstToken */, 140 /* LastToken */, [19 /* CloseParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 81 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 105 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 21 /* CloseBracketToken */, 25 /* CommaToken */, 24 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([21 /* CloseBracketToken */, 25 /* CommaToken */, 24 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // No space for dot this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); @@ -75040,10 +75815,10 @@ var ts; this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 80 /* DoKeyword */, 101 /* TryKeyword */, 86 /* FinallyKeyword */, 81 /* ElseKeyword */]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8 /* Delete */)); this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenBraceToken */, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); // Insert new line after { and before } in multi-line contexts. this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); @@ -75073,6 +75848,7 @@ var ts; this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([109 /* LetKeyword */, 75 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95 /* ReturnKeyword */, 24 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); @@ -75089,11 +75865,12 @@ var ts; this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); // TypeScript-specific higher priority rules // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses + this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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([127 /* ModuleKeyword */, 131 /* RequireKeyword */]), 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 133 /* SetKeyword */, 114 /* StaticKeyword */, 136 /* TypeKeyword */, 138 /* FromKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 130 /* ReadonlyKeyword */, 133 /* SetKeyword */, 114 /* StaticKeyword */, 136 /* TypeKeyword */, 138 /* FromKeyword */, 126 /* KeyOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 138 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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(9 /* StringLiteral */, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); @@ -75130,6 +75907,8 @@ var ts; this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* SlashToken */, 28 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57 /* EqualsToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57 /* EqualsToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + // No space before non-null assertion operator + this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50 /* ExclamationToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -75160,7 +75939,7 @@ var ts; this.SpaceBeforeJsxAttribute, this.SpaceBeforeSlashInJsxOpeningElement, this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement, this.NoSpaceBeforeEqualInJsxAttribute, this.NoSpaceAfterEqualInJsxAttribute, // TypeScript-specific rules - this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, + this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, this.SpaceBeforeArrow, this.SpaceAfterArrow, @@ -75175,6 +75954,7 @@ var ts; this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, + this.NoSpaceBeforeNonNullAssertionOperator ]; // These rules are lower in priority than user-configurable rules. this.LowPriorityCommonRules = [ @@ -75184,7 +75964,6 @@ var ts; this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, - this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; /// @@ -75242,9 +76021,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_49 in o) { - if (o[name_49] === rule) { - return name_49; + for (var name_50 in o) { + if (o[name_50] === rule) { + return name_50; } } throw new Error("Unknown rule"); @@ -75253,7 +76032,7 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 211 /* ForStatement */; + return context.contextNode.kind === 212 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); @@ -75263,8 +76042,8 @@ var ts; case 192 /* BinaryExpression */: case 193 /* ConditionalExpression */: case 200 /* AsExpression */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: case 156 /* TypePredicate */: case 164 /* UnionType */: case 165 /* IntersectionType */: @@ -75272,22 +76051,24 @@ var ts; // equals in binding elements: function foo([[x, y] = [1, 2]]) case 174 /* BindingElement */: // equals in type X = ... - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: // equal in p = 0; case 144 /* Parameter */: - case 260 /* EnumMember */: + case 261 /* EnumMember */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: return context.currentTokenSpan.kind === 57 /* EqualsToken */ || context.nextTokenSpan.kind === 57 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: + // "in" keyword in [P in keyof T]: T[P] + case 143 /* TypeParameter */: return context.currentTokenSpan.kind === 91 /* InKeyword */ || context.nextTokenSpan.kind === 91 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return context.currentTokenSpan.kind === 140 /* OfKeyword */ || context.nextTokenSpan.kind === 140 /* OfKeyword */; } return false; @@ -75317,6 +76098,9 @@ var ts; //// * ) and { are on different lines. We only need to format if the block is multiline context. So in this case we format. return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; + Rules.IsBraceWrappedContext = function (context) { + return context.contextNode.kind === 172 /* ObjectBindingPattern */ || Rules.IsSingleLineBlockContext(context); + }; // This check is done before an open brace in a control construct, a function, or a typescript block declaration Rules.IsBeforeMultilineBlockContext = function (context) { return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); @@ -75340,17 +76124,17 @@ var ts; return true; } switch (node.kind) { - case 204 /* Block */: - case 232 /* CaseBlock */: + case 205 /* Block */: + case 233 /* CaseBlock */: case 176 /* ObjectLiteralExpression */: - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: @@ -75364,60 +76148,66 @@ var ts; // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 225 /* FunctionDeclaration */ || context.contextNode.kind === 184 /* FunctionExpression */; + return context.contextNode.kind === 226 /* FunctionDeclaration */ || context.contextNode.kind === 184 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: case 161 /* TypeLiteral */: - case 230 /* ModuleDeclaration */: - case 241 /* ExportDeclaration */: - case 242 /* NamedExports */: - case 235 /* ImportDeclaration */: - case 238 /* NamedImports */: + case 231 /* ModuleDeclaration */: + case 242 /* ExportDeclaration */: + case 243 /* NamedExports */: + case 236 /* ImportDeclaration */: + case 239 /* NamedImports */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 226 /* ClassDeclaration */: - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: - case 204 /* Block */: - case 256 /* CatchClause */: - case 231 /* ModuleBlock */: - case 218 /* SwitchStatement */: + case 227 /* ClassDeclaration */: + case 231 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: + case 257 /* CatchClause */: + case 232 /* ModuleBlock */: + case 219 /* SwitchStatement */: return true; + case 205 /* Block */: { + var blockParent = context.currentTokenParent.parent; + if (blockParent.kind !== 185 /* ArrowFunction */ && + blockParent.kind !== 184 /* FunctionExpression */) { + return true; + } + } } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 208 /* IfStatement */: - case 218 /* SwitchStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: - case 221 /* TryStatement */: - case 209 /* DoStatement */: - case 217 /* WithStatement */: + case 209 /* IfStatement */: + case 219 /* SwitchStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 211 /* WhileStatement */: + case 222 /* TryStatement */: + case 210 /* DoStatement */: + case 218 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 256 /* CatchClause */: + case 257 /* CatchClause */: return true; default: return false; @@ -75448,19 +76238,19 @@ var ts; return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 246 /* JsxElement */; + return context.contextNode.kind !== 247 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 252 /* JsxExpression */; + return context.contextNode.kind === 253 /* JsxExpression */; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 250 /* JsxAttribute */; + return context.nextTokenParent.kind === 251 /* JsxAttribute */; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 250 /* JsxAttribute */; + return context.contextNode.kind === 251 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 247 /* JsxSelfClosingElement */; + return context.contextNode.kind === 248 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -75478,14 +76268,14 @@ var ts; return node.kind === 145 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 224 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 225 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 230 /* ModuleDeclaration */; + return context.contextNode.kind === 231 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { return context.contextNode.kind === 161 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; @@ -75497,10 +76287,11 @@ var ts; switch (parent.kind) { case 157 /* TypeReference */: case 182 /* TypeAssertionExpression */: - case 226 /* ClassDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: + case 228 /* InterfaceDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: @@ -75528,6 +76319,9 @@ var ts; Rules.IsYieldOrYieldStarWithOperand = function (context) { return context.contextNode.kind === 195 /* YieldExpression */ && context.contextNode.expression !== undefined; }; + Rules.IsNonNullAssertionContext = function (context) { + return context.contextNode.kind === 201 /* NonNullExpression */; + }; return Rules; }()); formatting.Rules = Rules; @@ -75846,6 +76640,12 @@ var ts; }; RulesProvider.prototype.createActiveRules = function (options) { var rules = this.globalRules.HighPriorityCommonRules.slice(0); + if (options.insertSpaceAfterConstructor) { + rules.push(this.globalRules.SpaceAfterConstructor); + } + else { + rules.push(this.globalRules.NoSpaceAfterConstructor); + } if (options.insertSpaceAfterCommaDelimiter) { rules.push(this.globalRules.SpaceAfterComma); } @@ -75926,6 +76726,12 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); rules.push(this.globalRules.NoSpaceAfterBinaryOperator); } + if (options.insertSpaceBeforeFunctionParenthesis) { + rules.push(this.globalRules.SpaceBeforeOpenParenInFuncDecl); + } + else { + rules.push(this.globalRules.NoSpaceBeforeOpenParenInFuncDecl); + } if (options.placeOpenBraceOnNewLineForControlBlocks) { rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); } @@ -76058,17 +76864,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 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 231 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 261 /* SourceFile */: - case 204 /* Block */: - case 231 /* ModuleBlock */: + return body && body.kind === 232 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 262 /* SourceFile */: + case 205 /* Block */: + case 232 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -76273,10 +77079,10 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 226 /* ClassDeclaration */: return 74 /* ClassKeyword */; - case 227 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; - case 225 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; - case 229 /* EnumDeclaration */: return 229 /* EnumDeclaration */; + case 227 /* ClassDeclaration */: return 74 /* ClassKeyword */; + case 228 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; + case 226 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; + case 230 /* EnumDeclaration */: return 230 /* EnumDeclaration */; case 151 /* GetAccessor */: return 124 /* GetKeyword */; case 152 /* SetAccessor */: return 133 /* SetKeyword */; case 149 /* MethodDeclaration */: @@ -76316,18 +77122,31 @@ var ts; // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent case 16 /* OpenBraceToken */: case 17 /* CloseBraceToken */: - case 20 /* OpenBracketToken */: - case 21 /* CloseBracketToken */: case 18 /* OpenParenToken */: case 19 /* CloseParenToken */: case 81 /* ElseKeyword */: case 105 /* WhileKeyword */: case 56 /* AtToken */: return indentation; - default: - // if token line equals to the line of containing node (this is a first token in the node) - use node indentation - return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; + case 40 /* SlashToken */: + case 28 /* GreaterThanToken */: { + if (container.kind === 249 /* JsxOpeningElement */ || + container.kind === 250 /* JsxClosingElement */ || + container.kind === 248 /* JsxSelfClosingElement */) { + return indentation; + } + break; + } + case 20 /* OpenBracketToken */: + case 21 /* CloseBracketToken */: { + if (container.kind !== 170 /* MappedType */) { + return indentation; + } + break; + } } + // if token line equals to the line of containing node (this is a first token in the node) - use node indentation + return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; }, getIndentation: function () { return indentation; }, getDelta: function (child) { return getEffectiveDelta(delta, child); }, @@ -76383,7 +77202,7 @@ var ts; if (tokenInfo.token.end > node.end) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); @@ -76417,7 +77236,7 @@ var ts; // stop when formatting scanner advances past the beginning of the child break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, node); } if (!formattingScanner.isOnToken()) { return inheritedIndentation; @@ -76457,11 +77276,11 @@ var ts; startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1 /* Unknown */, parent, parentDynamicIndentation, parentStartLine); listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } else { // consume any tokens that precede the list as child elements of 'node' using its indentation scope - consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); } } } @@ -76479,7 +77298,7 @@ var ts; // without this check close paren will be interpreted as list end token for function expression which is wrong if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { // consume list end token - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } } } @@ -76686,7 +77505,7 @@ var ts; } // shift all parts on the delta size var delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; i++, startLine++) { + for (var i = startIndex; i < parts.length; i++, startLine++) { var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart @@ -76792,7 +77611,7 @@ var ts; function getOpenTokenForList(node, list) { switch (node.kind) { case 150 /* Constructor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -77052,7 +77871,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.isStatementButNotDeclaration(current)) && - (parent.kind === 261 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 262 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -77085,7 +77904,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 208 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 209 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -77107,7 +77926,7 @@ var ts; return node.parent.properties; case 175 /* ArrayLiteralExpression */: return node.parent.elements; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: @@ -77241,35 +78060,36 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 207 /* ExpressionStatement */: - case 226 /* ClassDeclaration */: + case 208 /* ExpressionStatement */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: + case 229 /* TypeAliasDeclaration */: case 175 /* ArrayLiteralExpression */: - case 204 /* Block */: - case 231 /* ModuleBlock */: + case 205 /* Block */: + case 232 /* ModuleBlock */: case 176 /* ObjectLiteralExpression */: case 161 /* TypeLiteral */: + case 170 /* MappedType */: case 163 /* TupleType */: - case 232 /* CaseBlock */: - case 254 /* DefaultClause */: - case 253 /* CaseClause */: + case 233 /* CaseBlock */: + case 255 /* DefaultClause */: + case 254 /* CaseClause */: case 183 /* ParenthesizedExpression */: case 177 /* PropertyAccessExpression */: case 179 /* CallExpression */: case 180 /* NewExpression */: - case 205 /* VariableStatement */: - case 223 /* VariableDeclaration */: - case 240 /* ExportAssignment */: - case 216 /* ReturnStatement */: + case 206 /* VariableStatement */: + case 224 /* VariableDeclaration */: + case 241 /* ExportAssignment */: + case 217 /* ReturnStatement */: case 193 /* ConditionalExpression */: case 173 /* ArrayBindingPattern */: case 172 /* ObjectBindingPattern */: - case 248 /* JsxOpeningElement */: - case 247 /* JsxSelfClosingElement */: - case 252 /* JsxExpression */: + case 249 /* JsxOpeningElement */: + case 248 /* JsxSelfClosingElement */: + case 253 /* JsxExpression */: case 148 /* MethodSignature */: case 153 /* CallSignature */: case 154 /* ConstructSignature */: @@ -77279,10 +78099,10 @@ var ts; case 166 /* ParenthesizedType */: case 181 /* TaggedTemplateExpression */: case 189 /* AwaitExpression */: - case 242 /* NamedExports */: - case 238 /* NamedImports */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: + case 243 /* NamedExports */: + case 239 /* NamedImports */: + case 244 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: return true; } return false; @@ -77291,27 +78111,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 211 /* ForStatement */: - case 208 /* IfStatement */: - case 225 /* FunctionDeclaration */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 212 /* ForStatement */: + case 209 /* IfStatement */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 185 /* ArrowFunction */: case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - return childKind !== 204 /* Block */; - case 241 /* ExportDeclaration */: - return childKind !== 242 /* NamedExports */; - case 235 /* ImportDeclaration */: - return childKind !== 236 /* ImportClause */ || - (child.namedBindings && child.namedBindings.kind !== 238 /* NamedImports */); - case 246 /* JsxElement */: - return childKind !== 249 /* JsxClosingElement */; + return childKind !== 205 /* Block */; + case 242 /* ExportDeclaration */: + return childKind !== 243 /* NamedExports */; + case 236 /* ImportDeclaration */: + return childKind !== 237 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 239 /* NamedImports */); + case 247 /* JsxElement */: + return childKind !== 250 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -77367,25 +78187,128 @@ var ts; (function (ts) { var codefix; (function (codefix) { - function getOpenBraceEnd(constructor, sourceFile) { - // First token is the open curly, this is where we want to put the 'super' call. - return constructor.body.getFirstToken(sourceFile).getEnd(); - } codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 122 /* ConstructorKeyword */) { - return undefined; - } - var newPosition = getOpenBraceEnd(token.parent, sourceFile); - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] - }]; - } + errorCodes: [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code], + getCodeActions: getActionForClassLikeIncorrectImplementsInterface }); + function getActionForClassLikeIncorrectImplementsInterface(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + var classDecl = ts.getContainingClass(token); + if (!classDecl) { + return undefined; + } + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDecl); + var hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, 1 /* Number */); + var hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, 0 /* String */); + var result = []; + for (var _i = 0, implementedTypeNodes_2 = implementedTypeNodes; _i < implementedTypeNodes_2.length; _i++) { + var implementedTypeNode = implementedTypeNodes_2[_i]; + var implementedType = checker.getTypeFromTypeNode(implementedTypeNode); + // Note that this is ultimately derived from a map indexed by symbol names, + // so duplicates cannot occur. + var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); + var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); }); + var insertion = getMissingIndexSignatureInsertion(implementedType, 1 /* Number */, classDecl, hasNumericIndexSignature); + insertion += getMissingIndexSignatureInsertion(implementedType, 0 /* String */, classDecl, hasStringIndexSignature); + insertion += codefix.getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); + var message = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); + if (insertion) { + pushAction(result, insertion, message); + } + } + return result; + function getMissingIndexSignatureInsertion(type, kind, enclosingDeclaration, hasIndexSigOfKind) { + if (!hasIndexSigOfKind) { + var IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); + if (IndexInfoOfKind) { + var writer = ts.getSingleLineStringWriter(); + checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); + var result_7 = writer.string(); + ts.releaseStringWriter(writer); + return result_7; + } + } + return ""; + } + function pushAction(result, insertion, description) { + var newAction = { + description: description, + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }; + result.push(newAction); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + function getActionForClassLikeMissingAbstractMember(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + // This is the identifier in the case of a class declaration + // or the class keyword token in the case of a class expression. + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + if (ts.isClassLike(token.parent)) { + var classDecl = token.parent; + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + // Note that this is ultimately derived from a map indexed by symbol names, + // so duplicates cannot occur. + var extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); + var abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); + var insertion = codefix.getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); + if (insertion.length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_inherited_abstract_class), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }]; + } + } + return undefined; + } + function symbolPointsToNonPrivateAndAbstractMember(symbol) { + var decls = symbol.getDeclarations(); + ts.Debug.assert(!!(decls && decls.length > 0)); + var flags = ts.getModifierFlags(decls[0]); + return !(flags & 8 /* Private */) && !!(flags & 128 /* Abstract */); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { codefix.registerCodeFix({ errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], getCodeActions: function (context) { @@ -77409,7 +78332,7 @@ var ts; } } } - var newPosition = getOpenBraceEnd(constructor, sourceFile); + var newPosition = ts.getOpenBraceEnd(constructor, sourceFile); var changes = [{ fileName: sourceFile.fileName, textChanges: [{ newText: superCall.getText(sourceFile), @@ -77425,7 +78348,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -77439,6 +78362,227 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 122 /* ConstructorKeyword */) { + return undefined; + } + var newPosition = ts.getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var classDeclNode = ts.getContainingClass(token); + if (!(token.kind === 70 /* Identifier */ && ts.isClassLike(classDeclNode))) { + return undefined; + } + var heritageClauses = classDeclNode.heritageClauses; + if (!(heritageClauses && heritageClauses.length > 0)) { + return undefined; + } + var extendsToken = heritageClauses[0].getFirstToken(); + if (!(extendsToken && extendsToken.kind === 84 /* ExtendsKeyword */)) { + return undefined; + } + var changeStart = extendsToken.getStart(sourceFile); + var changeEnd = extendsToken.getEnd(); + var textChanges = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + // We replace existing keywords with commas. + for (var i = 1; i < heritageClauses.length; i++) { + var keywordToken = heritageClauses[i].getFirstToken(); + if (keywordToken) { + changeStart = keywordToken.getStart(sourceFile); + changeEnd = keywordToken.getEnd(); + textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + } + } + var result = [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Change_extends_to_implements), + changes: [{ + fileName: sourceFile.fileName, + textChanges: textChanges + }] + }]; + return result; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ + ts.Diagnostics._0_is_declared_but_never_used.code, + ts.Diagnostics.Property_0_is_declared_but_never_used.code + ], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + // this handles var ["computed"] = 12; + if (token.kind === 20 /* OpenBracketToken */) { + token = ts.getTokenAtPosition(sourceFile, start + 1); + } + switch (token.kind) { + case 70 /* Identifier */: + switch (token.parent.kind) { + case 224 /* VariableDeclaration */: + switch (token.parent.parent.parent.kind) { + case 212 /* ForStatement */: + var forStatement = token.parent.parent.parent; + var forInitializer = forStatement.initializer; + if (forInitializer.declarations.length === 1) { + return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); + } + else { + return removeSingleItem(forInitializer.declarations, token); + } + case 214 /* ForOfStatement */: + var forOfStatement = token.parent.parent.parent; + if (forOfStatement.initializer.kind === 225 /* VariableDeclarationList */) { + var forOfInitializer = forOfStatement.initializer; + return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); + } + break; + case 213 /* ForInStatement */: + // There is no valid fix in the case of: + // for .. in + return undefined; + case 257 /* CatchClause */: + var catchClause = token.parent.parent; + var parameter = catchClause.variableDeclaration.getChildren()[0]; + return createCodeFix("", parameter.pos, parameter.end - parameter.pos); + default: + var variableStatement = token.parent.parent.parent; + if (variableStatement.declarationList.declarations.length === 1) { + return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); + } + else { + var declarations = variableStatement.declarationList.declarations; + return removeSingleItem(declarations, token); + } + } + case 143 /* TypeParameter */: + var typeParameters = token.parent.parent.typeParameters; + if (typeParameters.length === 1) { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + } + else { + return removeSingleItem(typeParameters, token); + } + case 144 /* Parameter */: + var functionDeclaration = token.parent.parent; + if (functionDeclaration.parameters.length === 1) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else { + return removeSingleItem(functionDeclaration.parameters, token); + } + // handle case where 'import a = A;' + case 235 /* ImportEqualsDeclaration */: + var importEquals = findImportDeclaration(token); + return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); + case 240 /* ImportSpecifier */: + var namedImports = token.parent.parent; + if (namedImports.elements.length === 1) { + // Only 1 import and it is unused. So the entire declaration should be removed. + var importSpec = findImportDeclaration(token); + return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); + } + else { + return removeSingleItem(namedImports.elements, token); + } + // handle case where "import d, * as ns from './file'" + // or "'import {a, b as ns} from './file'" + case 237 /* ImportClause */: + var importClause = token.parent; + if (!importClause.namedBindings) { + var importDecl = findImportDeclaration(importClause); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); + } + case 238 /* NamespaceImport */: + var namespaceImport = token.parent; + if (namespaceImport.name == token && !namespaceImport.parent.name) { + var importDecl = findImportDeclaration(namespaceImport); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + var start_4 = namespaceImport.parent.name.end; + return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); + } + } + break; + case 147 /* PropertyDeclaration */: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + case 238 /* NamespaceImport */: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + if (ts.isDeclarationName(token)) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else if (ts.isLiteralComputedPropertyDeclarationName(token)) { + return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); + } + else { + return undefined; + } + function findImportDeclaration(token) { + var importDecl = token; + while (importDecl.kind != 236 /* ImportDeclaration */ && importDecl.parent) { + importDecl = importDecl.parent; + } + return importDecl; + } + function createCodeFix(newText, start, length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ newText: newText, span: { start: start, length: length } }] + }] + }]; + } + function removeSingleItem(elements, token) { + if (elements[0] === token.parent) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + } + else { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + } + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -77538,7 +78682,10 @@ var ts; return ImportCodeActionMap; }()); codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Cannot_find_name_0.code], + errorCodes: [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ], getCodeActions: function (context) { var sourceFile = context.sourceFile; var checker = context.program.getTypeChecker(); @@ -77550,6 +78697,11 @@ var ts; // this is a module id -> module import declaration map var cachedImportDeclarations = ts.createMap(); var cachedNewImportInsertPosition; + var currentTokenMeaning = ts.getMeaningFromLocation(token); + if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { + var symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); + return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true); + } var allPotentialModules = checker.getAmbientModules(); for (var _i = 0, allSourceFiles_1 = allSourceFiles; _i < allSourceFiles_1.length; _i++) { var otherSourceFile = allSourceFiles_1[_i]; @@ -77557,7 +78709,6 @@ var ts; allPotentialModules.push(otherSourceFile.symbol); } } - var currentTokenMeaning = ts.getMeaningFromLocation(token); for (var _a = 0, allPotentialModules_1 = allPotentialModules; _a < allPotentialModules_1.length; _a++) { var moduleSymbol = allPotentialModules_1[_a]; context.cancellationToken.throwIfCancellationRequested(); @@ -77597,10 +78748,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 236 /* ImportDeclaration */) { return node; } - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 235 /* ImportEqualsDeclaration */) { return node; } node = node.parent; @@ -77618,7 +78769,7 @@ var ts; var declarations = symbol.getDeclarations(); return declarations ? ts.some(symbol.declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }) : false; } - function getCodeActionForImport(moduleSymbol, isDefault) { + function getCodeActionForImport(moduleSymbol, isDefault, isNamespaceImport) { var existingDeclarations = getImportDeclarations(moduleSymbol); if (existingDeclarations.length > 0) { // With an existing import statement, there are more than one actions the user can do. @@ -77646,9 +78797,9 @@ var ts; var existingModuleSpecifier; for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { var declaration = declarations_11[_i]; - if (declaration.kind === 235 /* ImportDeclaration */) { + if (declaration.kind === 236 /* ImportDeclaration */) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 238 /* NamespaceImport */) { // case: // import * as ns from "foo" namespaceImportDeclaration = declaration; @@ -77672,7 +78823,7 @@ var ts; if (namespaceImportDeclaration) { actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); } - if (namedImportDeclaration && namedImportDeclaration.importClause && + if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause && (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { /** * If the existing import declaration already has a named import list, just @@ -77688,7 +78839,7 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 245 /* ExternalModuleReference */) { + if (declaration.moduleReference && declaration.moduleReference.kind === 246 /* ExternalModuleReference */) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); @@ -77736,7 +78887,7 @@ var ts; } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 235 /* ImportDeclaration */) { + if (declaration.kind === 236 /* ImportDeclaration */) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -77773,7 +78924,9 @@ var ts; var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); var importStatementText = isDefault ? "import " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" - : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; + : isNamespaceImport + ? "import * as " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" + : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; // if this file doesn't have any import statements, insert an import statement and then insert a new line // between the only import statement and user code. Otherwise just insert the statement because chances // are there are already a new line seperating code and import statements. @@ -77793,7 +78946,7 @@ var ts; tryGetModuleNameAsNodeModule() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 261 /* SourceFile */) { + if (moduleSymbol.valueDeclaration.kind !== 262 /* SourceFile */) { return moduleSymbol.name; } } @@ -77806,6 +78959,7 @@ var ts; if (!relativeName) { return undefined; } + var relativeNameWithIndex = ts.removeFileExtension(relativeName); relativeName = removeExtensionAndIndexPostFix(relativeName); if (options.paths) { for (var key in options.paths) { @@ -77825,7 +78979,7 @@ var ts; return key.replace("\*", matchedStar); } } - else if (pattern === relativeName) { + else if (pattern === relativeName || pattern === relativeNameWithIndex) { return key; } } @@ -77947,156 +79101,149 @@ var ts; (function (ts) { var codefix; (function (codefix) { - codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics._0_is_declared_but_never_used.code, - ts.Diagnostics.Property_0_is_declared_but_never_used.code - ], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var start = context.span.start; - var token = ts.getTokenAtPosition(sourceFile, start); - // this handles var ["computed"] = 12; - if (token.kind === 20 /* OpenBracketToken */) { - token = ts.getTokenAtPosition(sourceFile, start + 1); - } - switch (token.kind) { - case 70 /* Identifier */: - switch (token.parent.kind) { - case 223 /* VariableDeclaration */: - switch (token.parent.parent.parent.kind) { - case 211 /* ForStatement */: - var forStatement = token.parent.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); - } - else { - return removeSingleItem(forInitializer.declarations, token); - } - case 213 /* ForOfStatement */: - var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 224 /* VariableDeclarationList */) { - var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); - } - break; - case 212 /* ForInStatement */: - // There is no valid fix in the case of: - // for .. in - return undefined; - case 256 /* CatchClause */: - var catchClause = token.parent.parent; - var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); - default: - var variableStatement = token.parent.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); - } - else { - var declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); - } - } - case 143 /* TypeParameter */: - var typeParameters = token.parent.parent.typeParameters; - if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); - } - else { - return removeSingleItem(typeParameters, token); - } - case 144 /* Parameter */: - var functionDeclaration = token.parent.parent; - if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else { - return removeSingleItem(functionDeclaration.parameters, token); - } - // handle case where 'import a = A;' - case 234 /* ImportEqualsDeclaration */: - var importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); - case 239 /* ImportSpecifier */: - var namedImports = token.parent.parent; - if (namedImports.elements.length === 1) { - // Only 1 import and it is unused. So the entire declaration should be removed. - var importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); - } - else { - return removeSingleItem(namedImports.elements, token); - } - // handle case where "import d, * as ns from './file'" - // or "'import {a, b as ns} from './file'" - case 236 /* ImportClause */: - var importClause = token.parent; - if (!importClause.namedBindings) { - var importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); - } - case 237 /* NamespaceImport */: - var namespaceImport = token.parent; - if (namespaceImport.name == token && !namespaceImport.parent.name) { - var importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - var start_4 = namespaceImport.parent.name.end; - return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); - } - } - break; - case 147 /* PropertyDeclaration */: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case 237 /* NamespaceImport */: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - if (ts.isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); - } - else { - return undefined; - } - function findImportDeclaration(token) { - var importDecl = token; - while (importDecl.kind != 235 /* ImportDeclaration */ && importDecl.parent) { - importDecl = importDecl.parent; + /** + * Finds members of the resolved type that are missing in the class pointed to by class decl + * and generates source code for the missing members. + * @param possiblyMissingSymbols The collection of symbols to filter and then get insertions for. + * @returns Empty string iff there are no member insertions. + */ + function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { + var classMembers = classDeclaration.symbol.members; + var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !(symbol.getName() in classMembers); }); + var insertion = ""; + for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { + var symbol = missingMembers_1[_i]; + insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + } + return insertion; + } + codefix.getMissingMembersInsertion = getMissingMembersInsertion; + /** + * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. + */ + function getInsertionForMemberSymbol(symbol, enclosingDeclaration, checker, newlineChar) { + // const name = symbol.getName(); + var type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + var declarations = symbol.getDeclarations(); + if (!(declarations && declarations.length)) { + return ""; + } + var declaration = declarations[0]; + var name = declaration.name ? declaration.name.getText() : undefined; + var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); + switch (declaration.kind) { + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 146 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + var typeString = checker.typeToString(type, enclosingDeclaration, 0 /* None */); + return "" + visibility + name + ": " + typeString + ";" + newlineChar; + case 148 /* MethodSignature */: + case 149 /* MethodDeclaration */: + // The signature for the implementation appears as an entry in `signatures` iff + // there is only one signature. + // If there are overloads and an implementation signature, it appears as an + // extra declaration that isn't a signature for `type`. + // If there is more than one overload but no implementation signature + // (eg: an abstract method or interface declaration), there is a 1-1 + // correspondence of declarations and signatures. + var signatures = checker.getSignaturesOfType(type, 0 /* Call */); + if (!(signatures && signatures.length > 0)) { + return ""; } - return importDecl; - } - function createCodeFix(newText, start, length) { - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText: newText, span: { start: start, length: length } }] - }] - }]; - } - function removeSingleItem(elements, token) { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + if (declarations.length === 1) { + ts.Debug.assert(signatures.length === 1); + var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar); + } + var result = ""; + for (var i = 0; i < signatures.length; i++) { + var sigString_2 = checker.signatureToString(signatures[i], enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + result += "" + visibility + name + sigString_2 + ";" + newlineChar; + } + // If there is a declaration with a body, it is the last declaration, + // and it isn't caught by `getSignaturesOfType`. + var bodySig = undefined; + if (declarations.length > signatures.length) { + bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); } else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + ts.Debug.assert(declarations.length === signatures.length); + bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); } + var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar); + return result; + default: + return ""; + } + } + function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { + var newSignatureDeclaration = ts.createNode(153 /* CallSignature */); + newSignatureDeclaration.parent = enclosingDeclaration; + newSignatureDeclaration.name = signatures[0].getDeclaration().name; + var maxNonRestArgs = -1; + var maxArgsIndex = 0; + var minArgumentCount = signatures[0].minArgumentCount; + var hasRestParameter = false; + for (var i = 0; i < signatures.length; i++) { + var sig = signatures[i]; + minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); + hasRestParameter = hasRestParameter || sig.hasRestParameter; + var nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); + if (nonRestLength > maxNonRestArgs) { + maxNonRestArgs = nonRestLength; + maxArgsIndex = i; } } - }); + var maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(function (symbol) { return symbol.getName(); }); + var optionalToken = ts.createToken(54 /* QuestionToken */); + newSignatureDeclaration.parameters = ts.createNodeArray(); + for (var i = 0; i < maxNonRestArgs; i++) { + var newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); + newSignatureDeclaration.parameters.push(newParameter); + } + if (hasRestParameter) { + var restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); + restParameter.dotDotDotToken = ts.createToken(23 /* DotDotDotToken */); + newSignatureDeclaration.parameters.push(restParameter); + } + return checker.getSignatureFromDeclaration(newSignatureDeclaration); + function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { + var newParameter = ts.createNode(144 /* Parameter */); + newParameter.symbol = new SymbolConstructor(1 /* FunctionScopedVariable */, maxArgsParameterSymbolNames[index] || "rest"); + newParameter.symbol.valueDeclaration = newParameter; + newParameter.symbol.declarations = [newParameter]; + newParameter.parent = enclosingSignatureDeclaration; + if (index >= minArgCount) { + newParameter.questionToken = optionalToken; + } + return newParameter; + } + } + function getMethodBodyStub(newLineChar) { + return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar; + } + function getVisibilityPrefix(flags) { + if (flags & 4 /* Public */) { + return "public "; + } + else if (flags & 16 /* Protected */) { + return "protected "; + } + return ""; + } + var SymbolConstructor = ts.objectAllocator.getSymbolConstructor(); })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); -/// -/// -/// +/// +/// +/// +/// +/// +/// +/// +/// /// /// /// @@ -78122,7 +79269,7 @@ var ts; /// /// /// -/// +/// /// var ts; (function (ts) { @@ -78187,7 +79334,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(292 /* SyntaxList */, nodes.pos, nodes.end, this); + var list = createNode(293 /* SyntaxList */, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -78210,7 +79357,7 @@ var ts; ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 278 /* FirstJSDocTagNode */ && this.kind <= 291 /* LastJSDocTagNode */; + var useJSDocScanner_1 = this.kind >= 279 /* FirstJSDocTagNode */ && this.kind <= 292 /* LastJSDocTagNode */; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -78489,9 +79636,9 @@ var ts; } function getDeclarationName(declaration) { if (declaration.name) { - var result_7 = getTextOfIdentifierOrLiteral(declaration.name); - if (result_7 !== undefined) { - return result_7; + var result_8 = getTextOfIdentifierOrLiteral(declaration.name); + if (result_8 !== undefined) { + return result_8; } if (declaration.name.kind === 142 /* ComputedPropertyName */) { var expr = declaration.name.expression; @@ -78515,7 +79662,7 @@ var ts; } function visit(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -78538,18 +79685,18 @@ var ts; } ts.forEachChild(node, visit); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: - case 234 /* ImportEqualsDeclaration */: - case 236 /* ImportClause */: - case 237 /* NamespaceImport */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 230 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 244 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: + case 235 /* ImportEqualsDeclaration */: + case 237 /* ImportClause */: + case 238 /* NamespaceImport */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 161 /* TypeLiteral */: @@ -78562,7 +79709,7 @@ var ts; break; } // fall through - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { @@ -78572,19 +79719,19 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 260 /* EnumMember */: + case 261 /* EnumMember */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: addDeclaration(node); break; - case 241 /* ExportDeclaration */: + case 242 /* 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 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -78596,7 +79743,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 238 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -79297,7 +80444,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 === 230 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 231 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -79529,7 +80676,7 @@ var ts; continue; } var descriptor = undefined; - for (var i = 0, n = descriptors.length; i < n; i++) { + for (var i = 0; i < descriptors.length; i++) { if (matchArray[i + firstDescriptorCaptureIndex]) { descriptor = descriptors[i]; } @@ -79683,7 +80830,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 === 245 /* ExternalModuleReference */ || + node.parent.kind === 246 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -79787,16 +80934,16 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: return spanInVariableDeclaration(node); case 144 /* Parameter */: return spanInParameterDeclaration(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: @@ -79805,85 +80952,85 @@ var ts; case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 204 /* Block */: + case 205 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return spanInBlock(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return spanInBlock(node.block); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 209 /* DoStatement */: + case 210 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 222 /* DebuggerStatement */: + case 223 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 208 /* IfStatement */: + case 209 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: + case 216 /* BreakStatement */: + case 215 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return spanInForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 254 /* CaseClause */: + case 255 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 221 /* TryStatement */: + case 222 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 261 /* EnumMember */: case 174 /* BindingElement */: // span on complete node return textSpan(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: // span in statement return spanInNode(node.statement); case 145 /* Decorator */: @@ -79892,8 +81039,8 @@ var ts; case 173 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: return undefined; // Tokens: case 24 /* SemicolonToken */: @@ -79937,8 +81084,8 @@ var ts; // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern if ((node.kind === 70 /* Identifier */ || node.kind == 196 /* SpreadElement */ || - node.kind === 257 /* PropertyAssignment */ || - node.kind === 258 /* ShorthandPropertyAssignment */) && + node.kind === 258 /* PropertyAssignment */ || + node.kind === 259 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } @@ -79965,14 +81112,14 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 209 /* DoStatement */: + case 210 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); case 145 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 212 /* ForStatement */: + case 214 /* ForOfStatement */: return textSpan(node); case 192 /* BinaryExpression */: if (node.parent.operatorToken.kind === 25 /* CommaToken */) { @@ -79989,7 +81136,7 @@ var ts; } } // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 257 /* PropertyAssignment */ && + if (node.parent.kind === 258 /* PropertyAssignment */ && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); @@ -80003,7 +81150,7 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 223 /* VariableDeclaration */ || + if ((node.parent.kind === 224 /* VariableDeclaration */ || node.parent.kind === 144 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || @@ -80038,7 +81185,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 212 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 213 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -80049,7 +81196,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 213 /* ForOfStatement */) { + variableDeclaration.parent.parent.kind === 214 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -80089,7 +81236,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 226 /* ClassDeclaration */ && functionDeclaration.kind !== 150 /* Constructor */); + (functionDeclaration.parent.kind === 227 /* ClassDeclaration */ && functionDeclaration.kind !== 150 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -80112,25 +81259,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 210 /* WhileStatement */: - case 208 /* IfStatement */: - case 212 /* ForInStatement */: + case 211 /* WhileStatement */: + case 209 /* IfStatement */: + case 213 /* ForInStatement */: 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 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 212 /* ForStatement */: + case 214 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 224 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 225 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -80184,13 +81331,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -80198,24 +81345,24 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 229 /* EnumDeclaration */: - case 226 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 204 /* Block */: + case 205 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through - case 256 /* CatchClause */: + case 257 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -80254,7 +81401,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 209 /* DoStatement */ || + if (node.parent.kind === 210 /* DoStatement */ || node.parent.kind === 179 /* CallExpression */ || node.parent.kind === 180 /* NewExpression */) { return spanInPreviousNode(node); @@ -80269,17 +81416,17 @@ var ts; // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 150 /* Constructor */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 211 /* WhileStatement */: + case 210 /* DoStatement */: + case 212 /* ForStatement */: + case 214 /* ForOfStatement */: case 179 /* CallExpression */: case 180 /* NewExpression */: case 183 /* ParenthesizedExpression */: @@ -80292,7 +81439,7 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 257 /* PropertyAssignment */ || + node.parent.kind === 258 /* PropertyAssignment */ || node.parent.kind === 144 /* Parameter */) { return spanInPreviousNode(node); } @@ -80305,7 +81452,7 @@ var ts; return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 209 /* DoStatement */) { + if (node.parent.kind === 210 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -80313,7 +81460,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 213 /* ForOfStatement */) { + if (node.parent.kind === 214 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -81102,7 +82249,7 @@ var ts; this._shims.push(shim); }; TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { + for (var i = 0; i < this._shims.length; i++) { if (this._shims[i] === shim) { delete this._shims[i]; return; diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index e11c200ef44..24ec0a740ca 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -239,102 +239,102 @@ declare namespace ts { ExpressionWithTypeArguments = 199, AsExpression = 200, NonNullExpression = 201, - TemplateSpan = 202, - SemicolonClassElement = 203, - Block = 204, - VariableStatement = 205, - EmptyStatement = 206, - ExpressionStatement = 207, - IfStatement = 208, - DoStatement = 209, - WhileStatement = 210, - ForStatement = 211, - ForInStatement = 212, - ForOfStatement = 213, - ContinueStatement = 214, - BreakStatement = 215, - ReturnStatement = 216, - WithStatement = 217, - SwitchStatement = 218, - LabeledStatement = 219, - ThrowStatement = 220, - TryStatement = 221, - DebuggerStatement = 222, - VariableDeclaration = 223, - VariableDeclarationList = 224, - FunctionDeclaration = 225, - ClassDeclaration = 226, - InterfaceDeclaration = 227, - TypeAliasDeclaration = 228, - EnumDeclaration = 229, - ModuleDeclaration = 230, - ModuleBlock = 231, - CaseBlock = 232, - NamespaceExportDeclaration = 233, - ImportEqualsDeclaration = 234, - ImportDeclaration = 235, - ImportClause = 236, - NamespaceImport = 237, - NamedImports = 238, - ImportSpecifier = 239, - ExportAssignment = 240, - ExportDeclaration = 241, - NamedExports = 242, - ExportSpecifier = 243, - MissingDeclaration = 244, - ExternalModuleReference = 245, - JsxElement = 246, - JsxSelfClosingElement = 247, - JsxOpeningElement = 248, - JsxClosingElement = 249, - JsxAttribute = 250, - JsxSpreadAttribute = 251, - JsxExpression = 252, - CaseClause = 253, - DefaultClause = 254, - HeritageClause = 255, - CatchClause = 256, - PropertyAssignment = 257, - ShorthandPropertyAssignment = 258, - SpreadAssignment = 259, - EnumMember = 260, - SourceFile = 261, - JSDocTypeExpression = 262, - JSDocAllType = 263, - JSDocUnknownType = 264, - JSDocArrayType = 265, - JSDocUnionType = 266, - JSDocTupleType = 267, - JSDocNullableType = 268, - JSDocNonNullableType = 269, - JSDocRecordType = 270, - JSDocRecordMember = 271, - JSDocTypeReference = 272, - JSDocOptionalType = 273, - JSDocFunctionType = 274, - JSDocVariadicType = 275, - JSDocConstructorType = 276, - JSDocThisType = 277, - JSDocComment = 278, - JSDocTag = 279, - JSDocAugmentsTag = 280, - JSDocParameterTag = 281, - JSDocReturnTag = 282, - JSDocTypeTag = 283, - JSDocTemplateTag = 284, - JSDocTypedefTag = 285, - JSDocPropertyTag = 286, - JSDocTypeLiteral = 287, - JSDocLiteralType = 288, - JSDocNullKeyword = 289, - JSDocUndefinedKeyword = 290, - JSDocNeverKeyword = 291, - SyntaxList = 292, - NotEmittedStatement = 293, - PartiallyEmittedExpression = 294, - MergeDeclarationMarker = 295, - EndOfDeclarationMarker = 296, - RawExpression = 297, + MetaProperty = 202, + TemplateSpan = 203, + SemicolonClassElement = 204, + Block = 205, + VariableStatement = 206, + EmptyStatement = 207, + ExpressionStatement = 208, + IfStatement = 209, + DoStatement = 210, + WhileStatement = 211, + ForStatement = 212, + ForInStatement = 213, + ForOfStatement = 214, + ContinueStatement = 215, + BreakStatement = 216, + ReturnStatement = 217, + WithStatement = 218, + SwitchStatement = 219, + LabeledStatement = 220, + ThrowStatement = 221, + TryStatement = 222, + DebuggerStatement = 223, + VariableDeclaration = 224, + VariableDeclarationList = 225, + FunctionDeclaration = 226, + ClassDeclaration = 227, + InterfaceDeclaration = 228, + TypeAliasDeclaration = 229, + EnumDeclaration = 230, + ModuleDeclaration = 231, + ModuleBlock = 232, + CaseBlock = 233, + NamespaceExportDeclaration = 234, + ImportEqualsDeclaration = 235, + ImportDeclaration = 236, + ImportClause = 237, + NamespaceImport = 238, + NamedImports = 239, + ImportSpecifier = 240, + ExportAssignment = 241, + ExportDeclaration = 242, + NamedExports = 243, + ExportSpecifier = 244, + MissingDeclaration = 245, + ExternalModuleReference = 246, + JsxElement = 247, + JsxSelfClosingElement = 248, + JsxOpeningElement = 249, + JsxClosingElement = 250, + JsxAttribute = 251, + JsxSpreadAttribute = 252, + JsxExpression = 253, + CaseClause = 254, + DefaultClause = 255, + HeritageClause = 256, + CatchClause = 257, + PropertyAssignment = 258, + ShorthandPropertyAssignment = 259, + SpreadAssignment = 260, + EnumMember = 261, + SourceFile = 262, + JSDocTypeExpression = 263, + JSDocAllType = 264, + JSDocUnknownType = 265, + JSDocArrayType = 266, + JSDocUnionType = 267, + JSDocTupleType = 268, + JSDocNullableType = 269, + JSDocNonNullableType = 270, + JSDocRecordType = 271, + JSDocRecordMember = 272, + JSDocTypeReference = 273, + JSDocOptionalType = 274, + JSDocFunctionType = 275, + JSDocVariadicType = 276, + JSDocConstructorType = 277, + JSDocThisType = 278, + JSDocComment = 279, + JSDocTag = 280, + JSDocAugmentsTag = 281, + JSDocParameterTag = 282, + JSDocReturnTag = 283, + JSDocTypeTag = 284, + JSDocTemplateTag = 285, + JSDocTypedefTag = 286, + JSDocPropertyTag = 287, + JSDocTypeLiteral = 288, + JSDocLiteralType = 289, + JSDocNullKeyword = 290, + JSDocUndefinedKeyword = 291, + JSDocNeverKeyword = 292, + SyntaxList = 293, + NotEmittedStatement = 294, + PartiallyEmittedExpression = 295, + MergeDeclarationMarker = 296, + EndOfDeclarationMarker = 297, Count = 298, FirstAssignment = 57, LastAssignment = 69, @@ -361,10 +361,10 @@ declare namespace ts { FirstBinaryOperator = 26, LastBinaryOperator = 69, FirstNode = 141, - FirstJSDocNode = 262, - LastJSDocNode = 288, - FirstJSDocTagNode = 278, - LastJSDocTagNode = 291, + FirstJSDocNode = 263, + LastJSDocNode = 289, + FirstJSDocTagNode = 279, + LastJSDocTagNode = 292, } enum NodeFlags { None = 0, @@ -969,6 +969,11 @@ declare namespace ts { kind: SyntaxKind.NonNullExpression; expression: Expression; } + interface MetaProperty extends PrimaryExpression { + kind: SyntaxKind.MetaProperty; + keywordToken: SyntaxKind; + name: Identifier; + } interface JsxElement extends PrimaryExpression { kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; @@ -1003,6 +1008,7 @@ declare namespace ts { } interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; + dotDotDotToken?: Token; expression?: Expression; } interface JsxText extends Node { @@ -1022,7 +1028,7 @@ declare namespace ts { kind: SyntaxKind.MissingDeclaration; name?: Identifier; } - type BlockLike = SourceFile | Block | ModuleBlock | CaseClause; + type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; @@ -1569,6 +1575,7 @@ declare namespace ts { getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol; + getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; getBaseTypes(type: InterfaceType): ObjectType[]; @@ -1581,6 +1588,8 @@ declare namespace ts { getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol; getTypeAtLocation(node: Node): Type; + getTypeFromTypeNode(node: TypeNode): Type; + signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string; typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; getSymbolDisplayBuilder(): SymbolDisplayBuilder; @@ -1603,11 +1612,13 @@ declare namespace ts { isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; + getApparentType(type: Type): Type; } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; + buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1645,6 +1656,7 @@ declare namespace ts { InFirstTypeArgument = 256, InTypeAlias = 512, UseTypeAliasValue = 1024, + SuppressAnyReturnType = 2048, } enum SymbolFormatFlags { None = 0, @@ -1815,6 +1827,7 @@ declare namespace ts { interface ObjectType extends Type { objectFlags: ObjectFlags; } + /** Class and interface types (TypeFlags.Class and TypeFlags.Interface). */ interface InterfaceType extends ObjectType { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; @@ -1828,6 +1841,16 @@ declare namespace ts { declaredStringIndexInfo: IndexInfo; declaredNumberIndexInfo: IndexInfo; } + /** + * Type references (TypeFlags.Reference). When a class or interface has type parameters or + * a "this" type, references to the class or interface are made using type references. The + * typeArguments property specifies the types to substitute for the type parameters of the + * class or interface and optionally includes an extra element that specifies the type to + * substitute for "this" in the resulting instantiation. When no extra argument is present, + * the type reference itself is substituted for "this". The typeArguments property is undefined + * if the class or interface has no type parameters and the reference isn't specifying an + * explicit "this" argument. + */ interface TypeReference extends ObjectType { target: GenericType; typeArguments: Type[]; @@ -2106,7 +2129,6 @@ declare namespace ts { } interface ResolvedModuleWithFailedLookupLocations { resolvedModule: ResolvedModuleFull | undefined; - failedLookupLocations: string[]; } interface ResolvedTypeReferenceDirective { primary: boolean; @@ -2325,9 +2347,28 @@ declare namespace ts { * this list is only the set of defaults that are implicitly included. */ function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + /** + * Cached module resolutions per containing directory. + * This assumes that any module id will have the same resolution for sibling files located in the same folder. + */ + interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { + getOrCreateCacheForDirectory(directoryName: string): Map; + } + /** + * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory + * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. + */ + interface NonRelativeModuleNameResolutionCache { + getOrCreateCacheForModuleName(nonRelativeModuleName: string): PerModuleNameCache; + } + interface PerModuleNameCache { + get(directory: string): ResolvedModuleWithFailedLookupLocations; + set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; + } + function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): ModuleResolutionCache; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; @@ -2674,6 +2715,7 @@ declare namespace ts { InsertSpaceAfterCommaDelimiter: boolean; InsertSpaceAfterSemicolonInForStatements: boolean; InsertSpaceBeforeAndAfterBinaryOperators: boolean; + InsertSpaceAfterConstructor?: boolean; InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; @@ -2682,6 +2724,7 @@ declare namespace ts { InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; InsertSpaceAfterTypeAssertion?: boolean; + InsertSpaceBeforeFunctionParenthesis?: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; } @@ -2689,6 +2732,7 @@ declare namespace ts { insertSpaceAfterCommaDelimiter?: boolean; insertSpaceAfterSemicolonInForStatements?: boolean; insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterConstructor?: boolean; insertSpaceAfterKeywordsInControlFlowStatements?: boolean; insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; @@ -2697,6 +2741,7 @@ declare namespace ts { insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; insertSpaceAfterTypeAssertion?: boolean; + insertSpaceBeforeFunctionParenthesis?: boolean; placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; } diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 7f41e5d07f5..bae2811e4de 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -13,11 +13,16 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ts; (function (ts) { // token > SyntaxKind.Identifer => token is a keyword @@ -244,115 +249,115 @@ var ts; SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 199] = "ExpressionWithTypeArguments"; SyntaxKind[SyntaxKind["AsExpression"] = 200] = "AsExpression"; SyntaxKind[SyntaxKind["NonNullExpression"] = 201] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 202] = "MetaProperty"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 202] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 203] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 203] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 204] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 204] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 205] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 206] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 207] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 208] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 209] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 210] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 211] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 212] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 213] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 214] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 215] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 216] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 217] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 218] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 219] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 220] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 221] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 222] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 223] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 224] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 225] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 226] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 227] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 228] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 229] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 230] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 231] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 232] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 233] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 234] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 235] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 236] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 237] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 238] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 239] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 240] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 241] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 242] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 243] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 244] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 205] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 206] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 207] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 208] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 209] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 210] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 211] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 212] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 213] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 214] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 215] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 216] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 217] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 218] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 219] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 220] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 221] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 222] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 223] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 225] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 226] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 227] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 228] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 229] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 230] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 231] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 232] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 233] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 234] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 235] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 236] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 237] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 238] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 239] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 240] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 241] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 242] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 243] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 244] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 245] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 246] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 246] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 247] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 248] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 249] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 250] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 251] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 252] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 247] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 248] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 249] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 250] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 251] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 252] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 253] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 253] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 254] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 255] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 256] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 254] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 255] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 256] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 257] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 257] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 258] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 259] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 258] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 259] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 260] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 260] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 261] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 261] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 262] = "SourceFile"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 262] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 263] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 263] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 264] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 264] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 265] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 266] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 267] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 268] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 269] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 270] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 271] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 272] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 273] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 274] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 275] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 276] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 277] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 278] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 279] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 280] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 281] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 282] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 283] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 284] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 285] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 286] = "JSDocPropertyTag"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 287] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocLiteralType"] = 288] = "JSDocLiteralType"; - SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 289] = "JSDocNullKeyword"; - SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 290] = "JSDocUndefinedKeyword"; - SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 291] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 265] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 266] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 267] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 268] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 269] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 270] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 271] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 272] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 273] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 274] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 275] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 276] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 277] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 278] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 279] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 280] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 281] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 282] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 283] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 284] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 285] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 286] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 287] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 288] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 289] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 290] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 291] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 292] = "JSDocNeverKeyword"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 292] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 293] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 293] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 294] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 295] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 296] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["RawExpression"] = 297] = "RawExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 294] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 295] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 296] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 297] = "EndOfDeclarationMarker"; // Enum value count SyntaxKind[SyntaxKind["Count"] = 298] = "Count"; // Markers @@ -381,10 +386,10 @@ var ts; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; SyntaxKind[SyntaxKind["FirstNode"] = 141] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 262] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 288] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 278] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 291] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 263] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 289] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 279] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 292] = "LastJSDocTagNode"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -511,6 +516,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 2048] = "SuppressAnyReturnType"; })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -647,6 +653,7 @@ var ts; NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["CaptureNewTarget"] = 8] = "CaptureNewTarget"; NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; @@ -1290,7 +1297,7 @@ var ts; */ function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -1314,7 +1321,7 @@ var ts; */ function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -1325,7 +1332,7 @@ var ts; ts.every = every; /** Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. */ function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -1339,7 +1346,7 @@ var ts; * This is like `forEach`, but never returns undefined. */ function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -1362,7 +1369,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -1372,7 +1379,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -2220,6 +2227,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -3915,7 +3923,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_be_declared_in_an_ambient_context_1086", message: "An accessor cannot be declared in an ambient context." }, _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", message: "'{0}' modifier cannot appear on a constructor declaration." }, _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_parameter_1090", message: "'{0}' modifier cannot appear on a parameter." }, @@ -4072,6 +4080,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "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_2301", message: "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_2302", message: "Static members cannot reference class type parameters." }, @@ -4301,6 +4310,8 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "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: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -4310,6 +4321,7 @@ var ts; Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "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: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -4361,6 +4373,8 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "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_4002", message: "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_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -4529,6 +4543,7 @@ var ts; Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -4542,10 +4557,10 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, @@ -4594,6 +4609,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -4650,22 +4667,25 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); /// @@ -5132,7 +5152,7 @@ var ts; if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { var ch = text.charCodeAt(pos); if ((pos + mergeConflictMarkerLength) < text.length) { - for (var i = 0, n = mergeConflictMarkerLength; i < n; i++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -5344,7 +5364,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -6524,7 +6544,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 261 /* SourceFile */) { + while (node && node.kind !== 262 /* SourceFile */) { node = node.parent; } return node; @@ -6532,11 +6552,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 204 /* Block */: - case 232 /* CaseBlock */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 205 /* Block */: + case 233 /* CaseBlock */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: return true; } return false; @@ -6627,18 +6647,18 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 292 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 293 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 262 /* FirstJSDocNode */ && node.kind <= 288 /* LastJSDocNode */; + return node.kind >= 263 /* FirstJSDocNode */ && node.kind <= 289 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 278 /* FirstJSDocTagNode */ && node.kind <= 291 /* LastJSDocTagNode */; + return node.kind >= 279 /* FirstJSDocTagNode */ && node.kind <= 292 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -6742,11 +6762,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 223 /* VariableDeclaration */ && node.parent.kind === 256 /* CatchClause */; + return node.kind === 224 /* VariableDeclaration */ && node.parent.kind === 257 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 230 /* ModuleDeclaration */ && + return node && node.kind === 231 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -6757,11 +6777,11 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node.kind === 230 /* ModuleDeclaration */ && (!node.body); + return node.kind === 231 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 261 /* SourceFile */ || - node.kind === 230 /* ModuleDeclaration */ || + return node.kind === 262 /* SourceFile */ || + node.kind === 231 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6777,9 +6797,9 @@ var ts; return false; } switch (node.parent.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: return ts.isExternalModule(node.parent); - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6791,22 +6811,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 261 /* SourceFile */: - case 232 /* CaseBlock */: - case 256 /* CatchClause */: - case 230 /* ModuleDeclaration */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 262 /* SourceFile */: + case 233 /* CaseBlock */: + case 257 /* CatchClause */: + case 231 /* ModuleDeclaration */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: case 150 /* Constructor */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: return true; - case 204 /* Block */: + case 205 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -6891,7 +6911,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 204 /* Block */) { + if (node.body && node.body.kind === 205 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6905,7 +6925,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -6914,20 +6934,20 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: - case 225 /* FunctionDeclaration */: + case 228 /* InterfaceDeclaration */: + case 231 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: + case 261 /* EnumMember */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: errorNode = node.name; break; case 185 /* ArrowFunction */: @@ -6953,7 +6973,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 229 /* EnumDeclaration */ && isConst(node); + return node.kind === 230 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -6970,7 +6990,7 @@ var ts; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 207 /* ExpressionStatement */ + return node.kind === 208 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -7053,9 +7073,9 @@ var ts; case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: case 144 /* Parameter */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return node === parent_1.type; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 150 /* Constructor */: @@ -7081,29 +7101,43 @@ var ts; return false; } ts.isPartOfTypeNode = isPartOfTypeNode; + function isChildOfNodeWithKind(node, kind) { + while (node) { + if (node.kind === kind) { + return true; + } + node = node.parent; + } + return false; + } + ts.isChildOfNodeWithKind = isChildOfNodeWithKind; + function isPrefixUnaryExpression(node) { + return node.kind === 190 /* PrefixUnaryExpression */; + } + ts.isPrefixUnaryExpression = isPrefixUnaryExpression; // Warning: This has the same semantics as the forEach family of functions, // in that traversal terminates in the event that 'visitor' supplies a truthy value. function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return visitor(node); - case 232 /* CaseBlock */: - case 204 /* Block */: - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 217 /* WithStatement */: - case 218 /* SwitchStatement */: - case 253 /* CaseClause */: - case 254 /* DefaultClause */: - case 219 /* LabeledStatement */: - case 221 /* TryStatement */: - case 256 /* CatchClause */: + case 233 /* CaseBlock */: + case 205 /* Block */: + case 209 /* IfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 218 /* WithStatement */: + case 219 /* SwitchStatement */: + case 254 /* CaseClause */: + case 255 /* DefaultClause */: + case 220 /* LabeledStatement */: + case 222 /* TryStatement */: + case 257 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -7119,11 +7153,11 @@ var ts; if (operand) { traverse(operand); } - case 229 /* EnumDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 226 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 228 /* InterfaceDeclaration */: + case 231 /* ModuleDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* 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 @@ -7170,13 +7204,13 @@ var ts; if (node) { switch (node.kind) { case 174 /* BindingElement */: - case 260 /* EnumMember */: + case 261 /* EnumMember */: case 144 /* Parameter */: - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 258 /* ShorthandPropertyAssignment */: - case 223 /* VariableDeclaration */: + case 259 /* ShorthandPropertyAssignment */: + case 224 /* VariableDeclaration */: return true; } } @@ -7188,7 +7222,7 @@ var ts; } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 226 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */); + return node && (node.kind === 227 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7199,7 +7233,7 @@ var ts; switch (kind) { case 150 /* Constructor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -7222,7 +7256,7 @@ var ts; case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: return true; } @@ -7231,20 +7265,32 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: return true; - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; + function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + while (true) { + if (beforeUnwrapLabelCallback) { + beforeUnwrapLabelCallback(node); + } + if (node.statement.kind !== 220 /* LabeledStatement */) { + return node.statement; + } + node = node.statement; + } + } + ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 204 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 205 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { @@ -7323,9 +7369,9 @@ var ts; continue; } // Fall through - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: case 149 /* MethodDeclaration */: @@ -7336,13 +7382,26 @@ var ts; case 153 /* CallSignature */: case 154 /* ConstructSignature */: case 155 /* IndexSignature */: - case 229 /* EnumDeclaration */: - case 261 /* SourceFile */: + case 230 /* EnumDeclaration */: + case 262 /* SourceFile */: return node; } } } ts.getThisContainer = getThisContainer; + function getNewTargetContainer(node) { + var container = getThisContainer(node, /*includeArrowFunctions*/ false); + if (container) { + switch (container.kind) { + case 150 /* Constructor */: + case 226 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + return container; + } + } + return undefined; + } + ts.getNewTargetContainer = getNewTargetContainer; /** * Given an super call/property node, returns the closest node where * - a super call/property access is legal in the node and not legal in the parent node the node. @@ -7361,7 +7420,7 @@ var ts; case 142 /* ComputedPropertyName */: node = node.parent; break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: if (!stopOnFunctions) { @@ -7418,7 +7477,7 @@ var ts; function getEntityNameFromTypeNode(node) { switch (node.kind) { case 157 /* TypeReference */: - case 272 /* JSDocTypeReference */: + case 273 /* JSDocTypeReference */: return node.typeName; case 199 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) @@ -7453,25 +7512,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: // classes are valid targets return true; case 147 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 226 /* ClassDeclaration */; + return node.parent.kind === 227 /* ClassDeclaration */; case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 149 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && node.parent.kind === 226 /* ClassDeclaration */; + && node.parent.kind === 227 /* ClassDeclaration */; case 144 /* 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 !== undefined && (node.parent.kind === 150 /* Constructor */ || node.parent.kind === 149 /* MethodDeclaration */ || node.parent.kind === 152 /* SetAccessor */) - && node.parent.parent.kind === 226 /* ClassDeclaration */; + && node.parent.parent.kind === 227 /* ClassDeclaration */; } return false; } @@ -7487,7 +7546,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); case 149 /* MethodDeclaration */: case 152 /* SetAccessor */: @@ -7497,9 +7556,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 248 /* JsxOpeningElement */ || - parent.kind === 247 /* JsxSelfClosingElement */ || - parent.kind === 249 /* JsxClosingElement */) { + if (parent.kind === 249 /* JsxOpeningElement */ || + parent.kind === 248 /* JsxSelfClosingElement */ || + parent.kind === 250 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -7538,10 +7597,11 @@ var ts; case 194 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: case 198 /* OmittedExpression */: - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: + case 247 /* JsxElement */: + case 248 /* JsxSelfClosingElement */: case 195 /* YieldExpression */: case 189 /* AwaitExpression */: + case 202 /* MetaProperty */: return true; case 141 /* QualifiedName */: while (node.parent.kind === 141 /* QualifiedName */) { @@ -7558,46 +7618,46 @@ var ts; case 98 /* ThisKeyword */: var parent_3 = node.parent; switch (parent_3.kind) { - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 144 /* Parameter */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 260 /* EnumMember */: - case 257 /* PropertyAssignment */: + case 261 /* EnumMember */: + case 258 /* PropertyAssignment */: case 174 /* BindingElement */: return parent_3.initializer === node; - case 207 /* ExpressionStatement */: - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 216 /* ReturnStatement */: - case 217 /* WithStatement */: - case 218 /* SwitchStatement */: - case 253 /* CaseClause */: - case 220 /* ThrowStatement */: - case 218 /* SwitchStatement */: + case 208 /* ExpressionStatement */: + case 209 /* IfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 217 /* ReturnStatement */: + case 218 /* WithStatement */: + case 219 /* SwitchStatement */: + case 254 /* CaseClause */: + case 221 /* ThrowStatement */: + case 219 /* SwitchStatement */: return parent_3.expression === node; - case 211 /* ForStatement */: + case 212 /* ForStatement */: var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 224 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 225 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 225 /* VariableDeclarationList */) || forInStatement.expression === node; case 182 /* TypeAssertionExpression */: case 200 /* AsExpression */: return node === parent_3.expression; - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return node === parent_3.expression; case 142 /* ComputedPropertyName */: return node === parent_3.expression; case 145 /* Decorator */: - case 252 /* JsxExpression */: - case 251 /* JsxSpreadAttribute */: - case 259 /* SpreadAssignment */: + case 253 /* JsxExpression */: + case 252 /* JsxSpreadAttribute */: + case 260 /* SpreadAssignment */: return true; case 199 /* ExpressionWithTypeArguments */: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); @@ -7617,7 +7677,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 245 /* ExternalModuleReference */; + return node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 246 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7626,7 +7686,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 245 /* ExternalModuleReference */; + return node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 246 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7660,7 +7720,7 @@ var ts; * This function does not test if the node is in a JavaScript file or not. */ function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 223 /* VariableDeclaration */) { + if (s.valueDeclaration && s.valueDeclaration.kind === 224 /* VariableDeclaration */) { var declaration = s.valueDeclaration; return declaration.initializer && declaration.initializer.kind === 184 /* FunctionExpression */; } @@ -7713,35 +7773,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 236 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 235 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 245 /* ExternalModuleReference */) { + if (reference.kind === 246 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 241 /* ExportDeclaration */) { + if (node.kind === 242 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 230 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 231 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 235 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 238 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 235 /* ImportDeclaration */ + return node.kind === 236 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7752,8 +7812,8 @@ var ts; case 144 /* Parameter */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: - case 258 /* ShorthandPropertyAssignment */: - case 257 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: + case 258 /* PropertyAssignment */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: return node.questionToken !== undefined; @@ -7763,9 +7823,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 274 /* JSDocFunctionType */ && + return node.kind === 275 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 276 /* JSDocConstructorType */; + node.parameters[0].type.kind === 277 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { @@ -7778,7 +7838,7 @@ var ts; var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 281 /* JSDocParameterTag */) { + if (doc.kind === 282 /* JSDocParameterTag */) { if (doc.kind === kind) { result.push(doc); } @@ -7810,9 +7870,9 @@ var ts; // var x = function(name) { return name.length; } var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 205 /* VariableStatement */; + parent.parent.parent.kind === 206 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 205 /* VariableStatement */; + parent.parent.kind === 206 /* VariableStatement */; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -7823,13 +7883,13 @@ var ts; var isSourceOfAssignmentExpressionStatement = parent && parent.parent && parent.kind === 192 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && - parent.parent.kind === 207 /* ExpressionStatement */; + parent.parent.kind === 208 /* ExpressionStatement */; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 230 /* ModuleDeclaration */ && - parent && parent.kind === 230 /* ModuleDeclaration */; - var isPropertyAssignmentExpression = parent && parent.kind === 257 /* PropertyAssignment */; + var isModuleDeclaration = node.kind === 231 /* ModuleDeclaration */ && + parent && parent.kind === 231 /* ModuleDeclaration */; + var isPropertyAssignmentExpression = parent && parent.kind === 258 /* PropertyAssignment */; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } @@ -7848,18 +7908,18 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 281 /* JSDocParameterTag */); + var tags = getJSDocTags(func, 282 /* JSDocParameterTag */); if (!param.name) { // this is an anonymous jsdoc param from a `function(type1, type2): type3` specification var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 281 /* JSDocParameterTag */; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 282 /* JSDocParameterTag */; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70 /* Identifier */) { var name_6 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 281 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); + return ts.filter(tags, function (tag) { return tag.kind === 282 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); } else { // TODO: it's a destructured parameter, so it should look up an "object type" series of multiple lines @@ -7869,7 +7929,7 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 283 /* JSDocTypeTag */); + var tag = getFirstJSDocTag(node, 284 /* JSDocTypeTag */); if (!tag && node.kind === 144 /* Parameter */) { var paramTags = getJSDocParameterTags(node); if (paramTags) { @@ -7880,15 +7940,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 280 /* JSDocAugmentsTag */); + return getFirstJSDocTag(node, 281 /* JSDocAugmentsTag */); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 282 /* JSDocReturnTag */); + return getFirstJSDocTag(node, 283 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 284 /* JSDocTemplateTag */); + return getFirstJSDocTag(node, 285 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -7901,8 +7961,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536 /* JavaScriptFile */)) { - if (node.type && node.type.kind === 275 /* JSDocVariadicType */ || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275 /* JSDocVariadicType */; })) { + if (node.type && node.type.kind === 276 /* JSDocVariadicType */ || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 276 /* JSDocVariadicType */; })) { return true; } } @@ -7932,20 +7992,20 @@ var ts; case 191 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 42 /* PlusPlusToken */ || unaryOperator === 43 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; case 183 /* ParenthesizedExpression */: case 175 /* ArrayLiteralExpression */: case 196 /* SpreadElement */: node = parent; break; - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } // Fall through - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: node = parent.parent; break; default: @@ -7962,6 +8022,18 @@ var ts; return getAssignmentTargetKind(node) !== 0 /* None */; } ts.isAssignmentTarget = isAssignmentTarget; + // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped + function isDeleteTarget(node) { + if (node.kind !== 177 /* PropertyAccessExpression */ && node.kind !== 178 /* ElementAccessExpression */) { + return false; + } + node = node.parent; + while (node && node.kind === 183 /* ParenthesizedExpression */) { + node = node.parent; + } + return node && node.kind === 186 /* DeleteExpression */; + } + ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { while (node) { if (node === ancestor) @@ -7973,7 +8045,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2 /* Ambient */) || (node.kind === 261 /* SourceFile */ && node.isDeclarationFile)) { + if (hasModifier(node, 2 /* Ambient */) || (node.kind === 262 /* SourceFile */ && node.isDeclarationFile)) { return true; } node = node.parent; @@ -7987,7 +8059,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 239 /* ImportSpecifier */ || parent.kind === 243 /* ExportSpecifier */) { + if (parent.kind === 240 /* ImportSpecifier */ || parent.kind === 244 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -8014,8 +8086,8 @@ var ts; case 148 /* MethodSignature */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 260 /* EnumMember */: - case 257 /* PropertyAssignment */: + case 261 /* EnumMember */: + case 258 /* PropertyAssignment */: case 177 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; @@ -8029,10 +8101,10 @@ var ts; } return false; case 174 /* BindingElement */: - case 239 /* ImportSpecifier */: + case 240 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 243 /* ExportSpecifier */: + case 244 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -8048,13 +8120,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ || - node.kind === 233 /* NamespaceExportDeclaration */ || - node.kind === 236 /* ImportClause */ && !!node.name || - node.kind === 237 /* NamespaceImport */ || - node.kind === 239 /* ImportSpecifier */ || - node.kind === 243 /* ExportSpecifier */ || - node.kind === 240 /* ExportAssignment */ && exportAssignmentIsAlias(node); + return node.kind === 235 /* ImportEqualsDeclaration */ || + node.kind === 234 /* NamespaceExportDeclaration */ || + node.kind === 237 /* ImportClause */ && !!node.name || + node.kind === 238 /* NamespaceImport */ || + node.kind === 240 /* ImportSpecifier */ || + node.kind === 244 /* ExportSpecifier */ || + node.kind === 241 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8249,13 +8321,13 @@ var ts; var kind = node.kind; return kind === 150 /* Constructor */ || kind === 184 /* FunctionExpression */ - || kind === 225 /* FunctionDeclaration */ + || kind === 226 /* FunctionDeclaration */ || kind === 185 /* ArrowFunction */ || kind === 149 /* MethodDeclaration */ || kind === 151 /* GetAccessor */ || kind === 152 /* SetAccessor */ - || kind === 230 /* ModuleDeclaration */ - || kind === 261 /* SourceFile */; + || kind === 231 /* ModuleDeclaration */ + || kind === 262 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8387,14 +8459,13 @@ var ts; case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 197 /* ClassExpression */: - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: + case 247 /* JsxElement */: + case 248 /* JsxSelfClosingElement */: case 11 /* RegularExpressionLiteral */: case 12 /* NoSubstitutionTemplateLiteral */: case 194 /* TemplateExpression */: case 183 /* ParenthesizedExpression */: case 198 /* OmittedExpression */: - case 297 /* RawExpression */: return 19; case 181 /* TaggedTemplateExpression */: case 177 /* PropertyAccessExpression */: @@ -8578,13 +8649,12 @@ var ts; * Note that this doesn't actually wrap the input in double quotes. */ function escapeString(s) { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; - return s; - function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } + return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; + function getReplacement(c) { + return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); return ch.toLowerCase() === ch; @@ -9638,8 +9708,8 @@ var ts; var parseNode = getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -9660,7 +9730,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 /* ClassDeclaration */ && declaration !== node) { + if (declaration.kind === 227 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9725,6 +9795,10 @@ var ts; return node.kind === 70 /* Identifier */; } ts.isIdentifier = isIdentifier; + function isVoidExpression(node) { + return node.kind === 188 /* VoidExpression */; + } + ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { // Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`. return isIdentifier(node) && node.autoGenerateKind > 0 /* None */; @@ -9797,18 +9871,18 @@ var ts; || kind === 151 /* GetAccessor */ || kind === 152 /* SetAccessor */ || kind === 155 /* IndexSignature */ - || kind === 203 /* SemicolonClassElement */; + || kind === 204 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 257 /* PropertyAssignment */ - || kind === 258 /* ShorthandPropertyAssignment */ - || kind === 259 /* SpreadAssignment */ + return kind === 258 /* PropertyAssignment */ + || kind === 259 /* ShorthandPropertyAssignment */ + || kind === 260 /* SpreadAssignment */ || kind === 149 /* MethodDeclaration */ || kind === 151 /* GetAccessor */ || kind === 152 /* SetAccessor */ - || kind === 244 /* MissingDeclaration */; + || kind === 245 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -9871,7 +9945,7 @@ var ts; */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 144 /* Parameter */: case 174 /* BindingElement */: return true; @@ -9959,8 +10033,8 @@ var ts; || kind === 178 /* ElementAccessExpression */ || kind === 180 /* NewExpression */ || kind === 179 /* CallExpression */ - || kind === 246 /* JsxElement */ - || kind === 247 /* JsxSelfClosingElement */ + || kind === 247 /* JsxElement */ + || kind === 248 /* JsxSelfClosingElement */ || kind === 181 /* TaggedTemplateExpression */ || kind === 175 /* ArrayLiteralExpression */ || kind === 183 /* ParenthesizedExpression */ @@ -9979,7 +10053,7 @@ var ts; || kind === 100 /* TrueKeyword */ || kind === 96 /* SuperKeyword */ || kind === 201 /* NonNullExpression */ - || kind === 297 /* RawExpression */; + || kind === 202 /* MetaProperty */; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); @@ -10007,7 +10081,6 @@ var ts; || kind === 196 /* SpreadElement */ || kind === 200 /* AsExpression */ || kind === 198 /* OmittedExpression */ - || kind === 297 /* RawExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -10021,11 +10094,11 @@ var ts; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 294 /* PartiallyEmittedExpression */; + return node.kind === 295 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 293 /* NotEmittedStatement */; + return node.kind === 294 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10039,12 +10112,12 @@ var ts; ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 202 /* TemplateSpan */; + return node.kind === 203 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 204 /* Block */; + return node.kind === 205 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -10062,121 +10135,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 223 /* VariableDeclaration */; + return node.kind === 224 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 224 /* VariableDeclarationList */; + return node.kind === 225 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 232 /* CaseBlock */; + return node.kind === 233 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 231 /* ModuleBlock */ - || kind === 230 /* ModuleDeclaration */; + return kind === 232 /* ModuleBlock */ + || kind === 231 /* ModuleDeclaration */; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */; + return node.kind === 235 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 236 /* ImportClause */; + return node.kind === 237 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 238 /* NamedImports */ - || kind === 237 /* NamespaceImport */; + return kind === 239 /* NamedImports */ + || kind === 238 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 239 /* ImportSpecifier */; + return node.kind === 240 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 242 /* NamedExports */; + return node.kind === 243 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 243 /* ExportSpecifier */; + return node.kind === 244 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 230 /* ModuleDeclaration */ || node.kind === 229 /* EnumDeclaration */; + return node.kind === 231 /* ModuleDeclaration */ || node.kind === 230 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { return kind === 185 /* ArrowFunction */ || kind === 174 /* BindingElement */ - || kind === 226 /* ClassDeclaration */ + || kind === 227 /* ClassDeclaration */ || kind === 197 /* ClassExpression */ || kind === 150 /* Constructor */ - || kind === 229 /* EnumDeclaration */ - || kind === 260 /* EnumMember */ - || kind === 243 /* ExportSpecifier */ - || kind === 225 /* FunctionDeclaration */ + || kind === 230 /* EnumDeclaration */ + || kind === 261 /* EnumMember */ + || kind === 244 /* ExportSpecifier */ + || kind === 226 /* FunctionDeclaration */ || kind === 184 /* FunctionExpression */ || kind === 151 /* GetAccessor */ - || kind === 236 /* ImportClause */ - || kind === 234 /* ImportEqualsDeclaration */ - || kind === 239 /* ImportSpecifier */ - || kind === 227 /* InterfaceDeclaration */ + || kind === 237 /* ImportClause */ + || kind === 235 /* ImportEqualsDeclaration */ + || kind === 240 /* ImportSpecifier */ + || kind === 228 /* InterfaceDeclaration */ || kind === 149 /* MethodDeclaration */ || kind === 148 /* MethodSignature */ - || kind === 230 /* ModuleDeclaration */ - || kind === 233 /* NamespaceExportDeclaration */ - || kind === 237 /* NamespaceImport */ + || kind === 231 /* ModuleDeclaration */ + || kind === 234 /* NamespaceExportDeclaration */ + || kind === 238 /* NamespaceImport */ || kind === 144 /* Parameter */ - || kind === 257 /* PropertyAssignment */ + || kind === 258 /* PropertyAssignment */ || kind === 147 /* PropertyDeclaration */ || kind === 146 /* PropertySignature */ || kind === 152 /* SetAccessor */ - || kind === 258 /* ShorthandPropertyAssignment */ - || kind === 228 /* TypeAliasDeclaration */ + || kind === 259 /* ShorthandPropertyAssignment */ + || kind === 229 /* TypeAliasDeclaration */ || kind === 143 /* TypeParameter */ - || kind === 223 /* VariableDeclaration */ - || kind === 285 /* JSDocTypedefTag */; + || kind === 224 /* VariableDeclaration */ + || kind === 286 /* JSDocTypedefTag */; } function isDeclarationStatementKind(kind) { - return kind === 225 /* FunctionDeclaration */ - || kind === 244 /* MissingDeclaration */ - || kind === 226 /* ClassDeclaration */ - || kind === 227 /* InterfaceDeclaration */ - || kind === 228 /* TypeAliasDeclaration */ - || kind === 229 /* EnumDeclaration */ - || kind === 230 /* ModuleDeclaration */ - || kind === 235 /* ImportDeclaration */ - || kind === 234 /* ImportEqualsDeclaration */ - || kind === 241 /* ExportDeclaration */ - || kind === 240 /* ExportAssignment */ - || kind === 233 /* NamespaceExportDeclaration */; + return kind === 226 /* FunctionDeclaration */ + || kind === 245 /* MissingDeclaration */ + || kind === 227 /* ClassDeclaration */ + || kind === 228 /* InterfaceDeclaration */ + || kind === 229 /* TypeAliasDeclaration */ + || kind === 230 /* EnumDeclaration */ + || kind === 231 /* ModuleDeclaration */ + || kind === 236 /* ImportDeclaration */ + || kind === 235 /* ImportEqualsDeclaration */ + || kind === 242 /* ExportDeclaration */ + || kind === 241 /* ExportAssignment */ + || kind === 234 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 215 /* BreakStatement */ - || kind === 214 /* ContinueStatement */ - || kind === 222 /* DebuggerStatement */ - || kind === 209 /* DoStatement */ - || kind === 207 /* ExpressionStatement */ - || kind === 206 /* EmptyStatement */ - || kind === 212 /* ForInStatement */ - || kind === 213 /* ForOfStatement */ - || kind === 211 /* ForStatement */ - || kind === 208 /* IfStatement */ - || kind === 219 /* LabeledStatement */ - || kind === 216 /* ReturnStatement */ - || kind === 218 /* SwitchStatement */ - || kind === 220 /* ThrowStatement */ - || kind === 221 /* TryStatement */ - || kind === 205 /* VariableStatement */ - || kind === 210 /* WhileStatement */ - || kind === 217 /* WithStatement */ - || kind === 293 /* NotEmittedStatement */ - || kind === 296 /* EndOfDeclarationMarker */ - || kind === 295 /* MergeDeclarationMarker */; + return kind === 216 /* BreakStatement */ + || kind === 215 /* ContinueStatement */ + || kind === 223 /* DebuggerStatement */ + || kind === 210 /* DoStatement */ + || kind === 208 /* ExpressionStatement */ + || kind === 207 /* EmptyStatement */ + || kind === 213 /* ForInStatement */ + || kind === 214 /* ForOfStatement */ + || kind === 212 /* ForStatement */ + || kind === 209 /* IfStatement */ + || kind === 220 /* LabeledStatement */ + || kind === 217 /* ReturnStatement */ + || kind === 219 /* SwitchStatement */ + || kind === 221 /* ThrowStatement */ + || kind === 222 /* TryStatement */ + || kind === 206 /* VariableStatement */ + || kind === 211 /* WhileStatement */ + || kind === 218 /* WithStatement */ + || kind === 294 /* NotEmittedStatement */ + || kind === 297 /* EndOfDeclarationMarker */ + || kind === 296 /* MergeDeclarationMarker */; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10197,24 +10270,24 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 204 /* Block */; + || kind === 205 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 245 /* ExternalModuleReference */ + return kind === 246 /* ExternalModuleReference */ || kind === 141 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 248 /* JsxOpeningElement */; + return node.kind === 249 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 249 /* JsxClosingElement */; + return node.kind === 250 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { @@ -10226,64 +10299,64 @@ var ts; ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 246 /* JsxElement */ - || kind === 252 /* JsxExpression */ - || kind === 247 /* JsxSelfClosingElement */ + return kind === 247 /* JsxElement */ + || kind === 253 /* JsxExpression */ + || kind === 248 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 250 /* JsxAttribute */ - || kind === 251 /* JsxSpreadAttribute */; + return kind === 251 /* JsxAttribute */ + || kind === 252 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 251 /* JsxSpreadAttribute */; + return node.kind === 252 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 250 /* JsxAttribute */; + return node.kind === 251 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 252 /* JsxExpression */; + || kind === 253 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 253 /* CaseClause */ - || kind === 254 /* DefaultClause */; + return kind === 254 /* CaseClause */ + || kind === 255 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 255 /* HeritageClause */; + return node.kind === 256 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 256 /* CatchClause */; + return node.kind === 257 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 257 /* PropertyAssignment */; + return node.kind === 258 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 258 /* ShorthandPropertyAssignment */; + return node.kind === 259 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; // Enum function isEnumMember(node) { - return node.kind === 260 /* EnumMember */; + return node.kind === 261 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 261 /* SourceFile */; + return node.kind === 262 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10515,7 +10588,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 143 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 227 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 228 /* InterfaceDeclaration */) { return current; } } @@ -10535,14 +10608,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 224 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 224 /* VariableDeclarationList */) { + if (node && node.kind === 225 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 205 /* VariableStatement */) { + if (node && node.kind === 206 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10558,14 +10631,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 224 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 224 /* VariableDeclarationList */) { + if (node && node.kind === 225 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 205 /* VariableStatement */) { + if (node && node.kind === 206 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -10634,7 +10707,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 261 /* SourceFile */ + var ConstructorForKind = kind === 262 /* SourceFile */ ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -11351,7 +11424,7 @@ var ts; ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; // Misc function createTemplateSpan(expression, literal, location) { - var node = createNode(202 /* TemplateSpan */, location); + var node = createNode(203 /* TemplateSpan */, location); node.expression = expression; node.literal = literal; return node; @@ -11366,7 +11439,7 @@ var ts; ts.updateTemplateSpan = updateTemplateSpan; // Element function createBlock(statements, location, multiLine, flags) { - var block = createNode(204 /* Block */, location, flags); + var block = createNode(205 /* Block */, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -11382,7 +11455,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(205 /* VariableStatement */, location, flags); + var node = createNode(206 /* VariableStatement */, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -11397,7 +11470,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(224 /* VariableDeclarationList */, location, flags); + var node = createNode(225 /* VariableDeclarationList */, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -11410,7 +11483,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(223 /* VariableDeclaration */, location, flags); + var node = createNode(224 /* VariableDeclaration */, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11425,11 +11498,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(206 /* EmptyStatement */, location); + return createNode(207 /* EmptyStatement */, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(207 /* ExpressionStatement */, location, flags); + var node = createNode(208 /* ExpressionStatement */, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -11442,7 +11515,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(208 /* IfStatement */, location); + var node = createNode(209 /* IfStatement */, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11457,7 +11530,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(209 /* DoStatement */, location); + var node = createNode(210 /* DoStatement */, location); node.statement = statement; node.expression = expression; return node; @@ -11471,7 +11544,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(210 /* WhileStatement */, location); + var node = createNode(211 /* WhileStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11485,7 +11558,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(211 /* ForStatement */, location, /*flags*/ undefined); + var node = createNode(212 /* ForStatement */, location, /*flags*/ undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11501,7 +11574,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(212 /* ForInStatement */, location); + var node = createNode(213 /* ForInStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11516,7 +11589,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(213 /* ForOfStatement */, location); + var node = createNode(214 /* ForOfStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11531,7 +11604,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(214 /* ContinueStatement */, location); + var node = createNode(215 /* ContinueStatement */, location); if (label) { node.label = label; } @@ -11546,7 +11619,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(215 /* BreakStatement */, location); + var node = createNode(216 /* BreakStatement */, location); if (label) { node.label = label; } @@ -11561,7 +11634,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(216 /* ReturnStatement */, location); + var node = createNode(217 /* ReturnStatement */, location); node.expression = expression; return node; } @@ -11574,7 +11647,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(217 /* WithStatement */, location); + var node = createNode(218 /* WithStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11588,7 +11661,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(218 /* SwitchStatement */, location); + var node = createNode(219 /* SwitchStatement */, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11602,7 +11675,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(219 /* LabeledStatement */, location); + var node = createNode(220 /* LabeledStatement */, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11616,7 +11689,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(220 /* ThrowStatement */, location); + var node = createNode(221 /* ThrowStatement */, location); node.expression = expression; return node; } @@ -11629,7 +11702,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(221 /* TryStatement */, location); + var node = createNode(222 /* TryStatement */, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11644,7 +11717,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(232 /* CaseBlock */, location); + var node = createNode(233 /* CaseBlock */, location); node.clauses = createNodeArray(clauses); return node; } @@ -11657,7 +11730,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(225 /* FunctionDeclaration */, location, flags); + var node = createNode(226 /* FunctionDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11677,7 +11750,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(226 /* ClassDeclaration */, location); + var node = createNode(227 /* ClassDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11695,7 +11768,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(235 /* ImportDeclaration */, location); + var node = createNode(236 /* ImportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11711,7 +11784,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(236 /* ImportClause */, location); + var node = createNode(237 /* ImportClause */, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11725,7 +11798,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(237 /* NamespaceImport */, location); + var node = createNode(238 /* NamespaceImport */, location); node.name = name; return node; } @@ -11738,7 +11811,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(238 /* NamedImports */, location); + var node = createNode(239 /* NamedImports */, location); node.elements = createNodeArray(elements); return node; } @@ -11751,7 +11824,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(239 /* ImportSpecifier */, location); + var node = createNode(240 /* ImportSpecifier */, location); node.propertyName = propertyName; node.name = name; return node; @@ -11765,7 +11838,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(240 /* ExportAssignment */, location); + var node = createNode(241 /* ExportAssignment */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11781,7 +11854,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(241 /* ExportDeclaration */, location); + var node = createNode(242 /* ExportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11797,7 +11870,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(242 /* NamedExports */, location); + var node = createNode(243 /* NamedExports */, location); node.elements = createNodeArray(elements); return node; } @@ -11810,7 +11883,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(243 /* ExportSpecifier */, location); + var node = createNode(244 /* ExportSpecifier */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11825,7 +11898,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // JSX function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(246 /* JsxElement */, location); + var node = createNode(247 /* JsxElement */, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11840,7 +11913,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(247 /* JsxSelfClosingElement */, location); + var node = createNode(248 /* JsxSelfClosingElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11854,7 +11927,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(248 /* JsxOpeningElement */, location); + var node = createNode(249 /* JsxOpeningElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11868,7 +11941,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(249 /* JsxClosingElement */, location); + var node = createNode(250 /* JsxClosingElement */, location); node.tagName = tagName; return node; } @@ -11881,7 +11954,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(250 /* JsxAttribute */, location); + var node = createNode(251 /* JsxAttribute */, location); node.name = name; node.initializer = initializer; return node; @@ -11895,7 +11968,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(251 /* JsxSpreadAttribute */, location); + var node = createNode(252 /* JsxSpreadAttribute */, location); node.expression = expression; return node; } @@ -11907,22 +11980,23 @@ var ts; return node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, location) { - var node = createNode(252 /* JsxExpression */, location); + function createJsxExpression(expression, dotDotDotToken, location) { + var node = createNode(253 /* JsxExpression */, location); + node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node), node); + return updateNode(createJsxExpression(expression, node.dotDotDotToken, node), node); } return node; } ts.updateJsxExpression = updateJsxExpression; // Clauses function createHeritageClause(token, types, location) { - var node = createNode(255 /* HeritageClause */, location); + var node = createNode(256 /* HeritageClause */, location); node.token = token; node.types = createNodeArray(types); return node; @@ -11936,7 +12010,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(253 /* CaseClause */, location); + var node = createNode(254 /* CaseClause */, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -11950,7 +12024,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(254 /* DefaultClause */, location); + var node = createNode(255 /* DefaultClause */, location); node.statements = createNodeArray(statements); return node; } @@ -11963,7 +12037,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(256 /* CatchClause */, location); + var node = createNode(257 /* CatchClause */, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11978,7 +12052,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer, location) { - var node = createNode(257 /* PropertyAssignment */, location); + var node = createNode(258 /* PropertyAssignment */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11993,14 +12067,14 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(258 /* ShorthandPropertyAssignment */, location); + var node = createNode(259 /* ShorthandPropertyAssignment */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; function createSpreadAssignment(expression, location) { - var node = createNode(259 /* SpreadAssignment */, location); + var node = createNode(260 /* SpreadAssignment */, location); node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; return node; } @@ -12022,7 +12096,7 @@ var ts; // Top-level nodes function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(261 /* SourceFile */, /*location*/ node, node.flags); + var updated = createNode(262 /* SourceFile */, /*location*/ node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -12089,7 +12163,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createNode(293 /* NotEmittedStatement */, /*location*/ original); + var node = createNode(294 /* NotEmittedStatement */, /*location*/ original); node.original = original; return node; } @@ -12099,7 +12173,7 @@ var ts; * order to properly emit exports. */ function createEndOfDeclarationMarker(original) { - var node = createNode(296 /* EndOfDeclarationMarker */); + var node = createNode(297 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12110,7 +12184,7 @@ var ts; * order to properly emit exports. */ function createMergeDeclarationMarker(original) { - var node = createNode(295 /* MergeDeclarationMarker */); + var node = createNode(296 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12125,7 +12199,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(294 /* PartiallyEmittedExpression */, /*location*/ location || original); + var node = createNode(295 /* PartiallyEmittedExpression */, /*location*/ location || original); node.expression = expression; node.original = original; return node; @@ -12138,19 +12212,6 @@ var ts; return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; - /** - * Creates a node that emits a string of raw text in an expression position. Raw text is never - * transformed, should be ES3 compliant, and should have the same precedence as - * PrimaryExpression. - * - * @param text The raw text of the node. - */ - function createRawExpression(text) { - var node = createNode(297 /* RawExpression */); - node.text = text; - return node; - } - ts.createRawExpression = createRawExpression; // Compound nodes function createComma(left, right) { return createBinary(left, 25 /* CommaToken */, right); @@ -12326,6 +12387,20 @@ var ts; return setEmitFlags(createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } ts.getHelperName = getHelperName; + // Utilities + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 220 /* LabeledStatement */ + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { @@ -12432,9 +12507,9 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); case 149 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); @@ -12999,7 +13074,7 @@ var ts; case 177 /* PropertyAccessExpression */: node = node.expression; continue; - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -13054,7 +13129,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 294 /* PartiallyEmittedExpression */) { + while (node.kind === 295 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -13133,7 +13208,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -13391,10 +13466,10 @@ var ts; var name_9 = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 235 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 236 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 241 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 242 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -13514,7 +13589,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -13526,11 +13601,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -13567,7 +13642,7 @@ var ts; // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; case 196 /* SpreadElement */: - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -13591,7 +13666,7 @@ var ts; : propertyName; } break; - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -13603,7 +13678,7 @@ var ts; : propertyName; } break; - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -13717,20 +13792,20 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); break; - case 234 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 245 /* ExternalModuleReference */) { + case 235 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 246 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -13760,13 +13835,13 @@ var ts; } } break; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -13774,7 +13849,7 @@ var ts; } } break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -13794,7 +13869,7 @@ var ts; } } break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -13847,7 +13922,7 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 261 /* SourceFile */) { + if (kind === 262 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70 /* Identifier */) { @@ -13903,20 +13978,20 @@ var ts; return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: return visitNode(cbNode, node.expression); case 144 /* Parameter */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 223 /* VariableDeclaration */: + case 258 /* PropertyAssignment */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -13942,7 +14017,7 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -14034,6 +14109,8 @@ var ts; visitNode(cbNode, node.type); case 201 /* NonNullExpression */: return visitNode(cbNode, node.expression); + case 202 /* MetaProperty */: + return visitNode(cbNode, node.name); case 193 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || @@ -14042,76 +14119,76 @@ var ts; visitNode(cbNode, node.whenFalse); case 196 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 204 /* Block */: - case 231 /* ModuleBlock */: + case 205 /* Block */: + case 232 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 261 /* SourceFile */: + case 262 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 215 /* ContinueStatement */: + case 216 /* BreakStatement */: return visitNode(cbNode, node.label); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 253 /* CaseClause */: + case 254 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 145 /* Decorator */: return visitNode(cbNode, node.expression); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -14119,155 +14196,156 @@ var ts; visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 227 /* InterfaceDeclaration */: + case 228 /* 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 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 260 /* EnumMember */: + case 261 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 233 /* NamespaceExportDeclaration */: + case 234 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 239 /* NamedImports */: + case 243 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); case 194 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 142 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: return visitNodes(cbNodes, node.types); case 199 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 245 /* ExternalModuleReference */: + case 246 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 244 /* MissingDeclaration */: + case 245 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 246 /* JsxElement */: + case 247 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 248 /* JsxSelfClosingElement */: + case 249 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 252 /* JsxExpression */: - return visitNode(cbNode, node.expression); - case 249 /* JsxClosingElement */: + case 253 /* JsxExpression */: + return visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.expression); + case 250 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 262 /* JSDocTypeExpression */: + case 263 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 266 /* JSDocUnionType */: + case 267 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 267 /* JSDocTupleType */: + case 268 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 265 /* JSDocArrayType */: + case 266 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 269 /* JSDocNonNullableType */: + case 270 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 268 /* JSDocNullableType */: + case 269 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 270 /* JSDocRecordType */: + case 271 /* JSDocRecordType */: return visitNode(cbNode, node.literal); - case 272 /* JSDocTypeReference */: + case 273 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 273 /* JSDocOptionalType */: + case 274 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 274 /* JSDocFunctionType */: + case 275 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 275 /* JSDocVariadicType */: + case 276 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 276 /* JSDocConstructorType */: + case 277 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 277 /* JSDocThisType */: + case 278 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 271 /* JSDocRecordMember */: + case 272 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 278 /* JSDocComment */: + case 279 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 281 /* JSDocParameterTag */: + case 282 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 282 /* JSDocReturnTag */: + case 283 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 283 /* JSDocTypeTag */: + case 284 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 280 /* JSDocAugmentsTag */: + case 281 /* JSDocAugmentsTag */: return visitNode(cbNode, node.typeExpression); - case 284 /* JSDocTemplateTag */: + case 285 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 287 /* JSDocTypeLiteral */: + case 288 /* JSDocTypeLiteral */: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 286 /* JSDocPropertyTag */: + case 287 /* JSDocPropertyTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); - case 288 /* JSDocLiteralType */: + case 289 /* JSDocLiteralType */: return visitNode(cbNode, node.literal); } } @@ -14539,7 +14617,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(261 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(262 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -15327,7 +15405,7 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 147 /* PropertyDeclaration */: - case 203 /* SemicolonClassElement */: + case 204 /* SemicolonClassElement */: return true; case 149 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal @@ -15344,8 +15422,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 254 /* CaseClause */: + case 255 /* DefaultClause */: return true; } } @@ -15354,42 +15432,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: - case 205 /* VariableStatement */: - case 204 /* Block */: - case 208 /* IfStatement */: - case 207 /* ExpressionStatement */: - case 220 /* ThrowStatement */: - case 216 /* ReturnStatement */: - case 218 /* SwitchStatement */: - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 211 /* ForStatement */: - case 210 /* WhileStatement */: - case 217 /* WithStatement */: - case 206 /* EmptyStatement */: - case 221 /* TryStatement */: - case 219 /* LabeledStatement */: - case 209 /* DoStatement */: - case 222 /* DebuggerStatement */: - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: - case 240 /* ExportAssignment */: - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 226 /* FunctionDeclaration */: + case 206 /* VariableStatement */: + case 205 /* Block */: + case 209 /* IfStatement */: + case 208 /* ExpressionStatement */: + case 221 /* ThrowStatement */: + case 217 /* ReturnStatement */: + case 219 /* SwitchStatement */: + case 216 /* BreakStatement */: + case 215 /* ContinueStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 212 /* ForStatement */: + case 211 /* WhileStatement */: + case 218 /* WithStatement */: + case 207 /* EmptyStatement */: + case 222 /* TryStatement */: + case 220 /* LabeledStatement */: + case 210 /* DoStatement */: + case 223 /* DebuggerStatement */: + case 236 /* ImportDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 242 /* ExportDeclaration */: + case 241 /* ExportAssignment */: + case 231 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: + case 229 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 260 /* EnumMember */; + return node.kind === 261 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { @@ -15405,7 +15483,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 223 /* VariableDeclaration */) { + if (node.kind !== 224 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -15590,7 +15668,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(202 /* TemplateSpan */); + var span = createNode(203 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17 /* CloseBraceToken */) { @@ -17179,8 +17257,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 248 /* JsxOpeningElement */) { - var node = createNode(246 /* JsxElement */, opening.pos); + if (opening.kind === 249 /* JsxOpeningElement */) { + var node = createNode(247 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -17190,7 +17268,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 247 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 248 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -17264,7 +17342,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(248 /* JsxOpeningElement */, fullStart); + node = createNode(249 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -17276,7 +17354,7 @@ var ts; parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(247 /* JsxSelfClosingElement */, fullStart); + node = createNode(248 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -17300,9 +17378,10 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(252 /* JsxExpression */); + var node = createNode(253 /* JsxExpression */); parseExpected(16 /* OpenBraceToken */); if (token() !== 17 /* CloseBraceToken */) { + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { @@ -17319,7 +17398,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(250 /* JsxAttribute */); + var node = createNode(251 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 57 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -17334,7 +17413,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(251 /* JsxSpreadAttribute */); + var node = createNode(252 /* JsxSpreadAttribute */); parseExpected(16 /* OpenBraceToken */); parseExpected(23 /* DotDotDotToken */); node.expression = parseExpression(); @@ -17342,7 +17421,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(249 /* JsxClosingElement */); + var node = createNode(250 /* JsxClosingElement */); parseExpected(27 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -17581,7 +17660,7 @@ var ts; var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); if (dotDotDotToken) { - var spreadElement = createNode(259 /* SpreadAssignment */, fullStart); + var spreadElement = createNode(260 /* SpreadAssignment */, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -17606,7 +17685,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 /* CommaToken */ || token() === 17 /* CloseBraceToken */ || token() === 57 /* EqualsToken */); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(258 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(259 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57 /* EqualsToken */); @@ -17617,7 +17696,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(257 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(258 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -17668,8 +17747,15 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(180 /* NewExpression */); + var fullStart = scanner.getStartPos(); parseExpected(93 /* NewKeyword */); + if (parseOptional(22 /* DotToken */)) { + var node_1 = createNode(202 /* MetaProperty */, fullStart); + node_1.keywordToken = 93 /* NewKeyword */; + node_1.name = parseIdentifierName(); + return finishNode(node_1); + } + var node = createNode(180 /* NewExpression */, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18 /* OpenParenToken */) { @@ -17679,7 +17765,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(204 /* Block */); + var node = createNode(205 /* Block */); if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17712,12 +17798,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(206 /* EmptyStatement */); + var node = createNode(207 /* EmptyStatement */); parseExpected(24 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(208 /* IfStatement */); + var node = createNode(209 /* IfStatement */); parseExpected(89 /* IfKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17727,7 +17813,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(209 /* DoStatement */); + var node = createNode(210 /* DoStatement */); parseExpected(80 /* DoKeyword */); node.statement = parseStatement(); parseExpected(105 /* WhileKeyword */); @@ -17742,7 +17828,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(210 /* WhileStatement */); + var node = createNode(211 /* WhileStatement */); parseExpected(105 /* WhileKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17765,21 +17851,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91 /* InKeyword */)) { - var forInStatement = createNode(212 /* ForInStatement */, pos); + var forInStatement = createNode(213 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else if (parseOptional(140 /* OfKeyword */)) { - var forOfStatement = createNode(213 /* ForOfStatement */, pos); + var forOfStatement = createNode(214 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(211 /* ForStatement */, pos); + var forStatement = createNode(212 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(24 /* SemicolonToken */); if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { @@ -17797,7 +17883,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 215 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); + parseExpected(kind === 216 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -17805,7 +17891,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(216 /* ReturnStatement */); + var node = createNode(217 /* ReturnStatement */); parseExpected(95 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -17814,7 +17900,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(217 /* WithStatement */); + var node = createNode(218 /* WithStatement */); parseExpected(106 /* WithKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17823,7 +17909,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(253 /* CaseClause */); + var node = createNode(254 /* CaseClause */); parseExpected(72 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(55 /* ColonToken */); @@ -17831,7 +17917,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(254 /* DefaultClause */); + var node = createNode(255 /* DefaultClause */); parseExpected(78 /* DefaultKeyword */); parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -17841,12 +17927,12 @@ var ts; return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(218 /* SwitchStatement */); + var node = createNode(219 /* SwitchStatement */); parseExpected(97 /* SwitchKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); - var caseBlock = createNode(232 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(233 /* CaseBlock */, scanner.getStartPos()); parseExpected(16 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(17 /* CloseBraceToken */); @@ -17861,7 +17947,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(220 /* ThrowStatement */); + var node = createNode(221 /* ThrowStatement */); parseExpected(99 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -17869,7 +17955,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(221 /* TryStatement */); + var node = createNode(222 /* TryStatement */); parseExpected(101 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 73 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -17882,7 +17968,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(256 /* CatchClause */); + var result = createNode(257 /* CatchClause */); parseExpected(73 /* CatchKeyword */); if (parseExpected(18 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -17892,7 +17978,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(222 /* DebuggerStatement */); + var node = createNode(223 /* DebuggerStatement */); parseExpected(77 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -17904,13 +17990,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 /* Identifier */ && parseOptional(55 /* ColonToken */)) { - var labeledStatement = createNode(219 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(220 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(207 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(208 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -18091,9 +18177,9 @@ var ts; case 87 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 76 /* ContinueKeyword */: - return parseBreakOrContinueStatement(214 /* ContinueStatement */); + return parseBreakOrContinueStatement(215 /* ContinueStatement */); case 71 /* BreakKeyword */: - return parseBreakOrContinueStatement(215 /* BreakStatement */); + return parseBreakOrContinueStatement(216 /* BreakStatement */); case 95 /* ReturnKeyword */: return parseReturnStatement(); case 106 /* WithKeyword */: @@ -18175,7 +18261,7 @@ var ts; 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(244 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(245 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -18248,7 +18334,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(223 /* VariableDeclaration */); + var node = createNode(224 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -18257,7 +18343,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(224 /* VariableDeclarationList */); + var node = createNode(225 /* VariableDeclarationList */); switch (token()) { case 103 /* VarKeyword */: break; @@ -18295,7 +18381,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(205 /* VariableStatement */, fullStart); + var node = createNode(206 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -18303,7 +18389,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225 /* FunctionDeclaration */, fullStart); + var node = createNode(226 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88 /* FunctionKeyword */); @@ -18527,7 +18613,7 @@ var ts; } function parseClassElement() { if (token() === 24 /* SemicolonToken */) { - var result = createNode(203 /* SemicolonClassElement */); + var result = createNode(204 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -18568,7 +18654,7 @@ var ts; /*modifiers*/ undefined, 197 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 227 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -18612,7 +18698,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */) { - var node = createNode(255 /* HeritageClause */); + var node = createNode(256 /* HeritageClause */); node.token = token(); nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -18635,7 +18721,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227 /* InterfaceDeclaration */, fullStart); + var node = createNode(228 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108 /* InterfaceKeyword */); @@ -18646,7 +18732,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228 /* TypeAliasDeclaration */, fullStart); + var node = createNode(229 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(136 /* TypeKeyword */); @@ -18662,13 +18748,13 @@ 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(260 /* EnumMember */, scanner.getStartPos()); + var node = createNode(261 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229 /* EnumDeclaration */, fullStart); + var node = createNode(230 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82 /* EnumKeyword */); @@ -18683,7 +18769,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(231 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(232 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(16 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(17 /* CloseBraceToken */); @@ -18694,7 +18780,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(230 /* ModuleDeclaration */, fullStart); + var node = createNode(231 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -18708,7 +18794,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230 /* ModuleDeclaration */, fullStart); + var node = createNode(231 /* ModuleDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (token() === 139 /* GlobalKeyword */) { @@ -18755,7 +18841,7 @@ var ts; return nextToken() === 40 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(233 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(234 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117 /* AsKeyword */); @@ -18774,7 +18860,7 @@ var ts; // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(234 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(235 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -18785,7 +18871,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(235 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(236 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: @@ -18808,7 +18894,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(236 /* ImportClause */, fullStart); + var importClause = createNode(237 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -18818,7 +18904,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(25 /* CommaToken */)) { - importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(238 /* NamedImports */); + importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(239 /* NamedImports */); } return finishNode(importClause); } @@ -18828,7 +18914,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(245 /* ExternalModuleReference */); + var node = createNode(246 /* ExternalModuleReference */); parseExpected(131 /* RequireKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -18851,7 +18937,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(237 /* NamespaceImport */); + var namespaceImport = createNode(238 /* NamespaceImport */); parseExpected(38 /* AsteriskToken */); parseExpected(117 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -18866,14 +18952,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 238 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 239 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(243 /* ExportSpecifier */); + return parseImportOrExportSpecifier(244 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(239 /* ImportSpecifier */); + return parseImportOrExportSpecifier(240 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -18898,14 +18984,14 @@ var ts; else { node.name = identifierName; } - if (kind === 239 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 240 /* 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(241 /* ExportDeclaration */, fullStart); + var node = createNode(242 /* ExportDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38 /* AsteriskToken */)) { @@ -18913,7 +18999,7 @@ var ts; node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(242 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(243 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. @@ -18926,7 +19012,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(240 /* ExportAssignment */, fullStart); + var node = createNode(241 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57 /* EqualsToken */)) { @@ -19008,10 +19094,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 245 /* ExternalModuleReference */ - || node.kind === 235 /* ImportDeclaration */ - || node.kind === 240 /* ExportAssignment */ - || node.kind === 241 /* ExportDeclaration */ + || node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 246 /* ExternalModuleReference */ + || node.kind === 236 /* ImportDeclaration */ + || node.kind === 241 /* ExportAssignment */ + || node.kind === 242 /* ExportDeclaration */ ? node : undefined; }); @@ -19086,7 +19172,7 @@ var ts; // Parses out a JSDoc type expression. /* @internal */ function parseJSDocTypeExpression() { - var result = createNode(262 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(263 /* JSDocTypeExpression */, scanner.getTokenPos()); parseExpected(16 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(17 /* CloseBraceToken */); @@ -19097,12 +19183,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48 /* BarToken */) { - var unionType = createNode(266 /* JSDocUnionType */, type.pos); + var unionType = createNode(267 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57 /* EqualsToken */) { - var optionalType = createNode(273 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(274 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -19113,20 +19199,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20 /* OpenBracketToken */) { - var arrayType = createNode(265 /* JSDocArrayType */, type.pos); + var arrayType = createNode(266 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token() === 54 /* QuestionToken */) { - var nullableType = createNode(268 /* JSDocNullableType */, type.pos); + var nullableType = createNode(269 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50 /* ExclamationToken */) { - var nonNullableType = createNode(269 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(270 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -19178,27 +19264,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(277 /* JSDocThisType */); + var result = createNode(278 /* JSDocThisType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(276 /* JSDocConstructorType */); + var result = createNode(277 /* JSDocConstructorType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(275 /* JSDocVariadicType */); + var result = createNode(276 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(274 /* JSDocFunctionType */); + var result = createNode(275 /* JSDocFunctionType */); nextToken(); parseExpected(18 /* OpenParenToken */); result.parameters = parseDelimitedList(23 /* JSDocFunctionParameters */, parseJSDocParameter); @@ -19220,7 +19306,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(272 /* JSDocTypeReference */); + var result = createNode(273 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); @@ -19261,18 +19347,18 @@ var ts; return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(270 /* JSDocRecordType */); + var result = createNode(271 /* JSDocRecordType */); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(269 /* JSDocNonNullableType */); + var result = createNode(270 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(267 /* JSDocTupleType */); + var result = createNode(268 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(26 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); @@ -19286,7 +19372,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(266 /* JSDocUnionType */); + var result = createNode(267 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19 /* CloseParenToken */); @@ -19302,12 +19388,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(263 /* JSDocAllType */); + var result = createNode(264 /* JSDocAllType */); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(288 /* JSDocLiteralType */); + var result = createNode(289 /* JSDocLiteralType */); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -19330,11 +19416,11 @@ var ts; token() === 28 /* GreaterThanToken */ || token() === 57 /* EqualsToken */ || token() === 48 /* BarToken */) { - var result = createNode(264 /* JSDocUnknownType */, pos); + var result = createNode(265 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(268 /* JSDocNullableType */, pos); + var result = createNode(269 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -19499,7 +19585,7 @@ var ts; content.charCodeAt(start + 3) !== 42 /* asterisk */; } function createJSDocComment() { - var result = createNode(278 /* JSDocComment */, start); + var result = createNode(279 /* JSDocComment */, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -19615,7 +19701,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(279 /* JSDocTag */, atToken.pos); + var result = createNode(280 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -19672,7 +19758,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(281 /* JSDocParameterTag */, atToken.pos); + var result = createNode(282 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -19683,20 +19769,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 282 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 283 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(282 /* JSDocReturnTag */, atToken.pos); + var result = createNode(283 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 284 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283 /* JSDocTypeTag */, atToken.pos); + var result = createNode(284 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -19711,7 +19797,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(286 /* JSDocPropertyTag */, atToken.pos); + var result = createNode(287 /* JSDocPropertyTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -19720,7 +19806,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(280 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(281 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -19729,7 +19815,7 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(285 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(286 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0); @@ -19743,7 +19829,7 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 272 /* JSDocTypeReference */) { + if (typeExpression.type.kind === 273 /* JSDocTypeReference */) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70 /* Identifier */) { var name_14 = jsDocTypeReference.name; @@ -19761,7 +19847,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(288 /* JSDocTypeLiteral */, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -19802,7 +19888,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22 /* DotToken */)) { - var jsDocNamespaceNode = createNode(230 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(231 /* ModuleDeclaration */, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4 /* NestedNamespace */); @@ -19848,7 +19934,7 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 285 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } // Type parameter list looks like '@template T,U,V' @@ -19872,7 +19958,7 @@ var ts; break; } } - var result = createNode(284 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(285 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -20346,7 +20432,7 @@ var ts; if (position >= array.pos && position < array.end) { // position was in this array. Search through this array to see if we find a // viable element. - for (var i = 0, n = array.length; i < n; i++) { + for (var i = 0; i < array.length; i++) { var child = array[i]; if (child) { if (child.pos === position) { @@ -20392,16 +20478,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 227 /* InterfaceDeclaration */ || node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 228 /* InterfaceDeclaration */ || node.kind === 229 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 235 /* ImportDeclaration */ || node.kind === 234 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { + else if ((node.kind === 236 /* ImportDeclaration */ || node.kind === 235 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 231 /* ModuleBlock */) { + else if (node.kind === 232 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -20420,7 +20506,7 @@ var ts; }); return state_1; } - else if (node.kind === 230 /* ModuleDeclaration */) { + else if (node.kind === 231 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } @@ -20561,7 +20647,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 230 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 231 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -20596,9 +20682,9 @@ var ts; return "__new"; case 155 /* IndexSignature */: return "__index"; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return "__export"; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; case 192 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { @@ -20615,22 +20701,22 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 225 /* FunctionDeclaration */: - case 226 /* ClassDeclaration */: + case 226 /* FunctionDeclaration */: + case 227 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; - case 274 /* JSDocFunctionType */: + case 275 /* JSDocFunctionType */: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; case 144 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 274 /* JSDocFunctionType */); + ts.Debug.assert(node.parent.kind === 275 /* JSDocFunctionType */); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 205 /* VariableStatement */) { + if (parentNode && parentNode.kind === 206 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -20717,7 +20803,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 240 /* ExportAssignment */ && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 241 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -20737,7 +20823,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 243 /* ExportSpecifier */ || (node.kind === 234 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 244 /* ExportSpecifier */ || (node.kind === 235 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -20760,7 +20846,7 @@ var ts; // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation // and this case is specially handled. Module augmentations should only be merged with original module definition // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. - var isJSDocTypedefInJSDocNamespace = node.kind === 285 /* JSDocTypedefTag */ && + var isJSDocTypedefInJSDocNamespace = node.kind === 286 /* JSDocTypedefTag */ && node.name && node.name.kind === 70 /* Identifier */ && node.name.isInJSDocNamespace; @@ -20847,7 +20933,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { node.flags |= emitFlags; } if (isIIFE) { @@ -20926,43 +21012,43 @@ var ts; return; } switch (node.kind) { - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: bindWhileStatement(node); break; - case 209 /* DoStatement */: + case 210 /* DoStatement */: bindDoStatement(node); break; - case 211 /* ForStatement */: + case 212 /* ForStatement */: bindForStatement(node); break; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 208 /* IfStatement */: + case 209 /* IfStatement */: bindIfStatement(node); break; - case 216 /* ReturnStatement */: - case 220 /* ThrowStatement */: + case 217 /* ReturnStatement */: + case 221 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: + case 216 /* BreakStatement */: + case 215 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 221 /* TryStatement */: + case 222 /* TryStatement */: bindTryStatement(node); break; - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: bindSwitchStatement(node); break; - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: bindCaseBlock(node); break; - case 253 /* CaseClause */: + case 254 /* CaseClause */: bindCaseClause(node); break; - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: bindLabeledStatement(node); break; case 190 /* PrefixUnaryExpression */: @@ -20980,7 +21066,7 @@ var ts; case 193 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; case 179 /* CallExpression */: @@ -21147,11 +21233,11 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 208 /* IfStatement */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: + case 209 /* IfStatement */: + case 211 /* WhileStatement */: + case 210 /* DoStatement */: return parent.expression === node; - case 211 /* ForStatement */: + case 212 /* ForStatement */: case 193 /* ConditionalExpression */: return parent.condition === node; } @@ -21215,7 +21301,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 219 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 220 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -21252,7 +21338,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 224 /* VariableDeclarationList */) { + if (node.initializer.kind !== 225 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -21274,7 +21360,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 216 /* ReturnStatement */) { + if (node.kind === 217 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -21294,7 +21380,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 215 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 216 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -21360,7 +21446,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 254 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 255 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -21427,7 +21513,7 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 209 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 210 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); @@ -21459,13 +21545,13 @@ var ts; else if (node.kind === 176 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 257 /* PropertyAssignment */) { + if (p.kind === 258 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 258 /* ShorthandPropertyAssignment */) { + else if (p.kind === 259 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 259 /* SpreadAssignment */) { + else if (p.kind === 260 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -21565,7 +21651,7 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 212 /* ForInStatement */ || node.parent.parent.kind === 213 /* ForOfStatement */) { + if (node.initializer || node.parent.parent.kind === 213 /* ForInStatement */ || node.parent.parent.kind === 214 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } @@ -21595,28 +21681,28 @@ var ts; function getContainerFlags(node) { switch (node.kind) { case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: case 176 /* ObjectLiteralExpression */: case 161 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 270 /* JSDocRecordType */: + case 288 /* JSDocTypeLiteral */: + case 271 /* JSDocRecordType */: return 1 /* IsContainer */; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 274 /* JSDocFunctionType */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 275 /* JSDocFunctionType */: + case 231 /* ModuleDeclaration */: + case 229 /* TypeAliasDeclaration */: case 170 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 261 /* SourceFile */: + case 262 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; case 149 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } case 150 /* Constructor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: @@ -21629,17 +21715,17 @@ var ts; case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; case 147 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 256 /* CatchClause */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 232 /* CaseBlock */: + case 257 /* CatchClause */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 233 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 204 /* Block */: + case 205 /* 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. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -21676,20 +21762,20 @@ var ts; // 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). We defer to specialized // handlers to take care of declaring these child members. - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 261 /* SourceFile */: + case 262 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 161 /* TypeLiteral */: case 176 /* ObjectLiteralExpression */: - case 227 /* InterfaceDeclaration */: - case 270 /* JSDocRecordType */: - case 287 /* JSDocTypeLiteral */: + case 228 /* InterfaceDeclaration */: + case 271 /* JSDocRecordType */: + case 288 /* JSDocTypeLiteral */: // 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 @@ -21706,11 +21792,11 @@ var ts; case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 274 /* JSDocFunctionType */: - case 228 /* TypeAliasDeclaration */: + case 275 /* JSDocFunctionType */: + case 229 /* TypeAliasDeclaration */: case 170 /* MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, @@ -21732,11 +21818,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 261 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 261 /* SourceFile */ || body.kind === 231 /* ModuleBlock */)) { + var body = node.kind === 262 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 262 /* SourceFile */ || body.kind === 232 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 241 /* ExportDeclaration */ || stat.kind === 240 /* ExportAssignment */) { + if (stat.kind === 242 /* ExportDeclaration */ || stat.kind === 241 /* ExportAssignment */) { return true; } } @@ -21829,7 +21915,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { + if (prop.kind === 260 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { continue; } var identifier = prop.name; @@ -21841,7 +21927,7 @@ var ts; // 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 === 257 /* PropertyAssignment */ || prop.kind === 258 /* ShorthandPropertyAssignment */ || prop.kind === 149 /* MethodDeclaration */ + var currentKind = prop.kind === 258 /* PropertyAssignment */ || prop.kind === 259 /* ShorthandPropertyAssignment */ || prop.kind === 149 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -21863,10 +21949,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -21977,8 +22063,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 261 /* SourceFile */ && - blockScopeContainer.kind !== 230 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 262 /* SourceFile */ && + blockScopeContainer.kind !== 231 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -22091,14 +22177,14 @@ var ts; // current "blockScopeContainer" needs to be set to its immediate namespace parent. if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 285 /* JSDocTypedefTag */) { + while (parentNode && parentNode.kind !== 286 /* JSDocTypedefTag */) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); break; } case 98 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 258 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 259 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); @@ -22131,7 +22217,7 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return checkStrictModeCatchClause(node); case 186 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); @@ -22141,7 +22227,7 @@ var ts; return checkStrictModePostfixUnaryExpression(node); case 190 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return checkStrictModeWithStatement(node); case 167 /* ThisType */: seenThisKeyword = true; @@ -22152,22 +22238,22 @@ var ts; return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530920 /* TypeParameterExcludes */); case 144 /* Parameter */: return bindParameter(node); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 271 /* JSDocRecordMember */: + case 272 /* JSDocRecordMember */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); - case 286 /* JSDocPropertyTag */: + case 287 /* JSDocPropertyTag */: return bindJSDocProperty(node); - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: + case 258 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 260 /* EnumMember */: + case 261 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 259 /* SpreadAssignment */: - case 251 /* JsxSpreadAttribute */: + case 260 /* SpreadAssignment */: + case 252 /* JsxSpreadAttribute */: var root = container; var hasRest = false; while (root.parent) { @@ -22192,7 +22278,7 @@ var ts; // 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) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return bindFunctionDeclaration(node); case 150 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); @@ -22202,12 +22288,12 @@ var ts; return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); case 158 /* FunctionType */: case 159 /* ConstructorType */: - case 274 /* JSDocFunctionType */: + case 275 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); case 161 /* TypeLiteral */: case 170 /* MappedType */: - case 287 /* JSDocTypeLiteral */: - case 270 /* JSDocRecordType */: + case 288 /* JSDocTypeLiteral */: + case 271 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); case 176 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); @@ -22221,46 +22307,46 @@ var ts; break; // Members of classes, interfaces, and modules case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: if (!node.fullName || node.fullName.kind === 70 /* Identifier */) { return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); } break; - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Imports and exports - case 234 /* ImportEqualsDeclaration */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 235 /* ImportEqualsDeclaration */: + case 238 /* NamespaceImport */: + case 240 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 233 /* NamespaceExportDeclaration */: + case 234 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return bindImportClause(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return bindExportDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return bindExportAssignment(node); - case 261 /* SourceFile */: + case 262 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 204 /* Block */: + case 205 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // Fall through - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } @@ -22292,7 +22378,7 @@ var ts; // An export default clause with an expression exports a value // We want to exclude both class and function here, this is necessary to issue an error when there are both // default export-assignment and default export function and class declaration. - var flags = node.kind === 240 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 241 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -22302,7 +22388,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 261 /* SourceFile */) { + if (node.parent.kind !== 262 /* SourceFile */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -22357,7 +22443,7 @@ var ts; function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); // Declare a 'member' if the container is an ES5 class or ES6 constructor - if (container.kind === 225 /* FunctionDeclaration */ || container.kind === 184 /* FunctionExpression */) { + if (container.kind === 226 /* FunctionDeclaration */ || container.kind === 184 /* FunctionExpression */) { container.symbol.members = container.symbol.members || ts.createMap(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); @@ -22405,7 +22491,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 227 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -22541,13 +22627,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 206 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 207 /* EmptyStatement */) || // report error on class declarations - node.kind === 226 /* ClassDeclaration */ || + node.kind === 227 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 230 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 231 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 229 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 230 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -22561,7 +22647,7 @@ var ts; // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 205 /* VariableStatement */ || + (node.kind !== 206 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -22585,13 +22671,13 @@ var ts; return computeCallExpression(node, subtreeFlags); case 180 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); case 183 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); case 192 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); case 144 /* Parameter */: return computeParameter(node, subtreeFlags); @@ -22599,23 +22685,23 @@ var ts; return computeArrowFunction(node, subtreeFlags); case 184 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); case 197 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return computeCatchClause(node, subtreeFlags); case 199 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); @@ -22628,7 +22714,7 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); case 177 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); @@ -23113,8 +23199,8 @@ var ts; case 116 /* AbstractKeyword */: case 123 /* DeclareKeyword */: case 75 /* ConstKeyword */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: + case 230 /* EnumDeclaration */: + case 261 /* EnumMember */: case 182 /* TypeAssertionExpression */: case 200 /* AsExpression */: case 201 /* NonNullExpression */: @@ -23122,18 +23208,18 @@ var ts; // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 247 /* JsxElement */: + case 248 /* JsxSelfClosingElement */: + case 249 /* JsxOpeningElement */: case 10 /* JsxText */: - case 249 /* JsxClosingElement */: - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: - case 252 /* JsxExpression */: + case 250 /* JsxClosingElement */: + case 251 /* JsxAttribute */: + case 252 /* JsxSpreadAttribute */: + case 253 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: // for-of might be ESNext if it has a rest destructuring transformFlags |= 8 /* AssertESNext */; // FALLTHROUGH @@ -23143,8 +23229,9 @@ var ts; case 15 /* TemplateTail */: case 194 /* TemplateExpression */: case 181 /* TaggedTemplateExpression */: - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: case 114 /* StaticKeyword */: + case 202 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; @@ -23176,8 +23263,8 @@ var ts; case 164 /* UnionType */: case 165 /* IntersectionType */: case 166 /* ParenthesizedType */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: case 167 /* ThisType */: case 168 /* TypeOperator */: case 169 /* IndexedAccessType */: @@ -23207,7 +23294,7 @@ var ts; case 196 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 96 /* SuperKeyword */: @@ -23266,23 +23353,23 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 216 /* ReturnStatement */: - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 217 /* ReturnStatement */: + case 215 /* ContinueStatement */: + case 216 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -23306,18 +23393,18 @@ var ts; case 180 /* NewExpression */: case 175 /* ArrayLiteralExpression */: return 537396545 /* ArrayLiteralOrCallOrNewExcludes */; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return 574674241 /* ModuleExcludes */; case 144 /* Parameter */: return 536872257 /* ParameterExcludes */; case 185 /* ArrowFunction */: return 601249089 /* ArrowFunctionExcludes */; case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return 601281857 /* FunctionExcludes */; - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return 546309441 /* VariableDeclarationListExcludes */; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return 539358529 /* ClassExcludes */; case 150 /* Constructor */: @@ -23339,12 +23426,12 @@ var ts; case 153 /* CallSignature */: case 154 /* ConstructSignature */: case 155 /* IndexSignature */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; case 176 /* ObjectLiteralExpression */: return 540087617 /* ObjectLiteralExcludes */; - case 256 /* CatchClause */: + case 257 /* CatchClause */: return 537920833 /* CatchClauseExcludes */; case 172 /* ObjectBindingPattern */: case 173 /* ArrayBindingPattern */: @@ -23386,10 +23473,6 @@ var ts; ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); return resolved.path; } - /** Create Resolved from a file with unknown extension. */ - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } /** Adds `isExernalLibraryImport` to a Resolved to get a ResolvedModule. */ function resolvedModuleFromResolved(_a, isExternalLibraryImport) { var path = _a.path, extension = _a.extension; @@ -23402,13 +23485,14 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { + /** Reads from "main" or "types"/"typings" depending on `extensions`. */ + function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); switch (extensions) { - case 2 /* DtsOnly */: - case 0 /* TypeScript */: + case Extensions.DtsOnly: + case Extensions.TypeScript: return tryReadFromField("typings") || tryReadFromField("types"); - case 1 /* JavaScript */: + case Extensions.JavaScript: if (typeof jsonContent.main === "string") { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); @@ -23475,6 +23559,7 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } + return undefined; }); return typeRoots; } @@ -23535,7 +23620,11 @@ var ts; return ts.forEach(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2 /* DtsOnly */, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); }); } else { @@ -23552,7 +23641,8 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2 /* DtsOnly */, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, /*cache*/ undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -23605,31 +23695,134 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + if (!perModuleNameCache) { + moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + /** + * At first this function add entry directory -> module resolution result to the table. + * Then it computes the set of parent folders for 'directory' that should have the same module resolution result + * and for every parent folder in set it adds entry: parent -> module resolution. . + * Lets say we first directory name: /a/b/c/d/e and resolution result is: /a/b/bar.ts. + * Set of parent folders that should have the same result will be: + * [ + * /a/b/c/d, /a/b/c, /a/b + * ] + * this means that request for module resolution from file in any of these folder will be immediately found in cache. + */ + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + // if entry is already in cache do nothing + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + // find common prefix between directory and resolved file name + // this common prefix should be the shorted path that has the same resolution + // directory: /a/b/c/d/e + // resolvedFileName: /a/b/foo.d.ts + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent_5 = ts.getDirectoryPath(current); + if (parent_5 === current || directoryPathMap.contains(parent_5)) { + break; + } + directoryPathMap.set(parent_5, result); + current = parent_5; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + // find first position where directory and resolution differs + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + // find last directory separator before position i + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache[moduleName]; + if (result) { if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache[moduleName] = result; + // put result in per-module name cache + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; } if (traceEnabled) { if (result.resolvedModule) { @@ -23822,34 +24015,34 @@ var ts; return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0 /* TypeScript */) || tryResolve(1 /* JavaScript */); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } @@ -23866,10 +24059,33 @@ var ts; } function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } /* @internal */ function directoryProbablyExists(directoryName, host) { @@ -23908,11 +24124,11 @@ var ts; } } switch (extensions) { - case 2 /* DtsOnly */: + case Extensions.DtsOnly: return tryExtension(".d.ts", ts.Extension.Dts); - case 0 /* TypeScript */: + case Extensions.TypeScript: return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1 /* JavaScript */: + case Extensions.JavaScript: return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } function tryExtension(ext, extension) { @@ -23922,19 +24138,21 @@ var ts; } /** Return the file if it exists. */ function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } } - failedLookupLocations.push(fileName); - return undefined; } + failedLookupLocations.push(fileName); + return undefined; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var packageJsonPath = pathToPackageJson(candidate); @@ -23943,18 +24161,23 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); + var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); + if (mainOrTypesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); // A package.json "typings" may specify an exact filename, or may choose to omit an extension. - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - // Note: this would allow a package.json to specify a ".js" file as typings. Maybe that should be forbidden. - return resolvedFromAnyFile(fromFile); + var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); + if (fromExactFile) { + var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); + if (resolved_3) { + return resolved_3; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } - var x = tryAddingExtensions(typesFile, 0 /* TypeScript */, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; + var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved) { + return resolved; } } else { @@ -23964,7 +24187,7 @@ var ts; } } else { - if (state.traceEnabled) { + if (directoryExists && state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results @@ -23972,70 +24195,116 @@ var ts; } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + /** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */ + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + /** True if `extension` is one of the supported `extensions`. */ + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ false, cache); } function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { // Extensions parameter here doesn't actually matter, because typesOnly ensures we're just doing @types lookup, which is always DtsOnly. - return loadModuleFromNodeModulesWorker(2 /* DtsOnly */, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ true); + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ true, /*cache*/ undefined); } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); } }); } /** Load a module from a single node_modules directory, but not from any ancestors' node_modules directories. */ function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } - if (extensions !== 1 /* JavaScript */) { - return loadModuleFromNodeModulesFolder(2 /* DtsOnly */, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0 /* TypeScript */) || tryResolve(1 /* JavaScript */); - return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ false, failedLookupLocations); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); if (resolvedUsingSettings) { - return resolvedUsingSettings; + return { value: resolvedUsingSettings }; } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { // Climb up parent directories looking for a module. - var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state)); }); - if (resolved_3) { - return resolved_3; + if (resolved_4) { + return resolved_4; } - if (extensions === 0 /* TypeScript */) { + if (extensions === Extensions.TypeScript) { // If we didn't find the file normally, look it up in @types. return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state)); } } } @@ -24052,10 +24321,17 @@ var ts; } var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2 /* DtsOnly */, moduleName, globalCache, failedLookupLocations, state); + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + /** + * Wraps value to SearchResult. + * @returns undefined if value is undefined or { value } otherwise + */ + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ function forEachAncestorDirectory(directory, callback) { while (true) { @@ -24142,9 +24418,11 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, + getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, + getTypeFromTypeNode: getTypeFromTypeNode, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -24153,6 +24431,7 @@ var ts; getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, + signatureToString: signatureToString, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -24177,7 +24456,8 @@ var ts; // we deliberately exclude augmentations // since we are only interested in declarations of the module itself return tryFindAmbientModule(moduleName, /*withAugmentations*/ false); - } + }, + getApparentType: getApparentType }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -24281,6 +24561,7 @@ var ts; var visitedFlowNodes = []; var visitedFlowTypes = []; var potentialThisCollisions = []; + var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var TypeFacts; @@ -24501,7 +24782,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 230 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 230 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 231 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 231 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -24606,7 +24887,7 @@ var ts; return type.flags & 32768 /* Object */ ? type.objectFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 261 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 262 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -24662,9 +24943,21 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - // still might be illegal if usage is in the initializer of the variable declaration - return declaration.kind !== 223 /* VariableDeclaration */ || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + if (declaration.kind === 174 /* BindingElement */) { + // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) + var errorBindingElement = ts.getAncestor(usage, 174 /* BindingElement */); + if (errorBindingElement) { + return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + declaration.pos < errorBindingElement.pos; + } + // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 224 /* VariableDeclaration */), usage); + } + else if (declaration.kind === 224 /* VariableDeclaration */) { + // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) + return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return true; } // declaration is after usage // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) @@ -24673,9 +24966,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 205 /* VariableStatement */: - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 206 /* VariableStatement */: + case 212 /* ForStatement */: + case 214 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -24684,8 +24977,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -24713,6 +25006,15 @@ var ts; } return false; } + function getAncestorBindingPattern(node) { + while (node) { + if (ts.isBindingPattern(node)) { + return node; + } + node = node.parent; + } + return undefined; + } } // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with @@ -24736,7 +25038,7 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 278 /* JSDocComment */) { + if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 279 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || lastLocation.kind === 144 /* Parameter */ || @@ -24763,13 +25065,13 @@ var ts; } } switch (location.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 261 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 262 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports["default"]) { @@ -24792,7 +25094,7 @@ var ts; // which is not the desired behavior. if (moduleExports[name] && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 243 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 244 /* ExportSpecifier */)) { break; } } @@ -24800,7 +25102,7 @@ var ts; break loop; } break; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } @@ -24823,9 +25125,9 @@ var ts; } } break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064 /* Type */)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -24854,7 +25156,7 @@ var ts; // case 142 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 227 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 228 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -24867,7 +25169,7 @@ var ts; case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; @@ -24960,7 +25262,7 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 107455 /* Value */) === 107455 /* Value */) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 233 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 234 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -25048,7 +25350,7 @@ var ts; // Block-scoped variables cannot be used before their definition var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 223 /* VariableDeclaration */), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -25069,10 +25371,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 235 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 235 /* ImportDeclaration */) { + while (node && node.kind !== 236 /* ImportDeclaration */) { node = node.parent; } return node; @@ -25082,7 +25384,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 245 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 246 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -25207,19 +25509,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return getTargetOfImportClause(node); - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 239 /* ImportSpecifier */: + case 240 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 243 /* ExportSpecifier */: + case 244 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return getTargetOfExportAssignment(node); - case 233 /* NamespaceExportDeclaration */: + case 234 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node); } } @@ -25266,11 +25568,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 240 /* ExportAssignment */) { + if (node.kind === 241 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 243 /* ExportSpecifier */) { + else if (node.kind === 244 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -25298,14 +25600,16 @@ var ts; else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 234 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 235 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol) { return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); } - // Resolves a qualified name and any involved aliases + /** + * Resolves a qualified name and any involved aliases. + */ function resolveEntityName(name, meaning, ignoreErrors, dontResolveAlias, location) { if (ts.nodeIsMissing(name)) { return undefined; @@ -25626,11 +25930,11 @@ var ts; } } switch (location_1.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -25682,7 +25986,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -25722,7 +26026,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -25821,7 +26125,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -25867,7 +26171,7 @@ var ts; meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } else if (entityName.kind === 141 /* QualifiedName */ || entityName.kind === 177 /* PropertyAccessExpression */ || - entityName.parent.kind === 234 /* ImportEqualsDeclaration */) { + entityName.parent.kind === 235 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -25966,7 +26270,7 @@ var ts; while (node.kind === 166 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 229 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -25974,7 +26278,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 231 /* ModuleBlock */ && + node.parent.kind === 232 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -26066,9 +26370,9 @@ var ts; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - var parent_5 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_5) { - walkSymbol(parent_5, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + var parent_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_6) { + walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); } } if (accessibleSymbolChain) { @@ -26218,14 +26522,14 @@ var ts; while (i < length_1) { // Find group of type arguments for type parameters with the same declaring container. var start = i; - var parent_6 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_6); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_6, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); writePunctuation(writer, 22 /* DotToken */); } } @@ -26291,7 +26595,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 261 /* SourceFile */ || declaration.parent.kind === 231 /* ModuleBlock */; + return declaration.parent.kind === 262 /* SourceFile */ || declaration.parent.kind === 232 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -26305,25 +26609,6 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } - function writeIndexSignature(info, keyword) { - if (info) { - if (info.isReadonly) { - writeKeyword(writer, 130 /* ReadonlyKeyword */); - writeSpace(writer); - } - writePunctuation(writer, 20 /* OpenBracketToken */); - writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, keyword); - writePunctuation(writer, 21 /* CloseBracketToken */); - writePunctuation(writer, 55 /* ColonToken */); - writeSpace(writer); - writeType(info.type, 0 /* None */); - writePunctuation(writer, 24 /* SemicolonToken */); - writer.writeLine(); - } - } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { writeKeyword(writer, 130 /* ReadonlyKeyword */); @@ -26407,8 +26692,8 @@ var ts; writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 134 /* StringKeyword */); - writeIndexSignature(resolved.numberIndexInfo, 132 /* NumberKeyword */); + buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0 /* String */, enclosingDeclaration, globalFlags, symbolStack); + buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, 1 /* Number */, enclosingDeclaration, globalFlags, symbolStack); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -26588,6 +26873,10 @@ var ts; buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + var returnType = getReturnTypeOfSignature(signature); + if (flags & 2048 /* SuppressAnyReturnType */ && isTypeAny(returnType)) { + return; + } if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); writePunctuation(writer, 35 /* EqualsGreaterThanToken */); @@ -26600,7 +26889,6 @@ var ts; buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); } else { - var returnType = getReturnTypeOfSignature(signature); buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } } @@ -26620,6 +26908,32 @@ var ts; buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } + function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 130 /* ReadonlyKeyword */); + writeSpace(writer); + } + writePunctuation(writer, 20 /* OpenBracketToken */); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 55 /* ColonToken */); + writeSpace(writer); + switch (kind) { + case 1 /* Number */: + writeKeyword(writer, 132 /* NumberKeyword */); + break; + case 0 /* String */: + writeKeyword(writer, 134 /* StringKeyword */); + break; + } + writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 55 /* ColonToken */); + writeSpace(writer); + buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); + writePunctuation(writer, 24 /* SemicolonToken */); + writer.writeLine(); + } + } return _displayBuilder || (_displayBuilder = { buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, @@ -26630,6 +26944,7 @@ var ts; buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, + buildIndexSignatureDisplay: buildIndexSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay }); } @@ -26646,32 +26961,32 @@ var ts; switch (node.kind) { case 174 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 223 /* VariableDeclaration */: + case 224 /* 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 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 225 /* FunctionDeclaration */: - case 229 /* EnumDeclaration */: - case 234 /* ImportEqualsDeclaration */: + case 231 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 226 /* FunctionDeclaration */: + case 230 /* EnumDeclaration */: + case 235 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_7 = getDeclarationContainer(node); + var parent_8 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 234 /* ImportEqualsDeclaration */ && parent_7.kind !== 261 /* SourceFile */ && ts.isInAmbientContext(parent_7))) { - return isGlobalSourceFile(parent_7); + !(node.kind !== 235 /* ImportEqualsDeclaration */ && parent_8.kind !== 262 /* SourceFile */ && ts.isInAmbientContext(parent_8))) { + return isGlobalSourceFile(parent_8); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible - return isDeclarationVisible(parent_7); + return isDeclarationVisible(parent_8); case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: case 151 /* GetAccessor */: @@ -26688,7 +27003,7 @@ var ts; case 153 /* CallSignature */: case 155 /* IndexSignature */: case 144 /* Parameter */: - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: case 158 /* FunctionType */: case 159 /* ConstructorType */: case 161 /* TypeLiteral */: @@ -26701,18 +27016,18 @@ var ts; return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 236 /* ImportClause */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: + case 237 /* ImportClause */: + case 238 /* NamespaceImport */: + case 240 /* ImportSpecifier */: return false; // Type parameters are always visible case 143 /* TypeParameter */: // Source file and namespace export are always visible - case 261 /* SourceFile */: - case 233 /* NamespaceExportDeclaration */: + case 262 /* SourceFile */: + case 234 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return false; default: return false; @@ -26721,10 +27036,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 240 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 241 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 243 /* ExportSpecifier */) { + else if (node.parent.kind === 244 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -26817,12 +27132,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 223 /* VariableDeclaration */: - case 224 /* VariableDeclarationList */: - case 239 /* ImportSpecifier */: - case 238 /* NamedImports */: - case 237 /* NamespaceImport */: - case 236 /* ImportClause */: + case 224 /* VariableDeclaration */: + case 225 /* VariableDeclarationList */: + case 240 /* ImportSpecifier */: + case 239 /* NamedImports */: + case 238 /* NamespaceImport */: + case 237 /* ImportClause */: node = node.parent; break; default: @@ -26846,9 +27161,6 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1 /* Any */) !== 0; } - function isTypeNever(type) { - return type && (type.flags & 8192 /* Never */) !== 0; - } // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node) { @@ -27007,11 +27319,11 @@ var ts; } // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (declaration.parent.parent.kind === 212 /* ForInStatement */) { + if (declaration.parent.parent.kind === 213 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 /* TypeParameter */ | 262144 /* Index */) ? indexType : stringType; } - if (declaration.parent.parent.kind === 213 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 214 /* 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, @@ -27026,7 +27338,7 @@ var ts; return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536 /* JavaScriptFile */) && - declaration.kind === 223 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 224 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -27074,7 +27386,7 @@ var ts; return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 258 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 259 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -27177,7 +27489,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. - if (declaration.kind === 257 /* PropertyAssignment */) { + if (declaration.kind === 258 /* PropertyAssignment */) { return type; } return getWidenedType(type); @@ -27210,10 +27522,10 @@ var ts; return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 240 /* ExportAssignment */) { + if (declaration.kind === 241 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 286 /* JSDocPropertyTag */ && declaration.typeExpression) { + if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 287 /* JSDocPropertyTag */ && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } // Handle variable, parameter or property @@ -27443,8 +27755,8 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 226 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */ || - node.kind === 225 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || + if (node.kind === 227 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */ || + node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 185 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { @@ -27455,7 +27767,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 227 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 228 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -27464,8 +27776,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 227 /* InterfaceDeclaration */ || node.kind === 226 /* ClassDeclaration */ || - node.kind === 197 /* ClassExpression */ || node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 228 /* InterfaceDeclaration */ || node.kind === 227 /* ClassDeclaration */ || + node.kind === 197 /* ClassExpression */ || node.kind === 229 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -27497,11 +27809,13 @@ var ts; } 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. + /** + * 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); @@ -27616,7 +27930,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 228 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -27648,7 +27962,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 /* InterfaceDeclaration */) { + if (declaration.kind === 228 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -27705,7 +28019,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 285 /* JSDocTypedefTag */); + var declaration = ts.getDeclarationOfKind(symbol, 286 /* JSDocTypedefTag */); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -27716,7 +28030,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 228 /* TypeAliasDeclaration */); + declaration = ts.getDeclarationOfKind(symbol, 229 /* TypeAliasDeclaration */); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -27750,7 +28064,7 @@ var ts; function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 /* EnumDeclaration */) { + if (declaration.kind === 230 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -27778,7 +28092,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 /* EnumDeclaration */) { + if (declaration.kind === 230 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -28176,6 +28490,9 @@ var ts; } setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } + /** + * Converts an AnonymousType to a ResolvedType. + */ function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; if (type.target) { @@ -28306,8 +28623,8 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is {}. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint.flags & 262144 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 262144 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; @@ -28618,7 +28935,7 @@ var ts; } function isJSDocOptionalParameter(node) { if (node.flags & 65536 /* JavaScriptFile */) { - if (node.type && node.type.kind === 273 /* JSDocOptionalType */) { + if (node.type && node.type.kind === 274 /* JSDocOptionalType */) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -28629,7 +28946,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 273 /* JSDocOptionalType */; + return paramTag.typeExpression.type.kind === 274 /* JSDocOptionalType */; } } } @@ -28685,7 +29002,7 @@ var ts; // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct // signature. - for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { + for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; // Include parameter symbol instead of property symbol in the signature @@ -28773,12 +29090,12 @@ var ts; if (!symbol) return emptyArray; var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { + for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { case 158 /* FunctionType */: case 159 /* ConstructorType */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 150 /* Constructor */: @@ -28789,7 +29106,7 @@ var ts; case 152 /* SetAccessor */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 274 /* JSDocFunctionType */: + case 275 /* JSDocFunctionType */: // 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). @@ -29080,7 +29397,7 @@ var ts; switch (node.kind) { case 157 /* TypeReference */: return node.typeName; - case 272 /* JSDocTypeReference */: + case 273 /* JSDocTypeReference */: return node.name; case 199 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other @@ -29108,7 +29425,7 @@ var ts; if (symbol.flags & 524288 /* TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 /* Value */ && node.kind === 272 /* JSDocTypeReference */) { + if (symbol.flags & 107455 /* Value */ && node.kind === 273 /* JSDocTypeReference */) { // A JSDocTypeReference may have resolved to a value (as opposed to a type). In // that case, the type of this reference is just the type of the value we resolved // to. @@ -29121,7 +29438,7 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 272 /* JSDocTypeReference */) { + if (node.kind === 273 /* JSDocTypeReference */) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); @@ -29163,9 +29480,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: return declaration; } } @@ -29358,8 +29675,9 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; + if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } } @@ -29479,8 +29797,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; addTypeToIntersection(typeSet, type); } } @@ -29618,7 +29936,7 @@ var ts; getIndexInfoOfType(objectType, 0 /* String */) || undefined; if (indexInfo) { - if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return unknownType; } @@ -29745,7 +30063,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 228 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 229 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -29875,7 +30193,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 227 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 228 /* InterfaceDeclaration */)) { if (!(ts.getModifierFlags(container) & 32 /* Static */) && (container.kind !== 150 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -29894,8 +30212,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118 /* AnyKeyword */: - case 263 /* JSDocAllType */: - case 264 /* JSDocUnknownType */: + case 264 /* JSDocAllType */: + case 265 /* JSDocUnknownType */: return anyType; case 134 /* StringKeyword */: return stringType; @@ -29913,21 +30231,21 @@ var ts; return nullType; case 129 /* NeverKeyword */: return neverType; - case 289 /* JSDocNullKeyword */: + case 290 /* JSDocNullKeyword */: return nullType; - case 290 /* JSDocUndefinedKeyword */: + case 291 /* JSDocUndefinedKeyword */: return undefinedType; - case 291 /* JSDocNeverKeyword */: + case 292 /* JSDocNeverKeyword */: return neverType; case 167 /* ThisType */: case 98 /* ThisKeyword */: return getTypeFromThisTypeNode(node); case 171 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 288 /* JSDocLiteralType */: + case 289 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); case 157 /* TypeReference */: - case 272 /* JSDocTypeReference */: + case 273 /* JSDocTypeReference */: return getTypeFromTypeReference(node); case 156 /* TypePredicate */: return booleanType; @@ -29936,29 +30254,29 @@ var ts; case 160 /* TypeQuery */: return getTypeFromTypeQueryNode(node); case 162 /* ArrayType */: - case 265 /* JSDocArrayType */: + case 266 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); case 163 /* TupleType */: return getTypeFromTupleTypeNode(node); case 164 /* UnionType */: - case 266 /* JSDocUnionType */: + case 267 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node); case 165 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); case 166 /* ParenthesizedType */: - case 268 /* JSDocNullableType */: - case 269 /* JSDocNonNullableType */: - case 276 /* JSDocConstructorType */: - case 277 /* JSDocThisType */: - case 273 /* JSDocOptionalType */: + case 269 /* JSDocNullableType */: + case 270 /* JSDocNonNullableType */: + case 277 /* JSDocConstructorType */: + case 278 /* JSDocThisType */: + case 274 /* JSDocOptionalType */: return getTypeFromTypeNode(node.type); - case 270 /* JSDocRecordType */: + case 271 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); case 158 /* FunctionType */: case 159 /* ConstructorType */: case 161 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 274 /* JSDocFunctionType */: + case 288 /* JSDocTypeLiteral */: + case 275 /* JSDocFunctionType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 168 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); @@ -29972,9 +30290,9 @@ var ts; case 141 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 267 /* JSDocTupleType */: + case 268 /* JSDocTupleType */: return getTypeFromJSDocTupleType(node); - case 275 /* JSDocVariadicType */: + case 276 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -30136,17 +30454,19 @@ var ts; var constraintType = getConstraintTypeFromMappedType(type); if (constraintType.flags & 262144 /* Index */) { var typeVariable_1 = constraintType.type; - var mappedTypeVariable = instantiateType(typeVariable_1, mapper); - if (typeVariable_1 !== mappedTypeVariable) { - return mapType(mappedTypeVariable, function (t) { - if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); - } - return t; - }); + if (typeVariable_1.flags & 16384 /* TypeParameter */) { + var mappedTypeVariable = instantiateType(typeVariable_1, mapper); + if (typeVariable_1 !== mappedTypeVariable) { + return mapType(mappedTypeVariable, function (t) { + if (isMappableType(t)) { + var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); + var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); + combinedMapper.mappedTypes = mapper.mappedTypes; + return instantiateMappedObjectType(type, combinedMapper); + } + return t; + }); + } } } return instantiateMappedObjectType(type, mapper); @@ -30170,12 +30490,12 @@ var ts; // Starting with the parent of the symbol's declaration, check if the mapper maps any of // the type parameters introduced by enclosing declarations. We just pick the first // declaration since multiple declarations will all have the same parent anyway. - var node = symbol.declarations[0].parent; + var node = symbol.declarations[0]; while (node) { switch (node.kind) { case 158 /* FunctionType */: case 159 /* ConstructorType */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 150 /* Constructor */: @@ -30186,10 +30506,10 @@ var ts; case 152 /* SetAccessor */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -30199,15 +30519,24 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 227 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 228 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 230 /* ModuleDeclaration */: - case 261 /* SourceFile */: + case 275 /* JSDocFunctionType */: + var func = node; + for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { + var p = _c[_b]; + if (ts.contains(mappedTypes, getTypeOfNode(p))) { + return true; + } + } + break; + case 231 /* ModuleDeclaration */: + case 262 /* SourceFile */: return false; } node = node.parent; @@ -30217,7 +30546,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 261 /* SourceFile */ || parentKind === 231 /* ModuleBlock */; + return parentKind === 262 /* SourceFile */ || parentKind === 232 /* ModuleBlock */; } return false; } @@ -30309,7 +30638,7 @@ var ts; case 192 /* BinaryExpression */: return node.operatorToken.kind === 53 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return isContextSensitive(node.initializer); case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -30376,7 +30705,7 @@ var ts; // subtype of T but not structurally identical to T. This specifically means that two distinct but // structurally identical types (such as two classes) are not considered instances of each other. function isTypeInstanceOf(source, target) { - return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); } /** * This is *not* a bi-directional relationship. @@ -30710,10 +31039,12 @@ var ts; } return false; } - // Compare two types and return - // Ternary.True if they are related with no assumptions, - // Ternary.Maybe if they are related with assumptions of other relationships, or - // Ternary.False if they are not related. + /** + * Compare two types and return + * * Ternary.True if they are related with no assumptions, + * * Ternary.Maybe if they are related with assumptions of other relationships, or + * * Ternary.False if they are not related. + */ function isRelatedTo(source, target, reportErrors, headMessage) { var result; if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 1048576 /* FreshLiteral */) { @@ -31177,8 +31508,11 @@ var ts; } } } - else if (relation !== identityRelation && isEmptyObjectType(resolveStructuredTypeMembers(target))) { - return -1 /* True */; + else if (relation !== identityRelation) { + var resolved = resolveStructuredTypeMembers(target); + if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1 /* Any */) { + return -1 /* True */; + } } return 0 /* False */; } @@ -31345,7 +31679,7 @@ var ts; return 0 /* False */; } var result = -1 /* True */; - for (var i = 0, len = sourceSignatures.length; i < len; i++) { + for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { return 0 /* False */; @@ -31584,8 +31918,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var t = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var t = types_8[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -31593,8 +31927,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -31700,8 +32034,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; result |= getFalsyFlags(t); } return result; @@ -31883,7 +32217,7 @@ var ts; case 174 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: @@ -32269,8 +32603,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -32411,7 +32745,7 @@ var ts; switch (source.kind) { case 70 /* Identifier */: return target.kind === 70 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 223 /* VariableDeclaration */ || target.kind === 174 /* BindingElement */) && + (target.kind === 224 /* VariableDeclaration */ || target.kind === 174 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98 /* ThisKeyword */: return target.kind === 98 /* ThisKeyword */; @@ -32516,8 +32850,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getTypeFacts(t); } return result; @@ -32605,7 +32939,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 /* ArrayLiteralExpression */ || node.parent.kind === 257 /* PropertyAssignment */ ? + return node.parent.kind === 175 /* ArrayLiteralExpression */ || node.parent.kind === 258 /* PropertyAssignment */ ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } @@ -32624,9 +32958,9 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return stringType; - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression) || unknownType; case 192 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); @@ -32636,9 +32970,9 @@ var ts; return getAssignedTypeOfArrayLiteralElement(parent, node); case 196 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -32664,26 +32998,26 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 212 /* ForInStatement */) { + if (node.parent.parent.kind === 213 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 213 /* ForOfStatement */) { + if (node.parent.parent.kind === 214 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 223 /* VariableDeclaration */ ? + return node.kind === 224 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 223 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */ ? + return node.kind === 224 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 223 /* VariableDeclaration */ && node.initializer && + return node.kind === 224 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || node.kind !== 174 /* BindingElement */ && node.parent.kind === 192 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); @@ -32710,7 +33044,7 @@ var ts; getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 253 /* CaseClause */) { + if (clause.kind === 254 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -32825,8 +33159,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; if (!(t.flags & 8192 /* Never */)) { if (!(getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -33461,8 +33795,8 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 231 /* ModuleBlock */ || - node.kind === 261 /* SourceFile */ || + node.kind === 232 /* ModuleBlock */ || + node.kind === 262 /* SourceFile */ || node.kind === 147 /* PropertyDeclaration */) { return node; } @@ -33542,7 +33876,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration_1.kind === 226 /* ClassDeclaration */ + if (declaration_1.kind === 227 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -33573,6 +33907,7 @@ var ts; } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkCollisionWithCapturedNewTargetVariable(node, node); checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; @@ -33611,7 +33946,7 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0 || isInTypeQuery(node)) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph @@ -33646,7 +33981,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 256 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 257 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -33671,8 +34006,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 211 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 224 /* VariableDeclarationList */).parent === container && + if (container.kind === 212 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 225 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -33793,11 +34128,11 @@ var ts; needToCaptureLexicalThis = (languageVersion < 2 /* ES2015 */); } switch (container.kind) { - case 230 /* ModuleDeclaration */: + case 231 /* 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 229 /* EnumDeclaration */: + case 230 /* 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; @@ -33861,9 +34196,9 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 274 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 275 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 277 /* JSDocThisType */) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 278 /* JSDocThisType */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -34254,8 +34589,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -34338,13 +34673,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 250 /* JsxAttribute */) { + if (attribute.kind === 251 /* JsxAttribute */) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 251 /* JsxSpreadAttribute */) { + else if (attribute.kind === 252 /* JsxSpreadAttribute */) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -34382,14 +34717,14 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 144 /* Parameter */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: case 174 /* BindingElement */: return getContextualTypeForInitializerExpression(node); case 185 /* ArrowFunction */: - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); case 195 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); @@ -34401,22 +34736,22 @@ var ts; return getTypeFromTypeNode(parent.type); case 192 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: + case 258 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); case 175 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); case 193 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: ts.Debug.assert(parent.parent.kind === 194 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); case 183 /* ParenthesizedExpression */: return getContextualType(parent); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return getContextualType(parent); - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: + case 251 /* JsxAttribute */: + case 252 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -34477,8 +34812,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -34683,18 +35018,18 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 257 /* PropertyAssignment */ || - memberDecl.kind === 258 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 258 /* PropertyAssignment */ || + memberDecl.kind === 259 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 257 /* PropertyAssignment */) { + if (memberDecl.kind === 258 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } else if (memberDecl.kind === 149 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 258 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 259 /* ShorthandPropertyAssignment */); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -34702,8 +35037,8 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 257 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 258 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 258 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 259 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912 /* Optional */; } @@ -34731,7 +35066,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 259 /* SpreadAssignment */) { + else if (memberDecl.kind === 260 /* SpreadAssignment */) { if (languageVersion < 5 /* ESNext */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -34842,13 +35177,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: checkJsxExpression(child); break; - case 246 /* JsxElement */: + case 247 /* JsxElement */: checkJsxElement(child); break; - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -35223,11 +35558,11 @@ var ts; // thus should have their types ignored var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 250 /* JsxAttribute */) { + if (node.attributes[i].kind === 251 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 251 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 252 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -35248,7 +35583,11 @@ var ts; } function checkJsxExpression(node) { if (node.expression) { - return checkExpression(node.expression); + var type = checkExpression(node.expression); + if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { + error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); + } + return type; } else { return unknownType; @@ -35276,7 +35615,7 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 /* PropertyAccessExpression */ || node.kind === 223 /* VariableDeclaration */ ? + var errorNode = node.kind === 177 /* PropertyAccessExpression */ || node.kind === 224 /* VariableDeclaration */ ? node.name : node.right; if (left.kind === 96 /* SuperKeyword */) { @@ -35453,7 +35792,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 224 /* VariableDeclarationList */) { + if (initializer.kind === 225 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -35482,7 +35821,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 212 /* ForInStatement */ && + if (node.kind === 213 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -35591,13 +35930,13 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_8 = signature.declaration && signature.declaration.parent; + var parent_9 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_8 === lastParent) { + if (lastParent && parent_9 === lastParent) { index++; } else { - lastParent = parent_8; + lastParent = parent_9; index = cutoffIndex; } } @@ -35605,7 +35944,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_8; + lastParent = parent_9; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -35909,7 +36248,7 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 145 /* Decorator */) { switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; @@ -35953,7 +36292,7 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 227 /* ClassDeclaration */) { // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); @@ -35998,7 +36337,7 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 227 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } @@ -36049,7 +36388,7 @@ var ts; function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 227 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } @@ -36554,7 +36893,7 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 144 /* Parameter */: @@ -36693,9 +37032,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 225 /* FunctionDeclaration */ + ? 226 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 223 /* VariableDeclaration */ + ? 224 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -36722,6 +37061,23 @@ var ts; function checkNonNullAssertion(node) { return getNonNullableType(checkExpression(node.expression)); } + function checkMetaProperty(node) { + checkGrammarMetaProperty(node); + ts.Debug.assert(node.keywordToken === 93 /* NewKeyword */ && node.name.text === "target", "Unrecognized meta-property."); + var container = ts.getNewTargetContainer(node); + if (!container) { + error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); + return unknownType; + } + else if (container.kind === 150 /* Constructor */) { + var symbol = getSymbolOfNode(container.parent); + return getTypeOfSymbol(symbol); + } + else { + var symbol = getSymbolOfNode(container); + return getTypeOfSymbol(symbol); + } + } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks) { @@ -36863,7 +37219,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 204 /* Block */) { + if (func.body.kind !== 205 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -36953,7 +37309,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 218 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 219 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -37015,7 +37371,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (ts.nodeIsMissing(func.body) || func.body.kind !== 204 /* Block */ || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 205 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -37095,6 +37451,7 @@ var ts; if (produceDiagnostics && node.kind !== 149 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); } return type; } @@ -37115,7 +37472,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 204 /* Block */) { + if (node.body.kind === 205 /* Block */) { checkSourceElement(node.body); } else { @@ -37184,7 +37541,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 237 /* NamespaceImport */; + return declaration && declaration.kind === 238 /* NamespaceImport */; } } } @@ -37201,6 +37558,16 @@ var ts; } function checkDeleteExpression(node) { checkExpression(node.expression); + var expr = ts.skipParentheses(node.expression); + if (expr.kind !== 177 /* PropertyAccessExpression */ && expr.kind !== 178 /* ElementAccessExpression */) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); + return booleanType; + } + var links = getNodeLinks(expr); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } return booleanType; } function checkTypeOfExpression(node) { @@ -37276,8 +37643,8 @@ var ts; } if (type.flags & 196608 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -37294,8 +37661,8 @@ var ts; } if (type.flags & 65536 /* Union */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -37304,8 +37671,8 @@ var ts; } if (type.flags & 131072 /* Intersection */) { var types = type.types; - for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { - var t = types_17[_a]; + for (var _a = 0, types_18 = types; _a < types_18.length; _a++) { + var t = types_18[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -37363,7 +37730,7 @@ var ts; } /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 257 /* PropertyAssignment */ || property.kind === 258 /* ShorthandPropertyAssignment */) { + if (property.kind === 258 /* PropertyAssignment */ || property.kind === 259 /* ShorthandPropertyAssignment */) { var name_20 = property.name; if (name_20.kind === 142 /* ComputedPropertyName */) { checkComputedPropertyName(name_20); @@ -37378,7 +37745,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 258 /* ShorthandPropertyAssignment */) { + if (property.kind === 259 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -37390,7 +37757,7 @@ var ts; error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); } } - else if (property.kind === 259 /* SpreadAssignment */) { + else if (property.kind === 260 /* SpreadAssignment */) { if (languageVersion < 5 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -37463,7 +37830,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 258 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 259 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -37493,7 +37860,7 @@ var ts; } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 259 /* SpreadAssignment */ ? + var error = target.parent.kind === 260 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -37530,8 +37897,8 @@ var ts; case 176 /* ObjectLiteralExpression */: case 187 /* TypeOfExpression */: case 201 /* NonNullExpression */: - case 247 /* JsxSelfClosingElement */: - case 246 /* JsxElement */: + case 248 /* JsxSelfClosingElement */: + case 247 /* JsxElement */: return true; case 193 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && @@ -38038,6 +38405,8 @@ var ts; return checkAssertion(node); case 201 /* NonNullExpression */: return checkNonNullAssertion(node); + case 202 /* MetaProperty */: + return checkMetaProperty(node); case 186 /* DeleteExpression */: return checkDeleteExpression(node); case 188 /* VoidExpression */: @@ -38058,13 +38427,13 @@ var ts; return undefinedWideningType; case 195 /* YieldExpression */: return checkYieldExpression(node); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return checkJsxExpression(node); - case 246 /* JsxElement */: + case 247 /* JsxElement */: return checkJsxElement(node); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 248 /* JsxOpeningElement */: + case 249 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -38118,7 +38487,7 @@ var ts; return false; } return node.kind === 149 /* MethodDeclaration */ || - node.kind === 225 /* FunctionDeclaration */ || + node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { @@ -38179,14 +38548,14 @@ var ts; switch (node.parent.kind) { case 185 /* ArrowFunction */: case 153 /* CallSignature */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 158 /* FunctionType */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: - var parent_9 = node.parent; - if (node === parent_9.type) { - return parent_9; + var parent_10 = node.parent; + if (node === parent_10.type) { + return parent_10; } } } @@ -38215,7 +38584,7 @@ var ts; if (node.kind === 155 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 /* FunctionType */ || node.kind === 225 /* FunctionDeclaration */ || node.kind === 159 /* ConstructorType */ || + else if (node.kind === 158 /* FunctionType */ || node.kind === 226 /* FunctionDeclaration */ || node.kind === 159 /* ConstructorType */ || node.kind === 153 /* CallSignature */ || node.kind === 150 /* Constructor */ || node.kind === 154 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); @@ -38349,7 +38718,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 227 /* InterfaceDeclaration */) { + if (node.kind === 228 /* 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 @@ -38445,7 +38814,7 @@ var ts; if (n.kind === 98 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 /* FunctionExpression */ && n.kind !== 225 /* FunctionDeclaration */) { + else if (n.kind !== 184 /* FunctionExpression */ && n.kind !== 226 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } @@ -38480,7 +38849,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -38641,8 +39010,8 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 227 /* InterfaceDeclaration */ && - n.parent.kind !== 226 /* ClassDeclaration */ && + if (n.parent.kind !== 228 /* InterfaceDeclaration */ && + n.parent.kind !== 227 /* ClassDeclaration */ && n.parent.kind !== 197 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { @@ -38770,7 +39139,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 227 /* InterfaceDeclaration */ || node.parent.kind === 161 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 228 /* InterfaceDeclaration */ || node.parent.kind === 161 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -38781,7 +39150,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 === 225 /* FunctionDeclaration */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */ || node.kind === 150 /* Constructor */) { + if (node.kind === 226 /* FunctionDeclaration */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */ || node.kind === 150 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -38903,16 +39272,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -38924,7 +39293,8 @@ var ts; } function checkNonThenableType(type, location, message) { type = getWidenedType(type); - if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + var apparentType = getApparentType(type); + if ((apparentType.flags & (1 /* Any */ | 8192 /* Never */)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -39175,7 +39545,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -39238,7 +39608,7 @@ var ts; checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -39271,6 +39641,7 @@ var ts; checkFunctionOrMethodDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -39342,28 +39713,28 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 261 /* SourceFile */: - case 230 /* ModuleDeclaration */: + case 262 /* SourceFile */: + case 231 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 204 /* Block */: - case 232 /* CaseBlock */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 205 /* Block */: + case 233 /* CaseBlock */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: checkUnusedLocalsAndParameters(node); break; case 150 /* Constructor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: @@ -39387,7 +39758,7 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 227 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 228 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_2 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { @@ -39420,9 +39791,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 223 /* VariableDeclaration */ && - (declaration.parent.parent.kind === 212 /* ForInStatement */ || - declaration.parent.parent.kind === 213 /* ForOfStatement */)) { + if (declaration.kind === 224 /* VariableDeclaration */ && + (declaration.parent.parent.kind === 213 /* ForInStatement */ || + declaration.parent.parent.kind === 214 /* ForOfStatement */)) { return; } } @@ -39485,7 +39856,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - error(declaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + errorUnusedLocal(declaration.name, local.name); } } } @@ -39494,7 +39865,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 204 /* Block */) { + if (node.kind === 205 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -39542,6 +39913,11 @@ var ts; potentialThisCollisions.push(node); } } + function checkCollisionWithCapturedNewTargetVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_newTarget")) { + potentialNewTargetCollisions.push(node); + } + } // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; @@ -39559,6 +39935,22 @@ var ts; current = current.parent; } } + function checkIfNewTargetIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { + var isDeclaration_2 = node.kind !== 70 /* Identifier */; + if (isDeclaration_2) { + error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); + } + return; + } + current = current.parent; + } + } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -39570,8 +39962,8 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 70 /* Identifier */; - if (isDeclaration_2) { + var isDeclaration_3 = node.kind !== 70 /* Identifier */; + if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -39588,12 +39980,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 230 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 231 /* 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 === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(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)); } @@ -39603,12 +39995,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 230 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 231 /* 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 === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -39643,7 +40035,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 === 223 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 224 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -39653,17 +40045,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 224 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 205 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 225 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 206 /* 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 === 204 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 231 /* ModuleBlock */ || - container.kind === 230 /* ModuleDeclaration */ || - container.kind === 261 /* SourceFile */); + (container.kind === 205 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 232 /* ModuleBlock */ || + container.kind === 231 /* ModuleDeclaration */ || + container.kind === 262 /* 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 @@ -39708,7 +40100,8 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144 /* Parameter */) { + if (symbol.valueDeclaration.kind === 144 /* Parameter */ || + symbol.valueDeclaration.kind === 174 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -39756,7 +40149,7 @@ var ts; } } if (node.kind === 174 /* BindingElement */) { - if (node.parent.kind === 172 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */) { + if (node.parent.kind === 172 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */ && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements @@ -39764,13 +40157,13 @@ var ts; checkComputedPropertyName(node.propertyName); } // check private/protected variable access - var parent_10 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_10); + var parent_11 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_11); var name_24 = node.propertyName || node.name; var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_24)); markPropertyAsReferenced(property); - if (parent_10.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_10, parent_10.initializer, parentType, property); + if (parent_11.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); } } // For a binding pattern, check contained binding elements @@ -39785,7 +40178,7 @@ var ts; // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 212 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 213 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -39796,7 +40189,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 212 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 213 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -39819,18 +40212,19 @@ var ts; if (node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 146 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 223 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */) { + if (node.kind === 224 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 /* Parameter */ && right.kind === 223 /* VariableDeclaration */) || - (left.kind === 223 /* VariableDeclaration */ && right.kind === 144 /* Parameter */)) { + if ((left.kind === 144 /* Parameter */ && right.kind === 224 /* VariableDeclaration */) || + (left.kind === 224 /* VariableDeclaration */ && right.kind === 144 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -39881,7 +40275,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 206 /* EmptyStatement */) { + if (node.thenStatement.kind === 207 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -39901,12 +40295,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 224 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 225 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 225 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -39929,7 +40323,7 @@ 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 === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 225 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { @@ -39968,7 +40362,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 === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 225 /* 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); @@ -40318,7 +40712,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 254 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 255 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -40330,7 +40724,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 253 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 254 /* 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 comparable @@ -40361,7 +40755,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 219 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 220 /* 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; @@ -40501,7 +40895,7 @@ var ts; /** Check each type parameter and check that type parameters have no duplicate type parameter declarations */ function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { @@ -40522,7 +40916,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 /* ClassDeclaration */ || declaration.kind === 227 /* InterfaceDeclaration */) { + if (declaration.kind === 227 /* ClassDeclaration */ || declaration.kind === 228 /* InterfaceDeclaration */) { if (!firstDecl) { firstDecl = declaration; } @@ -40555,6 +40949,7 @@ var ts; if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -40590,7 +40985,7 @@ var ts; checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 226 /* ClassDeclaration */) { + baseType_1.symbol.valueDeclaration.kind === 227 /* ClassDeclaration */) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -40751,7 +41146,7 @@ var ts; // TypeScript 1.0 spec (April 2014): // When a generic interface has multiple declarations, all declarations must have identical type parameter // lists, i.e. identical type parameter names with identical constraints in identical order. - for (var i = 0, len = list1.length; i < len; i++) { + for (var i = 0; i < list1.length; i++) { var tp1 = list1[i]; var tp2 = list2[i]; if (tp1.name.text !== tp2.name.text) { @@ -40811,7 +41206,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 228 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -40953,6 +41348,7 @@ var ts; } return undefined; case 8 /* NumericLiteral */: + checkGrammarNumericLiteral(e); return +e.text; case 183 /* ParenthesizedExpression */: return evalConstant(e.expression); @@ -41033,6 +41429,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); @@ -41061,7 +41458,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 229 /* EnumDeclaration */) { + if (declaration.kind !== 230 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -41084,8 +41481,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 226 /* ClassDeclaration */ || - (declaration.kind === 225 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 227 /* ClassDeclaration */ || + (declaration.kind === 226 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -41149,7 +41546,7 @@ 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, 226 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 227 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -41200,23 +41597,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 240 /* ExportAssignment */: - case 241 /* ExportDeclaration */: + case 241 /* ExportAssignment */: + case 242 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 234 /* ImportEqualsDeclaration */: - case 235 /* ImportDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; case 174 /* BindingElement */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: var name_25 = node.name; if (ts.isBindingPattern(name_25)) { for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { @@ -41227,12 +41624,12 @@ var ts; break; } // fallthrough - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 225 /* FunctionDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 226 /* FunctionDeclaration */: + case 228 /* InterfaceDeclaration */: + case 231 /* ModuleDeclaration */: + case 229 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -41273,9 +41670,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 231 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 241 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 232 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 242 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -41308,7 +41705,7 @@ var ts; (symbol.flags & 793064 /* Type */ ? 793064 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 243 /* ExportSpecifier */ ? + var message = node.kind === 244 /* 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)); @@ -41336,7 +41733,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 238 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -41393,8 +41790,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 231 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 232 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -41408,7 +41805,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 261 /* SourceFile */ || node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 230 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 262 /* SourceFile */ || node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 231 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -41434,9 +41831,14 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 261 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 230 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + var container = node.parent.kind === 262 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 231 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + if (node.isExportEquals) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + } + else { + error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); + } return; } // Grammar checking @@ -41510,7 +41912,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 225 /* FunctionDeclaration */ && declaration.kind !== 149 /* MethodDeclaration */) || + return (declaration.kind !== 226 /* FunctionDeclaration */ && declaration.kind !== 149 /* MethodDeclaration */) || !!declaration.body; } } @@ -41523,10 +41925,10 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: + case 231 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 226 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -41575,71 +41977,71 @@ var ts; return checkIndexedAccessType(node); case 170 /* MappedType */: return checkMappedType(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 204 /* Block */: - case 231 /* ModuleBlock */: + case 205 /* Block */: + case 232 /* ModuleBlock */: return checkBlock(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return checkVariableStatement(node); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return checkExpressionStatement(node); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return checkIfStatement(node); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return checkDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return checkWhileStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return checkForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return checkForInStatement(node); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return checkForOfStatement(node); - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 215 /* ContinueStatement */: + case 216 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return checkReturnStatement(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return checkWithStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return checkSwitchStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return checkLabeledStatement(node); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return checkThrowStatement(node); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return checkTryStatement(node); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return checkVariableDeclaration(node); case 174 /* BindingElement */: return checkBindingElement(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return checkClassDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return checkImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return checkExportDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return checkExportAssignment(node); - case 206 /* EmptyStatement */: + case 207 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 222 /* DebuggerStatement */: + case 223 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 244 /* MissingDeclaration */: + case 245 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -41696,6 +42098,7 @@ var ts; // Grammar checking checkGrammarSourceFile(node); potentialThisCollisions.length = 0; + potentialNewTargetCollisions.length = 0; deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; ts.forEach(node.statements, checkSourceElement); @@ -41715,6 +42118,10 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } + if (potentialNewTargetCollisions.length) { + ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); + potentialNewTargetCollisions.length = 0; + } links.flags |= 1 /* TypeChecked */; } } @@ -41772,7 +42179,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 217 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 218 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -41795,14 +42202,14 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; case 197 /* ClassExpression */: @@ -41812,8 +42219,8 @@ var ts; } // fall through; this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -41872,10 +42279,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 143 /* TypeParameter */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 230 /* EnumDeclaration */: return true; } } @@ -41885,7 +42292,7 @@ var ts; while (node.parent && node.parent.kind === 141 /* QualifiedName */) { node = node.parent; } - return node.parent && (node.parent.kind === 157 /* TypeReference */ || node.parent.kind === 272 /* JSDocTypeReference */); + return node.parent && (node.parent.kind === 157 /* TypeReference */ || node.parent.kind === 273 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; @@ -41912,10 +42319,10 @@ var ts; while (nodeOnRightSide.parent.kind === 141 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 234 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 235 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 240 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 241 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -41939,13 +42346,13 @@ var ts; default: } } - if (entityName.parent.kind === 240 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 241 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */); } if (entityName.kind !== 177 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 234 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 235 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -41995,10 +42402,10 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 /* TypeReference */ || entityName.parent.kind === 272 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = (entityName.parent.kind === 157 /* TypeReference */ || entityName.parent.kind === 273 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 250 /* JsxAttribute */) { + else if (entityName.parent.kind === 251 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 156 /* TypePredicate */) { @@ -42008,7 +42415,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -42066,7 +42473,7 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 235 /* ImportDeclaration */ || node.parent.kind === 241 /* ExportDeclaration */) && + ((node.parent.kind === 236 /* ImportDeclaration */ || node.parent.kind === 242 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -42093,7 +42500,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 === 258 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 259 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; @@ -42159,7 +42566,7 @@ var ts; // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 213 /* ForOfStatement */) { + if (expr.parent.kind === 214 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -42171,7 +42578,7 @@ var ts; } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 257 /* PropertyAssignment */) { + if (expr.parent.kind === 258 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } @@ -42312,7 +42719,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 261 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 262 /* SourceFile */) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -42369,7 +42776,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 204 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 205 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -42415,16 +42822,16 @@ var ts; return true; } switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: - case 236 /* ImportClause */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 235 /* ImportEqualsDeclaration */: + case 237 /* ImportClause */: + case 238 /* NamespaceImport */: + case 240 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return node.expression && node.expression.kind === 70 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -42434,7 +42841,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 261 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 262 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -42500,7 +42907,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 260 /* EnumMember */) { + if (node.kind === 261 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -42601,9 +43008,9 @@ var ts; if (startInDeclarationContainer) { // When resolving the name of a declaration as a value, we need to start resolution // at a point outside of the declaration. - var parent_11 = reference.parent; - if (ts.isDeclaration(parent_11) && reference === parent_11.name) { - location = getDeclarationContainer(parent_11); + var parent_12 = reference.parent; + if (ts.isDeclaration(parent_12) && reference === parent_12.name) { + location = getDeclarationContainer(parent_12); } } return resolveName(location, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -42732,15 +43139,15 @@ var ts; // external modules cannot define or contribute to type declaration files var current = symbol; while (true) { - var parent_12 = getParentOfSymbol(current); - if (parent_12) { - current = parent_12; + var parent_13 = getParentOfSymbol(current); + if (parent_13) { + current = parent_13; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 261 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 262 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -42760,7 +43167,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 261 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 262 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -42946,7 +43353,7 @@ var ts; } switch (modifier.kind) { case 75 /* ConstKeyword */: - if (node.kind !== 229 /* EnumDeclaration */ && node.parent.kind === 226 /* ClassDeclaration */) { + if (node.kind !== 230 /* EnumDeclaration */ && node.parent.kind === 227 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); } break; @@ -42972,7 +43379,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + else if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -42995,7 +43402,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + else if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 144 /* Parameter */) { @@ -43031,7 +43438,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 227 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 144 /* Parameter */) { @@ -43046,13 +43453,13 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 227 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === 144 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 231 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 232 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -43062,14 +43469,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 226 /* ClassDeclaration */) { + if (node.kind !== 227 /* ClassDeclaration */) { if (node.kind !== 149 /* MethodDeclaration */ && node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 151 /* GetAccessor */ && node.kind !== 152 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 226 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 227 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -43111,7 +43518,7 @@ var ts; } return; } - else if ((node.kind === 235 /* ImportDeclaration */ || node.kind === 234 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 236 /* ImportDeclaration */ || node.kind === 235 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 144 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { @@ -43145,29 +43552,29 @@ var ts; case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 155 /* IndexSignature */: - case 230 /* ModuleDeclaration */: - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: - case 240 /* ExportAssignment */: + case 231 /* ModuleDeclaration */: + case 236 /* ImportDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 242 /* ExportDeclaration */: + case 241 /* ExportAssignment */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 144 /* Parameter */: return false; default: - if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { return false; } switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); - case 227 /* InterfaceDeclaration */: - case 205 /* VariableStatement */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 206 /* VariableStatement */: + case 229 /* TypeAliasDeclaration */: return true; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); default: ts.Debug.fail(); @@ -43181,7 +43588,7 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 149 /* MethodDeclaration */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: if (!node.asteriskToken) { @@ -43392,7 +43799,7 @@ var ts; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 225 /* FunctionDeclaration */ || + ts.Debug.assert(node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || node.kind === 149 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { @@ -43419,7 +43826,7 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 /* SpreadAssignment */) { + if (prop.kind === 260 /* SpreadAssignment */) { continue; } var name_28 = prop.name; @@ -43427,7 +43834,7 @@ var ts; // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_28); } - if (prop.kind === 258 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 259 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -43450,7 +43857,7 @@ 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 === 257 /* PropertyAssignment */ || prop.kind === 258 /* ShorthandPropertyAssignment */) { + if (prop.kind === 258 /* PropertyAssignment */ || prop.kind === 259 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_28.kind === 8 /* NumericLiteral */) { @@ -43500,7 +43907,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 251 /* JsxSpreadAttribute */) { + if (attr.kind === 252 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; @@ -43512,7 +43919,7 @@ var ts; return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 252 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 253 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -43521,7 +43928,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 224 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 225 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -43536,20 +43943,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 213 /* 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 = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 213 /* 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 === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 213 /* 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); @@ -43642,7 +44049,7 @@ 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 === 227 /* InterfaceDeclaration */) { + else if (node.parent.kind === 228 /* 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 === 161 /* TypeLiteral */) { @@ -43656,11 +44063,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 219 /* LabeledStatement */: + case 220 /* 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 === 214 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 215 /* ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -43668,8 +44075,8 @@ var ts; return false; } break; - case 218 /* SwitchStatement */: - if (node.kind === 215 /* BreakStatement */ && !node.label) { + case 219 /* SwitchStatement */: + if (node.kind === 216 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -43684,13 +44091,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 215 /* BreakStatement */ + var message = node.kind === 216 /* 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 === 215 /* BreakStatement */ + var message = node.kind === 216 /* 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); @@ -43717,7 +44124,7 @@ var ts; expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 212 /* ForInStatement */ && node.parent.parent.kind !== 213 /* ForOfStatement */) { + if (node.parent.parent.kind !== 213 /* ForInStatement */ && node.parent.parent.kind !== 214 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -43782,15 +44189,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 217 /* WithStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 209 /* IfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 218 /* WithStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: return false; - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -43805,6 +44212,13 @@ var ts; } } } + function checkGrammarMetaProperty(node) { + if (node.keywordToken === 93 /* NewKeyword */) { + if (node.name.text !== "target") { + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + } + } + } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -43845,7 +44259,7 @@ var ts; return true; } } - else if (node.parent.kind === 227 /* InterfaceDeclaration */) { + else if (node.parent.kind === 228 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -43878,13 +44292,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 227 /* InterfaceDeclaration */ || - node.kind === 228 /* TypeAliasDeclaration */ || - node.kind === 235 /* ImportDeclaration */ || - node.kind === 234 /* ImportEqualsDeclaration */ || - node.kind === 241 /* ExportDeclaration */ || - node.kind === 240 /* ExportAssignment */ || - node.kind === 233 /* NamespaceExportDeclaration */ || + if (node.kind === 228 /* InterfaceDeclaration */ || + node.kind === 229 /* TypeAliasDeclaration */ || + node.kind === 236 /* ImportDeclaration */ || + node.kind === 235 /* ImportEqualsDeclaration */ || + node.kind === 242 /* ExportDeclaration */ || + node.kind === 241 /* ExportAssignment */ || + node.kind === 234 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -43893,7 +44307,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 === 205 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 206 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -43919,7 +44333,7 @@ var ts; // to prevent noisiness. 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 === 204 /* Block */ || node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + if (node.parent.kind === 205 /* Block */ || node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -43932,8 +44346,22 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.isOctalLiteral && languageVersion >= 1 /* ES5 */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + if (node.isOctalLiteral) { + var diagnosticMessage = void 0; + if (languageVersion >= 1 /* ES5 */) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 171 /* LiteralType */)) { + diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 261 /* EnumMember */)) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; + } + if (diagnosticMessage) { + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37 /* MinusToken */; + var literal = (withMinus ? "-" : "") + "0o" + node.text; + return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); + } } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -43997,31 +44425,31 @@ var ts; _a[201 /* NonNullExpression */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[229 /* EnumDeclaration */] = [ + _a[230 /* EnumDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[230 /* ModuleDeclaration */] = [ + _a[231 /* ModuleDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[231 /* ModuleBlock */] = [ + _a[232 /* ModuleBlock */] = [ { name: "statements", test: ts.isStatement } ], - _a[234 /* ImportEqualsDeclaration */] = [ + _a[235 /* ImportEqualsDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[245 /* ExternalModuleReference */] = [ + _a[246 /* ExternalModuleReference */] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[260 /* EnumMember */] = [ + _a[261 /* EnumMember */] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -44059,11 +44487,11 @@ var ts; var result = initial; switch (node.kind) { // Leaf nodes - case 203 /* SemicolonClassElement */: - case 206 /* EmptyStatement */: + case 204 /* SemicolonClassElement */: + case 207 /* EmptyStatement */: case 198 /* OmittedExpression */: - case 222 /* DebuggerStatement */: - case 293 /* NotEmittedStatement */: + case 223 /* DebuggerStatement */: + case 294 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -44211,73 +44639,73 @@ var ts; result = reduceNodes(node.typeArguments, cbNodes, result); break; // Misc - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 204 /* Block */: + case 205 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 208 /* IfStatement */: + case 209 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 209 /* DoStatement */: + case 210 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 210 /* WhileStatement */: - case 217 /* WithStatement */: + case 211 /* WhileStatement */: + case 218 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 211 /* ForStatement */: + case 212 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 216 /* ReturnStatement */: - case 220 /* ThrowStatement */: + case 217 /* ReturnStatement */: + case 221 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 221 /* TryStatement */: + case 222 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44286,7 +44714,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44294,97 +44722,97 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 236 /* ImportClause */: + case 237 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 239 /* NamedImports */: + case 243 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // JSX - case 246 /* JsxElement */: + case 247 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 248 /* JsxSelfClosingElement */: + case 249 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.attributes, cbNodes, result); break; - case 249 /* JsxClosingElement */: + case 250 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 253 /* CaseClause */: + case 254 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // fall-through - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 256 /* CatchClause */: + case 257 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Top-level nodes - case 261 /* SourceFile */: + case 262 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; default: @@ -44542,10 +44970,10 @@ var ts; return node; } switch (node.kind) { - case 203 /* SemicolonClassElement */: - case 206 /* EmptyStatement */: + case 204 /* SemicolonClassElement */: + case 207 /* EmptyStatement */: case 198 /* OmittedExpression */: - case 222 /* DebuggerStatement */: + case 223 /* DebuggerStatement */: // No need to visit nodes with no children. return node; // Names @@ -44620,107 +45048,107 @@ var ts; case 199 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 204 /* Block */: + case 205 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, /*optional*/ true, liftToBlock)); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 214 /* ContinueStatement */: + case 215 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 215 /* BreakStatement */: + case 216 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, /*optional*/ true), visitNode(node.finallyBlock, visitor, ts.isBlock, /*optional*/ true)); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true)); - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 238 /* NamedImports */: + case 239 /* NamedImports */: return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 239 /* ImportSpecifier */: + case 240 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, /*optional*/ true)); - case 242 /* NamedExports */: + case 243 /* NamedExports */: return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 243 /* ExportSpecifier */: + case 244 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); // JSX - case 246 /* JsxElement */: + case 247 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 248 /* JsxOpeningElement */: + case 249 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 249 /* JsxClosingElement */: + case 250 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 253 /* CaseClause */: + case 254 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Top-level nodes - case 261 /* SourceFile */: + case 262 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -44836,7 +45264,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || ts.isTypeNode(node)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 199 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -45412,15 +45840,15 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 261 /* SourceFile */: - case 232 /* CaseBlock */: - case 231 /* ModuleBlock */: - case 204 /* Block */: + case 262 /* SourceFile */: + case 233 /* CaseBlock */: + case 232 /* ModuleBlock */: + case 205 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 226 /* ClassDeclaration */: - case 225 /* FunctionDeclaration */: + case 227 /* ClassDeclaration */: + case 226 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -45467,13 +45895,13 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitExportAssignment(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -45493,11 +45921,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 241 /* ExportDeclaration */ || - node.kind === 235 /* ImportDeclaration */ || - node.kind === 236 /* ImportClause */ || - (node.kind === 234 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 245 /* ExternalModuleReference */)) { + if (node.kind === 242 /* ExportDeclaration */ || + node.kind === 236 /* ImportDeclaration */ || + node.kind === 237 /* ImportClause */ || + (node.kind === 235 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 246 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -45539,7 +45967,7 @@ var ts; case 149 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 203 /* SemicolonClassElement */: + case 204 /* SemicolonClassElement */: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -45608,18 +46036,18 @@ var ts; // TypeScript index signatures are elided. case 145 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. case 147 /* PropertyDeclaration */: // TypeScript property declarations are elided. return undefined; case 150 /* Constructor */: return visitConstructor(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -45641,7 +46069,7 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: @@ -45660,7 +46088,7 @@ var ts; case 152 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: @@ -45694,18 +46122,18 @@ var ts; case 201 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -46113,7 +46541,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -46622,7 +47050,7 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; case 149 /* MethodDeclaration */: @@ -46645,7 +47073,7 @@ var ts; return serializeTypeNode(node.type); case 152 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: case 149 /* MethodDeclaration */: return ts.createIdentifier("Function"); @@ -46730,6 +47158,9 @@ var ts; } switch (node.kind) { case 104 /* VoidKeyword */: + case 137 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 129 /* NeverKeyword */: return ts.createVoidZero(); case 166 /* ParenthesizedType */: return serializeTypeNode(node.type); @@ -46768,34 +47199,7 @@ var ts; return serializeTypeReferenceNode(node); case 165 /* IntersectionType */: case 164 /* UnionType */: - { - var unionOrIntersection = node; - var serializedUnion = void 0; - for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - var serializedIndividual = serializeTypeNode(typeNode); - // Non identifier - if (serializedIndividual.kind !== 70 /* Identifier */) { - serializedUnion = undefined; - break; - } - // One of the individual is global object, return immediately - if (serializedIndividual.text === "Object") { - return serializedIndividual; - } - // Different types - if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { - serializedUnion = undefined; - break; - } - serializedUnion = serializedIndividual; - } - // If we were able to find common type - if (serializedUnion) { - return serializedUnion; - } - } - // Fallthrough + return serializeUnionOrIntersectionType(node); case 160 /* TypeQuery */: case 168 /* TypeOperator */: case 169 /* IndexedAccessType */: @@ -46810,6 +47214,37 @@ var ts; } return ts.createIdentifier("Object"); } + function serializeUnionOrIntersectionType(node) { + var serializedUnion; + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (ts.isVoidExpression(serializedIndividual)) { + // If we dont have any other type already set, set the initial type + if (!serializedUnion) { + serializedUnion = serializedIndividual; + } + } + else if (ts.isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") { + // One of the individual is global object, return immediately + return serializedIndividual; + } + else if (serializedUnion && !ts.isVoidExpression(serializedUnion)) { + // Different types + if (!ts.isIdentifier(serializedUnion) || + !ts.isIdentifier(serializedIndividual) || + serializedUnion.text !== serializedIndividual.text) { + return ts.createIdentifier("Object"); + } + } + else { + // Initialize the union type + serializedUnion = serializedIndividual; + } + } + // If we were able to find common type, use it + return serializedUnion; + } /** * Serializes a TypeReferenceNode to an appropriate JS constructor value for use with * decorator type metadata. @@ -47411,7 +47846,7 @@ var ts; recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 229 /* EnumDeclaration */) { + if (node.kind === 230 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -47530,8 +47965,8 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 231 /* ModuleBlock */) { - ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); + if (body.kind === 232 /* ModuleBlock */) { + saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; } @@ -47576,13 +48011,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 231 /* ModuleBlock */) { + if (body.kind !== 232 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 230 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 231 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -47623,7 +48058,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 237 /* NamespaceImport */) { + if (node.kind === 238 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -47855,16 +48290,16 @@ var ts; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. context.enableSubstitution(70 /* Identifier */); - context.enableSubstitution(258 /* ShorthandPropertyAssignment */); + context.enableSubstitution(259 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(230 /* ModuleDeclaration */); + context.enableEmitNotification(231 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 230 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 231 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 229 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 230 /* EnumDeclaration */; } /** * Hook for node emit. @@ -47960,9 +48395,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 261 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 230 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 229 /* EnumDeclaration */); + if (container && container.kind !== 262 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 231 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 230 /* EnumDeclaration */); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, /*location*/ node); } @@ -48082,11 +48517,11 @@ var ts; return visitObjectLiteralExpression(node); case 192 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return visitForOfStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return visitForStatement(node); case 188 /* VoidExpression */: return visitVoidExpression(node); @@ -48098,7 +48533,7 @@ var ts; return visitGetAccessorDeclaration(node); case 152 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: return visitFunctionExpression(node); @@ -48106,7 +48541,7 @@ var ts; return visitArrowFunction(node); case 144 /* Parameter */: return visitParameter(node); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return visitExpressionStatement(node); case 183 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); @@ -48119,7 +48554,7 @@ var ts; var objects = []; for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { var e = elements_3[_i]; - if (e.kind === 259 /* SpreadAssignment */) { + if (e.kind === 260 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -48131,7 +48566,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 257 /* PropertyAssignment */) { + if (e.kind === 258 /* PropertyAssignment */) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -48361,11 +48796,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 246 /* JsxElement */: + case 247 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -48375,11 +48810,11 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return visitJsxExpression(node); - case 246 /* JsxElement */: + case 247 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); default: ts.Debug.failBadSyntaxKind(node); @@ -48440,7 +48875,10 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, /*location*/ node) : node; } - else if (node.kind === 252 /* JsxExpression */) { + else if (node.kind === 253 /* JsxExpression */) { + if (node.expression === undefined) { + return ts.createLiteral(true); + } return visitJsxExpression(node); } else { @@ -48522,7 +48960,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 246 /* JsxElement */) { + if (node.kind === 247 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -48868,7 +49306,7 @@ var ts; case 149 /* MethodDeclaration */: // ES2017 method declarations may be 'async' return visitMethodDeclaration(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: // ES2017 function declarations may be 'async' return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: @@ -49032,7 +49470,7 @@ var ts; context.enableSubstitution(177 /* PropertyAccessExpression */); context.enableSubstitution(178 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(226 /* ClassDeclaration */); + context.enableEmitNotification(227 /* ClassDeclaration */); context.enableEmitNotification(149 /* MethodDeclaration */); context.enableEmitNotification(151 /* GetAccessor */); context.enableEmitNotification(152 /* SetAccessor */); @@ -49089,7 +49527,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 226 /* ClassDeclaration */ + return kind === 227 /* ClassDeclaration */ || kind === 150 /* Constructor */ || kind === 149 /* MethodDeclaration */ || kind === 151 /* GetAccessor */ @@ -49299,6 +49737,82 @@ var ts; */ SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; })(SuperCaptureResult || (SuperCaptureResult = {})); + // Facts we track as we traverse the tree + var HierarchyFacts; + (function (HierarchyFacts) { + HierarchyFacts[HierarchyFacts["None"] = 0] = "None"; + // + // Ancestor facts + // + HierarchyFacts[HierarchyFacts["Function"] = 1] = "Function"; + HierarchyFacts[HierarchyFacts["ArrowFunction"] = 2] = "ArrowFunction"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBody"] = 4] = "AsyncFunctionBody"; + HierarchyFacts[HierarchyFacts["NonStaticClassElement"] = 8] = "NonStaticClassElement"; + HierarchyFacts[HierarchyFacts["CapturesThis"] = 16] = "CapturesThis"; + HierarchyFacts[HierarchyFacts["ExportedVariableStatement"] = 32] = "ExportedVariableStatement"; + HierarchyFacts[HierarchyFacts["TopLevel"] = 64] = "TopLevel"; + HierarchyFacts[HierarchyFacts["Block"] = 128] = "Block"; + HierarchyFacts[HierarchyFacts["IterationStatement"] = 256] = "IterationStatement"; + HierarchyFacts[HierarchyFacts["IterationStatementBlock"] = 512] = "IterationStatementBlock"; + HierarchyFacts[HierarchyFacts["ForStatement"] = 1024] = "ForStatement"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 2048] = "ForInOrForOfStatement"; + HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 4096] = "ConstructorWithCapturedSuper"; + HierarchyFacts[HierarchyFacts["ComputedPropertyName"] = 8192] = "ComputedPropertyName"; + // NOTE: do not add more ancestor flags without also updating AncestorFactsMask below. + // + // Ancestor masks + // + HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 16383] = "AncestorFactsMask"; + // We are always in *some* kind of block scope, but only specific block-scope containers are + // top-level or Blocks. + HierarchyFacts[HierarchyFacts["BlockScopeIncludes"] = 0] = "BlockScopeIncludes"; + HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 4032] = "BlockScopeExcludes"; + // A source file is a top-level block scope. + HierarchyFacts[HierarchyFacts["SourceFileIncludes"] = 64] = "SourceFileIncludes"; + HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 3968] = "SourceFileExcludes"; + // Functions, methods, and accessors are both new lexical scopes and new block scopes. + HierarchyFacts[HierarchyFacts["FunctionIncludes"] = 65] = "FunctionIncludes"; + HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 16286] = "FunctionExcludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyIncludes"] = 69] = "AsyncFunctionBodyIncludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 16278] = "AsyncFunctionBodyExcludes"; + // Arrow functions are lexically scoped to their container, but are new block scopes. + HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 66] = "ArrowFunctionIncludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 16256] = "ArrowFunctionExcludes"; + // Constructors are both new lexical scopes and new block scopes. Constructors are also + // always considered non-static members of a class. + HierarchyFacts[HierarchyFacts["ConstructorIncludes"] = 73] = "ConstructorIncludes"; + HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 16278] = "ConstructorExcludes"; + // 'do' and 'while' statements are not block scopes. We track that the subtree is contained + // within an IterationStatement to indicate whether the embedded statement is an + // IterationStatementBlock. + HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 256] = "DoOrWhileStatementIncludes"; + HierarchyFacts[HierarchyFacts["DoOrWhileStatementExcludes"] = 0] = "DoOrWhileStatementExcludes"; + // 'for' statements are new block scopes and have special handling for 'let' declarations. + HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 1280] = "ForStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 3008] = "ForStatementExcludes"; + // 'for-in' and 'for-of' statements are new block scopes and have special handling for + // 'let' declarations. + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 2304] = "ForInOrForOfStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 1984] = "ForInOrForOfStatementExcludes"; + // Blocks (other than function bodies) are new block scopes. + HierarchyFacts[HierarchyFacts["BlockIncludes"] = 128] = "BlockIncludes"; + HierarchyFacts[HierarchyFacts["BlockExcludes"] = 3904] = "BlockExcludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockIncludes"] = 512] = "IterationStatementBlockIncludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 4032] = "IterationStatementBlockExcludes"; + // Computed property names track subtree flags differently than their containing members. + HierarchyFacts[HierarchyFacts["ComputedPropertyNameIncludes"] = 8192] = "ComputedPropertyNameIncludes"; + HierarchyFacts[HierarchyFacts["ComputedPropertyNameExcludes"] = 0] = "ComputedPropertyNameExcludes"; + // + // Subtree facts + // + HierarchyFacts[HierarchyFacts["NewTarget"] = 16384] = "NewTarget"; + HierarchyFacts[HierarchyFacts["NewTargetInComputedPropertyName"] = 32768] = "NewTargetInComputedPropertyName"; + // + // Subtree masks + // + HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -16384] = "SubtreeFactsMask"; + HierarchyFacts[HierarchyFacts["PropagateNewTargetMask"] = 49152] = "PropagateNewTargetMask"; + })(HierarchyFacts || (HierarchyFacts = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -49308,15 +49822,7 @@ var ts; context.onSubstituteNode = onSubstituteNode; var currentSourceFile; var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - var isInConstructorWithCapturedSuper; + var hierarchyFacts; /** * Used to track if we are emitting body of the converted loop */ @@ -49334,185 +49840,116 @@ var ts; } currentSourceFile = node; currentText = node.text; - var visited = saveStateAndInvoke(node, visitSourceFile); + var visited = visitSourceFile(node); ts.addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined; currentText = undefined; + hierarchyFacts = 0 /* None */; return visited; } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); + /** + * Sets the `HierarchyFacts` for this node prior to visiting this node's subtree, returning the facts set prior to modification. + * @param excludeFacts The existing `HierarchyFacts` to reset before visiting the subtree. + * @param includeFacts The new `HierarchyFacts` to set before visiting the subtree. + **/ + function enterSubtree(excludeFacts, includeFacts) { + var ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383 /* AncestorFactsMask */; + return ancestorFacts; } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - // don't treat content of nodes that start new lexical environment as part of converted loop copy or constructor body - isInConstructorWithCapturedSuper = false; - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 185 /* ArrowFunction */) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 131072 /* AsyncFunctionBody */)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - // keep track of the enclosing variable statement when in the context of - // variable statements, variable declarations, binding elements, and binding - // patterns. - switch (currentNode.kind) { - case 205 /* VariableStatement */: - enclosingVariableStatement = currentNode; - break; - case 224 /* VariableDeclarationList */: - case 223 /* VariableDeclaration */: - case 174 /* BindingElement */: - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function returnCapturedThis(node) { - return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + /** + * Restores the `HierarchyFacts` for this node's ancestor after visiting this node's + * subtree, propagating specific facts from the subtree. + * @param ancestorFacts The `HierarchyFacts` of the ancestor to restore after visiting the subtree. + * @param excludeFacts The existing `HierarchyFacts` of the subtree that should not be propagated. + * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. + **/ + function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 /* SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 216 /* ReturnStatement */ && !node.expression; + return hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ + && node.kind === 217 /* ReturnStatement */ + && !node.expression; } - function shouldCheckNode(node) { - return (node.transformFlags & 64 /* ES2015 */) !== 0 || - node.kind === 219 /* LabeledStatement */ || - (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); + function shouldVisitNode(node) { + return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 + || convertedLoopState !== undefined + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && ts.isStatement(node)) + || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); } - function visitorWorker(node) { - if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { - return returnCapturedThis(node); - } - else if (shouldCheckNode(node)) { + function visitor(node) { + if (shouldVisitNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128 /* ContainsES2015 */ || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { - // we want to dive in this branch either if node has children with ES2015 specific syntax - // or we are inside constructor that captures result of the super call so all returns without expression should be - // rewritten. Note: we skip expressions since returns should never appear there - return ts.visitEachChild(node, visitor, context); - } else { return node; } } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function functionBodyVisitor(node) { + if (shouldVisitNode(node)) { + return visitBlock(node, /*isFunctionBody*/ true); } - else { - result = visitNodesInConvertedLoop(node); - } - return result; + return node; } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 216 /* ReturnStatement */: - node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; - return visitReturnStatement(node); - case 205 /* VariableStatement */: - return visitVariableStatement(node); - case 218 /* SwitchStatement */: - return visitSwitchStatement(node); - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: - return visitBreakOrContinueStatement(node); - case 98 /* ThisKeyword */: - return visitThisKeyword(node); - case 70 /* Identifier */: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); + function callExpressionVisitor(node) { + if (node.kind === 96 /* SuperKeyword */) { + return visitSuperKeyword(/*isExpressionOfCall*/ true); } + return visitor(node); } function visitJavaScript(node) { switch (node.kind) { case 114 /* StaticKeyword */: return undefined; // elide static keyword - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return visitClassDeclaration(node); case 197 /* ClassExpression */: return visitClassExpression(node); case 144 /* Parameter */: return visitParameter(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); case 185 /* ArrowFunction */: return visitArrowFunction(node); case 184 /* FunctionExpression */: return visitFunctionExpression(node); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return visitVariableDeclaration(node); case 70 /* Identifier */: return visitIdentifier(node); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 219 /* LabeledStatement */: + case 219 /* SwitchStatement */: + return visitSwitchStatement(node); + case 233 /* CaseBlock */: + return visitCaseBlock(node); + case 205 /* Block */: + return visitBlock(node, /*isFunctionBody*/ false); + case 216 /* BreakStatement */: + case 215 /* ContinueStatement */: + return visitBreakOrContinueStatement(node); + case 220 /* LabeledStatement */: return visitLabeledStatement(node); - case 209 /* DoStatement */: - return visitDoStatement(node); - case 210 /* WhileStatement */: - return visitWhileStatement(node); - case 211 /* ForStatement */: - return visitForStatement(node); - case 212 /* ForInStatement */: - return visitForInStatement(node); - case 213 /* ForOfStatement */: - return visitForOfStatement(node); - case 207 /* ExpressionStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); + case 212 /* ForStatement */: + return visitForStatement(node, /*outermostLabeledStatement*/ undefined); + case 213 /* ForInStatement */: + return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); + case 214 /* ForOfStatement */: + return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); + case 208 /* ExpressionStatement */: return visitExpressionStatement(node); case 176 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return visitCatchClause(node); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); + case 142 /* ComputedPropertyName */: + return visitComputedPropertyName(node); case 175 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); case 179 /* CallExpression */: @@ -49537,54 +49974,82 @@ var ts; case 196 /* SpreadElement */: return visitSpreadElement(node); case 96 /* SuperKeyword */: - return visitSuperKeyword(); - case 195 /* YieldExpression */: - // `yield` will be handled by a generators transform. - return ts.visitEachChild(node, visitor, context); + return visitSuperKeyword(/*isExpressionOfCall*/ false); + case 98 /* ThisKeyword */: + return visitThisKeyword(node); + case 202 /* MetaProperty */: + return visitMetaProperty(node); case 149 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 205 /* VariableStatement */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + return visitAccessorDeclaration(node); + case 206 /* VariableStatement */: return visitVariableStatement(node); + case 217 /* ReturnStatement */: + return visitReturnStatement(node); default: - ts.Debug.failBadSyntaxKind(node); return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { + var ancestorFacts = enterSubtree(3968 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); var statements = []; startLexicalEnvironment(); var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ false, visitor); addCaptureThisForNodeIfNeeded(statements, node); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); } function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; + if (convertedLoopState !== undefined) { + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + // for switch statement allow only non-labeled break + convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitCaseBlock(node) { + var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8 /* Return */; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8 /* Return */; + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + node = returnCapturedThis(node); + } + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 185 /* ArrowFunction */) { - // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. - convertedLoopState.containsLexicalThis = true; - return node; + if (convertedLoopState) { + if (hierarchyFacts & 2 /* ArrowFunction */) { + // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword. + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + return node; } function visitIdentifier(node) { if (!convertedLoopState) { @@ -49604,13 +50069,13 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 215 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 216 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 215 /* BreakStatement */) { + if (node.kind === 216 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -49621,7 +50086,7 @@ var ts; } } else { - if (node.kind === 215 /* BreakStatement */) { + if (node.kind === 216 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -49813,6 +50278,9 @@ var ts; * @param extendsClauseElement The expression for the class `extends` clause. */ function addConstructor(statements, node, extendsClauseElement) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16278 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = ts.createFunctionDeclaration( @@ -49826,6 +50294,8 @@ var ts; ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); } statements.push(constructorFunction); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; } /** * Transforms the parameters of the constructor declaration of a class. @@ -49871,26 +50341,31 @@ var ts; addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + // determine whether the class is known syntactically to be a derived class (e.g. a + // class that extends a value that is not syntactically known to be `null`). + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94 /* NullKeyword */; + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { - isInConstructorWithCapturedSuper = superCaptureStatus === 1 /* ReplaceSuperCapture */; - return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); - }); - ts.addRange(statements, body); + if (superCaptureStatus === 1 /* ReplaceSuperCapture */) { + hierarchyFacts |= 4096 /* ConstructorWithCapturedSuper */; + } + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset)); } // Return `_this` unless we're sure enough that it would be pointless to add a return statement. // If there's a constructor that we can tell returns in enough places, then we *do not* want to add a return. - if (extendsClauseElement + if (isDerivedClass && superCaptureStatus !== 2 /* ReplaceWithReturn */ && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createIdentifier("_this"))); } ts.addRange(statements, endLexicalEnvironment()); + if (constructor) { + prependCaptureNewTargetIfNeeded(statements, constructor, /*copyOnWrite*/ false); + } var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ constructor ? constructor.body.statements : node.members), /*location*/ constructor ? constructor.body : node, @@ -49907,17 +50382,17 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 216 /* ReturnStatement */) { + if (statement.kind === 217 /* ReturnStatement */) { return true; } - else if (statement.kind === 208 /* IfStatement */) { + else if (statement.kind === 209 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 204 /* Block */) { + else if (statement.kind === 205 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -49930,9 +50405,9 @@ var ts; * * @returns The new statement offset into the `statements` array. */ - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, isDerivedClass, hasSynthesizedSuper, statementOffset) { // If this isn't a derived class, just capture 'this' for arrow functions if necessary. - if (!hasExtendsClause) { + if (!isDerivedClass) { if (ctor) { addCaptureThisForNodeIfNeeded(statements, ctor); } @@ -49975,9 +50450,8 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + if (firstStatement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } // Return the result if we have an immediate super() call on the last statement, @@ -49996,18 +50470,18 @@ var ts; return 2 /* ReplaceWithReturn */; } // Perform the capture. - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); // If we're actually replacing the original statement, we need to signal this to the caller. if (superCallExpression) { return 1 /* ReplaceSuperCapture */; } return 0 /* NoReplacement */; } + function createActualThis() { + return ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */); + } function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); + return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createIdentifier("_super"), ts.createNull()), ts.createFunctionApply(ts.createIdentifier("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis()); } /** * Visits a parameter declaration. @@ -50202,6 +50676,46 @@ var ts; ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } + function prependCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { + if (hierarchyFacts & 16384 /* NewTarget */) { + var newTarget = void 0; + switch (node.kind) { + case 185 /* ArrowFunction */: + return statements; + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + // Methods and accessors cannot be constructors, so 'new.target' will + // always return 'undefined'. + newTarget = ts.createVoidZero(); + break; + case 150 /* Constructor */: + // Class constructors can only be called with `new`, so `this.constructor` + // should be relatively safe to use. + newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); + break; + case 226 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + // Functions can be called or constructed, and may have a `this` due to + // being a member or when calling an imported function via `other_1.f()`. + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 92 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + var captureNewTargetStatement = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_newTarget", + /*type*/ undefined, newTarget) + ])); + if (copyOnWrite) { + return [captureNewTargetStatement].concat(statements); + } + statements.unshift(captureNewTargetStatement); + } + return statements; + } /** * Adds statements to the class body function for a class to define the members of the * class. @@ -50213,17 +50727,17 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 203 /* SemicolonClassElement */: + case 204 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; case 149 /* MethodDeclaration */: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case 151 /* GetAccessor */: case 152 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; case 150 /* Constructor */: @@ -50249,11 +50763,12 @@ var ts; * @param receiver The receiver for the member. * @param member The MethodDeclaration node. */ - function transformClassMethodDeclarationToStatement(receiver, member) { + function transformClassMethodDeclarationToStatement(receiver, member, container) { + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); - var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined); + var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), @@ -50264,6 +50779,7 @@ var ts; // No source map should be emitted for this statement to align with the // old emitter. ts.setEmitFlags(statement, 48 /* NoSourceMap */); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return statement; } /** @@ -50272,8 +50788,8 @@ var ts; * @param receiver The receiver for the member. * @param accessors The set of related get/set accessors. */ - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, /*startsOnNewLine*/ false), + function transformAccessorsToStatement(receiver, accessors, container) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false), /*location*/ ts.getSourceMapRange(accessors.firstAccessor)); // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the @@ -50287,8 +50803,9 @@ var ts; * * @param receiver The receiver for the member. */ - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); // To align with source maps in the old emitter, the receiver and property name // arguments are both mapped contiguously to the accessor name. var target = ts.getMutableClone(receiver); @@ -50299,7 +50816,7 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); + var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -50307,7 +50824,7 @@ var ts; properties.push(getter); } if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); + var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); var setter = ts.createPropertyAssignment("set", setterFunction); @@ -50324,6 +50841,7 @@ var ts; if (startsOnNewLine) { call.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return call; } /** @@ -50335,6 +50853,9 @@ var ts; if (node.transformFlags & 16384 /* ContainsLexicalThis */) { enableSubstitutionsForCapturedThis(); } + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16256 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */); var func = ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -50343,6 +50864,8 @@ var ts; /*type*/ undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8 /* CapturesThis */); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; return func; } /** @@ -50351,12 +50874,24 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, - /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.transformFlags & 64 /* ES2015 */ + var ancestorFacts = ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */ + ? enterSubtree(16278 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) + : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 /* ES2015 */ ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 /* NewTarget */ + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionExpression(node, + /*modifiers*/ undefined, name, + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body); } /** * Visits a FunctionDeclaration node. @@ -50364,12 +50899,22 @@ var ts; * @param node a FunctionDeclaration node. */ function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, - /*decorators*/ undefined, node.modifiers, node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.transformFlags & 64 /* ES2015 */ + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 /* ES2015 */ ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 /* NewTarget */ + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionDeclaration(node, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body); } /** * Transforms a function-like node into a FunctionExpression. @@ -50378,18 +50923,24 @@ var ts; * @param location The source-map location for the new FunctionExpression. * @param name The name of the new FunctionExpression. */ - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 185 /* ArrowFunction */) { - enclosingNonArrowFunction = node; + function transformFunctionLikeToExpression(node, location, name, container) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32 /* Static */) + ? enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) + : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */)) { + name = ts.getGeneratedNameForNode(node); } - var expression = ts.setOriginalNode(ts.createFunctionExpression( + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.setOriginalNode(ts.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, saveStateAndInvoke(node, transformFunctionBody), location), + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body, location), /*original*/ node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; } /** * Transforms the body of a function-like node. @@ -50451,6 +51002,7 @@ var ts; } var lexicalEnvironment = context.endLexicalEnvironment(); ts.addRange(statements, lexicalEnvironment); + prependCaptureNewTargetIfNeeded(statements, node, /*copyOnWrite*/ false); // If we added any final generated statements, this must be a multi-line block if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; @@ -50465,6 +51017,23 @@ var ts; ts.setOriginalNode(block, node.body); return block; } + function visitFunctionBodyDownLevel(node) { + var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); + return ts.updateBlock(updated, ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, /*copyOnWrite*/ true), + /*location*/ updated.statements)); + } + function visitBlock(node, isFunctionBody) { + if (isFunctionBody) { + // A function body is not a block scope. + return ts.visitEachChild(node, visitor, context); + } + var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */ + ? enterSubtree(4032 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */) + : enterSubtree(3904 /* BlockExcludes */, 128 /* BlockIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } /** * Visits an ExpressionStatement that contains a destructuring assignment. * @@ -50511,9 +51080,12 @@ var ts; if (ts.isDestructuringAssignment(node)) { return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, needsDestructuringValue); } + return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) == 0) { + var ancestorFacts = enterSubtree(0 /* None */, ts.hasModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + var updated; + if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0) { // we are inside a converted loop - hoist variable declarations var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -50531,14 +51103,18 @@ var ts; } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); }), node); + updated = ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); }), node); } else { // none of declarations has initializer - the entire variable statement can be deleted - return undefined; + updated = undefined; } } - return ts.visitEachChild(node, visitor, context); + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } /** * Visits a VariableDeclarationList that is block scoped (e.g. `let` or `const`). @@ -50546,25 +51122,28 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); + if (node.transformFlags & 64 /* ES2015 */) { + if (node.flags & 3 /* BlockScoped */) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); + ts.setOriginalNode(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 /* ContainsBindingPattern */ + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + // If the first or last declaration is a binding pattern, we need to modify + // the source map range for the declaration list. + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 /* ContainsBindingPattern */ - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - // If the first or last declaration is a binding pattern, we need to modify - // the source map range for the declaration list. - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; + return ts.visitEachChild(node, visitor, context); } /** * Gets a value indicating whether we should emit an explicit initializer for a variable @@ -50615,18 +51194,16 @@ var ts; var flags = resolver.getNodeCheckFlags(node); var isCapturedInFunction = flags & 131072 /* CapturedBlockScopedBinding */; var isDeclaredInLoop = flags & 262144 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + var emittedAsTopLevel = (hierarchyFacts & 64 /* TopLevel */) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); + && (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 212 /* ForInStatement */ - && enclosingBlockScopeContainer.kind !== 213 /* ForOfStatement */ + && (hierarchyFacts & 2048 /* ForInOrForOfStatement */) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, /*lookInLabeledStatements*/ false))); + && (hierarchyFacts & (1024 /* ForStatement */ | 2048 /* ForInOrForOfStatement */)) === 0)); return emitExplicitInitializer; } /** @@ -50655,55 +51232,52 @@ var ts; * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { - // If we are here it is because the name contains a binding pattern. + var ancestorFacts = enterSubtree(32 /* ExportedVariableStatement */, 0 /* None */); + var updated; if (ts.isBindingPattern(node.name)) { - var hoistTempVariables = enclosingVariableStatement - && ts.hasModifier(enclosingVariableStatement, 1 /* Export */); - return ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, - /*value*/ undefined, hoistTempVariables); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, + /*value*/ undefined, (ancestorFacts & 32 /* ExportedVariableStatement */) !== 0); } else { - result = ts.visitEachChild(node, visitor, context); + updated = ts.visitEachChild(node, visitor, context); } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } + function recordLabel(node) { + convertedLoopState.labels[node.label.text] = node.label.text; + } + function resetLabel(node) { + convertedLoopState.labels[node.label.text] = undefined; + } + function visitLabeledStatement(node) { + if (convertedLoopState && !convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); } - return result; + var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(statement) + ? visitIterationStatement(statement, /*outermostLabeledStatement*/ node) + : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { + var ancestorFacts = enterSubtree(excludeFacts, includeFacts); + var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitDoOrWhileStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 256 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement); } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(3008 /* ForStatementExcludes */, 1280 /* ForStatementIncludes */, node, outermostLabeledStatement); } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForInStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } - /** - * Visits a ForOfStatement and converts it into a compatible ForStatement. - * - * @param node A ForOfStatement. - */ - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function visitForOfStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, convertForOfToFor); } - function convertForOfToFor(node, convertedLoopBodyStatements) { + function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: // // for (let v of expr) { } @@ -50815,7 +51389,20 @@ var ts; /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); - return forStatement; + return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); + } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 212 /* ForStatement */: + return visitForStatement(node, outermostLabeledStatement); + case 213 /* ForInStatement */: + return visitForInStatement(node, outermostLabeledStatement); + case 214 /* ForOfStatement */: + return visitForOfStatement(node, outermostLabeledStatement); + } } /** * Visits an ObjectLiteralExpression with computed propety names. @@ -50829,31 +51416,40 @@ var ts; // Find the first computed property. // Everything until that point can be emitted as part of the initial object literal. var numInitialProperties = numProperties; + var numInitialPropertiesWithoutYield = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 /* ContainsYield */ - || property.name.kind === 142 /* ComputedPropertyName */) { + if ((property.transformFlags & 16777216 /* ContainsYield */ && hierarchyFacts & 4 /* AsyncFunctionBody */) + && i < numInitialPropertiesWithoutYield) { + numInitialPropertiesWithoutYield = i; + } + if (property.name.kind === 142 /* ComputedPropertyName */) { numInitialProperties = i; break; } } - ts.Debug.assert(numInitialProperties !== numProperties); - // For computed properties, we need to create a unique handle to the object - // literal so we can modify it without risking internal assignments tainting the object. - var temp = ts.createTempVariable(hoistVariableDeclaration); - // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), - /*location*/ undefined, node.multiLine), 32768 /* Indented */)); - if (node.multiLine) { - assignment.startsOnNewLine = true; + if (numInitialProperties !== numProperties) { + if (numInitialPropertiesWithoutYield < numInitialProperties) { + numInitialProperties = numInitialPropertiesWithoutYield; + } + // For computed properties, we need to create a unique handle to the object + // literal so we can modify it without risking internal assignments tainting the object. + var temp = ts.createTempVariable(hoistVariableDeclaration); + // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), + /*location*/ undefined, node.multiLine), 32768 /* Indented */)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + // We need to clone the temporary identifier so that we can write it on a + // new line + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - // We need to clone the temporary identifier so that we can write it on a - // new line - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); + return ts.visitEachChild(node, visitor, context); } function shouldConvertIterationStatementBody(node) { return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; @@ -50880,7 +51476,7 @@ var ts; } } } - function convertIterationStatementBodyIfNecessary(node, convert) { + function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) { if (!shouldConvertIterationStatementBody(node)) { var saveAllowedNonLabeledJumps = void 0; if (convertedLoopState) { @@ -50889,7 +51485,9 @@ var ts; saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; } - var result = convert ? convert(node, /*convertedLoopBodyStatements*/ undefined) : ts.visitEachChild(node, visitor, context); + var result = convert + ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined) + : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); if (convertedLoopState) { convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } @@ -50898,11 +51496,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 224 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 225 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -50939,7 +51537,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -50951,11 +51549,13 @@ var ts; ts.addRange(statements_4, lexicalEnvironment); loopBody = ts.createBlock(statements_4, /*location*/ undefined, /*multiline*/ true); } - if (!ts.isBlock(loopBody)) { + if (ts.isBlock(loopBody)) { + loopBody.multiLine = true; + } + else { loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 131072 /* AsyncFunctionBody */) !== 0 + var isAsyncBlockContainingAwait = hierarchyFacts & 4 /* AsyncFunctionBody */ && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -51038,25 +51638,24 @@ var ts; var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); var loop; if (convert) { - loop = convert(node, convertedLoopBodyStatements); + loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); } else { - loop = ts.getMutableClone(node); + var clone_4 = ts.getMutableClone(node); // clean statement part - loop.statement = undefined; + clone_4.statement = undefined; // visit childnodes to transform initializer/condition/incrementor parts - loop = ts.visitEachChild(loop, visitor, context); + clone_4 = ts.visitEachChild(clone_4, visitor, context); // set loop statement - loop.statement = ts.createBlock(convertedLoopBodyStatements, + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, /*location*/ undefined, /*multiline*/ true); // reset and re-aggregate the transform flags - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); + clone_4.transformFlags = 0; + ts.aggregateTransformFlags(clone_4); + loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } - statements.push(currentParent.kind === 219 /* LabeledStatement */ - ? ts.createLabel(currentParent.label, loop) - : loop); + statements.push(loop); return statements; } function copyOutParameter(outParam, copyDirection) { @@ -51186,18 +51785,18 @@ var ts; case 152 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 257 /* PropertyAssignment */: + case 149 /* MethodDeclaration */: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); + break; + case 258 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 149 /* MethodDeclaration */: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); - break; default: ts.Debug.failBadSyntaxKind(node); break; @@ -51241,22 +51840,32 @@ var ts; * @param method The MethodDeclaration node. * @param receiver The receiver for the assignment. */ - function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined), + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined, container), /*location*/ method); if (startsOnNewLine) { expression.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return expression; } function visitCatchClause(node) { - ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); - var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); - var list = ts.createVariableDeclarationList(vars, /*location*/ node.variableDeclaration, /*flags*/ node.variableDeclaration.flags); - var destructure = ts.createVariableStatement(undefined, list); - return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var updated; + if (ts.isBindingPattern(node.variableDeclaration.name)) { + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); + var list = ts.createVariableDeclarationList(vars, /*location*/ node.variableDeclaration, /*flags*/ node.variableDeclaration.flags); + var destructure = ts.createVariableStatement(undefined, list); + updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); @@ -51273,11 +51882,26 @@ var ts; // Methods on classes are handled in visitClassDeclaration/visitClassExpression. // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined); + var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); return ts.createPropertyAssignment(node.name, functionExpression, /*location*/ node); } + /** + * Visits an AccessorDeclaration of an ObjectLiteralExpression. + * + * @param node An AccessorDeclaration node. + */ + function visitAccessorDeclaration(node) { + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return updated; + } /** * Visits a ShorthandPropertyAssignment and transforms it into a PropertyAssignment. * @@ -51287,6 +51911,12 @@ var ts; return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), /*location*/ node); } + function visitComputedPropertyName(node) { + var ancestorFacts = enterSubtree(0 /* ComputedPropertyNameExcludes */, 8192 /* ComputedPropertyNameIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 32768 /* NewTargetInComputedPropertyName */ : 0 /* None */); + return updated; + } /** * Visits a YieldExpression node. * @@ -51302,8 +51932,11 @@ var ts; * @param node An ArrayLiteralExpression node. */ function visitArrayLiteralExpression(node) { - // We are here because we contain a SpreadElementExpression. - return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + if (node.transformFlags & 64 /* ES2015 */) { + // We are here because we contain a SpreadElementExpression. + return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + } + return ts.visitEachChild(node, visitor, context); } /** * Visits a CallExpression that contains either a spread element or `super`. @@ -51311,7 +51944,11 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + if (node.transformFlags & 64 /* ES2015 */) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + } + return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), + /*typeArguments*/ undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitImmediateSuperCallInBody(node) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false); @@ -51338,7 +51975,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -51350,18 +51987,18 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } if (node.expression.kind === 96 /* SuperKeyword */) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis + resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createIdentifier("_this"), initializer) : initializer; } - return resultingCall; + return ts.setOriginalNode(resultingCall, node); } /** * Visits a NewExpression that contains a spread element. @@ -51369,16 +52006,18 @@ var ts; * @param node A NewExpression node. */ function visitNewExpression(node) { - // We are here because we contain a SpreadElementExpression. - ts.Debug.assert((node.transformFlags & 524288 /* ContainsSpread */) !== 0); - // [source] - // new C(...a) - // - // [output] - // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), - /*typeArguments*/ undefined, []); + if (node.transformFlags & 524288 /* ContainsSpread */) { + // We are here because we contain a SpreadElementExpression. + // [source] + // new C(...a) + // + // [output] + // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + /*typeArguments*/ undefined, []); + } + return ts.visitEachChild(node, visitor, context); } /** * Transforms an array of Expression nodes that contains a SpreadExpression. @@ -51581,27 +52220,40 @@ var ts; /** * Visits the `super` keyword */ - function visitSuperKeyword() { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) - && currentParent.kind !== 179 /* CallExpression */ + function visitSuperKeyword(isExpressionOfCall) { + return hierarchyFacts & 8 /* NonStaticClassElement */ + && !isExpressionOfCall ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } + function visitMetaProperty(node) { + if (node.keywordToken === 93 /* NewKeyword */ && node.name.text === "target") { + if (hierarchyFacts & 8192 /* ComputedPropertyName */) { + hierarchyFacts |= 32768 /* NewTargetInComputedPropertyName */; + } + else { + hierarchyFacts |= 16384 /* NewTarget */; + } + return ts.createIdentifier("_newTarget"); + } + return node; + } /** * Called by the printer just before a node is printed. * * @param node The node to be printed. */ function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - enclosingFunction = node; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ + ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ + : 65 /* FunctionIncludes */); + previousOnEmitNode(emitContext, node, emitCallback); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return; } previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; } /** * Enables a more costly code path for substitutions when we determine a source file @@ -51627,7 +52279,7 @@ var ts; context.enableEmitNotification(152 /* SetAccessor */); context.enableEmitNotification(185 /* ArrowFunction */); context.enableEmitNotification(184 /* FunctionExpression */); - context.enableEmitNotification(225 /* FunctionDeclaration */); + context.enableEmitNotification(226 /* FunctionDeclaration */); } } /** @@ -51670,9 +52322,9 @@ var ts; var parent = node.parent; switch (parent.kind) { case 174 /* BindingElement */: - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 223 /* VariableDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 224 /* VariableDeclaration */: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -51713,8 +52365,7 @@ var ts; */ function substituteThisKeyword(node) { if (enabledSubstitutions & 1 /* CapturedThis */ - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 8 /* CapturesThis */) { + && hierarchyFacts & 16 /* CapturesThis */) { return ts.createIdentifier("_this", /*location*/ node); } return node; @@ -51731,7 +52382,7 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 207 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 208 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; @@ -51763,7 +52414,7 @@ var ts; name: "typescript:extends", scoped: false, priority: 0, - text: "\n var __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 };" + text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; })(ts || (ts = {})); /// @@ -52036,13 +52687,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 209 /* DoStatement */: + case 210 /* DoStatement */: return visitDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return visitWhileStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return visitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -52055,24 +52706,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: return visitFunctionExpression(node); case 151 /* GetAccessor */: case 152 /* SetAccessor */: return visitAccessorDeclaration(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return visitVariableStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return visitForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return visitForInStatement(node); - case 215 /* BreakStatement */: + case 216 /* BreakStatement */: return visitBreakStatement(node); - case 214 /* ContinueStatement */: + case 215 /* ContinueStatement */: return visitContinueStatement(node); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -52120,7 +52771,7 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: return visitFunctionExpression(node); @@ -52405,10 +53056,10 @@ var ts; // _a = a(); // .yield resumeLabel // _a + %sent% + c() - var clone_4 = ts.getMutableClone(node); - clone_4.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_4.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_4; + var clone_5 = ts.getMutableClone(node); + clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_5; } return ts.visitEachChild(node, visitor, context); } @@ -52553,7 +53204,7 @@ var ts; emitYield(expression, /*location*/ node); } markLabel(resumeLabel); - return createGeneratorResume(); + return createGeneratorResume(/*location*/ node); } /** * Visits an ArrayLiteralExpression that contains a YieldExpression. @@ -52667,10 +53318,10 @@ var ts; // .yield resumeLabel // .mark resumeLabel // a = _a[%sent%] - var clone_5 = ts.getMutableClone(node); - clone_5.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_5.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -52737,35 +53388,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 204 /* Block */: + case 205 /* Block */: return transformAndEmitBlock(node); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return transformAndEmitIfStatement(node); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return transformAndEmitDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return transformAndEmitForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 214 /* ContinueStatement */: + case 215 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 215 /* BreakStatement */: + case 216 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return transformAndEmitWithStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); @@ -52785,7 +53436,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - hoistVariableDeclaration(variable.name); + var name_37 = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name_37, variable.name); + hoistVariableDeclaration(name_37); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -52828,7 +53481,7 @@ var ts; if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) { var endLabel = defineLabel(); var elseLabel = node.elseStatement ? defineLabel() : undefined; - emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression)); + emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), /*location*/ node.expression); transformAndEmitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { emitBreak(endLabel); @@ -53185,7 +53838,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 254 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 255 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -53198,7 +53851,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 253 /* CaseClause */) { + if (clause.kind === 254 /* CaseClause */) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -53359,12 +54012,12 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_37) { - var clone_6 = ts.getMutableClone(name_37); - ts.setSourceMapRange(clone_6, node); - ts.setCommentRange(clone_6, node); - return clone_6; + var name_38 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_38) { + var clone_7 = ts.getMutableClone(name_38); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); + return clone_7; } } } @@ -54249,9 +54902,9 @@ var ts; function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)]), operationLocation)); + : [createInstruction(2 /* Return */)]), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -54261,10 +54914,10 @@ var ts; */ function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation)); + ]), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -54274,10 +54927,10 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -54287,10 +54940,10 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -54300,9 +54953,9 @@ var ts; */ function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)]), operationLocation)); + : [createInstruction(4 /* Yield */)]), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -54312,10 +54965,10 @@ var ts; */ function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(5 /* YieldStar */), expression - ]), operationLocation)); + ]), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -54411,10 +55064,22 @@ var ts; * @param context Context and state information for the transformation. */ function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + // enable emit notification only if using --jsx preserve + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1 /* Preserve */) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(249 /* JsxOpeningElement */); + context.enableEmitNotification(250 /* JsxClosingElement */); + context.enableEmitNotification(248 /* JsxSelfClosingElement */); + noSubstitution = []; + } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; context.enableSubstitution(177 /* PropertyAccessExpression */); - context.enableSubstitution(257 /* PropertyAssignment */); + context.enableSubstitution(258 /* PropertyAssignment */); return transformSourceFile; /** * Transforms an ES5 source file to ES3. @@ -54424,6 +55089,22 @@ var ts; function transformSourceFile(node) { return node; } + /** + * Called by the printer just before a node is printed. + * + * @param node The node to be printed. + */ + function onEmitNode(emitContext, node, emitCallback) { + switch (node.kind) { + case 249 /* JsxOpeningElement */: + case 250 /* JsxClosingElement */: + case 248 /* JsxSelfClosingElement */: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(emitContext, node, emitCallback); + } /** * Hooks node substitutions. * @@ -54431,6 +55112,9 @@ var ts; * @param node The node to substitute. */ function onSubstituteNode(emitContext, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(emitContext, node); + } node = previousOnSubstituteNode(emitContext, node); if (ts.isPropertyAccessExpression(node)) { return substitutePropertyAccessExpression(node); @@ -54490,7 +55174,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(261 /* SourceFile */); + context.enableEmitNotification(262 /* SourceFile */); context.enableSubstitution(70 /* Identifier */); var currentSourceFile; return transformSourceFile; @@ -54517,10 +55201,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -54595,7 +55279,7 @@ var ts; context.enableSubstitution(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(261 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableEmitNotification(262 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = ts.createMap(); // The export function associated with a source file. @@ -54815,7 +55499,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 241 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 242 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -54840,7 +55524,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 241 /* ExportDeclaration */) { + if (externalImport.kind !== 242 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -54921,19 +55605,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // fall-through - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -54983,15 +55667,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -55169,7 +55853,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 1048576 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 261 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 262 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -55233,7 +55917,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -55289,10 +55973,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238 /* NamedImports */: + case 239 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -55471,43 +56155,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return visitClassDeclaration(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return visitForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return visitForInStatement(node); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return visitForOfStatement(node); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return visitDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return visitWhileStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return visitLabeledStatement(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return visitWithStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return visitSwitchStatement(node); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return visitCaseBlock(node); - case 253 /* CaseClause */: + case 254 /* CaseClause */: return visitCaseClause(node); - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: return visitDefaultClause(node); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return visitTryStatement(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return visitCatchClause(node); - case 204 /* Block */: + case 205 /* Block */: return visitBlock(node); - case 295 /* MergeDeclarationMarker */: + case 296 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 296 /* EndOfDeclarationMarker */: + case 297 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -55735,7 +56419,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 261 /* SourceFile */; + return container !== undefined && container.kind === 262 /* SourceFile */; } else { return false; @@ -55768,7 +56452,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -55941,7 +56625,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 261 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 262 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -55997,8 +56681,8 @@ var ts; context.enableSubstitution(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(258 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(261 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(259 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(262 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -56052,26 +56736,6 @@ var ts; function transformAMDModule(node) { var define = ts.createIdentifier("define"); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); - } - /** - * Transforms a SourceFile into a UMD module. - * - * @param node The SourceFile node. - */ - function transformUMDModule(node) { - var define = ts.createRawExpression(umdHelper); - return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); - } - /** - * Transforms a SourceFile into an AMD or UMD module. - * - * @param node The SourceFile node. - * @param define The expression used to define the module. - * @param moduleName An expression for the module name, if available. - * @param includeNonAmdDependencies A value indicating whether to incldue any non-AMD dependencies. - */ - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { // An AMD define function has the following shape: // // define(id?, dependencies?, factory); @@ -56092,7 +56756,7 @@ var ts; // /// // // we need to add modules without alias names to the end of the dependencies list - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; // Create an updated SourceFile: // // define(moduleName?, ["module1", "module2"], function ... @@ -56122,6 +56786,73 @@ var ts; ], /*location*/ node.statements)); } + /** + * Transforms a SourceFile into a UMD module. + * + * @param node The SourceFile node. + */ + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "factory")], + /*type*/ undefined, ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement( + /*modifiers*/ undefined, [ + ts.createVariableDeclaration("v", + /*type*/ undefined, ts.createCall(ts.createIdentifier("factory"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), + /*typeArguments*/ undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], + /*location*/ undefined, + /*multiLine*/ true)); + // Create an updated SourceFile: + // + // (function (factory) { + // if (typeof module === "object" && typeof module.exports === "object") { + // var v = factory(require, exports); + // if (v !== undefined) module.exports = v; + // } + // else if (typeof define === 'function' && define.amd) { + // define(["require", "exports"], factory); + // } + // })(function ...) + return ts.updateSourceFileNode(node, ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, + /*typeArguments*/ undefined, [ + // Add the module body function argument: + // + // function (require, exports) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ])) + ], + /*location*/ node.statements)); + } /** * Collect the additional asynchronous dependencies for the module. * @@ -56226,23 +56957,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return visitExportDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitExportAssignment(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return visitClassDeclaration(node); - case 295 /* MergeDeclarationMarker */: + case 296 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 296 /* EndOfDeclarationMarker */: + case 297 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: // This visitor does not descend into the tree, as export/import statements @@ -56554,7 +57285,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -56609,10 +57340,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238 /* NamedImports */: + case 239 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -56811,7 +57542,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = ts.createMap(); @@ -56899,7 +57630,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 261 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 262 /* SourceFile */) { return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), /*location*/ node); } @@ -56910,8 +57641,8 @@ var ts; /*location*/ node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_38 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_38), + var name_39 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_39), /*location*/ node); } } @@ -57013,8 +57744,6 @@ var ts; scoped: true, text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" }; - // emit output for the UMD helper function. - var umdHelper = "\n (function (dependencies, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(dependencies, factory);\n }\n })"; })(ts || (ts = {})); /// /// @@ -57521,7 +58250,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 293 /* NotEmittedStatement */ + if (node.kind !== 294 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -57534,7 +58263,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 293 /* NotEmittedStatement */ + if (node.kind !== 294 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -57713,7 +58442,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 293 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 294 /* NotEmittedStatement */; var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; // Emit leading comments if the position is not synthesized and the node @@ -57732,7 +58461,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 224 /* VariableDeclarationList */) { + if (node.kind === 225 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -58045,7 +58774,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 235 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 236 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -58120,10 +58849,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 223 /* VariableDeclaration */) { + if (declaration.kind === 224 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 238 /* NamedImports */ || declaration.kind === 239 /* ImportSpecifier */ || declaration.kind === 236 /* ImportClause */) { + else if (declaration.kind === 239 /* NamedImports */ || declaration.kind === 240 /* ImportSpecifier */ || declaration.kind === 237 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -58141,7 +58870,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 === 235 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 236 /* 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; @@ -58151,12 +58880,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 230 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 231 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 230 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 231 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -58334,7 +59063,7 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 234 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 235 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); @@ -58456,9 +59185,9 @@ var ts; var count = 0; while (true) { count++; - var name_39 = baseName + "_" + count; - if (!(name_39 in currentIdentifiers)) { - return name_39; + var name_40 = baseName + "_" + count; + if (!(name_40 in currentIdentifiers)) { + return name_40; } } } @@ -58505,10 +59234,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 234 /* ImportEqualsDeclaration */ || - (node.parent.kind === 261 /* SourceFile */ && isCurrentFileExternalModule)) { + else if (node.kind === 235 /* ImportEqualsDeclaration */ || + (node.parent.kind === 262 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 262 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -58518,7 +59247,7 @@ var ts; }); } else { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 236 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -58536,23 +59265,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return writeVariableStatement(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return writeClassDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -58560,7 +59289,7 @@ var ts; } function emitModuleElementDeclarationFlags(node) { // If the node is parented in the current source file we need to emit export declare or just export - if (node.parent.kind === 261 /* SourceFile */) { + if (node.parent.kind === 262 /* SourceFile */) { var modifiers = ts.getModifierFlags(node); // If the node is exported if (modifiers & 1 /* Export */) { @@ -58569,7 +59298,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 227 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 228 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -58621,7 +59350,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings.kind === 238 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -58645,7 +59374,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 238 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -58666,13 +59395,13 @@ var ts; // the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered // external modules since they are indistinguishable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' // so compiler will treat them as external modules. - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 231 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 234 /* ImportEqualsDeclaration */) { + if (parent.kind === 235 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 230 /* ModuleDeclaration */) { + else if (parent.kind === 231 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -58742,7 +59471,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 231 /* ModuleBlock */) { + while (node.body && node.body.kind !== 232 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -58842,10 +59571,10 @@ 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 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 154 /* ConstructSignature */: @@ -58859,17 +59588,17 @@ var ts; if (ts.hasModifier(node.parent, 32 /* 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 === 226 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 227 /* 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 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -58907,7 +59636,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 226 /* ClassDeclaration */) { + if (node.parent.parent.kind === 227 /* 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 : @@ -58994,7 +59723,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 !== 223 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 224 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -59022,7 +59751,7 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 224 /* VariableDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59038,7 +59767,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 === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 227 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -59212,13 +59941,13 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 225 /* FunctionDeclaration */) { + if (node.kind === 226 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } else if (node.kind === 149 /* MethodDeclaration */ || node.kind === 150 /* Constructor */) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 225 /* FunctionDeclaration */) { + if (node.kind === 226 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } @@ -59323,7 +60052,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 === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 227 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -59337,7 +60066,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -59420,7 +60149,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 === 226 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 227 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -59433,7 +60162,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 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59509,20 +60238,20 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: - case 230 /* ModuleDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 227 /* InterfaceDeclaration */: - case 226 /* ClassDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: + case 226 /* FunctionDeclaration */: + case 231 /* ModuleDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 228 /* InterfaceDeclaration */: + case 227 /* ClassDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 230 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return emitExportDeclaration(node); case 150 /* Constructor */: case 149 /* MethodDeclaration */: @@ -59538,11 +60267,11 @@ var ts; case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: return emitPropertyDeclaration(node); - case 260 /* EnumMember */: + case 261 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return emitExportAssignment(node); - case 261 /* SourceFile */: + case 262 /* SourceFile */: return emitSourceFile(node); } } @@ -59835,7 +60564,7 @@ var ts; var kind = node.kind; switch (kind) { // Top-level nodes - case 261 /* SourceFile */: + case 262 /* SourceFile */: return emitSourceFile(node); } } @@ -59983,126 +60712,126 @@ var ts; case 174 /* BindingElement */: return emitBindingElement(node); // Misc - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return emitTemplateSpan(node); - case 203 /* SemicolonClassElement */: + case 204 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 204 /* Block */: + case 205 /* Block */: return emitBlock(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return emitVariableStatement(node); - case 206 /* EmptyStatement */: + case 207 /* EmptyStatement */: return emitEmptyStatement(); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return emitExpressionStatement(node); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return emitIfStatement(node); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return emitDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return emitWhileStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return emitForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return emitForInStatement(node); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return emitForOfStatement(node); - case 214 /* ContinueStatement */: + case 215 /* ContinueStatement */: return emitContinueStatement(node); - case 215 /* BreakStatement */: + case 216 /* BreakStatement */: return emitBreakStatement(node); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return emitReturnStatement(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return emitWithStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return emitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return emitLabeledStatement(node); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return emitThrowStatement(node); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return emitTryStatement(node); - case 222 /* DebuggerStatement */: + case 223 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return emitClassDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return emitModuleBlock(node); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return emitCaseBlock(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return emitImportDeclaration(node); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return emitImportClause(node); - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: return emitNamespaceImport(node); - case 238 /* NamedImports */: + case 239 /* NamedImports */: return emitNamedImports(node); - case 239 /* ImportSpecifier */: + case 240 /* ImportSpecifier */: return emitImportSpecifier(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return emitExportAssignment(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return emitExportDeclaration(node); - case 242 /* NamedExports */: + case 243 /* NamedExports */: return emitNamedExports(node); - case 243 /* ExportSpecifier */: + case 244 /* ExportSpecifier */: return emitExportSpecifier(node); - case 244 /* MissingDeclaration */: + case 245 /* MissingDeclaration */: return; // Module references - case 245 /* ExternalModuleReference */: + case 246 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 248 /* JsxOpeningElement */: + case 249 /* JsxOpeningElement */: return emitJsxOpeningElement(node); - case 249 /* JsxClosingElement */: + case 250 /* JsxClosingElement */: return emitJsxClosingElement(node); - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: return emitJsxAttribute(node); - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 253 /* CaseClause */: + case 254 /* CaseClause */: return emitCaseClause(node); - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: return emitDefaultClause(node); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: return emitHeritageClause(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 260 /* EnumMember */: + case 261 /* EnumMember */: return emitEnumMember(node); } // If the node is an expression, try to emit it as an expression with @@ -60191,16 +60920,16 @@ var ts; return emitAsExpression(node); case 201 /* NonNullExpression */: return emitNonNullExpression(node); + case 202 /* MetaProperty */: + return emitMetaProperty(node); // JSX - case 246 /* JsxElement */: + case 247 /* JsxElement */: return emitJsxElement(node); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 297 /* RawExpression */: - return writeLines(node.text); } } // @@ -60693,6 +61422,11 @@ var ts; emitExpression(node.expression); write("!"); } + function emitMetaProperty(node) { + writeToken(node.keywordToken, node.pos); + write("."); + emit(node.name); + } // // Misc // @@ -60741,27 +61475,27 @@ var ts; writeToken(18 /* OpenParenToken */, openParenPos, node); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end, node); - emitEmbeddedStatement(node.thenStatement); + emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { - writeLine(); + writeLineOrSpace(node); writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 208 /* IfStatement */) { + if (node.elseStatement.kind === 209 /* IfStatement */) { write(" "); emit(node.elseStatement); } else { - emitEmbeddedStatement(node.elseStatement); + emitEmbeddedStatement(node, node.elseStatement); } } } function emitDoStatement(node) { write("do"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { write(" "); } else { - writeLine(); + writeLineOrSpace(node); } write("while ("); emitExpression(node.expression); @@ -60771,7 +61505,7 @@ var ts; write("while ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60783,7 +61517,7 @@ var ts; write(";"); emitExpressionWithPrefix(" ", node.incrementor); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60793,7 +61527,7 @@ var ts; write(" in "); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60803,11 +61537,11 @@ var ts; write(" of "); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 224 /* VariableDeclarationList */) { + if (node.kind === 225 /* VariableDeclarationList */) { emit(node); } else { @@ -60834,7 +61568,7 @@ var ts; write("with ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { var openParenPos = writeToken(97 /* SwitchKeyword */, node.pos); @@ -60858,9 +61592,12 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchClause); + if (node.catchClause) { + writeLineOrSpace(node); + emit(node.catchClause); + } if (node.finallyBlock) { - writeLine(); + writeLineOrSpace(node); write("finally "); emit(node.finallyBlock); } @@ -61046,7 +61783,7 @@ var ts; write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 230 /* ModuleDeclaration */) { + while (body.kind === 231 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -61203,6 +61940,9 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); + if (node.dotDotDotToken) { + write("..."); + } emitExpression(node.expression); write("}"); } @@ -61438,8 +62178,8 @@ var ts; write(suffix); } } - function emitEmbeddedStatement(node) { - if (ts.isBlock(node)) { + function emitEmbeddedStatement(parent, node) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* SingleLine */) { write(" "); emit(node); } @@ -61580,6 +62320,14 @@ var ts; write(getClosingBracket(format)); } } + function writeLineOrSpace(node) { + if (ts.getEmitFlags(node) & 1 /* SingleLine */) { + write(" "); + } + else { + writeLine(); + } + } function writeIfAny(nodes, text) { if (nodes && nodes.length > 0) { write(text); @@ -61771,10 +62519,10 @@ var ts; */ function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_40 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_40)) { + var name_41 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_41)) { tempFlags |= flags; - return name_40; + return name_41; } } while (true) { @@ -61782,11 +62530,11 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_41 = count < 26 + var name_42 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_41)) { - return name_41; + if (isUniqueName(name_42)) { + return name_42; } } } @@ -61826,6 +62574,12 @@ var ts; function generateNameForClassExpression() { return makeUniqueName("class"); } + function generateNameForMethodOrAccessor(node) { + if (ts.isIdentifier(node.name)) { + return generateNameForNodeCached(node.name); + } + return makeTempVariableName(0 /* Auto */); + } /** * Generates a unique name from a node. * @@ -61835,18 +62589,22 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 235 /* ImportDeclaration */: - case 241 /* ExportDeclaration */: + case 236 /* ImportDeclaration */: + case 242 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 225 /* FunctionDeclaration */: - case 226 /* ClassDeclaration */: - case 240 /* ExportAssignment */: + case 226 /* FunctionDeclaration */: + case 227 /* ClassDeclaration */: + case 241 /* ExportAssignment */: return generateNameForExportDefault(); case 197 /* ClassExpression */: return generateNameForClassExpression(); + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); } @@ -61890,6 +62648,10 @@ var ts; // otherwise, return the original node for the source; return node; } + function generateNameForNodeCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + } /** * Gets the generated identifier text from a generated identifier. * @@ -61900,8 +62662,7 @@ var ts; // Generated names generate unique names based on their original node // and are cached based on that node's id var node = getNodeForGeneratedName(name); - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + return generateNameForNodeCached(node); } else { // Auto, Loop, and Unique names are cached based on their unique @@ -62046,7 +62807,8 @@ var ts; commonPathComponents = sourcePathComponents; return; } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + var n = Math.min(commonPathComponents.length, sourcePathComponents.length); + for (var i = 0; i < n; i++) { if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { if (i === 0) { // Failed to find any common path component @@ -62237,10 +62999,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_42 = names_1[_i]; - var result = name_42 in cache - ? cache[name_42] - : cache[name_42] = loader(name_42, containingFile); + var name_43 = names_1[_i]; + var result = name_43 in cache + ? cache[name_43] + : cache[name_43] = loader(name_43, containingFile); resolutions.push(result); } return resolutions; @@ -62276,6 +63038,7 @@ var ts; var supportedExtensions = ts.getSupportedExtensions(options); // Map storing if there is emit blocking diagnostics for given input var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); + var moduleResolutionCache; var resolveModuleNamesWorker; if (host.resolveModuleNames) { resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { @@ -62289,7 +63052,8 @@ var ts; }); }; } else { - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -62335,6 +63099,8 @@ var ts; } } } + // unconditionally set moduleResolutionCache to undefined to avoid unnecessary leaks + moduleResolutionCache = undefined; // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; program = { @@ -62600,7 +63366,7 @@ var ts; newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } // update fileName -> file mapping - for (var i = 0, len = newSourceFiles.length; i < len; i++) { + for (var i = 0; i < newSourceFiles.length; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; @@ -62787,10 +63553,10 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: - case 223 /* VariableDeclaration */: + case 226 /* FunctionDeclaration */: + case 224 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -62798,32 +63564,32 @@ var ts; } } switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 107 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; case 182 /* TypeAssertionExpression */: @@ -62841,26 +63607,26 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // pass through - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 205 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 206 /* VariableStatement */); } break; case 147 /* PropertyDeclaration */: @@ -62983,7 +63749,7 @@ var ts; // synthesize 'import "tslib"' declaration var externalHelpersModuleReference = ts.createSynthesizedNode(9 /* StringLiteral */); externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(235 /* ImportDeclaration */); + var importDecl = ts.createSynthesizedNode(236 /* ImportDeclaration */); importDecl.parent = file; externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; @@ -63001,9 +63767,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: + case 236 /* ImportDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 242 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -63018,7 +63784,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2 /* Ambient */) || ts.isDeclarationFile(file))) { var moduleName = node.name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -64281,11 +65047,11 @@ var ts; function serializeCompilerOptions(options) { var result = ts.createMap(); var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_43 in options) { - if (ts.hasProperty(options, name_43)) { + for (var name_44 in options) { + if (ts.hasProperty(options, name_44)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - switch (name_43) { + switch (name_44) { case "init": case "watch": case "version": @@ -64293,14 +65059,14 @@ var ts; case "project": break; default: - var value = options[name_43]; - var optionDefinition = optionsNameMap[name_43.toLowerCase()]; + var value = options[name_44]; + var optionDefinition = optionsNameMap[name_44.toLowerCase()]; if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { // There is no map associated with this compiler option then use the value as-is // This is the case if the value is expect to be string, number, boolean or list of string - result[name_43] = value; + result[name_44] = value; } else { if (optionDefinition.type === "list") { @@ -64309,11 +65075,11 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_43] = convertedValue; + result[name_44] = convertedValue; } else { // There is a typeMap associated with this command-line option so use it to map value back to its name - result[name_43] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -64361,6 +65127,7 @@ var ts; if (resolutionStack === void 0) { resolutionStack = []; } if (extraFileExtensions === void 0) { extraFileExtensions = []; } var errors = []; + basePath = ts.normalizeSlashes(basePath); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -65130,32 +65897,32 @@ var ts; function getMeaningFromDeclaration(node) { switch (node.kind) { case 144 /* Parameter */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: - case 260 /* EnumMember */: + case 258 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: + case 261 /* EnumMember */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 256 /* CatchClause */: + case 257 /* CatchClause */: return 1 /* Value */; case 143 /* TypeParameter */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: case 161 /* TypeLiteral */: return 2 /* Type */; - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -65165,22 +65932,22 @@ var ts; else { return 4 /* Namespace */; } - case 238 /* NamedImports */: - case 239 /* ImportSpecifier */: - case 234 /* ImportEqualsDeclaration */: - case 235 /* ImportDeclaration */: - case 240 /* ExportAssignment */: - case 241 /* ExportDeclaration */: + case 239 /* NamedImports */: + case 240 /* ImportSpecifier */: + case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportDeclaration */: + case 241 /* ExportAssignment */: + case 242 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 261 /* SourceFile */: + case 262 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 240 /* ExportAssignment */) { + if (node.parent.kind === 241 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -65207,7 +65974,7 @@ var ts; // import a = |b.c|.d; // Namespace if (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 234 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 235 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; @@ -65241,10 +66008,10 @@ var ts; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 199 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 255 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 199 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 256 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 226 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || - (decl.kind === 227 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); + return (decl.kind === 227 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || + (decl.kind === 228 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); } return false; } @@ -65275,7 +66042,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 219 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 220 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -65285,13 +66052,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 /* Identifier */ && - (node.parent.kind === 215 /* BreakStatement */ || node.parent.kind === 214 /* ContinueStatement */) && + (node.parent.kind === 216 /* BreakStatement */ || node.parent.kind === 215 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 /* Identifier */ && - node.parent.kind === 219 /* LabeledStatement */ && + node.parent.kind === 220 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -65307,7 +66074,7 @@ var ts; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 230 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 231 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -65320,13 +66087,13 @@ var ts; switch (node.parent.kind) { case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 260 /* EnumMember */: + case 258 /* PropertyAssignment */: + case 261 /* EnumMember */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return node.parent.name === node; case 178 /* ElementAccessExpression */: return node.parent.argumentExpression === node; @@ -65379,17 +66146,17 @@ var ts; return undefined; } switch (node.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: return node; } } @@ -65397,22 +66164,22 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return ts.ScriptElementKind.classElement; - case 227 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; - case 228 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; - case 229 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; - case 223 /* VariableDeclaration */: + case 228 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 229 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 230 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 224 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); case 174 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: return ts.ScriptElementKind.functionElement; case 151 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; @@ -65428,15 +66195,15 @@ var ts; case 153 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; case 150 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; case 143 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; - case 260 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 261 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; case 144 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 234 /* ImportEqualsDeclaration */: - case 239 /* ImportSpecifier */: - case 236 /* ImportClause */: - case 243 /* ExportSpecifier */: - case 237 /* NamespaceImport */: + case 235 /* ImportEqualsDeclaration */: + case 240 /* ImportSpecifier */: + case 237 /* ImportClause */: + case 244 /* ExportSpecifier */: + case 238 /* NamespaceImport */: return ts.ScriptElementKind.alias; - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -65511,19 +66278,19 @@ var ts; return false; } switch (n.kind) { - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: case 176 /* ObjectLiteralExpression */: case 172 /* ObjectBindingPattern */: case 161 /* TypeLiteral */: - case 204 /* Block */: - case 231 /* ModuleBlock */: - case 232 /* CaseBlock */: - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 205 /* Block */: + case 232 /* ModuleBlock */: + case 233 /* CaseBlock */: + case 239 /* NamedImports */: + case 243 /* NamedExports */: return nodeEndsWith(n, 17 /* CloseBraceToken */, sourceFile); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return isCompletedNode(n.block, sourceFile); case 180 /* NewExpression */: if (!n.arguments) { @@ -65540,7 +66307,7 @@ var ts; case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -65556,14 +66323,14 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 19 /* CloseParenToken */, sourceFile); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 208 /* IfStatement */: + case 209 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24 /* SemicolonToken */); case 175 /* ArrayLiteralExpression */: @@ -65577,16 +66344,16 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 254 /* CaseClause */: + case 255 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 211 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 209 /* DoStatement */: + case 210 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 105 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { @@ -65607,10 +66374,10 @@ var ts; case 194 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 241 /* ExportDeclaration */: - case 235 /* ImportDeclaration */: + case 242 /* ExportDeclaration */: + case 236 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); case 190 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); @@ -65672,7 +66439,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 === 292 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 293 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -65739,8 +66506,8 @@ var ts; } } // find the child that contains 'position' - for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { - var child = current.getChildAt(i); + for (var _a = 0, _b = current.getChildren(); _a < _b.length; _a++) { + var child = _b[_a]; // all jsDocComment nodes were already visited if (ts.isJSDocNode(child)) { continue; @@ -65819,7 +66586,7 @@ var ts; return n; } var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; i++) { + for (var i = 0; i < children.length; i++) { var child = children[i]; // condition 'position < child.end' checks if child node end after the position // in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc' @@ -65844,7 +66611,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 261 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 262 /* 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. @@ -65903,17 +66670,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 252 /* JsxExpression */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 253 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 252 /* JsxExpression */) { + if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 253 /* JsxExpression */) { return true; } //
|
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 249 /* JsxClosingElement */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 250 /* JsxClosingElement */) { return true; } return false; @@ -66028,7 +66795,7 @@ var ts; if (node.kind === 157 /* TypeReference */ || node.kind === 179 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 226 /* ClassDeclaration */ || node.kind === 227 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 227 /* ClassDeclaration */ || node.kind === 228 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -66105,7 +66872,7 @@ var ts; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 213 /* ForOfStatement */ && + if (node.parent.kind === 214 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -66113,7 +66880,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 257 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 258 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -66339,7 +67106,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 239 /* ImportSpecifier */ || location.parent.kind === 243 /* ExportSpecifier */) && + (location.parent.kind === 240 /* ImportSpecifier */ || location.parent.kind === 244 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -66406,6 +67173,11 @@ var ts; }; } ts.sanitizeConfigFile = sanitizeConfigFile; + function getOpenBraceEnd(constructor, sourceFile) { + // First token is the open curly, this is where we want to put the 'super' call. + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + ts.getOpenBraceEnd = getOpenBraceEnd; })(ts || (ts = {})); var ts; (function (ts) { @@ -66473,7 +67245,7 @@ var ts; var entries = []; var dense = classifications.spans; var lastEnd = 0; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; var length_4 = dense[i + 1]; var type = dense[i + 2]; @@ -66845,10 +67617,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: + case 231 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 226 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -66899,7 +67671,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 230 /* ModuleDeclaration */ && + return declaration.kind === 231 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -66960,7 +67732,7 @@ var ts; ts.Debug.assert(classifications.spans.length % 3 === 0); var dense = classifications.spans; var result = []; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { result.push({ textSpan: ts.createTextSpan(dense[i], dense[i + 1]), classificationType: getClassificationTypeName(dense[i + 2]) @@ -67063,16 +67835,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 281 /* JSDocParameterTag */: + case 282 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 284 /* JSDocTemplateTag */: + case 285 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 283 /* JSDocTypeTag */: + case 284 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 282 /* JSDocReturnTag */: + case 283 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -67159,22 +67931,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 248 /* JsxOpeningElement */: + case 249 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 249 /* JsxClosingElement */: + case 250 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -67202,10 +67974,10 @@ var ts; if (token) { if (tokenKind === 57 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 223 /* VariableDeclaration */ || + if (token.parent.kind === 224 /* VariableDeclaration */ || token.parent.kind === 147 /* PropertyDeclaration */ || token.parent.kind === 144 /* Parameter */ || - token.parent.kind === 250 /* JsxAttribute */) { + token.parent.kind === 251 /* JsxAttribute */) { return 5 /* operator */; } } @@ -67222,7 +67994,7 @@ var ts; return 4 /* numericLiteral */; } else if (tokenKind === 9 /* StringLiteral */) { - return token.parent.kind === 250 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 251 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 11 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -67238,7 +68010,7 @@ var ts; else if (tokenKind === 70 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } @@ -67248,17 +68020,17 @@ var ts; return 15 /* typeParameterName */; } return; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } @@ -67280,9 +68052,8 @@ var ts; // Ignore nodes that don't intersect the original span to classify. if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { checkForClassificationCancellation(cancellationToken, element.kind); - var children = element.getChildren(sourceFile); - for (var i = 0, n = children.length; i < n; i++) { - var child = children[i]; + for (var _i = 0, _a = element.getChildren(sourceFile); _i < _a.length; _i++) { + var child = _a[_i]; if (!tryClassifyNode(child)) { // Recurse into our child nodes. processElement(child); @@ -67323,7 +68094,7 @@ var ts; else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 /* JSX */ && - location.parent && location.parent.kind === 249 /* JsxClosingElement */) { + location.parent && location.parent.kind === 250 /* JsxClosingElement */) { // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. // For example: @@ -67350,14 +68121,14 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_44 in nameTable) { + for (var name_45 in nameTable) { // Skip identifiers produced only from the current location - if (nameTable[name_44] === position) { + if (nameTable[name_45] === position) { continue; } - if (!uniqueNames[name_44]) { - uniqueNames[name_44] = name_44; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_44), compilerOptions.target, /*performCharacterChecks*/ true); + if (!uniqueNames[name_45]) { + uniqueNames[name_45] = name_45; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_45), compilerOptions.target, /*performCharacterChecks*/ true); if (displayName) { var entry = { name: displayName, @@ -67417,7 +68188,7 @@ var ts; if (!node || node.kind !== 9 /* StringLiteral */) { return undefined; } - if (node.parent.kind === 257 /* PropertyAssignment */ && + if (node.parent.kind === 258 /* PropertyAssignment */ && node.parent.parent.kind === 176 /* ObjectLiteralExpression */ && node.parent.name === node) { // Get quoted name of properties of the object literal expression @@ -67443,7 +68214,7 @@ var ts; // a['/*completion position*/'] return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 235 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 236 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // import x = require("/*completion position*/"); @@ -67512,6 +68283,9 @@ var ts; return undefined; } function addStringLiteralCompletionsFromType(type, result) { + if (type && type.flags & 16384 /* TypeParameter */) { + type = typeChecker.getApparentType(type); + } if (!type) { return; } @@ -67870,11 +68644,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_13 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_13) { + var parent_14 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_14) { break; } - currentDir = parent_13; + currentDir = parent_14; } else { break; @@ -68026,9 +68800,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 283 /* JSDocTypeTag */: - case 281 /* JSDocParameterTag */: - case 282 /* JSDocReturnTag */: + case 284 /* JSDocTypeTag */: + case 282 /* JSDocParameterTag */: + case 283 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -68073,13 +68847,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_14 = contextToken.parent, kind = contextToken.kind; + var parent_15 = contextToken.parent, kind = contextToken.kind; if (kind === 22 /* DotToken */) { - if (parent_14.kind === 177 /* PropertyAccessExpression */) { + if (parent_15.kind === 177 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_14.kind === 141 /* QualifiedName */) { + else if (parent_15.kind === 141 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -68094,7 +68868,7 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 249 /* JsxClosingElement */) { + else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 250 /* JsxClosingElement */) { isStartingCloseTag = true; location = contextToken; } @@ -68199,7 +68973,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 247 /* JsxSelfClosingElement */) || (jsxContainer.kind === 248 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 248 /* JsxSelfClosingElement */) || (jsxContainer.kind === 249 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -68247,9 +69021,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 261 /* SourceFile */ || + scopeNode.kind === 262 /* SourceFile */ || scopeNode.kind === 194 /* TemplateExpression */ || - scopeNode.kind === 252 /* JsxExpression */ || + scopeNode.kind === 253 /* JsxExpression */ || ts.isStatement(scopeNode); } /// TODO filter meaning based on the current context @@ -68282,11 +69056,11 @@ var ts; return true; } if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 248 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 249 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 249 /* JsxClosingElement */ || contextToken.parent.kind === 247 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 246 /* JsxElement */; + if (contextToken.parent.kind === 250 /* JsxClosingElement */ || contextToken.parent.kind === 248 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 247 /* JsxElement */; } } return false; @@ -68316,16 +69090,16 @@ var ts; case 128 /* NamespaceKeyword */: return true; case 22 /* DotToken */: - return containingNodeKind === 230 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 231 /* ModuleDeclaration */; // module A.| case 16 /* OpenBraceToken */: - return containingNodeKind === 226 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 227 /* ClassDeclaration */; // class A{ | case 57 /* EqualsToken */: - return containingNodeKind === 223 /* VariableDeclaration */ // const x = a| + return containingNodeKind === 224 /* VariableDeclaration */ // const x = a| || containingNodeKind === 192 /* BinaryExpression */; // x = a| case 13 /* TemplateHead */: return containingNodeKind === 194 /* TemplateExpression */; // `aa ${| case 14 /* TemplateMiddle */: - return containingNodeKind === 202 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 203 /* TemplateSpan */; // `aa ${10} dd ${| case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: @@ -68439,9 +69213,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 238 /* NamedImports */ ? - 235 /* ImportDeclaration */ : - 241 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 239 /* NamedImports */ ? + 236 /* ImportDeclaration */ : + 242 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -68466,9 +69240,9 @@ var ts; switch (contextToken.kind) { case 16 /* OpenBraceToken */: // const x = { | case 25 /* CommaToken */: - var parent_15 = contextToken.parent; - if (parent_15 && (parent_15.kind === 176 /* ObjectLiteralExpression */ || parent_15.kind === 172 /* ObjectBindingPattern */)) { - return parent_15; + var parent_16 = contextToken.parent; + if (parent_16 && (parent_16.kind === 176 /* ObjectLiteralExpression */ || parent_16.kind === 172 /* ObjectBindingPattern */)) { + return parent_16; } break; } @@ -68485,8 +69259,8 @@ var ts; case 16 /* OpenBraceToken */: // import { | case 25 /* CommaToken */: switch (contextToken.parent.kind) { - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 239 /* NamedImports */: + case 243 /* NamedExports */: return contextToken.parent; } } @@ -68495,37 +69269,37 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_16 = contextToken.parent; + var parent_17 = contextToken.parent; switch (contextToken.kind) { case 27 /* LessThanSlashToken */: case 40 /* SlashToken */: case 70 /* Identifier */: - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: - if (parent_16 && (parent_16.kind === 247 /* JsxSelfClosingElement */ || parent_16.kind === 248 /* JsxOpeningElement */)) { - return parent_16; + case 251 /* JsxAttribute */: + case 252 /* JsxSpreadAttribute */: + if (parent_17 && (parent_17.kind === 248 /* JsxSelfClosingElement */ || parent_17.kind === 249 /* JsxOpeningElement */)) { + return parent_17; } - else if (parent_16.kind === 250 /* JsxAttribute */) { - return parent_16.parent; + else if (parent_17.kind === 251 /* JsxAttribute */) { + return parent_17.parent; } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_16 && ((parent_16.kind === 250 /* JsxAttribute */) || (parent_16.kind === 251 /* JsxSpreadAttribute */))) { - return parent_16.parent; + if (parent_17 && ((parent_17.kind === 251 /* JsxAttribute */) || (parent_17.kind === 252 /* JsxSpreadAttribute */))) { + return parent_17.parent; } break; case 17 /* CloseBraceToken */: - if (parent_16 && - parent_16.kind === 252 /* JsxExpression */ && - parent_16.parent && - (parent_16.parent.kind === 250 /* JsxAttribute */)) { - return parent_16.parent.parent; + if (parent_17 && + parent_17.kind === 253 /* JsxExpression */ && + parent_17.parent && + (parent_17.parent.kind === 251 /* JsxAttribute */)) { + return parent_17.parent.parent; } - if (parent_16 && parent_16.kind === 251 /* JsxSpreadAttribute */) { - return parent_16.parent; + if (parent_17 && parent_17.kind === 252 /* JsxSpreadAttribute */) { + return parent_17.parent; } break; } @@ -68536,7 +69310,7 @@ var ts; switch (kind) { case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: @@ -68555,16 +69329,16 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25 /* CommaToken */: - return containingNodeKind === 223 /* VariableDeclaration */ || - containingNodeKind === 224 /* VariableDeclarationList */ || - containingNodeKind === 205 /* VariableStatement */ || - containingNodeKind === 229 /* EnumDeclaration */ || + return containingNodeKind === 224 /* VariableDeclaration */ || + containingNodeKind === 225 /* VariableDeclarationList */ || + containingNodeKind === 206 /* VariableStatement */ || + containingNodeKind === 230 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 226 /* ClassDeclaration */ || + containingNodeKind === 227 /* ClassDeclaration */ || containingNodeKind === 197 /* ClassExpression */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || + containingNodeKind === 228 /* InterfaceDeclaration */ || containingNodeKind === 173 /* ArrayBindingPattern */ || - containingNodeKind === 228 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 229 /* TypeAliasDeclaration */; // type Map, K, | case 22 /* DotToken */: return containingNodeKind === 173 /* ArrayBindingPattern */; // var [.| case 55 /* ColonToken */: @@ -68572,22 +69346,22 @@ var ts; case 20 /* OpenBracketToken */: return containingNodeKind === 173 /* ArrayBindingPattern */; // var [x| case 18 /* OpenParenToken */: - return containingNodeKind === 256 /* CatchClause */ || + return containingNodeKind === 257 /* CatchClause */ || isFunction(containingNodeKind); case 16 /* OpenBraceToken */: - return containingNodeKind === 229 /* EnumDeclaration */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || + return containingNodeKind === 230 /* EnumDeclaration */ || + containingNodeKind === 228 /* InterfaceDeclaration */ || containingNodeKind === 161 /* TypeLiteral */; // const x : { | case 24 /* SemicolonToken */: return containingNodeKind === 146 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 227 /* InterfaceDeclaration */ || + (contextToken.parent.parent.kind === 228 /* InterfaceDeclaration */ || contextToken.parent.parent.kind === 161 /* TypeLiteral */); // const x : { a; | case 26 /* LessThanToken */: - return containingNodeKind === 226 /* ClassDeclaration */ || + return containingNodeKind === 227 /* ClassDeclaration */ || containingNodeKind === 197 /* ClassExpression */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || - containingNodeKind === 228 /* TypeAliasDeclaration */ || + containingNodeKind === 228 /* InterfaceDeclaration */ || + containingNodeKind === 229 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); case 114 /* StaticKeyword */: return containingNodeKind === 147 /* PropertyDeclaration */; @@ -68600,9 +69374,9 @@ var ts; case 112 /* ProtectedKeyword */: return containingNodeKind === 144 /* Parameter */; case 117 /* AsKeyword */: - return containingNodeKind === 239 /* ImportSpecifier */ || - containingNodeKind === 243 /* ExportSpecifier */ || - containingNodeKind === 237 /* NamespaceImport */; + return containingNodeKind === 240 /* ImportSpecifier */ || + containingNodeKind === 244 /* ExportSpecifier */ || + containingNodeKind === 238 /* NamespaceImport */; case 74 /* ClassKeyword */: case 82 /* EnumKeyword */: case 108 /* InterfaceKeyword */: @@ -68662,8 +69436,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_45 = element.propertyName || element.name; - existingImportsOrExports[name_45.text] = true; + var name_46 = element.propertyName || element.name; + existingImportsOrExports[name_46.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -68684,8 +69458,8 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 257 /* PropertyAssignment */ && - m.kind !== 258 /* ShorthandPropertyAssignment */ && + if (m.kind !== 258 /* PropertyAssignment */ && + m.kind !== 259 /* ShorthandPropertyAssignment */ && m.kind !== 174 /* BindingElement */ && m.kind !== 149 /* MethodDeclaration */ && m.kind !== 151 /* GetAccessor */ && @@ -68727,7 +69501,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 250 /* JsxAttribute */) { + if (attr.kind === 251 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -68908,58 +69682,58 @@ var ts; switch (node.kind) { case 89 /* IfKeyword */: case 81 /* ElseKeyword */: - if (hasKind(node.parent, 208 /* IfStatement */)) { + if (hasKind(node.parent, 209 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 95 /* ReturnKeyword */: - if (hasKind(node.parent, 216 /* ReturnStatement */)) { + if (hasKind(node.parent, 217 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 99 /* ThrowKeyword */: - if (hasKind(node.parent, 220 /* ThrowStatement */)) { + if (hasKind(node.parent, 221 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 73 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 221 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 222 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 101 /* TryKeyword */: case 86 /* FinallyKeyword */: - if (hasKind(parent(node), 221 /* TryStatement */)) { + if (hasKind(parent(node), 222 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 97 /* SwitchKeyword */: - if (hasKind(node.parent, 218 /* SwitchStatement */)) { + if (hasKind(node.parent, 219 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 72 /* CaseKeyword */: case 78 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 218 /* SwitchStatement */)) { + if (hasKind(parent(parent(parent(node))), 219 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 71 /* BreakKeyword */: case 76 /* ContinueKeyword */: - if (hasKind(node.parent, 215 /* BreakStatement */) || hasKind(node.parent, 214 /* ContinueStatement */)) { + if (hasKind(node.parent, 216 /* BreakStatement */) || hasKind(node.parent, 215 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 87 /* ForKeyword */: - if (hasKind(node.parent, 211 /* ForStatement */) || - hasKind(node.parent, 212 /* ForInStatement */) || - hasKind(node.parent, 213 /* ForOfStatement */)) { + if (hasKind(node.parent, 212 /* ForStatement */) || + hasKind(node.parent, 213 /* ForInStatement */) || + hasKind(node.parent, 214 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 105 /* WhileKeyword */: case 80 /* DoKeyword */: - if (hasKind(node.parent, 210 /* WhileStatement */) || hasKind(node.parent, 209 /* DoStatement */)) { + if (hasKind(node.parent, 211 /* WhileStatement */) || hasKind(node.parent, 210 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; @@ -68976,7 +69750,7 @@ var ts; break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 205 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 206 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -68992,10 +69766,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 220 /* ThrowStatement */) { + if (node.kind === 221 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 221 /* TryStatement */) { + else if (node.kind === 222 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -69022,19 +69796,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_17 = child.parent; - if (ts.isFunctionBlock(parent_17) || parent_17.kind === 261 /* SourceFile */) { - return parent_17; + var parent_18 = child.parent; + if (ts.isFunctionBlock(parent_18) || parent_18.kind === 262 /* SourceFile */) { + return parent_18; } // 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_17.kind === 221 /* TryStatement */) { - var tryStatement = parent_17; + if (parent_18.kind === 222 /* TryStatement */) { + var tryStatement = parent_18; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_17; + child = parent_18; } return undefined; } @@ -69043,7 +69817,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 215 /* BreakStatement */ || node.kind === 214 /* ContinueStatement */) { + if (node.kind === 216 /* BreakStatement */ || node.kind === 215 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -69056,25 +69830,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 218 /* SwitchStatement */: - if (statement.kind === 214 /* ContinueStatement */) { + for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { + switch (node_2.kind) { + case 219 /* SwitchStatement */: + if (statement.kind === 215 /* ContinueStatement */) { continue; } // Fall through. - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 211 /* WhileStatement */: + case 210 /* 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; @@ -69086,24 +69860,24 @@ 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 === 226 /* ClassDeclaration */ || + if (!(container.kind === 227 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */ || (declaration.kind === 144 /* Parameter */ && hasKind(container, 150 /* Constructor */)))) { return undefined; } } else if (modifier === 114 /* StaticKeyword */) { - if (!(container.kind === 226 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */)) { + if (!(container.kind === 227 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */)) { return undefined; } } else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { - if (!(container.kind === 231 /* ModuleBlock */ || container.kind === 261 /* SourceFile */)) { + if (!(container.kind === 232 /* ModuleBlock */ || container.kind === 262 /* SourceFile */)) { return undefined; } } else if (modifier === 116 /* AbstractKeyword */) { - if (!(container.kind === 226 /* ClassDeclaration */ || declaration.kind === 226 /* ClassDeclaration */)) { + if (!(container.kind === 227 /* ClassDeclaration */ || declaration.kind === 227 /* ClassDeclaration */)) { return undefined; } } @@ -69115,8 +69889,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 231 /* ModuleBlock */: - case 261 /* SourceFile */: + case 232 /* ModuleBlock */: + case 262 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -69128,7 +69902,7 @@ var ts; case 150 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search @@ -69212,7 +69986,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87 /* ForKeyword */, 105 /* WhileKeyword */, 80 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 209 /* DoStatement */) { + if (loopNode.kind === 210 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { @@ -69233,13 +70007,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -69293,7 +70067,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, 204 /* Block */))) { + if (!(func && hasKind(func.body, 205 /* Block */))) { return undefined; } var keywords = []; @@ -69309,7 +70083,7 @@ var ts; function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 208 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 209 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -69322,7 +70096,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 208 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 209 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -69365,7 +70139,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 219 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 220 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -69599,12 +70373,12 @@ var ts; function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608 /* Alias */) { // Default import get alias - var defaultImport = ts.getDeclarationOfKind(symbol, 236 /* ImportClause */); + var defaultImport = ts.getDeclarationOfKind(symbol, 237 /* ImportClause */); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 239 /* ImportSpecifier */ || - declaration.kind === 243 /* ExportSpecifier */) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 240 /* ImportSpecifier */ || + declaration.kind === 244 /* ExportSpecifier */) ? declaration : undefined; }); if (importOrExportSpecifier && // export { a } (!importOrExportSpecifier.propertyName || @@ -69612,7 +70386,7 @@ var ts; importOrExportSpecifier.propertyName === location)) { // If Import specifier -> get alias // else Export specifier -> get local target - return importOrExportSpecifier.kind === 239 /* ImportSpecifier */ ? + return importOrExportSpecifier.kind === 240 /* ImportSpecifier */ ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -69671,7 +70445,7 @@ var ts; if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 226 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 227 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -69702,7 +70476,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 261 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 262 /* 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; @@ -69978,7 +70752,7 @@ var ts; result.push(getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === 70 /* Identifier */) { - if (refNode.parent.kind === 258 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 259 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } @@ -69991,24 +70765,24 @@ var ts; // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface var containingTypeReference = getContainingTypeReference(refNode); if (containingTypeReference) { - var parent_18 = containingTypeReference.parent; - if (ts.isVariableLike(parent_18) && parent_18.type === containingTypeReference && parent_18.initializer && isImplementationExpression(parent_18.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_18.initializer)); + var parent_19 = containingTypeReference.parent; + if (ts.isVariableLike(parent_19) && parent_19.type === containingTypeReference && parent_19.initializer && isImplementationExpression(parent_19.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_19.initializer)); } - else if (ts.isFunctionLike(parent_18) && parent_18.type === containingTypeReference && parent_18.body) { - if (parent_18.body.kind === 204 /* Block */) { - ts.forEachReturnStatement(parent_18.body, function (returnStatement) { + else if (ts.isFunctionLike(parent_19) && parent_19.type === containingTypeReference && parent_19.body) { + if (parent_19.body.kind === 205 /* Block */) { + ts.forEachReturnStatement(parent_19.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); } }); } - else if (isImplementationExpression(parent_18.body)) { - maybeAdd(getReferenceEntryFromNode(parent_18.body)); + else if (isImplementationExpression(parent_19.body)) { + maybeAdd(getReferenceEntryFromNode(parent_19.body)); } } - else if (ts.isAssertionExpression(parent_18) && isImplementationExpression(parent_18.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_18.expression)); + else if (ts.isAssertionExpression(parent_19) && isImplementationExpression(parent_19.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_19.expression)); } } } @@ -70049,7 +70823,7 @@ var ts; function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { if (node.kind === 199 /* ExpressionWithTypeArguments */ - && node.parent.kind === 255 /* HeritageClause */ + && node.parent.kind === 256 /* HeritageClause */ && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -70120,7 +70894,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 227 /* InterfaceDeclaration */) { + else if (declaration.kind === 228 /* InterfaceDeclaration */) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -70200,12 +70974,12 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, @@ -70215,7 +70989,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 261 /* SourceFile */) { + if (searchSpaceNode.kind === 262 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -70250,7 +71024,7 @@ var ts; var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } @@ -70262,15 +71036,15 @@ var ts; } break; case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: + case 227 /* 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 && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 261 /* SourceFile */: - if (container.kind === 261 /* SourceFile */ && !ts.isExternalModule(container)) { + case 262 /* SourceFile */: + if (container.kind === 262 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -70306,13 +71080,13 @@ var ts; for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { var position = possiblePositions_1[_i]; cancellationToken.throwIfCancellationRequested(); - var node_2 = ts.getTouchingWord(sourceFile, position); - if (!node_2 || node_2.kind !== 9 /* StringLiteral */) { + var node_3 = ts.getTouchingWord(sourceFile, position); + if (!node_3 || node_3.kind !== 9 /* StringLiteral */) { return; } - var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + var type_1 = ts.getStringLiteralTypeForNode(node_3, typeChecker); if (type_1 === searchType) { - references.push(getReferenceEntryFromNode(node_2)); + references.push(getReferenceEntryFromNode(node_3)); } } } @@ -70324,7 +71098,7 @@ var ts; // Search the property symbol // for ( { property: p2 } of elems) { } var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 258 /* ShorthandPropertyAssignment */) { + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 259 /* ShorthandPropertyAssignment */) { var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); if (propertySymbol) { result.push(propertySymbol); @@ -70427,7 +71201,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 227 /* InterfaceDeclaration */) { + else if (declaration.kind === 228 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -70593,7 +71367,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 223 /* VariableDeclaration */) { + else if (node.kind === 224 /* VariableDeclaration */) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } @@ -70603,18 +71377,18 @@ var ts; } else { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 205 /* VariableStatement */) { - ts.Debug.assert(node.parent.kind === 224 /* VariableDeclarationList */); + if (node.parent && node.parent.parent && node.parent.parent.kind === 206 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 225 /* VariableDeclarationList */); return node.parent.parent; } } @@ -70689,8 +71463,8 @@ var ts; } function isObjectLiteralPropertyDeclaration(node) { switch (node.kind) { - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: + case 258 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: @@ -70768,7 +71542,7 @@ var ts; // if (node.kind === 70 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 239 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 238 /* NamedImports */))) { + (declaration.kind === 240 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 239 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -70777,7 +71551,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 === 258 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 259 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -70861,7 +71635,7 @@ var ts; var definition; ts.forEach(signatureDeclarations, function (d) { if ((selectConstructors && d.kind === 150 /* Constructor */) || - (!selectConstructors && (d.kind === 225 /* FunctionDeclaration */ || d.kind === 149 /* MethodDeclaration */ || d.kind === 148 /* MethodSignature */))) { + (!selectConstructors && (d.kind === 226 /* FunctionDeclaration */ || d.kind === 149 /* MethodDeclaration */ || d.kind === 148 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -70941,7 +71715,7 @@ var ts; function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 258 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 259 /* ShorthandPropertyAssignment */) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -71048,7 +71822,7 @@ var ts; */ function forEachUnique(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (ts.indexOf(array, array[i]) === i) { var result = callback(array[i], i); if (result) { @@ -71108,19 +71882,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 150 /* Constructor */: - case 226 /* ClassDeclaration */: - case 205 /* VariableStatement */: + case 227 /* ClassDeclaration */: + case 206 /* VariableStatement */: break findOwner; - case 261 /* SourceFile */: + case 262 /* SourceFile */: return undefined; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - if (commentOwner.parent.kind === 230 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 231 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -71135,7 +71909,7 @@ var ts; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; - for (var i = 0, numParams = parameters.length; i < numParams; i++) { + for (var i = 0; i < parameters.length; i++) { var currentName = parameters[i].name; var paramName = currentName.kind === 70 /* Identifier */ ? currentName.text : @@ -71167,7 +71941,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 205 /* VariableStatement */) { + if (commentOwner.kind === 206 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -71287,9 +72061,9 @@ var ts; } } // Add the cached typing locations for inferred typings that are already installed - for (var name_46 in packageNameToTypingLocation) { - if (name_46 in inferredTypings && !inferredTypings[name_46]) { - inferredTypings[name_46] = packageNameToTypingLocation[name_46]; + for (var name_47 in packageNameToTypingLocation) { + if (name_47 in inferredTypings && !inferredTypings[name_47]) { + inferredTypings[name_47] = packageNameToTypingLocation[name_47]; } } // Remove typings that the user has added to the exclude list @@ -71427,12 +72201,12 @@ var ts; return; } var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_47 in nameToDeclarations) { - var declarations = nameToDeclarations[name_47]; + for (var name_48 in nameToDeclarations) { + var declarations = nameToDeclarations[name_48]; 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_47); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_48); if (!matches) { continue; } @@ -71445,14 +72219,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_47); + matches = patternMatcher.getMatches(containers, name_48); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_47, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_48, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -71460,7 +72234,7 @@ var ts; // Remove imports when the imported declaration is already in the list and has the same name. rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 236 /* ImportClause */ || decl.kind === 239 /* ImportSpecifier */ || decl.kind === 234 /* ImportEqualsDeclaration */) { + if (decl.kind === 237 /* ImportClause */ || decl.kind === 240 /* ImportSpecifier */ || decl.kind === 235 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -71715,7 +72489,7 @@ var ts; addLeafNode(node); } break; - case 236 /* ImportClause */: + case 237 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -71727,7 +72501,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings.kind === 238 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -71739,11 +72513,11 @@ var ts; } break; case 174 /* BindingElement */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: var decl = node; - var name_48 = decl.name; - if (ts.isBindingPattern(name_48)) { - addChildrenRecursively(name_48); + var name_49 = decl.name; + if (ts.isBindingPattern(name_49)) { + addChildrenRecursively(name_49); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { // For `const x = function() {}`, just use the function node, not the const. @@ -71754,11 +72528,11 @@ var ts; } break; case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -71768,9 +72542,9 @@ var ts; } endNode(); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -71778,21 +72552,21 @@ var ts; } endNode(); break; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 243 /* ExportSpecifier */: - case 234 /* ImportEqualsDeclaration */: + case 244 /* ExportSpecifier */: + case 235 /* ImportEqualsDeclaration */: case 155 /* IndexSignature */: case 153 /* CallSignature */: case 154 /* ConstructSignature */: - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 285 /* JSDocTypedefTag */) { + if (tag.kind === 286 /* JSDocTypedefTag */) { addLeafNode(tag); } }); @@ -71843,14 +72617,14 @@ var ts; }); /** a and b have the same name, but they may not be mergeable. */ function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 230 /* ModuleDeclaration */ || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 231 /* ModuleDeclaration */ || areSameModule(a, b)); // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 230 /* ModuleDeclaration */) { + if (a.body.kind !== 231 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -71910,7 +72684,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 230 /* ModuleDeclaration */) { + if (node.kind === 231 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -71922,14 +72696,14 @@ var ts; case 185 /* ArrowFunction */: case 197 /* ClassExpression */: return getFunctionOrClassName(node); - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 230 /* ModuleDeclaration */) { + if (node.kind === 231 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -71940,15 +72714,15 @@ var ts; } } switch (node.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; @@ -71965,7 +72739,7 @@ var ts; return "()"; case 155 /* IndexSignature */: return "[]"; - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return ""; @@ -71977,7 +72751,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 205 /* VariableStatement */) { + if (parentNode && parentNode.kind === 206 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -72006,23 +72780,23 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 229 /* EnumDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 261 /* SourceFile */: - case 228 /* TypeAliasDeclaration */: - case 285 /* JSDocTypedefTag */: + case 230 /* EnumDeclaration */: + case 228 /* InterfaceDeclaration */: + case 231 /* ModuleDeclaration */: + case 262 /* SourceFile */: + case 229 /* TypeAliasDeclaration */: + case 286 /* JSDocTypedefTag */: return true; case 150 /* Constructor */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return hasSomeImportantChild(item); case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: @@ -72033,8 +72807,8 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 231 /* ModuleBlock */: - case 261 /* SourceFile */: + case 232 /* ModuleBlock */: + case 262 /* SourceFile */: case 149 /* MethodDeclaration */: case 150 /* Constructor */: return true; @@ -72045,7 +72819,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 223 /* VariableDeclaration */ && childKind !== 174 /* BindingElement */; + return childKind !== 224 /* VariableDeclaration */ && childKind !== 174 /* BindingElement */; }); } } @@ -72103,7 +72877,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 === 230 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 231 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -72114,13 +72888,13 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 230 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 231 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { return !member.name || member.name.kind === 142 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 261 /* SourceFile */ + return node.kind === 262 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); } @@ -72128,14 +72902,14 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 223 /* VariableDeclaration */) { + else if (node.parent.kind === 224 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } else if (node.parent.kind === 192 /* BinaryExpression */ && node.parent.operatorToken.kind === 57 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 257 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 258 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512 /* Default */) { @@ -72248,30 +73022,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 204 /* Block */: + case 205 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_19 = n.parent; + var parent_20 = n.parent; var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent_19.kind === 209 /* DoStatement */ || - parent_19.kind === 212 /* ForInStatement */ || - parent_19.kind === 213 /* ForOfStatement */ || - parent_19.kind === 211 /* ForStatement */ || - parent_19.kind === 208 /* IfStatement */ || - parent_19.kind === 210 /* WhileStatement */ || - parent_19.kind === 217 /* WithStatement */ || - parent_19.kind === 256 /* CatchClause */) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + if (parent_20.kind === 210 /* DoStatement */ || + parent_20.kind === 213 /* ForInStatement */ || + parent_20.kind === 214 /* ForOfStatement */ || + parent_20.kind === 212 /* ForStatement */ || + parent_20.kind === 209 /* IfStatement */ || + parent_20.kind === 211 /* WhileStatement */ || + parent_20.kind === 218 /* WithStatement */ || + parent_20.kind === 257 /* CatchClause */) { + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_19.kind === 221 /* TryStatement */) { + if (parent_20.kind === 222 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_19; + var tryStatement = parent_20; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -72294,17 +73068,17 @@ var ts; break; } // Fallthrough. - case 231 /* ModuleBlock */: { + case 232 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: case 176 /* ObjectLiteralExpression */: - case 232 /* CaseBlock */: { + case 233 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); @@ -72690,7 +73464,8 @@ var ts; } // Assumes 'value' is already lowercase. function indexOfIgnoringCase(string, value) { - for (var i = 0, n = string.length - value.length; i <= n; i++) { + var n = string.length - value.length; + for (var i = 0; i <= n; i++) { if (startsWithIgnoringCase(string, value, i)) { return i; } @@ -72699,7 +73474,7 @@ var ts; } // Assumes 'value' is already lowercase. function startsWithIgnoringCase(string, value, start) { - for (var i = 0, n = value.length; i < n; i++) { + for (var i = 0; i < value.length; i++) { var ch1 = toLowerCase(string.charCodeAt(i + start)); var ch2 = value.charCodeAt(i); if (ch1 !== ch2) { @@ -72771,7 +73546,7 @@ var ts; function breakIntoSpans(identifier, word) { var result = []; var wordStart = 0; - for (var i = 1, n = identifier.length; i < n; i++) { + for (var i = 1; i < identifier.length; i++) { var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); var currentIsDigit = isDigit(identifier.charCodeAt(i)); var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); @@ -73597,7 +74372,7 @@ var ts; var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 202 /* TemplateSpan */ && node.parent.parent.parent.kind === 181 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 203 /* TemplateSpan */ && node.parent.parent.parent.kind === 181 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; @@ -73728,7 +74503,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 261 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 262 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -74124,7 +74899,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 230 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 231 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 70 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 128 /* NamespaceKeyword */ : 127 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -74161,7 +74936,7 @@ var ts; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 228 /* TypeAliasDeclaration */) { + else if (declaration.kind === 229 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -74177,7 +74952,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 260 /* EnumMember */) { + if (declaration.kind === 261 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -74189,7 +74964,7 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 233 /* NamespaceExportDeclaration */) { + if (symbol.declarations[0].kind === 234 /* NamespaceExportDeclaration */) { displayParts.push(ts.keywordPart(83 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(128 /* NamespaceKeyword */)); @@ -74200,7 +74975,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 234 /* ImportEqualsDeclaration */) { + if (declaration.kind === 235 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -74273,7 +75048,7 @@ var ts; // For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 261 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 262 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!declaration.parent || declaration.parent.kind !== 192 /* BinaryExpression */) { @@ -74360,13 +75135,13 @@ var ts; if (declaration.kind === 184 /* FunctionExpression */) { return true; } - if (declaration.kind !== 223 /* VariableDeclaration */ && declaration.kind !== 225 /* FunctionDeclaration */) { + if (declaration.kind !== 224 /* VariableDeclaration */ && declaration.kind !== 226 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_20 = declaration.parent; !ts.isFunctionBlock(parent_20); parent_20 = parent_20.parent) { + for (var parent_21 = declaration.parent; !ts.isFunctionBlock(parent_21); parent_21 = parent_21.parent) { // Reached source file or module block - if (parent_20.kind === 261 /* SourceFile */ || parent_20.kind === 231 /* ModuleBlock */) { + if (parent_21.kind === 262 /* SourceFile */ || parent_21.kind === 232 /* ModuleBlock */) { return false; } } @@ -74604,10 +75379,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 250 /* JsxAttribute */: - case 248 /* JsxOpeningElement */: - case 249 /* JsxClosingElement */: - case 247 /* JsxSelfClosingElement */: + case 251 /* JsxAttribute */: + case 249 /* JsxOpeningElement */: + case 250 /* JsxClosingElement */: + case 248 /* JsxSelfClosingElement */: return node.kind === 70 /* Identifier */; } } @@ -75019,11 +75794,11 @@ var ts; this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Space after }. - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromRange(0 /* FirstToken */, 140 /* LastToken */, [19 /* CloseParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 81 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 105 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 21 /* CloseBracketToken */, 25 /* CommaToken */, 24 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([21 /* CloseBracketToken */, 25 /* CommaToken */, 24 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // No space for dot this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); @@ -75040,10 +75815,10 @@ var ts; this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 80 /* DoKeyword */, 101 /* TryKeyword */, 86 /* FinallyKeyword */, 81 /* ElseKeyword */]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8 /* Delete */)); this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenBraceToken */, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); // Insert new line after { and before } in multi-line contexts. this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); @@ -75073,6 +75848,7 @@ var ts; this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([109 /* LetKeyword */, 75 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95 /* ReturnKeyword */, 24 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); @@ -75089,11 +75865,12 @@ var ts; this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); // TypeScript-specific higher priority rules // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses + this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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([127 /* ModuleKeyword */, 131 /* RequireKeyword */]), 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 133 /* SetKeyword */, 114 /* StaticKeyword */, 136 /* TypeKeyword */, 138 /* FromKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 130 /* ReadonlyKeyword */, 133 /* SetKeyword */, 114 /* StaticKeyword */, 136 /* TypeKeyword */, 138 /* FromKeyword */, 126 /* KeyOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 138 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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(9 /* StringLiteral */, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); @@ -75130,6 +75907,8 @@ var ts; this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* SlashToken */, 28 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57 /* EqualsToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57 /* EqualsToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + // No space before non-null assertion operator + this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50 /* ExclamationToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -75160,7 +75939,7 @@ var ts; this.SpaceBeforeJsxAttribute, this.SpaceBeforeSlashInJsxOpeningElement, this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement, this.NoSpaceBeforeEqualInJsxAttribute, this.NoSpaceAfterEqualInJsxAttribute, // TypeScript-specific rules - this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, + this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, this.SpaceBeforeArrow, this.SpaceAfterArrow, @@ -75175,6 +75954,7 @@ var ts; this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, + this.NoSpaceBeforeNonNullAssertionOperator ]; // These rules are lower in priority than user-configurable rules. this.LowPriorityCommonRules = [ @@ -75184,7 +75964,6 @@ var ts; this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, - this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; /// @@ -75242,9 +76021,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_49 in o) { - if (o[name_49] === rule) { - return name_49; + for (var name_50 in o) { + if (o[name_50] === rule) { + return name_50; } } throw new Error("Unknown rule"); @@ -75253,7 +76032,7 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 211 /* ForStatement */; + return context.contextNode.kind === 212 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); @@ -75263,8 +76042,8 @@ var ts; case 192 /* BinaryExpression */: case 193 /* ConditionalExpression */: case 200 /* AsExpression */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: case 156 /* TypePredicate */: case 164 /* UnionType */: case 165 /* IntersectionType */: @@ -75272,22 +76051,24 @@ var ts; // equals in binding elements: function foo([[x, y] = [1, 2]]) case 174 /* BindingElement */: // equals in type X = ... - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: // equal in p = 0; case 144 /* Parameter */: - case 260 /* EnumMember */: + case 261 /* EnumMember */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: return context.currentTokenSpan.kind === 57 /* EqualsToken */ || context.nextTokenSpan.kind === 57 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: + // "in" keyword in [P in keyof T]: T[P] + case 143 /* TypeParameter */: return context.currentTokenSpan.kind === 91 /* InKeyword */ || context.nextTokenSpan.kind === 91 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return context.currentTokenSpan.kind === 140 /* OfKeyword */ || context.nextTokenSpan.kind === 140 /* OfKeyword */; } return false; @@ -75317,6 +76098,9 @@ var ts; //// * ) and { are on different lines. We only need to format if the block is multiline context. So in this case we format. return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; + Rules.IsBraceWrappedContext = function (context) { + return context.contextNode.kind === 172 /* ObjectBindingPattern */ || Rules.IsSingleLineBlockContext(context); + }; // This check is done before an open brace in a control construct, a function, or a typescript block declaration Rules.IsBeforeMultilineBlockContext = function (context) { return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); @@ -75340,17 +76124,17 @@ var ts; return true; } switch (node.kind) { - case 204 /* Block */: - case 232 /* CaseBlock */: + case 205 /* Block */: + case 233 /* CaseBlock */: case 176 /* ObjectLiteralExpression */: - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: @@ -75364,60 +76148,66 @@ var ts; // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 225 /* FunctionDeclaration */ || context.contextNode.kind === 184 /* FunctionExpression */; + return context.contextNode.kind === 226 /* FunctionDeclaration */ || context.contextNode.kind === 184 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: case 161 /* TypeLiteral */: - case 230 /* ModuleDeclaration */: - case 241 /* ExportDeclaration */: - case 242 /* NamedExports */: - case 235 /* ImportDeclaration */: - case 238 /* NamedImports */: + case 231 /* ModuleDeclaration */: + case 242 /* ExportDeclaration */: + case 243 /* NamedExports */: + case 236 /* ImportDeclaration */: + case 239 /* NamedImports */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 226 /* ClassDeclaration */: - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: - case 204 /* Block */: - case 256 /* CatchClause */: - case 231 /* ModuleBlock */: - case 218 /* SwitchStatement */: + case 227 /* ClassDeclaration */: + case 231 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: + case 257 /* CatchClause */: + case 232 /* ModuleBlock */: + case 219 /* SwitchStatement */: return true; + case 205 /* Block */: { + var blockParent = context.currentTokenParent.parent; + if (blockParent.kind !== 185 /* ArrowFunction */ && + blockParent.kind !== 184 /* FunctionExpression */) { + return true; + } + } } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 208 /* IfStatement */: - case 218 /* SwitchStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: - case 221 /* TryStatement */: - case 209 /* DoStatement */: - case 217 /* WithStatement */: + case 209 /* IfStatement */: + case 219 /* SwitchStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 211 /* WhileStatement */: + case 222 /* TryStatement */: + case 210 /* DoStatement */: + case 218 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 256 /* CatchClause */: + case 257 /* CatchClause */: return true; default: return false; @@ -75448,19 +76238,19 @@ var ts; return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 246 /* JsxElement */; + return context.contextNode.kind !== 247 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 252 /* JsxExpression */; + return context.contextNode.kind === 253 /* JsxExpression */; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 250 /* JsxAttribute */; + return context.nextTokenParent.kind === 251 /* JsxAttribute */; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 250 /* JsxAttribute */; + return context.contextNode.kind === 251 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 247 /* JsxSelfClosingElement */; + return context.contextNode.kind === 248 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -75478,14 +76268,14 @@ var ts; return node.kind === 145 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 224 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 225 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 230 /* ModuleDeclaration */; + return context.contextNode.kind === 231 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { return context.contextNode.kind === 161 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; @@ -75497,10 +76287,11 @@ var ts; switch (parent.kind) { case 157 /* TypeReference */: case 182 /* TypeAssertionExpression */: - case 226 /* ClassDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: + case 228 /* InterfaceDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: @@ -75528,6 +76319,9 @@ var ts; Rules.IsYieldOrYieldStarWithOperand = function (context) { return context.contextNode.kind === 195 /* YieldExpression */ && context.contextNode.expression !== undefined; }; + Rules.IsNonNullAssertionContext = function (context) { + return context.contextNode.kind === 201 /* NonNullExpression */; + }; return Rules; }()); formatting.Rules = Rules; @@ -75846,6 +76640,12 @@ var ts; }; RulesProvider.prototype.createActiveRules = function (options) { var rules = this.globalRules.HighPriorityCommonRules.slice(0); + if (options.insertSpaceAfterConstructor) { + rules.push(this.globalRules.SpaceAfterConstructor); + } + else { + rules.push(this.globalRules.NoSpaceAfterConstructor); + } if (options.insertSpaceAfterCommaDelimiter) { rules.push(this.globalRules.SpaceAfterComma); } @@ -75926,6 +76726,12 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); rules.push(this.globalRules.NoSpaceAfterBinaryOperator); } + if (options.insertSpaceBeforeFunctionParenthesis) { + rules.push(this.globalRules.SpaceBeforeOpenParenInFuncDecl); + } + else { + rules.push(this.globalRules.NoSpaceBeforeOpenParenInFuncDecl); + } if (options.placeOpenBraceOnNewLineForControlBlocks) { rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); } @@ -76058,17 +76864,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 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 231 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 261 /* SourceFile */: - case 204 /* Block */: - case 231 /* ModuleBlock */: + return body && body.kind === 232 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 262 /* SourceFile */: + case 205 /* Block */: + case 232 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -76273,10 +77079,10 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 226 /* ClassDeclaration */: return 74 /* ClassKeyword */; - case 227 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; - case 225 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; - case 229 /* EnumDeclaration */: return 229 /* EnumDeclaration */; + case 227 /* ClassDeclaration */: return 74 /* ClassKeyword */; + case 228 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; + case 226 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; + case 230 /* EnumDeclaration */: return 230 /* EnumDeclaration */; case 151 /* GetAccessor */: return 124 /* GetKeyword */; case 152 /* SetAccessor */: return 133 /* SetKeyword */; case 149 /* MethodDeclaration */: @@ -76316,18 +77122,31 @@ var ts; // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent case 16 /* OpenBraceToken */: case 17 /* CloseBraceToken */: - case 20 /* OpenBracketToken */: - case 21 /* CloseBracketToken */: case 18 /* OpenParenToken */: case 19 /* CloseParenToken */: case 81 /* ElseKeyword */: case 105 /* WhileKeyword */: case 56 /* AtToken */: return indentation; - default: - // if token line equals to the line of containing node (this is a first token in the node) - use node indentation - return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; + case 40 /* SlashToken */: + case 28 /* GreaterThanToken */: { + if (container.kind === 249 /* JsxOpeningElement */ || + container.kind === 250 /* JsxClosingElement */ || + container.kind === 248 /* JsxSelfClosingElement */) { + return indentation; + } + break; + } + case 20 /* OpenBracketToken */: + case 21 /* CloseBracketToken */: { + if (container.kind !== 170 /* MappedType */) { + return indentation; + } + break; + } } + // if token line equals to the line of containing node (this is a first token in the node) - use node indentation + return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; }, getIndentation: function () { return indentation; }, getDelta: function (child) { return getEffectiveDelta(delta, child); }, @@ -76383,7 +77202,7 @@ var ts; if (tokenInfo.token.end > node.end) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); @@ -76417,7 +77236,7 @@ var ts; // stop when formatting scanner advances past the beginning of the child break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, node); } if (!formattingScanner.isOnToken()) { return inheritedIndentation; @@ -76457,11 +77276,11 @@ var ts; startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1 /* Unknown */, parent, parentDynamicIndentation, parentStartLine); listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } else { // consume any tokens that precede the list as child elements of 'node' using its indentation scope - consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); } } } @@ -76479,7 +77298,7 @@ var ts; // without this check close paren will be interpreted as list end token for function expression which is wrong if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { // consume list end token - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } } } @@ -76686,7 +77505,7 @@ var ts; } // shift all parts on the delta size var delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; i++, startLine++) { + for (var i = startIndex; i < parts.length; i++, startLine++) { var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart @@ -76792,7 +77611,7 @@ var ts; function getOpenTokenForList(node, list) { switch (node.kind) { case 150 /* Constructor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -77052,7 +77871,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.isStatementButNotDeclaration(current)) && - (parent.kind === 261 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 262 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -77085,7 +77904,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 208 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 209 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -77107,7 +77926,7 @@ var ts; return node.parent.properties; case 175 /* ArrayLiteralExpression */: return node.parent.elements; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: @@ -77241,35 +78060,36 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 207 /* ExpressionStatement */: - case 226 /* ClassDeclaration */: + case 208 /* ExpressionStatement */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: + case 229 /* TypeAliasDeclaration */: case 175 /* ArrayLiteralExpression */: - case 204 /* Block */: - case 231 /* ModuleBlock */: + case 205 /* Block */: + case 232 /* ModuleBlock */: case 176 /* ObjectLiteralExpression */: case 161 /* TypeLiteral */: + case 170 /* MappedType */: case 163 /* TupleType */: - case 232 /* CaseBlock */: - case 254 /* DefaultClause */: - case 253 /* CaseClause */: + case 233 /* CaseBlock */: + case 255 /* DefaultClause */: + case 254 /* CaseClause */: case 183 /* ParenthesizedExpression */: case 177 /* PropertyAccessExpression */: case 179 /* CallExpression */: case 180 /* NewExpression */: - case 205 /* VariableStatement */: - case 223 /* VariableDeclaration */: - case 240 /* ExportAssignment */: - case 216 /* ReturnStatement */: + case 206 /* VariableStatement */: + case 224 /* VariableDeclaration */: + case 241 /* ExportAssignment */: + case 217 /* ReturnStatement */: case 193 /* ConditionalExpression */: case 173 /* ArrayBindingPattern */: case 172 /* ObjectBindingPattern */: - case 248 /* JsxOpeningElement */: - case 247 /* JsxSelfClosingElement */: - case 252 /* JsxExpression */: + case 249 /* JsxOpeningElement */: + case 248 /* JsxSelfClosingElement */: + case 253 /* JsxExpression */: case 148 /* MethodSignature */: case 153 /* CallSignature */: case 154 /* ConstructSignature */: @@ -77279,10 +78099,10 @@ var ts; case 166 /* ParenthesizedType */: case 181 /* TaggedTemplateExpression */: case 189 /* AwaitExpression */: - case 242 /* NamedExports */: - case 238 /* NamedImports */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: + case 243 /* NamedExports */: + case 239 /* NamedImports */: + case 244 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: return true; } return false; @@ -77291,27 +78111,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 211 /* ForStatement */: - case 208 /* IfStatement */: - case 225 /* FunctionDeclaration */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 212 /* ForStatement */: + case 209 /* IfStatement */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 185 /* ArrowFunction */: case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - return childKind !== 204 /* Block */; - case 241 /* ExportDeclaration */: - return childKind !== 242 /* NamedExports */; - case 235 /* ImportDeclaration */: - return childKind !== 236 /* ImportClause */ || - (child.namedBindings && child.namedBindings.kind !== 238 /* NamedImports */); - case 246 /* JsxElement */: - return childKind !== 249 /* JsxClosingElement */; + return childKind !== 205 /* Block */; + case 242 /* ExportDeclaration */: + return childKind !== 243 /* NamedExports */; + case 236 /* ImportDeclaration */: + return childKind !== 237 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 239 /* NamedImports */); + case 247 /* JsxElement */: + return childKind !== 250 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -77367,25 +78187,128 @@ var ts; (function (ts) { var codefix; (function (codefix) { - function getOpenBraceEnd(constructor, sourceFile) { - // First token is the open curly, this is where we want to put the 'super' call. - return constructor.body.getFirstToken(sourceFile).getEnd(); - } codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 122 /* ConstructorKeyword */) { - return undefined; - } - var newPosition = getOpenBraceEnd(token.parent, sourceFile); - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] - }]; - } + errorCodes: [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code], + getCodeActions: getActionForClassLikeIncorrectImplementsInterface }); + function getActionForClassLikeIncorrectImplementsInterface(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + var classDecl = ts.getContainingClass(token); + if (!classDecl) { + return undefined; + } + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDecl); + var hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, 1 /* Number */); + var hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, 0 /* String */); + var result = []; + for (var _i = 0, implementedTypeNodes_2 = implementedTypeNodes; _i < implementedTypeNodes_2.length; _i++) { + var implementedTypeNode = implementedTypeNodes_2[_i]; + var implementedType = checker.getTypeFromTypeNode(implementedTypeNode); + // Note that this is ultimately derived from a map indexed by symbol names, + // so duplicates cannot occur. + var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); + var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); }); + var insertion = getMissingIndexSignatureInsertion(implementedType, 1 /* Number */, classDecl, hasNumericIndexSignature); + insertion += getMissingIndexSignatureInsertion(implementedType, 0 /* String */, classDecl, hasStringIndexSignature); + insertion += codefix.getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); + var message = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); + if (insertion) { + pushAction(result, insertion, message); + } + } + return result; + function getMissingIndexSignatureInsertion(type, kind, enclosingDeclaration, hasIndexSigOfKind) { + if (!hasIndexSigOfKind) { + var IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); + if (IndexInfoOfKind) { + var writer = ts.getSingleLineStringWriter(); + checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); + var result_7 = writer.string(); + ts.releaseStringWriter(writer); + return result_7; + } + } + return ""; + } + function pushAction(result, insertion, description) { + var newAction = { + description: description, + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }; + result.push(newAction); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + function getActionForClassLikeMissingAbstractMember(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + // This is the identifier in the case of a class declaration + // or the class keyword token in the case of a class expression. + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + if (ts.isClassLike(token.parent)) { + var classDecl = token.parent; + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + // Note that this is ultimately derived from a map indexed by symbol names, + // so duplicates cannot occur. + var extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); + var abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); + var insertion = codefix.getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); + if (insertion.length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_inherited_abstract_class), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }]; + } + } + return undefined; + } + function symbolPointsToNonPrivateAndAbstractMember(symbol) { + var decls = symbol.getDeclarations(); + ts.Debug.assert(!!(decls && decls.length > 0)); + var flags = ts.getModifierFlags(decls[0]); + return !(flags & 8 /* Private */) && !!(flags & 128 /* Abstract */); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { codefix.registerCodeFix({ errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], getCodeActions: function (context) { @@ -77409,7 +78332,7 @@ var ts; } } } - var newPosition = getOpenBraceEnd(constructor, sourceFile); + var newPosition = ts.getOpenBraceEnd(constructor, sourceFile); var changes = [{ fileName: sourceFile.fileName, textChanges: [{ newText: superCall.getText(sourceFile), @@ -77425,7 +78348,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -77439,6 +78362,227 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 122 /* ConstructorKeyword */) { + return undefined; + } + var newPosition = ts.getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var classDeclNode = ts.getContainingClass(token); + if (!(token.kind === 70 /* Identifier */ && ts.isClassLike(classDeclNode))) { + return undefined; + } + var heritageClauses = classDeclNode.heritageClauses; + if (!(heritageClauses && heritageClauses.length > 0)) { + return undefined; + } + var extendsToken = heritageClauses[0].getFirstToken(); + if (!(extendsToken && extendsToken.kind === 84 /* ExtendsKeyword */)) { + return undefined; + } + var changeStart = extendsToken.getStart(sourceFile); + var changeEnd = extendsToken.getEnd(); + var textChanges = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + // We replace existing keywords with commas. + for (var i = 1; i < heritageClauses.length; i++) { + var keywordToken = heritageClauses[i].getFirstToken(); + if (keywordToken) { + changeStart = keywordToken.getStart(sourceFile); + changeEnd = keywordToken.getEnd(); + textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + } + } + var result = [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Change_extends_to_implements), + changes: [{ + fileName: sourceFile.fileName, + textChanges: textChanges + }] + }]; + return result; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ + ts.Diagnostics._0_is_declared_but_never_used.code, + ts.Diagnostics.Property_0_is_declared_but_never_used.code + ], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + // this handles var ["computed"] = 12; + if (token.kind === 20 /* OpenBracketToken */) { + token = ts.getTokenAtPosition(sourceFile, start + 1); + } + switch (token.kind) { + case 70 /* Identifier */: + switch (token.parent.kind) { + case 224 /* VariableDeclaration */: + switch (token.parent.parent.parent.kind) { + case 212 /* ForStatement */: + var forStatement = token.parent.parent.parent; + var forInitializer = forStatement.initializer; + if (forInitializer.declarations.length === 1) { + return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); + } + else { + return removeSingleItem(forInitializer.declarations, token); + } + case 214 /* ForOfStatement */: + var forOfStatement = token.parent.parent.parent; + if (forOfStatement.initializer.kind === 225 /* VariableDeclarationList */) { + var forOfInitializer = forOfStatement.initializer; + return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); + } + break; + case 213 /* ForInStatement */: + // There is no valid fix in the case of: + // for .. in + return undefined; + case 257 /* CatchClause */: + var catchClause = token.parent.parent; + var parameter = catchClause.variableDeclaration.getChildren()[0]; + return createCodeFix("", parameter.pos, parameter.end - parameter.pos); + default: + var variableStatement = token.parent.parent.parent; + if (variableStatement.declarationList.declarations.length === 1) { + return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); + } + else { + var declarations = variableStatement.declarationList.declarations; + return removeSingleItem(declarations, token); + } + } + case 143 /* TypeParameter */: + var typeParameters = token.parent.parent.typeParameters; + if (typeParameters.length === 1) { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + } + else { + return removeSingleItem(typeParameters, token); + } + case 144 /* Parameter */: + var functionDeclaration = token.parent.parent; + if (functionDeclaration.parameters.length === 1) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else { + return removeSingleItem(functionDeclaration.parameters, token); + } + // handle case where 'import a = A;' + case 235 /* ImportEqualsDeclaration */: + var importEquals = findImportDeclaration(token); + return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); + case 240 /* ImportSpecifier */: + var namedImports = token.parent.parent; + if (namedImports.elements.length === 1) { + // Only 1 import and it is unused. So the entire declaration should be removed. + var importSpec = findImportDeclaration(token); + return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); + } + else { + return removeSingleItem(namedImports.elements, token); + } + // handle case where "import d, * as ns from './file'" + // or "'import {a, b as ns} from './file'" + case 237 /* ImportClause */: + var importClause = token.parent; + if (!importClause.namedBindings) { + var importDecl = findImportDeclaration(importClause); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); + } + case 238 /* NamespaceImport */: + var namespaceImport = token.parent; + if (namespaceImport.name == token && !namespaceImport.parent.name) { + var importDecl = findImportDeclaration(namespaceImport); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + var start_4 = namespaceImport.parent.name.end; + return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); + } + } + break; + case 147 /* PropertyDeclaration */: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + case 238 /* NamespaceImport */: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + if (ts.isDeclarationName(token)) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else if (ts.isLiteralComputedPropertyDeclarationName(token)) { + return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); + } + else { + return undefined; + } + function findImportDeclaration(token) { + var importDecl = token; + while (importDecl.kind != 236 /* ImportDeclaration */ && importDecl.parent) { + importDecl = importDecl.parent; + } + return importDecl; + } + function createCodeFix(newText, start, length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ newText: newText, span: { start: start, length: length } }] + }] + }]; + } + function removeSingleItem(elements, token) { + if (elements[0] === token.parent) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + } + else { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + } + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -77538,7 +78682,10 @@ var ts; return ImportCodeActionMap; }()); codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Cannot_find_name_0.code], + errorCodes: [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ], getCodeActions: function (context) { var sourceFile = context.sourceFile; var checker = context.program.getTypeChecker(); @@ -77550,6 +78697,11 @@ var ts; // this is a module id -> module import declaration map var cachedImportDeclarations = ts.createMap(); var cachedNewImportInsertPosition; + var currentTokenMeaning = ts.getMeaningFromLocation(token); + if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { + var symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); + return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true); + } var allPotentialModules = checker.getAmbientModules(); for (var _i = 0, allSourceFiles_1 = allSourceFiles; _i < allSourceFiles_1.length; _i++) { var otherSourceFile = allSourceFiles_1[_i]; @@ -77557,7 +78709,6 @@ var ts; allPotentialModules.push(otherSourceFile.symbol); } } - var currentTokenMeaning = ts.getMeaningFromLocation(token); for (var _a = 0, allPotentialModules_1 = allPotentialModules; _a < allPotentialModules_1.length; _a++) { var moduleSymbol = allPotentialModules_1[_a]; context.cancellationToken.throwIfCancellationRequested(); @@ -77597,10 +78748,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 236 /* ImportDeclaration */) { return node; } - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 235 /* ImportEqualsDeclaration */) { return node; } node = node.parent; @@ -77618,7 +78769,7 @@ var ts; var declarations = symbol.getDeclarations(); return declarations ? ts.some(symbol.declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }) : false; } - function getCodeActionForImport(moduleSymbol, isDefault) { + function getCodeActionForImport(moduleSymbol, isDefault, isNamespaceImport) { var existingDeclarations = getImportDeclarations(moduleSymbol); if (existingDeclarations.length > 0) { // With an existing import statement, there are more than one actions the user can do. @@ -77646,9 +78797,9 @@ var ts; var existingModuleSpecifier; for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { var declaration = declarations_11[_i]; - if (declaration.kind === 235 /* ImportDeclaration */) { + if (declaration.kind === 236 /* ImportDeclaration */) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 238 /* NamespaceImport */) { // case: // import * as ns from "foo" namespaceImportDeclaration = declaration; @@ -77672,7 +78823,7 @@ var ts; if (namespaceImportDeclaration) { actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); } - if (namedImportDeclaration && namedImportDeclaration.importClause && + if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause && (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { /** * If the existing import declaration already has a named import list, just @@ -77688,7 +78839,7 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 245 /* ExternalModuleReference */) { + if (declaration.moduleReference && declaration.moduleReference.kind === 246 /* ExternalModuleReference */) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); @@ -77736,7 +78887,7 @@ var ts; } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 235 /* ImportDeclaration */) { + if (declaration.kind === 236 /* ImportDeclaration */) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -77773,7 +78924,9 @@ var ts; var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); var importStatementText = isDefault ? "import " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" - : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; + : isNamespaceImport + ? "import * as " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" + : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; // if this file doesn't have any import statements, insert an import statement and then insert a new line // between the only import statement and user code. Otherwise just insert the statement because chances // are there are already a new line seperating code and import statements. @@ -77793,7 +78946,7 @@ var ts; tryGetModuleNameAsNodeModule() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 261 /* SourceFile */) { + if (moduleSymbol.valueDeclaration.kind !== 262 /* SourceFile */) { return moduleSymbol.name; } } @@ -77806,6 +78959,7 @@ var ts; if (!relativeName) { return undefined; } + var relativeNameWithIndex = ts.removeFileExtension(relativeName); relativeName = removeExtensionAndIndexPostFix(relativeName); if (options.paths) { for (var key in options.paths) { @@ -77825,7 +78979,7 @@ var ts; return key.replace("\*", matchedStar); } } - else if (pattern === relativeName) { + else if (pattern === relativeName || pattern === relativeNameWithIndex) { return key; } } @@ -77947,156 +79101,149 @@ var ts; (function (ts) { var codefix; (function (codefix) { - codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics._0_is_declared_but_never_used.code, - ts.Diagnostics.Property_0_is_declared_but_never_used.code - ], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var start = context.span.start; - var token = ts.getTokenAtPosition(sourceFile, start); - // this handles var ["computed"] = 12; - if (token.kind === 20 /* OpenBracketToken */) { - token = ts.getTokenAtPosition(sourceFile, start + 1); - } - switch (token.kind) { - case 70 /* Identifier */: - switch (token.parent.kind) { - case 223 /* VariableDeclaration */: - switch (token.parent.parent.parent.kind) { - case 211 /* ForStatement */: - var forStatement = token.parent.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); - } - else { - return removeSingleItem(forInitializer.declarations, token); - } - case 213 /* ForOfStatement */: - var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 224 /* VariableDeclarationList */) { - var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); - } - break; - case 212 /* ForInStatement */: - // There is no valid fix in the case of: - // for .. in - return undefined; - case 256 /* CatchClause */: - var catchClause = token.parent.parent; - var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); - default: - var variableStatement = token.parent.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); - } - else { - var declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); - } - } - case 143 /* TypeParameter */: - var typeParameters = token.parent.parent.typeParameters; - if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); - } - else { - return removeSingleItem(typeParameters, token); - } - case 144 /* Parameter */: - var functionDeclaration = token.parent.parent; - if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else { - return removeSingleItem(functionDeclaration.parameters, token); - } - // handle case where 'import a = A;' - case 234 /* ImportEqualsDeclaration */: - var importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); - case 239 /* ImportSpecifier */: - var namedImports = token.parent.parent; - if (namedImports.elements.length === 1) { - // Only 1 import and it is unused. So the entire declaration should be removed. - var importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); - } - else { - return removeSingleItem(namedImports.elements, token); - } - // handle case where "import d, * as ns from './file'" - // or "'import {a, b as ns} from './file'" - case 236 /* ImportClause */: - var importClause = token.parent; - if (!importClause.namedBindings) { - var importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); - } - case 237 /* NamespaceImport */: - var namespaceImport = token.parent; - if (namespaceImport.name == token && !namespaceImport.parent.name) { - var importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - var start_4 = namespaceImport.parent.name.end; - return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); - } - } - break; - case 147 /* PropertyDeclaration */: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case 237 /* NamespaceImport */: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - if (ts.isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); - } - else { - return undefined; - } - function findImportDeclaration(token) { - var importDecl = token; - while (importDecl.kind != 235 /* ImportDeclaration */ && importDecl.parent) { - importDecl = importDecl.parent; + /** + * Finds members of the resolved type that are missing in the class pointed to by class decl + * and generates source code for the missing members. + * @param possiblyMissingSymbols The collection of symbols to filter and then get insertions for. + * @returns Empty string iff there are no member insertions. + */ + function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { + var classMembers = classDeclaration.symbol.members; + var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !(symbol.getName() in classMembers); }); + var insertion = ""; + for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { + var symbol = missingMembers_1[_i]; + insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + } + return insertion; + } + codefix.getMissingMembersInsertion = getMissingMembersInsertion; + /** + * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. + */ + function getInsertionForMemberSymbol(symbol, enclosingDeclaration, checker, newlineChar) { + // const name = symbol.getName(); + var type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + var declarations = symbol.getDeclarations(); + if (!(declarations && declarations.length)) { + return ""; + } + var declaration = declarations[0]; + var name = declaration.name ? declaration.name.getText() : undefined; + var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); + switch (declaration.kind) { + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 146 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + var typeString = checker.typeToString(type, enclosingDeclaration, 0 /* None */); + return "" + visibility + name + ": " + typeString + ";" + newlineChar; + case 148 /* MethodSignature */: + case 149 /* MethodDeclaration */: + // The signature for the implementation appears as an entry in `signatures` iff + // there is only one signature. + // If there are overloads and an implementation signature, it appears as an + // extra declaration that isn't a signature for `type`. + // If there is more than one overload but no implementation signature + // (eg: an abstract method or interface declaration), there is a 1-1 + // correspondence of declarations and signatures. + var signatures = checker.getSignaturesOfType(type, 0 /* Call */); + if (!(signatures && signatures.length > 0)) { + return ""; } - return importDecl; - } - function createCodeFix(newText, start, length) { - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText: newText, span: { start: start, length: length } }] - }] - }]; - } - function removeSingleItem(elements, token) { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + if (declarations.length === 1) { + ts.Debug.assert(signatures.length === 1); + var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar); + } + var result = ""; + for (var i = 0; i < signatures.length; i++) { + var sigString_2 = checker.signatureToString(signatures[i], enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + result += "" + visibility + name + sigString_2 + ";" + newlineChar; + } + // If there is a declaration with a body, it is the last declaration, + // and it isn't caught by `getSignaturesOfType`. + var bodySig = undefined; + if (declarations.length > signatures.length) { + bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); } else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + ts.Debug.assert(declarations.length === signatures.length); + bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); } + var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar); + return result; + default: + return ""; + } + } + function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { + var newSignatureDeclaration = ts.createNode(153 /* CallSignature */); + newSignatureDeclaration.parent = enclosingDeclaration; + newSignatureDeclaration.name = signatures[0].getDeclaration().name; + var maxNonRestArgs = -1; + var maxArgsIndex = 0; + var minArgumentCount = signatures[0].minArgumentCount; + var hasRestParameter = false; + for (var i = 0; i < signatures.length; i++) { + var sig = signatures[i]; + minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); + hasRestParameter = hasRestParameter || sig.hasRestParameter; + var nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); + if (nonRestLength > maxNonRestArgs) { + maxNonRestArgs = nonRestLength; + maxArgsIndex = i; } } - }); + var maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(function (symbol) { return symbol.getName(); }); + var optionalToken = ts.createToken(54 /* QuestionToken */); + newSignatureDeclaration.parameters = ts.createNodeArray(); + for (var i = 0; i < maxNonRestArgs; i++) { + var newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); + newSignatureDeclaration.parameters.push(newParameter); + } + if (hasRestParameter) { + var restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); + restParameter.dotDotDotToken = ts.createToken(23 /* DotDotDotToken */); + newSignatureDeclaration.parameters.push(restParameter); + } + return checker.getSignatureFromDeclaration(newSignatureDeclaration); + function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { + var newParameter = ts.createNode(144 /* Parameter */); + newParameter.symbol = new SymbolConstructor(1 /* FunctionScopedVariable */, maxArgsParameterSymbolNames[index] || "rest"); + newParameter.symbol.valueDeclaration = newParameter; + newParameter.symbol.declarations = [newParameter]; + newParameter.parent = enclosingSignatureDeclaration; + if (index >= minArgCount) { + newParameter.questionToken = optionalToken; + } + return newParameter; + } + } + function getMethodBodyStub(newLineChar) { + return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar; + } + function getVisibilityPrefix(flags) { + if (flags & 4 /* Public */) { + return "public "; + } + else if (flags & 16 /* Protected */) { + return "protected "; + } + return ""; + } + var SymbolConstructor = ts.objectAllocator.getSymbolConstructor(); })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); -/// -/// -/// +/// +/// +/// +/// +/// +/// +/// +/// /// /// /// @@ -78122,7 +79269,7 @@ var ts; /// /// /// -/// +/// /// var ts; (function (ts) { @@ -78187,7 +79334,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(292 /* SyntaxList */, nodes.pos, nodes.end, this); + var list = createNode(293 /* SyntaxList */, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -78210,7 +79357,7 @@ var ts; ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 278 /* FirstJSDocTagNode */ && this.kind <= 291 /* LastJSDocTagNode */; + var useJSDocScanner_1 = this.kind >= 279 /* FirstJSDocTagNode */ && this.kind <= 292 /* LastJSDocTagNode */; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -78489,9 +79636,9 @@ var ts; } function getDeclarationName(declaration) { if (declaration.name) { - var result_7 = getTextOfIdentifierOrLiteral(declaration.name); - if (result_7 !== undefined) { - return result_7; + var result_8 = getTextOfIdentifierOrLiteral(declaration.name); + if (result_8 !== undefined) { + return result_8; } if (declaration.name.kind === 142 /* ComputedPropertyName */) { var expr = declaration.name.expression; @@ -78515,7 +79662,7 @@ var ts; } function visit(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -78538,18 +79685,18 @@ var ts; } ts.forEachChild(node, visit); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: - case 234 /* ImportEqualsDeclaration */: - case 236 /* ImportClause */: - case 237 /* NamespaceImport */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 230 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 244 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: + case 235 /* ImportEqualsDeclaration */: + case 237 /* ImportClause */: + case 238 /* NamespaceImport */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 161 /* TypeLiteral */: @@ -78562,7 +79709,7 @@ var ts; break; } // fall through - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { @@ -78572,19 +79719,19 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 260 /* EnumMember */: + case 261 /* EnumMember */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: addDeclaration(node); break; - case 241 /* ExportDeclaration */: + case 242 /* 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 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -78596,7 +79743,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 238 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -79297,7 +80444,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 === 230 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 231 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -79529,7 +80676,7 @@ var ts; continue; } var descriptor = undefined; - for (var i = 0, n = descriptors.length; i < n; i++) { + for (var i = 0; i < descriptors.length; i++) { if (matchArray[i + firstDescriptorCaptureIndex]) { descriptor = descriptors[i]; } @@ -79683,7 +80830,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 === 245 /* ExternalModuleReference */ || + node.parent.kind === 246 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -79787,16 +80934,16 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: return spanInVariableDeclaration(node); case 144 /* Parameter */: return spanInParameterDeclaration(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: @@ -79805,85 +80952,85 @@ var ts; case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 204 /* Block */: + case 205 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return spanInBlock(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return spanInBlock(node.block); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 209 /* DoStatement */: + case 210 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 222 /* DebuggerStatement */: + case 223 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 208 /* IfStatement */: + case 209 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: + case 216 /* BreakStatement */: + case 215 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return spanInForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 254 /* CaseClause */: + case 255 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 221 /* TryStatement */: + case 222 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 261 /* EnumMember */: case 174 /* BindingElement */: // span on complete node return textSpan(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: // span in statement return spanInNode(node.statement); case 145 /* Decorator */: @@ -79892,8 +81039,8 @@ var ts; case 173 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: return undefined; // Tokens: case 24 /* SemicolonToken */: @@ -79937,8 +81084,8 @@ var ts; // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern if ((node.kind === 70 /* Identifier */ || node.kind == 196 /* SpreadElement */ || - node.kind === 257 /* PropertyAssignment */ || - node.kind === 258 /* ShorthandPropertyAssignment */) && + node.kind === 258 /* PropertyAssignment */ || + node.kind === 259 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } @@ -79965,14 +81112,14 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 209 /* DoStatement */: + case 210 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); case 145 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 212 /* ForStatement */: + case 214 /* ForOfStatement */: return textSpan(node); case 192 /* BinaryExpression */: if (node.parent.operatorToken.kind === 25 /* CommaToken */) { @@ -79989,7 +81136,7 @@ var ts; } } // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 257 /* PropertyAssignment */ && + if (node.parent.kind === 258 /* PropertyAssignment */ && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); @@ -80003,7 +81150,7 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 223 /* VariableDeclaration */ || + if ((node.parent.kind === 224 /* VariableDeclaration */ || node.parent.kind === 144 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || @@ -80038,7 +81185,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 212 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 213 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -80049,7 +81196,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 213 /* ForOfStatement */) { + variableDeclaration.parent.parent.kind === 214 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -80089,7 +81236,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 226 /* ClassDeclaration */ && functionDeclaration.kind !== 150 /* Constructor */); + (functionDeclaration.parent.kind === 227 /* ClassDeclaration */ && functionDeclaration.kind !== 150 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -80112,25 +81259,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 210 /* WhileStatement */: - case 208 /* IfStatement */: - case 212 /* ForInStatement */: + case 211 /* WhileStatement */: + case 209 /* IfStatement */: + case 213 /* ForInStatement */: 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 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 212 /* ForStatement */: + case 214 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 224 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 225 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -80184,13 +81331,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -80198,24 +81345,24 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 229 /* EnumDeclaration */: - case 226 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 204 /* Block */: + case 205 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through - case 256 /* CatchClause */: + case 257 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -80254,7 +81401,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 209 /* DoStatement */ || + if (node.parent.kind === 210 /* DoStatement */ || node.parent.kind === 179 /* CallExpression */ || node.parent.kind === 180 /* NewExpression */) { return spanInPreviousNode(node); @@ -80269,17 +81416,17 @@ var ts; // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 150 /* Constructor */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 211 /* WhileStatement */: + case 210 /* DoStatement */: + case 212 /* ForStatement */: + case 214 /* ForOfStatement */: case 179 /* CallExpression */: case 180 /* NewExpression */: case 183 /* ParenthesizedExpression */: @@ -80292,7 +81439,7 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 257 /* PropertyAssignment */ || + node.parent.kind === 258 /* PropertyAssignment */ || node.parent.kind === 144 /* Parameter */) { return spanInPreviousNode(node); } @@ -80305,7 +81452,7 @@ var ts; return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 209 /* DoStatement */) { + if (node.parent.kind === 210 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -80313,7 +81460,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 213 /* ForOfStatement */) { + if (node.parent.kind === 214 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -81102,7 +82249,7 @@ var ts; this._shims.push(shim); }; TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { + for (var i = 0; i < this._shims.length; i++) { if (this._shims[i] === shim) { delete this._shims[i]; return; diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index d8cd324a8d2..47b04ae9e58 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -13,11 +13,16 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ts; (function (ts) { var OperationCanceledException = (function () { @@ -206,7 +211,7 @@ var ts; ts.toPath = toPath; function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -225,7 +230,7 @@ var ts; ts.zipWith = zipWith; function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -235,7 +240,7 @@ var ts; } ts.every = every; function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -245,7 +250,7 @@ var ts; } ts.find = find; function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -268,7 +273,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -278,7 +283,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -981,6 +986,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -2475,7 +2481,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_be_declared_in_an_ambient_context_1086", message: "An accessor cannot be declared in an ambient context." }, _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", message: "'{0}' modifier cannot appear on a constructor declaration." }, _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_parameter_1090", message: "'{0}' modifier cannot appear on a parameter." }, @@ -2632,6 +2638,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "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_2301", message: "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_2302", message: "Static members cannot reference class type parameters." }, @@ -2861,6 +2868,8 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "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: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2870,6 +2879,7 @@ var ts; Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "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: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -2921,6 +2931,8 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "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_4002", message: "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_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -3089,6 +3101,7 @@ var ts; Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -3102,10 +3115,10 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, @@ -3154,6 +3167,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -3210,22 +3225,25 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); var ts; @@ -3606,7 +3624,7 @@ var ts; if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { var ch = text.charCodeAt(pos); if ((pos + mergeConflictMarkerLength) < text.length) { - for (var i = 0, n = mergeConflictMarkerLength; i < n; i++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -3792,7 +3810,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -5539,6 +5557,7 @@ var ts; if (resolutionStack === void 0) { resolutionStack = []; } if (extraFileExtensions === void 0) { extraFileExtensions = []; } var errors = []; + basePath = ts.normalizeSlashes(basePath); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -6102,6 +6121,12 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; + var Extensions; + (function (Extensions) { + Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; + Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; + Extensions[Extensions["DtsOnly"] = 2] = "DtsOnly"; + })(Extensions || (Extensions = {})); function resolvedTypeScriptOnly(resolved) { if (!resolved) { return undefined; @@ -6109,9 +6134,6 @@ var ts; ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); return resolved.path; } - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } function resolvedModuleFromResolved(_a, isExternalLibraryImport) { var path = _a.path, extension = _a.extension; return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; @@ -6123,13 +6145,13 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { + function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); switch (extensions) { - case 2: - case 0: + case Extensions.DtsOnly: + case Extensions.TypeScript: return tryReadFromField("typings") || tryReadFromField("types"); - case 1: + case Extensions.JavaScript: if (typeof jsonContent.main === "string") { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); @@ -6191,6 +6213,7 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } + return undefined; }); return typeRoots; } @@ -6245,7 +6268,11 @@ var ts; return ts.forEach(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); }); } else { @@ -6261,7 +6288,8 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -6302,31 +6330,115 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + if (!perModuleNameCache) { + moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent_1 = ts.getDirectoryPath(current); + if (parent_1 === current || directoryPathMap.contains(parent_1)) { + break; + } + directoryPathMap.set(parent_1, result); + current = parent_1; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache[moduleName]; + if (result) { if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache[moduleName] = result; + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; } if (traceEnabled) { if (result.resolvedModule) { @@ -6451,33 +6563,33 @@ var ts; return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0) || tryResolve(1); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } @@ -6494,10 +6606,33 @@ var ts; } function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); @@ -6525,11 +6660,11 @@ var ts; } } switch (extensions) { - case 2: + case Extensions.DtsOnly: return tryExtension(".d.ts", ts.Extension.Dts); - case 0: + case Extensions.TypeScript: return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1: + case Extensions.JavaScript: return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } function tryExtension(ext, extension) { @@ -6538,19 +6673,21 @@ var ts; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } } - failedLookupLocations.push(fileName); - return undefined; } + failedLookupLocations.push(fileName); + return undefined; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var packageJsonPath = pathToPackageJson(candidate); @@ -6559,16 +6696,22 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - return resolvedFromAnyFile(fromFile); + var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); + if (mainOrTypesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); + var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); + if (fromExactFile) { + var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); + if (resolved_3) { + return resolved_3; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } - var x = tryAddingExtensions(typesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; + var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved) { + return resolved; } } else { @@ -6578,73 +6721,117 @@ var ts; } } else { - if (state.traceEnabled) { + if (directoryExists && state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } failedLookupLocations.push(packageJsonPath); } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); } function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(2, moduleName, directory, failedLookupLocations, state, true); + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, true, undefined); } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); } }); } function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } - if (extensions !== 1) { - return loadModuleFromNodeModulesFolder(2, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0) || tryResolve(1); - return createResolvedModuleWithFailedLookupLocations(resolved, false, failedLookupLocations); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); if (resolvedUsingSettings) { - return resolvedUsingSettings; + return { value: resolvedUsingSettings }; } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { - var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); - if (resolved_3) { - return resolved_3; + if (resolved_4) { + return resolved_4; } - if (extensions === 0) { + if (extensions === Extensions.TypeScript) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); } } } @@ -6656,10 +6843,13 @@ var ts; } var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2, moduleName, globalCache, failedLookupLocations, state); + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } function forEachAncestorDirectory(directory, callback) { while (true) { var result = callback(directory); diff --git a/package.json b/package.json index 2de37b712ab..c49162343a2 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "gulp-insert": "latest", "gulp-newer": "latest", "gulp-sourcemaps": "latest", - "gulp-typescript": "latest", + "gulp-typescript": "3.1.3", "into-stream": "latest", "istanbul": "latest", "jake": "latest", @@ -75,7 +75,7 @@ "through2": "latest", "travis-fold": "latest", "ts-node": "latest", - "tslint": "4.0.0-dev.3", + "tslint": "next", "typescript": "next" }, "scripts": { diff --git a/scripts/processDiagnosticMessages.ts b/scripts/processDiagnosticMessages.ts index e5eaa46c8e5..db7a9e0f1f2 100644 --- a/scripts/processDiagnosticMessages.ts +++ b/scripts/processDiagnosticMessages.ts @@ -27,7 +27,7 @@ function main(): void { var inputFilePath = sys.args[0].replace(/\\/g, "/"); var inputStr = sys.readFile(inputFilePath); - + var diagnosticMessages: InputDiagnosticMessageTable = JSON.parse(inputStr); var names = Utilities.getObjectKeys(diagnosticMessages); @@ -44,7 +44,7 @@ function main(): void { function checkForUniqueCodes(messages: string[], diagnosticTable: InputDiagnosticMessageTable) { const originalMessageForCode: string[] = []; let numConflicts = 0; - + for (const currentMessage of messages) { const code = diagnosticTable[currentMessage].code; @@ -74,7 +74,7 @@ function buildUniqueNameMap(names: string[]): ts.Map { var uniqueNames = NameGenerator.ensureUniqueness(names, /* isCaseSensitive */ false, /* isFixed */ undefined); for (var i = 0; i < names.length; i++) { - nameMap[names[i]] = uniqueNames[i]; + nameMap.set(names[i], uniqueNames[i]); } return nameMap; @@ -91,7 +91,7 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap: for (var i = 0; i < names.length; i++) { var name = names[i]; var diagnosticDetails = messageTable[name]; - var propName = convertPropertyName(nameMap[name]); + var propName = convertPropertyName(nameMap.get(name)); result += ' ' + propName + @@ -114,7 +114,7 @@ function buildDiagnosticMessageOutput(messageTable: InputDiagnosticMessageTable, for (var i = 0; i < names.length; i++) { var name = names[i]; var diagnosticDetails = messageTable[name]; - var propName = convertPropertyName(nameMap[name]); + var propName = convertPropertyName(nameMap.get(name)); result += '\r\n "' + createKey(propName, diagnosticDetails.code) + '"' + ' : "' + name.replace(/[\"]/g, '\\"') + '"'; if (i !== names.length - 1) { diff --git a/scripts/tslint/preferConstRule.ts b/scripts/tslint/preferConstRule.ts deleted file mode 100644 index 28d7446b290..00000000000 --- a/scripts/tslint/preferConstRule.ts +++ /dev/null @@ -1,204 +0,0 @@ -import * as Lint from "tslint/lib"; -import * as ts from "typescript"; - -export class Rule extends Lint.Rules.AbstractRule { - public static FAILURE_STRING_FACTORY = (identifier: string) => `Identifier '${identifier}' never appears on the LHS of an assignment - use const instead of let for its declaration.`; - - public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { - return this.applyWithWalker(new PreferConstWalker(sourceFile, this.getOptions())); - } -} - -function isLet(node: ts.Node) { - return !!(ts.getCombinedNodeFlags(node) & ts.NodeFlags.Let); -} - -function isExported(node: ts.Node) { - return !!(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export); -} - -function isAssignmentOperator(token: ts.SyntaxKind): boolean { - return token >= ts.SyntaxKind.FirstAssignment && token <= ts.SyntaxKind.LastAssignment; -} - -function isBindingLiteralExpression(node: ts.Node): node is (ts.ArrayLiteralExpression | ts.ObjectLiteralExpression) { - return (!!node) && (node.kind === ts.SyntaxKind.ObjectLiteralExpression || node.kind === ts.SyntaxKind.ArrayLiteralExpression); -} - -interface DeclarationUsages { - declaration: ts.VariableDeclaration; - usages: number; -} - -class PreferConstWalker extends Lint.RuleWalker { - private inScopeLetDeclarations: ts.MapLike[] = []; - private errors: Lint.RuleFailure[] = []; - private markAssignment(identifier: ts.Identifier) { - const name = identifier.text; - for (let i = this.inScopeLetDeclarations.length - 1; i >= 0; i--) { - const declarations = this.inScopeLetDeclarations[i]; - if (declarations[name]) { - declarations[name].usages++; - break; - } - } - } - - visitSourceFile(node: ts.SourceFile) { - super.visitSourceFile(node); - // Sort errors by position because tslint doesn't - this.errors.sort((a, b) => a.getStartPosition().getPosition() - b.getStartPosition().getPosition()).forEach(e => this.addFailure(e)); - } - - visitBinaryExpression(node: ts.BinaryExpression) { - if (isAssignmentOperator(node.operatorToken.kind)) { - this.visitLeftHandSideExpression(node.left); - } - super.visitBinaryExpression(node); - } - - private visitLeftHandSideExpression(node: ts.Expression) { - while (node.kind === ts.SyntaxKind.ParenthesizedExpression) { - node = (node as ts.ParenthesizedExpression).expression; - } - if (node.kind === ts.SyntaxKind.Identifier) { - this.markAssignment(node as ts.Identifier); - } - else if (isBindingLiteralExpression(node)) { - this.visitBindingLiteralExpression(node as (ts.ArrayLiteralExpression | ts.ObjectLiteralExpression)); - } - } - - private visitBindingLiteralExpression(node: ts.ArrayLiteralExpression | ts.ObjectLiteralExpression) { - if (node.kind === ts.SyntaxKind.ObjectLiteralExpression) { - const pattern = node as ts.ObjectLiteralExpression; - for (const element of pattern.properties) { - const kind = element.kind; - - if (kind === ts.SyntaxKind.ShorthandPropertyAssignment) { - this.markAssignment((element as ts.ShorthandPropertyAssignment).name); - } - else if (kind === ts.SyntaxKind.PropertyAssignment) { - this.visitLeftHandSideExpression((element as ts.PropertyAssignment).initializer); - } - } - } - else if (node.kind === ts.SyntaxKind.ArrayLiteralExpression) { - const pattern = node as ts.ArrayLiteralExpression; - for (const element of pattern.elements) { - this.visitLeftHandSideExpression(element); - } - } - } - - private visitBindingPatternIdentifiers(pattern: ts.BindingPattern) { - for (const element of pattern.elements) { - if (element.kind !== ts.SyntaxKind.BindingElement) { - continue; - } - - const name = (element).name; - if (name.kind === ts.SyntaxKind.Identifier) { - this.markAssignment(name as ts.Identifier); - } - else { - this.visitBindingPatternIdentifiers(name as ts.BindingPattern); - } - } - } - - visitPrefixUnaryExpression(node: ts.PrefixUnaryExpression) { - this.visitAnyUnaryExpression(node); - super.visitPrefixUnaryExpression(node); - } - - visitPostfixUnaryExpression(node: ts.PostfixUnaryExpression) { - this.visitAnyUnaryExpression(node); - super.visitPostfixUnaryExpression(node); - } - - private visitAnyUnaryExpression(node: ts.PrefixUnaryExpression | ts.PostfixUnaryExpression) { - if (node.operator === ts.SyntaxKind.PlusPlusToken || node.operator === ts.SyntaxKind.MinusMinusToken) { - this.visitLeftHandSideExpression(node.operand); - } - } - - visitModuleDeclaration(node: ts.ModuleDeclaration) { - if (node.body.kind === ts.SyntaxKind.ModuleBlock) { - // For some reason module blocks are left out of the visit block traversal - this.visitBlock(node.body as any as ts.Block); - } - super.visitModuleDeclaration(node); - } - - visitForOfStatement(node: ts.ForOfStatement) { - this.visitAnyForStatement(node); - super.visitForOfStatement(node); - this.popDeclarations(); - } - - visitForInStatement(node: ts.ForInStatement) { - this.visitAnyForStatement(node); - super.visitForInStatement(node); - this.popDeclarations(); - } - - private visitAnyForStatement(node: ts.ForOfStatement | ts.ForInStatement) { - const names: ts.MapLike = {}; - if (isLet(node.initializer)) { - if (node.initializer.kind === ts.SyntaxKind.VariableDeclarationList) { - this.collectLetIdentifiers(node.initializer as ts.VariableDeclarationList, names); - } - } - this.inScopeLetDeclarations.push(names); - } - - private popDeclarations() { - const completed = this.inScopeLetDeclarations.pop(); - for (const name in completed) { - if (Object.hasOwnProperty.call(completed, name)) { - const element = completed[name]; - if (element.usages === 0) { - this.errors.push(this.createFailure(element.declaration.getStart(this.getSourceFile()), element.declaration.getWidth(this.getSourceFile()), Rule.FAILURE_STRING_FACTORY(name))); - } - } - } - } - - visitBlock(node: ts.Block) { - const names: ts.MapLike = {}; - for (const statement of node.statements) { - if (statement.kind === ts.SyntaxKind.VariableStatement) { - this.collectLetIdentifiers((statement as ts.VariableStatement).declarationList, names); - } - } - this.inScopeLetDeclarations.push(names); - super.visitBlock(node); - this.popDeclarations(); - } - - private collectLetIdentifiers(list: ts.VariableDeclarationList, ret: ts.MapLike) { - for (const node of list.declarations) { - if (isLet(node) && !isExported(node)) { - this.collectNameIdentifiers(node, node.name, ret); - } - } - } - - private collectNameIdentifiers(declaration: ts.VariableDeclaration, node: ts.Identifier | ts.BindingPattern, table: ts.MapLike) { - if (node.kind === ts.SyntaxKind.Identifier) { - table[(node as ts.Identifier).text] = { declaration, usages: 0 }; - } - else { - this.collectBindingPatternIdentifiers(declaration, node as ts.BindingPattern, table); - } - } - - private collectBindingPatternIdentifiers(value: ts.VariableDeclaration, pattern: ts.BindingPattern, table: ts.MapLike) { - for (const element of pattern.elements) { - if (element.kind === ts.SyntaxKind.BindingElement) { - this.collectNameIdentifiers(value, (element).name, table); - } - } - } -} diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a6f5993f6c8..712c96a49f9 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -283,8 +283,8 @@ namespace ts { // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. Debug.assert(node.parent.kind === SyntaxKind.JSDocFunctionType); - let functionType = node.parent; - let index = indexOf(functionType.parameters, node); + const functionType = node.parent; + const index = indexOf(functionType.parameters, node); return "arg" + index; case SyntaxKind.JSDocTypedefTag: const parentNode = node.parent && node.parent.parent; @@ -349,17 +349,20 @@ namespace ts { // Otherwise, we'll be merging into a compatible existing symbol (for example when // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. - symbol = symbolTable[name] || (symbolTable[name] = createSymbol(SymbolFlags.None, name)); + symbol = symbolTable.get(name); + if (!symbol) { + symbolTable.set(name, symbol = createSymbol(SymbolFlags.None, name)); + } if (name && (includes & SymbolFlags.Classifiable)) { - classifiableNames[name] = name; + classifiableNames.set(name, name); } if (symbol.flags & excludes) { if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbol = symbolTable[name] = createSymbol(SymbolFlags.None, name); + symbolTable.set(name, symbol = createSymbol(SymbolFlags.None, name)); } else { if (node.name) { @@ -1570,7 +1573,7 @@ namespace ts { const typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral); typeLiteralSymbol.members = createMap(); - typeLiteralSymbol.members[symbol.name] = symbol; + typeLiteralSymbol.members.set(symbol.name, symbol); } function bindObjectLiteralExpression(node: ObjectLiteralExpression) { @@ -1601,9 +1604,9 @@ namespace ts { ? ElementKind.Property : ElementKind.Accessor; - const existingKind = seen[identifier.text]; + const existingKind = seen.get(identifier.text); if (!existingKind) { - seen[identifier.text] = currentKind; + seen.set(identifier.text, currentKind); continue; } @@ -2208,7 +2211,7 @@ namespace ts { constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - const funcSymbol = container.locals[constructorFunction.text]; + const funcSymbol = container.locals.get(constructorFunction.text); if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) { return; } @@ -2239,7 +2242,7 @@ namespace ts { bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName); // Add name of class expression into the map for semantic classifier if (node.name) { - classifiableNames[node.name.text] = node.name.text; + classifiableNames.set(node.name.text, node.name.text); } } @@ -2255,14 +2258,14 @@ namespace ts { // module might have an exported variable called 'prototype'. We can't allow that as // that would clash with the built-in 'prototype' for the class. const prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype"); - if (symbol.exports[prototypeSymbol.name]) { + const symbolExport = symbol.exports.get(prototypeSymbol.name); + if (symbolExport) { if (node.name) { node.name.parent = node; } - file.bindDiagnostics.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], - Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); + file.bindDiagnostics.push(createDiagnosticForNode(symbolExport.declarations[0], Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; + symbol.exports.set(prototypeSymbol.name, prototypeSymbol); prototypeSymbol.parent = symbol; } @@ -3133,6 +3136,7 @@ namespace ts { case SyntaxKind.TaggedTemplateExpression: case SyntaxKind.ShorthandPropertyAssignment: case SyntaxKind.StaticKeyword: + case SyntaxKind.MetaProperty: // These nodes are ES6 syntax. transformFlags |= TransformFlags.AssertES2015; break; @@ -3145,6 +3149,7 @@ namespace ts { case SyntaxKind.AnyKeyword: case SyntaxKind.NumberKeyword: case SyntaxKind.NeverKeyword: + case SyntaxKind.ObjectKeyword: case SyntaxKind.StringKeyword: case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: @@ -3343,6 +3348,7 @@ namespace ts { case SyntaxKind.NumberKeyword: case SyntaxKind.NeverKeyword: case SyntaxKind.StringKeyword: + case SyntaxKind.ObjectKeyword: case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: case SyntaxKind.VoidKeyword: diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a2c92ca560f..c510478512a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1,4 +1,4 @@ -/// +/// /// /* @internal */ @@ -85,9 +85,12 @@ namespace ts { getDeclaredTypeOfSymbol, getPropertiesOfType, getPropertyOfType, + getIndexInfoOfType, getSignaturesOfType, getIndexTypeOfType, getBaseTypes, + getTypeFromTypeNode, + getParameterType: getTypeAtPosition, getReturnTypeOfSignature, getNonNullableType, getSymbolsInScope, @@ -96,6 +99,7 @@ namespace ts { getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, getPropertySymbolOfDestructuringAssignment, + signatureToString, typeToString, getSymbolDisplayBuilder, symbolToString, @@ -111,6 +115,7 @@ namespace ts { getAliasedSymbol: resolveAlias, getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, + getExportsAndPropertiesOfModule, getAmbientModules, getJsxElementAttributesType, getJsxIntrinsicTagNames, @@ -120,7 +125,8 @@ namespace ts { // we deliberately exclude augmentations // since we are only interested in declarations of the module itself return tryFindAmbientModule(moduleName, /*withAugmentations*/ false); - } + }, + getApparentType }; const tupleTypes: GenericType[] = []; @@ -150,6 +156,7 @@ namespace ts { const voidType = createIntrinsicType(TypeFlags.Void, "void"); const neverType = createIntrinsicType(TypeFlags.Never, "never"); const silentNeverType = createIntrinsicType(TypeFlags.Never, "never"); + const nonPrimitiveType = createIntrinsicType(TypeFlags.NonPrimitive, "object"); const emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -166,6 +173,7 @@ namespace ts { anyFunctionType.flags |= TypeFlags.ContainsAnyFunctionType; const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + const circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); const anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); const unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); @@ -247,6 +255,7 @@ namespace ts { const visitedFlowNodes: FlowNode[] = []; const visitedFlowTypes: FlowType[] = []; const potentialThisCollisions: Node[] = []; + const potentialNewTargetCollisions: Node[] = []; const awaitedTypeStack: number[] = []; const diagnostics = createDiagnosticCollection(); @@ -314,7 +323,7 @@ namespace ts { NullFacts = TypeofEQObject | TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNESymbol | TypeofNEFunction | TypeofNEHostObject | EQNull | EQUndefinedOrNull | NEUndefined | Falsy, } - const typeofEQFacts = createMap({ + const typeofEQFacts = createMapFromTemplate({ "string": TypeFacts.TypeofEQString, "number": TypeFacts.TypeofEQNumber, "boolean": TypeFacts.TypeofEQBoolean, @@ -324,7 +333,7 @@ namespace ts { "function": TypeFacts.TypeofEQFunction }); - const typeofNEFacts = createMap({ + const typeofNEFacts = createMapFromTemplate({ "string": TypeFacts.TypeofNEString, "number": TypeFacts.TypeofNENumber, "boolean": TypeFacts.TypeofNEBoolean, @@ -334,7 +343,7 @@ namespace ts { "function": TypeFacts.TypeofNEFunction }); - const typeofTypesByName = createMap({ + const typeofTypesByName = createMapFromTemplate({ "string": stringType, "number": numberType, "boolean": booleanType, @@ -377,7 +386,7 @@ namespace ts { } const builtinGlobals = createMap(); - builtinGlobals[undefinedSymbol.name] = undefinedSymbol; + builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); initializeTypeChecker(); @@ -496,18 +505,19 @@ namespace ts { } function mergeSymbolTable(target: SymbolTable, source: SymbolTable) { - for (const id in source) { - let targetSymbol = target[id]; + source.forEach((sourceSymbol, id) => { + let targetSymbol = target.get(id); if (!targetSymbol) { - target[id] = source[id]; + target.set(id, sourceSymbol); } else { if (!(targetSymbol.flags & SymbolFlags.Merged)) { - target[id] = targetSymbol = cloneSymbol(targetSymbol); + targetSymbol = cloneSymbol(targetSymbol); + target.set(id, targetSymbol); } - mergeSymbol(targetSymbol, source[id]); + mergeSymbol(targetSymbol, sourceSymbol); } - } + }); } function mergeModuleAugmentation(moduleName: LiteralExpression): void { @@ -548,15 +558,16 @@ namespace ts { } function addToSymbolTable(target: SymbolTable, source: SymbolTable, message: DiagnosticMessage) { - for (const id in source) { - if (target[id]) { + source.forEach((sourceSymbol, id) => { + const targetSymbol = target.get(id); + if (targetSymbol) { // Error on redeclarations - forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); + forEach(targetSymbol.declarations, addDeclarationDiagnostic(id, message)); } else { - target[id] = source[id]; + target.set(id, sourceSymbol); } - } + }); function addDeclarationDiagnostic(id: string, message: DiagnosticMessage) { return (declaration: Declaration) => diagnostics.add(createDiagnosticForNode(declaration, message, id)); @@ -584,7 +595,7 @@ namespace ts { function getSymbol(symbols: SymbolTable, name: string, meaning: SymbolFlags): Symbol { if (meaning) { - const symbol = symbols[name]; + const symbol = symbols.get(name); if (symbol) { Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { @@ -642,11 +653,24 @@ namespace ts { if (declaration.pos <= usage.pos) { // declaration is before usage - // still might be illegal if usage is in the initializer of the variable declaration - return declaration.kind !== SyntaxKind.VariableDeclaration || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + if (declaration.kind === SyntaxKind.BindingElement) { + // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) + const errorBindingElement = getAncestor(usage, SyntaxKind.BindingElement) as BindingElement; + if (errorBindingElement) { + return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + declaration.pos < errorBindingElement.pos; + } + // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) + return isBlockScopedNameDeclaredBeforeUse(getAncestor(declaration, SyntaxKind.VariableDeclaration) as Declaration, usage); + } + else if (declaration.kind === SyntaxKind.VariableDeclaration) { + // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) + return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration as VariableDeclaration, usage); + } + return true; } + // declaration is after usage // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) const container = getEnclosingBlockScopeContainer(declaration); @@ -703,6 +727,16 @@ namespace ts { } return false; } + + function getAncestorBindingPattern(node: Node): BindingPattern { + while (node) { + if (isBindingPattern(node)) { + return node; + } + node = node.parent; + } + return undefined; + } } // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and @@ -769,7 +803,7 @@ namespace ts { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. - if (result = moduleExports["default"]) { + if (result = moduleExports.get("default")) { const localSymbol = getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; @@ -788,9 +822,10 @@ namespace ts { // 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 (moduleExports[name] && - moduleExports[name].flags === SymbolFlags.Alias && - getDeclarationOfKind(moduleExports[name], SyntaxKind.ExportSpecifier)) { + const moduleExport = moduleExports.get(name); + if (moduleExport && + moduleExport.flags === SymbolFlags.Alias && + getDeclarationOfKind(moduleExport, SyntaxKind.ExportSpecifier)) { break; } } @@ -1069,7 +1104,7 @@ namespace ts { Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(getAncestor(declaration, SyntaxKind.VariableDeclaration), errorLocation)) { + if (!isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name)); } } @@ -1118,11 +1153,16 @@ namespace ts { const moduleSymbol = resolveExternalModuleName(node, (node.parent).moduleSpecifier); if (moduleSymbol) { - const exportDefaultSymbol = isShorthandAmbientModuleSymbol(moduleSymbol) ? - moduleSymbol : - moduleSymbol.exports["export="] ? - getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") : - resolveSymbol(moduleSymbol.exports["default"]); + let exportDefaultSymbol: Symbol; + if (isShorthandAmbientModuleSymbol(moduleSymbol)) { + exportDefaultSymbol = moduleSymbol; + } + else { + const exportValue = moduleSymbol.exports.get("export="); + exportDefaultSymbol = exportValue + ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") + : resolveSymbol(moduleSymbol.exports.get("default")); + } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); @@ -1172,7 +1212,7 @@ namespace ts { function getExportOfModule(symbol: Symbol, name: string): Symbol { if (symbol.flags & SymbolFlags.Module) { - const exportedSymbol = getExportsOfSymbol(symbol)[name]; + const exportedSymbol = getExportsOfSymbol(symbol).get(name); if (exportedSymbol) { return resolveSymbol(exportedSymbol); } @@ -1200,7 +1240,7 @@ namespace ts { let symbolFromVariable: Symbol; // First check if module was specified with "export=". If so, get the member from the resolved type - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) { symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.text); } else { @@ -1350,7 +1390,9 @@ namespace ts { return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); } - // Resolves a qualified name and any involved aliases + /** + * Resolves a qualified name and any involved aliases. + */ function resolveEntityName(name: EntityNameOrEntityNameExpression, meaning: SymbolFlags, ignoreErrors?: boolean, dontResolveAlias?: boolean, location?: Node): Symbol | undefined { if (nodeIsMissing(name)) { return undefined; @@ -1478,7 +1520,7 @@ namespace ts { // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, // and an external module with no 'export =' declaration resolves to the module itself. function resolveExternalModuleSymbol(moduleSymbol: Symbol): Symbol { - return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="))) || moduleSymbol; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' @@ -1494,17 +1536,26 @@ namespace ts { } function hasExportAssignmentSymbol(moduleSymbol: Symbol): boolean { - return moduleSymbol.exports["export="] !== undefined; + return moduleSymbol.exports.get("export=") !== undefined; } function getExportsOfModuleAsArray(moduleSymbol: Symbol): Symbol[] { return symbolsToArray(getExportsOfModule(moduleSymbol)); } + function getExportsAndPropertiesOfModule(moduleSymbol: Symbol): Symbol[] { + const exports = getExportsOfModuleAsArray(moduleSymbol); + const exportEquals = resolveExternalModuleSymbol(moduleSymbol); + if (exportEquals !== moduleSymbol) { + addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + } + return exports; + } + function tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined { const symbolTable = getExportsOfModule(moduleSymbol); if (symbolTable) { - return symbolTable[memberName]; + return symbolTable.get(memberName); } } @@ -1527,24 +1578,28 @@ namespace ts { * Not passing `lookupTable` and `exportNode` disables this collection, and just extends the tables */ function extendExportSymbols(target: SymbolTable, source: SymbolTable, lookupTable?: Map, exportNode?: ExportDeclaration) { - for (const id in source) { - if (id !== "default" && !target[id]) { - target[id] = source[id]; + source && source.forEach((sourceSymbol, id) => { + if (id === "default") return; + + const targetSymbol = target.get(id); + if (!targetSymbol) { + target.set(id, sourceSymbol); if (lookupTable && exportNode) { - lookupTable[id] = { + lookupTable.set(id, { specifierText: getTextOfNode(exportNode.moduleSpecifier) - } as ExportCollisionTracker; + } as ExportCollisionTracker); } } - else if (lookupTable && exportNode && id !== "default" && target[id] && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { - if (!lookupTable[id].exportsWithDuplicate) { - lookupTable[id].exportsWithDuplicate = [exportNode]; + else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) { + const collisionTracker = lookupTable.get(id); + if (!collisionTracker.exportsWithDuplicate) { + collisionTracker.exportsWithDuplicate = [exportNode]; } else { - lookupTable[id].exportsWithDuplicate.push(exportNode); + collisionTracker.exportsWithDuplicate.push(exportNode); } } - } + }); } function getExportsForModule(moduleSymbol: Symbol): SymbolTable { @@ -1564,7 +1619,7 @@ namespace ts { visitedSymbols.push(symbol); const symbols = cloneMap(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - const exportStars = symbol.exports["__export"]; + const exportStars = symbol.exports.get("__export"); if (exportStars) { const nestedSymbols = createMap(); const lookupTable = createMap(); @@ -1578,21 +1633,20 @@ namespace ts { node as ExportDeclaration ); } - for (const id in lookupTable) { - const { exportsWithDuplicate } = lookupTable[id]; + lookupTable.forEach(({ exportsWithDuplicate }, id) => { // It's not an error if the file with multiple `export *`s with duplicate names exports a member with that name itself - if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols[id]) { - continue; + if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) { + return; } for (const node of exportsWithDuplicate) { diagnostics.add(createDiagnosticForNode( node, Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, - lookupTable[id].specifierText, + lookupTable.get(id).specifierText, id )); } - } + }); extendExportSymbols(symbols, nestedSymbols); } return symbols; @@ -1687,15 +1741,14 @@ namespace ts { function getNamedMembers(members: SymbolTable): Symbol[] { let result: Symbol[]; - for (const id in members) { + members.forEach((symbol, id) => { if (!isReservedMemberName(id)) { if (!result) result = []; - const symbol = members[id]; if (symbolIsValue(symbol)) { result.push(symbol); } } - } + }); return result || emptyArray; } @@ -1781,12 +1834,12 @@ namespace ts { function trySymbolTable(symbols: SymbolTable) { // If symbol is directly available by its name in the symbol table - if (isAccessible(symbols[symbol.name])) { + if (isAccessible(symbols.get(symbol.name))) { return [symbol]; } // Check if symbol is any of the alias - return forEachProperty(symbols, symbolFromSymbolTable => { + return forEachEntry(symbols, symbolFromSymbolTable => { if (symbolFromSymbolTable.flags & SymbolFlags.Alias && symbolFromSymbolTable.name !== "export=" && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) { @@ -1822,7 +1875,7 @@ namespace ts { let qualify = false; forEachSymbolTableInScope(enclosingDeclaration, symbolTable => { // If symbol of this name is not available in the symbol table we are ok - let symbolFromSymbolTable = symbolTable[symbol.name]; + let symbolFromSymbolTable = symbolTable.get(symbol.name); if (!symbolFromSymbolTable) { // Continue to the next symbol table return false; @@ -2091,7 +2144,7 @@ namespace ts { return result || types; } - function visibilityToString(flags: ModifierFlags) { + function visibilityToString(flags: ModifierFlags): string | undefined { if (flags === ModifierFlags.Private) { return "private"; } @@ -2469,26 +2522,6 @@ namespace ts { buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Value, SymbolFormatFlags.None, typeFormatFlags); } - function writeIndexSignature(info: IndexInfo, keyword: SyntaxKind) { - if (info) { - if (info.isReadonly) { - writeKeyword(writer, SyntaxKind.ReadonlyKeyword); - writeSpace(writer); - } - writePunctuation(writer, SyntaxKind.OpenBracketToken); - writer.writeParameter(info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, SyntaxKind.ColonToken); - writeSpace(writer); - writeKeyword(writer, keyword); - writePunctuation(writer, SyntaxKind.CloseBracketToken); - writePunctuation(writer, SyntaxKind.ColonToken); - writeSpace(writer); - writeType(info.type, TypeFormatFlags.None); - writePunctuation(writer, SyntaxKind.SemicolonToken); - writer.writeLine(); - } - } - function writePropertyWithModifiers(prop: Symbol) { if (isReadonlySymbol(prop)) { writeKeyword(writer, SyntaxKind.ReadonlyKeyword); @@ -2576,8 +2609,8 @@ namespace ts { writePunctuation(writer, SyntaxKind.SemicolonToken); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, SyntaxKind.StringKeyword); - writeIndexSignature(resolved.numberIndexInfo, SyntaxKind.NumberKeyword); + buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, IndexKind.String, enclosingDeclaration, globalFlags, symbolStack); + buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, IndexKind.Number, enclosingDeclaration, globalFlags, symbolStack); for (const p of resolved.properties) { const t = getTypeOfSymbol(p); if (p.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(t).length) { @@ -2768,6 +2801,11 @@ namespace ts { } function buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { + const returnType = getReturnTypeOfSignature(signature); + if (flags & TypeFormatFlags.SuppressAnyReturnType && isTypeAny(returnType)) { + return; + } + if (flags & TypeFormatFlags.WriteArrowStyleSignature) { writeSpace(writer); writePunctuation(writer, SyntaxKind.EqualsGreaterThanToken); @@ -2781,7 +2819,6 @@ namespace ts { buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); } else { - const returnType = getReturnTypeOfSignature(signature); buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } } @@ -2806,6 +2843,34 @@ namespace ts { buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } + function buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, SyntaxKind.ReadonlyKeyword); + writeSpace(writer); + } + writePunctuation(writer, SyntaxKind.OpenBracketToken); + writer.writeParameter(info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, SyntaxKind.ColonToken); + writeSpace(writer); + switch (kind) { + case IndexKind.Number: + writeKeyword(writer, SyntaxKind.NumberKeyword); + break; + case IndexKind.String: + writeKeyword(writer, SyntaxKind.StringKeyword); + break; + } + + writePunctuation(writer, SyntaxKind.CloseBracketToken); + writePunctuation(writer, SyntaxKind.ColonToken); + writeSpace(writer); + buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); + writePunctuation(writer, SyntaxKind.SemicolonToken); + writer.writeLine(); + } + } + return _displayBuilder || (_displayBuilder = { buildSymbolDisplay, buildTypeDisplay, @@ -2816,6 +2881,7 @@ namespace ts { buildDisplayForTypeParametersAndDelimiters, buildTypeParameterDisplayFromSymbol, buildSignatureDisplay, + buildIndexSignatureDisplay, buildReturnTypeDisplay }); } @@ -3057,10 +3123,6 @@ namespace ts { return type && (type.flags & TypeFlags.Any) !== 0; } - function isTypeNever(type: Type) { - return type && (type.flags & TypeFlags.Never) !== 0; - } - // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node: VariableLikeDeclaration) { @@ -3085,15 +3147,14 @@ namespace ts { const members = createMap(); const names = createMap(); for (const name of properties) { - names[getTextOfPropertyName(name)] = true; + names.set(getTextOfPropertyName(name), true); } for (const prop of getPropertiesOfType(source)) { - const inNamesToRemove = prop.name in names; + const inNamesToRemove = names.has(prop.name); const isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (ModifierFlags.Private | ModifierFlags.Protected); - const isMethod = prop.flags & SymbolFlags.Method; const isSetOnlyAccessor = prop.flags & SymbolFlags.SetAccessor && !(prop.flags & SymbolFlags.GetAccessor); - if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { - members[prop.name] = prop; + if (!inNamesToRemove && !isPrivate && !isClassMethod(prop) && !isSetOnlyAccessor) { + members.set(prop.name, prop); } } const stringIndexInfo = getIndexInfoOfType(source, IndexKind.String); @@ -3355,7 +3416,7 @@ namespace ts { const symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; - members[symbol.name] = symbol; + members.set(symbol.name, symbol); }); const result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { @@ -3771,11 +3832,13 @@ namespace ts { 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. + /** + * 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): Type { if (!type.resolvedBaseConstructorType) { const baseTypeNode = getBaseTypeNodeOfClass(type); @@ -3965,7 +4028,7 @@ namespace ts { type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; (type).instantiations = createMap(); - (type).instantiations[getTypeListId(type.typeParameters)] = type; + (type).instantiations.set(getTypeListId(type.typeParameters), type); (type).target = type; (type).typeArguments = type.typeParameters; type.thisType = createType(TypeFlags.TypeParameter); @@ -4008,7 +4071,7 @@ namespace ts { // an instantiation of the type alias with the type parameters supplied as type arguments. links.typeParameters = typeParameters; links.instantiations = createMap(); - links.instantiations[getTypeListId(typeParameters)] = type; + links.instantiations.set(getTypeListId(typeParameters), type); } } else { @@ -4028,7 +4091,7 @@ namespace ts { return expr.kind === SyntaxKind.NumericLiteral || expr.kind === SyntaxKind.PrefixUnaryExpression && (expr).operator === SyntaxKind.MinusToken && (expr).operand.kind === SyntaxKind.NumericLiteral || - expr.kind === SyntaxKind.Identifier && !!symbol.exports[(expr).text]; + expr.kind === SyntaxKind.Identifier && !!symbol.exports.get((expr).text); } function enumHasLiteralMembers(symbol: Symbol) { @@ -4059,7 +4122,7 @@ namespace ts { enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { const memberTypeList: Type[] = []; - const memberTypes = createMap(); + const memberTypes: EnumLiteralType[] = []; for (const declaration of enumType.symbol.declarations) { if (declaration.kind === SyntaxKind.EnumDeclaration) { computeEnumMemberValues(declaration); @@ -4077,7 +4140,7 @@ namespace ts { if (memberTypeList.length > 1) { enumType.flags |= TypeFlags.Union; (enumType).types = memberTypeList; - unionTypes[getTypeListId(memberTypeList)] = enumType; + unionTypes.set(getTypeListId(memberTypeList), enumType); } } } @@ -4100,9 +4163,6 @@ namespace ts { if (!links.declaredType) { const type = createType(TypeFlags.TypeParameter); type.symbol = symbol; - if (!(getDeclarationOfKind(symbol, SyntaxKind.TypeParameter)).constraint) { - type.constraint = noConstraintType; - } links.declaredType = type; } return links.declaredType; @@ -4161,6 +4221,7 @@ namespace ts { case SyntaxKind.NumberKeyword: case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: + case SyntaxKind.ObjectKeyword: case SyntaxKind.VoidKeyword: case SyntaxKind.UndefinedKeyword: case SyntaxKind.NullKeyword: @@ -4221,7 +4282,7 @@ namespace ts { function createSymbolTable(symbols: Symbol[]): SymbolTable { const result = createMap(); for (const symbol of symbols) { - result[symbol.name] = symbol; + result.set(symbol.name, symbol); } return result; } @@ -4231,15 +4292,15 @@ namespace ts { function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper, mappingThisOnly: boolean): SymbolTable { const result = createMap(); for (const symbol of symbols) { - result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); + result.set(symbol.name, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } function addInheritedMembers(symbols: SymbolTable, baseSymbols: Symbol[]) { for (const s of baseSymbols) { - if (!symbols[s.name]) { - symbols[s.name] = s; + if (!symbols.has(s.name)) { + symbols.set(s.name, s); } } } @@ -4248,15 +4309,15 @@ namespace ts { if (!(type).declaredProperties) { const symbol = type.symbol; (type).declaredProperties = getNamedMembers(symbol.members); - (type).declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - (type).declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); + (type).declaredCallSignatures = getSignaturesOfSymbol(symbol.members.get("__call")); + (type).declaredConstructSignatures = getSignaturesOfSymbol(symbol.members.get("__new")); (type).declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.String); (type).declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.Number); } return type; } - function getTypeWithThisArgument(type: Type, thisArgument?: Type) { + function getTypeWithThisArgument(type: Type, thisArgument?: Type): Type { if (getObjectFlags(type) & ObjectFlags.Reference) { return createTypeReference((type).target, concatenate((type).typeArguments, [thisArgument || (type).target.thisType])); @@ -4482,6 +4543,9 @@ namespace ts { setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } + /** + * Converts an AnonymousType to a ResolvedType. + */ function resolveAnonymousTypeMembers(type: AnonymousType) { const symbol = type.symbol; if (type.target) { @@ -4494,8 +4558,8 @@ namespace ts { } else if (symbol.flags & SymbolFlags.TypeLiteral) { const members = symbol.members; - const callSignatures = getSignaturesOfSymbol(members["__call"]); - const constructSignatures = getSignaturesOfSymbol(members["__new"]); + const callSignatures = getSignaturesOfSymbol(members.get("__call")); + const constructSignatures = getSignaturesOfSymbol(members.get("__new")); const stringIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.String); const numberIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.Number); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -4509,7 +4573,7 @@ namespace ts { } if (symbol.flags & SymbolFlags.Class) { const classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); + constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } @@ -4566,7 +4630,7 @@ namespace ts { // Create a mapper from T to the current iteration type constituent. Then, if the // mapped type is itself an instantiated type, combine the iteration mapper with the // instantiation mapper. - const iterationMapper = createUnaryTypeMapper(typeParameter, t); + const iterationMapper = createTypeMapper([typeParameter], [t]); const templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; const propType = instantiateType(templateType, templateMapper); // If the current iteration type constituent is a string literal type, create a property. @@ -4578,7 +4642,7 @@ namespace ts { const prop = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | (isOptional ? SymbolFlags.Optional : 0), propName); prop.type = propType; prop.isReadonly = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp); - members[propName] = prop; + members.set(propName, prop); } else if (t.flags & TypeFlags.String) { stringIndexInfo = createIndexInfo(propType, templateReadonly); @@ -4625,10 +4689,6 @@ namespace ts { return type.modifiersType; } - function getErasedTemplateTypeFromMappedType(type: MappedType) { - return instantiateType(getTemplateTypeFromMappedType(type), createUnaryTypeMapper(getTypeParameterFromMappedType(type), anyType)); - } - function isGenericMappedType(type: Type) { if (getObjectFlags(type) & ObjectFlags.Mapped) { const constraintType = getConstraintTypeFromMappedType(type); @@ -4676,7 +4736,7 @@ namespace ts { function getPropertyOfObjectType(type: Type, name: string): Symbol { if (type.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(type); - const symbol = resolved.members[name]; + const symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } @@ -4697,13 +4757,12 @@ namespace ts { const props = type.resolvedProperties; if (props) { const result: Symbol[] = []; - for (const key in props) { - const prop = props[key]; + props.forEach(prop => { // We need to filter out partial properties in union types if (!(prop.flags & SymbolFlags.SyntheticProperty && (prop).isPartial)) { result.push(prop); } - } + }); return result; } return emptyArray; @@ -4716,19 +4775,79 @@ namespace ts { getPropertiesOfObjectType(type); } + function getConstraintOfType(type: TypeVariable | UnionOrIntersectionType): Type { + return type.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + } + + function getConstraintOfTypeParameter(typeParameter: TypeParameter): Type { + return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; + } + + function getBaseConstraintOfType(type: TypeVariable | UnionOrIntersectionType): Type { + const constraint = getResolvedBaseConstraint(type); + return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + } + + function hasNonCircularBaseConstraint(type: TypeVariable): boolean { + return getResolvedBaseConstraint(type) !== circularConstraintType; + } + /** - * The apparent type of a type parameter is the base constraint instantiated with the type parameter - * as the type argument for the 'this' type. + * Return the resolved base constraint of a type variable. The noConstraintType singleton is returned if the + * type variable has no constraint, and the circularConstraintType singleton is returned if the constraint + * circularly references the type variable. */ - function getApparentTypeOfTypeVariable(type: TypeVariable) { - if (!type.resolvedApparentType) { - let constraintType = getConstraintOfTypeVariable(type); - while (constraintType && constraintType.flags & TypeFlags.TypeParameter) { - constraintType = getConstraintOfTypeVariable(constraintType); - } - type.resolvedApparentType = getTypeWithThisArgument(constraintType || emptyObjectType, type); + function getResolvedBaseConstraint(type: TypeVariable | UnionOrIntersectionType): Type { + let typeStack: Type[]; + let circular: boolean; + if (!type.resolvedBaseConstraint) { + typeStack = []; + const constraint = getBaseConstraint(type); + type.resolvedBaseConstraint = circular ? circularConstraintType : getTypeWithThisArgument(constraint || noConstraintType, type); + } + return type.resolvedBaseConstraint; + + function getBaseConstraint(t: Type): Type { + if (contains(typeStack, t)) { + circular = true; + return undefined; + } + typeStack.push(t); + const result = computeBaseConstraint(t); + typeStack.pop(); + return result; + } + + function computeBaseConstraint(t: Type): Type { + if (t.flags & TypeFlags.TypeParameter) { + const constraint = getConstraintFromTypeParameter(t); + return (t).isThisType ? constraint : + constraint ? getBaseConstraint(constraint) : undefined; + } + if (t.flags & TypeFlags.UnionOrIntersection) { + const types = (t).types; + const baseTypes: Type[] = []; + for (const type of types) { + const baseType = getBaseConstraint(type); + if (baseType) { + baseTypes.push(baseType); + } + } + return t.flags & TypeFlags.Union && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & TypeFlags.Intersection && baseTypes.length ? getIntersectionType(baseTypes) : + undefined; + } + if (t.flags & TypeFlags.Index) { + return stringType; + } + if (t.flags & TypeFlags.IndexedAccess) { + const baseObjectType = getBaseConstraint((t).objectType); + const baseIndexType = getBaseConstraint((t).indexType); + const baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; + return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + } + return t; } - return type.resolvedApparentType; } /** @@ -4737,11 +4856,12 @@ namespace ts { * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type: Type): Type { - const t = type.flags & TypeFlags.TypeVariable ? getApparentTypeOfTypeVariable(type) : type; + const t = type.flags & TypeFlags.TypeVariable ? getBaseConstraintOfType(type) || emptyObjectType : type; return t.flags & TypeFlags.StringLike ? globalStringType : t.flags & TypeFlags.NumberLike ? globalNumberType : t.flags & TypeFlags.BooleanLike ? globalBooleanType : t.flags & TypeFlags.ESSymbol ? getGlobalESSymbolType() : + t.flags & TypeFlags.NonPrimitive ? globalObjectType : t; } @@ -4814,11 +4934,11 @@ namespace ts { // and do not appear to be present in the union type. function getUnionOrIntersectionProperty(type: UnionOrIntersectionType, name: string): Symbol { const properties = type.resolvedProperties || (type.resolvedProperties = createMap()); - let property = properties[name]; + let property = properties.get(name); if (!property) { property = createUnionOrIntersectionProperty(type, name); if (property) { - properties[name] = property; + properties.set(name, property); } } return property; @@ -4842,7 +4962,7 @@ namespace ts { type = getApparentType(type); if (type.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(type); - const symbol = resolved.members[name]; + const symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } @@ -4941,11 +5061,11 @@ namespace ts { function symbolsToArray(symbols: SymbolTable): Symbol[] { const result: Symbol[] = []; - for (const id in symbols) { + symbols.forEach((symbol, id) => { if (!isReservedMemberName(id)) { - result.push(symbols[id]); + result.push(symbol); } - } + }); return result; } @@ -5017,15 +5137,16 @@ namespace ts { if (!links.resolvedSignature) { const parameters: Symbol[] = []; let hasLiteralTypes = false; - let minArgumentCount = -1; + let minArgumentCount = 0; let thisParameter: Symbol = undefined; let hasThisParameter: boolean; + const iife = getImmediatelyInvokedFunctionExpression(declaration); const isJSConstructSignature = isJSDocConstructSignature(declaration); // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct // signature. - for (let i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { + for (let i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { const param = declaration.parameters[i]; let paramSymbol = param.symbol; @@ -5046,14 +5167,12 @@ namespace ts { hasLiteralTypes = true; } - if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { - if (minArgumentCount < 0) { - minArgumentCount = i - (hasThisParameter ? 1 : 0); - } - } - else { - // If we see any required parameters, it means the prior ones were not in fact optional. - minArgumentCount = -1; + // Record a new minimum argument count if this is not an optional parameter + const isOptionalParameter = param.initializer || param.questionToken || param.dotDotDotToken || + iife && parameters.length > iife.arguments.length && !param.type || + isJSDocOptionalParameter(param); + if (!isOptionalParameter) { + minArgumentCount = parameters.length; } } @@ -5068,13 +5187,6 @@ namespace ts { } } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); - } - if (isJSConstructSignature) { - minArgumentCount--; - } - const classType = declaration.kind === SyntaxKind.Constructor ? getDeclaredTypeOfClassOrInterface(getMergedSymbol((declaration.parent).symbol)) : undefined; @@ -5124,7 +5236,7 @@ namespace ts { function getSignaturesOfSymbol(symbol: Symbol): Signature[] { if (!symbol) return emptyArray; const result: Signature[] = []; - for (let i = 0, len = symbol.declarations.length; i < len; i++) { + for (let i = 0; i < symbol.declarations.length; i++) { const node = symbol.declarations[i]; switch (node.kind) { case SyntaxKind.FunctionType: @@ -5219,7 +5331,11 @@ namespace ts { function getSignatureInstantiation(signature: Signature, typeArguments: Type[]): Signature { const instantiations = signature.instantiations || (signature.instantiations = createMap()); const id = getTypeListId(typeArguments); - return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + let instantiation = instantiations.get(id); + if (!instantiation) { + instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments)); + } + return instantiation; } function createSignatureInstantiation(signature: Signature, typeArguments: Type[]): Signature { @@ -5253,7 +5369,7 @@ namespace ts { } function getIndexSymbol(symbol: Symbol): Symbol { - return symbol.members["__index"]; + return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol: Symbol, kind: IndexKind): SignatureDeclaration { @@ -5291,20 +5407,7 @@ namespace ts { return (getDeclarationOfKind(type.symbol, SyntaxKind.TypeParameter)).constraint; } - function hasConstraintReferenceTo(type: Type, target: TypeParameter): boolean { - let checked: Type[]; - while (type && type.flags & TypeFlags.TypeParameter && !((type as TypeParameter).isThisType) && !contains(checked, type)) { - if (type === target) { - return true; - } - (checked || (checked = [])).push(type); - const constraintDeclaration = getConstraintDeclaration(type); - type = constraintDeclaration && getTypeFromTypeNode(constraintDeclaration); - } - return false; - } - - function getConstraintOfTypeParameter(typeParameter: TypeParameter): Type { + function getConstraintFromTypeParameter(typeParameter: TypeParameter): Type { if (!typeParameter.constraint) { if (typeParameter.target) { const targetConstraint = getConstraintOfTypeParameter(typeParameter.target); @@ -5312,23 +5415,12 @@ namespace ts { } else { const constraintDeclaration = getConstraintDeclaration(typeParameter); - let constraint = getTypeFromTypeNode(constraintDeclaration); - if (hasConstraintReferenceTo(constraint, typeParameter)) { - error(constraintDeclaration, Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); - constraint = unknownType; - } - typeParameter.constraint = constraint; + typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : noConstraintType; } } return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } - function getConstraintOfTypeVariable(type: TypeVariable): Type { - return type.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(type) : - type.flags & TypeFlags.IndexedAccess ? (type).constraint : - undefined; - } - function getParentSymbolOfTypeParameter(typeParameter: TypeParameter): Symbol { return getSymbolOfNode(getDeclarationOfKind(typeParameter.symbol, SyntaxKind.TypeParameter).parent); } @@ -5373,9 +5465,10 @@ namespace ts { function createTypeReference(target: GenericType, typeArguments: Type[]): TypeReference { const id = getTypeListId(typeArguments); - let type = target.instantiations[id]; + let type = target.instantiations.get(id); if (!type) { - type = target.instantiations[id] = createObjectType(ObjectFlags.Reference, target.symbol); + type = createObjectType(ObjectFlags.Reference, target.symbol); + target.instantiations.set(id, type); type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; type.typeArguments = typeArguments; @@ -5422,7 +5515,11 @@ namespace ts { const links = getSymbolLinks(symbol); const typeParameters = links.typeParameters; const id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + let instantiation = links.instantiations.get(id); + if (!instantiation) { + links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + } + return instantiation; } // Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include @@ -5663,7 +5760,7 @@ namespace ts { type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; type.instantiations = createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(TypeFlags.TypeParameter); @@ -5774,8 +5871,8 @@ namespace ts { } function isSubtypeOfAny(candidate: Type, types: Type[]): boolean { - for (let i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + for (const type of types) { + if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } } @@ -5868,10 +5965,11 @@ namespace ts { return types[0]; } const id = getTypeListId(types); - let type = unionTypes[id]; + let type = unionTypes.get(id); if (!type) { const propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ TypeFlags.Nullable); - type = unionTypes[id] = createType(TypeFlags.Union | propagatedFlags); + type = createType(TypeFlags.Union | propagatedFlags); + unionTypes.set(id, type); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -5942,10 +6040,11 @@ namespace ts { /*subtypeReduction*/ false, aliasSymbol, aliasTypeArguments); } const id = getTypeListId(typeSet); - let type = intersectionTypes[id]; + let type = intersectionTypes.get(id); if (!type) { const propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ TypeFlags.Nullable); - type = intersectionTypes[id] = createType(TypeFlags.Intersection | propagatedFlags); + type = createType(TypeFlags.Intersection | propagatedFlags); + intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -6004,24 +6103,6 @@ namespace ts { const type = createType(TypeFlags.IndexedAccess); type.objectType = objectType; type.indexType = indexType; - // We eagerly compute the constraint of the indexed access type such that circularity - // errors are immediately caught and reported. For example, class C { x: this["x"] } - // becomes an error only when the constraint is eagerly computed. - if (type.objectType.flags & TypeFlags.StructuredType) { - // The constraint of T[K], where T is an object, union, or intersection type, - // is the type of the string index signature of T, if any. - type.constraint = getIndexTypeOfType(type.objectType, IndexKind.String); - } - else if (type.objectType.flags & TypeFlags.TypeVariable) { - // The constraint of T[K], where T is a type variable, is A[K], where A is the - // apparent type of T. - const apparentType = getApparentTypeOfTypeVariable(type.objectType); - if (apparentType !== emptyObjectType) { - type.constraint = isTypeOfKind((type).indexType, TypeFlags.StringLike) ? - getIndexedAccessType(apparentType, (type).indexType) : - getIndexTypeOfType(apparentType, IndexKind.String); - } - } return type; } @@ -6055,7 +6136,7 @@ namespace ts { getIndexInfoOfType(objectType, IndexKind.String) || undefined; if (indexInfo) { - if (accessExpression && isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + if (accessExpression && indexInfo.isReadonly && (isAssignmentTarget(accessExpression) || isDeleteTarget(accessExpression))) { error(accessExpression, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return unknownType; } @@ -6094,7 +6175,7 @@ namespace ts { error(accessExpression, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; } - const mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); + const mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); const templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } @@ -6112,13 +6193,6 @@ namespace ts { if (objectType.flags & TypeFlags.Any) { return objectType; } - // We first check that the index type is assignable to 'keyof T' for the object type. - if (accessNode) { - if (!isTypeAssignableTo(indexType, getIndexType(objectType))) { - error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); - return unknownType; - } - } // If the object type is a mapped type { [P in K]: E }, we instantiate E using a mapper that substitutes // the index type for P. For example, for an index access { [P in K]: Box }[X], we construct the // type Box. @@ -6127,7 +6201,11 @@ namespace ts { } // Otherwise we defer the operation by creating an indexed access type. const id = objectType.id + "," + indexType.id; - return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType)); + let type = indexedAccessTypes.get(id); + if (!type) { + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType)); + } + return type; } // In the following we resolve T[K] to the type of the property in T selected by K. const apparentObjectType = getApparentType(objectType); @@ -6173,7 +6251,7 @@ namespace ts { if (!links.resolvedType) { // Deferred resolution of members is handled by resolveObjectTypeMembers const aliasSymbol = getAliasSymbolForTypeNode(node); - if (isEmpty(node.symbol.members) && !aliasSymbol) { + if (node.symbol.members.size === 0 && !aliasSymbol) { links.resolvedType = emptyTypeLiteralType; } else { @@ -6200,7 +6278,7 @@ namespace ts { * this function should be called in a left folding style, with left = previous result of getSpreadType * and right = the new element to be spread. */ - function getSpreadType(left: Type, right: Type, isFromObjectLiteral: boolean): Type { + function getSpreadType(left: Type, right: Type): Type { if (left.flags & TypeFlags.Any || right.flags & TypeFlags.Any) { return anyType; } @@ -6213,10 +6291,10 @@ namespace ts { return left; } if (left.flags & TypeFlags.Union) { - return mapType(left, t => getSpreadType(t, right, isFromObjectLiteral)); + return mapType(left, t => getSpreadType(t, right)); } if (right.flags & TypeFlags.Union) { - return mapType(right, t => getSpreadType(left, t, isFromObjectLiteral)); + return mapType(right, t => getSpreadType(left, t)); } const members = createMap(); @@ -6235,22 +6313,22 @@ namespace ts { for (const rightProp of getPropertiesOfType(right)) { // we approximate own properties as non-methods plus methods that are inside the object literal - const isOwnProperty = !(rightProp.flags & SymbolFlags.Method) || isFromObjectLiteral; const isSetterWithoutGetter = rightProp.flags & SymbolFlags.SetAccessor && !(rightProp.flags & SymbolFlags.GetAccessor); if (getDeclarationModifierFlagsFromSymbol(rightProp) & (ModifierFlags.Private | ModifierFlags.Protected)) { - skippedPrivateMembers[rightProp.name] = true; + skippedPrivateMembers.set(rightProp.name, true); } - else if (isOwnProperty && !isSetterWithoutGetter) { - members[rightProp.name] = rightProp; + else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { + members.set(rightProp.name, rightProp); } } for (const leftProp of getPropertiesOfType(left)) { if (leftProp.flags & SymbolFlags.SetAccessor && !(leftProp.flags & SymbolFlags.GetAccessor) - || leftProp.name in skippedPrivateMembers) { + || skippedPrivateMembers.has(leftProp.name) + || isClassMethod(leftProp)) { continue; } - if (leftProp.name in members) { - const rightProp = members[leftProp.name]; + if (members.has(leftProp.name)) { + const rightProp = members.get(leftProp.name); const rightType = getTypeOfSymbol(rightProp); if (maybeTypeOfKind(rightType, TypeFlags.Undefined) || rightProp.flags & SymbolFlags.Optional) { const declarations: Declaration[] = concatenate(leftProp.declarations, rightProp.declarations); @@ -6261,16 +6339,20 @@ namespace ts { result.rightSpread = rightProp; result.declarations = declarations; result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); - members[leftProp.name] = result; + members.set(leftProp.name, result); } } else { - members[leftProp.name] = leftProp; + members.set(leftProp.name, leftProp); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function isClassMethod(prop: Symbol) { + return prop.flags & SymbolFlags.Method && find(prop.declarations, decl => isClassLike(decl.parent)); + } + function createLiteralType(flags: TypeFlags, text: string) { const type = createType(flags); type.text = text; @@ -6295,7 +6377,11 @@ namespace ts { function getLiteralTypeForText(flags: TypeFlags, text: string) { const map = flags & TypeFlags.StringLiteral ? stringLiteralTypes : numericLiteralTypes; - return map[text] || (map[text] = createLiteralType(flags, text)); + let type = map.get(text); + if (!type) { + map.set(text, type = createLiteralType(flags, text)); + } + return type; } function getTypeFromLiteralTypeNode(node: LiteralTypeNode): Type { @@ -6367,6 +6453,8 @@ namespace ts { return nullType; case SyntaxKind.NeverKeyword: return neverType; + case SyntaxKind.ObjectKeyword: + return nonPrimitiveType; case SyntaxKind.JSDocNullKeyword: return nullType; case SyntaxKind.JSDocUndefinedKeyword: @@ -6459,16 +6547,16 @@ namespace ts { return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); } - function createUnaryTypeMapper(source: Type, target: Type): TypeMapper { - return t => t === source ? target : t; + function makeUnaryTypeMapper(source: Type, target: Type) { + return (t: Type) => t === source ? target : t; } - function createBinaryTypeMapper(source1: Type, target1: Type, source2: Type, target2: Type): TypeMapper { - return t => t === source1 ? target1 : t === source2 ? target2 : t; + function makeBinaryTypeMapper(source1: Type, target1: Type, source2: Type, target2: Type) { + return (t: Type) => t === source1 ? target1 : t === source2 ? target2 : t; } - function createArrayTypeMapper(sources: Type[], targets: Type[]): TypeMapper { - return t => { + function makeArrayTypeMapper(sources: Type[], targets: Type[]) { + return (t: Type) => { for (let i = 0; i < sources.length; i++) { if (t === sources[i]) { return targets ? targets[i] : anyType; @@ -6479,11 +6567,9 @@ namespace ts { } function createTypeMapper(sources: Type[], targets: Type[]): TypeMapper { - const count = sources.length; - const mapper: TypeMapper = - count == 1 ? createUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : - count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : - createArrayTypeMapper(sources, targets); + const mapper: TypeMapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : + makeArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; return mapper; } @@ -6517,7 +6603,13 @@ namespace ts { function combineTypeMappers(mapper1: TypeMapper, mapper2: TypeMapper): TypeMapper { const mapper: TypeMapper = t => instantiateType(mapper1(t), mapper2); - mapper.mappedTypes = mapper1.mappedTypes; + mapper.mappedTypes = concatenate(mapper1.mappedTypes, mapper2.mappedTypes); + return mapper; + } + + function createReplacementMapper(source: Type, target: Type, baseMapper: TypeMapper) { + const mapper: TypeMapper = t => t === source ? target : baseMapper(t); + mapper.mappedTypes = baseMapper.mappedTypes; return mapper; } @@ -6614,17 +6706,16 @@ namespace ts { const constraintType = getConstraintTypeFromMappedType(type); if (constraintType.flags & TypeFlags.Index) { const typeVariable = (constraintType).type; - const mappedTypeVariable = instantiateType(typeVariable, mapper); - if (typeVariable !== mappedTypeVariable) { - return mapType(mappedTypeVariable, t => { - if (isMappableType(t)) { - const replacementMapper = createUnaryTypeMapper(typeVariable, t); - const combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); - } - return t; - }); + if (typeVariable.flags & TypeFlags.TypeParameter) { + const mappedTypeVariable = instantiateType(typeVariable, mapper); + if (typeVariable !== mappedTypeVariable) { + return mapType(mappedTypeVariable, t => { + if (isMappableType(t)) { + return instantiateMappedObjectType(type, createReplacementMapper(typeVariable, t, mapper)); + } + return t; + }); + } } } return instantiateMappedObjectType(type, mapper); @@ -6880,7 +6971,7 @@ namespace ts { // subtype of T but not structurally identical to T. This specifically means that two distinct but // structurally identical types (such as two classes) are not considered instances of each other. function isTypeInstanceOf(source: Type, target: Type): boolean { - return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); } /** @@ -7088,13 +7179,15 @@ namespace ts { return true; } const id = source.id + "," + target.id; - if (enumRelation[id] !== undefined) { - return enumRelation[id]; + const relation = enumRelation.get(id); + if (relation !== undefined) { + return relation; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & SymbolFlags.RegularEnum) || !(target.symbol.flags & SymbolFlags.RegularEnum) || (source.flags & TypeFlags.Union) !== (target.flags & TypeFlags.Union)) { - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } const targetEnumType = getTypeOfSymbol(target.symbol); for (const property of getPropertiesOfType(getTypeOfSymbol(source.symbol))) { @@ -7105,11 +7198,13 @@ namespace ts { errorReporter(Diagnostics.Property_0_is_missing_in_type_1, property.name, typeToString(target, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType)); } - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } } } - return enumRelation[id] = true; + enumRelation.set(id, true); + return true; } function isSimpleTypeRelatedTo(source: Type, target: Type, relation: Map, errorReporter?: ErrorReporter) { @@ -7122,6 +7217,7 @@ namespace ts { if (source.flags & TypeFlags.Enum && target.flags & TypeFlags.Enum && isEnumTypeRelatedTo(source, target, errorReporter)) return true; if (source.flags & TypeFlags.Undefined && (!strictNullChecks || target.flags & (TypeFlags.Undefined | TypeFlags.Void))) return true; if (source.flags & TypeFlags.Null && (!strictNullChecks || target.flags & TypeFlags.Null)) return true; + if (source.flags & TypeFlags.Object && target.flags & TypeFlags.NonPrimitive) return true; if (relation === assignableRelation || relation === comparableRelation) { if (source.flags & TypeFlags.Any) return true; if ((source.flags & TypeFlags.Number | source.flags & TypeFlags.NumberLiteral) && target.flags & TypeFlags.EnumLike) return true; @@ -7152,12 +7248,12 @@ namespace ts { } if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) { const id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - const related = relation[id]; + const related = relation.get(id); if (related !== undefined) { return related === RelationComparisonResult.Succeeded; } } - if (source.flags & TypeFlags.StructuredOrTypeParameter || target.flags & TypeFlags.StructuredOrTypeParameter) { + if (source.flags & TypeFlags.StructuredOrTypeVariable || target.flags & TypeFlags.StructuredOrTypeVariable) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -7263,10 +7359,12 @@ namespace ts { return false; } - // Compare two types and return - // Ternary.True if they are related with no assumptions, - // Ternary.Maybe if they are related with assumptions of other relationships, or - // Ternary.False if they are not related. + /** + * Compare two types and return + * * Ternary.True if they are related with no assumptions, + * * Ternary.Maybe if they are related with assumptions of other relationships, or + * * Ternary.False if they are not related. + */ function isRelatedTo(source: Type, target: Type, reportErrors?: boolean, headMessage?: DiagnosticMessage): Ternary { let result: Ternary; if (source.flags & TypeFlags.StringOrNumberLiteral && source.flags & TypeFlags.FreshLiteral) { @@ -7355,16 +7453,6 @@ namespace ts { } } } - else { - // Given a type parameter K with a constraint keyof T, a type S is - // assignable to K if S is assignable to keyof T. - const constraint = getConstraintOfTypeParameter(target); - if (constraint && constraint.flags & TypeFlags.Index) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - return result; - } - } - } } else if (target.flags & TypeFlags.Index) { // A keyof S is related to a keyof T if T is related to S. @@ -7373,14 +7461,12 @@ namespace ts { return result; } } - // Given a type variable T with a constraint C, a type S is assignable to - // keyof T if S is assignable to keyof C. - if ((target).type.flags & TypeFlags.TypeVariable) { - const constraint = getConstraintOfTypeVariable((target).type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } + // A type S is assignable to keyof T if S is assignable to keyof C, where C is the + // constraint of T. + const constraint = getConstraintOfType((target).type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; } } } @@ -7394,8 +7480,9 @@ namespace ts { } // A type S is related to a type T[K] if S is related to A[K], where K is string-like and // A is the apparent type of S. - if ((target).constraint) { - if (result = isRelatedTo(source, (target).constraint, reportErrors)) { + const constraint = getBaseConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -7414,27 +7501,28 @@ namespace ts { } else { let constraint = getConstraintOfTypeParameter(source); - - if (!constraint || constraint.flags & TypeFlags.Any) { - constraint = emptyObjectType; - } - - // The constraint may need to be further instantiated with its 'this' type. - constraint = getTypeWithThisArgument(constraint, source); - - // Report constraint errors only if the constraint is not the empty object type - const reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; + // A type parameter with no constraint is not related to the non-primitive object type. + if (constraint || !(target.flags & TypeFlags.NonPrimitive)) { + if (!constraint || constraint.flags & TypeFlags.Any) { + constraint = emptyObjectType; + } + // The constraint may need to be further instantiated with its 'this' type. + constraint = getTypeWithThisArgument(constraint, source); + // Report constraint errors only if the constraint is not the empty object type + const reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } } else if (source.flags & TypeFlags.IndexedAccess) { // A type S[K] is related to a type T if A[K] is related to T, where K is string-like and // A is the apparent type of S. - if ((source).constraint) { - if (result = isRelatedTo((source).constraint, target, reportErrors)) { + const constraint = getBaseConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -7646,12 +7734,12 @@ namespace ts { return Ternary.False; } const id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - const related = relation[id]; + const related = relation.get(id); if (related !== undefined) { if (reportErrors && related === RelationComparisonResult.Failed) { // We are elaborating errors and the cached result is an unreported failure. Record the result as a reported // failure and continue computing the relation such that errors get reported. - relation[id] = RelationComparisonResult.FailedAndReported; + relation.set(id, RelationComparisonResult.FailedAndReported); } else { return related === RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False; @@ -7660,7 +7748,7 @@ namespace ts { if (depth > 0) { for (let i = 0; i < depth; i++) { // If source and target are already being compared, consider them related with assumptions - if (maybeStack[i][id]) { + if (maybeStack[i].get(id)) { return Ternary.Maybe; } } @@ -7678,7 +7766,7 @@ namespace ts { sourceStack[depth] = source; targetStack[depth] = target; maybeStack[depth] = createMap(); - maybeStack[depth][id] = RelationComparisonResult.Succeeded; + maybeStack[depth].set(id, RelationComparisonResult.Succeeded); depth++; const saveExpandingFlags = expandingFlags; if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) expandingFlags |= 1; @@ -7711,35 +7799,34 @@ namespace ts { const maybeCache = maybeStack[depth]; // If result is definitely true, copy assumptions to global cache, else copy to next level up const destinationCache = (result === Ternary.True || depth === 0) ? relation : maybeStack[depth - 1]; - copyProperties(maybeCache, destinationCache); + copyEntries(maybeCache, destinationCache); } else { // A false result goes straight into global cache (when something is false under assumptions it // will also be false without assumptions) - relation[id] = reportErrors ? RelationComparisonResult.FailedAndReported : RelationComparisonResult.Failed; + relation.set(id, reportErrors ? RelationComparisonResult.FailedAndReported : RelationComparisonResult.Failed); } return result; } - // A type [P in S]: X is related to a type [P in T]: Y if T is related to S and X is related to Y. + // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is + // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice + // that S and T are contra-variant whereas X and Y are co-variant. function mappedTypeRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { - let result: Ternary; - if (relation === identityRelation) { - const readonlyMatches = !(source).declaration.readonlyToken === !(target).declaration.readonlyToken; - const optionalMatches = !(source).declaration.questionToken === !(target).declaration.questionToken; - if (readonlyMatches && optionalMatches) { - if (result = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result & isRelatedTo(getErasedTemplateTypeFromMappedType(source), getErasedTemplateTypeFromMappedType(target), reportErrors); - } - } - } - else { - if (relation === comparableRelation || !(source).declaration.questionToken || (target).declaration.questionToken) { - if (result = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result & isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors); - } + const sourceReadonly = !!(source).declaration.readonlyToken; + const sourceOptional = !!(source).declaration.questionToken; + const targetReadonly = !!(target).declaration.readonlyToken; + const targetOptional = !!(target).declaration.questionToken; + const modifiersRelated = relation === identityRelation ? + sourceReadonly === targetReadonly && sourceOptional === targetOptional : + relation === comparableRelation || !sourceOptional || targetOptional; + if (modifiersRelated) { + let result: Ternary; + if (result = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { + const mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); + return result & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } @@ -7928,7 +8015,7 @@ namespace ts { return Ternary.False; } let result = Ternary.True; - for (let i = 0, len = sourceSignatures.length; i < len; i++) { + for (let i = 0; i < sourceSignatures.length; i++) { const related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { return Ternary.False; @@ -8388,7 +8475,7 @@ namespace ts { for (const property of getPropertiesOfObjectType(type)) { const original = getTypeOfSymbol(property); const updated = f(original); - members[property.name] = updated === original ? property : createTransientSymbol(property, updated); + members.set(property.name, updated === original ? property : createTransientSymbol(property, updated)); }; return members; } @@ -8630,7 +8717,7 @@ namespace ts { inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); - members[prop.name] = inferredProp; + members.set(prop.name, inferredProp); } if (indexInfo) { const inferredIndexType = inferTargetType(indexInfo.type); @@ -8805,10 +8892,10 @@ namespace ts { return; } const key = source.id + "," + target.id; - if (visited[key]) { + if (visited.get(key)) { return; } - visited[key] = true; + visited.set(key, true); if (depth === 0) { sourceStack = []; targetStack = []; @@ -9189,7 +9276,7 @@ namespace ts { // check. This gives us a quicker out in the common case where an object type is not a function. const resolved = resolveStructuredTypeMembers(type); return !!(resolved.callSignatures.length || resolved.constructSignatures.length || - resolved.members["bind"] && isTypeSubtypeOf(type, globalFunctionType)); + resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type: Type): TypeFacts { @@ -9233,6 +9320,9 @@ namespace ts { if (flags & TypeFlags.ESSymbol) { return strictNullChecks ? TypeFacts.SymbolStrictFacts : TypeFacts.SymbolFacts; } + if (flags & TypeFlags.NonPrimitive) { + return strictNullChecks ? TypeFacts.ObjectStrictFacts : TypeFacts.ObjectFacts; + } if (flags & TypeFlags.TypeParameter) { const constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); @@ -9809,8 +9899,9 @@ namespace ts { if (!key) { key = getFlowCacheKey(reference); } - if (cache[key]) { - return cache[key]; + const cached = cache.get(key); + if (cached) { + return cached; } // If this flow loop junction and reference are already being processed, return // the union of the types computed for each branch so far, marked as incomplete. @@ -9844,8 +9935,9 @@ namespace ts { // If we see a value appear in the cache it is a sign that control flow analysis // was restarted and completed by checkExpressionCached. We can simply pick up // the resulting type and bail out. - if (cache[key]) { - return cache[key]; + const cached = cache.get(key); + if (cached) { + return cached; } if (!contains(antecedentTypes, type)) { antecedentTypes.push(type); @@ -9869,7 +9961,8 @@ namespace ts { if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } - return cache[key] = result; + cache.set(key, result); + return result; } function isMatchingReferenceDiscriminant(expr: Expression) { @@ -9992,14 +10085,14 @@ namespace ts { // We narrow a non-union type to an exact primitive type if the non-union type // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. - const targetType = typeofTypesByName[literal.text]; + const targetType = typeofTypesByName.get(literal.text); if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; } } const facts = assumeTrue ? - typeofEQFacts[literal.text] || TypeFacts.TypeofEQHostObject : - typeofNEFacts[literal.text] || TypeFacts.TypeofNEHostObject; + typeofEQFacts.get(literal.text) || TypeFacts.TypeofEQHostObject : + typeofNEFacts.get(literal.text) || TypeFacts.TypeofNEHostObject; return getTypeWithFacts(type, facts); } @@ -10318,6 +10411,7 @@ namespace ts { checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkCollisionWithCapturedNewTargetVariable(node, node); checkNestedBlockScopedBinding(node, symbol); const type = getTypeOfSymbol(localOrExportSymbol); @@ -10359,7 +10453,7 @@ namespace ts { // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). const assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & TypeFlags.Any) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & TypeFlags.Any) !== 0 || isInTypeQuery(node)) || isInAmbientContext(declaration); const flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph @@ -10880,23 +10974,23 @@ namespace ts { const func = parameter.parent; if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { const iife = getImmediatelyInvokedFunctionExpression(func); - if (iife) { + if (iife && iife.arguments) { const indexOfParameter = indexOf(func.parameters, parameter); - if (iife.arguments && indexOfParameter < iife.arguments.length) { - if (parameter.dotDotDotToken) { - const restTypes: Type[] = []; - for (let i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return createArrayType(getUnionType(restTypes)); + if (parameter.dotDotDotToken) { + const restTypes: Type[] = []; + for (let i = indexOfParameter; i < iife.arguments.length; i++) { + restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); } - const links = getNodeLinks(iife); - const cached = links.resolvedSignature; - links.resolvedSignature = anySignature; - const type = getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])); - links.resolvedSignature = cached; - return type; + return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; } + const links = getNodeLinks(iife); + const cached = links.resolvedSignature; + links.resolvedSignature = anySignature; + const type = indexOfParameter < iife.arguments.length ? + getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + parameter.initializer ? undefined : undefinedWideningType; + links.resolvedSignature = cached; + return type; } const contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -11605,7 +11699,7 @@ namespace ts { checkExternalEmitHelpers(memberDecl, ExternalEmitHelpers.Assign); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + spread = getSpreadType(spread, createObjectLiteralType()); propertiesArray = []; propertiesTable = createMap(); hasComputedStringProperty = false; @@ -11617,7 +11711,7 @@ namespace ts { error(memberDecl, Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } - spread = getSpreadType(spread, type, /*isFromObjectLiteral*/ false); + spread = getSpreadType(spread, type); offset = i + 1; continue; } @@ -11640,7 +11734,7 @@ namespace ts { } } else { - propertiesTable[member.name] = member; + propertiesTable.set(member.name, member); } propertiesArray.push(member); } @@ -11649,12 +11743,12 @@ namespace ts { // type with those properties for which the binding pattern specifies a default value. if (contextualTypeHasPattern) { for (const prop of getPropertiesOfType(contextualType)) { - if (!propertiesTable[prop.name]) { + if (!propertiesTable.get(prop.name)) { if (!(prop.flags & SymbolFlags.Optional)) { error(prop.valueDeclaration || (prop).bindingElement, Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } - propertiesTable[prop.name] = prop; + propertiesTable.set(prop.name, prop); propertiesArray.push(prop); } } @@ -11662,7 +11756,7 @@ namespace ts { if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + spread = getSpreadType(spread, createObjectLiteralType()); } if (spread.flags & TypeFlags.Object) { // only set the symbol and flags if this is a (fresh) object type @@ -11795,7 +11889,7 @@ namespace ts { checkTypeAssignableTo(exprType, correspondingPropType, node); } - nameTable[node.name.text] = true; + nameTable.set(node.name.text, true); return exprType; } @@ -11808,24 +11902,25 @@ namespace ts { for (const 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]) { + if (!nameTable.get(prop.name)) { const targetPropSym = getPropertyOfType(elementAttributesType, prop.name); if (targetPropSym) { const 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; + nameTable.set(prop.name, true); } } return type; } function getJsxType(name: string) { - if (jsxTypes[name] === undefined) { - return jsxTypes[name] = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType; + let jsxType = jsxTypes.get(name); + if (jsxType === undefined) { + jsxTypes.set(name, jsxType = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType); } - return jsxTypes[name]; + return jsxType; } /** @@ -12158,11 +12253,9 @@ namespace ts { // was spreaded in, though, assume that it provided all required properties if (targetAttributesType && !sawSpreadedAny) { const targetProperties = getPropertiesOfType(targetAttributesType); - for (let i = 0; i < targetProperties.length; i++) { - if (!(targetProperties[i].flags & SymbolFlags.Optional) && - !nameTable[targetProperties[i].name]) { - - error(node, Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); + for (const targetProperty of targetProperties) { + if (!(targetProperty.flags & SymbolFlags.Optional) && !nameTable.get(targetProperty.name)) { + error(node, Diagnostics.Property_0_is_missing_in_type_1, targetProperty.name, typeToString(targetAttributesType)); } } } @@ -12170,7 +12263,11 @@ namespace ts { function checkJsxExpression(node: JsxExpression) { if (node.expression) { - return checkExpression(node.expression); + const type = checkExpression(node.expression); + if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { + error(node, Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); + } + return type; } else { return unknownType; @@ -12286,16 +12383,18 @@ namespace ts { } function checkNonNullExpression(node: Expression | QualifiedName) { - const type = checkExpression(node); - if (strictNullChecks) { - const kind = getFalsyFlags(type) & TypeFlags.Nullable; - if (kind) { - error(node, kind & TypeFlags.Undefined ? kind & TypeFlags.Null ? - Diagnostics.Object_is_possibly_null_or_undefined : - Diagnostics.Object_is_possibly_undefined : - Diagnostics.Object_is_possibly_null); - } - return getNonNullableType(type); + return checkNonNullType(checkExpression(node), node); + } + + function checkNonNullType(type: Type, errorNode: Node): Type { + const kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & TypeFlags.Nullable; + if (kind) { + error(errorNode, kind & TypeFlags.Undefined ? kind & TypeFlags.Null ? + Diagnostics.Object_is_possibly_null_or_undefined : + Diagnostics.Object_is_possibly_undefined : + Diagnostics.Object_is_possibly_null); + const t = getNonNullableType(type); + return t.flags & (TypeFlags.Nullable | TypeFlags.Never) ? unknownType : t; } return type; } @@ -12481,7 +12580,7 @@ namespace ts { return unknownType; } - return getIndexedAccessType(objectType, indexType, node); + return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression: Expression, expressionType: Type, reportError: boolean): boolean { @@ -13840,6 +13939,24 @@ namespace ts { return getNonNullableType(checkExpression(node.expression)); } + function checkMetaProperty(node: MetaProperty) { + checkGrammarMetaProperty(node); + Debug.assert(node.keywordToken === SyntaxKind.NewKeyword && node.name.text === "target", "Unrecognized meta-property."); + const container = getNewTargetContainer(node); + if (!container) { + error(node, Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); + return unknownType; + } + else if (container.kind === SyntaxKind.Constructor) { + const symbol = getSymbolOfNode(container.parent); + return getTypeOfSymbol(symbol); + } + else { + const symbol = getSymbolOfNode(container); + return getTypeOfSymbol(symbol); + } + } + function getTypeOfParameter(symbol: Symbol) { const type = getTypeOfSymbol(symbol); if (strictNullChecks) { @@ -14248,6 +14365,7 @@ namespace ts { if (produceDiagnostics && node.kind !== SyntaxKind.MethodDeclaration) { checkCollisionWithCapturedSuperVariable(node, (node).name); checkCollisionWithCapturedThisVariable(node, (node).name); + checkCollisionWithCapturedNewTargetVariable(node, (node).name); } return type; @@ -14365,6 +14483,16 @@ namespace ts { function checkDeleteExpression(node: DeleteExpression): Type { checkExpression(node.expression); + const expr = skipParentheses(node.expression); + if (expr.kind !== SyntaxKind.PropertyAccessExpression && expr.kind !== SyntaxKind.ElementAccessExpression) { + error(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); + return booleanType; + } + const links = getNodeLinks(expr); + const symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } return booleanType; } @@ -14406,6 +14534,7 @@ namespace ts { case SyntaxKind.PlusToken: case SyntaxKind.MinusToken: case SyntaxKind.TildeToken: + checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, TypeFlags.ESSymbol)) { error(node.operand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(node.operator)); } @@ -14417,7 +14546,7 @@ namespace ts { booleanType; case SyntaxKind.PlusPlusToken: case SyntaxKind.MinusMinusToken: - const ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), + const ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -14433,7 +14562,7 @@ namespace ts { if (operandType === silentNeverType) { return silentNeverType; } - const ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), + const ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -14500,14 +14629,17 @@ namespace ts { } // TypeScript 1.0 spec (April 2014): 4.15.4 // The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, - // and the right operand to be of type Any or a subtype of the 'Function' interface type. + // and the right operand to be of type Any, a subtype of the 'Function' interface type, or have a call or construct signature. // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (isTypeOfKind(leftType, TypeFlags.Primitive)) { error(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported - if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { + if (!(isTypeAny(rightType) || + getSignaturesOfType(rightType, SignatureKind.Call).length || + getSignaturesOfType(rightType, SignatureKind.Construct).length || + isTypeSubtypeOf(rightType, globalFunctionType))) { error(right, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; @@ -14517,6 +14649,8 @@ namespace ts { if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); // TypeScript 1.0 spec (April 2014): 4.15.5 // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. @@ -14801,17 +14935,9 @@ namespace ts { if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - // TypeScript 1.0 spec (April 2014): 4.19.1 - // These operators require their operands to be of type Any, the Number primitive type, - // or an enum type. Operands of an enum type are treated - // as having the primitive type Number. If one operand is the null or undefined value, - // it is treated as having the type of the other operand. - // The result is always of the Number primitive type. - if (leftType.flags & TypeFlags.Nullable) leftType = rightType; - if (rightType.flags & TypeFlags.Nullable) rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); let suggestedOperator: SyntaxKind; // if a user tries to apply a bitwise operator to 2 boolean operands @@ -14836,16 +14962,11 @@ namespace ts { if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - // TypeScript 1.0 spec (April 2014): 4.19.2 - // The binary + operator requires both operands to be of the Number primitive type or an enum type, - // or at least one of the operands to be of type Any or the String primitive type. - // If one operand is the null or undefined value, it is treated as having the type of the other operand. - if (leftType.flags & TypeFlags.Nullable) leftType = rightType; - if (rightType.flags & TypeFlags.Nullable) rightType = leftType; - - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + if (!isTypeOfKind(leftType, TypeFlags.Any | TypeFlags.StringLike) && !isTypeOfKind(rightType, TypeFlags.Any | TypeFlags.StringLike)) { + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); + } let resultType: Type; if (isTypeOfKind(leftType, TypeFlags.NumberLike) && isTypeOfKind(rightType, TypeFlags.NumberLike)) { @@ -14884,8 +15005,8 @@ namespace ts { case SyntaxKind.LessThanEqualsToken: case SyntaxKind.GreaterThanEqualsToken: if (checkForDisallowedESSymbolOperand(operator)) { - leftType = getBaseTypeOfLiteralType(leftType); - rightType = getBaseTypeOfLiteralType(rightType); + leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); + rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } @@ -15110,14 +15231,14 @@ namespace ts { function isLiteralContextualType(contextualType: Type) { if (contextualType) { if (contextualType.flags & TypeFlags.TypeVariable) { - const apparentType = getApparentTypeOfTypeVariable(contextualType); + const constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; // If the type parameter is constrained to the base primitive type we're checking for, // consider this a literal context. For example, given a type parameter 'T extends string', // this causes us to infer string literal types for T. - if (apparentType.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum)) { + if (constraint.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum)) { return true; } - contextualType = apparentType; + contextualType = constraint; } return maybeTypeOfKind(contextualType, (TypeFlags.Literal | TypeFlags.Index)); } @@ -15272,6 +15393,8 @@ namespace ts { return checkAssertion(node); case SyntaxKind.NonNullExpression: return checkNonNullAssertion(node); + case SyntaxKind.MetaProperty: + return checkMetaProperty(node); case SyntaxKind.DeleteExpression: return checkDeleteExpression(node); case SyntaxKind.VoidExpression: @@ -15313,6 +15436,10 @@ namespace ts { } checkSourceElement(node.constraint); + const typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); + if (!hasNonCircularBaseConstraint(typeParameter)) { + error(node.constraint, Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); + } getConstraintOfTypeParameter(getDeclaredTypeOfTypeParameter(getSymbolOfNode(node))); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, Diagnostics.Type_parameter_name_cannot_be_0); @@ -15582,17 +15709,17 @@ namespace ts { } function addName(names: Map, location: Node, name: string, meaning: Accessor) { - const prev = names[name]; + const prev = names.get(name); if (prev) { if (prev & meaning) { error(location, Diagnostics.Duplicate_identifier_0, getTextOfNode(location)); } else { - names[name] = prev | meaning; + names.set(name, prev | meaning); } } else { - names[name] = meaning; + names.set(name, meaning); } } } @@ -15612,12 +15739,12 @@ namespace ts { continue; } - if (names[memberName]) { + if (names.get(memberName)) { error(member.symbol.valueDeclaration.name, Diagnostics.Duplicate_identifier_0, memberName); error(member.name, Diagnostics.Duplicate_identifier_0, memberName); } else { - names[memberName] = true; + names.set(memberName, true); } } } @@ -15936,8 +16063,20 @@ namespace ts { forEach(node.types, checkSourceElement); } + function checkIndexedAccessIndexType(type: Type, accessNode: ElementAccessExpression | IndexedAccessTypeNode) { + if (type.flags & TypeFlags.IndexedAccess) { + // Check that the index type is assignable to 'keyof T' for the object type. + const objectType = (type).objectType; + const indexType = (type).indexType; + if (!isTypeAssignableTo(indexType, getIndexType(objectType))) { + error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); + } + } + return type; + } + function checkIndexedAccessType(node: IndexedAccessTypeNode) { - getTypeFromIndexedAccessTypeNode(node); + checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node: MappedTypeNode) { @@ -15945,8 +16084,7 @@ namespace ts { checkSourceElement(node.type); const type = getTypeFromMappedTypeNode(node); const constraintType = getConstraintTypeFromMappedType(type); - const keyType = constraintType.flags & TypeFlags.TypeVariable ? getApparentTypeOfTypeVariable(constraintType) : constraintType; - checkTypeAssignableTo(keyType, stringType, node.typeParameter.constraint); + checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node: Node): boolean { @@ -16268,9 +16406,10 @@ namespace ts { } } - function checkNonThenableType(type: Type, location?: Node, message?: DiagnosticMessage) { + function checkNonThenableType(type: Type, location?: Node, message?: DiagnosticMessage): Type { type = getWidenedType(type); - if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + const apparentType = getApparentType(type); + if ((apparentType.flags & (TypeFlags.Any | TypeFlags.Never)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -16678,6 +16817,7 @@ namespace ts { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -16807,8 +16947,7 @@ namespace ts { function checkUnusedLocalsAndParameters(node: Node): void { if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && noUnusedIdentifiers && !isInAmbientContext(node)) { - for (const key in node.locals) { - const local = node.locals[key]; + node.locals.forEach(local => { if (!local.isReferenced) { if (local.valueDeclaration && getRootDeclaration(local.valueDeclaration).kind === SyntaxKind.Parameter) { const parameter = getRootDeclaration(local.valueDeclaration); @@ -16823,7 +16962,7 @@ namespace ts { forEach(local.declarations, d => errorUnusedLocal(d.name || d, local.name)); } } - } + }); } } @@ -16900,16 +17039,15 @@ namespace ts { function checkUnusedModuleMembers(node: ModuleDeclaration | SourceFile): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { - for (const key in node.locals) { - const local = node.locals[key]; + node.locals.forEach(local => { if (!local.isReferenced && !local.exportSymbol) { for (const declaration of local.declarations) { if (!isAmbientModule(declaration)) { - error(declaration.name, Diagnostics._0_is_declared_but_never_used, local.name); + errorUnusedLocal(declaration.name, local.name); } } } - } + }); } } @@ -16972,6 +17110,12 @@ namespace ts { } } + function checkCollisionWithCapturedNewTargetVariable(node: Node, name: Identifier): void { + if (needCollisionCheckForIdentifier(node, name, "_newTarget")) { + potentialNewTargetCollisions.push(node); + } + } + // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node: Node): void { let current = node; @@ -16990,6 +17134,23 @@ namespace ts { } } + function checkIfNewTargetIsCapturedInEnclosingScope(node: Node): void { + let current = node; + while (current) { + if (getNodeCheckFlags(current) & NodeCheckFlags.CaptureNewTarget) { + const isDeclaration = node.kind !== SyntaxKind.Identifier; + if (isDeclaration) { + error((node).name, Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); + } + else { + error(node, Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); + } + return; + } + current = current.parent; + } + } + function checkCollisionWithCapturedSuperVariable(node: Node, name: Identifier) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -17163,7 +17324,8 @@ namespace ts { // so we need to do a bit of extra work to check if reference is legal const enclosingContainer = getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === SyntaxKind.Parameter) { + if (symbol.valueDeclaration.kind === SyntaxKind.Parameter || + symbol.valueDeclaration.kind === SyntaxKind.BindingElement) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -17215,7 +17377,7 @@ namespace ts { } if (node.kind === SyntaxKind.BindingElement) { - if (node.parent.kind === SyntaxKind.ObjectBindingPattern && languageVersion < ScriptTarget.ESNext) { + if (node.parent.kind === SyntaxKind.ObjectBindingPattern && languageVersion < ScriptTarget.ESNext && !isInAmbientContext(node)) { checkExternalEmitHelpers(node, ExternalEmitHelpers.Rest); } // check computed properties inside property names of binding elements @@ -17285,6 +17447,7 @@ namespace ts { } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -17789,27 +17952,27 @@ namespace ts { if (func.kind === SyntaxKind.SetAccessor) { if (node.expression) { - error(node.expression, Diagnostics.Setters_cannot_return_a_value); + error(node, Diagnostics.Setters_cannot_return_a_value); } } else if (func.kind === SyntaxKind.Constructor) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { - error(node.expression, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + error(node, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { if (isAsyncFunctionLike(func)) { const promisedType = getPromisedType(returnType); - const awaitedType = checkAwaitedType(exprType, node.expression || node, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + const awaitedType = checkAwaitedType(exprType, node, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); if (promisedType) { // If the function has a return type, but promisedType is // undefined, an error will be reported in checkAsyncFunctionReturnType // so we don't need to report one here. - checkTypeAssignableTo(awaitedType, promisedType, node.expression || node); + checkTypeAssignableTo(awaitedType, promisedType, node); } } else { - checkTypeAssignableTo(exprType, returnType, node.expression || node); + checkTypeAssignableTo(exprType, returnType, node); } } } @@ -17938,12 +18101,12 @@ namespace ts { else { const blockLocals = catchClause.block.locals; if (blockLocals) { - for (const caughtName in catchClause.locals) { - const blockLocal = blockLocals[caughtName]; + forEachKey(catchClause.locals, caughtName => { + const blockLocal = blockLocals.get(caughtName); if (blockLocal && (blockLocal.flags & SymbolFlags.BlockScopedVariable) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } - } + }); } } } @@ -18054,6 +18217,7 @@ namespace ts { case "string": case "symbol": case "void": + case "object": error(name, message, (name).text); } } @@ -18061,7 +18225,7 @@ namespace ts { /** Check each type parameter and check that type parameters have no duplicate type parameter declarations */ function checkTypeParameters(typeParameterDeclarations: TypeParameterDeclaration[]) { if (typeParameterDeclarations) { - for (let i = 0, n = typeParameterDeclarations.length; i < n; i++) { + for (let i = 0; i < typeParameterDeclarations.length; i++) { const node = typeParameterDeclarations[i]; checkTypeParameter(node); @@ -18121,6 +18285,7 @@ namespace ts { if (node.name) { checkTypeNameIsReserved(node.name, Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -18341,7 +18506,7 @@ namespace ts { // TypeScript 1.0 spec (April 2014): // When a generic interface has multiple declarations, all declarations must have identical type parameter // lists, i.e. identical type parameter names with identical constraints in identical order. - for (let i = 0, len = list1.length; i < len; i++) { + for (let i = 0; i < list1.length; i++) { const tp1 = list1[i]; const tp2 = list2[i]; if (tp1.name.text !== tp2.name.text) { @@ -18367,15 +18532,15 @@ namespace ts { } const seen = createMap<{ prop: Symbol; containingType: Type }>(); - forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen[p.name] = { prop: p, containingType: type }; }); + forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen.set(p.name, { prop: p, containingType: type }); }); let ok = true; for (const base of baseTypes) { const properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); for (const prop of properties) { - const existing = seen[prop.name]; + const existing = seen.get(prop.name); if (!existing) { - seen[prop.name] = { prop: prop, containingType: base }; + seen.set(prop.name, { prop: prop, containingType: base }); } else { const isInheritedProperty = existing.containingType !== type; @@ -18564,6 +18729,7 @@ namespace ts { } return undefined; case SyntaxKind.NumericLiteral: + checkGrammarNumericLiteral(e); return +(e).text; case SyntaxKind.ParenthesizedExpression: return evalConstant((e).expression); @@ -18655,6 +18821,7 @@ namespace ts { checkTypeNameIsReserved(node.name, Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); @@ -19088,7 +19255,13 @@ namespace ts { const container = node.parent.kind === SyntaxKind.SourceFile ? node.parent : node.parent.parent; if (container.kind === SyntaxKind.ModuleDeclaration && !isAmbientModule(container)) { - error(node, Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + if (node.isExportEquals) { + error(node, Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + } + else { + error(node, Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); + } + return; } // Grammar checking @@ -19117,19 +19290,14 @@ namespace ts { } function hasExportedMembers(moduleSymbol: Symbol) { - for (const id in moduleSymbol.exports) { - if (id !== "export=") { - return true; - } - } - return false; + return forEachEntry(moduleSymbol.exports, (_, id) => id !== "export="); } function checkExternalModuleExports(node: SourceFile | ModuleDeclaration) { const moduleSymbol = getSymbolOfNode(node); const links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - const exportEqualsSymbol = moduleSymbol.exports["export="]; + const exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { const declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; if (!isTopLevelInExternalModuleAugmentation(declaration)) { @@ -19138,21 +19306,20 @@ namespace ts { } // Checks for export * conflicts const exports = getExportsOfModule(moduleSymbol); - for (const id in exports) { + exports && exports.forEach(({ declarations, flags }, id) => { if (id === "__export") { - continue; + return; } - const { declarations, flags } = exports[id]; // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. // (TS Exceptions: namespaces, function overloads, enums, and interfaces) if (flags & (SymbolFlags.Namespace | SymbolFlags.Interface | SymbolFlags.Enum)) { - continue; + return; } const exportedDeclarationsCount = countWhere(declarations, isNotOverload); if (flags & SymbolFlags.TypeAlias && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) - continue; + return; } if (exportedDeclarationsCount > 1) { for (const declaration of declarations) { @@ -19161,7 +19328,7 @@ namespace ts { } } } - } + }); links.exportsChecked = true; } @@ -19360,6 +19527,7 @@ namespace ts { checkGrammarSourceFile(node); potentialThisCollisions.length = 0; + potentialNewTargetCollisions.length = 0; deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; @@ -19388,6 +19556,11 @@ namespace ts { potentialThisCollisions.length = 0; } + if (potentialNewTargetCollisions.length) { + forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope) + potentialNewTargetCollisions.length = 0; + } + links.flags |= NodeCheckFlags.TypeChecked; } } @@ -19544,18 +19717,17 @@ namespace ts { // We will copy all symbol regardless of its reserved name because // symbolsToArray will check whether the key is a reserved name and // it will not copy symbol with reserved name to the array - if (!symbols[id]) { - symbols[id] = symbol; + if (!symbols.has(id)) { + symbols.set(id, symbol); } } } function copySymbols(source: SymbolTable, meaning: SymbolFlags): void { if (meaning) { - for (const id in source) { - const symbol = source[id]; + source.forEach(symbol => { copySymbol(symbol, meaning); - } + }); } } } @@ -19966,8 +20138,8 @@ namespace ts { const propsByName = createSymbolTable(getPropertiesOfType(type)); if (getSignaturesOfType(type, SignatureKind.Call).length || getSignaturesOfType(type, SignatureKind.Construct).length) { forEach(getPropertiesOfType(globalFunctionType), p => { - if (!propsByName[p.name]) { - propsByName[p.name] = p; + if (!propsByName.has(p.name)) { + propsByName.set(p.name, p); } }); } @@ -20034,7 +20206,7 @@ namespace ts { // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment ? !!(moduleSymbol.flags & SymbolFlags.Value) - : forEachProperty(getExportsOfModule(moduleSymbol), isValue); + : forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; @@ -20384,7 +20556,7 @@ namespace ts { } function hasGlobalName(name: string): boolean { - return !!globals[name]; + return globals.has(name); } function getReferencedValueSymbol(reference: Identifier, startInDeclarationContainer?: boolean): Symbol { @@ -20441,14 +20613,13 @@ namespace ts { if (resolvedTypeReferenceDirectives) { // populate reverse mapping: file path -> type reference directive that was resolved to this file fileToDirective = createFileMap(); - for (const key in resolvedTypeReferenceDirectives) { - const resolvedDirective = resolvedTypeReferenceDirectives[key]; + resolvedTypeReferenceDirectives.forEach((resolvedDirective, key) => { if (!resolvedDirective) { - continue; + return; } const file = host.getSourceFile(resolvedDirective.resolvedFileName); fileToDirective.set(file.path, key); - } + }); } return { getReferencedExportContainer, @@ -20592,11 +20763,11 @@ namespace ts { if (file.symbol && file.symbol.globalExports) { // Merge in UMD exports with first-in-wins semantics (see #9771) const source = file.symbol.globalExports; - for (const id in source) { - if (!(id in globals)) { - globals[id] = source[id]; + source.forEach((sourceSymbol, id) => { + if (!globals.has(id)) { + globals.set(id, sourceSymbol); } - } + }); } } @@ -20778,7 +20949,7 @@ namespace ts { case SyntaxKind.PublicKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.PrivateKeyword: - let text = visibilityToString(modifierToFlag(modifier.kind)); + const text = visibilityToString(modifierToFlag(modifier.kind)); if (modifier.kind === SyntaxKind.ProtectedKeyword) { lastProtected = modifier; @@ -21348,17 +21519,17 @@ namespace ts { continue; } - if (!seen[effectiveName]) { - seen[effectiveName] = currentKind; + const existingKind = seen.get(effectiveName); + if (!existingKind) { + seen.set(effectiveName, currentKind); } else { - const existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { grammarErrorOnNode(name, Diagnostics.Duplicate_identifier_0, getTextOfNode(name)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[effectiveName] = currentKind | existingKind; + seen.set(effectiveName, currentKind | existingKind); } else { return grammarErrorOnNode(name, Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); @@ -21380,8 +21551,8 @@ namespace ts { const jsxAttr = (attr); const name = jsxAttr.name; - if (!seen[name.text]) { - seen[name.text] = true; + if (!seen.get(name.text)) { + seen.set(name.text, true); } else { return grammarErrorOnNode(name, Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); @@ -21718,6 +21889,14 @@ namespace ts { } } + function checkGrammarMetaProperty(node: MetaProperty) { + if (node.keywordToken === SyntaxKind.NewKeyword) { + if (node.name.text !== "target") { + return grammarErrorOnNode(node.name, Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, tokenToString(node.keywordToken), "target"); + } + } + } + function hasParseDiagnostics(sourceFile: SourceFile): boolean { return sourceFile.parseDiagnostics.length > 0; } @@ -21863,11 +22042,20 @@ namespace ts { function checkGrammarNumericLiteral(node: NumericLiteral): boolean { // Grammar checking if (node.isOctalLiteral) { + let diagnosticMessage: DiagnosticMessage | undefined; if (languageVersion >= ScriptTarget.ES5) { - return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0o_0, node.text); + diagnosticMessage = Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - if (isChildOfLiteralType(node)) { - return grammarErrorOnNode(node, Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0o_0, node.text); + else if (isChildOfNodeWithKind(node, SyntaxKind.LiteralType)) { + diagnosticMessage = Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; + } + else if (isChildOfNodeWithKind(node, SyntaxKind.EnumMember)) { + diagnosticMessage = Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; + } + if (diagnosticMessage) { + const withMinus = isPrefixUnaryExpression(node.parent) && node.parent.operator === SyntaxKind.MinusToken; + const literal = `${withMinus ? "-" : ""}0o${node.text}`; + return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } } @@ -21883,11 +22071,11 @@ namespace ts { function getAmbientModules(): Symbol[] { const result: Symbol[] = []; - for (const sym in globals) { + globals.forEach((global, sym) => { if (ambientModuleSymbolRegex.test(sym)) { - result.push(globals[sym]); + result.push(global); } - } + }); return result; } } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index fc49b9b1347..74308951d54 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// @@ -65,7 +65,7 @@ namespace ts { }, { name: "jsx", - type: createMap({ + type: createMapFromTemplate({ "preserve": JsxEmit.Preserve, "react": JsxEmit.React }), @@ -100,7 +100,7 @@ namespace ts { { name: "module", shortName: "m", - type: createMap({ + type: createMapFromTemplate({ "none": ModuleKind.None, "commonjs": ModuleKind.CommonJS, "amd": ModuleKind.AMD, @@ -114,7 +114,7 @@ namespace ts { }, { name: "newLine", - type: createMap({ + type: createMapFromTemplate({ "crlf": NewLineKind.CarriageReturnLineFeed, "lf": NewLineKind.LineFeed }), @@ -212,8 +212,8 @@ namespace ts { shortName: "p", type: "string", isFilePath: true, - description: Diagnostics.Compile_the_project_in_the_given_directory, - paramType: Diagnostics.DIRECTORY + description: Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + paramType: Diagnostics.FILE_OR_DIRECTORY }, { name: "removeComments", @@ -263,7 +263,7 @@ namespace ts { { name: "target", shortName: "t", - type: createMap({ + type: createMapFromTemplate({ "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, "es6": ScriptTarget.ES2015, @@ -300,7 +300,7 @@ namespace ts { }, { name: "moduleResolution", - type: createMap({ + type: createMapFromTemplate({ "node": ModuleResolutionKind.NodeJs, "classic": ModuleResolutionKind.Classic, }), @@ -409,7 +409,7 @@ namespace ts { type: "list", element: { name: "lib", - type: createMap({ + type: createMapFromTemplate({ // JavaScript only "es5": "lib.es5.d.ts", "es6": "lib.es2015.d.ts", @@ -517,7 +517,7 @@ namespace ts { include: typeAcquisition.include || [], exclude: typeAcquisition.exclude || [] }; - return result; + return result; } return typeAcquisition; } @@ -531,9 +531,9 @@ namespace ts { const optionNameMap = createMap(); const shortOptionNames = createMap(); forEach(optionDeclarations, option => { - optionNameMap[option.name.toLowerCase()] = option; + optionNameMap.set(option.name.toLowerCase(), option); if (option.shortName) { - shortOptionNames[option.shortName] = option.name; + shortOptionNames.set(option.shortName, option.name); } }); @@ -547,7 +547,7 @@ namespace ts { } function createDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType, createDiagnostic: (message: DiagnosticMessage, arg0: string, arg1: string) => Diagnostic): Diagnostic { - const namesOfType = Object.keys(opt.type).map(key => `'${key}'`).join(", "); + const namesOfType = arrayFrom(opt.type.keys()).map(key => `'${key}'`).join(", "); return createDiagnostic(Diagnostics.Argument_for_0_option_must_be_Colon_1, `--${opt.name}`, namesOfType); } @@ -601,13 +601,13 @@ namespace ts { s = s.slice(s.charCodeAt(1) === CharacterCodes.minus ? 2 : 1).toLowerCase(); // Try to translate short option names to their full equivalents. - if (s in shortOptionNames) { - s = shortOptionNames[s]; + const short = shortOptionNames.get(s); + if (short !== undefined) { + s = short; } - if (s in optionNameMap) { - const opt = optionNameMap[s]; - + const opt = optionNameMap.get(s); + if (opt) { if (opt.isTSConfigOnly) { errors.push(createCompilerDiagnostic(Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } @@ -624,7 +624,7 @@ namespace ts { break; case "boolean": // boolean flag has optional value true, false, others - let optValue = args[i]; + const optValue = args[i]; options[opt.name] = optValue !== "false"; // consume next argument as boolean flag value if (optValue === "false" || optValue === "true") { @@ -846,7 +846,7 @@ namespace ts { } const keyText = getTextOfPropertyName(element.name); - const option = options ? options[keyText] : undefined; + const option = options ? options.get(keyText) : undefined; if (extraKeyDiagnosticMessage && !option) { errors.push(createDiagnosticForNodeInSourceFile(sourceFile, element.name, extraKeyDiagnosticMessage, keyText)); } @@ -901,7 +901,7 @@ namespace ts { if (option && typeof option.type !== "string") { const customOption = option; // Validate custom option type - if (!(text in customOption.type)) { + if (!customOption.type.has(text)) { errors.push( createDiagnosticForInvalidCustomType( customOption, @@ -976,7 +976,7 @@ namespace ts { * @param fileNames array of filenames to be generated into tsconfig.json */ /* @internal */ - export function generateTSConfig(options: CompilerOptions, fileNames: string[]): { compilerOptions: Map } { + export function generateTSConfig(options: CompilerOptions, fileNames: string[]): { compilerOptions: MapLike } { const compilerOptions = extend(options, defaultInitCompilerOptions); const configurations: any = { compilerOptions: serializeCompilerOptions(compilerOptions) @@ -1001,18 +1001,17 @@ namespace ts { } } - function getNameOfCompilerOptionValue(value: CompilerOptionsValue, customTypeMap: MapLike): string | undefined { + function getNameOfCompilerOptionValue(value: CompilerOptionsValue, customTypeMap: Map): string | undefined { // There is a typeMap associated with this command-line option so use it to map value back to its name - for (const key in customTypeMap) { - if (customTypeMap[key] === value) { + return forEachEntry(customTypeMap, (mapValue, key) => { + if (mapValue === value) { return key; } - } - return undefined; + }); } - function serializeCompilerOptions(options: CompilerOptions): Map { - const result = createMap(); + function serializeCompilerOptions(options: CompilerOptions): MapLike { + const result: ts.MapLike = {}; const optionsNameMap = getOptionNameMap().optionNameMap; for (const name in options) { @@ -1028,7 +1027,7 @@ namespace ts { break; default: const value = options[name]; - let optionDefinition = optionsNameMap[name.toLowerCase()]; + const optionDefinition = optionsNameMap.get(name.toLowerCase()); if (optionDefinition) { const customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { @@ -1090,6 +1089,7 @@ namespace ts { function parseJsonConfigFileContentWorker(json: any, sourceFile: JsonSourceFile, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: FileExtensionInfo[] = []): ParsedCommandLine { Debug.assert((json === undefined && sourceFile !== undefined) || (json !== undefined && sourceFile === undefined)); const errors: Diagnostic[] = []; + basePath = normalizeSlashes(basePath); const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames); const resolvedPath = toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -1387,8 +1387,8 @@ namespace ts { const optionNameMap = commandLineOptionsToMap(optionDeclarations); for (const id in jsonOptions) { - if (id in optionNameMap) { - const opt = optionNameMap[id]; + const opt = optionNameMap.get(id); + if (opt) { defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); } else { @@ -1422,7 +1422,7 @@ namespace ts { return value; } else if (typeof option.type !== "string") { - return option.type[value]; + return option.type.get(value); } return normalizeNonListOptionValue(option, basePath, value); } @@ -1439,8 +1439,9 @@ namespace ts { function convertJsonOptionOfCustomType(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]) { const key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; + const val = opt.type.get(key); + if (val !== undefined) { + return val; } else { errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); @@ -1568,7 +1569,7 @@ namespace ts { // file map that marks whether it was a regular wildcard match (with a `*` or `?` token), // or a recursive directory. This information is used by filesystem watchers to monitor for // new entries in these paths. - const wildcardDirectories: Map = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); + const wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); // Rather than requery this for each file and filespec, we query the supported extensions // once and store it on the expansion context. @@ -1579,7 +1580,7 @@ namespace ts { if (fileNames) { for (const fileName of fileNames) { const file = combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; + literalFileMap.set(keyMapper(file), file); } } @@ -1602,14 +1603,14 @@ namespace ts { removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); const key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; + if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) { + wildcardFileMap.set(key, file); } } } - const literalFiles = reduceProperties(literalFileMap, addFileToOutput, []); - const wildcardFiles = reduceProperties(wildcardFileMap, addFileToOutput, []); + const literalFiles = arrayFrom(literalFileMap.values()); + const wildcardFiles = arrayFrom(wildcardFileMap.values()); wildcardFiles.sort(host.useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); return { fileNames: literalFiles.concat(wildcardFiles), @@ -1657,7 +1658,7 @@ namespace ts { /** * Gets directories in a set of include patterns that should be watched for changes. */ - function getWildcardDirectories(include: string[], exclude: string[], path: string, useCaseSensitiveFileNames: boolean): Map { + function getWildcardDirectories(include: string[], exclude: string[], path: string, useCaseSensitiveFileNames: boolean): MapLike { // We watch a directory recursively if it contains a wildcard anywhere in a directory segment // of the pattern: // @@ -1672,7 +1673,7 @@ namespace ts { // /a/b/a?z - Watch /a/b directly to catch any new file matching a?z const rawExcludeRegex = getRegularExpressionForWildcard(exclude, path, "exclude"); const excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - const wildcardDirectories = createMap(); + const wildcardDirectories: ts.MapLike = {}; if (include !== undefined) { const recursiveKeys: string[] = []; for (const file of include) { @@ -1695,13 +1696,13 @@ namespace ts { } // Remove any subpaths under an existing recursively watched directory. - for (const key in wildcardDirectories) { + for (const key in wildcardDirectories) if (hasProperty(wildcardDirectories, key)) { for (const recursiveKey of recursiveKeys) { if (key !== recursiveKey && containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { delete wildcardDirectories[key]; } } - } + }; } return wildcardDirectories; @@ -1735,7 +1736,7 @@ namespace ts { for (let i = ExtensionPriority.Highest; i < adjustedExtensionPriority; i++) { const higherPriorityExtension = extensions[i]; const higherPriorityPath = keyMapper(changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { return true; } } @@ -1757,21 +1758,10 @@ namespace ts { for (let i = nextExtensionPriority; i < extensions.length; i++) { const lowerPriorityExtension = extensions[i]; const lowerPriorityPath = keyMapper(changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; + wildcardFiles.delete(lowerPriorityPath); } } - /** - * Adds a file to an array of files. - * - * @param output The output array. - * @param file The file path. - */ - function addFileToOutput(output: string[], file: string) { - output.push(file); - return output; - } - /** * Gets a case sensitive key. * diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 55a712707bc..6e51221318f 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -23,13 +23,12 @@ namespace ts { True = -1 } - const createObject = Object.create; - // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. export const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - export function createMap(template?: MapLike): Map { - const map: Map = createObject(null); // tslint:disable-line:no-null-keyword + /** Create a MapLike with good performance. */ + function createDictionaryObject(): MapLike { + const map = Object.create(null); // tslint:disable-line:no-null-keyword // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is @@ -37,17 +36,113 @@ namespace ts { map["__"] = undefined; delete map["__"]; + return map; + } + + /** Create a new map. If a template object is provided, the map will copy entries from it. */ + export function createMap(): Map { + return new MapCtr(); + } + + export function createMapFromTemplate(template?: MapLike): Map { + const map: Map = new MapCtr(); + // Copies keys/values from template. Note that for..in will not throw if // template is undefined, and instead will just exit the loop. for (const key in template) if (hasOwnProperty.call(template, key)) { - map[key] = template[key]; + map.set(key, template[key]); } return map; } + // The global Map object. This may not be available, so we must test for it. + declare const Map: { new(): Map } | undefined; + // Internet Explorer's Map doesn't support iteration, so don't use it. + // tslint:disable-next-line:no-in-operator + const MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); + + // Keep the class inside a function so it doesn't get compiled if it's not used. + function shimMap(): { new(): Map } { + + class MapIterator { + private data: MapLike; + private keys: string[]; + private index = 0; + private selector: (data: MapLike, key: string) => U; + constructor(data: MapLike, selector: (data: MapLike, key: string) => U) { + this.data = data; + this.selector = selector; + this.keys = Object.keys(data); + } + + public next(): { value: U, done: false } | { value: never, done: true } { + const index = this.index; + if (index < this.keys.length) { + this.index++; + return { value: this.selector(this.data, this.keys[index]), done: false }; + } + return { value: undefined as never, done: true } + } + } + + return class implements Map { + private data = createDictionaryObject(); + public size = 0; + + get(key: string): T { + return this.data[key]; + } + + set(key: string, value: T): this { + if (!this.has(key)) { + this.size++; + } + this.data[key] = value; + return this; + } + + has(key: string): boolean { + // tslint:disable-next-line:no-in-operator + return key in this.data; + } + + delete(key: string): boolean { + if (this.has(key)) { + this.size--; + delete this.data[key]; + return true; + } + return false; + } + + clear(): void { + this.data = createDictionaryObject(); + this.size = 0; + } + + keys() { + return new MapIterator(this.data, (_data, key) => key); + } + + values() { + return new MapIterator(this.data, (data, key) => data[key]); + } + + entries() { + return new MapIterator(this.data, (data, key) => [key, data[key]] as [string, T]); + } + + forEach(action: (value: T, key: string) => void): void { + for (const key in this.data) { + action(this.data[key], key); + } + } + } + } + export function createFileMap(keyMapper?: (key: string) => string): FileMap { - let files = createMap(); + const files = createMap(); return { get, set, @@ -59,39 +154,34 @@ namespace ts { }; function forEachValueInMap(f: (key: Path, value: T) => void) { - for (const key in files) { - f(key, files[key]); - } + files.forEach((file, key) => { + f(key, file); + }); } function getKeys() { - const keys: Path[] = []; - for (const key in files) { - keys.push(key); - } - return keys; + return arrayFrom(files.keys()) as Path[]; } // path should already be well-formed so it does not need to be normalized function get(path: Path): T { - return files[toKey(path)]; + return files.get(toKey(path)); } function set(path: Path, value: T) { - files[toKey(path)] = value; + files.set(toKey(path), value); } function contains(path: Path) { - return toKey(path) in files; + return files.has(toKey(path)); } function remove(path: Path) { - const key = toKey(path); - delete files[key]; + files.delete(toKey(path)); } function clear() { - files = createMap(); + files.clear(); } function toKey(path: Path): string { @@ -119,7 +209,7 @@ namespace ts { */ export function forEach(array: T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined { if (array) { - for (let i = 0, len = array.length; i < len; i++) { + for (let i = 0; i < array.length; i++) { const result = callback(array[i], i); if (result) { return result; @@ -143,7 +233,7 @@ namespace ts { */ export function every(array: T[], callback: (element: T, index: number) => boolean): boolean { if (array) { - for (let i = 0, len = array.length; i < len; i++) { + for (let i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -155,7 +245,7 @@ namespace ts { /** Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. */ export function find(array: T[], predicate: (element: T, index: number) => boolean): T | undefined { - for (let i = 0, len = array.length; i < len; i++) { + for (let i = 0; i < array.length; i++) { const value = array[i]; if (predicate(value, i)) { return value; @@ -169,7 +259,7 @@ namespace ts { * This is like `forEach`, but never returns undefined. */ export function findMap(array: T[], callback: (element: T, index: number) => U | undefined): U { - for (let i = 0, len = array.length; i < len; i++) { + for (let i = 0; i < array.length; i++) { const result = callback(array[i], i); if (result) { return result; @@ -191,7 +281,7 @@ namespace ts { export function indexOf(array: T[], value: T): number { if (array) { - for (let i = 0, len = array.length; i < len; i++) { + for (let i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -201,7 +291,7 @@ namespace ts { } export function indexOfAnyCharCode(text: string, charCodes: number[], start?: number): number { - for (let i = start || 0, len = text.length; i < len; i++) { + for (let i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -420,17 +510,16 @@ namespace ts { return result; } - export function mapObject(object: MapLike, f: (key: string, x: T) => [string, U]): MapLike { - let result: MapLike; - if (object) { - result = {}; - for (const v of getOwnKeys(object)) { - const [key, value]: [string, U] = f(v, object[v]) || [undefined, undefined]; - if (key !== undefined) { - result[key] = value; - } - } + export function mapEntries(map: Map, f: (key: string, value: T) => [string, U]): Map { + if (!map) { + return undefined; } + + const result = createMap(); + map.forEach((value, key) => { + const [newKey, newValue] = f(key, value); + result.set(newKey, newValue); + }); return result; } @@ -748,9 +837,6 @@ namespace ts { /** * Indicates whether a map-like contains an own property with the specified key. * - * NOTE: This is intended for use only with MapLike objects. For Map objects, use - * the 'in' operator. - * * @param map A map-like. * @param key A property key. */ @@ -761,9 +847,6 @@ namespace ts { /** * Gets the value of an owned property in a map-like. * - * NOTE: This is intended for use only with MapLike objects. For Map objects, use - * an indexer. - * * @param map A map-like. * @param key A property key. */ @@ -787,50 +870,48 @@ namespace ts { return keys; } - /** - * Enumerates the properties of a Map, invoking a callback and returning the first truthy result. - * - * @param map A map for which properties should be enumerated. - * @param callback A callback to invoke for each property. - */ - export function forEachProperty(map: Map, callback: (value: T, key: string) => U): U { - let result: U; - for (const key in map) { - if (result = callback(map[key], key)) break; + /** Shims `Array.from`. */ + export function arrayFrom(iterator: Iterator): T[] { + const result: T[] = []; + for (let { value, done } = iterator.next(); !done; { value, done } = iterator.next()) { + result.push(value); } return result; } /** - * Returns true if a Map has some matching property. - * - * @param map A map whose properties should be tested. - * @param predicate An optional callback used to test each property. + * Calls `callback` for each entry in the map, returning the first truthy result. + * Use `map.forEach` instead for normal iteration. */ - export function someProperties(map: Map, predicate?: (value: T, key: string) => boolean) { - for (const key in map) { - if (!predicate || predicate(map[key], key)) return true; + export function forEachEntry(map: Map, callback: (value: T, key: string) => U | undefined): U | undefined { + const iterator = map.entries(); + for (let { value: pair, done } = iterator.next(); !done; { value: pair, done } = iterator.next()) { + const [key, value] = pair; + const result = callback(value, key); + if (result) { + return result; + } } - return false; + return undefined; } - /** - * Performs a shallow copy of the properties from a source Map to a target MapLike - * - * @param source A map from which properties should be copied. - * @param target A map to which properties should be copied. - */ - export function copyProperties(source: Map, target: MapLike): void { - for (const key in source) { - target[key] = source[key]; + /** `forEachEntry` for just keys. */ + export function forEachKey(map: Map<{}>, callback: (key: string) => T | undefined): T | undefined { + const iterator = map.keys(); + for (let { value: key, done } = iterator.next(); !done; { value: key, done } = iterator.next()) { + const result = callback(key); + if (result) { + return result; + } } + return undefined; } - export function appendProperty(map: Map, key: string | number, value: T): Map { - if (key === undefined || value === undefined) return map; - if (map === undefined) map = createMap(); - map[key] = value; - return map; + /** Copy entries from `source` to `target`. */ + export function copyEntries(source: Map, target: Map): void { + source.forEach((value, key) => { + target.set(key, value); + }); } export function assign, T2, T3>(t: T1, arg1: T2, arg2: T3): T1 & T2 & T3; @@ -845,24 +926,6 @@ namespace ts { return t; } - /** - * Reduce the properties of a map. - * - * NOTE: This is intended for use with Map objects. For MapLike objects, use - * reduceOwnProperties instead as it offers better runtime safety. - * - * @param map The map to reduce - * @param callback An aggregation function that is called for each entry in the map - * @param initial The initial value for the reduction. - */ - export function reduceProperties(map: Map, callback: (aggregate: U, value: T, key: string) => U, initial: U): U { - let result = initial; - for (const key in map) { - result = callback(result, map[key], String(key)); - } - return result; - } - /** * Performs a shallow equality comparison of the contents of two map-likes. * @@ -897,23 +960,14 @@ namespace ts { export function arrayToMap(array: T[], makeKey: (value: T) => string, makeValue?: (value: T) => U): Map { const result = createMap(); for (const value of array) { - result[makeKey(value)] = makeValue ? makeValue(value) : value; + result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; } - export function isEmpty(map: Map) { - for (const id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - export function cloneMap(map: Map) { const clone = createMap(); - copyProperties(map, clone); + copyEntries(map, clone); return clone; } @@ -938,32 +992,43 @@ namespace ts { return result; } - /** - * Adds the value to an array of values associated with the key, and returns the array. - * Creates the array if it does not already exist. - */ - export function multiMapAdd(map: Map, key: string | number, value: V): V[] { - const values = map[key]; - if (values) { - values.push(value); - return values; - } - else { - return map[key] = [value]; - } + export interface MultiMap extends Map { + /** + * Adds the value to an array of values associated with the key, and returns the array. + * Creates the array if it does not already exist. + */ + add(key: string, value: T): T[]; + /** + * Removes a value from an array of values associated with the key. + * Does not preserve the order of those values. + * Does nothing if `key` is not in `map`, or `value` is not in `map[key]`. + */ + remove(key: string, value: T): void; } - /** - * Removes a value from an array of values associated with the key. - * Does not preserve the order of those values. - * Does nothing if `key` is not in `map`, or `value` is not in `map[key]`. - */ - export function multiMapRemove(map: Map, key: string, value: V): void { - const values = map[key]; + export function createMultiMap(): MultiMap { + const map = createMap() as MultiMap; + map.add = multiMapAdd; + map.remove = multiMapRemove; + return map; + } + function multiMapAdd(this: MultiMap, key: string, value: T) { + let values = this.get(key); + if (values) { + values.push(value); + } + else { + this.set(key, values = [value]); + } + return values; + + } + function multiMapRemove(this: MultiMap, key: string, value: T) { + const values = this.get(key); if (values) { unorderedRemoveItem(values, value); if (!values.length) { - delete map[key]; + this.delete(key); } } } @@ -1060,13 +1125,13 @@ namespace ts { } } - function formatStringFromArgs(text: string, args: { [index: number]: string; }, baseIndex?: number): string { + export function formatStringFromArgs(text: string, args: { [index: number]: string; }, baseIndex?: number): string { baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, (_match, index?) => args[+index + baseIndex]); } - export let localizedDiagnosticMessages: Map = undefined; + export let localizedDiagnosticMessages: MapLike = undefined; export function getLocaleSpecificMessage(message: DiagnosticMessage) { return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message; diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index cd98622e080..2287de179e3 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -156,9 +156,9 @@ namespace ts { }); if (usedTypeDirectiveReferences) { - for (const directive in usedTypeDirectiveReferences) { + forEachKey(usedTypeDirectiveReferences, directive => { referencesOutput += `/// ${newLine}`; - } + }); } return { @@ -271,8 +271,8 @@ namespace ts { usedTypeDirectiveReferences = createMap(); } for (const directive of typeReferenceDirectives) { - if (!(directive in usedTypeDirectiveReferences)) { - usedTypeDirectiveReferences[directive] = directive; + if (!usedTypeDirectiveReferences.has(directive)) { + usedTypeDirectiveReferences.set(directive, directive); } } } @@ -390,6 +390,7 @@ namespace ts { case SyntaxKind.StringKeyword: case SyntaxKind.NumberKeyword: case SyntaxKind.BooleanKeyword: + case SyntaxKind.ObjectKeyword: case SyntaxKind.SymbolKeyword: case SyntaxKind.VoidKeyword: case SyntaxKind.UndefinedKeyword: @@ -581,14 +582,14 @@ namespace ts { // do not need to keep track of created temp names. function getExportDefaultTempVariableName(): string { const baseName = "_default"; - if (!(baseName in currentIdentifiers)) { + if (!currentIdentifiers.has(baseName)) { return baseName; } let count = 0; while (true) { count++; const name = baseName + "_" + count; - if (!(name in currentIdentifiers)) { + if (!currentIdentifiers.has(name)) { return name; } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 0ee91f12be4..dc285b03c15 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -227,7 +227,7 @@ "category": "Error", "code": 1084 }, - "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '0o{0}'.": { + "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'.": { "category": "Error", "code": 1085 }, @@ -855,14 +855,18 @@ "category": "Error", "code": 1318 }, - "String literal with double quotes expected.": { + "A default export can only be used in an ECMAScript-style module.": { "category": "Error", "code": 1319 }, - "String, number, object, array, true, false or null expected.": { + "String literal with double quotes expected.": { "category": "Error", "code": 1320 }, + "String, number, object, array, true, false or null expected.": { + "category": "Error", + "code": 1321 + }, "Duplicate identifier '{0}'.": { "category": "Error", "code": 2300 @@ -1779,6 +1783,14 @@ "category": "Error", "code": 2542 }, + "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference.": { + "category": "Error", + "code": 2543 + }, + "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference.": { + "category": "Error", + "code": 2544 + }, "JSX element attributes type '{0}' may not be a union type.": { "category": "Error", "code": 2600 @@ -1815,6 +1827,10 @@ "category": "Error", "code": 2608 }, + "JSX spread child must be an array type.": { + "category": "Error", + "code": 2609 + }, "Cannot emit namespaced JSX elements in React": { "category": "Error", "code": 2650 @@ -2019,6 +2035,14 @@ "category": "Error", "code": 2702 }, + "The operand of a delete operator must be a property reference": { + "category": "Error", + "code": 2703 + }, + "The operand of a delete operator cannot be a read-only property": { + "category": "Error", + "code": 2704 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", @@ -2497,7 +2521,7 @@ "category": "Message", "code": 6019 }, - "Compile the project in the given directory.": { + "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'": { "category": "Message", "code": 6020 }, @@ -2557,6 +2581,10 @@ "category": "Message", "code": 6039 }, + "FILE OR DIRECTORY": { + "category": "Message", + "code": 6040 + }, "Compilation complete. Watching for file changes.": { "category": "Message", "code": 6042 @@ -2749,7 +2777,7 @@ "category": "Message", "code": 6094 }, - "Loading module as file / folder, candidate module location '{0}'.": { + "Loading module as file / folder, candidate module location '{0}', target file type '{1}'.": { "category": "Message", "code": 6095 }, @@ -2761,7 +2789,7 @@ "category": "Message", "code": 6097 }, - "Loading module '{0}' from 'node_modules' folder.": { + "Loading module '{0}' from 'node_modules' folder, target file type '{1}'.": { "category": "Message", "code": 6098 }, @@ -2957,10 +2985,14 @@ "category": "Message", "code": 6146 }, - "Resolution for module '{0}' was found in cache": { + "Resolution for module '{0}' was found in cache.": { "category": "Message", "code": 6147 - }, + }, + "Directory '{0}' does not exist, skipping all lookups in it.": { + "category": "Message", + "code": 6148 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 @@ -3185,6 +3217,14 @@ "category": "Error", "code": 17011 }, + "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?": { + "category": "Error", + "code": 17012 + }, + "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor.": { + "category": "Error", + "code": 17013 + }, "Circularity detected while resolving configuration: {0}": { "category": "Error", @@ -3211,23 +3251,19 @@ "category": "Message", "code": 90002 }, - "Change 'extends' to 'implements'": { + "Change 'extends' to 'implements'.": { "category": "Message", "code": 90003 }, - "Remove unused identifiers": { + "Remove declaration for: {0}": { "category": "Message", "code": 90004 }, - "Implement interface on reference": { - "category": "Message", - "code": 90005 - }, - "Implement interface on class": { + "Implement interface '{0}'.": { "category": "Message", "code": 90006 }, - "Implement inherited abstract class": { + "Implement inherited abstract class.": { "category": "Message", "code": 90007 }, @@ -3251,8 +3287,12 @@ "category": "Message", "code": 90015 }, - "Octal literal types must use ES2015 syntax. Use the syntax '0o{0}'.": { + "Octal literal types must use ES2015 syntax. Use the syntax '{0}'.": { "category": "Error", "code": 8017 + }, + "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'.": { + "category": "Error", + "code": 8018 } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 90738d828be..2ff342138c8 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -660,6 +660,8 @@ namespace ts { return emitAsExpression(node); case SyntaxKind.NonNullExpression: return emitNonNullExpression(node); + case SyntaxKind.MetaProperty: + return emitMetaProperty(node); // JSX case SyntaxKind.JsxElement: @@ -670,8 +672,6 @@ namespace ts { // Transformation nodes case SyntaxKind.PartiallyEmittedExpression: return emitPartiallyEmittedExpression(node); - case SyntaxKind.RawExpression: - return writeLines((node).text); } } @@ -1249,6 +1249,12 @@ namespace ts { write("!"); } + function emitMetaProperty(node: MetaProperty) { + writeToken(node.keywordToken, node.pos); + write("."); + emit(node.name); + } + // // Misc // @@ -1305,28 +1311,28 @@ namespace ts { writeToken(SyntaxKind.OpenParenToken, openParenPos, node); emitExpression(node.expression); writeToken(SyntaxKind.CloseParenToken, node.expression.end, node); - emitEmbeddedStatement(node.thenStatement); + emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { - writeLine(); + writeLineOrSpace(node); writeToken(SyntaxKind.ElseKeyword, node.thenStatement.end, node); if (node.elseStatement.kind === SyntaxKind.IfStatement) { write(" "); emit(node.elseStatement); } else { - emitEmbeddedStatement(node.elseStatement); + emitEmbeddedStatement(node, node.elseStatement); } } } function emitDoStatement(node: DoStatement) { write("do"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); if (isBlock(node.statement)) { write(" "); } else { - writeLine(); + writeLineOrSpace(node); } write("while ("); @@ -1338,7 +1344,7 @@ namespace ts { write("while ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForStatement(node: ForStatement) { @@ -1351,7 +1357,7 @@ namespace ts { write(";"); emitExpressionWithPrefix(" ", node.incrementor); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node: ForInStatement) { @@ -1362,7 +1368,7 @@ namespace ts { write(" in "); emitExpression(node.expression); writeToken(SyntaxKind.CloseParenToken, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node: ForOfStatement) { @@ -1373,7 +1379,7 @@ namespace ts { write(" of "); emitExpression(node.expression); writeToken(SyntaxKind.CloseParenToken, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForBinding(node: VariableDeclarationList | Expression) { @@ -1409,7 +1415,7 @@ namespace ts { write("with ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node: SwitchStatement) { @@ -1437,9 +1443,12 @@ namespace ts { function emitTryStatement(node: TryStatement) { write("try "); emit(node.tryBlock); - emit(node.catchClause); + if (node.catchClause) { + writeLineOrSpace(node); + emit(node.catchClause); + } if (node.finallyBlock) { - writeLine(); + writeLineOrSpace(node); write("finally "); emit(node.finallyBlock); } @@ -1851,6 +1860,9 @@ namespace ts { function emitJsxExpression(node: JsxExpression) { if (node.expression) { write("{"); + if (node.dotDotDotToken) { + write("..."); + } emitExpression(node.expression); write("}"); } @@ -2031,11 +2043,11 @@ namespace ts { // Skip the helper if it can be bundled but hasn't already been emitted and we // are emitting a bundled module. if (shouldBundle) { - if (bundledHelpers[helper.name]) { + if (bundledHelpers.get(helper.name)) { continue; } - bundledHelpers[helper.name] = true; + bundledHelpers.set(helper.name, true); } } else if (isBundle) { @@ -2125,8 +2137,8 @@ namespace ts { } } - function emitEmbeddedStatement(node: Statement) { - if (isBlock(node)) { + function emitEmbeddedStatement(parent: Node, node: Statement) { + if (isBlock(node) || getEmitFlags(parent) & EmitFlags.SingleLine) { write(" "); emit(node); } @@ -2291,6 +2303,15 @@ namespace ts { } } + function writeLineOrSpace(node: Node) { + if (getEmitFlags(node) & EmitFlags.SingleLine) { + write(" "); + } + else { + writeLine(); + } + } + function writeIfAny(nodes: NodeArray, text: string) { if (nodes && nodes.length > 0) { write(text); @@ -2487,15 +2508,16 @@ namespace ts { function isUniqueName(name: string): boolean { return !resolver.hasGlobalName(name) && - !hasProperty(currentFileIdentifiers, name) && - !hasProperty(generatedNameSet, name); + !currentFileIdentifiers.has(name) && + !generatedNameSet.has(name); } function isUniqueLocalName(name: string, container: Node): boolean { for (let node = container; isNodeDescendantOf(node, container); node = node.nextContainer) { - if (node.locals && hasProperty(node.locals, name)) { + if (node.locals) { + const local = node.locals.get(name); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (node.locals[name].flags & (SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias)) { + if (local && local.flags & (SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias)) { return false; } } @@ -2544,7 +2566,8 @@ namespace ts { while (true) { const generatedName = baseName + i; if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; + generatedNameSet.set(generatedName, generatedName); + return generatedName; } i++; } @@ -2571,6 +2594,13 @@ namespace ts { return makeUniqueName("class"); } + function generateNameForMethodOrAccessor(node: MethodDeclaration | AccessorDeclaration) { + if (isIdentifier(node.name)) { + return generateNameForNodeCached(node.name); + } + return makeTempVariableName(TempFlags.Auto); + } + /** * Generates a unique name from a node. * @@ -2592,6 +2622,10 @@ namespace ts { return generateNameForExportDefault(); case SyntaxKind.ClassExpression: return generateNameForClassExpression(); + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(TempFlags.Auto); } @@ -2642,6 +2676,11 @@ namespace ts { return node; } + function generateNameForNodeCached(node: Node) { + const nodeId = getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = unescapeIdentifier(generateNameForNode(node))); + } + /** * Gets the generated identifier text from a generated identifier. * @@ -2652,8 +2691,7 @@ namespace ts { // Generated names generate unique names based on their original node // and are cached based on that node's id const node = getNodeForGeneratedName(name); - const nodeId = getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = unescapeIdentifier(generateNameForNode(node))); + return generateNameForNodeCached(node); } else { // Auto, Loop, and Unique names are cached based on their unique diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 9d6773ea9d9..20e2e035af0 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -1,4 +1,4 @@ -/// +/// /// /* @internal */ @@ -1317,15 +1317,16 @@ namespace ts { return node; } - export function createJsxExpression(expression: Expression, location?: TextRange) { + export function createJsxExpression(expression: Expression, dotDotDotToken: Token, location?: TextRange) { const node = createNode(SyntaxKind.JsxExpression, location); + node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } export function updateJsxExpression(node: JsxExpression, expression: Expression) { if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node), node); + return updateNode(createJsxExpression(expression, node.dotDotDotToken, node), node); } return node; } @@ -1529,19 +1530,6 @@ namespace ts { return node; } - /** - * Creates a node that emits a string of raw text in an expression position. Raw text is never - * transformed, should be ES3 compliant, and should have the same precedence as - * PrimaryExpression. - * - * @param text The raw text of the node. - */ - export function createRawExpression(text: string) { - const node = createNode(SyntaxKind.RawExpression); - node.text = text; - return node; - } - // Compound nodes export function createComma(left: Expression, right: Expression) { @@ -1754,6 +1742,23 @@ namespace ts { // Utilities + export function restoreEnclosingLabel(node: Statement, outermostLabeledStatement: LabeledStatement, afterRestoreLabelCallback?: (node: LabeledStatement) => void): Statement { + if (!outermostLabeledStatement) { + return node; + } + const updated = updateLabel( + outermostLabeledStatement, + outermostLabeledStatement.label, + outermostLabeledStatement.statement.kind === SyntaxKind.LabeledStatement + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node + ); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + export interface CallBinding { target: LeftHandSideExpression; thisArg: Expression; @@ -2631,9 +2636,11 @@ namespace ts { return destEmitNode; } - function mergeTokenSourceMapRanges(sourceRanges: Map, destRanges: Map) { - if (!destRanges) destRanges = createMap(); - copyProperties(sourceRanges, destRanges); + function mergeTokenSourceMapRanges(sourceRanges: TextRange[], destRanges: TextRange[]) { + if (!destRanges) destRanges = []; + for (const key in sourceRanges) { + destRanges[key] = sourceRanges[key]; + } return destRanges; } @@ -2747,7 +2754,7 @@ namespace ts { */ export function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange) { const emitNode = getOrCreateEmitNode(node); - const tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = createMap()); + const tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []); tokenSourceMapRanges[token] = range; return node; } @@ -2959,10 +2966,8 @@ namespace ts { * Here we check if alternative name was provided for a given moduleName and return it if possible. */ function tryRenameExternalModule(moduleName: LiteralExpression, sourceFile: SourceFile) { - if (sourceFile.renamedDependencies && hasProperty(sourceFile.renamedDependencies, moduleName.text)) { - return createLiteral(sourceFile.renamedDependencies[moduleName.text]); - } - return undefined; + const rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text); + return rename && createLiteral(rename); } /** diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index be8f4d6f0cb..0300ff71ec5 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { @@ -15,7 +15,7 @@ namespace ts { } /** Array that is only intended to be pushed to, never read. */ - interface Push { + export interface Push { push(value: T): void; } @@ -32,7 +32,7 @@ namespace ts { * Kinds of file that we are currently looking for. * Typically there is one pass with Extensions.TypeScript, then a second pass with Extensions.JavaScript. */ - const enum Extensions { + enum Extensions { TypeScript, /** '.ts', '.tsx', or '.d.ts' */ JavaScript, /** '.js' or '.jsx' */ DtsOnly /** Only '.d.ts' */ @@ -217,9 +217,13 @@ namespace ts { return forEach(typeRoots, typeRoot => { const candidate = combinePaths(typeRoot, typeReferenceDirectiveName); const candidateDirectory = getDirectoryPath(candidate); + const directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } return resolvedTypeScriptOnly( loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, - !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + !directoryExists, moduleResolutionState)); }); } else { @@ -332,9 +336,10 @@ namespace ts { if (!moduleHasNonRelativeName(nonRelativeModuleName)) { return undefined; } - let perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + let perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); if (!perModuleNameCache) { - moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + perModuleNameCache = createPerModuleNameCache(); + moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); } return perModuleNameCache; } @@ -353,7 +358,7 @@ namespace ts { * Then it computes the set of parent folders for 'directory' that should have the same module resolution result * and for every parent folder in set it adds entry: parent -> module resolution. . * Lets say we first directory name: /a/b/c/d/e and resolution result is: /a/b/bar.ts. - * Set of parent folders that should have the same result will be: + * Set of parent folders that should have the same result will be: * [ * /a/b/c/d, /a/b/c, /a/b * ] @@ -387,7 +392,7 @@ namespace ts { } } } - + function getCommonPrefix(directory: Path, resolution: string) { if (resolution === undefined) { return undefined; @@ -417,8 +422,8 @@ namespace ts { trace(host, Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } const containingDirectory = getDirectoryPath(containingFile); - let perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); - let result = perFolderCache && perFolderCache[moduleName]; + const perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + let result = perFolderCache && perFolderCache.get(moduleName); if (result) { if (traceEnabled) { @@ -449,7 +454,7 @@ namespace ts { } if (perFolderCache) { - perFolderCache[moduleName] = result; + perFolderCache.set(moduleName, result); // put result in per-module name cache const perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); if (perModuleNameCache) { @@ -700,7 +705,7 @@ namespace ts { if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } const resolved = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. @@ -728,11 +733,33 @@ namespace ts { function nodeLoadModuleByRelativeName(extensions: Extensions, candidate: string, failedLookupLocations: Push, onlyRecordFailures: boolean, state: ModuleResolutionState): Resolved | undefined { if (state.traceEnabled) { - trace(state.host, Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - - const resolvedFromFile = !pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + const parentOfCandidate = getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + const resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + const candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } /* @internal */ @@ -791,19 +818,21 @@ namespace ts { /** Return the file if it exists. */ function tryFile(fileName: string, failedLookupLocations: Push, onlyRecordFailures: boolean, state: ModuleResolutionState): string | undefined { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, Diagnostics.File_0_does_not_exist, fileName); + else { + if (state.traceEnabled) { + trace(state.host, Diagnostics.File_0_does_not_exist, fileName); + } } - failedLookupLocations.push(fileName); - return undefined; } + failedLookupLocations.push(fileName); + return undefined; } function loadNodeModuleFromDirectory(extensions: Extensions, candidate: string, failedLookupLocations: Push, onlyRecordFailures: boolean, state: ModuleResolutionState): Resolved | undefined { @@ -824,7 +853,9 @@ namespace ts { if (resolved) { return resolved; } - trace(state.host, Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + if (state.traceEnabled) { + trace(state.host, Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } const resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures, state); if (resolved) { @@ -838,7 +869,7 @@ namespace ts { } } else { - if (state.traceEnabled) { + if (directoryExists && state.traceEnabled) { trace(state.host, Diagnostics.File_0_does_not_exist, packageJsonPath); } // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results @@ -870,9 +901,7 @@ namespace ts { return combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions: Extensions, moduleName: string, directory: string, failedLookupLocations: Push, state: ModuleResolutionState): Resolved | undefined { - const nodeModulesFolder = combinePaths(directory, "node_modules"); - const nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions: Extensions, moduleName: string, nodeModulesFolder: string, nodeModulesFolderExists: boolean, failedLookupLocations: Push, state: ModuleResolutionState): Resolved | undefined { const candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || @@ -902,12 +931,26 @@ namespace ts { /** Load a module from a single node_modules directory, but not from any ancestors' node_modules directories. */ function loadModuleFromNodeModulesOneLevel(extensions: Extensions, moduleName: string, directory: string, failedLookupLocations: Push, state: ModuleResolutionState, typesOnly = false): Resolved | undefined { - const packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + const nodeModulesFolder = combinePaths(directory, "node_modules"); + const nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + + const packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } if (extensions !== Extensions.JavaScript) { - return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, combinePaths("@types", moduleName), directory, failedLookupLocations, state); + const nodeModulesAtTypes = combinePaths(nodeModulesFolder, "@types"); + let nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes, state.host)) { + if (state.traceEnabled) { + trace(state.host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes, nodeModulesAtTypesExists, failedLookupLocations, state); } } @@ -980,7 +1023,7 @@ namespace ts { /** * Represents result of search. Normally when searching among several alternatives we treat value `undefined` as indicator - * that search fails and we should try another option. + * that search fails and we should try another option. * However this does not allow us to represent final result that should be used instead of further searching (i.e. a final result that was found in cache). * SearchResult is used to deal with this issue, its values represents following outcomes: * - undefined - not found, continue searching @@ -988,7 +1031,7 @@ namespace ts { * - { value: } - found - stop searching */ type SearchResult = { value: T | undefined } | undefined; - + /** * Wraps value to SearchResult. * @returns undefined if value is undefined or { value } otherwise diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index e47494069eb..a8fdcfd7d58 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -197,6 +197,8 @@ namespace ts { visitNode(cbNode, (node).type); case SyntaxKind.NonNullExpression: return visitNode(cbNode, (node).expression); + case SyntaxKind.MetaProperty: + return visitNode(cbNode, (node).name); case SyntaxKind.ConditionalExpression: return visitNode(cbNode, (node).condition) || visitNode(cbNode, (node).questionToken) || @@ -372,7 +374,8 @@ namespace ts { case SyntaxKind.JsxSpreadAttribute: return visitNode(cbNode, (node).expression); case SyntaxKind.JsxExpression: - return visitNode(cbNode, (node).expression); + return visitNode(cbNode, (node as JsxExpression).dotDotDotToken) || + visitNode(cbNode, (node as JsxExpression).expression); case SyntaxKind.JsxClosingElement: return visitNode(cbNode, (node).tagName); @@ -1164,7 +1167,11 @@ namespace ts { function internIdentifier(text: string): string { text = escapeIdentifier(text); - return identifiers[text] || (identifiers[text] = text); + let identifier = identifiers.get(text); + if (identifier === undefined) { + identifiers.set(text, identifier = text); + } + return identifier; } // An identifier that starts with two underscores has an extra underscore character prepended to it to avoid issues @@ -1711,8 +1718,8 @@ namespace ts { // 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 && + const methodDeclaration = node; + const nameIsConstructor = methodDeclaration.name.kind === SyntaxKind.Identifier && (methodDeclaration.name).originalKeywordKind === SyntaxKind.ConstructorKeyword; return !nameIsConstructor; @@ -2540,6 +2547,7 @@ namespace ts { case SyntaxKind.SymbolKeyword: case SyntaxKind.UndefinedKeyword: case SyntaxKind.NeverKeyword: + case SyntaxKind.ObjectKeyword: // If these are followed by a dot, then parse these out as a dotted type reference instead. const node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); @@ -2598,6 +2606,7 @@ namespace ts { case SyntaxKind.NumericLiteral: case SyntaxKind.TrueKeyword: case SyntaxKind.FalseKeyword: + case SyntaxKind.ObjectKeyword: return true; case SyntaxKind.MinusToken: return lookAhead(nextTokenIsNumericLiteral); @@ -3947,6 +3956,7 @@ namespace ts { parseExpected(SyntaxKind.OpenBraceToken); if (token() !== SyntaxKind.CloseBraceToken) { + node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { @@ -4362,15 +4372,22 @@ namespace ts { return isIdentifier() ? parseIdentifier() : undefined; } - function parseNewExpression(): NewExpression { - const node = createNode(SyntaxKind.NewExpression); + function parseNewExpression(): NewExpression | MetaProperty { + const fullStart = scanner.getStartPos(); parseExpected(SyntaxKind.NewKeyword); + if (parseOptional(SyntaxKind.DotToken)) { + const node = createNode(SyntaxKind.MetaProperty, fullStart); + node.keywordToken = SyntaxKind.NewKeyword; + node.name = parseIdentifierName(); + return finishNode(node); + } + + const node = createNode(SyntaxKind.NewExpression, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === SyntaxKind.OpenParenToken) { node.arguments = parseArgumentList(); } - return finishNode(node); } @@ -6059,6 +6076,7 @@ namespace ts { case SyntaxKind.NullKeyword: case SyntaxKind.UndefinedKeyword: case SyntaxKind.NeverKeyword: + case SyntaxKind.ObjectKeyword: return parseTokenNode(); case SyntaxKind.StringLiteral: case SyntaxKind.NumericLiteral: @@ -7437,7 +7455,7 @@ namespace ts { if (position >= array.pos && position < array.end) { // position was in this array. Search through this array to see if we find a // viable element. - for (let i = 0, n = array.length; i < n; i++) { + for (let i = 0; i < array.length; i++) { const child = array[i]; if (child) { if (child.pos === position) { diff --git a/src/compiler/performance.ts b/src/compiler/performance.ts index a48eb117e28..8c24b3b9f1b 100644 --- a/src/compiler/performance.ts +++ b/src/compiler/performance.ts @@ -27,8 +27,8 @@ namespace ts.performance { */ export function mark(markName: string) { if (enabled) { - marks[markName] = timestamp(); - counts[markName] = (counts[markName] || 0) + 1; + marks.set(markName, timestamp()); + counts.set(markName, (counts.get(markName) || 0) + 1); profilerEvent(markName); } } @@ -44,9 +44,9 @@ namespace ts.performance { */ export function measure(measureName: string, startMarkName?: string, endMarkName?: string) { if (enabled) { - const end = endMarkName && marks[endMarkName] || timestamp(); - const start = startMarkName && marks[startMarkName] || profilerStart; - measures[measureName] = (measures[measureName] || 0) + (end - start); + const end = endMarkName && marks.get(endMarkName) || timestamp(); + const start = startMarkName && marks.get(startMarkName) || profilerStart; + measures.set(measureName, (measures.get(measureName) || 0) + (end - start)); } } @@ -56,7 +56,7 @@ namespace ts.performance { * @param markName The name of the mark. */ export function getCount(markName: string) { - return counts && counts[markName] || 0; + return counts && counts.get(markName) || 0; } /** @@ -65,7 +65,7 @@ namespace ts.performance { * @param measureName The name of the measure whose durations should be accumulated. */ export function getDuration(measureName: string) { - return measures && measures[measureName] || 0; + return measures && measures.get(measureName) || 0; } /** @@ -74,9 +74,9 @@ namespace ts.performance { * @param cb The action to perform for each measure */ export function forEachMeasure(cb: (measureName: string, duration: number) => void) { - for (const key in measures) { - cb(key, measures[key]); - } + measures.forEach((measure, key) => { + cb(key, measure); + }); } /** Enables (and resets) performance measurements for the compiler. */ diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 4ab709d8455..324a21f229e 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -40,7 +40,8 @@ namespace ts { return; } - for (let i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + const n = Math.min(commonPathComponents.length, sourcePathComponents.length); + for (let i = 0; i < n; i++) { if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { if (i === 0) { // Failed to find any common path component @@ -110,11 +111,11 @@ namespace ts { } function directoryExists(directoryPath: string): boolean { - if (directoryPath in existingDirectories) { + if (existingDirectories.has(directoryPath)) { return true; } if (sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; + existingDirectories.set(directoryPath, true); return true; } return false; @@ -138,11 +139,11 @@ namespace ts { const hash = sys.createHash(data); const mtimeBefore = sys.getModifiedTime(fileName); - if (mtimeBefore && fileName in outputFingerprints) { - const fingerprint = outputFingerprints[fileName]; - + if (mtimeBefore) { + const fingerprint = outputFingerprints.get(fileName); // If output has not been changed, and the file has no external modification - if (fingerprint.byteOrderMark === writeByteOrderMark && + if (fingerprint && + fingerprint.byteOrderMark === writeByteOrderMark && fingerprint.hash === hash && fingerprint.mtime.getTime() === mtimeBefore.getTime()) { return; @@ -153,11 +154,11 @@ namespace ts { const mtimeAfter = sys.getModifiedTime(fileName); - outputFingerprints[fileName] = { + outputFingerprints.set(fileName, { hash, byteOrderMark: writeByteOrderMark, mtime: mtimeAfter - }; + }); } function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) { @@ -277,9 +278,13 @@ namespace ts { const resolutions: T[] = []; const cache = createMap(); for (const name of names) { - const result = name in cache - ? cache[name] - : cache[name] = loader(name, containingFile); + let result: T; + if (cache.has(name)) { + result = cache.get(name); + } + else { + cache.set(name, result = loader(name, containingFile)); + } resolutions.push(result); } return resolutions; @@ -459,7 +464,7 @@ namespace ts { classifiableNames = createMap(); for (const sourceFile of files) { - copyProperties(sourceFile.classifiableNames, classifiableNames); + copyEntries(sourceFile.classifiableNames, classifiableNames); } } @@ -700,7 +705,7 @@ namespace ts { } // update fileName -> file mapping - for (let i = 0, len = newSourceFiles.length; i < len; i++) { + for (let i = 0; i < newSourceFiles.length; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } @@ -734,7 +739,7 @@ namespace ts { } function isSourceFileFromExternalLibrary(file: SourceFile): boolean { - return sourceFilesFoundSearchingNodeModules[file.path]; + return sourceFilesFoundSearchingNodeModules.get(file.path); } function getDiagnosticsProducingTypeChecker() { @@ -957,7 +962,7 @@ namespace ts { } break; case SyntaxKind.HeritageClause: - let heritageClause = node; + const heritageClause = node; if (heritageClause.token === SyntaxKind.ImplementsKeyword) { diagnostics.push(createDiagnosticForNode(node, Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; @@ -976,7 +981,7 @@ namespace ts { diagnostics.push(createDiagnosticForNode(node, Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; case SyntaxKind.TypeAssertionExpression: - let typeAssertionExpression = node; + const typeAssertionExpression = node; diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; } @@ -1175,7 +1180,7 @@ namespace ts { case SyntaxKind.ImportDeclaration: case SyntaxKind.ImportEqualsDeclaration: case SyntaxKind.ExportDeclaration: - let moduleNameExpr = getExternalModuleName(node); + const moduleNameExpr = getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== SyntaxKind.StringLiteral) { break; } @@ -1297,20 +1302,20 @@ namespace ts { // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file && sourceFilesFoundSearchingNodeModules[file.path] && currentNodeModulesDepth == 0) { - sourceFilesFoundSearchingNodeModules[file.path] = false; + if (file && sourceFilesFoundSearchingNodeModules.get(file.path) && currentNodeModulesDepth == 0) { + sourceFilesFoundSearchingNodeModules.set(file.path, false); if (!options.noResolve) { processReferencedFiles(file, isDefaultLib); processTypeReferenceDirectives(file); } - modulesWithElidedImports[file.path] = false; + modulesWithElidedImports.set(file.path, false); processImportedModules(file); } // See if we need to reprocess the imports due to prior skipped imports - else if (file && modulesWithElidedImports[file.path]) { + else if (file && modulesWithElidedImports.get(file.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports[file.path] = false; + modulesWithElidedImports.set(file.path, false); processImportedModules(file); } } @@ -1331,7 +1336,7 @@ namespace ts { filesByName.set(path, file); if (file) { - sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0); + sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; if (host.useCaseSensitiveFileNames()) { @@ -1392,7 +1397,7 @@ namespace ts { refFile?: SourceFile, refPos?: number, refEnd?: number): void { // If we already found this library as a primary reference - nothing to do - const previousResolution = resolvedTypeReferenceDirectives[typeReferenceDirective]; + const previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { return; } @@ -1432,7 +1437,7 @@ namespace ts { } if (saveResolution) { - resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective; + resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); } } @@ -1485,7 +1490,7 @@ namespace ts { const shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { - modulesWithElidedImports[file.path] = true; + modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { const path = toPath(resolvedFileName, currentDirectory, getCanonicalFileName); diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 82302e98e37..52c75a37005 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -56,7 +56,7 @@ namespace ts { tryScan(callback: () => T): T; } - const textToToken = createMap({ + const textToToken = createMapFromTemplate({ "abstract": SyntaxKind.AbstractKeyword, "any": SyntaxKind.AnyKeyword, "as": SyntaxKind.AsKeyword, @@ -98,6 +98,7 @@ namespace ts { "new": SyntaxKind.NewKeyword, "null": SyntaxKind.NullKeyword, "number": SyntaxKind.NumberKeyword, + "object": SyntaxKind.ObjectKeyword, "package": SyntaxKind.PackageKeyword, "private": SyntaxKind.PrivateKeyword, "protected": SyntaxKind.ProtectedKeyword, @@ -275,9 +276,9 @@ namespace ts { function makeReverseMap(source: Map): string[] { const result: string[] = []; - for (const name in source) { - result[source[name]] = name; - } + source.forEach((value, name) => { + result[value] = name; + }); return result; } @@ -289,7 +290,7 @@ namespace ts { /* @internal */ export function stringToToken(s: string): SyntaxKind { - return textToToken[s]; + return textToToken.get(s); } /* @internal */ @@ -363,8 +364,6 @@ namespace ts { return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } - const hasOwnProperty = Object.prototype.hasOwnProperty; - export function isWhiteSpace(ch: number): boolean { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } @@ -531,7 +530,7 @@ namespace ts { const ch = text.charCodeAt(pos); if ((pos + mergeConflictMarkerLength) < text.length) { - for (let i = 0, n = mergeConflictMarkerLength; i < n; i++) { + for (let i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -643,7 +642,7 @@ namespace ts { pos++; continue; case CharacterCodes.slash: - let nextChar = text.charCodeAt(pos + 1); + const nextChar = text.charCodeAt(pos + 1); let hasTrailingNewLine = false; if (nextChar === CharacterCodes.slash || nextChar === CharacterCodes.asterisk) { const kind = nextChar === CharacterCodes.slash ? SyntaxKind.SingleLineCommentTrivia : SyntaxKind.MultiLineCommentTrivia; @@ -733,11 +732,11 @@ namespace ts { return comments; } - export function getLeadingCommentRanges(text: string, pos: number): CommentRange[] { + export function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined { return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined); } - export function getTrailingCommentRanges(text: string, pos: number): CommentRange[] { + export function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined { return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined); } @@ -766,7 +765,7 @@ namespace ts { return false; } - for (let i = 1, n = name.length; i < n; i++) { + for (let i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -1183,8 +1182,11 @@ namespace ts { const len = tokenValue.length; if (len >= 2 && len <= 11) { const ch = tokenValue.charCodeAt(0); - if (ch >= CharacterCodes.a && ch <= CharacterCodes.z && hasOwnProperty.call(textToToken, tokenValue)) { - return token = textToToken[tokenValue]; + if (ch >= CharacterCodes.a && ch <= CharacterCodes.z) { + token = textToToken.get(tokenValue); + if (token !== undefined) { + return token; + } } } return token = SyntaxKind.Identifier; @@ -1563,7 +1565,7 @@ namespace ts { pos++; return token = SyntaxKind.AtToken; case CharacterCodes.backslash: - let cookedChar = peekUnicodeEscape(); + const cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index a1e82a66595..3c28efd0de8 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -1,4 +1,4 @@ -/// +/// namespace ts { export type FileWatcherCallback = (fileName: string, removed?: boolean) => void; @@ -18,7 +18,7 @@ namespace ts { getFileSize?(path: string): number; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; /** - * @pollingInterval - this parameter is used in polling-based watchers and ignored in watchers that + * @pollingInterval - this parameter is used in polling-based watchers and ignored in watchers that * use native OS file watching */ watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; @@ -160,7 +160,7 @@ namespace ts { function getNames(collection: any): string[] { const result: string[] = []; - for (let e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { + for (const e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { result.push(e.item().Name); } return result.sort(); @@ -243,23 +243,23 @@ namespace ts { function createWatchedFileSet() { const dirWatchers = createMap(); // One file can have multiple watchers - const fileWatcherCallbacks = createMap(); + const fileWatcherCallbacks = createMultiMap(); return { addFile, removeFile }; function reduceDirWatcherRefCountForFile(fileName: string) { const dirName = getDirectoryPath(fileName); - const watcher = dirWatchers[dirName]; + const watcher = dirWatchers.get(dirName); if (watcher) { watcher.referenceCount -= 1; if (watcher.referenceCount <= 0) { watcher.close(); - delete dirWatchers[dirName]; + dirWatchers.delete(dirName); } } } function addDirWatcher(dirPath: string): void { - let watcher = dirWatchers[dirPath]; + let watcher = dirWatchers.get(dirPath); if (watcher) { watcher.referenceCount += 1; return; @@ -270,12 +270,12 @@ namespace ts { (eventName: string, relativeFileName: string) => fileEventHandler(eventName, relativeFileName, dirPath) ); watcher.referenceCount = 1; - dirWatchers[dirPath] = watcher; + dirWatchers.set(dirPath, watcher); return; } function addFileWatcherCallback(filePath: string, callback: FileWatcherCallback): void { - multiMapAdd(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.add(filePath, callback); } function addFile(fileName: string, callback: FileWatcherCallback): WatchedFile { @@ -291,7 +291,7 @@ namespace ts { } function removeFileWatcherCallback(filePath: string, callback: FileWatcherCallback) { - multiMapRemove(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.remove(filePath, callback); } function fileEventHandler(eventName: string, relativeFileName: string, baseDirPath: string) { @@ -300,9 +300,12 @@ namespace ts { ? undefined : ts.getNormalizedAbsolutePath(relativeFileName, baseDirPath); // Some applications save a working file via rename operations - if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks[fileName]) { - for (const fileCallback of fileWatcherCallbacks[fileName]) { - fileCallback(fileName); + if ((eventName === "change" || eventName === "rename")) { + const callbacks = fileWatcherCallbacks.get(fileName); + if (callbacks) { + for (const fileCallback of callbacks) { + fileCallback(fileName); + } } } } diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 0f241f3ef75..33a20d187eb 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -14,14 +14,16 @@ /* @internal */ namespace ts { - const moduleTransformerMap = createMap({ - [ModuleKind.ES2015]: transformES2015Module, - [ModuleKind.System]: transformSystemModule, - [ModuleKind.AMD]: transformModule, - [ModuleKind.CommonJS]: transformModule, - [ModuleKind.UMD]: transformModule, - [ModuleKind.None]: transformModule, - }); + function getModuleTransformer(moduleKind: ModuleKind): Transformer { + switch (moduleKind) { + case ModuleKind.ES2015: + return transformES2015Module; + case ModuleKind.System: + return transformSystemModule; + default: + return transformModule; + } + } const enum SyntaxKindFeatureFlags { Substitution = 1 << 0, @@ -57,7 +59,7 @@ namespace ts { transformers.push(transformGenerators); } - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ModuleKind.None]); + transformers.push(getModuleTransformer(moduleKind)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 5dae1da7b74..d0b9ef7455f 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -162,6 +162,104 @@ namespace ts { ReplaceWithReturn, } + type LoopConverter = (node: IterationStatement, outermostLabeledStatement: LabeledStatement, convertedLoopBodyStatements: Statement[]) => Statement; + + // Facts we track as we traverse the tree + const enum HierarchyFacts { + None = 0, + + // + // Ancestor facts + // + + Function = 1 << 0, // Enclosed in a non-arrow function + ArrowFunction = 1 << 1, // Enclosed in an arrow function + AsyncFunctionBody = 1 << 2, // Enclosed in an async function body + NonStaticClassElement = 1 << 3, // Enclosed in a non-static, non-async class element + CapturesThis = 1 << 4, // Enclosed in a function that captures the lexical 'this' (used in substitution) + ExportedVariableStatement = 1 << 5, // Enclosed in an exported variable statement in the current scope + TopLevel = 1 << 6, // Enclosing block-scoped container is a top-level container + Block = 1 << 7, // Enclosing block-scoped container is a Block + IterationStatement = 1 << 8, // Enclosed in an IterationStatement + IterationStatementBlock = 1 << 9, // Enclosing Block is enclosed in an IterationStatement + ForStatement = 1 << 10, // Enclosing block-scoped container is a ForStatement + ForInOrForOfStatement = 1 << 11, // Enclosing block-scoped container is a ForInStatement or ForOfStatement + ConstructorWithCapturedSuper = 1 << 12, // Enclosed in a constructor that captures 'this' for use with 'super' + ComputedPropertyName = 1 << 13, // Enclosed in a computed property name + // NOTE: do not add more ancestor flags without also updating AncestorFactsMask below. + + // + // Ancestor masks + // + + AncestorFactsMask = (ComputedPropertyName << 1) - 1, + + // We are always in *some* kind of block scope, but only specific block-scope containers are + // top-level or Blocks. + BlockScopeIncludes = None, + BlockScopeExcludes = TopLevel | Block | IterationStatement | IterationStatementBlock | ForStatement | ForInOrForOfStatement, + + // A source file is a top-level block scope. + SourceFileIncludes = TopLevel, + SourceFileExcludes = BlockScopeExcludes & ~TopLevel, + + // Functions, methods, and accessors are both new lexical scopes and new block scopes. + FunctionIncludes = Function | TopLevel, + FunctionExcludes = BlockScopeExcludes & ~TopLevel | ArrowFunction | AsyncFunctionBody | CapturesThis | NonStaticClassElement | ConstructorWithCapturedSuper | ComputedPropertyName, + + AsyncFunctionBodyIncludes = FunctionIncludes | AsyncFunctionBody, + AsyncFunctionBodyExcludes = FunctionExcludes & ~NonStaticClassElement, + + // Arrow functions are lexically scoped to their container, but are new block scopes. + ArrowFunctionIncludes = ArrowFunction | TopLevel, + ArrowFunctionExcludes = BlockScopeExcludes & ~TopLevel | ConstructorWithCapturedSuper | ComputedPropertyName, + + // Constructors are both new lexical scopes and new block scopes. Constructors are also + // always considered non-static members of a class. + ConstructorIncludes = FunctionIncludes | NonStaticClassElement, + ConstructorExcludes = FunctionExcludes & ~NonStaticClassElement, + + // 'do' and 'while' statements are not block scopes. We track that the subtree is contained + // within an IterationStatement to indicate whether the embedded statement is an + // IterationStatementBlock. + DoOrWhileStatementIncludes = IterationStatement, + DoOrWhileStatementExcludes = None, + + // 'for' statements are new block scopes and have special handling for 'let' declarations. + ForStatementIncludes = IterationStatement | ForStatement, + ForStatementExcludes = BlockScopeExcludes & ~ForStatement, + + // 'for-in' and 'for-of' statements are new block scopes and have special handling for + // 'let' declarations. + ForInOrForOfStatementIncludes = IterationStatement | ForInOrForOfStatement, + ForInOrForOfStatementExcludes = BlockScopeExcludes & ~ForInOrForOfStatement, + + // Blocks (other than function bodies) are new block scopes. + BlockIncludes = Block, + BlockExcludes = BlockScopeExcludes & ~Block, + + IterationStatementBlockIncludes = IterationStatementBlock, + IterationStatementBlockExcludes = BlockScopeExcludes, + + // Computed property names track subtree flags differently than their containing members. + ComputedPropertyNameIncludes = ComputedPropertyName, + ComputedPropertyNameExcludes = None, + + // + // Subtree facts + // + NewTarget = 1 << 14, // Contains a 'new.target' meta-property + NewTargetInComputedPropertyName = 1 << 15, // Contains a 'new.target' meta-property in a computed property name. + + + // + // Subtree masks + // + + SubtreeFactsMask = ~AncestorFactsMask, + PropagateNewTargetMask = NewTarget | NewTargetInComputedPropertyName, + } + export function transformES2015(context: TransformationContext) { const { startLexicalEnvironment, @@ -178,15 +276,7 @@ namespace ts { let currentSourceFile: SourceFile; let currentText: string; - let currentParent: Node; - let currentNode: Node; - let enclosingVariableStatement: VariableStatement; - let enclosingBlockScopeContainer: Node; - let enclosingBlockScopeContainerParent: Node; - let enclosingFunction: FunctionLikeDeclaration; - let enclosingNonArrowFunction: FunctionLikeDeclaration; - let enclosingNonAsyncFunctionBody: FunctionLikeDeclaration | ClassElement; - let isInConstructorWithCapturedSuper: boolean; + let hierarchyFacts: HierarchyFacts; /** * Used to track if we are emitting body of the converted loop @@ -210,166 +300,71 @@ namespace ts { currentSourceFile = node; currentText = node.text; - const visited = saveStateAndInvoke(node, visitSourceFile); + const visited = visitSourceFile(node); addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined; currentText = undefined; + hierarchyFacts = HierarchyFacts.None; return visited; } - function visitor(node: Node): VisitResult { - return saveStateAndInvoke(node, dispatcher); + /** + * Sets the `HierarchyFacts` for this node prior to visiting this node's subtree, returning the facts set prior to modification. + * @param excludeFacts The existing `HierarchyFacts` to reset before visiting the subtree. + * @param includeFacts The new `HierarchyFacts` to set before visiting the subtree. + **/ + function enterSubtree(excludeFacts: HierarchyFacts, includeFacts: HierarchyFacts) { + const ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & HierarchyFacts.AncestorFactsMask; + return ancestorFacts; } - function dispatcher(node: Node): VisitResult { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - - function saveStateAndInvoke(node: T, f: (node: T) => U): U { - const savedEnclosingFunction = enclosingFunction; - const savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - const savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - const savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - const savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - const savedEnclosingVariableStatement = enclosingVariableStatement; - const savedCurrentParent = currentParent; - const savedCurrentNode = currentNode; - const savedConvertedLoopState = convertedLoopState; - const savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; - if (nodeStartsNewLexicalEnvironment(node)) { - // don't treat content of nodes that start new lexical environment as part of converted loop copy or constructor body - isInConstructorWithCapturedSuper = false; - convertedLoopState = undefined; - } - - onBeforeVisitNode(node); - const visited = f(node); - - isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - - function onBeforeVisitNode(node: Node) { - if (currentNode) { - if (isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - - if (isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== SyntaxKind.ArrowFunction) { - enclosingNonArrowFunction = currentNode; - if (!(getEmitFlags(currentNode) & EmitFlags.AsyncFunctionBody)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - - // keep track of the enclosing variable statement when in the context of - // variable statements, variable declarations, binding elements, and binding - // patterns. - switch (currentNode.kind) { - case SyntaxKind.VariableStatement: - enclosingVariableStatement = currentNode; - break; - - case SyntaxKind.VariableDeclarationList: - case SyntaxKind.VariableDeclaration: - case SyntaxKind.BindingElement: - case SyntaxKind.ObjectBindingPattern: - case SyntaxKind.ArrayBindingPattern: - break; - - default: - enclosingVariableStatement = undefined; - } - } - - currentParent = currentNode; - currentNode = node; - } - - function returnCapturedThis(node: Node): Node { - return setOriginalNode(createReturn(createIdentifier("_this")), node); + /** + * Restores the `HierarchyFacts` for this node's ancestor after visiting this node's + * subtree, propagating specific facts from the subtree. + * @param ancestorFacts The `HierarchyFacts` of the ancestor to restore after visiting the subtree. + * @param excludeFacts The existing `HierarchyFacts` of the subtree that should not be propagated. + * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. + **/ + function exitSubtree(ancestorFacts: HierarchyFacts, excludeFacts: HierarchyFacts, includeFacts: HierarchyFacts) { + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & HierarchyFacts.SubtreeFactsMask | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node: Node): boolean { - return isInConstructorWithCapturedSuper && node.kind === SyntaxKind.ReturnStatement && !(node).expression; + return hierarchyFacts & HierarchyFacts.ConstructorWithCapturedSuper + && node.kind === SyntaxKind.ReturnStatement + && !(node).expression; } - function shouldCheckNode(node: Node): boolean { - return (node.transformFlags & TransformFlags.ES2015) !== 0 || - node.kind === SyntaxKind.LabeledStatement || - (isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); + function shouldVisitNode(node: Node): boolean { + return (node.transformFlags & TransformFlags.ContainsES2015) !== 0 + || convertedLoopState !== undefined + || (hierarchyFacts & HierarchyFacts.ConstructorWithCapturedSuper && isStatement(node)) + || (isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); } - function visitorWorker(node: Node): VisitResult { - if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { - return returnCapturedThis(node); - } - else if (shouldCheckNode(node)) { + function visitor(node: Node): VisitResult { + if (shouldVisitNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & TransformFlags.ContainsES2015 || (isInConstructorWithCapturedSuper && !isExpression(node))) { - // we want to dive in this branch either if node has children with ES2015 specific syntax - // or we are inside constructor that captures result of the super call so all returns without expression should be - // rewritten. Note: we skip expressions since returns should never appear there - return visitEachChild(node, visitor, context); - } else { return node; } } - function visitorForConvertedLoopWorker(node: Node): VisitResult { - let result: VisitResult; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function functionBodyVisitor(node: Block): Block { + if (shouldVisitNode(node)) { + return visitBlock(node, /*isFunctionBody*/ true); } - else { - result = visitNodesInConvertedLoop(node); - } - return result; + return node; } - function visitNodesInConvertedLoop(node: Node): VisitResult { - switch (node.kind) { - case SyntaxKind.ReturnStatement: - node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; - return visitReturnStatement(node); - - case SyntaxKind.VariableStatement: - return visitVariableStatement(node); - - case SyntaxKind.SwitchStatement: - return visitSwitchStatement(node); - - case SyntaxKind.BreakStatement: - case SyntaxKind.ContinueStatement: - return visitBreakOrContinueStatement(node); - - case SyntaxKind.ThisKeyword: - return visitThisKeyword(node); - - case SyntaxKind.Identifier: - return visitIdentifier(node); - - default: - return visitEachChild(node, visitor, context); + function callExpressionVisitor(node: Node): VisitResult { + if (node.kind === SyntaxKind.SuperKeyword) { + return visitSuperKeyword(/*isExpressionOfCall*/ true); } + return visitor(node); } function visitJavaScript(node: Node): VisitResult { @@ -404,23 +399,34 @@ namespace ts { case SyntaxKind.VariableDeclarationList: return visitVariableDeclarationList(node); + case SyntaxKind.SwitchStatement: + return visitSwitchStatement(node); + + case SyntaxKind.CaseBlock: + return visitCaseBlock(node); + + case SyntaxKind.Block: + return visitBlock(node, /*isFunctionBody*/ false); + + case SyntaxKind.BreakStatement: + case SyntaxKind.ContinueStatement: + return visitBreakOrContinueStatement(node); + case SyntaxKind.LabeledStatement: return visitLabeledStatement(node); case SyntaxKind.DoStatement: - return visitDoStatement(node); - case SyntaxKind.WhileStatement: - return visitWhileStatement(node); + return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); case SyntaxKind.ForStatement: - return visitForStatement(node); + return visitForStatement(node, /*outermostLabeledStatement*/ undefined); case SyntaxKind.ForInStatement: - return visitForInStatement(node); + return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); case SyntaxKind.ForOfStatement: - return visitForOfStatement(node); + return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); case SyntaxKind.ExpressionStatement: return visitExpressionStatement(node); @@ -434,6 +440,9 @@ namespace ts { case SyntaxKind.ShorthandPropertyAssignment: return visitShorthandPropertyAssignment(node); + case SyntaxKind.ComputedPropertyName: + return visitComputedPropertyName(node); + case SyntaxKind.ArrayLiteralExpression: return visitArrayLiteralExpression(node); @@ -468,31 +477,41 @@ namespace ts { return visitSpreadElement(node); case SyntaxKind.SuperKeyword: - return visitSuperKeyword(); + return visitSuperKeyword(/*isExpressionOfCall*/ false); - case SyntaxKind.YieldExpression: - // `yield` will be handled by a generators transform. - return visitEachChild(node, visitor, context); + case SyntaxKind.ThisKeyword: + return visitThisKeyword(node); + + case SyntaxKind.MetaProperty: + return visitMetaProperty(node); case SyntaxKind.MethodDeclaration: return visitMethodDeclaration(node); + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + return visitAccessorDeclaration(node); + case SyntaxKind.VariableStatement: return visitVariableStatement(node); + case SyntaxKind.ReturnStatement: + return visitReturnStatement(node); + default: - Debug.failBadSyntaxKind(node); return visitEachChild(node, visitor, context); } } function visitSourceFile(node: SourceFile): SourceFile { + const ancestorFacts = enterSubtree(HierarchyFacts.SourceFileExcludes, HierarchyFacts.SourceFileIncludes); const statements: Statement[] = []; startLexicalEnvironment(); const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ false, visitor); addCaptureThisForNodeIfNeeded(statements, node); addRange(statements, visitNodes(node.statements, visitor, isStatement, statementOffset)); addRange(statements, endLexicalEnvironment()); + exitSubtree(ancestorFacts, HierarchyFacts.None, HierarchyFacts.None); return updateSourceFileNode( node, createNodeArray(statements, node.statements) @@ -500,44 +519,63 @@ namespace ts { } function visitSwitchStatement(node: SwitchStatement): SwitchStatement { - Debug.assert(convertedLoopState !== undefined); + if (convertedLoopState !== undefined) { + const savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + // for switch statement allow only non-labeled break + convertedLoopState.allowedNonLabeledJumps |= Jump.Break; + const result = visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + return visitEachChild(node, visitor, context); + } - const savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= Jump.Break; + function visitCaseBlock(node: CaseBlock): CaseBlock { + const ancestorFacts = enterSubtree(HierarchyFacts.BlockScopeExcludes, HierarchyFacts.BlockScopeIncludes); + const updated = visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, HierarchyFacts.None, HierarchyFacts.None); + return updated; + } - const result = visitEachChild(node, visitor, context); - - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; + function returnCapturedThis(node: Node): ReturnStatement { + return setOriginalNode(createReturn(createIdentifier("_this")), node); } function visitReturnStatement(node: ReturnStatement): Statement { - Debug.assert(convertedLoopState !== undefined); - - convertedLoopState.nonLocalJumps |= Jump.Return; - return createReturn( - createObjectLiteral( - [ - createPropertyAssignment( - createIdentifier("value"), - node.expression - ? visitNode(node.expression, visitor, isExpression) - : createVoidZero() - ) - ] - ) - ); + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= Jump.Return; + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + node = returnCapturedThis(node); + } + return createReturn( + createObjectLiteral( + [ + createPropertyAssignment( + createIdentifier("value"), + node.expression + ? visitNode(node.expression, visitor, isExpression) + : createVoidZero() + ) + ] + ) + ); + } + else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + return visitEachChild(node, visitor, context); } function visitThisKeyword(node: Node): Node { - Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === SyntaxKind.ArrowFunction) { - // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. - convertedLoopState.containsLexicalThis = true; - return node; + if (convertedLoopState) { + if (hierarchyFacts & HierarchyFacts.ArrowFunction) { + // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword. + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = createUniqueName("this")); } - return convertedLoopState.thisName || (convertedLoopState.thisName = createUniqueName("this")); + return node; } function visitIdentifier(node: Identifier): Identifier { @@ -561,7 +599,7 @@ namespace ts { // - break/continue is non-labeled and located in non-converted loop/switch statement const jump = node.kind === SyntaxKind.BreakStatement ? Jump.Break : Jump.Continue; const canUseBreakOrContinue = - (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { @@ -811,9 +849,11 @@ namespace ts { * @param extendsClauseElement The expression for the class `extends` clause. */ function addConstructor(statements: Statement[], node: ClassExpression | ClassDeclaration, extendsClauseElement: ExpressionWithTypeArguments): void { + const savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + const ancestorFacts = enterSubtree(HierarchyFacts.ConstructorExcludes, HierarchyFacts.ConstructorIncludes); const constructor = getFirstConstructorWithBody(node); const hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - const constructorFunction = createFunctionDeclaration( /*decorators*/ undefined, @@ -830,7 +870,10 @@ namespace ts { if (extendsClauseElement) { setEmitFlags(constructorFunction, EmitFlags.CapturesThis); } + statements.push(constructorFunction); + exitSubtree(ancestorFacts, HierarchyFacts.PropagateNewTargetMask, HierarchyFacts.None); + convertedLoopState = savedConvertedLoopState; } /** @@ -882,7 +925,10 @@ namespace ts { } - const superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + // determine whether the class is known syntactically to be a derived class (e.g. a + // class that extends a value that is not syntactically known to be `null`). + const isDerivedClass = extendsClauseElement && skipOuterExpressions(extendsClauseElement.expression).kind !== SyntaxKind.NullKeyword; + const superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === SuperCaptureResult.ReplaceSuperCapture || superCaptureStatus === SuperCaptureResult.ReplaceWithReturn) { @@ -890,16 +936,16 @@ namespace ts { } if (constructor) { - const body = saveStateAndInvoke(constructor, constructor => { - isInConstructorWithCapturedSuper = superCaptureStatus === SuperCaptureResult.ReplaceSuperCapture; - return visitNodes(constructor.body.statements, visitor, isStatement, /*start*/ statementOffset); - }); - addRange(statements, body); + if (superCaptureStatus === SuperCaptureResult.ReplaceSuperCapture) { + hierarchyFacts |= HierarchyFacts.ConstructorWithCapturedSuper; + } + + addRange(statements, visitNodes(constructor.body.statements, visitor, isStatement, /*start*/ statementOffset)); } // Return `_this` unless we're sure enough that it would be pointless to add a return statement. // If there's a constructor that we can tell returns in enough places, then we *do not* want to add a return. - if (extendsClauseElement + if (isDerivedClass && superCaptureStatus !== SuperCaptureResult.ReplaceWithReturn && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push( @@ -910,6 +956,11 @@ namespace ts { } addRange(statements, endLexicalEnvironment()); + + if (constructor) { + prependCaptureNewTargetIfNeeded(statements, constructor, /*copyOnWrite*/ false); + } + const block = createBlock( createNodeArray( statements, @@ -963,11 +1014,11 @@ namespace ts { function declareOrCaptureOrReturnThisForConstructorIfNeeded( statements: Statement[], ctor: ConstructorDeclaration | undefined, - hasExtendsClause: boolean, + isDerivedClass: boolean, hasSynthesizedSuper: boolean, statementOffset: number) { // If this isn't a derived class, just capture 'this' for arrow functions if necessary. - if (!hasExtendsClause) { + if (!isDerivedClass) { if (ctor) { addCaptureThisForNodeIfNeeded(statements, ctor); } @@ -1016,11 +1067,7 @@ namespace ts { firstStatement = ctorStatements[statementOffset]; if (firstStatement.kind === SyntaxKind.ExpressionStatement && isSuperCall((firstStatement as ExpressionStatement).expression)) { - const superCall = (firstStatement as ExpressionStatement).expression as CallExpression; - superCallExpression = setOriginalNode( - saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), - superCall - ); + superCallExpression = visitImmediateSuperCallInBody((firstStatement as ExpressionStatement).expression as CallExpression); } } @@ -1047,7 +1094,7 @@ namespace ts { } // Perform the capture. - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); // If we're actually replacing the original statement, we need to signal this to the caller. if (superCallExpression) { @@ -1057,15 +1104,25 @@ namespace ts { return SuperCaptureResult.NoReplacement; } + function createActualThis() { + return setEmitFlags(createThis(), EmitFlags.NoSubstitution); + } + function createDefaultSuperCallOrThis() { - const actualThis = createThis(); - setEmitFlags(actualThis, EmitFlags.NoSubstitution); - const superCall = createFunctionApply( - createIdentifier("_super"), - actualThis, - createIdentifier("arguments"), + return createLogicalOr( + createLogicalAnd( + createStrictInequality( + createIdentifier("_super"), + createNull() + ), + createFunctionApply( + createIdentifier("_super"), + createActualThis(), + createIdentifier("arguments"), + ) + ), + createActualThis() ); - return createLogicalOr(superCall, actualThis); } /** @@ -1357,6 +1414,77 @@ namespace ts { statements.push(captureThisStatement); } + function prependCaptureNewTargetIfNeeded(statements: Statement[], node: FunctionLikeDeclaration, copyOnWrite: boolean): Statement[] { + if (hierarchyFacts & HierarchyFacts.NewTarget) { + let newTarget: Expression; + switch (node.kind) { + case SyntaxKind.ArrowFunction: + return statements; + + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + // Methods and accessors cannot be constructors, so 'new.target' will + // always return 'undefined'. + newTarget = createVoidZero(); + break; + + case SyntaxKind.Constructor: + // Class constructors can only be called with `new`, so `this.constructor` + // should be relatively safe to use. + newTarget = createPropertyAccess( + setEmitFlags(createThis(), EmitFlags.NoSubstitution), + "constructor" + ); + break; + + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + // Functions can be called or constructed, and may have a `this` due to + // being a member or when calling an imported function via `other_1.f()`. + newTarget = createConditional( + createLogicalAnd( + setEmitFlags(createThis(), EmitFlags.NoSubstitution), + createBinary( + setEmitFlags(createThis(), EmitFlags.NoSubstitution), + SyntaxKind.InstanceOfKeyword, + getLocalName(node) + ) + ), + createPropertyAccess( + setEmitFlags(createThis(), EmitFlags.NoSubstitution), + "constructor" + ), + createVoidZero() + ); + break; + + default: + Debug.failBadSyntaxKind(node); + break; + } + + const captureNewTargetStatement = createVariableStatement( + /*modifiers*/ undefined, + createVariableDeclarationList([ + createVariableDeclaration( + "_newTarget", + /*type*/ undefined, + newTarget + ) + ]) + ); + + if (copyOnWrite) { + return [captureNewTargetStatement, ...statements]; + } + + statements.unshift(captureNewTargetStatement); + } + + return statements; + } + /** * Adds statements to the class body function for a class to define the members of the * class. @@ -1372,14 +1500,14 @@ namespace ts { break; case SyntaxKind.MethodDeclaration: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: const accessors = getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; @@ -1410,11 +1538,12 @@ namespace ts { * @param receiver The receiver for the member. * @param member The MethodDeclaration node. */ - function transformClassMethodDeclarationToStatement(receiver: LeftHandSideExpression, member: MethodDeclaration) { + function transformClassMethodDeclarationToStatement(receiver: LeftHandSideExpression, member: MethodDeclaration, container: Node) { + const ancestorFacts = enterSubtree(HierarchyFacts.None, HierarchyFacts.None); const commentRange = getCommentRange(member); const sourceMapRange = getSourceMapRange(member); const memberName = createMemberAccessForPropertyName(receiver, visitNode(member.name, visitor, isPropertyName), /*location*/ member.name); - const memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined); + const memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); setEmitFlags(memberFunction, EmitFlags.NoComments); setSourceMapRange(memberFunction, sourceMapRange); @@ -1430,6 +1559,8 @@ namespace ts { // No source map should be emitted for this statement to align with the // old emitter. setEmitFlags(statement, EmitFlags.NoSourceMap); + + exitSubtree(ancestorFacts, HierarchyFacts.PropagateNewTargetMask, hierarchyFacts & HierarchyFacts.PropagateNewTargetMask ? HierarchyFacts.NewTarget : HierarchyFacts.None); return statement; } @@ -1439,9 +1570,9 @@ namespace ts { * @param receiver The receiver for the member. * @param accessors The set of related get/set accessors. */ - function transformAccessorsToStatement(receiver: LeftHandSideExpression, accessors: AllAccessorDeclarations): Statement { + function transformAccessorsToStatement(receiver: LeftHandSideExpression, accessors: AllAccessorDeclarations, container: Node): Statement { const statement = createStatement( - transformAccessorsToExpression(receiver, accessors, /*startsOnNewLine*/ false), + transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false), /*location*/ getSourceMapRange(accessors.firstAccessor) ); @@ -1458,7 +1589,9 @@ namespace ts { * * @param receiver The receiver for the member. */ - function transformAccessorsToExpression(receiver: LeftHandSideExpression, { firstAccessor, getAccessor, setAccessor }: AllAccessorDeclarations, startsOnNewLine: boolean): Expression { + function transformAccessorsToExpression(receiver: LeftHandSideExpression, { firstAccessor, getAccessor, setAccessor }: AllAccessorDeclarations, container: Node, startsOnNewLine: boolean): Expression { + const ancestorFacts = enterSubtree(HierarchyFacts.None, HierarchyFacts.None); + // To align with source maps in the old emitter, the receiver and property name // arguments are both mapped contiguously to the accessor name. const target = getMutableClone(receiver); @@ -1471,7 +1604,7 @@ namespace ts { const properties: ObjectLiteralElementLike[] = []; if (getAccessor) { - const getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); + const getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); setSourceMapRange(getterFunction, getSourceMapRange(getAccessor)); setEmitFlags(getterFunction, EmitFlags.NoLeadingComments); const getter = createPropertyAssignment("get", getterFunction); @@ -1480,7 +1613,7 @@ namespace ts { } if (setAccessor) { - const setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); + const setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); setSourceMapRange(setterFunction, getSourceMapRange(setAccessor)); setEmitFlags(setterFunction, EmitFlags.NoLeadingComments); const setter = createPropertyAssignment("set", setterFunction); @@ -1505,6 +1638,8 @@ namespace ts { if (startsOnNewLine) { call.startsOnNewLine = true; } + + exitSubtree(ancestorFacts, HierarchyFacts.PropagateNewTargetMask, hierarchyFacts & HierarchyFacts.PropagateNewTargetMask ? HierarchyFacts.NewTarget : HierarchyFacts.None); return call; } @@ -1517,6 +1652,9 @@ namespace ts { if (node.transformFlags & TransformFlags.ContainsLexicalThis) { enableSubstitutionsForCapturedThis(); } + const savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + const ancestorFacts = enterSubtree(HierarchyFacts.ArrowFunctionExcludes, HierarchyFacts.ArrowFunctionIncludes); const func = createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -1529,6 +1667,8 @@ namespace ts { ); setOriginalNode(func, node); setEmitFlags(func, EmitFlags.CapturesThis); + exitSubtree(ancestorFacts, HierarchyFacts.None, HierarchyFacts.None); + convertedLoopState = savedConvertedLoopState; return func; } @@ -1538,16 +1678,30 @@ namespace ts { * @param node a FunctionExpression node. */ function visitFunctionExpression(node: FunctionExpression): Expression { + const ancestorFacts = getEmitFlags(node) & EmitFlags.AsyncFunctionBody + ? enterSubtree(HierarchyFacts.AsyncFunctionBodyExcludes, HierarchyFacts.AsyncFunctionBodyIncludes) + : enterSubtree(HierarchyFacts.FunctionExcludes, HierarchyFacts.FunctionIncludes); + const savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + + const parameters = visitParameterList(node.parameters, visitor, context); + const body = node.transformFlags & TransformFlags.ES2015 + ? transformFunctionBody(node) + : visitFunctionBodyDownLevel(node); + const name = hierarchyFacts & HierarchyFacts.NewTarget + ? getLocalName(node) + : node.name; + + exitSubtree(ancestorFacts, HierarchyFacts.PropagateNewTargetMask, HierarchyFacts.None); + convertedLoopState = savedConvertedLoopState; return updateFunctionExpression( node, /*modifiers*/ undefined, - node.name, + name, /*typeParameters*/ undefined, - visitParameterList(node.parameters, visitor, context), + parameters, /*type*/ undefined, - node.transformFlags & TransformFlags.ES2015 - ? transformFunctionBody(node) - : visitFunctionBody(node.body, visitor, context) + body ); } @@ -1557,17 +1711,28 @@ namespace ts { * @param node a FunctionDeclaration node. */ function visitFunctionDeclaration(node: FunctionDeclaration): FunctionDeclaration { + const savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + const ancestorFacts = enterSubtree(HierarchyFacts.FunctionExcludes, HierarchyFacts.FunctionIncludes); + const parameters = visitParameterList(node.parameters, visitor, context); + const body = node.transformFlags & TransformFlags.ES2015 + ? transformFunctionBody(node) + : visitFunctionBodyDownLevel(node); + const name = hierarchyFacts & HierarchyFacts.NewTarget + ? getLocalName(node) + : node.name; + + exitSubtree(ancestorFacts, HierarchyFacts.PropagateNewTargetMask, HierarchyFacts.None); + convertedLoopState = savedConvertedLoopState; return updateFunctionDeclaration( node, /*decorators*/ undefined, - node.modifiers, - node.name, + visitNodes(node.modifiers, visitor, isModifier), + name, /*typeParameters*/ undefined, - visitParameterList(node.parameters, visitor, context), + parameters, /*type*/ undefined, - node.transformFlags & TransformFlags.ES2015 - ? transformFunctionBody(node) - : visitFunctionBody(node.body, visitor, context) + body ); } @@ -1578,28 +1743,33 @@ namespace ts { * @param location The source-map location for the new FunctionExpression. * @param name The name of the new FunctionExpression. */ - function transformFunctionLikeToExpression(node: FunctionLikeDeclaration, location: TextRange, name: Identifier): FunctionExpression { - const savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== SyntaxKind.ArrowFunction) { - enclosingNonArrowFunction = node; + function transformFunctionLikeToExpression(node: FunctionLikeDeclaration, location: TextRange, name: Identifier, container: Node): FunctionExpression { + const savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + const ancestorFacts = container && isClassLike(container) && !hasModifier(node, ModifierFlags.Static) + ? enterSubtree(HierarchyFacts.FunctionExcludes, HierarchyFacts.FunctionIncludes | HierarchyFacts.NonStaticClassElement) + : enterSubtree(HierarchyFacts.FunctionExcludes, HierarchyFacts.FunctionIncludes); + const parameters = visitParameterList(node.parameters, visitor, context); + const body = transformFunctionBody(node); + if (hierarchyFacts & HierarchyFacts.NewTarget && !name && (node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression)) { + name = getGeneratedNameForNode(node); } - const expression = setOriginalNode( + exitSubtree(ancestorFacts, HierarchyFacts.PropagateNewTargetMask, HierarchyFacts.None); + convertedLoopState = savedConvertedLoopState; + return setOriginalNode( createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, /*typeParameters*/ undefined, - visitParameterList(node.parameters, visitor, context), + parameters, /*type*/ undefined, - saveStateAndInvoke(node, transformFunctionBody), + body, location ), /*original*/ node ); - - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; } /** @@ -1674,6 +1844,8 @@ namespace ts { const lexicalEnvironment = context.endLexicalEnvironment(); addRange(statements, lexicalEnvironment); + prependCaptureNewTargetIfNeeded(statements, node, /*copyOnWrite*/ false); + // If we added any final generated statements, this must be a multi-line block if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; @@ -1692,6 +1864,30 @@ namespace ts { return block; } + function visitFunctionBodyDownLevel(node: FunctionDeclaration | FunctionExpression) { + const updated = visitFunctionBody(node.body, functionBodyVisitor, context); + return updateBlock( + updated, + createNodeArray( + prependCaptureNewTargetIfNeeded(updated.statements, node, /*copyOnWrite*/ true), + /*location*/ updated.statements + ) + ); + } + + function visitBlock(node: Block, isFunctionBody: boolean): Block { + if (isFunctionBody) { + // A function body is not a block scope. + return visitEachChild(node, visitor, context); + } + const ancestorFacts = hierarchyFacts & HierarchyFacts.IterationStatement + ? enterSubtree(HierarchyFacts.IterationStatementBlockExcludes, HierarchyFacts.IterationStatementBlockIncludes) + : enterSubtree(HierarchyFacts.BlockExcludes, HierarchyFacts.BlockIncludes); + const updated = visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, HierarchyFacts.None, HierarchyFacts.None); + return updated; + } + /** * Visits an ExpressionStatement that contains a destructuring assignment. * @@ -1745,10 +1941,13 @@ namespace ts { FlattenLevel.All, needsDestructuringValue); } + return visitEachChild(node, visitor, context); } function visitVariableStatement(node: VariableStatement): Statement { - if (convertedLoopState && (getCombinedNodeFlags(node.declarationList) & NodeFlags.BlockScoped) == 0) { + const ancestorFacts = enterSubtree(HierarchyFacts.None, hasModifier(node, ModifierFlags.Export) ? HierarchyFacts.ExportedVariableStatement : HierarchyFacts.None); + let updated: Statement; + if (convertedLoopState && (node.declarationList.flags & NodeFlags.BlockScoped) === 0) { // we are inside a converted loop - hoist variable declarations let assignments: Expression[]; for (const decl of node.declarationList.declarations) { @@ -1770,15 +1969,19 @@ namespace ts { } } if (assignments) { - return createStatement(reduceLeft(assignments, (acc, v) => createBinary(v, SyntaxKind.CommaToken, acc)), node); + updated = createStatement(reduceLeft(assignments, (acc, v) => createBinary(v, SyntaxKind.CommaToken, acc)), node); } else { // none of declarations has initializer - the entire variable statement can be deleted - return undefined; + updated = undefined; } } + else { + updated = visitEachChild(node, visitor, context); + } - return visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, HierarchyFacts.None, HierarchyFacts.None); + return updated; } /** @@ -1787,29 +1990,32 @@ namespace ts { * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node: VariableDeclarationList): VariableDeclarationList { - if (node.flags & NodeFlags.BlockScoped) { - enableSubstitutionsForBlockScopedBindings(); + if (node.transformFlags & TransformFlags.ES2015) { + if (node.flags & NodeFlags.BlockScoped) { + enableSubstitutionsForBlockScopedBindings(); + } + + const declarations = flatten(map(node.declarations, node.flags & NodeFlags.Let + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + + const declarationList = createVariableDeclarationList(declarations, /*location*/ node); + setOriginalNode(declarationList, node); + setCommentRange(declarationList, node); + + if (node.transformFlags & TransformFlags.ContainsBindingPattern + && (isBindingPattern(node.declarations[0].name) + || isBindingPattern(lastOrUndefined(node.declarations).name))) { + // If the first or last declaration is a binding pattern, we need to modify + // the source map range for the declaration list. + const firstDeclaration = firstOrUndefined(declarations); + const lastDeclaration = lastOrUndefined(declarations); + setSourceMapRange(declarationList, createRange(firstDeclaration.pos, lastDeclaration.end)); + } + + return declarationList; } - - const declarations = flatten(map(node.declarations, node.flags & NodeFlags.Let - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - - const declarationList = createVariableDeclarationList(declarations, /*location*/ node); - setOriginalNode(declarationList, node); - setCommentRange(declarationList, node); - - if (node.transformFlags & TransformFlags.ContainsBindingPattern - && (isBindingPattern(node.declarations[0].name) - || isBindingPattern(lastOrUndefined(node.declarations).name))) { - // If the first or last declaration is a binding pattern, we need to modify - // the source map range for the declaration list. - const firstDeclaration = firstOrUndefined(declarations); - const lastDeclaration = lastOrUndefined(declarations); - setSourceMapRange(declarationList, createRange(firstDeclaration.pos, lastDeclaration.end)); - } - - return declarationList; + return visitEachChild(node, visitor, context); } /** @@ -1863,20 +2069,18 @@ namespace ts { const isCapturedInFunction = flags & NodeCheckFlags.CapturedBlockScopedBinding; const isDeclaredInLoop = flags & NodeCheckFlags.BlockScopedBindingInLoop; const emittedAsTopLevel = - isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + (hierarchyFacts & HierarchyFacts.TopLevel) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && isBlock(enclosingBlockScopeContainer) - && isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); + && (hierarchyFacts & HierarchyFacts.IterationStatementBlock) !== 0); const emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== SyntaxKind.ForInStatement - && enclosingBlockScopeContainer.kind !== SyntaxKind.ForOfStatement + && (hierarchyFacts & HierarchyFacts.ForInOrForOfStatement) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && !isIterationStatement(enclosingBlockScopeContainer, /*lookInLabeledStatements*/ false))); + && (hierarchyFacts & (HierarchyFacts.ForStatement | HierarchyFacts.ForInOrForOfStatement)) === 0)); return emitExplicitInitializer; } @@ -1910,72 +2114,85 @@ namespace ts { * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node: VariableDeclaration): VisitResult { - // If we are here it is because the name contains a binding pattern. + const ancestorFacts = enterSubtree(HierarchyFacts.ExportedVariableStatement, HierarchyFacts.None); + let updated: VisitResult; if (isBindingPattern(node.name)) { - const hoistTempVariables = enclosingVariableStatement - && hasModifier(enclosingVariableStatement, ModifierFlags.Export); - return flattenDestructuringBinding( + updated = flattenDestructuringBinding( node, visitor, context, FlattenLevel.All, /*value*/ undefined, - hoistTempVariables + (ancestorFacts & HierarchyFacts.ExportedVariableStatement) !== 0 ); } + else { + updated = visitEachChild(node, visitor, context); + } - return visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, HierarchyFacts.None, HierarchyFacts.None); + return updated; + } + + function recordLabel(node: LabeledStatement) { + convertedLoopState.labels.set(node.label.text, node.label.text); + } + + function resetLabel(node: LabeledStatement) { + convertedLoopState.labels.set(node.label.text, undefined); } function visitLabeledStatement(node: LabeledStatement): VisitResult { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; + if (convertedLoopState && !convertedLoopState.labels) { + convertedLoopState.labels = createMap(); } - - let result: VisitResult; - if (isIterationStatement(node.statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node.statement)) { - result = visitNodes(createNodeArray([node.statement]), visitor, isStatement); - } - else { - result = visitEachChild(node, visitor, context); - } - - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; - } - - return result; + const statement = unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); + return isIterationStatement(statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(statement) + ? visitIterationStatement(statement, /*outermostLabeledStatement*/ node) + : restoreEnclosingLabel(visitNode(statement, visitor, isStatement), node, convertedLoopState && resetLabel); } - function visitDoStatement(node: DoStatement) { - return convertIterationStatementBodyIfNecessary(node); + function visitIterationStatementWithFacts(excludeFacts: HierarchyFacts, includeFacts: HierarchyFacts, node: IterationStatement, outermostLabeledStatement: LabeledStatement, convert?: LoopConverter) { + const ancestorFacts = enterSubtree(excludeFacts, includeFacts); + const updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); + exitSubtree(ancestorFacts, HierarchyFacts.None, HierarchyFacts.None); + return updated; } - function visitWhileStatement(node: WhileStatement) { - return convertIterationStatementBodyIfNecessary(node); + function visitDoOrWhileStatement(node: DoStatement | WhileStatement, outermostLabeledStatement: LabeledStatement) { + return visitIterationStatementWithFacts( + HierarchyFacts.DoOrWhileStatementExcludes, + HierarchyFacts.DoOrWhileStatementIncludes, + node, + outermostLabeledStatement); } - function visitForStatement(node: ForStatement) { - return convertIterationStatementBodyIfNecessary(node); + function visitForStatement(node: ForStatement, outermostLabeledStatement: LabeledStatement) { + return visitIterationStatementWithFacts( + HierarchyFacts.ForStatementExcludes, + HierarchyFacts.ForStatementIncludes, + node, + outermostLabeledStatement); } - function visitForInStatement(node: ForInStatement) { - return convertIterationStatementBodyIfNecessary(node); + function visitForInStatement(node: ForInStatement, outermostLabeledStatement: LabeledStatement) { + return visitIterationStatementWithFacts( + HierarchyFacts.ForInOrForOfStatementExcludes, + HierarchyFacts.ForInOrForOfStatementIncludes, + node, + outermostLabeledStatement); } - /** - * Visits a ForOfStatement and converts it into a compatible ForStatement. - * - * @param node A ForOfStatement. - */ - function visitForOfStatement(node: ForOfStatement): VisitResult { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function visitForOfStatement(node: ForOfStatement, outermostLabeledStatement: LabeledStatement): VisitResult { + return visitIterationStatementWithFacts( + HierarchyFacts.ForInOrForOfStatementExcludes, + HierarchyFacts.ForInOrForOfStatementIncludes, + node, + outermostLabeledStatement, + convertForOfToFor); } - function convertForOfToFor(node: ForOfStatement, convertedLoopBodyStatements: Statement[]): ForStatement { + function convertForOfToFor(node: ForOfStatement, outermostLabeledStatement: LabeledStatement, convertedLoopBodyStatements: Statement[]): Statement { // The following ES6 code: // // for (let v of expr) { } @@ -2142,7 +2359,21 @@ namespace ts { // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. setEmitFlags(forStatement, EmitFlags.NoTokenTrailingSourceMaps); - return forStatement; + return restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); + } + + function visitIterationStatement(node: IterationStatement, outermostLabeledStatement: LabeledStatement) { + switch (node.kind) { + case SyntaxKind.DoStatement: + case SyntaxKind.WhileStatement: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case SyntaxKind.ForStatement: + return visitForStatement(node, outermostLabeledStatement); + case SyntaxKind.ForInStatement: + return visitForInStatement(node, outermostLabeledStatement); + case SyntaxKind.ForOfStatement: + return visitForOfStatement(node, outermostLabeledStatement); + } } /** @@ -2158,45 +2389,56 @@ namespace ts { // Find the first computed property. // Everything until that point can be emitted as part of the initial object literal. let numInitialProperties = numProperties; + let numInitialPropertiesWithoutYield = numProperties; for (let i = 0; i < numProperties; i++) { const property = properties[i]; - if (property.transformFlags & TransformFlags.ContainsYield - || property.name.kind === SyntaxKind.ComputedPropertyName) { + if ((property.transformFlags & TransformFlags.ContainsYield && hierarchyFacts & HierarchyFacts.AsyncFunctionBody) + && i < numInitialPropertiesWithoutYield) { + numInitialPropertiesWithoutYield = i; + } + if (property.name.kind === SyntaxKind.ComputedPropertyName) { numInitialProperties = i; break; } } - Debug.assert(numInitialProperties !== numProperties); + if (numInitialProperties !== numProperties) { + if (numInitialPropertiesWithoutYield < numInitialProperties) { + numInitialProperties = numInitialPropertiesWithoutYield; + } - // For computed properties, we need to create a unique handle to the object - // literal so we can modify it without risking internal assignments tainting the object. - const temp = createTempVariable(hoistVariableDeclaration); + // For computed properties, we need to create a unique handle to the object + // literal so we can modify it without risking internal assignments tainting the object. + const temp = createTempVariable(hoistVariableDeclaration); - // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. - const expressions: Expression[] = []; - const assignment = createAssignment( - temp, - setEmitFlags( - createObjectLiteral( - visitNodes(properties, visitor, isObjectLiteralElementLike, 0, numInitialProperties), - /*location*/ undefined, - node.multiLine - ), - EmitFlags.Indented - ) - ); - if (node.multiLine) { - assignment.startsOnNewLine = true; + // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. + const expressions: Expression[] = []; + const assignment = createAssignment( + temp, + setEmitFlags( + createObjectLiteral( + visitNodes(properties, visitor, isObjectLiteralElementLike, 0, numInitialProperties), + /*location*/ undefined, + node.multiLine + ), + EmitFlags.Indented + ) + ); + + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + + expressions.push(assignment); + + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + + // We need to clone the temporary identifier so that we can write it on a + // new line + expressions.push(node.multiLine ? startOnNewLine(getMutableClone(temp)) : temp); + return inlineExpressions(expressions); } - expressions.push(assignment); - - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - - // We need to clone the temporary identifier so that we can write it on a - // new line - expressions.push(node.multiLine ? startOnNewLine(getMutableClone(temp)) : temp); - return inlineExpressions(expressions); + return visitEachChild(node, visitor, context); } function shouldConvertIterationStatementBody(node: IterationStatement): boolean { @@ -2227,7 +2469,7 @@ namespace ts { } } - function convertIterationStatementBodyIfNecessary(node: IterationStatement, convert?: (node: IterationStatement, convertedLoopBodyStatements: Statement[]) => IterationStatement): VisitResult { + function convertIterationStatementBodyIfNecessary(node: IterationStatement, outermostLabeledStatement: LabeledStatement, convert?: LoopConverter): VisitResult { if (!shouldConvertIterationStatementBody(node)) { let saveAllowedNonLabeledJumps: Jump; if (convertedLoopState) { @@ -2237,7 +2479,9 @@ namespace ts { convertedLoopState.allowedNonLabeledJumps = Jump.Break | Jump.Continue; } - const result = convert ? convert(node, /*convertedLoopBodyStatements*/ undefined) : visitEachChild(node, visitor, context); + const result = convert + ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined) + : restoreEnclosingLabel(visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); if (convertedLoopState) { convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; @@ -2313,8 +2557,7 @@ namespace ts { } const isAsyncBlockContainingAwait = - enclosingNonArrowFunction - && (getEmitFlags(enclosingNonArrowFunction) & EmitFlags.AsyncFunctionBody) !== 0 + hierarchyFacts & HierarchyFacts.AsyncFunctionBody && (node.statement.transformFlags & TransformFlags.ContainsYield) !== 0; let loopBodyFlags: EmitFlags = 0; @@ -2433,34 +2676,30 @@ namespace ts { } const convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); - let loop: IterationStatement; + let loop: Statement; if (convert) { - loop = convert(node, convertedLoopBodyStatements); + loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); } else { - loop = getMutableClone(node); + let clone = getMutableClone(node); // clean statement part - loop.statement = undefined; + clone.statement = undefined; // visit childnodes to transform initializer/condition/incrementor parts - loop = visitEachChild(loop, visitor, context); + clone = visitEachChild(clone, visitor, context); // set loop statement - loop.statement = createBlock( + clone.statement = createBlock( convertedLoopBodyStatements, /*location*/ undefined, /*multiline*/ true ); // reset and re-aggregate the transform flags - loop.transformFlags = 0; - aggregateTransformFlags(loop); + clone.transformFlags = 0; + aggregateTransformFlags(clone); + loop = restoreEnclosingLabel(clone, outermostLabeledStatement, convertedLoopState && resetLabel); } - - statements.push( - currentParent.kind === SyntaxKind.LabeledStatement - ? createLabel((currentParent).label, loop) - : loop - ); + statements.push(loop); return statements; } @@ -2559,13 +2798,13 @@ namespace ts { if (!state.labeledNonLocalBreaks) { state.labeledNonLocalBreaks = createMap(); } - state.labeledNonLocalBreaks[labelText] = labelMarker; + state.labeledNonLocalBreaks.set(labelText, labelMarker); } else { if (!state.labeledNonLocalContinues) { state.labeledNonLocalContinues = createMap(); } - state.labeledNonLocalContinues[labelText] = labelMarker; + state.labeledNonLocalContinues.set(labelText, labelMarker); } } @@ -2573,13 +2812,12 @@ namespace ts { if (!table) { return; } - for (const labelText in table) { - const labelMarker = table[labelText]; + table.forEach((labelMarker, labelText) => { const statements: Statement[] = []; // if there are no outer converted loop or outer label in question is located inside outer converted loop // then emit labeled break\continue // otherwise propagate pair 'label -> marker' to outer converted loop and emit 'return labelMarker' so outer loop can later decide what to do - if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) { const label = createIdentifier(labelText); statements.push(isBreak ? createBreak(label) : createContinue(label)); } @@ -2588,7 +2826,7 @@ namespace ts { statements.push(createReturn(loopResultName)); } caseClauses.push(createCaseClause(createLiteral(labelMarker), statements)); - } + }); } function processLoopVariableDeclaration(decl: VariableDeclaration | BindingElement, loopParameters: ParameterDeclaration[], loopOutParameters: LoopOutParameter[]) { @@ -2628,11 +2866,15 @@ namespace ts { case SyntaxKind.SetAccessor: const accessors = getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; + case SyntaxKind.MethodDeclaration: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); + break; + case SyntaxKind.PropertyAssignment: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; @@ -2641,10 +2883,6 @@ namespace ts { expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case SyntaxKind.MethodDeclaration: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); - break; - default: Debug.failBadSyntaxKind(node); break; @@ -2703,38 +2941,46 @@ namespace ts { * @param method The MethodDeclaration node. * @param receiver The receiver for the assignment. */ - function transformObjectLiteralMethodDeclarationToExpression(method: MethodDeclaration, receiver: Expression, startsOnNewLine: boolean) { + function transformObjectLiteralMethodDeclarationToExpression(method: MethodDeclaration, receiver: Expression, container: Node, startsOnNewLine: boolean) { + const ancestorFacts = enterSubtree(HierarchyFacts.None, HierarchyFacts.None); const expression = createAssignment( createMemberAccessForPropertyName( receiver, visitNode(method.name, visitor, isPropertyName) ), - transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined), + transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined, container), /*location*/ method ); if (startsOnNewLine) { expression.startsOnNewLine = true; } + exitSubtree(ancestorFacts, HierarchyFacts.PropagateNewTargetMask, hierarchyFacts & HierarchyFacts.PropagateNewTargetMask ? HierarchyFacts.NewTarget : HierarchyFacts.None); return expression; } function visitCatchClause(node: CatchClause): CatchClause { - Debug.assert(isBindingPattern(node.variableDeclaration.name)); + const ancestorFacts = enterSubtree(HierarchyFacts.BlockScopeExcludes, HierarchyFacts.BlockScopeIncludes); + let updated: CatchClause; + if (isBindingPattern(node.variableDeclaration.name)) { + const temp = createTempVariable(undefined); + const newVariableDeclaration = createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + const vars = flattenDestructuringBinding( + node.variableDeclaration, + visitor, + context, + FlattenLevel.All, + temp + ); + const list = createVariableDeclarationList(vars, /*location*/node.variableDeclaration, /*flags*/node.variableDeclaration.flags); + const destructure = createVariableStatement(undefined, list); + updated = updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + else { + updated = visitEachChild(node, visitor, context); + } - const temp = createTempVariable(undefined); - const newVariableDeclaration = createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); - - const vars = flattenDestructuringBinding( - node.variableDeclaration, - visitor, - context, - FlattenLevel.All, - temp - ); - const list = createVariableDeclarationList(vars, /*location*/node.variableDeclaration, /*flags*/node.variableDeclaration.flags); - const destructure = createVariableStatement(undefined, list); - - return updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + exitSubtree(ancestorFacts, HierarchyFacts.None, HierarchyFacts.None); + return updated; } function addStatementToStartOfBlock(block: Block, statement: Statement): Block { @@ -2753,7 +2999,7 @@ namespace ts { // Methods on classes are handled in visitClassDeclaration/visitClassExpression. // Methods with computed property names are handled in visitObjectLiteralExpression. Debug.assert(!isComputedPropertyName(node.name)); - const functionExpression = transformFunctionLikeToExpression(node, /*location*/ moveRangePos(node, -1), /*name*/ undefined); + const functionExpression = transformFunctionLikeToExpression(node, /*location*/ moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); setEmitFlags(functionExpression, EmitFlags.NoLeadingComments | getEmitFlags(functionExpression)); return createPropertyAssignment( node.name, @@ -2762,6 +3008,22 @@ namespace ts { ); } + /** + * Visits an AccessorDeclaration of an ObjectLiteralExpression. + * + * @param node An AccessorDeclaration node. + */ + function visitAccessorDeclaration(node: AccessorDeclaration): AccessorDeclaration { + Debug.assert(!isComputedPropertyName(node.name)); + const savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + const ancestorFacts = enterSubtree(HierarchyFacts.FunctionExcludes, HierarchyFacts.FunctionIncludes); + const updated = visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, HierarchyFacts.PropagateNewTargetMask, HierarchyFacts.None); + convertedLoopState = savedConvertedLoopState; + return updated; + } + /** * Visits a ShorthandPropertyAssignment and transforms it into a PropertyAssignment. * @@ -2775,6 +3037,13 @@ namespace ts { ); } + function visitComputedPropertyName(node: ComputedPropertyName) { + const ancestorFacts = enterSubtree(HierarchyFacts.ComputedPropertyNameExcludes, HierarchyFacts.ComputedPropertyNameIncludes); + const updated = visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, HierarchyFacts.PropagateNewTargetMask, hierarchyFacts & HierarchyFacts.PropagateNewTargetMask ? HierarchyFacts.NewTargetInComputedPropertyName : HierarchyFacts.None); + return updated; + } + /** * Visits a YieldExpression node. * @@ -2791,8 +3060,11 @@ namespace ts { * @param node An ArrayLiteralExpression node. */ function visitArrayLiteralExpression(node: ArrayLiteralExpression): Expression { - // We are here because we contain a SpreadElementExpression. - return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + if (node.transformFlags & TransformFlags.ES2015) { + // We are here because we contain a SpreadElementExpression. + return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + } + return visitEachChild(node, visitor, context); } /** @@ -2801,7 +3073,15 @@ namespace ts { * @param node a CallExpression. */ function visitCallExpression(node: CallExpression) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + if (node.transformFlags & TransformFlags.ES2015) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + } + return updateCall( + node, + visitNode(node.expression, callExpressionVisitor, isExpression), + /*typeArguments*/ undefined, + visitNodes(node.arguments, visitor, isExpression) + ); } function visitImmediateSuperCallInBody(node: CallExpression) { @@ -2833,7 +3113,7 @@ namespace ts { // _super.prototype.m.apply(this, a.concat([b])) resultingCall = createFunctionApply( - visitNode(target, visitor, isExpression), + visitNode(target, callExpressionVisitor, isExpression), visitNode(thisArg, visitor, isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false) ); @@ -2849,7 +3129,7 @@ namespace ts { // _super.m.call(this, a) // _super.prototype.m.call(this, a) resultingCall = createFunctionCall( - visitNode(target, visitor, isExpression), + visitNode(target, callExpressionVisitor, isExpression), visitNode(thisArg, visitor, isExpression), visitNodes(node.arguments, visitor, isExpression), /*location*/ node @@ -2864,11 +3144,11 @@ namespace ts { resultingCall, actualThis ); - return assignToCapturedThis + resultingCall = assignToCapturedThis ? createAssignment(createIdentifier("_this"), initializer) : initializer; } - return resultingCall; + return setOriginalNode(resultingCall, node); } /** @@ -2877,25 +3157,26 @@ namespace ts { * @param node A NewExpression node. */ function visitNewExpression(node: NewExpression): LeftHandSideExpression { - // We are here because we contain a SpreadElementExpression. - Debug.assert((node.transformFlags & TransformFlags.ContainsSpread) !== 0); + if (node.transformFlags & TransformFlags.ContainsSpread) { + // We are here because we contain a SpreadElementExpression. + // [source] + // new C(...a) + // + // [output] + // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() - // [source] - // new C(...a) - // - // [output] - // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() - - const { target, thisArg } = createCallBinding(createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration); - return createNew( - createFunctionApply( - visitNode(target, visitor, isExpression), - thisArg, - transformAndSpreadElements(createNodeArray([createVoidZero(), ...node.arguments]), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false) - ), - /*typeArguments*/ undefined, - [] - ); + const { target, thisArg } = createCallBinding(createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration); + return createNew( + createFunctionApply( + visitNode(target, visitor, isExpression), + thisArg, + transformAndSpreadElements(createNodeArray([createVoidZero(), ...node.arguments]), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false) + ), + /*typeArguments*/ undefined, + [] + ); + } + return visitEachChild(node, visitor, context); } /** @@ -3131,31 +3412,44 @@ namespace ts { /** * Visits the `super` keyword */ - function visitSuperKeyword(): LeftHandSideExpression { - return enclosingNonAsyncFunctionBody - && isClassElement(enclosingNonAsyncFunctionBody) - && !hasModifier(enclosingNonAsyncFunctionBody, ModifierFlags.Static) - && currentParent.kind !== SyntaxKind.CallExpression + function visitSuperKeyword(isExpressionOfCall: boolean): LeftHandSideExpression { + return hierarchyFacts & HierarchyFacts.NonStaticClassElement + && !isExpressionOfCall ? createPropertyAccess(createIdentifier("_super"), "prototype") : createIdentifier("_super"); } + function visitMetaProperty(node: MetaProperty) { + if (node.keywordToken === SyntaxKind.NewKeyword && node.name.text === "target") { + if (hierarchyFacts & HierarchyFacts.ComputedPropertyName) { + hierarchyFacts |= HierarchyFacts.NewTargetInComputedPropertyName; + } + else { + hierarchyFacts |= HierarchyFacts.NewTarget; + } + return createIdentifier("_newTarget"); + } + return node; + } + /** * Called by the printer just before a node is printed. * * @param node The node to be printed. */ function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) { - const savedEnclosingFunction = enclosingFunction; - if (enabledSubstitutions & ES2015SubstitutionFlags.CapturedThis && isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - enclosingFunction = node; + const ancestorFacts = enterSubtree( + HierarchyFacts.FunctionExcludes, + getEmitFlags(node) & EmitFlags.CapturesThis + ? HierarchyFacts.FunctionIncludes | HierarchyFacts.CapturesThis + : HierarchyFacts.FunctionIncludes); + previousOnEmitNode(emitContext, node, emitCallback); + exitSubtree(ancestorFacts, HierarchyFacts.None, HierarchyFacts.None); + return; } - previousOnEmitNode(emitContext, node, emitCallback); - - enclosingFunction = savedEnclosingFunction; } /** @@ -3283,11 +3577,9 @@ namespace ts { */ function substituteThisKeyword(node: PrimaryExpression): PrimaryExpression { if (enabledSubstitutions & ES2015SubstitutionFlags.CapturedThis - && enclosingFunction - && getEmitFlags(enclosingFunction) & EmitFlags.CapturesThis) { + && hierarchyFacts & HierarchyFacts.CapturesThis) { return createIdentifier("_this", /*location*/ node); } - return node; } @@ -3347,10 +3639,15 @@ namespace ts { scoped: false, priority: 0, text: ` - var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })();` }; } diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index c383902d495..7dcfe76a427 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -1,4 +1,4 @@ -/// +/// /// // Transforms generator functions into a compatible ES5 representation with similar runtime @@ -217,13 +217,15 @@ namespace ts { Endfinally = 7, } - const instructionNames = createMap({ - [Instruction.Return]: "return", - [Instruction.Break]: "break", - [Instruction.Yield]: "yield", - [Instruction.YieldStar]: "yield*", - [Instruction.Endfinally]: "endfinally", - }); + function getInstructionName(instruction: Instruction): string { + switch (instruction) { + case Instruction.Return: return "return"; + case Instruction.Break: return "break"; + case Instruction.Yield: return "yield"; + case Instruction.YieldStar: return "yield*"; + case Instruction.Endfinally: return "endfinally"; + } + } export function transformGenerators(context: TransformationContext) { const { @@ -241,7 +243,7 @@ namespace ts { let currentSourceFile: SourceFile; let renamedCatchVariables: Map; - let renamedCatchVariableDeclarations: Map; + let renamedCatchVariableDeclarations: Identifier[]; let inGeneratorFunctionBody: boolean; let inStatementContainingYield: boolean; @@ -938,7 +940,7 @@ namespace ts { } markLabel(resumeLabel); - return createGeneratorResume(); + return createGeneratorResume(/*location*/ node); } /** @@ -1234,7 +1236,9 @@ namespace ts { function transformAndEmitVariableDeclarationList(node: VariableDeclarationList): VariableDeclarationList { for (const variable of node.declarations) { - hoistVariableDeclaration(variable.name); + const name = getSynthesizedClone(variable.name); + setCommentRange(name, variable.name); + hoistVariableDeclaration(name); } const variables = getInitializedVariables(node); @@ -1287,7 +1291,7 @@ namespace ts { if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) { const endLabel = defineLabel(); const elseLabel = node.elseStatement ? defineLabel() : undefined; - emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, visitNode(node.expression, visitor, isExpression)); + emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, visitNode(node.expression, visitor, isExpression), /*location*/ node.expression); transformAndEmitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { emitBreak(endLabel); @@ -1921,12 +1925,12 @@ namespace ts { } function substituteExpressionIdentifier(node: Identifier) { - if (renamedCatchVariables && hasProperty(renamedCatchVariables, node.text)) { + if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { const original = getOriginalNode(node); if (isIdentifier(original) && original.parent) { const declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - const name = getProperty(renamedCatchVariableDeclarations, String(getOriginalNodeId(declaration))); + const name = renamedCatchVariableDeclarations[getOriginalNodeId(declaration)]; if (name) { const clone = getMutableClone(name); setSourceMapRange(clone, node); @@ -2092,11 +2096,11 @@ namespace ts { if (!renamedCatchVariables) { renamedCatchVariables = createMap(); - renamedCatchVariableDeclarations = createMap(); + renamedCatchVariableDeclarations = []; context.enableSubstitution(SyntaxKind.Identifier); } - renamedCatchVariables[text] = true; + renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[getOriginalNodeId(variable)] = name; const exception = peekBlock(); @@ -2401,7 +2405,7 @@ namespace ts { */ function createInstruction(instruction: Instruction): NumericLiteral { const literal = createLiteral(instruction); - literal.trailingComment = instructionNames[instruction]; + literal.trailingComment = getInstructionName(instruction); return literal; } @@ -2965,12 +2969,15 @@ namespace ts { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; writeStatement( - createReturn( - createArrayLiteral(expression - ? [createInstruction(Instruction.Return), expression] - : [createInstruction(Instruction.Return)] + setEmitFlags( + createReturn( + createArrayLiteral(expression + ? [createInstruction(Instruction.Return), expression] + : [createInstruction(Instruction.Return)] + ), + operationLocation ), - operationLocation + EmitFlags.NoTokenSourceMaps ) ); } @@ -2984,12 +2991,15 @@ namespace ts { function writeBreak(label: Label, operationLocation: TextRange): void { lastOperationWasAbrupt = true; writeStatement( - createReturn( - createArrayLiteral([ - createInstruction(Instruction.Break), - createLabel(label) - ]), - operationLocation + setEmitFlags( + createReturn( + createArrayLiteral([ + createInstruction(Instruction.Break), + createLabel(label) + ]), + operationLocation + ), + EmitFlags.NoTokenSourceMaps ) ); } @@ -3003,15 +3013,21 @@ namespace ts { */ function writeBreakWhenTrue(label: Label, condition: Expression, operationLocation: TextRange): void { writeStatement( - createIf( - condition, - createReturn( - createArrayLiteral([ - createInstruction(Instruction.Break), - createLabel(label) - ]), - operationLocation - ) + setEmitFlags( + createIf( + condition, + setEmitFlags( + createReturn( + createArrayLiteral([ + createInstruction(Instruction.Break), + createLabel(label) + ]), + operationLocation + ), + EmitFlags.NoTokenSourceMaps + ) + ), + EmitFlags.SingleLine ) ); } @@ -3025,15 +3041,21 @@ namespace ts { */ function writeBreakWhenFalse(label: Label, condition: Expression, operationLocation: TextRange): void { writeStatement( - createIf( - createLogicalNot(condition), - createReturn( - createArrayLiteral([ - createInstruction(Instruction.Break), - createLabel(label) - ]), - operationLocation - ) + setEmitFlags( + createIf( + createLogicalNot(condition), + setEmitFlags( + createReturn( + createArrayLiteral([ + createInstruction(Instruction.Break), + createLabel(label) + ]), + operationLocation + ), + EmitFlags.NoTokenSourceMaps + ) + ), + EmitFlags.SingleLine ) ); } @@ -3047,13 +3069,16 @@ namespace ts { function writeYield(expression: Expression, operationLocation: TextRange): void { lastOperationWasAbrupt = true; writeStatement( - createReturn( - createArrayLiteral( - expression - ? [createInstruction(Instruction.Yield), expression] - : [createInstruction(Instruction.Yield)] + setEmitFlags( + createReturn( + createArrayLiteral( + expression + ? [createInstruction(Instruction.Yield), expression] + : [createInstruction(Instruction.Yield)] + ), + operationLocation ), - operationLocation + EmitFlags.NoTokenSourceMaps ) ); } @@ -3067,12 +3092,15 @@ namespace ts { function writeYieldStar(expression: Expression, operationLocation: TextRange): void { lastOperationWasAbrupt = true; writeStatement( - createReturn( - createArrayLiteral([ - createInstruction(Instruction.YieldStar), - expression - ]), - operationLocation + setEmitFlags( + createReturn( + createArrayLiteral([ + createInstruction(Instruction.YieldStar), + expression + ]), + operationLocation + ), + EmitFlags.NoTokenSourceMaps ) ); } diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index ecb5dd053e0..1307a7f8551 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -150,6 +150,9 @@ namespace ts { return decoded ? createLiteral(decoded, /*location*/ node) : node; } else if (node.kind === SyntaxKind.JsxExpression) { + if (node.expression === undefined) { + return createLiteral(true); + } return visitJsxExpression(node); } else { @@ -157,33 +160,50 @@ namespace ts { } } - function visitJsxText(node: JsxText) { - const text = getTextOfNode(node, /*includeTrivia*/ true); - let parts: Expression[]; - let firstNonWhitespace = 0; - let lastNonWhitespace = -1; + function visitJsxText(node: JsxText): StringLiteral | undefined { + const fixed = fixupWhitespaceAndDecodeEntities(getTextOfNode(node, /*includeTrivia*/ true)); + return fixed === undefined ? undefined : createLiteral(fixed); + } + + /** + * 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 + * See also https://www.w3.org/TR/html4/struct/text.html#h-9.1 and https://www.w3.org/TR/CSS2/text.html#white-space-model + * + * An equivalent algorithm would be: + * - If there is only one line, return it. + * - If there is only whitespace (but multiple lines), return `undefined`. + * - Split the text into lines. + * - 'trimRight' the first line, 'trimLeft' the last line, 'trim' middle lines. + * - Decode entities on each line (individually). + * - Remove empty lines and join the rest with " ". + */ + function fixupWhitespaceAndDecodeEntities(text: string): string | undefined { + let acc: string | undefined; + // First non-whitespace character on this line. + let firstNonWhitespace = 0; + // Last non-whitespace character on this line. + let lastNonWhitespace = -1; + // These initial values are special because the first line is: + // firstNonWhitespace = 0 to indicate that we want leading whitsepace, + // but lastNonWhitespace = -1 as a special flag to indicate that we *don't* include the line if it's all whitespace. - // 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++) { const c = text.charCodeAt(i); if (isLineBreak(c)) { - if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - const part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - if (!parts) { - parts = []; - } - - // We do not escape the string here as that is handled by the printer - // when it emits the literal. We do, however, need to decode JSX entities. - parts.push(createLiteral(decodeEntities(part))); + // If we've seen any non-whitespace characters on this line, add the 'trim' of the line. + // (lastNonWhitespace === -1 is a special flag to detect whether the first line is all whitespace.) + if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) { + acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); } + // Reset firstNonWhitespace for the next line. + // Don't bother to reset lastNonWhitespace because we ignore it if firstNonWhitespace = -1. firstNonWhitespace = -1; } - else if (!isWhiteSpace(c)) { + else if (!isWhiteSpaceSingleLine(c)) { lastNonWhitespace = i; if (firstNonWhitespace === -1) { firstNonWhitespace = i; @@ -191,29 +211,18 @@ namespace ts { } } - if (firstNonWhitespace !== -1) { - const part = text.substr(firstNonWhitespace); - if (!parts) { - parts = []; - } - - // We do not escape the string here as that is handled by the printer - // when it emits the literal. We do, however, need to decode JSX entities. - parts.push(createLiteral(decodeEntities(part))); - } - - if (parts) { - return reduceLeft(parts, aggregateJsxTextParts); - } - - return undefined; + return firstNonWhitespace !== -1 + // Last line had a non-whitespace character. Emit the 'trimLeft', meaning keep trailing whitespace. + ? addLineOfJsxText(acc, text.substr(firstNonWhitespace)) + // Last line was all whitespace, so ignore it + : acc; } - /** - * Aggregates two expressions by interpolating them with a whitespace literal. - */ - function aggregateJsxTextParts(left: Expression, right: Expression) { - return createAdd(createAdd(left, createLiteral(" ")), right); + function addLineOfJsxText(acc: string | undefined, trimmedLine: string): string { + // We do not escape the string here as that is handled by the printer + // when it emits the literal. We do, however, need to decode JSX entities. + const decoded = decodeEntities(trimmedLine); + return acc === undefined ? decoded : acc + " " + decoded; } /** @@ -229,7 +238,7 @@ namespace ts { return String.fromCharCode(parseInt(hex, 16)); } else { - const ch = entities[word]; + const ch = entities.get(word); // If this is not a valid entity, then just use `match` (replace it with itself, i.e. don't replace) return ch ? String.fromCharCode(ch) : match; } @@ -277,7 +286,7 @@ namespace ts { } } - const entities = createMap({ + const entities = createMapFromTemplate({ "quot": 0x0022, "amp": 0x0026, "apos": 0x0027, diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index c900b7d20e1..0adea4fd540 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -1,4 +1,4 @@ -/// +/// /// /*@internal*/ @@ -10,12 +10,13 @@ namespace ts { importAliasNames: ParameterDeclaration[]; } - const transformModuleDelegates = createMap<(node: SourceFile) => SourceFile>({ - [ModuleKind.None]: transformCommonJSModule, - [ModuleKind.CommonJS]: transformCommonJSModule, - [ModuleKind.AMD]: transformAMDModule, - [ModuleKind.UMD]: transformUMDModule, - }); + function getTransformModuleDelegate(moduleKind: ModuleKind): (node: SourceFile) => SourceFile { + switch (moduleKind) { + case ModuleKind.AMD: return transformAMDModule; + case ModuleKind.UMD: return transformUMDModule; + default: return transformCommonJSModule; + } + } const { startLexicalEnvironment, @@ -38,12 +39,12 @@ namespace ts { context.enableSubstitution(SyntaxKind.ShorthandPropertyAssignment); // Substitutes shorthand property assignments for imported/exported symbols. context.enableEmitNotification(SyntaxKind.SourceFile); // Restore state when substituting nodes in a file. - const moduleInfoMap = createMap(); // The ExternalModuleInfo for each file. - const deferredExports = createMap(); // Exports to defer until an EndOfDeclarationMarker is found. + const moduleInfoMap: ExternalModuleInfo[] = []; // The ExternalModuleInfo for each file. + const deferredExports: Statement[][] = []; // Exports to defer until an EndOfDeclarationMarker is found. let currentSourceFile: SourceFile; // The current file. let currentModuleInfo: ExternalModuleInfo; // The ExternalModuleInfo for the current file. - let noSubstitution: Map; // Set of nodes for which substitution rules should be ignored. + let noSubstitution: boolean[]; // Set of nodes for which substitution rules should be ignored. return transformSourceFile; @@ -60,10 +61,11 @@ namespace ts { } currentSourceFile = node; - currentModuleInfo = moduleInfoMap[getOriginalNodeId(node)] = collectExternalModuleInfo(node, resolver, compilerOptions); + currentModuleInfo = collectExternalModuleInfo(node, resolver, compilerOptions); + moduleInfoMap[getOriginalNodeId(node)] = currentModuleInfo; // Perform the transformation. - const transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ModuleKind.None]; + const transformModule = getTransformModuleDelegate(moduleKind); const updated = transformModule(node); currentSourceFile = undefined; @@ -102,28 +104,7 @@ namespace ts { function transformAMDModule(node: SourceFile) { const define = createIdentifier("define"); const moduleName = tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); - } - /** - * Transforms a SourceFile into a UMD module. - * - * @param node The SourceFile node. - */ - function transformUMDModule(node: SourceFile) { - const define = createRawExpression(umdHelper); - return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); - } - - /** - * Transforms a SourceFile into an AMD or UMD module. - * - * @param node The SourceFile node. - * @param define The expression used to define the module. - * @param moduleName An expression for the module name, if available. - * @param includeNonAmdDependencies A value indicating whether to incldue any non-AMD dependencies. - */ - function transformAsynchronousModule(node: SourceFile, define: Expression, moduleName: Expression, includeNonAmdDependencies: boolean) { // An AMD define function has the following shape: // // define(id?, dependencies?, factory); @@ -145,7 +126,7 @@ namespace ts { // // we need to add modules without alias names to the end of the dependencies list - const { aliasedModuleNames, unaliasedModuleNames, importAliasNames } = collectAsynchronousDependencies(node, includeNonAmdDependencies); + const { aliasedModuleNames, unaliasedModuleNames, importAliasNames } = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ true); // Create an updated SourceFile: // @@ -194,6 +175,137 @@ namespace ts { ); } + /** + * Transforms a SourceFile into a UMD module. + * + * @param node The SourceFile node. + */ + function transformUMDModule(node: SourceFile) { + const { aliasedModuleNames, unaliasedModuleNames, importAliasNames } = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ false); + const umdHeader = createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, + [createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "factory")], + /*type*/ undefined, + createBlock( + [ + createIf( + createLogicalAnd( + createTypeCheck(createIdentifier("module"), "object"), + createTypeCheck(createPropertyAccess(createIdentifier("module"), "exports"), "object") + ), + createBlock([ + createVariableStatement( + /*modifiers*/ undefined, + [ + createVariableDeclaration( + "v", + /*type*/ undefined, + createCall( + createIdentifier("factory"), + /*typeArguments*/ undefined, + [ + createIdentifier("require"), + createIdentifier("exports") + ] + ) + ) + ] + ), + setEmitFlags( + createIf( + createStrictInequality( + createIdentifier("v"), + createIdentifier("undefined") + ), + createStatement( + createAssignment( + createPropertyAccess(createIdentifier("module"), "exports"), + createIdentifier("v") + ) + ) + ), + EmitFlags.SingleLine + ) + ]), + createIf( + createLogicalAnd( + createTypeCheck(createIdentifier("define"), "function"), + createPropertyAccess(createIdentifier("define"), "amd") + ), + createBlock([ + createStatement( + createCall( + createIdentifier("define"), + /*typeArguments*/ undefined, + [ + createArrayLiteral([ + createLiteral("require"), + createLiteral("exports"), + ...aliasedModuleNames, + ...unaliasedModuleNames + ]), + createIdentifier("factory") + ] + ) + ) + ]) + ) + ) + ], + /*location*/ undefined, + /*multiLine*/ true + ) + ); + + // Create an updated SourceFile: + // + // (function (factory) { + // if (typeof module === "object" && typeof module.exports === "object") { + // var v = factory(require, exports); + // if (v !== undefined) module.exports = v; + // } + // else if (typeof define === 'function' && define.amd) { + // define(["require", "exports"], factory); + // } + // })(function ...) + + return updateSourceFileNode( + node, + createNodeArray( + [ + createStatement( + createCall( + umdHeader, + /*typeArguments*/ undefined, + [ + // Add the module body function argument: + // + // function (require, exports) ... + createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, + [ + createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports"), + ...importAliasNames + ], + /*type*/ undefined, + transformAsynchronousModuleBody(node) + ) + ] + ) + ) + ], + /*location*/ node.statements + ) + ); + } + /** * Collect the additional asynchronous dependencies for the module. * @@ -973,7 +1085,7 @@ namespace ts { */ function appendExportsOfDeclaration(statements: Statement[] | undefined, decl: Declaration): Statement[] | undefined { const name = getDeclarationName(decl); - const exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; + const exportSpecifiers = currentModuleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { for (const exportSpecifier of exportSpecifiers) { statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name); @@ -997,7 +1109,7 @@ namespace ts { function appendExportStatement(statements: Statement[] | undefined, exportName: Identifier, expression: Expression, location?: TextRange, allowComments?: boolean): Statement[] | undefined { if (exportName.text === "default") { const sourceFile = getOriginalNode(currentSourceFile, isSourceFile); - if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { + if (sourceFile && !sourceFile.symbol.exports.get("___esModule")) { if (languageVersion === ScriptTarget.ES3) { statements = append(statements, createStatement( @@ -1103,7 +1215,7 @@ namespace ts { if (node.kind === SyntaxKind.SourceFile) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[getOriginalNodeId(currentSourceFile)]; - noSubstitution = createMap(); + noSubstitution = []; previousOnEmitNode(emitContext, node, emitCallback); @@ -1333,15 +1445,4 @@ namespace ts { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; }` }; - - // emit output for the UMD helper function. - const umdHelper = ` - (function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; - } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); - } - })`; } diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 0e3a42da0d2..3f1488b649d 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -1,4 +1,4 @@ -/// +/// /// /*@internal*/ @@ -28,10 +28,10 @@ namespace ts { context.enableSubstitution(SyntaxKind.PostfixUnaryExpression); // Substitutes updates to exported symbols. context.enableEmitNotification(SyntaxKind.SourceFile); // Restore state when substituting nodes in a file. - const moduleInfoMap = createMap(); // The ExternalModuleInfo for each file. - const deferredExports = createMap(); // Exports to defer until an EndOfDeclarationMarker is found. - const exportFunctionsMap = createMap(); // The export function associated with a source file. - const noSubstitutionMap = createMap>(); // Set of nodes for which substitution rules should be ignored for each file. + const moduleInfoMap: ExternalModuleInfo[] = []; // The ExternalModuleInfo for each file. + const deferredExports: Statement[][] = []; // Exports to defer until an EndOfDeclarationMarker is found. + const exportFunctionsMap: Identifier[] = []; // The export function associated with a source file. + const noSubstitutionMap: boolean[][] = []; // Set of nodes for which substitution rules should be ignored for each file. let currentSourceFile: SourceFile; // The current file. let moduleInfo: ExternalModuleInfo; // ExternalModuleInfo for the current file. @@ -39,7 +39,7 @@ namespace ts { let contextObject: Identifier; // The context object for the current file. let hoistedStatements: Statement[]; let enclosingBlockScopedContainer: Node; - let noSubstitution: Map; // Set of nodes for which substitution rules should be ignored. + let noSubstitution: boolean[]; // Set of nodes for which substitution rules should be ignored. return transformSourceFile; @@ -77,7 +77,8 @@ namespace ts { // Make sure that the name of the 'exports' function does not conflict with // existing identifiers. - exportFunction = exportFunctionsMap[id] = createUniqueName("exports"); + exportFunction = createUniqueName("exports"); + exportFunctionsMap[id] = exportFunction; contextObject = createUniqueName("context"); // Add the body of the module. @@ -148,13 +149,13 @@ namespace ts { const externalImport = externalImports[i]; const externalModuleName = getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); const text = externalModuleName.text; - if (hasProperty(groupIndices, text)) { + const groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { // deduplicate/group entries in dependency list by the dependency name - const groupIndex = groupIndices[text]; dependencyGroups[groupIndex].externalImports.push(externalImport); } else { - groupIndices[text] = dependencyGroups.length; + groupIndices.set(text, dependencyGroups.length); dependencyGroups.push({ name: externalModuleName, externalImports: [externalImport] @@ -306,7 +307,7 @@ namespace ts { // this set is used to filter names brought by star expors. // local names set should only be added if we have anything exported - if (!moduleInfo.exportedNames && isEmpty(moduleInfo.exportSpecifiers)) { + if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) { // no exported declarations (export var ...) or export specifiers (export {x}) // check if we have any non star export declarations. let hasExportDeclarationWithExportClause = false; @@ -1081,7 +1082,7 @@ namespace ts { } const name = getDeclarationName(decl); - const exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + const exportSpecifiers = moduleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { for (const exportSpecifier of exportSpecifiers) { if (exportSpecifier.name.text !== excludeName) { @@ -1770,7 +1771,7 @@ namespace ts { * @param node The node which should not be substituted. */ function preventSubstitution(node: T): T { - if (noSubstitution === undefined) noSubstitution = createMap(); + if (noSubstitution === undefined) noSubstitution = []; noSubstitution[getNodeId(node)] = true; return node; } diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index f791025807a..e2b8b8fe2ec 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -1,4 +1,4 @@ -/// +/// /// /// @@ -60,7 +60,7 @@ namespace ts { * A map that keeps track of aliases created for classes with decorators to avoid issues * with the double-binding behavior of classes. */ - let classAliases: Map; + let classAliases: Identifier[]; /** * Keeps track of whether we are within any containing namespaces when performing @@ -2538,8 +2538,8 @@ namespace ts { currentScopeFirstDeclarationsOfName = createMap(); } - if (!(name in currentScopeFirstDeclarationsOfName)) { - currentScopeFirstDeclarationsOfName[name] = node; + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } } @@ -2552,7 +2552,7 @@ namespace ts { if (currentScopeFirstDeclarationsOfName) { const name = node.symbol && node.symbol.name; if (name) { - return currentScopeFirstDeclarationsOfName[name] === node; + return currentScopeFirstDeclarationsOfName.get(name) === node; } } @@ -2731,7 +2731,7 @@ namespace ts { let blockLocation: TextRange; const body = node.body; if (body.kind === SyntaxKind.ModuleBlock) { - addRange(statements, visitNodes((body).statements, namespaceElementVisitor, isStatement)); + saveStateAndInvoke(body, body => addRange(statements, visitNodes((body).statements, namespaceElementVisitor, isStatement))); statementsLocation = (body).statements; blockLocation = body; } @@ -3125,7 +3125,7 @@ namespace ts { context.enableSubstitution(SyntaxKind.Identifier); // Keep track of class aliases. - classAliases = createMap(); + classAliases = []; } } diff --git a/src/compiler/transformers/utilities.ts b/src/compiler/transformers/utilities.ts index 1338a30e368..ece5009c226 100644 --- a/src/compiler/transformers/utilities.ts +++ b/src/compiler/transformers/utilities.ts @@ -9,7 +9,7 @@ namespace ts { externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; // imports of other external modules externalHelpersImportDeclaration: ImportDeclaration | undefined; // import of external helpers exportSpecifiers: Map; // export specifiers by name - exportedBindings: Map; // exported names of local declarations + exportedBindings: Identifier[][]; // exported names of local declarations exportedNames: Identifier[]; // all exported names local to module exportEquals: ExportAssignment | undefined; // an export= declaration if one was present hasExportStarsToExportValues: boolean; // whether this module contains export* @@ -17,8 +17,8 @@ namespace ts { export function collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver, compilerOptions: CompilerOptions): ExternalModuleInfo { const externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[] = []; - const exportSpecifiers = createMap(); - const exportedBindings = createMap(); + const exportSpecifiers = createMultiMap(); + const exportedBindings: Identifier[][] = []; const uniqueExports = createMap(); let exportedNames: Identifier[]; let hasExportDefault = false; @@ -69,18 +69,18 @@ namespace ts { else { // export { x, y } for (const specifier of (node).exportClause.elements) { - if (!uniqueExports[specifier.name.text]) { + if (!uniqueExports.get(specifier.name.text)) { const name = specifier.propertyName || specifier.name; - multiMapAdd(exportSpecifiers, name.text, specifier); + exportSpecifiers.add(name.text, specifier); const decl = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name); if (decl) { - multiMapAdd(exportedBindings, getOriginalNodeId(decl), specifier.name); + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name); } - uniqueExports[specifier.name.text] = true; + uniqueExports.set(specifier.name.text, true); exportedNames = append(exportedNames, specifier.name); } } @@ -107,16 +107,16 @@ namespace ts { if (hasModifier(node, ModifierFlags.Default)) { // export default function() { } if (!hasExportDefault) { - multiMapAdd(exportedBindings, getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { // export function x() { } const name = (node).name; - if (!uniqueExports[name.text]) { - multiMapAdd(exportedBindings, getOriginalNodeId(node), name); - uniqueExports[name.text] = true; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); exportedNames = append(exportedNames, name); } } @@ -128,16 +128,16 @@ namespace ts { if (hasModifier(node, ModifierFlags.Default)) { // export default class { } if (!hasExportDefault) { - multiMapAdd(exportedBindings, getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { // export class x { } const name = (node).name; - if (!uniqueExports[name.text]) { - multiMapAdd(exportedBindings, getOriginalNodeId(node), name); - uniqueExports[name.text] = true; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); exportedNames = append(exportedNames, name); } } @@ -158,11 +158,23 @@ namespace ts { } } else if (!isGeneratedIdentifier(decl.name)) { - if (!uniqueExports[decl.name.text]) { - uniqueExports[decl.name.text] = true; + if (!uniqueExports.get(decl.name.text)) { + uniqueExports.set(decl.name.text, true); exportedNames = append(exportedNames, decl.name); } } return exportedNames; } -} + + /** Use a sparse array as a multi-map. */ + function multiMapSparseArrayAdd(map: V[][], key: number, value: V): V[] { + let values = map[key]; + if (values) { + values.push(value); + } + else { + map[key] = values = [value]; + } + return values; + } +} \ No newline at end of file diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 43c3533f7e4..18631f1c11a 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { @@ -67,11 +67,13 @@ namespace ts { const gutterSeparator = " "; const resetEscapeSequence = "\u001b[0m"; const ellipsis = "..."; - const categoryFormatMap = createMap({ - [DiagnosticCategory.Warning]: yellowForegroundEscapeSequence, - [DiagnosticCategory.Error]: redForegroundEscapeSequence, - [DiagnosticCategory.Message]: blueForegroundEscapeSequence, - }); + function getCategoryFormat(category: DiagnosticCategory): string { + switch (category) { + case DiagnosticCategory.Warning: return yellowForegroundEscapeSequence; + case DiagnosticCategory.Error: return redForegroundEscapeSequence; + case DiagnosticCategory.Message: return blueForegroundEscapeSequence; + } + } function formatAndReset(text: string, formatStyle: string) { return formatStyle + text + resetEscapeSequence; @@ -139,7 +141,7 @@ namespace ts { output += `${ relativeFileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `; } - const categoryColor = categoryFormatMap[diagnostic.category]; + const categoryColor = getCategoryFormat(diagnostic.category); const category = DiagnosticCategory[diagnostic.category].toLowerCase(); output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }`; output += sys.newLine + sys.newLine; @@ -155,7 +157,7 @@ namespace ts { output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `; } - output += `${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`; + output += `${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine + sys.newLine + sys.newLine }`; sys.write(output); } @@ -377,9 +379,11 @@ namespace ts { } function cachedFileExists(fileName: string): boolean { - return fileName in cachedExistingFiles - ? cachedExistingFiles[fileName] - : cachedExistingFiles[fileName] = hostFileExists(fileName); + let fileExists = cachedExistingFiles.get(fileName); + if (fileExists === undefined) { + cachedExistingFiles.set(fileName, fileExists = hostFileExists(fileName)); + } + return fileExists; } function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void) { @@ -673,13 +677,9 @@ namespace ts { if (option.name === "lib") { description = getDiagnosticText(option.description); - const options: string[] = []; const element = (option).element; const typeMap = >element.type; - for (const key in typeMap) { - options.push(`'${key}'`); - } - optionsDescriptionMap[description] = options; + optionsDescriptionMap.set(description, arrayFrom(typeMap.keys()).map(key => `'${key}'`)); } else { description = getDiagnosticText(option.description); @@ -701,7 +701,7 @@ namespace ts { for (let i = 0; i < usageColumn.length; i++) { const usage = usageColumn[i]; const description = descriptionColumn[i]; - const kindsList = optionsDescriptionMap[description]; + const kindsList = optionsDescriptionMap.get(description); output.push(usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine); if (kindsList) { diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index d409b724a38..e896f4f2978 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -1,18 +1,9 @@ { + "extends": "../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": true, "removeComments": true, - "preserveConstEnums": true, - "pretty": true, "outFile": "../../built/local/tsc.js", - "sourceMap": true, - "declaration": true, - "stripInternal": true, - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true, - "types": [ ] + "declaration": true }, "files": [ "core.ts", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index e32fb2e8ef5..7d17b21ba06 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1,11 +1,30 @@ -namespace ts { - +namespace ts { + /** + * Type of objects whose values are all of the same type. + * The `in` and `for-in` operators can *not* be safely used, + * since `Object.prototype` may be modified by outside code. + */ export interface MapLike { [index: string]: T; } - export interface Map extends MapLike { - __mapBrand: any; + /** ES6 Map interface. */ + export interface Map { + get(key: string): T; + has(key: string): boolean; + set(key: string, value: T): this; + delete(key: string): boolean; + clear(): void; + forEach(action: (value: T, key: string) => void): void; + readonly size: number; + keys(): Iterator; + values(): Iterator; + entries(): Iterator<[string, T]>; + } + + /** ES6 Iterator type. */ + export interface Iterator { + next(): { value: T, done: false } | { value: never, done: true }; } // branded string type used to store absolute, normalized and canonicalized paths @@ -175,6 +194,7 @@ namespace ts { ReadonlyKeyword, RequireKeyword, NumberKeyword, + ObjectKeyword, SetKeyword, StringKeyword, SymbolKeyword, @@ -253,6 +273,7 @@ namespace ts { ExpressionWithTypeArguments, AsExpression, NonNullExpression, + MetaProperty, // Misc TemplateSpan, @@ -370,7 +391,6 @@ namespace ts { PartiallyEmittedExpression, MergeDeclarationMarker, EndOfDeclarationMarker, - RawExpression, // Enum value count Count, @@ -640,9 +660,9 @@ namespace ts { export interface ParameterDeclaration extends Declaration { kind: SyntaxKind.Parameter; - dotDotDotToken?: DotDotDotToken; // Present on rest parameter + dotDotDotToken?: DotDotDotToken; // Present on rest parameter name: BindingName; // Declared parameter name - questionToken?: QuestionToken; // Present on optional parameter + questionToken?: QuestionToken; // Present on optional parameter type?: TypeNode; // Optional type annotation initializer?: Expression; // Optional initializer } @@ -658,14 +678,14 @@ namespace ts { export interface PropertySignature extends TypeElement { kind: SyntaxKind.PropertySignature | SyntaxKind.JSDocRecordMember; name: PropertyName; // Declared property name - questionToken?: QuestionToken; // Present on optional property + questionToken?: QuestionToken; // Present on optional property type?: TypeNode; // Optional type annotation initializer?: Expression; // Optional initializer } export interface PropertyDeclaration extends ClassElement { kind: SyntaxKind.PropertyDeclaration; - questionToken?: QuestionToken; // Present for use with reporting a grammar error + questionToken?: QuestionToken; // Present for use with reporting a grammar error name: PropertyName; type?: TypeNode; initializer?: Expression; // Optional initializer @@ -816,6 +836,7 @@ namespace ts { export interface KeywordTypeNode extends TypeNode { kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword + | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword @@ -1444,6 +1465,14 @@ namespace ts { expression: Expression; } + // NOTE: MetaProperty is really a MemberExpression, but we consider it a PrimaryExpression + // for the same reasons we treat NewExpression as a PrimaryExpression. + export interface MetaProperty extends PrimaryExpression { + kind: SyntaxKind.MetaProperty; + keywordToken: SyntaxKind; + name: Identifier; + } + /// A JSX expression of the form ... export interface JsxElement extends PrimaryExpression { kind: SyntaxKind.JsxElement; @@ -1492,6 +1521,7 @@ namespace ts { export interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; + dotDotDotToken?: Token; expression?: Expression; } @@ -1520,16 +1550,6 @@ namespace ts { kind: SyntaxKind.EndOfDeclarationMarker; } - /** - * Emits a string of raw text in an expression position. Raw text is never transformed, should - * be ES3 compliant, and should have the same precedence as PrimaryExpression. - */ - /* @internal */ - export interface RawExpression extends PrimaryExpression { - kind: SyntaxKind.RawExpression; - text: string; - } - /** * Marks the beginning of a merged transformed declaration. */ @@ -1551,7 +1571,7 @@ namespace ts { name?: Identifier; } - export type BlockLike = SourceFile | Block | ModuleBlock | CaseClause; + export type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; export interface Block extends Statement { kind: SyntaxKind.Block; @@ -2339,10 +2359,16 @@ namespace ts { getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol; + getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; getBaseTypes(type: InterfaceType): ObjectType[]; getReturnTypeOfSignature(signature: Signature): Type; + /** + * Gets the type of a parameter at a given position in a signature. + * Returns `any` if the index is not valid. + */ + /* @internal */ getParameterType(signature: Signature, parameterIndex: number): Type; getNonNullableType(type: Type): Type; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; @@ -2352,6 +2378,8 @@ namespace ts { getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol; getTypeAtLocation(node: Node): Type; + getTypeFromTypeNode(node: TypeNode): Type; + signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string; typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; getSymbolDisplayBuilder(): SymbolDisplayBuilder; @@ -2370,6 +2398,8 @@ namespace ts { isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; + /** Unlike `getExportsOfModule`, this includes properties of an `export =` value. */ + /* @internal */ getExportsAndPropertiesOfModule(moduleSymbol: Symbol): Symbol[]; getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; @@ -2377,6 +2407,7 @@ namespace ts { getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; + getApparentType(type: Type): Type; /* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol; @@ -2395,6 +2426,7 @@ namespace ts { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; + buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -2438,6 +2470,7 @@ namespace ts { InFirstTypeArgument = 0x00000100, // Writing first type argument of the instantiated type InTypeAlias = 0x00000200, // Writing type in type alias declaration UseTypeAliasValue = 0x00000400, // Serialize the type instead of using type-alias. This is needed when we emit declaration file. + SuppressAnyReturnType = 0x00000800, // If the return type is any-like, don't offer a return type. } export const enum SymbolFormatFlags { @@ -2717,6 +2750,7 @@ namespace ts { TypeChecked = 0x00000001, // Node has been type checked LexicalThis = 0x00000002, // Lexical 'this' reference CaptureThis = 0x00000004, // Lexical 'this' used in body + CaptureNewTarget = 0x00000008, // Lexical 'new.target' used in body SuperInstance = 0x00000100, // Instance 'super' reference SuperStatic = 0x00000200, // Static 'super' reference ContextChecked = 0x00000400, // Contextual types have been assigned @@ -2783,6 +2817,7 @@ namespace ts { ContainsObjectLiteral = 1 << 22, // Type is or contains object literal type /* @internal */ ContainsAnyFunctionType = 1 << 23, // Type is or contains object literal type + NonPrimitive = 1 << 24, // intrinsic object type /* @internal */ Nullable = Undefined | Null, @@ -2792,7 +2827,7 @@ namespace ts { DefinitelyFalsy = StringLiteral | NumberLiteral | BooleanLiteral | Void | Undefined | Null, PossiblyFalsy = DefinitelyFalsy | String | Number | Boolean, /* @internal */ - Intrinsic = Any | String | Number | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never, + Intrinsic = Any | String | Number | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never | NonPrimitive, /* @internal */ Primitive = String | Number | Boolean | Enum | ESSymbol | Void | Undefined | Null | Literal, StringLike = String | StringLiteral | Index, @@ -2801,13 +2836,13 @@ namespace ts { EnumLike = Enum | EnumLiteral, UnionOrIntersection = Union | Intersection, StructuredType = Object | Union | Intersection, - StructuredOrTypeParameter = StructuredType | TypeParameter | Index, + StructuredOrTypeVariable = StructuredType | TypeParameter | Index | IndexedAccess, TypeVariable = TypeParameter | IndexedAccess, // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol, - NotUnionOrUnit = Any | ESSymbol | Object, + Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol | NonPrimitive, + NotUnionOrUnit = Any | ESSymbol | Object | NonPrimitive, /* @internal */ RequiresWidening = ContainsWideningType | ContainsObjectLiteral, /* @internal */ @@ -2842,7 +2877,7 @@ namespace ts { // Enum types (TypeFlags.Enum) export interface EnumType extends Type { - memberTypes: Map; + memberTypes: EnumLiteralType[]; } // Enum types (TypeFlags.EnumLiteral) @@ -2861,6 +2896,7 @@ namespace ts { ObjectLiteral = 1 << 7, // Originates in an object literal EvolvingArray = 1 << 8, // Evolving array type ObjectLiteralPatternWithComputedProperties = 1 << 9, // Object literal pattern with computed properties + NonPrimitive = 1 << 10, // NonPrimitive object type ClassOrInterface = Class | Interface } @@ -2869,7 +2905,7 @@ namespace ts { objectFlags: ObjectFlags; } - // Class and interface types (TypeFlags.Class and TypeFlags.Interface) + /** Class and interface types (TypeFlags.Class and TypeFlags.Interface). */ export interface InterfaceType extends ObjectType { typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic) outerTypeParameters: TypeParameter[]; // Outer type parameters (undefined if none) @@ -2889,14 +2925,16 @@ namespace ts { declaredNumberIndexInfo: IndexInfo; // Declared numeric indexing info } - // Type references (TypeFlags.Reference). When a class or interface has type parameters or - // a "this" type, references to the class or interface are made using type references. The - // typeArguments property specifies the types to substitute for the type parameters of the - // class or interface and optionally includes an extra element that specifies the type to - // substitute for "this" in the resulting instantiation. When no extra argument is present, - // the type reference itself is substituted for "this". The typeArguments property is undefined - // if the class or interface has no type parameters and the reference isn't specifying an - // explicit "this" argument. + /** + * Type references (TypeFlags.Reference). When a class or interface has type parameters or + * a "this" type, references to the class or interface are made using type references. The + * typeArguments property specifies the types to substitute for the type parameters of the + * class or interface and optionally includes an extra element that specifies the type to + * substitute for "this" in the resulting instantiation. When no extra argument is present, + * the type reference itself is substituted for "this". The typeArguments property is undefined + * if the class or interface has no type parameters and the reference isn't specifying an + * explicit "this" argument. + */ export interface TypeReference extends ObjectType { target: GenericType; // Type reference target typeArguments: Type[]; // Type reference type arguments (undefined if none) @@ -2915,6 +2953,8 @@ namespace ts { /* @internal */ resolvedIndexType: IndexType; /* @internal */ + resolvedBaseConstraint: Type; + /* @internal */ couldContainTypeVariables: boolean; } @@ -2974,7 +3014,7 @@ namespace ts { export interface TypeVariable extends Type { /* @internal */ - resolvedApparentType: Type; + resolvedBaseConstraint: Type; /* @internal */ resolvedIndexType: IndexType; } @@ -3550,6 +3590,7 @@ namespace ts { export interface ResolvedModuleWithFailedLookupLocations { resolvedModule: ResolvedModuleFull | undefined; + /* @internal */ failedLookupLocations: string[]; } @@ -3674,7 +3715,7 @@ namespace ts { flags?: EmitFlags; // Flags that customize emit commentRange?: TextRange; // The text range to use when emitting leading or trailing comments sourceMapRange?: TextRange; // The text range to use when emitting leading or trailing source mappings - tokenSourceMapRanges?: Map; // The text range to use when emitting source mappings for tokens + tokenSourceMapRanges?: TextRange[]; // The text range to use when emitting source mappings for tokens constantValue?: number; // The constant value of an expression externalHelpersModuleName?: Identifier; // The local name for an imported helpers module helpers?: EmitHelper[]; // Emit helpers for the node diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 32c0e60d32f..b18a2f929c0 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -70,11 +70,11 @@ namespace ts { } export function hasResolvedModule(sourceFile: SourceFile, moduleNameText: string): boolean { - return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText)); } export function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModuleFull { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules.get(moduleNameText) : undefined; } export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModuleFull): void { @@ -82,7 +82,7 @@ namespace ts { sourceFile.resolvedModules = createMap(); } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; + sourceFile.resolvedModules.set(moduleNameText, resolvedModule); } export function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective): void { @@ -90,7 +90,7 @@ namespace ts { sourceFile.resolvedTypeReferenceDirectiveNames = createMap(); } - sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; + sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective); } /* @internal */ @@ -112,7 +112,7 @@ namespace ts { } for (let i = 0; i < names.length; i++) { const newResolution = newResolutions[i]; - const oldResolution = oldResolutions && oldResolutions[names[i]]; + const oldResolution = oldResolutions && oldResolutions.get(names[i]); const changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) @@ -550,7 +550,7 @@ namespace ts { let errorNode = node; switch (node.kind) { case SyntaxKind.SourceFile: - let pos = skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); + const pos = skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos === sourceFile.text.length) { // file is empty - return span for the beginning of the file return createTextSpan(0, 0); @@ -682,7 +682,7 @@ namespace ts { case SyntaxKind.QualifiedName: case SyntaxKind.PropertyAccessExpression: case SyntaxKind.ThisKeyword: - let parent = node.parent; + const parent = node.parent; if (parent.kind === SyntaxKind.TypeQuery) { return false; } @@ -732,9 +732,9 @@ namespace ts { return false; } - export function isChildOfLiteralType(node: Node): boolean { + export function isChildOfNodeWithKind(node: Node, kind: SyntaxKind): boolean { while (node) { - if (node.kind === SyntaxKind.LiteralType) { + if (node.kind === kind) { return true; } node = node.parent; @@ -742,6 +742,10 @@ namespace ts { return false; } + export function isPrefixUnaryExpression(node: Node): node is PrefixUnaryExpression { + return node.kind === SyntaxKind.PrefixUnaryExpression; + } + // Warning: This has the same semantics as the forEach family of functions, // in that traversal terminates in the event that 'visitor' supplies a truthy value. export function forEachReturnStatement(body: Block, visitor: (stmt: ReturnStatement) => T): T { @@ -780,7 +784,7 @@ namespace ts { switch (node.kind) { case SyntaxKind.YieldExpression: visitor(node); - let operand = (node).expression; + const operand = (node).expression; if (operand) { traverse(operand); } @@ -910,6 +914,17 @@ namespace ts { return false; } + export function unwrapInnermostStatmentOfLabel(node: LabeledStatement, beforeUnwrapLabelCallback?: (node: LabeledStatement) => void) { + while (true) { + if (beforeUnwrapLabelCallback) { + beforeUnwrapLabelCallback(node); + } + if (node.statement.kind !== SyntaxKind.LabeledStatement) { + return node.statement; + } + node = node.statement; + } + } export function isFunctionBlock(node: Node) { return node && node.kind === SyntaxKind.Block && isFunctionLike(node.parent); @@ -1011,6 +1026,20 @@ namespace ts { } } + export function getNewTargetContainer(node: Node) { + const container = getThisContainer(node, /*includeArrowFunctions*/ false); + if (container) { + switch (container.kind) { + case SyntaxKind.Constructor: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + return container; + } + } + + return undefined; + } + /** * Given an super call/property node, returns the closest node where * - a super call/property access is legal in the node and not legal in the parent node the node. @@ -1218,6 +1247,7 @@ namespace ts { case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.YieldExpression: case SyntaxKind.AwaitExpression: + case SyntaxKind.MetaProperty: return true; case SyntaxKind.QualifiedName: while (node.parent.kind === SyntaxKind.QualifiedName) { @@ -1232,7 +1262,7 @@ namespace ts { case SyntaxKind.NumericLiteral: case SyntaxKind.StringLiteral: case SyntaxKind.ThisKeyword: - let parent = node.parent; + const parent = node.parent; switch (parent.kind) { case SyntaxKind.VariableDeclaration: case SyntaxKind.Parameter: @@ -1254,13 +1284,13 @@ namespace ts { case SyntaxKind.SwitchStatement: return (parent).expression === node; case SyntaxKind.ForStatement: - let forStatement = parent; + const forStatement = parent; return (forStatement.initializer === node && forStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || forStatement.condition === node || forStatement.incrementor === node; case SyntaxKind.ForInStatement: case SyntaxKind.ForOfStatement: - let forInStatement = parent; + const forInStatement = parent; return (forInStatement.initializer === node && forInStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || forInStatement.expression === node; case SyntaxKind.TypeAssertionExpression: @@ -1647,6 +1677,18 @@ namespace ts { return getAssignmentTargetKind(node) !== AssignmentKind.None; } + // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped + export function isDeleteTarget(node: Node): boolean { + if (node.kind !== SyntaxKind.PropertyAccessExpression && node.kind !== SyntaxKind.ElementAccessExpression) { + return false; + } + node = node.parent; + while (node && node.kind === SyntaxKind.ParenthesizedExpression) { + node = node.parent; + } + return node && node.kind === SyntaxKind.DeleteExpression; + } + export function isNodeDescendantOf(node: Node, ancestor: Node): boolean { while (node) { if (node === ancestor) return true; @@ -1782,7 +1824,7 @@ namespace ts { } } - export function getAncestor(node: Node, kind: SyntaxKind): Node { + export function getAncestor(node: Node | undefined, kind: SyntaxKind): Node { while (node) { if (node.kind === kind) { return node; @@ -2103,7 +2145,6 @@ namespace ts { case SyntaxKind.TemplateExpression: case SyntaxKind.ParenthesizedExpression: case SyntaxKind.OmittedExpression: - case SyntaxKind.RawExpression: return 19; case SyntaxKind.TaggedTemplateExpression: @@ -2233,22 +2274,16 @@ namespace ts { } function reattachFileDiagnostics(newFile: SourceFile): void { - if (!hasProperty(fileDiagnostics, newFile.fileName)) { - return; - } - - for (const diagnostic of fileDiagnostics[newFile.fileName]) { - diagnostic.file = newFile; - } + forEach(fileDiagnostics.get(newFile.fileName), diagnostic => diagnostic.file = newFile); } function add(diagnostic: Diagnostic): void { let diagnostics: Diagnostic[]; if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); if (!diagnostics) { diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; + fileDiagnostics.set(diagnostic.file.fileName, diagnostics); } } else { @@ -2268,7 +2303,7 @@ namespace ts { function getDiagnostics(fileName?: string): Diagnostic[] { sortAndDeduplicate(); if (fileName) { - return fileDiagnostics[fileName] || []; + return fileDiagnostics.get(fileName) || []; } const allDiagnostics: Diagnostic[] = []; @@ -2278,9 +2313,9 @@ namespace ts { forEach(nonFileDiagnostics, pushDiagnostic); - for (const key in fileDiagnostics) { - forEach(fileDiagnostics[key], pushDiagnostic); - } + fileDiagnostics.forEach(diagnostics => { + forEach(diagnostics, pushDiagnostic); + }); return sortAndDeduplicateDiagnostics(allDiagnostics); } @@ -2293,9 +2328,9 @@ namespace ts { diagnosticsModified = false; nonFileDiagnostics = sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (const key in fileDiagnostics) { - fileDiagnostics[key] = sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } + fileDiagnostics.forEach((diagnostics, key) => { + fileDiagnostics.set(key, sortAndDeduplicateDiagnostics(diagnostics)); + }); } } @@ -2305,7 +2340,7 @@ namespace ts { // the map below must be updated. Note that this regexp *does not* include the 'delete' character. // There is no reason for this other than that JSON.stringify does not handle it either. const escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - const escapedCharsMap = createMap({ + const escapedCharsMap = createMapFromTemplate({ "\0": "\\0", "\t": "\\t", "\v": "\\v", @@ -2327,13 +2362,11 @@ namespace ts { * Note that this doesn't actually wrap the input in double quotes. */ export function escapeString(s: string): string { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; + return s.replace(escapedCharsRegExp, getReplacement); + } - return s; - - function getReplacement(c: string) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } + function getReplacement(c: string) { + return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); } export function isIntrinsicJsxName(name: string) { @@ -3333,18 +3366,21 @@ namespace ts { return false; } - const syntaxKindCache = createMap(); + const syntaxKindCache: string[] = []; export function formatSyntaxKind(kind: SyntaxKind): string { const syntaxKindEnum = (ts).SyntaxKind; if (syntaxKindEnum) { - if (syntaxKindCache[kind]) { - return syntaxKindCache[kind]; + const cached = syntaxKindCache[kind]; + if (cached !== undefined) { + return cached; } for (const name in syntaxKindEnum) { if (syntaxKindEnum[name] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name + ")"; + const result = `${kind} (${name})`; + syntaxKindCache[kind] = result; + return result; } } } @@ -3851,7 +3887,7 @@ namespace ts { || kind === SyntaxKind.TrueKeyword || kind === SyntaxKind.SuperKeyword || kind === SyntaxKind.NonNullExpression - || kind === SyntaxKind.RawExpression; + || kind === SyntaxKind.MetaProperty; } export function skipPartiallyEmittedExpressions(node: Expression): Expression; @@ -3891,7 +3927,6 @@ namespace ts { || kind === SyntaxKind.SpreadElement || kind === SyntaxKind.AsExpression || kind === SyntaxKind.OmittedExpression - || kind === SyntaxKind.RawExpression || isUnaryExpressionKind(kind); } diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 43e01ca56bb..f3efc040e35 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -1,4 +1,4 @@ -/// +/// /// /// @@ -46,54 +46,56 @@ namespace ts { * supplant the existing `forEachChild` implementation if performance is not * significantly impacted. */ - const nodeEdgeTraversalMap = createMap({ - [SyntaxKind.QualifiedName]: [ - { name: "left", test: isEntityName }, - { name: "right", test: isIdentifier } - ], - [SyntaxKind.Decorator]: [ - { name: "expression", test: isLeftHandSideExpression } - ], - [SyntaxKind.TypeAssertionExpression]: [ - { name: "type", test: isTypeNode }, - { name: "expression", test: isUnaryExpression } - ], - [SyntaxKind.AsExpression]: [ - { name: "expression", test: isExpression }, - { name: "type", test: isTypeNode } - ], - [SyntaxKind.NonNullExpression]: [ - { name: "expression", test: isLeftHandSideExpression } - ], - [SyntaxKind.EnumDeclaration]: [ - { name: "decorators", test: isDecorator }, - { name: "modifiers", test: isModifier }, - { name: "name", test: isIdentifier }, - { name: "members", test: isEnumMember } - ], - [SyntaxKind.ModuleDeclaration]: [ - { name: "decorators", test: isDecorator }, - { name: "modifiers", test: isModifier }, - { name: "name", test: isModuleName }, - { name: "body", test: isModuleBody } - ], - [SyntaxKind.ModuleBlock]: [ - { name: "statements", test: isStatement } - ], - [SyntaxKind.ImportEqualsDeclaration]: [ - { name: "decorators", test: isDecorator }, - { name: "modifiers", test: isModifier }, - { name: "name", test: isIdentifier }, - { name: "moduleReference", test: isModuleReference } - ], - [SyntaxKind.ExternalModuleReference]: [ - { name: "expression", test: isExpression, optional: true } - ], - [SyntaxKind.EnumMember]: [ - { name: "name", test: isPropertyName }, - { name: "initializer", test: isExpression, optional: true, parenthesize: parenthesizeExpressionForList } - ] - }); + function getNodeEdgeTraversal(kind: SyntaxKind): NodeTraversalPath { + switch (kind) { + case SyntaxKind.QualifiedName: return [ + { name: "left", test: isEntityName }, + { name: "right", test: isIdentifier } + ]; + case SyntaxKind.Decorator: return [ + { name: "expression", test: isLeftHandSideExpression } + ]; + case SyntaxKind.TypeAssertionExpression: return [ + { name: "type", test: isTypeNode }, + { name: "expression", test: isUnaryExpression } + ]; + case SyntaxKind.AsExpression: return [ + { name: "expression", test: isExpression }, + { name: "type", test: isTypeNode } + ]; + case SyntaxKind.NonNullExpression: return [ + { name: "expression", test: isLeftHandSideExpression } + ]; + case SyntaxKind.EnumDeclaration: return [ + { name: "decorators", test: isDecorator }, + { name: "modifiers", test: isModifier }, + { name: "name", test: isIdentifier }, + { name: "members", test: isEnumMember } + ]; + case SyntaxKind.ModuleDeclaration: return [ + { name: "decorators", test: isDecorator }, + { name: "modifiers", test: isModifier }, + { name: "name", test: isModuleName }, + { name: "body", test: isModuleBody } + ]; + case SyntaxKind.ModuleBlock: return [ + { name: "statements", test: isStatement } + ]; + case SyntaxKind.ImportEqualsDeclaration: return [ + { name: "decorators", test: isDecorator }, + { name: "modifiers", test: isModifier }, + { name: "name", test: isIdentifier }, + { name: "moduleReference", test: isModuleReference } + ]; + case SyntaxKind.ExternalModuleReference: return [ + { name: "expression", test: isExpression, optional: true } + ]; + case SyntaxKind.EnumMember: return [ + { name: "name", test: isPropertyName }, + { name: "initializer", test: isExpression, optional: true, parenthesize: parenthesizeExpressionForList } + ]; + } + } function reduceNode(node: Node, f: (memo: T, node: Node) => T, initial: T) { return node ? f(initial, node) : initial; @@ -530,7 +532,7 @@ namespace ts { break; default: - const edgeTraversalPath = nodeEdgeTraversalMap[kind]; + const edgeTraversalPath = getNodeEdgeTraversal(kind); if (edgeTraversalPath) { for (const edge of edgeTraversalPath) { const value = (>node)[edge.name]; @@ -1188,10 +1190,10 @@ namespace ts { default: let updated: Node & MapLike; - const edgeTraversalPath = nodeEdgeTraversalMap[kind]; + const edgeTraversalPath = getNodeEdgeTraversal(kind); if (edgeTraversalPath) { for (const edge of edgeTraversalPath) { - const value = >(>node)[edge.name]; + const value = >(>node)[edge.name]; if (value !== undefined) { const visited = isArray(value) ? visitNodes(value, visitor, edge.test, 0, value.length, edge.parenthesize, node) @@ -1328,7 +1330,7 @@ namespace ts { function aggregateTransformFlagsForSubtree(node: Node): TransformFlags { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (hasModifier(node, ModifierFlags.Ambient) || isTypeNode(node)) { + if (hasModifier(node, ModifierFlags.Ambient) || (isTypeNode(node) && node.kind !== SyntaxKind.ExpressionWithTypeArguments)) { return TransformFlags.None; } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 653b87236fd..8ad715681ec 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -40,10 +40,18 @@ namespace FourSlash { files: FourSlashFile[]; // A mapping from marker names to name/position pairs - markerPositions: { [index: string]: Marker; }; + markerPositions: ts.Map; markers: Marker[]; + /** + * Inserted in source files by surrounding desired text + * in a range with `[|` and `|]`. For example, + * + * [|text in range|] + * + * is a range with `text in range` "selected". + */ ranges: Range[]; } @@ -53,10 +61,6 @@ namespace FourSlash { data?: any; } - interface MarkerMap { - [index: string]: Marker; - } - export interface Range { fileName: string; start: number; @@ -86,7 +90,7 @@ namespace FourSlash { export import IndentStyle = ts.IndentStyle; - const entityMap = ts.createMap({ + const entityMap = ts.createMapFromTemplate({ "&": "&", "\"": """, "'": "'", @@ -96,7 +100,7 @@ namespace FourSlash { }); export function escapeXmlAttributeValue(s: string) { - return s.replace(/[&<>"'\/]/g, ch => entityMap[ch]); + return s.replace(/[&<>"'\/]/g, ch => entityMap.get(ch)); } // Name of testcase metadata including ts.CompilerOptions properties that will be used by globalOptions @@ -222,7 +226,7 @@ namespace FourSlash { } function tryAdd(path: string) { - const inputFile = inputFiles[path]; + const inputFile = inputFiles.get(path); if (inputFile && !Harness.isDefaultLibraryFile(path)) { languageServiceAdapterHost.addScript(path, inputFile, /*isRootFile*/ true); return true; @@ -254,23 +258,12 @@ namespace FourSlash { // Initialize the language service with all the scripts let startResolveFileRef: FourSlashFile; + let configFileName: string; ts.forEach(testData.files, file => { // Create map between fileName and its content for easily looking up when resolveReference flag is specified - this.inputFiles[file.fileName] = file.content; - + this.inputFiles.set(file.fileName, file.content); if (ts.getBaseFileName(file.fileName).toLowerCase() === "tsconfig.json") { - const configJson = ts.parseConfigFileTextToJson(file.fileName, file.content); - assert.isTrue(configJson.config !== undefined); - - // Extend our existing compiler options so that we can also support tsconfig only options - if (configJson.config.compilerOptions) { - const baseDirectory = ts.normalizePath(ts.getDirectoryPath(file.fileName)); - const tsConfig = ts.convertCompilerOptionsFromJson(configJson.config.compilerOptions, baseDirectory, file.fileName); - - if (!tsConfig.errors || !tsConfig.errors.length) { - compilationOptions = ts.extend(compilationOptions, tsConfig.options); - } - } + configFileName = file.fileName; } if (!startResolveFileRef && file.fileOptions[metadataOptionNames.resolveReference] === "true") { @@ -282,6 +275,21 @@ namespace FourSlash { } }); + if (configFileName) { + const baseDir = ts.normalizePath(ts.getDirectoryPath(configFileName)); + const host = new Utils.MockParseConfigHost(baseDir, /*ignoreCase*/ false, this.inputFiles); + + const configJsonObj = ts.parseConfigFileTextToJson(configFileName, this.inputFiles.get(configFileName)); + assert.isTrue(configJsonObj.config !== undefined); + + const { options, errors } = ts.parseJsonConfigFileContent(configJsonObj.config, host, baseDir); + + // Extend our existing compiler options so that we can also support tsconfig only options + if (!errors || errors.length === 0) { + compilationOptions = ts.extend(compilationOptions, options); + } + } + if (compilationOptions.typeRoots) { compilationOptions.typeRoots = compilationOptions.typeRoots.map(p => ts.getNormalizedAbsolutePath(p, this.basePath)); @@ -322,11 +330,11 @@ namespace FourSlash { } else { // resolveReference file-option is not specified then do not resolve any files and include all inputFiles - for (const fileName in this.inputFiles) { + this.inputFiles.forEach((file, fileName) => { if (!Harness.isDefaultLibraryFile(fileName)) { - this.languageServiceAdapterHost.addScript(fileName, this.inputFiles[fileName], /*isRootFile*/ true); + this.languageServiceAdapterHost.addScript(fileName, file, /*isRootFile*/ true); } - } + }); this.languageServiceAdapterHost.addScript(Harness.Compiler.defaultLibFileName, Harness.Compiler.getDefaultLibrarySourceFile().text, /*isRootFile*/ false); } @@ -413,8 +421,7 @@ namespace FourSlash { } private raiseError(message: string) { - message = this.messageAtLastKnownMarker(message); - throw new Error(message); + throw new Error(this.messageAtLastKnownMarker(message)); } private messageAtLastKnownMarker(message: string) { @@ -479,7 +486,7 @@ namespace FourSlash { endPos = endMarker.position; } - errors.forEach(function(error: ts.Diagnostic) { + errors.forEach(function (error: ts.Diagnostic) { if (predicate(error.start, error.start + error.length, startPos, endPos)) { exists = true; } @@ -496,7 +503,7 @@ namespace FourSlash { Harness.IO.log("Unexpected error(s) found. Error list is:"); } - errors.forEach(function(error: ts.Diagnostic) { + errors.forEach(function (error: ts.Diagnostic) { Harness.IO.log(" minChar: " + error.start + ", limChar: " + (error.start + error.length) + ", message: " + ts.flattenDiagnosticMessageText(error.messageText, Harness.IO.newLine()) + "\n"); @@ -528,53 +535,66 @@ namespace FourSlash { } public verifyGoToDefinitionIs(endMarker: string | string[]) { - this.verifyGoToDefinitionWorker(endMarker instanceof Array ? endMarker : [endMarker]); + this.verifyGoToXWorker(endMarker instanceof Array ? endMarker : [endMarker], () => this.getGoToDefinition()); } public verifyGoToDefinition(arg0: any, endMarkerNames?: string | string[]) { + this.verifyGoToX(arg0, endMarkerNames, () => this.getGoToDefinition()); + } + + private getGoToDefinition(): ts.DefinitionInfo[] { + return this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition) + } + + public verifyGoToType(arg0: any, endMarkerNames?: string | string[]) { + this.verifyGoToX(arg0, endMarkerNames, () => + this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition)); + } + + private verifyGoToX(arg0: any, endMarkerNames: string | string[] | undefined, getDefs: () => ts.DefinitionInfo[] | undefined) { if (endMarkerNames) { - this.verifyGoToDefinitionPlain(arg0, endMarkerNames); + this.verifyGoToXPlain(arg0, endMarkerNames, getDefs); } else if (arg0 instanceof Array) { const pairs: [string | string[], string | string[]][] = arg0; for (const [start, end] of pairs) { - this.verifyGoToDefinitionPlain(start, end); + this.verifyGoToXPlain(start, end, getDefs); } } else { const obj: { [startMarkerName: string]: string | string[] } = arg0; for (const startMarkerName in obj) { if (ts.hasProperty(obj, startMarkerName)) { - this.verifyGoToDefinitionPlain(startMarkerName, obj[startMarkerName]); + this.verifyGoToXPlain(startMarkerName, obj[startMarkerName], getDefs); } } } } - private verifyGoToDefinitionPlain(startMarkerNames: string | string[], endMarkerNames: string | string[]) { + private verifyGoToXPlain(startMarkerNames: string | string[], endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | undefined) { if (startMarkerNames instanceof Array) { for (const start of startMarkerNames) { - this.verifyGoToDefinitionSingle(start, endMarkerNames); + this.verifyGoToXSingle(start, endMarkerNames, getDefs); } } else { - this.verifyGoToDefinitionSingle(startMarkerNames, endMarkerNames); + this.verifyGoToXSingle(startMarkerNames, endMarkerNames, getDefs); } } public verifyGoToDefinitionForMarkers(markerNames: string[]) { for (const markerName of markerNames) { - this.verifyGoToDefinitionSingle(`${markerName}Reference`, `${markerName}Definition`); + this.verifyGoToXSingle(`${markerName}Reference`, `${markerName}Definition`, () => this.getGoToDefinition()); } } - private verifyGoToDefinitionSingle(startMarkerName: string, endMarkerNames: string | string[]) { + private verifyGoToXSingle(startMarkerName: string, endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | undefined) { this.goToMarker(startMarkerName); - this.verifyGoToDefinitionWorker(endMarkerNames instanceof Array ? endMarkerNames : [endMarkerNames]); + this.verifyGoToXWorker(endMarkerNames instanceof Array ? endMarkerNames : [endMarkerNames], getDefs); } - private verifyGoToDefinitionWorker(endMarkers: string[]) { - const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition) || []; + private verifyGoToXWorker(endMarkers: string[], getDefs: () => ts.DefinitionInfo[] | undefined) { + const definitions = getDefs() || []; if (endMarkers.length !== definitions.length) { this.raiseError(`goToDefinitions failed - expected to find ${endMarkers.length} definitions but got ${definitions.length}`); @@ -660,11 +680,12 @@ namespace FourSlash { const completions = this.getCompletionListAtCaret(); const uniqueItems = ts.createMap(); for (const item of completions.entries) { - if (!(item.name in uniqueItems)) { - uniqueItems[item.name] = item.kind; + const uniqueItem = uniqueItems.get(item.name); + if (!uniqueItem) { + uniqueItems.set(item.name, item.kind); } else { - assert.equal(item.kind, uniqueItems[item.name], `Items should have the same kind, got ${item.kind} and ${uniqueItems[item.name]}`); + assert.equal(item.kind, uniqueItem, `Items should have the same kind, got ${item.kind} and ${uniqueItem}`); } } } @@ -698,6 +719,27 @@ namespace FourSlash { } } + public verifyCompletionsAt(markerName: string, expected: string[]) { + this.goToMarker(markerName); + + const actualCompletions = this.getCompletionListAtCaret(); + if (!actualCompletions) { + this.raiseError(`No completions at position '${this.currentCaretPosition}'.`); + } + + const actual = actualCompletions.entries; + + if (actual.length !== expected.length) { + this.raiseError(`Expected ${expected.length} completions, got ${actual.map(a => a.name)}.`); + } + + ts.zipWith(actual, expected, (completion, expectedCompletion, index) => { + if (completion.name !== expectedCompletion) { + this.raiseError(`Expected completion at index ${index} to be ${expectedCompletion}, got ${completion.name}`); + } + }); + } + public verifyCompletionListContains(symbol: string, text?: string, documentation?: string, kind?: string, spanIndex?: number) { const completions = this.getCompletionListAtCaret(); if (completions) { @@ -832,7 +874,7 @@ namespace FourSlash { } public verifyRangesWithSameTextReferenceEachOther() { - ts.forEachProperty(this.rangesByText(), ranges => this.verifyRangesReferenceEachOther(ranges)); + this.rangesByText().forEach(ranges => this.verifyRangesReferenceEachOther(ranges)); } public verifyDisplayPartsOfReferencedSymbol(expected: ts.SymbolDisplayPart[]) { @@ -904,7 +946,8 @@ namespace FourSlash { } public verifyQuickInfos(namesAndTexts: { [name: string]: string | [string, string] }) { - ts.forEachProperty(ts.createMap(namesAndTexts), (text, name) => { + for (const name in namesAndTexts) if (ts.hasProperty(namesAndTexts, name)) { + const text = namesAndTexts[name]; if (text instanceof Array) { assert(text.length === 2); const [expectedText, expectedDocumentation] = text; @@ -913,7 +956,7 @@ namespace FourSlash { else { this.verifyQuickInfoAt(name, text); } - }); + } } public verifyQuickInfoString(expectedText: string, expectedDocumentation?: string) { @@ -1533,7 +1576,8 @@ namespace FourSlash { let runningOffset = 0; edits = edits.sort((a, b) => a.span.start - b.span.start); // Get a snapshot of the content of the file so we can make sure any formatting edits didn't destroy non-whitespace characters - const oldContent = this.getFileContent(this.activeFile.fileName); + const oldContent = this.getFileContent(fileName); + for (const edit of edits) { this.languageServiceAdapterHost.editScript(fileName, edit.span.start + runningOffset, ts.textSpanEnd(edit.span) + runningOffset, edit.newText); this.updateMarkersForEdit(fileName, edit.span.start + runningOffset, ts.textSpanEnd(edit.span) + runningOffset, edit.newText); @@ -1750,7 +1794,7 @@ namespace FourSlash { } public getMarkerNames(): string[] { - return Object.keys(this.testData.markerPositions); + return ts.arrayFrom(this.testData.markerPositions.keys()); } public getRanges(): Range[] { @@ -1758,10 +1802,10 @@ namespace FourSlash { } public rangesByText(): ts.Map { - const result = ts.createMap(); + const result = ts.createMultiMap(); for (const range of this.getRanges()) { const text = this.rangeText(range); - ts.multiMapAdd(result, text, range); + result.add(text, range); } return result; } @@ -1970,54 +2014,93 @@ namespace FourSlash { }); } - private getCodeFixes(errorCode?: number) { - const fileName = this.activeFile.fileName; - const diagnostics = this.getDiagnostics(fileName); - - if (diagnostics.length === 0) { - this.raiseError("Errors expected."); - } - - if (diagnostics.length > 1 && errorCode === undefined) { - this.raiseError("When there's more than one error, you must specify the errror to fix."); - } - - const diagnostic = !errorCode ? diagnostics[0] : ts.find(diagnostics, d => d.code == errorCode); - - return this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.start + diagnostic.length, [diagnostic.code]); - } - - public verifyCodeFixAtPosition(expectedText: string, errorCode?: number) { + /** + * Compares expected text to the text that would be in the sole range + * (ie: [|...|]) in the file after applying the codefix sole codefix + * in the source file. + * + * Because codefixes are only applied on the working file, it is unsafe + * to apply this more than once (consider a refactoring across files). + */ + public verifyRangeAfterCodeFix(expectedText: string, errorCode?: number) { const ranges = this.getRanges(); - if (ranges.length == 0) { - this.raiseError("At least one range should be specified in the testfile."); + if (ranges.length !== 1) { + this.raiseError("Exactly one range should be specified in the testfile."); } - const actual = this.getCodeFixes(errorCode); + const fileName = this.activeFile.fileName; - if (!actual || actual.length == 0) { - this.raiseError("No codefixes returned."); - } + this.applyCodeFixActions(fileName, this.getCodeFixActions(fileName, errorCode)); - if (actual.length > 1) { - this.raiseError("More than 1 codefix returned."); - } - - this.applyEdits(actual[0].changes[0].fileName, actual[0].changes[0].textChanges, /*isFormattingEdit*/ false); const actualText = this.rangeText(ranges[0]); if (this.removeWhitespace(actualText) !== this.removeWhitespace(expectedText)) { - this.raiseError(`Actual text doesn't match expected text. Actual: '${actualText}' Expected: '${expectedText}'`); + this.raiseError(`Actual text doesn't match expected text. Actual:\n'${actualText}'\nExpected:\n'${expectedText}'`); } } + /** + * Applies fixes for the errors in fileName and compares the results to + * expectedContents after all fixes have been applied. + + * Note: applying one codefix may generate another (eg: remove duplicate implements + * may generate an extends -> interface conversion fix). + * @param expectedContents The contents of the file after the fixes are applied. + * @param fileName The file to check. If not supplied, the current open file is used. + */ + public verifyFileAfterCodeFix(expectedContents: string, fileName?: string) { + fileName = fileName ? fileName : this.activeFile.fileName; + + this.applyCodeFixActions(fileName, this.getCodeFixActions(fileName)); + + const actualContents: string = this.getFileContent(fileName); + if (this.removeWhitespace(actualContents) !== this.removeWhitespace(expectedContents)) { + this.raiseError(`Actual text doesn't match expected text. Actual:\n${actualContents}\n\nExpected:\n${expectedContents}`); + } + } + + /** + * Rerieves a codefix satisfying the parameters, or undefined if no such codefix is found. + * @param fileName Path to file where error should be retrieved from. + */ + private getCodeFixActions(fileName: string, errorCode?: number): ts.CodeAction[] { + const diagnostics: ts.Diagnostic[] = this.getDiagnostics(fileName); + + let actions: ts.CodeAction[] = undefined; + for (const diagnostic of diagnostics) { + + if (errorCode && errorCode !== diagnostic.code) { + continue; + } + + const newActions = this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [diagnostic.code]); + if (newActions && newActions.length) { + actions = actions ? actions.concat(newActions) : newActions; + } + } + return actions; + } + + private applyCodeFixActions(fileName: string, actions: ts.CodeAction[]): void { + if (!(actions && actions.length === 1)) { + this.raiseError(`Should find exactly one codefix, but ${actions ? actions.length : "none"} found.`); + } + + const fileChanges = ts.find(actions[0].changes, change => change.fileName === fileName); + if (!fileChanges) { + this.raiseError("The CodeFix found doesn't provide any changes in this file."); + } + + this.applyEdits(fileChanges.fileName, fileChanges.textChanges, /*isFormattingEdit*/ false); + } + public verifyImportFixAtPosition(expectedTextArray: string[], errorCode?: number) { const ranges = this.getRanges(); if (ranges.length == 0) { this.raiseError("At least one range should be specified in the testfile."); } - const codeFixes = this.getCodeFixes(errorCode); + const codeFixes = this.getCodeFixActions(this.activeFile.fileName, errorCode); if (!codeFixes || codeFixes.length == 0) { this.raiseError("No codefixes returned."); @@ -2078,7 +2161,7 @@ namespace FourSlash { public verifyBraceCompletionAtPosition(negative: boolean, openingBrace: string) { - const openBraceMap = ts.createMap({ + const openBraceMap = ts.createMapFromTemplate({ "(": ts.CharacterCodes.openParen, "{": ts.CharacterCodes.openBrace, "[": ts.CharacterCodes.openBracket, @@ -2088,7 +2171,7 @@ namespace FourSlash { "<": ts.CharacterCodes.lessThan }); - const charCode = openBraceMap[openingBrace]; + const charCode = openBraceMap.get(openingBrace); if (!charCode) { this.raiseError(`Invalid openingBrace '${openingBrace}' specified.`); @@ -2315,15 +2398,15 @@ namespace FourSlash { } } - public verifyCodeFixAvailable(negative: boolean, errorCode?: number) { - const fixes = this.getCodeFixes(errorCode); + public verifyCodeFixAvailable(negative: boolean) { + const codeFix = this.getCodeFixActions(this.activeFile.fileName); - if (negative && fixes && fixes.length > 0) { - this.raiseError(`verifyCodeFixAvailable failed - expected no fixes, actual: ${fixes.length}`); + if (negative && codeFix) { + this.raiseError(`verifyCodeFixAvailable failed - expected no fixes but found one.`); } - if (!negative && (fixes === undefined || fixes.length === 0)) { - this.raiseError(`verifyCodeFixAvailable failed - expected code fixes, actual: 0`); + if (!(negative || codeFix)) { + this.raiseError(`verifyCodeFixAvailable failed - expected code fixes but none found.`); } } @@ -2444,11 +2527,9 @@ namespace FourSlash { } public getMarkerByName(markerName: string) { - const markerPos = this.testData.markerPositions[markerName]; + const markerPos = this.testData.markerPositions.get(markerName); if (markerPos === undefined) { - const markerNames: string[] = []; - for (const m in this.testData.markerPositions) markerNames.push(m); - throw new Error(`Unknown marker "${markerName}" Available markers: ${markerNames.map(m => "\"" + m + "\"").join(", ")}`); + throw new Error(`Unknown marker "${markerName}" Available markers: ${this.getMarkerNames().map(m => "\"" + m + "\"").join(", ")}`); } else { return markerPos; @@ -2541,7 +2622,7 @@ ${code} // we have to string-based splitting instead and try to figure out the delimiting chars const lines = contents.split("\n"); - const markerPositions: MarkerMap = {}; + const markerPositions = ts.createMap(); const markers: Marker[] = []; const ranges: Range[] = []; @@ -2680,7 +2761,7 @@ ${code} throw new Error(errorMessage); } - function recordObjectMarker(fileName: string, location: LocationInformation, text: string, markerMap: MarkerMap, markers: Marker[]): Marker { + function recordObjectMarker(fileName: string, location: LocationInformation, text: string, markerMap: ts.Map, markers: Marker[]): Marker { let markerValue: any = undefined; try { // Attempt to parse the marker value as JSON @@ -2703,7 +2784,7 @@ ${code} // Object markers can be anonymous if (markerValue.name) { - markerMap[markerValue.name] = marker; + markerMap.set(markerValue.name, marker); } markers.push(marker); @@ -2711,26 +2792,26 @@ ${code} return marker; } - function recordMarker(fileName: string, location: LocationInformation, name: string, markerMap: MarkerMap, markers: Marker[]): Marker { + function recordMarker(fileName: string, location: LocationInformation, name: string, markerMap: ts.Map, markers: Marker[]): Marker { const marker: Marker = { fileName, position: location.position }; // Verify markers for uniqueness - if (markerMap[name] !== undefined) { + if (markerMap.has(name)) { const message = "Marker '" + name + "' is duplicated in the source file contents."; reportError(marker.fileName, location.sourceLine, location.sourceColumn, message); return undefined; } else { - markerMap[name] = marker; + markerMap.set(name, marker); markers.push(marker); return marker; } } - function parseFileContent(content: string, fileName: string, markerMap: MarkerMap, markers: Marker[], ranges: Range[]): FourSlashFile { + function parseFileContent(content: string, fileName: string, markerMap: ts.Map, markers: Marker[], ranges: Range[]): FourSlashFile { content = chompLeadingSpace(content); // Any slash-star comment with a character not in this string is not a marker. @@ -2990,10 +3071,6 @@ namespace FourSlashInterface { this.state.goToEOF(); } - public type(definitionIndex = 0) { - this.state.goToTypeDefinition(definitionIndex); - } - public implementation() { this.state.goToImplementation(); } @@ -3095,8 +3172,8 @@ namespace FourSlashInterface { this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace); } - public codeFixAvailable(errorCode?: number) { - this.state.verifyCodeFixAvailable(this.negative, errorCode); + public codeFixAvailable() { + this.state.verifyCodeFixAvailable(this.negative); } } @@ -3105,6 +3182,10 @@ namespace FourSlashInterface { super(state); } + public completionsAt(markerName: string, completions: string[]) { + this.state.verifyCompletionsAt(markerName, completions); + } + public quickInfoIs(expectedText: string, expectedDocumentation?: string) { this.state.verifyQuickInfoString(expectedText, expectedDocumentation); } @@ -3161,6 +3242,13 @@ namespace FourSlashInterface { this.state.verifyGoToDefinition(arg0, endMarkerName); } + public goToType(startMarkerName: string | string[], endMarkerName: string | string[]): void; + public goToType(startsAndEnds: [string | string[], string | string[]][]): void; + public goToType(startsAndEnds: { [startMarkerName: string]: string | string[] }): void; + public goToType(arg0: any, endMarkerName?: string | string[]) { + this.state.verifyGoToType(arg0, endMarkerName); + } + public goToDefinitionForMarkers(...markerNames: string[]) { this.state.verifyGoToDefinitionForMarkers(markerNames); } @@ -3281,8 +3369,8 @@ namespace FourSlashInterface { this.DocCommentTemplate(/*expectedText*/ undefined, /*expectedOffset*/ undefined, /*empty*/ true); } - public codeFixAtPosition(expectedText: string, errorCode?: number): void { - this.state.verifyCodeFixAtPosition(expectedText, errorCode); + public rangeAfterCodeFix(expectedText: string, errorCode?: number): void { + this.state.verifyRangeAfterCodeFix(expectedText, errorCode); } public importFixAtPosition(expectedTextArray: string[], errorCode?: number): void { @@ -3524,11 +3612,8 @@ namespace FourSlashInterface { this.state.formatOnType(this.state.getMarkerByName(posMarker).position, key); } - public setOption(name: string, value: number): void; - public setOption(name: string, value: string): void; - public setOption(name: string, value: boolean): void; - public setOption(name: string, value: any): void { - (this.state.formatCodeSettings)[name] = value; + public setOption(name: keyof ts.FormatCodeSettings, value: number | string | boolean): void { + this.state.formatCodeSettings[name] = value; } } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index e58a4f507a7..402eaa15a80 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -85,7 +85,7 @@ namespace Utils { eval(fileContents); break; case ExecutionEnvironment.Node: - let vm = require("vm"); + const vm = require("vm"); if (nodeContext) { vm.runInNewContext(fileContents, nodeContext, fileName); } @@ -175,9 +175,9 @@ namespace Utils { assert.isFalse(array.end > node.end, "array.end > node.end"); assert.isFalse(array.pos < currentPos, "array.pos < currentPos"); - for (let i = 0, n = array.length; i < n; i++) { - assert.isFalse(array[i].pos < currentPos, "array[i].pos < currentPos"); - currentPos = array[i].end; + for (const item of array) { + assert.isFalse(item.pos < currentPos, "array[i].pos < currentPos"); + currentPos = item.end; } currentPos = array.end; @@ -344,7 +344,7 @@ namespace Utils { assert.equal(array1.length, array2.length, "array1.length !== array2.length"); - for (let i = 0, n = array1.length; i < n; i++) { + for (let i = 0; i < array1.length; i++) { const d1 = array1[i]; const d2 = array2[i]; @@ -400,7 +400,7 @@ namespace Utils { assert.equal(array1.end, array2.end, "array1.end !== array2.end"); assert.equal(array1.length, array2.length, "array1.length !== array2.length"); - for (let i = 0, n = array1.length; i < n; i++) { + for (let i = 0; i < array1.length; i++) { assertStructuralEquals(array1[i], array2[i]); } } @@ -909,7 +909,7 @@ namespace Harness { export const defaultLibFileName = "lib.d.ts"; export const es2015DefaultLibFileName = "lib.es2015.d.ts"; - const libFileNameSourceFileMap = ts.createMap({ + const libFileNameSourceFileMap = ts.createMapFromTemplate({ [defaultLibFileName]: createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.es5.d.ts"), /*languageVersion*/ ts.ScriptTarget.Latest) }); @@ -918,10 +918,11 @@ namespace Harness { return undefined; } - if (!libFileNameSourceFileMap[fileName]) { - libFileNameSourceFileMap[fileName] = createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest); + let sourceFile = libFileNameSourceFileMap.get(fileName); + if (!sourceFile) { + libFileNameSourceFileMap.set(fileName, sourceFile = createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest)); } - return libFileNameSourceFileMap[fileName]; + return sourceFile; } export function getDefaultLibFileName(options: ts.CompilerOptions): string { @@ -1103,10 +1104,10 @@ namespace Harness { optionsIndex = ts.createMap(); const optionDeclarations = harnessOptionDeclarations.concat(ts.optionDeclarations); for (const option of optionDeclarations) { - optionsIndex[option.name.toLowerCase()] = option; + optionsIndex.set(option.name.toLowerCase(), option); } } - return optionsIndex[name.toLowerCase()]; + return optionsIndex.get(name.toLowerCase()); } export function setCompilerOptionsFromHarnessSetting(settings: Harness.TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnessOptions): void { @@ -1466,7 +1467,7 @@ namespace Harness { const fullResults = ts.createMap(); for (const sourceFile of allFiles) { - fullResults[sourceFile.unitName] = fullWalker.getTypeAndSymbols(sourceFile.unitName); + fullResults.set(sourceFile.unitName, fullWalker.getTypeAndSymbols(sourceFile.unitName)); } // Produce baselines. The first gives the types for all expressions. @@ -1519,7 +1520,7 @@ namespace Harness { allFiles.forEach(file => { const codeLines = file.content.split("\n"); - typeWriterResults[file.unitName].forEach(result => { + typeWriterResults.get(file.unitName).forEach(result => { if (isSymbolBaseline && !result.symbol) { return; } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index a49f8926729..cd44fbf7a3a 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -262,7 +262,7 @@ namespace Harness.LanguageService { this.getModuleResolutionsForFile = (fileName) => { const scriptInfo = this.getScriptInfo(fileName); const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ true); - const imports = ts.createMap(); + const imports: ts.MapLike = {}; for (const module of preprocessInfo.importedFiles) { const resolutionInfo = ts.resolveModuleName(module.fileName, fileName, compilerOptions, moduleResolutionHost); if (resolutionInfo.resolvedModule) { @@ -275,7 +275,7 @@ namespace Harness.LanguageService { const scriptInfo = this.getScriptInfo(fileName); if (scriptInfo) { const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ false); - const resolutions = ts.createMap(); + const resolutions: ts.MapLike = {}; const settings = this.nativeHost.getCompilationSettings(); for (const typeReferenceDirective of preprocessInfo.typeReferenceDirectives) { const resolutionInfo = ts.resolveTypeReferenceDirective(typeReferenceDirective.fileName, fileName, settings, moduleResolutionHost); diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index a85f7a13e16..d0ac213db7c 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -250,17 +250,20 @@ class ProjectRunner extends RunnerBase { // Set the values specified using json const optionNameMap = ts.arrayToMap(ts.optionDeclarations, option => option.name); for (const name in testCase) { - if (name !== "mapRoot" && name !== "sourceRoot" && name in optionNameMap) { - const option = optionNameMap[name]; - const optType = option.type; - let value = testCase[name]; - if (typeof optType !== "string") { - const key = value.toLowerCase(); - if (key in optType) { - value = optType[key]; + if (name !== "mapRoot" && name !== "sourceRoot") { + const option = optionNameMap.get(name); + if (option) { + const optType = option.type; + let value = testCase[name]; + if (typeof optType !== "string") { + const key = value.toLowerCase(); + const optTypeValue = optType.get(key); + if (optTypeValue) { + value = optTypeValue; + } } + compilerOptions[option.name] = value; } - compilerOptions[option.name] = value; } } diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index c9c82490619..c335c44b642 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -1,19 +1,12 @@ { + "extends": "../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "pretty": true, "removeComments": false, - "preserveConstEnums": true, "outFile": "../../built/local/run.js", - "sourceMap": true, "declaration": false, - "stripInternal": true, "types": [ "node", "mocha", "chai" - ], - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true + ] }, "files": [ "../compiler/core.ts", @@ -75,7 +68,18 @@ "../services/formatting/rulesProvider.ts", "../services/formatting/smartIndenter.ts", "../services/formatting/tokenRange.ts", - "harness.ts", + "../services/codeFixProvider.ts", + "../services/codefixes/fixes.ts", + "../services/codefixes/fixExtendsInterfaceBecomesImplements.ts", + "../services/codefixes/fixClassIncorrectlyImplementsInterface.ts", + "../services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts", + "../services/codefixes/fixClassSuperMustPrecedeThisAccess.ts", + "../services/codefixes/fixConstructorForDerivedNeedSuperCall.ts", + "../services/codefixes/helpers.ts", + "../services/codefixes/importFixes.ts", + "../services/codefixes/unusedIdentifierFixes.ts", + "../services/harness.ts", + "sourceMapRecorder.ts", "harnessLanguageService.ts", "fourslash.ts", diff --git a/src/harness/unittests/cachingInServerLSHost.ts b/src/harness/unittests/cachingInServerLSHost.ts index 4286d3555d8..caeab18958e 100644 --- a/src/harness/unittests/cachingInServerLSHost.ts +++ b/src/harness/unittests/cachingInServerLSHost.ts @@ -1,4 +1,4 @@ -/// +/// namespace ts { interface File { @@ -8,25 +8,28 @@ namespace ts { function createDefaultServerHost(fileMap: Map): server.ServerHost { const existingDirectories = createMap(); - for (const name in fileMap) { + forEachKey(fileMap, name => { let dir = getDirectoryPath(name); let previous: string; do { - existingDirectories[dir] = true; + existingDirectories.set(dir, true); previous = dir; dir = getDirectoryPath(dir); } while (dir !== previous); - } + }); return { args: [], newLine: "\r\n", useCaseSensitiveFileNames: false, write: noop, - readFile: path => path in fileMap ? fileMap[path].content : undefined, + readFile: path => { + const file = fileMap.get(path); + return file && file.content; + }, writeFile: notImplemented, resolvePath: notImplemented, - fileExists: path => path in fileMap, - directoryExists: path => existingDirectories[path] || false, + fileExists: path => fileMap.has(path), + directoryExists: path => existingDirectories.get(path) || false, createDirectory: noop, getExecutingFilePath: () => "", getCurrentDirectory: () => "", @@ -83,7 +86,7 @@ namespace ts { content: `foo()` }; - const serverHost = createDefaultServerHost(createMap({ [root.name]: root, [imported.name]: imported })); + const serverHost = createDefaultServerHost(createMapFromTemplate({ [root.name]: root, [imported.name]: imported })); const { project, rootScriptInfo } = createProject(root.name, serverHost); // ensure that imported file was found @@ -167,7 +170,7 @@ namespace ts { content: `export var y = 1` }; - const fileMap = createMap({ [root.name]: root }); + const fileMap = createMapFromTemplate({ [root.name]: root }); const serverHost = createDefaultServerHost(fileMap); const originalFileExists = serverHost.fileExists; @@ -191,7 +194,7 @@ namespace ts { assert.isTrue(typeof diags[0].messageText === "string" && ((diags[0].messageText).indexOf("Cannot find module") === 0), "should be 'cannot find module' message"); // assert that import will success once file appear on disk - fileMap[imported.name] = imported; + fileMap.set(imported.name, imported); fileExistsCalledForBar = false; rootScriptInfo.editContent(0, root.content.length, `import {y} from "bar"`); diff --git a/src/harness/unittests/compileOnSave.ts b/src/harness/unittests/compileOnSave.ts index d7731a625fe..c8deb9e7554 100644 --- a/src/harness/unittests/compileOnSave.ts +++ b/src/harness/unittests/compileOnSave.ts @@ -467,6 +467,36 @@ namespace ts.projectSystem { }); describe("EmitFile test", () => { + it("should respect line endings", () => { + test("\n"); + test("\r\n"); + + function test(newLine: string) { + const lines = ["var x = 1;", "var y = 2;"]; + const path = "/a/app"; + const f = { + path: path + ".ts", + content: lines.join(newLine) + }; + const host = createServerHost([f], { newLine }); + const session = createSession(host); + session.executeCommand({ + seq: 1, + type: "request", + command: "open", + arguments: { file: f.path } + }); + session.executeCommand({ + seq: 2, + type: "request", + command: "compileOnSaveEmitFile", + arguments: { file: f.path } + }); + const emitOutput = host.readFile(path + ".js"); + assert.equal(emitOutput, f.content + newLine, "content of emit output should be identical with the input + newline"); + } + }) + it("should emit specified file", () => { const file1 = { path: "/a/b/f1.ts", @@ -480,7 +510,7 @@ namespace ts.projectSystem { path: "/a/b/tsconfig.json", content: `{}` }; - const host = createServerHost([file1, file2, configFile, libFile]); + const host = createServerHost([file1, file2, configFile, libFile], { newLine: "\r\n" }); const typingsInstaller = createTestTypingsInstaller(host); const session = new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false); diff --git a/src/harness/unittests/configurationExtension.ts b/src/harness/unittests/configurationExtension.ts index e1136e5c0b0..8963bf2e505 100644 --- a/src/harness/unittests/configurationExtension.ts +++ b/src/harness/unittests/configurationExtension.ts @@ -2,7 +2,7 @@ /// namespace ts { - const testContents = { + const testContents = createMapFromTemplate({ "/dev/tsconfig.json": `{ "extends": "./configs/base", "files": [ @@ -86,10 +86,10 @@ namespace ts { "/dev/tests/utils.ts": "", "/dev/tests/scenarios/first.json": "", "/dev/tests/baselines/first/output.ts": "" - }; + }); const caseInsensitiveBasePath = "c:/dev/"; - const caseInsensitiveHost = new Utils.MockParseConfigHost(caseInsensitiveBasePath, /*useCaseSensitiveFileNames*/ false, mapObject(testContents, (key, content) => [`c:${key}`, content])); + const caseInsensitiveHost = new Utils.MockParseConfigHost(caseInsensitiveBasePath, /*useCaseSensitiveFileNames*/ false, mapEntries(testContents, (key, content) => [`c:${key}`, content])); const caseSensitiveBasePath = "/dev/"; const caseSensitiveHost = new Utils.MockParseConfigHost(caseSensitiveBasePath, /*useCaseSensitiveFileNames*/ true, testContents); diff --git a/src/harness/unittests/incrementalParser.ts b/src/harness/unittests/incrementalParser.ts index 6088e5fe082..fbd8a60da92 100644 --- a/src/harness/unittests/incrementalParser.ts +++ b/src/harness/unittests/incrementalParser.ts @@ -28,7 +28,7 @@ namespace ts { const diagnostics2 = file2.parseDiagnostics; assert.equal(diagnostics1.length, diagnostics2.length, "diagnostics1.length !== diagnostics2.length"); - for (let i = 0, n = diagnostics1.length; i < n; i++) { + for (let i = 0; i < diagnostics1.length; i++) { const d1 = diagnostics1[i]; const d2 = diagnostics2[i]; diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index 35313e15308..aa30f1e01e2 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -36,7 +36,7 @@ namespace ts { for (const f of files) { let name = getDirectoryPath(f.name); while (true) { - directories[name] = name; + directories.set(name, name); const baseName = getDirectoryPath(name); if (baseName === name) { break; @@ -46,20 +46,19 @@ namespace ts { } return { readFile, - directoryExists: path => { - return path in directories; - }, + directoryExists: path => directories.has(path), fileExists: path => { - assert.isTrue(getDirectoryPath(path) in directories, `'fileExists' '${path}' request in non-existing directory`); - return path in map; + assert.isTrue(directories.has(getDirectoryPath(path)), `'fileExists' '${path}' request in non-existing directory`); + return map.has(path); } }; } else { - return { readFile, fileExists: path => path in map, }; + return { readFile, fileExists: path => map.has(path) }; } function readFile(path: string): string { - return path in map ? map[path].content : undefined; + const file = map.get(path); + return file && file.content; } } @@ -300,7 +299,8 @@ namespace ts { const host: CompilerHost = { getSourceFile: (fileName: string, languageVersion: ScriptTarget) => { const path = normalizePath(combinePaths(currentDirectory, fileName)); - return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined; + const file = files.get(path); + return file && createSourceFile(fileName, file, languageVersion); }, getDefaultLibFileName: () => "lib.d.ts", writeFile: notImplemented, @@ -311,7 +311,7 @@ namespace ts { useCaseSensitiveFileNames: () => false, fileExists: fileName => { const path = normalizePath(combinePaths(currentDirectory, fileName)); - return path in files; + return files.has(path); }, readFile: notImplemented }; @@ -331,7 +331,7 @@ namespace ts { } it("should find all modules", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c/first/shared.ts": ` class A {} export = A`, @@ -350,7 +350,7 @@ export = C; }); it("should find modules in node_modules", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/parent/node_modules/mod/index.d.ts": "export var x", "/parent/app/myapp.ts": `import {x} from "mod"` }); @@ -358,7 +358,7 @@ export = C; }); it("should find file referenced via absolute and relative names", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c.ts": `/// `, "/a/b/b.ts": "var x" }); @@ -371,7 +371,11 @@ export = C; function test(files: Map, options: CompilerOptions, currentDirectory: string, useCaseSensitiveFileNames: boolean, rootFiles: string[], diagnosticCodes: number[]): void { const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); if (!useCaseSensitiveFileNames) { - files = reduceProperties(files, (files, file, fileName) => (files[getCanonicalFileName(fileName)] = file, files), createMap()); + const oldFiles = files; + files = createMap(); + oldFiles.forEach((file, fileName) => { + files.set(getCanonicalFileName(fileName), file); + }); } const host: CompilerHost = { @@ -380,7 +384,8 @@ export = C; return library; } const path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName))); - return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined; + const file = files.get(path); + return file && createSourceFile(fileName, file, languageVersion); }, getDefaultLibFileName: () => "lib.d.ts", writeFile: notImplemented, @@ -391,7 +396,7 @@ export = C; useCaseSensitiveFileNames: () => useCaseSensitiveFileNames, fileExists: fileName => { const path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName))); - return path in files; + return files.has(path); }, readFile: notImplemented }; @@ -404,7 +409,7 @@ export = C; } it("should succeed when the same file is referenced using absolute and relative names", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c.ts": `/// `, "/a/b/d.ts": "var x" }); @@ -412,7 +417,7 @@ export = C; }); it("should fail when two files used in program differ only in casing (tripleslash references)", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c.ts": `/// `, "/a/b/d.ts": "var x" }); @@ -420,7 +425,7 @@ export = C; }); it("should fail when two files used in program differ only in casing (imports)", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c.ts": `import {x} from "D"`, "/a/b/d.ts": "export var x" }); @@ -428,7 +433,7 @@ export = C; }); it("should fail when two files used in program differ only in casing (imports, relative module names)", () => { - const files = createMap({ + const files = createMapFromTemplate({ "moduleA.ts": `import {x} from "./ModuleB"`, "moduleB.ts": "export var x" }); @@ -436,7 +441,7 @@ export = C; }); it("should fail when two files exist on disk that differs only in casing", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c.ts": `import {x} from "D"`, "/a/b/D.ts": "export var x", "/a/b/d.ts": "export var y" @@ -445,7 +450,7 @@ export = C; }); it("should fail when module name in 'require' calls has inconsistent casing", () => { - const files = createMap({ + const files = createMapFromTemplate({ "moduleA.ts": `import a = require("./ModuleC")`, "moduleB.ts": `import a = require("./moduleC")`, "moduleC.ts": "export var x" @@ -454,7 +459,7 @@ export = C; }); it("should fail when module names in 'require' calls has inconsistent casing and current directory has uppercase chars", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/B/c/moduleA.ts": `import a = require("./ModuleC")`, "/a/B/c/moduleB.ts": `import a = require("./moduleC")`, "/a/B/c/moduleC.ts": "export var x", @@ -466,7 +471,7 @@ import b = require("./moduleB"); test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "/a/B/c", /*useCaseSensitiveFileNames*/ false, ["moduleD.ts"], [1149]); }); it("should not fail when module names in 'require' calls has consistent casing and current directory has uppercase chars", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/B/c/moduleA.ts": `import a = require("./moduleC")`, "/a/B/c/moduleB.ts": `import a = require("./moduleC")`, "/a/B/c/moduleC.ts": "export var x", @@ -1020,8 +1025,8 @@ import b = require("./moduleB"); const names = map(files, f => f.name); const sourceFiles = arrayToMap(map(files, f => createSourceFile(f.name, f.content, ScriptTarget.ES2015)), f => f.fileName); const compilerHost: CompilerHost = { - fileExists : fileName => fileName in sourceFiles, - getSourceFile: fileName => sourceFiles[fileName], + fileExists : fileName => sourceFiles.has(fileName), + getSourceFile: fileName => sourceFiles.get(fileName), getDefaultLibFileName: () => "lib.d.ts", writeFile: notImplemented, getCurrentDirectory: () => "/", @@ -1029,7 +1034,10 @@ import b = require("./moduleB"); getCanonicalFileName: f => f.toLowerCase(), getNewLine: () => "\r\n", useCaseSensitiveFileNames: () => false, - readFile: fileName => fileName in sourceFiles ? sourceFiles[fileName].text : undefined + readFile: fileName => { + const file = sourceFiles.get(fileName); + return file && file.text; + } }; const program1 = createProgram(names, {}, compilerHost); const diagnostics1 = program1.getFileProcessingDiagnostics().getDiagnostics(); diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 6dbd74e71d2..d13dd7a26fa 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { @@ -122,7 +122,7 @@ namespace ts { trace: s => trace.push(s), getTrace: () => trace, getSourceFile(fileName): SourceFile { - return files[fileName]; + return files.get(fileName); }, getDefaultLibFileName(): string { return "lib.d.ts"; @@ -143,9 +143,10 @@ namespace ts { getNewLine(): string { return sys ? sys.newLine : newLine; }, - fileExists: fileName => fileName in files, + fileExists: fileName => files.has(fileName), readFile: fileName => { - return fileName in files ? files[fileName].text : undefined; + const file = files.get(fileName); + return file && file.text; }, }; } @@ -188,10 +189,24 @@ namespace ts { } else { assert.isTrue(cache !== undefined, `expected ${caption} to be set`); - assert.isTrue(equalOwnProperties(expectedContent, cache, entryChecker), `contents of ${caption} did not match the expected contents.`); + assert.isTrue(mapsAreEqual(expectedContent, cache, entryChecker), `contents of ${caption} did not match the expected contents.`); } } + /** True if the maps have the same keys and values. */ + function mapsAreEqual(left: Map, right: Map, valuesAreEqual?: (left: T, right: T) => boolean): boolean { + if (left === right) return true; + if (!left || !right) return false; + const someInLeftHasNoMatch = forEachEntry(left, (leftValue, leftKey) => { + if (!right.has(leftKey)) return true; + const rightValue = right.get(leftKey); + return !(valuesAreEqual ? valuesAreEqual(leftValue, rightValue) : leftValue === rightValue); + }); + if (someInLeftHasNoMatch) return false; + const someInRightHasNoMatch = forEachKey(right, rightKey => !left.has(rightKey)); + return !someInRightHasNoMatch; + } + function checkResolvedModulesCache(program: Program, fileName: string, expectedContent: Map): void { checkCache("resolved modules", program, fileName, expectedContent, f => f.resolvedModules, checkResolvedModule); } @@ -307,7 +322,7 @@ namespace ts { const options: CompilerOptions = { target }; const program_1 = newProgram(files, ["a.ts"], options); - checkResolvedModulesCache(program_1, "a.ts", createMap({ "b": createResolvedModule("b.ts") })); + checkResolvedModulesCache(program_1, "a.ts", createMapFromTemplate({ "b": createResolvedModule("b.ts") })); checkResolvedModulesCache(program_1, "b.ts", undefined); const program_2 = updateProgram(program_1, ["a.ts"], options, files => { @@ -316,7 +331,7 @@ namespace ts { assert.isTrue(program_1.structureIsReused); // content of resolution cache should not change - checkResolvedModulesCache(program_1, "a.ts", createMap({ "b": createResolvedModule("b.ts") })); + checkResolvedModulesCache(program_1, "a.ts", createMapFromTemplate({ "b": createResolvedModule("b.ts") })); checkResolvedModulesCache(program_1, "b.ts", undefined); // imports has changed - program is not reused @@ -333,7 +348,7 @@ namespace ts { files[0].text = files[0].text.updateImportsAndExports(newImports); }); assert.isTrue(!program_3.structureIsReused); - checkResolvedModulesCache(program_4, "a.ts", createMap({ "b": createResolvedModule("b.ts"), "c": undefined })); + checkResolvedModulesCache(program_4, "a.ts", createMapFromTemplate({ "b": createResolvedModule("b.ts"), "c": undefined })); }); it("resolved type directives cache follows type directives", () => { @@ -344,7 +359,7 @@ namespace ts { const options: CompilerOptions = { target, typeRoots: ["/types"] }; const program_1 = newProgram(files, ["/a.ts"], options); - checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMap({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); + checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMapFromTemplate({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); checkResolvedTypeDirectivesCache(program_1, "/types/typedefs/index.d.ts", undefined); const program_2 = updateProgram(program_1, ["/a.ts"], options, files => { @@ -353,7 +368,7 @@ namespace ts { assert.isTrue(program_1.structureIsReused); // content of resolution cache should not change - checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMap({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); + checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMapFromTemplate({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); checkResolvedTypeDirectivesCache(program_1, "/types/typedefs/index.d.ts", undefined); // type reference directives has changed - program is not reused @@ -371,7 +386,7 @@ namespace ts { files[0].text = files[0].text.updateReferences(newReferences); }); assert.isTrue(!program_3.structureIsReused); - checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMap({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); + checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMapFromTemplate({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); }); it("can reuse ambient module declarations from non-modified files", () => { diff --git a/src/harness/unittests/services/colorization.ts b/src/harness/unittests/services/colorization.ts index 0fe63f4ff07..70592ea4151 100644 --- a/src/harness/unittests/services/colorization.ts +++ b/src/harness/unittests/services/colorization.ts @@ -13,8 +13,7 @@ describe("Colorization", function () { function getEntryAtPosition(result: ts.ClassificationResult, position: number) { let entryPosition = 0; - for (let i = 0, n = result.entries.length; i < n; i++) { - const entry = result.entries[i]; + for (const entry of result.entries) { if (entryPosition === position) { return entry; } @@ -43,9 +42,7 @@ describe("Colorization", function () { function testLexicalClassification(text: string, initialEndOfLineState: ts.EndOfLineState, ...expectedEntries: ClassificationEntry[]): void { const result = classifier.getClassificationsForLine(text, initialEndOfLineState, /*syntacticClassifierAbsent*/ false); - for (let i = 0, n = expectedEntries.length; i < n; i++) { - const expectedEntry = expectedEntries[i]; - + for (const expectedEntry of expectedEntries) { if (expectedEntry.classification === undefined) { assert.equal(result.finalLexState, expectedEntry.value, "final endOfLineState does not match expected."); } @@ -352,9 +349,9 @@ describe("Colorization", function () { // Adjusts 'pos' by accounting for the length of each portion of the string, // but only return the last given string function track(...vals: string[]): string { - for (let i = 0, n = vals.length; i < n; i++) { + for (const val of vals) { pos += lastLength; - lastLength = vals[i].length; + lastLength = val.length; } return ts.lastOrUndefined(vals); } diff --git a/src/harness/unittests/services/patternMatcher.ts b/src/harness/unittests/services/patternMatcher.ts index 8a70b38ab5e..728636e9af2 100644 --- a/src/harness/unittests/services/patternMatcher.ts +++ b/src/harness/unittests/services/patternMatcher.ts @@ -502,7 +502,7 @@ describe("PatternMatcher", function () { function assertArrayEquals(array1: T[], array2: T[]) { assert.equal(array1.length, array2.length); - for (let i = 0, n = array1.length; i < n; i++) { + for (let i = 0; i < array1.length; i++) { assert.equal(array1[i], array2[i]); } } diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index 8800e84474b..15c43d9e76b 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -1,4 +1,4 @@ -/// +/// const expect: typeof _chai.expect = _chai.expect; @@ -416,14 +416,15 @@ namespace ts.server { class InProcClient { private server: InProcSession; private seq = 0; - private callbacks = createMap<(resp: protocol.Response) => void>(); + private callbacks: Array<(resp: protocol.Response) => void> = []; private eventHandlers = createMap<(args: any) => void>(); handle(msg: protocol.Message): void { if (msg.type === "response") { const response = msg; - if (response.request_seq in this.callbacks) { - this.callbacks[response.request_seq](response); + const handler = this.callbacks[response.request_seq]; + if (handler) { + handler(response); delete this.callbacks[response.request_seq]; } } @@ -434,13 +435,14 @@ namespace ts.server { } emit(name: string, args: any): void { - if (name in this.eventHandlers) { - this.eventHandlers[name](args); + const handler = this.eventHandlers.get(name); + if (handler) { + handler(args); } } on(name: string, handler: (args: any) => void): void { - this.eventHandlers[name] = handler; + this.eventHandlers.set(name, handler); } connect(session: InProcSession): void { diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index d379b5bbf9c..5ed0d981511 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts.projectSystem { @@ -141,6 +141,7 @@ namespace ts.projectSystem { useCaseSensitiveFileNames?: boolean; executingFilePath?: string; currentDirectory?: string; + newLine?: string; } export function createServerHost(fileOrFolderList: FileOrFolder[], params?: TestServerHostCreationParameters): TestServerHost { @@ -151,7 +152,8 @@ namespace ts.projectSystem { params.useCaseSensitiveFileNames !== undefined ? params.useCaseSensitiveFileNames : false, params.executingFilePath || getExecutingFilePathFromLibFile(), params.currentDirectory || "/", - fileOrFolderList); + fileOrFolderList, + params.newLine); return host; } @@ -242,9 +244,9 @@ namespace ts.projectSystem { } export function checkMapKeys(caption: string, map: Map, expectedKeys: string[]) { - assert.equal(reduceProperties(map, count => count + 1, 0), expectedKeys.length, `${caption}: incorrect size of map`); + assert.equal(map.size, expectedKeys.length, `${caption}: incorrect size of map`); for (const name of expectedKeys) { - assert.isTrue(name in map, `${caption} is expected to contain ${name}, actual keys: ${Object.keys(map)}`); + assert.isTrue(map.has(name), `${caption} is expected to contain ${name}, actual keys: ${arrayFrom(map.keys())}`); } } @@ -290,7 +292,7 @@ namespace ts.projectSystem { } export class Callbacks { - private map: { [n: number]: TimeOutCallback } = {}; + private map: TimeOutCallback[] = []; private nextId = 1; register(cb: (...args: any[]) => void, args: any[]) { @@ -308,20 +310,16 @@ namespace ts.projectSystem { count() { let n = 0; for (const _ in this.map) { - // TODO: GH#11734 - _; n++; } return n; } invoke() { - for (const id in this.map) { - if (hasProperty(this.map, id)) { - this.map[id](); - } + for (const key in this.map) { + this.map[key](); } - this.map = {}; + this.map = []; } } @@ -329,7 +327,6 @@ namespace ts.projectSystem { export class TestServerHost implements server.ServerHost { args: string[] = []; - newLine: "\n"; private fs: ts.FileMap; private getCanonicalFileName: (s: string) => string; @@ -337,12 +334,12 @@ namespace ts.projectSystem { private timeoutCallbacks = new Callbacks(); private immediateCallbacks = new Callbacks(); - readonly watchedDirectories = createMap<{ cb: DirectoryWatcherCallback, recursive: boolean }[]>(); - readonly watchedFiles = createMap(); + readonly watchedDirectories = createMultiMap<{ cb: DirectoryWatcherCallback, recursive: boolean }>(); + readonly watchedFiles = createMultiMap(); private filesOrFolders: FileOrFolder[]; - constructor(public useCaseSensitiveFileNames: boolean, private executingFilePath: string, private currentDirectory: string, fileOrFolderList: FileOrFolder[]) { + constructor(public useCaseSensitiveFileNames: boolean, private executingFilePath: string, private currentDirectory: string, fileOrFolderList: FileOrFolder[], public readonly newLine = "\n") { this.getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); this.toPath = s => toPath(s, currentDirectory, this.getCanonicalFileName); @@ -424,11 +421,11 @@ namespace ts.projectSystem { watchDirectory(directoryName: string, callback: DirectoryWatcherCallback, recursive: boolean): DirectoryWatcher { const path = this.toPath(directoryName); const cbWithRecursive = { cb: callback, recursive }; - multiMapAdd(this.watchedDirectories, path, cbWithRecursive); + this.watchedDirectories.add(path, cbWithRecursive); return { referenceCount: 0, directoryName, - close: () => multiMapRemove(this.watchedDirectories, path, cbWithRecursive) + close: () => this.watchedDirectories.remove(path, cbWithRecursive) }; } @@ -438,7 +435,7 @@ namespace ts.projectSystem { triggerDirectoryWatcherCallback(directoryName: string, fileName: string): void { const path = this.toPath(directoryName); - const callbacks = this.watchedDirectories[path]; + const callbacks = this.watchedDirectories.get(path); if (callbacks) { for (const callback of callbacks) { callback.cb(fileName); @@ -448,7 +445,7 @@ namespace ts.projectSystem { triggerFileWatcherCallback(fileName: string, removed?: boolean): void { const path = this.toPath(fileName); - const callbacks = this.watchedFiles[path]; + const callbacks = this.watchedFiles.get(path); if (callbacks) { for (const callback of callbacks) { callback(path, removed); @@ -458,8 +455,8 @@ namespace ts.projectSystem { watchFile(fileName: string, callback: FileWatcherCallback) { const path = this.toPath(fileName); - multiMapAdd(this.watchedFiles, path, callback); - return { close: () => multiMapRemove(this.watchedFiles, path, callback) }; + this.watchedFiles.add(path, callback); + return { close: () => this.watchedFiles.remove(path, callback) }; } // TOOD: record and invoke callbacks to simulate timer events @@ -1619,7 +1616,7 @@ namespace ts.projectSystem { const configureHostRequest = makeSessionRequest(CommandNames.Configure, { extraFileExtensions }); session.executeCommand(configureHostRequest).response; - // HTML file still not included in the project as it is closed + // HTML file still not included in the project as it is closed checkNumberOfProjects(projectService, { configuredProjects: 1 }); checkProjectActualFiles(projectService.configuredProjects[0], [file1.path]); @@ -2068,58 +2065,17 @@ namespace ts.projectSystem { assert.deepEqual(resolutionTrace, [ "======== Resolving module 'lib' from '/a/b/app.js'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module 'lib' from 'node_modules' folder.", - "File '/a/b/node_modules/lib.ts' does not exist.", - "File '/a/b/node_modules/lib.tsx' does not exist.", - "File '/a/b/node_modules/lib.d.ts' does not exist.", - "File '/a/b/node_modules/lib/package.json' does not exist.", - "File '/a/b/node_modules/lib/index.ts' does not exist.", - "File '/a/b/node_modules/lib/index.tsx' does not exist.", - "File '/a/b/node_modules/lib/index.d.ts' does not exist.", - "File '/a/b/node_modules/@types/lib.d.ts' does not exist.", - "File '/a/b/node_modules/@types/lib/package.json' does not exist.", - "File '/a/b/node_modules/@types/lib/index.d.ts' does not exist.", - "File '/a/node_modules/lib.ts' does not exist.", - "File '/a/node_modules/lib.tsx' does not exist.", - "File '/a/node_modules/lib.d.ts' does not exist.", - "File '/a/node_modules/lib/package.json' does not exist.", - "File '/a/node_modules/lib/index.ts' does not exist.", - "File '/a/node_modules/lib/index.tsx' does not exist.", - "File '/a/node_modules/lib/index.d.ts' does not exist.", - "File '/a/node_modules/@types/lib.d.ts' does not exist.", - "File '/a/node_modules/@types/lib/package.json' does not exist.", - "File '/a/node_modules/@types/lib/index.d.ts' does not exist.", - "File '/node_modules/lib.ts' does not exist.", - "File '/node_modules/lib.tsx' does not exist.", - "File '/node_modules/lib.d.ts' does not exist.", - "File '/node_modules/lib/package.json' does not exist.", - "File '/node_modules/lib/index.ts' does not exist.", - "File '/node_modules/lib/index.tsx' does not exist.", - "File '/node_modules/lib/index.d.ts' does not exist.", - "File '/node_modules/@types/lib.d.ts' does not exist.", - "File '/node_modules/@types/lib/package.json' does not exist.", - "File '/node_modules/@types/lib/index.d.ts' does not exist.", - "Loading module 'lib' from 'node_modules' folder.", - "File '/a/b/node_modules/lib.js' does not exist.", - "File '/a/b/node_modules/lib.jsx' does not exist.", - "File '/a/b/node_modules/lib/package.json' does not exist.", - "File '/a/b/node_modules/lib/index.js' does not exist.", - "File '/a/b/node_modules/lib/index.jsx' does not exist.", - "File '/a/node_modules/lib.js' does not exist.", - "File '/a/node_modules/lib.jsx' does not exist.", - "File '/a/node_modules/lib/package.json' does not exist.", - "File '/a/node_modules/lib/index.js' does not exist.", - "File '/a/node_modules/lib/index.jsx' does not exist.", - "File '/node_modules/lib.js' does not exist.", - "File '/node_modules/lib.jsx' does not exist.", - "File '/node_modules/lib/package.json' does not exist.", - "File '/node_modules/lib/index.js' does not exist.", - "File '/node_modules/lib/index.jsx' does not exist.", + "Loading module 'lib' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Loading module 'lib' from 'node_modules' folder, target file type 'JavaScript'.", + "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name 'lib' was not resolved. ========", `Auto discovery for typings is enabled in project '${proj.getProjectName()}'. Running extra resolution pass for module 'lib' using cache location '/a/cache'.`, "File '/a/cache/node_modules/lib.d.ts' does not exist.", - "File '/a/cache/node_modules/lib/package.json' does not exist.", - "File '/a/cache/node_modules/lib/index.d.ts' does not exist.", "File '/a/cache/node_modules/@types/lib.d.ts' does not exist.", "File '/a/cache/node_modules/@types/lib/package.json' does not exist.", "File '/a/cache/node_modules/@types/lib/index.d.ts' exist - use it as a name resolution result.", @@ -3091,4 +3047,59 @@ namespace ts.projectSystem { service.checkNumberOfProjects({ externalProjects: 1 }); }); }); + + describe("maxNodeModuleJsDepth for inferred projects", () => { + it("should be set to 2 if the project has js root files", () => { + const file1: FileOrFolder = { + path: "/a/b/file1.js", + content: `var t = require("test"); t.` + }; + const moduleFile: FileOrFolder = { + path: "/a/b/node_modules/test/index.js", + content: `var v = 10; module.exports = v;` + }; + + const host = createServerHost([file1, moduleFile]); + const projectService = createProjectService(host); + projectService.openClientFile(file1.path); + + let project = projectService.inferredProjects[0]; + let options = project.getCompilerOptions(); + assert.isTrue(options.maxNodeModuleJsDepth === 2); + + // Assert the option sticks + projectService.setCompilerOptionsForInferredProjects({ target: ScriptTarget.ES2016 }); + project = projectService.inferredProjects[0]; + options = project.getCompilerOptions(); + assert.isTrue(options.maxNodeModuleJsDepth === 2); + }); + + it("should return to normal state when all js root files are removed from project", () => { + const file1 = { + path: "/a/file1.ts", + content: "let x =1;" + }; + const file2 = { + path: "/a/file2.js", + content: "let x =1;" + }; + + const host = createServerHost([file1, file2, libFile]); + const projectService = createProjectService(host, { useSingleInferredProject: true }); + + projectService.openClientFile(file1.path); + checkNumberOfInferredProjects(projectService, 1); + let project = projectService.inferredProjects[0]; + assert.isUndefined(project.getCompilerOptions().maxNodeModuleJsDepth); + + projectService.openClientFile(file2.path); + project = projectService.inferredProjects[0]; + assert.isTrue(project.getCompilerOptions().maxNodeModuleJsDepth === 2); + + projectService.closeClientFile(file2.path); + project = projectService.inferredProjects[0]; + assert.isUndefined(project.getCompilerOptions().maxNodeModuleJsDepth); + }); + }); + } \ No newline at end of file diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index 62d2f7ac801..d4956a387ee 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -14,7 +14,7 @@ namespace ts.projectSystem { function createTypesRegistry(...list: string[]): Map { const map = createMap(); for (const l of list) { - map[l] = undefined; + map.set(l, undefined); } return map; } @@ -944,7 +944,7 @@ namespace ts.projectSystem { content: "" }; const host = createServerHost([f, node]); - const cache = createMap({ "node": node.path }); + const cache = createMapFromTemplate({ "node": node.path }); const result = JsTyping.discoverTypings(host, [f.path], getDirectoryPath(f.path), /*safeListPath*/ undefined, cache, { enable: true }, ["fs", "bar"]); assert.deepEqual(result.cachedTypingPaths, [node.path]); assert.deepEqual(result.newTypingNames, ["bar"]); diff --git a/src/harness/unittests/versionCache.ts b/src/harness/unittests/versionCache.ts index 7fb01ee770a..17a70f59d59 100644 --- a/src/harness/unittests/versionCache.ts +++ b/src/harness/unittests/versionCache.ts @@ -307,7 +307,7 @@ and grew 1cm per day`; it("Start pos from line", () => { for (let i = 0; i < iterationCount; i++) { - for (let j = 0, llen = lines.length; j < llen; j++) { + for (let j = 0; j < lines.length; j++) { const lineInfo = lineIndex.lineNumberToInfo(j + 1); const lineIndexOffset = lineInfo.offset; const lineMapOffset = lineMap[j]; diff --git a/src/harness/virtualFileSystem.ts b/src/harness/virtualFileSystem.ts index 852363b3658..e409af9d4e7 100644 --- a/src/harness/virtualFileSystem.ts +++ b/src/harness/virtualFileSystem.ts @@ -195,11 +195,17 @@ namespace Utils { } export class MockParseConfigHost extends VirtualFileSystem implements ts.ParseConfigHost { - constructor(currentDirectory: string, ignoreCase: boolean, files: ts.MapLike | string[]) { + constructor(currentDirectory: string, ignoreCase: boolean, files: ts.Map | string[]) { super(currentDirectory, ignoreCase); - const fileNames = (files instanceof Array) ? files : ts.getOwnKeys(files); - for (const file of fileNames) { - this.addFile(file, new Harness.LanguageService.ScriptInfo(file, (files as ts.MapLike)[file], /*isRootFile*/false)); + if (files instanceof Array) { + for (const file of files) { + this.addFile(file, new Harness.LanguageService.ScriptInfo(file, undefined, /*isRootFile*/false)); + } + } + else { + files.forEach((fileContent, fileName) => { + this.addFile(fileName, new Harness.LanguageService.ScriptInfo(fileName, fileContent, /*isRootFile*/false)); + }); } } diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 1e6b44788b3..e5eabe950a2 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1171,8 +1171,9 @@ interface Array { /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. */ - splice(start: number): T[]; + splice(start: number, deleteCount?: number): T[]; /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. diff --git a/src/server/builder.ts b/src/server/builder.ts index 60f56dc3241..a5e7b06e64b 100644 --- a/src/server/builder.ts +++ b/src/server/builder.ts @@ -356,24 +356,24 @@ namespace ts.server { // Use slice to clone the array to avoid manipulating in place const queue = fileInfo.referencedBy.slice(0); const fileNameSet = createMap(); - fileNameSet[scriptInfo.fileName] = scriptInfo; + fileNameSet.set(scriptInfo.fileName, scriptInfo); while (queue.length > 0) { const processingFileInfo = queue.pop(); if (processingFileInfo.updateShapeSignature() && processingFileInfo.referencedBy.length > 0) { for (const potentialFileInfo of processingFileInfo.referencedBy) { - if (!fileNameSet[potentialFileInfo.scriptInfo.fileName]) { + if (!fileNameSet.has(potentialFileInfo.scriptInfo.fileName)) { queue.push(potentialFileInfo); } } } - fileNameSet[processingFileInfo.scriptInfo.fileName] = processingFileInfo.scriptInfo; + fileNameSet.set(processingFileInfo.scriptInfo.fileName, processingFileInfo.scriptInfo); } const result: string[] = []; - for (const fileName in fileNameSet) { - if (shouldEmitFile(fileNameSet[fileName])) { + fileNameSet.forEach((scriptInfo, fileName) => { + if (shouldEmitFile(scriptInfo)) { result.push(fileName); } - } + }); return result; } } diff --git a/src/server/cancellationToken/tsconfig.json b/src/server/cancellationToken/tsconfig.json index 1c4c0d60826..fa7f88ca994 100644 --- a/src/server/cancellationToken/tsconfig.json +++ b/src/server/cancellationToken/tsconfig.json @@ -1,19 +1,11 @@ { + "extends": "../../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": true, "removeComments": true, - "preserveConstEnums": true, - "pretty": true, "module": "commonjs", - "sourceMap": true, - "stripInternal": true, "types": [ "node" - ], - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true + ] }, "files": [ "cancellationToken.ts" diff --git a/src/server/client.ts b/src/server/client.ts index 3b09a926754..d9e93769bd9 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -31,10 +31,11 @@ namespace ts.server { } private getLineMap(fileName: string): number[] { - let lineMap = this.lineMaps[fileName]; + let lineMap = this.lineMaps.get(fileName); if (!lineMap) { const scriptSnapshot = this.host.getScriptSnapshot(fileName); - lineMap = this.lineMaps[fileName] = ts.computeLineStarts(scriptSnapshot.getText(0, scriptSnapshot.getLength())); + lineMap = ts.computeLineStarts(scriptSnapshot.getText(0, scriptSnapshot.getLength())); + this.lineMaps.set(fileName, lineMap); } return lineMap; } @@ -140,7 +141,7 @@ namespace ts.server { changeFile(fileName: string, start: number, end: number, newText: string): void { // clear the line map after an edit - this.lineMaps[fileName] = undefined; + this.lineMaps.set(fileName, undefined); const lineOffset = this.positionToOneBasedLineOffset(fileName, start); const endLineOffset = this.positionToOneBasedLineOffset(fileName, end); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index bf8b27a5b55..dd5d9f912eb 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// @@ -41,17 +41,17 @@ namespace ts.server { if (typeof option.type === "object") { const optionMap = >option.type; // verify that map contains only numbers - for (const id in optionMap) { - Debug.assert(typeof optionMap[id] === "number"); - } - map[option.name] = optionMap; + optionMap.forEach(value => { + Debug.assert(typeof value === "number"); + }); + map.set(option.name, optionMap); } } return map; } const compilerOptionConverters = prepareConvertersForEnumLikeCompilerOptions(optionDeclarations); - const indentStyle = createMap({ + const indentStyle = createMapFromTemplate({ "none": IndentStyle.None, "block": IndentStyle.Block, "smart": IndentStyle.Smart @@ -59,20 +59,19 @@ namespace ts.server { export function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings { if (typeof protocolOptions.indentStyle === "string") { - protocolOptions.indentStyle = indentStyle[protocolOptions.indentStyle.toLowerCase()]; + protocolOptions.indentStyle = indentStyle.get(protocolOptions.indentStyle.toLowerCase()); Debug.assert(protocolOptions.indentStyle !== undefined); } return protocolOptions; } export function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin { - for (const id in compilerOptionConverters) { + compilerOptionConverters.forEach((mappedValues, id) => { const propertyValue = protocolOptions[id]; if (typeof propertyValue === "string") { - const mappedValues = compilerOptionConverters[id]; - protocolOptions[id] = mappedValues[propertyValue.toLowerCase()]; + protocolOptions[id] = mappedValues.get(propertyValue.toLowerCase()); } - } + }); return protocolOptions; } @@ -193,11 +192,12 @@ namespace ts.server { stopWatchingDirectory(directory: string) { // if the ref count for this directory watcher drops to 0, it's time to close it - this.directoryWatchersRefCount[directory]--; - if (this.directoryWatchersRefCount[directory] === 0) { + const refCount = this.directoryWatchersRefCount.get(directory) - 1; + this.directoryWatchersRefCount.set(directory, refCount); + if (refCount === 0) { this.projectService.logger.info(`Close directory watcher for: ${directory}`); - this.directoryWatchersForTsconfig[directory].close(); - delete this.directoryWatchersForTsconfig[directory]; + this.directoryWatchersForTsconfig.get(directory).close(); + this.directoryWatchersForTsconfig.delete(directory); } } @@ -205,13 +205,13 @@ namespace ts.server { let currentPath = getDirectoryPath(fileName); let parentPath = getDirectoryPath(currentPath); while (currentPath != parentPath) { - if (!this.directoryWatchersForTsconfig[currentPath]) { + if (!this.directoryWatchersForTsconfig.has(currentPath)) { this.projectService.logger.info(`Add watcher for: ${currentPath}`); - this.directoryWatchersForTsconfig[currentPath] = this.projectService.host.watchDirectory(currentPath, callback); - this.directoryWatchersRefCount[currentPath] = 1; + this.directoryWatchersForTsconfig.set(currentPath, this.projectService.host.watchDirectory(currentPath, callback)); + this.directoryWatchersRefCount.set(currentPath, 1); } else { - this.directoryWatchersRefCount[currentPath] += 1; + this.directoryWatchersRefCount.set(currentPath, this.directoryWatchersRefCount.get(currentPath) + 1); } project.directoriesWatchedForTsconfig.push(currentPath); currentPath = parentPath; @@ -293,6 +293,7 @@ namespace ts.server { this.documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory()); } + /* @internal */ getChangedFiles_TestOnly() { return this.changedFiles; } @@ -430,7 +431,7 @@ namespace ts.server { } else { if (info && (!info.isScriptOpen())) { - // file has been changed which might affect the set of referenced files in projects that include + // file has been changed which might affect the set of referenced files in projects that include // this file and set of inferred projects info.reloadFromFile(); this.updateProjectGraphs(info.containingProjects); @@ -449,7 +450,7 @@ namespace ts.server { this.filenameToScriptInfo.remove(info.path); this.lastDeletedFile = info; - // capture list of projects since detachAllProjects will wipe out original list + // capture list of projects since detachAllProjects will wipe out original list const containingProjects = info.containingProjects.slice(); info.detachAllProjects(); @@ -605,7 +606,7 @@ namespace ts.server { const inferredProject = this.createInferredProjectWithRootFileIfNecessary(info); if (!this.useSingleInferredProject) { // if useOneInferredProject is not set then try to fixup ownership of open files - // check 'defaultProject !== inferredProject' is necessary to handle cases + // check 'defaultProject !== inferredProject' is necessary to handle cases // when creation inferred project for some file has added other open files into this project (i.e. as referenced files) // we definitely don't want to delete the project that was just created for (const f of this.openFiles) { @@ -615,7 +616,7 @@ namespace ts.server { } const defaultProject = f.getDefaultProject(); if (isRootFileInInferredProject(info) && defaultProject !== inferredProject && inferredProject.containsScriptInfo(f)) { - // open file used to be root in inferred project, + // open file used to be root in inferred project, // this inferred project is different from the one we've just created for current file // and new inferred project references this open file. // We should delete old inferred project and attach open file to the new one @@ -838,7 +839,7 @@ namespace ts.server { files: parsedCommandLine.fileNames, compilerOptions: parsedCommandLine.options, configHasFilesProperty: parsedCommandLine.raw["files"] !== undefined, - wildcardDirectories: createMap(parsedCommandLine.wildcardDirectories), + wildcardDirectories: createMapFromTemplate(parsedCommandLine.wildcardDirectories), typeAcquisition: parsedCommandLine.typeAcquisition, compileOnSave: parsedCommandLine.compileOnSave }; @@ -1000,7 +1001,7 @@ namespace ts.server { if (toAdd) { for (const f of toAdd) { if (f.isScriptOpen() && isRootFileInInferredProject(f)) { - // if file is already root in some inferred project + // if file is already root in some inferred project // - remove the file from that project and delete the project if necessary const inferredProject = f.containingProjects[0]; inferredProject.removeFile(f); @@ -1153,7 +1154,7 @@ namespace ts.server { this.logger.info(`Host information ${args.hostInfo}`); } if (args.formatOptions) { - mergeMaps(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); + mergeMapLikes(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); this.logger.info("Format host information updated"); } if (args.extraFileExtensions) { @@ -1268,6 +1269,7 @@ namespace ts.server { } } + /* @internal */ synchronizeProjectList(knownProjects: protocol.ProjectVersionInfo[]): ProjectFilesWithTSDiagnostics[] { const files: ProjectFilesWithTSDiagnostics[] = []; this.collectChanges(knownProjects, this.externalProjects, files); @@ -1276,6 +1278,7 @@ namespace ts.server { return files; } + /* @internal */ applyChangesInOpenFiles(openFiles: protocol.ExternalFile[], changedFiles: protocol.ChangedOpenFile[], closedFiles: string[]): void { const recordChangedFiles = changedFiles && !openFiles && !closedFiles; if (openFiles) { @@ -1291,7 +1294,7 @@ namespace ts.server { for (const file of changedFiles) { const scriptInfo = this.getScriptInfo(file.fileName); Debug.assert(!!scriptInfo); - // apply changes in reverse order + // apply changes in reverse order for (let i = file.changes.length - 1; i >= 0; i--) { const change = file.changes[i]; scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText); @@ -1328,7 +1331,7 @@ namespace ts.server { closeExternalProject(uncheckedFileName: string, suppressRefresh = false): void { const fileName = toNormalizedPath(uncheckedFileName); - const configFiles = this.externalProjectToConfiguredProjectMap[fileName]; + const configFiles = this.externalProjectToConfiguredProjectMap.get(fileName); if (configFiles) { let shouldRefreshInferredProjects = false; for (const configFile of configFiles) { @@ -1336,7 +1339,7 @@ namespace ts.server { shouldRefreshInferredProjects = true; } } - delete this.externalProjectToConfiguredProjectMap[fileName]; + this.externalProjectToConfiguredProjectMap.delete(fileName); if (shouldRefreshInferredProjects && !suppressRefresh) { this.refreshInferredProjects(); } @@ -1356,20 +1359,20 @@ namespace ts.server { openExternalProjects(projects: protocol.ExternalProject[]): void { // record project list before the update const projectsToClose = arrayToMap(this.externalProjects, p => p.getProjectName(), _ => true); - for (const externalProjectName in this.externalProjectToConfiguredProjectMap) { - projectsToClose[externalProjectName] = true; - } + forEachKey(this.externalProjectToConfiguredProjectMap, externalProjectName => { + projectsToClose.set(externalProjectName, true); + }); for (const externalProject of projects) { this.openExternalProject(externalProject, /*suppressRefreshOfInferredProjects*/ true); // delete project that is present in input list - delete projectsToClose[externalProject.projectFileName]; + projectsToClose.delete(externalProject.projectFileName); } // close projects that were missing in the input list - for (const externalProjectName in projectsToClose) { + forEachKey(projectsToClose, externalProjectName => { this.closeExternalProject(externalProjectName, /*suppressRefresh*/ true) - } + }); this.refreshInferredProjects(); } @@ -1419,7 +1422,7 @@ namespace ts.server { // close existing project and later we'll open a set of configured projects for these files this.closeExternalProject(proj.projectFileName, /*suppressRefresh*/ true); } - else if (this.externalProjectToConfiguredProjectMap[proj.projectFileName]) { + else if (this.externalProjectToConfiguredProjectMap.get(proj.projectFileName)) { // this project used to include config files if (!tsConfigFiles) { // config files were removed from the project - close existing external project which in turn will close configured projects @@ -1427,7 +1430,7 @@ namespace ts.server { } else { // project previously had some config files - compare them with new set of files and close all configured projects that correspond to unused files - const oldConfigFiles = this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + const oldConfigFiles = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName); let iNew = 0; let iOld = 0; while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) { @@ -1455,7 +1458,7 @@ namespace ts.server { } if (tsConfigFiles) { // store the list of tsconfig files that belong to the external project - this.externalProjectToConfiguredProjectMap[proj.projectFileName] = tsConfigFiles; + this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, tsConfigFiles); for (const tsconfigFile of tsConfigFiles) { let project = this.findConfiguredProjectByProjectName(tsconfigFile); if (!project) { @@ -1471,7 +1474,7 @@ namespace ts.server { } else { // no config files - remove the item from the collection - delete this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName); this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition); } if (!suppressRefreshOfInferredProjects) { diff --git a/src/server/lsHost.ts b/src/server/lsHost.ts index d73a31933f4..9d8c9c08cb6 100644 --- a/src/server/lsHost.ts +++ b/src/server/lsHost.ts @@ -75,15 +75,16 @@ namespace ts.server { for (const name of names) { // check if this is a duplicate entry in the list - let resolution = newResolutions[name]; + let resolution = newResolutions.get(name); if (!resolution) { - const existingResolution = currentResolutionsInFile && currentResolutionsInFile[name]; + const existingResolution = currentResolutionsInFile && currentResolutionsInFile.get(name); if (moduleResolutionIsValid(existingResolution)) { // ok, it is safe to use existing name resolution results resolution = existingResolution; } else { - newResolutions[name] = resolution = loader(name, containingFile, compilerOptions, this); + resolution = loader(name, containingFile, compilerOptions, this); + newResolutions.set(name, resolution); } if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { this.filesWithChangedSetOfUnresolvedImports.push(path); @@ -135,6 +136,10 @@ namespace ts.server { } } + getNewLine() { + return this.host.newLine; + } + getProjectVersion() { return this.project.getProjectVersion(); } diff --git a/src/server/project.ts b/src/server/project.ts index 6085ee05159..6042fd9a62b 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// @@ -58,6 +58,7 @@ namespace ts.server { return counts.ts === 0 && counts.tsx === 0; } + /* @internal */ export interface ProjectFilesWithTSDiagnostics extends protocol.ProjectFiles { projectErrors: Diagnostic[]; } @@ -395,7 +396,9 @@ namespace ts.server { } removeFile(info: ScriptInfo, detachFromProject = true) { - this.removeRootFileIfNecessary(info); + if (this.isRoot(info)) { + this.removeRoot(info); + } this.lsHost.notifyFileRemoved(info); this.cachedUnresolvedImportsPerFile.remove(info.path); @@ -407,7 +410,7 @@ namespace ts.server { } registerFileUpdate(fileName: string) { - (this.updatedFileNames || (this.updatedFileNames = createMap()))[fileName] = fileName; + (this.updatedFileNames || (this.updatedFileNames = createMap())).set(fileName, fileName); } markAsDirty() { @@ -425,9 +428,9 @@ namespace ts.server { } let unresolvedImports: string[]; if (file.resolvedModules) { - for (const name in file.resolvedModules) { + file.resolvedModules.forEach((resolvedModule, name) => { // pick unresolved non-relative names - if (!file.resolvedModules[name] && !isExternalModuleNameRelative(name)) { + if (!resolvedModule && !isExternalModuleNameRelative(name)) { // for non-scoped names extract part up-to the first slash // for scoped names - extract up to the second slash let trimmed = name.trim(); @@ -441,7 +444,7 @@ namespace ts.server { (unresolvedImports || (unresolvedImports = [])).push(trimmed); result.push(trimmed); } - } + }); } this.cachedUnresolvedImportsPerFile.set(file.path, unresolvedImports || emptyArray); } @@ -463,7 +466,7 @@ namespace ts.server { } // 1. no changes in structure, no changes in unresolved imports - do nothing - // 2. no changes in structure, unresolved imports were changed - collect unresolved imports for all files + // 2. no changes in structure, unresolved imports were changed - collect unresolved imports for all files // (can reuse cached imports for files that were not changed) // 3. new files were added/removed, but compilation settings stays the same - collect unresolved imports for all new/modified files // (can reuse cached imports for files that were not changed) @@ -566,9 +569,6 @@ namespace ts.server { setCompilerOptions(compilerOptions: CompilerOptions) { if (compilerOptions) { - if (this.projectKind === ProjectKind.Inferred) { - compilerOptions.allowJs = true; - } compilerOptions.allowNonTsExtensions = true; if (changesAffectModuleResolution(this.compilerOptions, compilerOptions)) { // reset cached unresolved imports if changes in compiler options affected module resolution @@ -593,6 +593,7 @@ namespace ts.server { return false; } + /* @internal */ getChangesSinceVersion(lastKnownVersion?: number): ProjectFilesWithTSDiagnostics { this.updateGraph(); @@ -617,17 +618,18 @@ namespace ts.server { const added: string[] = []; const removed: string[] = []; - const updated: string[] = getOwnKeys(updatedFileNames); - for (const id in currentFiles) { - if (!hasProperty(lastReportedFileNames, id)) { + const updated: string[] = arrayFrom(updatedFileNames.keys()); + + forEachKey(currentFiles, id => { + if (!lastReportedFileNames.has(id)) { added.push(id); } - } - for (const id in lastReportedFileNames) { - if (!hasProperty(currentFiles, id)) { + }); + forEachKey(lastReportedFileNames, id => { + if (!currentFiles.has(id)) { removed.push(id); } - } + }); this.lastReportedFileNames = currentFiles; this.lastReportedVersion = this.projectStructureVersion; return { info, changes: { added, removed, updated }, projectErrors: this.projectErrors }; @@ -661,7 +663,7 @@ namespace ts.server { if (symbol && symbol.declarations && symbol.declarations[0]) { const declarationSourceFile = symbol.declarations[0].getSourceFile(); if (declarationSourceFile) { - referencedFiles[declarationSourceFile.path] = true; + referencedFiles.set(declarationSourceFile.path, true); } } } @@ -673,34 +675,31 @@ namespace ts.server { if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) { for (const referencedFile of sourceFile.referencedFiles) { const referencedPath = toPath(referencedFile.fileName, currentDirectory, getCanonicalFileName); - referencedFiles[referencedPath] = true; + referencedFiles.set(referencedPath, true); } } // Handle type reference directives if (sourceFile.resolvedTypeReferenceDirectiveNames) { - for (const typeName in sourceFile.resolvedTypeReferenceDirectiveNames) { - const resolvedTypeReferenceDirective = sourceFile.resolvedTypeReferenceDirectiveNames[typeName]; + sourceFile.resolvedTypeReferenceDirectiveNames.forEach((resolvedTypeReferenceDirective) => { if (!resolvedTypeReferenceDirective) { - continue; + return; } const fileName = resolvedTypeReferenceDirective.resolvedFileName; const typeFilePath = toPath(fileName, currentDirectory, getCanonicalFileName); - referencedFiles[typeFilePath] = true; - } + referencedFiles.set(typeFilePath, true); + }) } - const allFileNames = map(Object.keys(referencedFiles), key => key); + const allFileNames = arrayFrom(referencedFiles.keys()) as Path[]; return filter(allFileNames, file => this.projectService.host.fileExists(file)); } // remove a root file from project - private removeRootFileIfNecessary(info: ScriptInfo): void { - if (this.isRoot(info)) { - remove(this.rootFiles, info); - this.rootFilesMap.remove(info.path); - } + protected removeRoot(info: ScriptInfo): void { + remove(this.rootFiles, info); + this.rootFilesMap.remove(info.path); } } @@ -715,6 +714,32 @@ namespace ts.server { } })(); + private _isJsInferredProject = false; + + toggleJsInferredProject(isJsInferredProject: boolean) { + if (isJsInferredProject !== this._isJsInferredProject) { + this._isJsInferredProject = isJsInferredProject; + this.setCompilerOptions(); + } + } + + setCompilerOptions(options?: CompilerOptions) { + // Avoid manipulating the given options directly + const newOptions = options ? clone(options) : this.getCompilerOptions(); + if (!newOptions) { + return; + } + + if (this._isJsInferredProject && typeof newOptions.maxNodeModuleJsDepth !== "number") { + newOptions.maxNodeModuleJsDepth = 2; + } + else if (!this._isJsInferredProject) { + newOptions.maxNodeModuleJsDepth = undefined; + } + newOptions.allowJs = true; + super.setCompilerOptions(newOptions); + } + // Used to keep track of what directories are watched for this project directoriesWatchedForTsconfig: string[] = []; @@ -729,6 +754,22 @@ namespace ts.server { /*compileOnSaveEnabled*/ false); } + addRoot(info: ScriptInfo) { + if (!this._isJsInferredProject && info.isJavaScript()) { + this.toggleJsInferredProject(/*isJsInferredProject*/ true); + } + super.addRoot(info); + } + + removeRoot(info: ScriptInfo) { + if (this._isJsInferredProject && info.isJavaScript()) { + if (filter(this.getRootScriptInfos(), info => info.isJavaScript()).length === 0) { + this.toggleJsInferredProject(/*isJsInferredProject*/ false); + } + } + super.removeRoot(info); + } + getProjectRootPath() { // Single inferred project does not have a project root. if (this.projectService.useSingleInferredProject) { @@ -827,18 +868,19 @@ namespace ts.server { return; } const configDirectoryPath = getDirectoryPath(this.getConfigFilePath()); - this.directoriesWatchedForWildcards = reduceProperties(this.wildcardDirectories, (watchers, flag, directory) => { + + this.directoriesWatchedForWildcards = createMap(); + this.wildcardDirectories.forEach((flag, directory) => { if (comparePaths(configDirectoryPath, directory, ".", !this.projectService.host.useCaseSensitiveFileNames) !== Comparison.EqualTo) { const recursive = (flag & WatchDirectoryFlags.Recursive) !== 0; this.projectService.logger.info(`Add ${recursive ? "recursive " : ""}watcher for: ${directory}`); - watchers[directory] = this.projectService.host.watchDirectory( + this.directoriesWatchedForWildcards.set(directory, this.projectService.host.watchDirectory( directory, path => callback(this, path), recursive - ); + )); } - return watchers; - }, >{}); + }); } stopWatchingDirectory() { @@ -862,9 +904,9 @@ namespace ts.server { this.typeRootsWatchers = undefined; } - for (const id in this.directoriesWatchedForWildcards) { - this.directoriesWatchedForWildcards[id].close(); - } + this.directoriesWatchedForWildcards.forEach(watcher => { + watcher.close(); + }); this.directoriesWatchedForWildcards = undefined; this.stopWatchingDirectory(); diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index 0acd45d0287..be3ef34ce3a 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -278,7 +278,7 @@ namespace ts.server { if (!this.formatCodeSettings) { this.formatCodeSettings = getDefaultFormatCodeSettings(this.host); } - mergeMaps(this.formatCodeSettings, formatSettings); + mergeMapLikes(this.formatCodeSettings, formatSettings); } } @@ -355,5 +355,9 @@ namespace ts.server { positionToLineOffset(position: number): ILineInfo { return this.textStorage.positionToLineOffset(position); } + + public isJavaScript() { + return this.scriptKind === ScriptKind.JS || this.scriptKind === ScriptKind.JSX; + } } } \ No newline at end of file diff --git a/src/server/scriptVersionCache.ts b/src/server/scriptVersionCache.ts index e087c3b6dde..7f09bcd549b 100644 --- a/src/server/scriptVersionCache.ts +++ b/src/server/scriptVersionCache.ts @@ -113,7 +113,7 @@ namespace ts.server { if (len > 1) { let insertedNodes = new Array(len - 1); let startNode = leafNode; - for (let i = 1, len = lines.length; i < len; i++) { + for (let i = 1; i < lines.length; i++) { insertedNodes[i - 1] = new LineLeaf(lines[i]); } let pathIndex = this.startPath.length - 2; @@ -341,8 +341,7 @@ namespace ts.server { let snap = this.versions[this.currentVersionToIndex()]; if (this.changes.length > 0) { let snapIndex = snap.index; - for (let i = 0, len = this.changes.length; i < len; i++) { - const change = this.changes[i]; + for (const change of this.changes) { snapIndex = snapIndex.edit(change.pos, change.deleteLen, change.insertedText); } snap = new LineIndexSnapshot(this.currentVersion + 1, this); @@ -366,8 +365,7 @@ namespace ts.server { const textChangeRanges: ts.TextChangeRange[] = []; for (let i = oldVersion + 1; i <= newVersion; i++) { const snap = this.versions[this.versionToIndex(i)]; - for (let j = 0, len = snap.changesSincePreviousVersion.length; j < len; j++) { - const textChange = snap.changesSincePreviousVersion[j]; + for (const textChange of snap.changesSincePreviousVersion) { textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); } } @@ -471,7 +469,7 @@ namespace ts.server { load(lines: string[]) { if (lines.length > 0) { const leaves: LineLeaf[] = []; - for (let i = 0, len = lines.length; i < len; i++) { + for (let i = 0; i < lines.length; i++) { leaves[i] = new LineLeaf(lines[i]); } this.root = LineIndex.buildTreeFromBottom(leaves); @@ -643,8 +641,7 @@ namespace ts.server { updateCounts() { this.totalChars = 0; this.totalLines = 0; - for (let i = 0, len = this.children.length; i < len; i++) { - const child = this.children[i]; + for (const child of this.children) { this.totalChars += child.charCount(); this.totalLines += child.lineCount(); } diff --git a/src/server/server.ts b/src/server/server.ts index a020ef210fe..e689a2fc782 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -409,7 +409,8 @@ namespace ts.server { function parseLoggingEnvironmentString(logEnvStr: string): LogOptions { const logEnv: LogOptions = { logToFile: true }; const args = logEnvStr.split(" "); - for (let i = 0, len = args.length; i < (len - 1); i += 2) { + const len = args.length - 1; + for (let i = 0; i < len; i += 2) { const option = args[i]; const value = args[i + 1]; if (option && value) { diff --git a/src/server/session.ts b/src/server/session.ts index 5c382aae7d3..1fa3986f66f 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -88,50 +88,65 @@ namespace ts.server { export namespace CommandNames { export const Brace: protocol.CommandTypes.Brace = "brace"; + /* @internal */ export const BraceFull: protocol.CommandTypes.BraceFull = "brace-full"; export const BraceCompletion: protocol.CommandTypes.BraceCompletion = "braceCompletion"; export const Change: protocol.CommandTypes.Change = "change"; export const Close: protocol.CommandTypes.Close = "close"; export const Completions: protocol.CommandTypes.Completions = "completions"; + /* @internal */ export const CompletionsFull: protocol.CommandTypes.CompletionsFull = "completions-full"; export const CompletionDetails: protocol.CommandTypes.CompletionDetails = "completionEntryDetails"; export const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; export const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile = "compileOnSaveEmitFile"; export const Configure: protocol.CommandTypes.Configure = "configure"; export const Definition: protocol.CommandTypes.Definition = "definition"; + /* @internal */ export const DefinitionFull: protocol.CommandTypes.DefinitionFull = "definition-full"; export const Exit: protocol.CommandTypes.Exit = "exit"; export const Format: protocol.CommandTypes.Format = "format"; export const Formatonkey: protocol.CommandTypes.Formatonkey = "formatonkey"; + /* @internal */ export const FormatFull: protocol.CommandTypes.FormatFull = "format-full"; + /* @internal */ export const FormatonkeyFull: protocol.CommandTypes.FormatonkeyFull = "formatonkey-full"; + /* @internal */ export const FormatRangeFull: protocol.CommandTypes.FormatRangeFull = "formatRange-full"; export const Geterr: protocol.CommandTypes.Geterr = "geterr"; export const GeterrForProject: protocol.CommandTypes.GeterrForProject = "geterrForProject"; export const Implementation: protocol.CommandTypes.Implementation = "implementation"; + /* @internal */ export const ImplementationFull: protocol.CommandTypes.ImplementationFull = "implementation-full"; export const SemanticDiagnosticsSync: protocol.CommandTypes.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; export const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; export const NavBar: protocol.CommandTypes.NavBar = "navbar"; + /* @internal */ export const NavBarFull: protocol.CommandTypes.NavBarFull = "navbar-full"; export const NavTree: protocol.CommandTypes.NavTree = "navtree"; export const NavTreeFull: protocol.CommandTypes.NavTreeFull = "navtree-full"; export const Navto: protocol.CommandTypes.Navto = "navto"; + /* @internal */ export const NavtoFull: protocol.CommandTypes.NavtoFull = "navto-full"; export const Occurrences: protocol.CommandTypes.Occurrences = "occurrences"; export const DocumentHighlights: protocol.CommandTypes.DocumentHighlights = "documentHighlights"; + /* @internal */ export const DocumentHighlightsFull: protocol.CommandTypes.DocumentHighlightsFull = "documentHighlights-full"; export const Open: protocol.CommandTypes.Open = "open"; export const Quickinfo: protocol.CommandTypes.Quickinfo = "quickinfo"; + /* @internal */ export const QuickinfoFull: protocol.CommandTypes.QuickinfoFull = "quickinfo-full"; export const References: protocol.CommandTypes.References = "references"; + /* @internal */ export const ReferencesFull: protocol.CommandTypes.ReferencesFull = "references-full"; export const Reload: protocol.CommandTypes.Reload = "reload"; export const Rename: protocol.CommandTypes.Rename = "rename"; + /* @internal */ export const RenameInfoFull: protocol.CommandTypes.RenameInfoFull = "rename-full"; + /* @internal */ export const RenameLocationsFull: protocol.CommandTypes.RenameLocationsFull = "renameLocations-full"; export const Saveto: protocol.CommandTypes.Saveto = "saveto"; export const SignatureHelp: protocol.CommandTypes.SignatureHelp = "signatureHelp"; + /* @internal */ export const SignatureHelpFull: protocol.CommandTypes.SignatureHelpFull = "signatureHelp-full"; export const TypeDefinition: protocol.CommandTypes.TypeDefinition = "typeDefinition"; export const ProjectInfo: protocol.CommandTypes.ProjectInfo = "projectInfo"; @@ -140,19 +155,28 @@ namespace ts.server { export const OpenExternalProject: protocol.CommandTypes.OpenExternalProject = "openExternalProject"; export const OpenExternalProjects: protocol.CommandTypes.OpenExternalProjects = "openExternalProjects"; export const CloseExternalProject: protocol.CommandTypes.CloseExternalProject = "closeExternalProject"; + /* @internal */ export const SynchronizeProjectList: protocol.CommandTypes.SynchronizeProjectList = "synchronizeProjectList"; + /* @internal */ export const ApplyChangedToOpenFiles: protocol.CommandTypes.ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; + /* @internal */ export const EncodedSemanticClassificationsFull: protocol.CommandTypes.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; + /* @internal */ export const Cleanup: protocol.CommandTypes.Cleanup = "cleanup"; + /* @internal */ export const OutliningSpans: protocol.CommandTypes.OutliningSpans = "outliningSpans"; export const TodoComments: protocol.CommandTypes.TodoComments = "todoComments"; export const Indentation: protocol.CommandTypes.Indentation = "indentation"; export const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate = "docCommentTemplate"; + /* @internal */ export const CompilerOptionsDiagnosticsFull: protocol.CommandTypes.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; + /* @internal */ export const NameOrDottedNameSpan: protocol.CommandTypes.NameOrDottedNameSpan = "nameOrDottedNameSpan"; + /* @internal */ export const BreakpointStatement: protocol.CommandTypes.BreakpointStatement = "breakpointStatement"; export const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; export const GetCodeFixes: protocol.CommandTypes.GetCodeFixes = "getCodeFixes"; + /* @internal */ export const GetCodeFixesFull: protocol.CommandTypes.GetCodeFixesFull = "getCodeFixes-full"; export const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes = "getSupportedCodeFixes"; } @@ -1366,7 +1390,7 @@ namespace ts.server { return { response, responseRequired: true }; } - private handlers = createMap<(request: protocol.Request) => { response?: any, responseRequired?: boolean }>({ + private handlers = createMapFromTemplate<(request: protocol.Request) => { response?: any, responseRequired?: boolean }>({ [CommandNames.OpenExternalProject]: (request: protocol.OpenExternalProjectRequest) => { this.projectService.openExternalProject(request.arguments, /*suppressRefreshOfInferredProjects*/ false); // TODO: report errors @@ -1610,14 +1634,14 @@ namespace ts.server { }); public addProtocolHandler(command: string, handler: (request: protocol.Request) => { response?: any, responseRequired: boolean }) { - if (command in this.handlers) { + if (this.handlers.has(command)) { throw new Error(`Protocol handler already exists for command "${command}"`); } - this.handlers[command] = handler; + this.handlers.set(command, handler); } public executeCommand(request: protocol.Request): { response?: any, responseRequired?: boolean } { - const handler = this.handlers[request.command]; + const handler = this.handlers.get(request.command); if (handler) { return handler(request); } diff --git a/src/server/shared.ts b/src/server/shared.ts index c56d4098e75..77f66fc5a2d 100644 --- a/src/server/shared.ts +++ b/src/server/shared.ts @@ -1,4 +1,4 @@ -/// +/// namespace ts.server { export const ActionSet: ActionSet = "action::set"; diff --git a/src/server/tsconfig.json b/src/server/tsconfig.json index 85c88679164..2f17019e2de 100644 --- a/src/server/tsconfig.json +++ b/src/server/tsconfig.json @@ -1,19 +1,11 @@ { + "extends": "../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": true, "removeComments": true, - "preserveConstEnums": true, - "pretty": true, "outFile": "../../built/local/tsserver.js", - "sourceMap": true, - "stripInternal": true, "types": [ "node" - ], - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true + ] }, "files": [ "../services/shims.ts", diff --git a/src/server/tsconfig.library.json b/src/server/tsconfig.library.json index 5483cc8ec28..76d700dd291 100644 --- a/src/server/tsconfig.library.json +++ b/src/server/tsconfig.library.json @@ -1,29 +1,30 @@ { "compilerOptions": { "noImplicitAny": true, - "removeComments": true, + "noImplicitThis": true, "preserveConstEnums": true, + "pretty": true, "outFile": "../../built/local/tsserverlibrary.js", "sourceMap": true, "stripInternal": true, - "declaration": true, - "types": [], "target": "es5", "noUnusedLocals": true, - "noUnusedParameters": true + "noUnusedParameters": true, + "declaration": true }, "files": [ - "../services/shims.ts", - "../services/utilities.ts", - "shared.ts", - "utilities.ts", - "scriptVersionCache.ts", - "scriptInfo.ts", - "lshost.ts", - "typingsCache.ts", - "project.ts", "editorServices.ts", - "protocol.d.ts", - "session.ts" + "lsHost.ts", + "project.ts", + "protocol.ts", + "scriptInfo.ts", + "scriptVersionCache.ts", + "session.ts", + "shared.ts", + "types.ts", + "typingsCache.ts", + "utilities.ts", + "../services/shims.ts", + "../services/utilities.ts" ] } diff --git a/src/server/types.d.ts b/src/server/types.ts similarity index 96% rename from src/server/types.d.ts rename to src/server/types.ts index 9f53fa8def1..2c18f275202 100644 --- a/src/server/types.d.ts +++ b/src/server/types.ts @@ -82,6 +82,7 @@ declare namespace ts.server { readonly installSuccess: boolean; } + /* @internal */ export interface InstallTypingHost extends JsTyping.TypingResolutionHost { writeFile(path: string, content: string): void; createDirectory(path: string): void; diff --git a/src/server/typingsCache.ts b/src/server/typingsCache.ts index 8b03d59003c..9379ae82d0e 100644 --- a/src/server/typingsCache.ts +++ b/src/server/typingsCache.ts @@ -35,17 +35,18 @@ namespace ts.server { let unique = 0; for (const v of arr1) { - if (set[v] !== true) { - set[v] = true; + if (set.get(v) !== true) { + set.set(v, true); unique++; } } for (const v of arr2) { - if (!hasProperty(set, v)) { + const isSet = set.get(v); + if (isSet === undefined) { return false; } - if (set[v] === true) { - set[v] = false; + if (isSet === true) { + set.set(v, false); unique--; } } @@ -83,7 +84,7 @@ namespace ts.server { return emptyArray; } - const entry = this.perProjectCache[project.getProjectName()]; + const entry = this.perProjectCache.get(project.getProjectName()); const result: SortedReadonlyArray = entry ? entry.typings : emptyArray; if (forceRefresh || !entry || @@ -92,13 +93,13 @@ namespace ts.server { unresolvedImportsChanged(unresolvedImports, entry.unresolvedImports)) { // Note: entry is now poisoned since it does not really contain typings for a given combination of compiler options\typings options. // instead it acts as a placeholder to prevent issuing multiple requests - this.perProjectCache[project.getProjectName()] = { + this.perProjectCache.set(project.getProjectName(), { compilerOptions: project.getCompilerOptions(), typeAcquisition, typings: result, unresolvedImports, poisoned: true - }; + }); // something has been changed, issue a request to update typings this.installer.enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports); } @@ -106,21 +107,21 @@ namespace ts.server { } updateTypingsForProject(projectName: string, compilerOptions: CompilerOptions, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, newTypings: string[]) { - this.perProjectCache[projectName] = { + this.perProjectCache.set(projectName, { compilerOptions, typeAcquisition, typings: toSortedReadonlyArray(newTypings), unresolvedImports, poisoned: false - }; + }); } deleteTypingsForProject(projectName: string) { - delete this.perProjectCache[projectName]; + this.perProjectCache.delete(projectName); } onProjectClosed(project: Project) { - delete this.perProjectCache[project.getProjectName()]; + this.perProjectCache.delete(project.getProjectName()); this.installer.onProjectClosed(project); } } diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index 19f794ad57c..ff20e89e2d7 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -46,7 +46,7 @@ namespace ts.server.typingsInstaller { } try { const content = JSON.parse(host.readFile(typesRegistryFilePath)); - return createMap(content.entries); + return createMapFromTemplate(content.entries); } catch (e) { if (log.isEnabled()) { diff --git a/src/server/typingsInstaller/tsconfig.json b/src/server/typingsInstaller/tsconfig.json index c6031b19aae..7bfb6c8b1ed 100644 --- a/src/server/typingsInstaller/tsconfig.json +++ b/src/server/typingsInstaller/tsconfig.json @@ -1,22 +1,14 @@ { + "extends": "../../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": true, "removeComments": true, - "preserveConstEnums": true, - "pretty": true, "outFile": "../../../built/local/typingsInstaller.js", - "sourceMap": true, - "stripInternal": true, "types": [ "node" - ], - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true + ] }, "files": [ - "../types.d.ts", + "../types.ts", "../shared.ts", "typingsInstaller.ts", "nodeTypingsInstaller.ts" diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index 7a09c1f6c21..1869c542a6e 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -1,7 +1,7 @@ /// /// /// -/// +/// /// namespace ts.server.typingsInstaller { @@ -112,7 +112,7 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Closing file watchers for project '${projectName}'`); } - const watchers = this.projectWatchers[projectName]; + const watchers = this.projectWatchers.get(projectName); if (!watchers) { if (this.log.isEnabled()) { this.log.writeLine(`No watchers are registered for project '${projectName}'`); @@ -123,7 +123,7 @@ namespace ts.server.typingsInstaller { w.close(); } - delete this.projectWatchers[projectName]; + this.projectWatchers.delete(projectName); if (this.log.isEnabled()) { this.log.writeLine(`Closing file watchers for project '${projectName}' - done.`); @@ -177,7 +177,7 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Processing cache location '${cacheLocation}'`); } - if (this.knownCachesSet[cacheLocation]) { + if (this.knownCachesSet.get(cacheLocation)) { if (this.log.isEnabled()) { this.log.writeLine(`Cache location was already processed...`); } @@ -201,10 +201,10 @@ namespace ts.server.typingsInstaller { } const typingFile = typingToFileName(cacheLocation, packageName, this.installTypingHost, this.log); if (!typingFile) { - this.missingTypingsSet[packageName] = true; + this.missingTypingsSet.set(packageName, true); continue; } - const existingTypingFile = this.packageNameToTypingLocation[packageName]; + const existingTypingFile = this.packageNameToTypingLocation.get(packageName); if (existingTypingFile === typingFile) { continue; } @@ -216,14 +216,14 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Adding entry into typings cache: '${packageName}' => '${typingFile}'`); } - this.packageNameToTypingLocation[packageName] = typingFile; + this.packageNameToTypingLocation.set(packageName, typingFile); } } } if (this.log.isEnabled()) { this.log.writeLine(`Finished processing cache location '${cacheLocation}'`); } - this.knownCachesSet[cacheLocation] = true; + this.knownCachesSet.set(cacheLocation, true); } private filterTypings(typingsToInstall: string[]) { @@ -232,12 +232,12 @@ namespace ts.server.typingsInstaller { } const result: string[] = []; for (const typing of typingsToInstall) { - if (this.missingTypingsSet[typing] || this.packageNameToTypingLocation[typing]) { + if (this.missingTypingsSet.get(typing) || this.packageNameToTypingLocation.get(typing)) { continue; } const validationResult = validatePackageName(typing); if (validationResult === PackageNameValidationResult.Ok) { - if (typing in this.typesRegistry) { + if (this.typesRegistry.has(typing)) { result.push(typing); } else { @@ -248,7 +248,7 @@ namespace ts.server.typingsInstaller { } else { // add typing name to missing set so we won't process it again - this.missingTypingsSet[typing] = true; + this.missingTypingsSet.set(typing, true); if (this.log.isEnabled()) { switch (validationResult) { case PackageNameValidationResult.EmptyName: @@ -323,7 +323,7 @@ namespace ts.server.typingsInstaller { this.log.writeLine(`install request failed, marking packages as missing to prevent repeated requests: ${JSON.stringify(filteredTypings)}`); } for (const typing of filteredTypings) { - this.missingTypingsSet[typing] = true; + this.missingTypingsSet.set(typing, true); } return; } @@ -336,11 +336,11 @@ namespace ts.server.typingsInstaller { for (const packageName of filteredTypings) { const typingFile = typingToFileName(cachePath, packageName, this.installTypingHost, this.log); if (!typingFile) { - this.missingTypingsSet[packageName] = true; + this.missingTypingsSet.set(packageName, true); continue; } - if (!this.packageNameToTypingLocation[packageName]) { - this.packageNameToTypingLocation[packageName] = typingFile; + if (!this.packageNameToTypingLocation.has(packageName)) { + this.packageNameToTypingLocation.set(packageName, typingFile); } installedTypingFiles.push(typingFile); } @@ -395,7 +395,7 @@ namespace ts.server.typingsInstaller { }, /*pollingInterval*/ 2000); watchers.push(w); } - this.projectWatchers[projectName] = watchers; + this.projectWatchers.set(projectName, watchers); } private createSetTypings(request: DiscoverTypings, typings: string[]): SetTypings { diff --git a/src/server/utilities.ts b/src/server/utilities.ts index 641ca128e63..af1f8e9826f 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts.server { @@ -86,6 +86,7 @@ namespace ts.server { insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, insertSpaceBeforeFunctionParenthesis: false, @@ -94,7 +95,7 @@ namespace ts.server { }; } - export function mergeMaps(target: MapLike, source: MapLike ): void { + export function mergeMapLikes(target: MapLike, source: MapLike ): void { for (const key in source) { if (hasProperty(source, key)) { target[key] = source[key]; @@ -144,20 +145,20 @@ namespace ts.server { export function createNormalizedPathMap(): NormalizedPathMap { /* tslint:disable:no-null-keyword */ - const map: Map = Object.create(null); + const map = createMap(); /* tslint:enable:no-null-keyword */ return { get(path) { - return map[path]; + return map.get(path); }, set(path, value) { - map[path] = value; + map.set(path, value); }, contains(path) { - return hasProperty(map, path); + return map.has(path); }, remove(path) { - delete map[path]; + map.delete(path); } }; } @@ -197,16 +198,17 @@ namespace ts.server { } public schedule(operationId: string, delay: number, cb: () => void) { - if (hasProperty(this.pendingTimeouts, operationId)) { + const pendingTimeout = this.pendingTimeouts.get(operationId); + if (pendingTimeout) { // another operation was already scheduled for this id - cancel it - this.host.clearTimeout(this.pendingTimeouts[operationId]); + this.host.clearTimeout(pendingTimeout); } // schedule new operation, pass arguments - this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); + this.pendingTimeouts.set(operationId, this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb)); } private static run(self: ThrottledOperations, operationId: string, cb: () => void) { - delete self.pendingTimeouts[operationId]; + self.pendingTimeouts.delete(operationId); cb(); } } diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index 6825ccb6371..c751cf3871b 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -560,11 +560,11 @@ namespace ts.BreakpointResolver { function spanInOpenBraceToken(node: Node): TextSpan { switch (node.parent.kind) { case SyntaxKind.EnumDeclaration: - let enumDeclaration = node.parent; + const enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); case SyntaxKind.ClassDeclaration: - let classDeclaration = node.parent; + const classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); case SyntaxKind.CaseBlock: @@ -600,8 +600,8 @@ namespace ts.BreakpointResolver { case SyntaxKind.CaseBlock: // breakpoint in last statement of the last clause - let caseBlock = node.parent; - let lastClause = lastOrUndefined(caseBlock.clauses); + const caseBlock = node.parent; + const lastClause = lastOrUndefined(caseBlock.clauses); if (lastClause) { return spanInNode(lastOrUndefined(lastClause.statements)); } @@ -609,7 +609,7 @@ namespace ts.BreakpointResolver { case SyntaxKind.ObjectBindingPattern: // Breakpoint in last binding element or binding pattern if it contains no elements - let bindingPattern = node.parent; + const bindingPattern = node.parent; return spanInNode(lastOrUndefined(bindingPattern.elements) || bindingPattern); // Default to parent node @@ -627,7 +627,7 @@ namespace ts.BreakpointResolver { switch (node.parent.kind) { case SyntaxKind.ArrayBindingPattern: // Breakpoint in last binding element or binding pattern if it contains no elements - let bindingPattern = node.parent; + const bindingPattern = node.parent; return textSpan(lastOrUndefined(bindingPattern.elements) || bindingPattern); default: diff --git a/src/services/classifier.ts b/src/services/classifier.ts index c22aec6a786..c15b65b0c39 100644 --- a/src/services/classifier.ts +++ b/src/services/classifier.ts @@ -71,7 +71,7 @@ namespace ts { const dense = classifications.spans; let lastEnd = 0; - for (let i = 0, n = dense.length; i < n; i += 3) { + for (let i = 0; i < dense.length; i += 3) { const start = dense[i]; const length = dense[i + 1]; const type = dense[i + 2]; @@ -557,7 +557,7 @@ namespace ts { // 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]) { + if (classifiableNames.get(identifier.text)) { const symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { const type = classifySymbol(symbol, getMeaningFromLocation(node)); @@ -605,7 +605,7 @@ namespace ts { Debug.assert(classifications.spans.length % 3 === 0); const dense = classifications.spans; const result: ClassifiedSpan[] = []; - for (let i = 0, n = dense.length; i < n; i += 3) { + for (let i = 0; i < dense.length; i += 3) { result.push({ textSpan: createTextSpan(dense[i], dense[i + 1]), classificationType: getClassificationTypeName(dense[i + 2]) @@ -972,9 +972,7 @@ namespace ts { if (decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { checkForClassificationCancellation(cancellationToken, element.kind); - const children = element.getChildren(sourceFile); - for (let i = 0, n = children.length; i < n; i++) { - const child = children[i]; + for (const child of element.getChildren(sourceFile)) { if (!tryClassifyNode(child)) { // Recurse into our child nodes. processElement(child); diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codeFixProvider.ts similarity index 93% rename from src/services/codefixes/codeFixProvider.ts rename to src/services/codeFixProvider.ts index e4489fc2dca..10d0b8eef34 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codeFixProvider.ts @@ -16,7 +16,7 @@ namespace ts { } export namespace codefix { - const codeFixes = createMap(); + const codeFixes: CodeFix[][] = []; export function registerCodeFix(action: CodeFix) { forEach(action.errorCodes, error => { diff --git a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts new file mode 100644 index 00000000000..22546e55ecc --- /dev/null +++ b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts @@ -0,0 +1,59 @@ +/* @internal */ +namespace ts.codefix { + registerCodeFix({ + errorCodes: [Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + + registerCodeFix({ + errorCodes: [Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + + function getActionForClassLikeMissingAbstractMember(context: CodeFixContext): CodeAction[] | undefined { + const sourceFile = context.sourceFile; + const start = context.span.start; + // This is the identifier in the case of a class declaration + // or the class keyword token in the case of a class expression. + const token = getTokenAtPosition(sourceFile, start); + const checker = context.program.getTypeChecker(); + + if (isClassLike(token.parent)) { + const classDecl = token.parent as ClassLikeDeclaration; + const startPos = classDecl.members.pos; + + const classType = checker.getTypeAtLocation(classDecl) as InterfaceType; + const instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + + // Note that this is ultimately derived from a map indexed by symbol names, + // so duplicates cannot occur. + const extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); + const abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); + + const insertion = getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); + + if (insertion.length) { + return [{ + description: getLocaleSpecificMessage(Diagnostics.Implement_inherited_abstract_class), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }]; + } + } + + return undefined; + + } + + function symbolPointsToNonPrivateAndAbstractMember(symbol: Symbol): boolean { + const decls = symbol.getDeclarations(); + Debug.assert(!!(decls && decls.length > 0)); + const flags = getModifierFlags(decls[0]); + return !(flags & ModifierFlags.Private) && !!(flags & ModifierFlags.Abstract); + } +} \ No newline at end of file diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts new file mode 100644 index 00000000000..42488dc2aed --- /dev/null +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -0,0 +1,75 @@ +/* @internal */ +namespace ts.codefix { + registerCodeFix({ + errorCodes: [Diagnostics.Class_0_incorrectly_implements_interface_1.code], + getCodeActions: getActionForClassLikeIncorrectImplementsInterface + }); + + function getActionForClassLikeIncorrectImplementsInterface(context: CodeFixContext): CodeAction[] | undefined { + const sourceFile = context.sourceFile; + const start = context.span.start; + const token = getTokenAtPosition(sourceFile, start); + const checker = context.program.getTypeChecker(); + + const classDecl = getContainingClass(token); + if (!classDecl) { + return undefined; + } + + const startPos: number = classDecl.members.pos; + const classType = checker.getTypeAtLocation(classDecl); + const implementedTypeNodes = getClassImplementsHeritageClauseElements(classDecl); + + const hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, IndexKind.Number); + const hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, IndexKind.String); + + const result: CodeAction[] = []; + for (const implementedTypeNode of implementedTypeNodes) { + const implementedType = checker.getTypeFromTypeNode(implementedTypeNode) as InterfaceType; + // Note that this is ultimately derived from a map indexed by symbol names, + // so duplicates cannot occur. + const implementedTypeSymbols = checker.getPropertiesOfType(implementedType); + const nonPrivateMembers = implementedTypeSymbols.filter(symbol => !(getModifierFlags(symbol.valueDeclaration) & ModifierFlags.Private)); + + let insertion = getMissingIndexSignatureInsertion(implementedType, IndexKind.Number, classDecl, hasNumericIndexSignature); + insertion += getMissingIndexSignatureInsertion(implementedType, IndexKind.String, classDecl, hasStringIndexSignature); + insertion += getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); + + const message = formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); + if (insertion) { + pushAction(result, insertion, message); + } + } + + return result; + + function getMissingIndexSignatureInsertion(type: InterfaceType, kind: IndexKind, enclosingDeclaration: ClassLikeDeclaration, hasIndexSigOfKind: boolean) { + if (!hasIndexSigOfKind) { + const IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); + if (IndexInfoOfKind) { + const writer = getSingleLineStringWriter(); + checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); + const result = writer.string(); + releaseStringWriter(writer); + + return result; + } + } + return ""; + } + + function pushAction(result: CodeAction[], insertion: string, description: string): void { + const newAction: CodeAction = { + description: description, + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }; + result.push(newAction); + } + } +} \ No newline at end of file diff --git a/src/services/codefixes/superFixes.ts b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts similarity index 68% rename from src/services/codefixes/superFixes.ts rename to src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts index f117799f3e1..4528c48774d 100644 --- a/src/services/codefixes/superFixes.ts +++ b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts @@ -1,28 +1,5 @@ /* @internal */ namespace ts.codefix { - function getOpenBraceEnd(constructor: ConstructorDeclaration, sourceFile: SourceFile) { - // First token is the open curly, this is where we want to put the 'super' call. - return constructor.body.getFirstToken(sourceFile).getEnd(); - } - - registerCodeFix({ - errorCodes: [Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], - getCodeActions: (context: CodeFixContext) => { - const sourceFile = context.sourceFile; - const token = getTokenAtPosition(sourceFile, context.span.start); - - if (token.kind !== SyntaxKind.ConstructorKeyword) { - return undefined; - } - - const newPosition = getOpenBraceEnd(token.parent, sourceFile); - return [{ - description: getLocaleSpecificMessage(Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] - }]; - } - }); - registerCodeFix({ errorCodes: [Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], getCodeActions: (context: CodeFixContext) => { diff --git a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts new file mode 100644 index 00000000000..0dede87cf28 --- /dev/null +++ b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts @@ -0,0 +1,20 @@ +/* @internal */ +namespace ts.codefix { + registerCodeFix({ + errorCodes: [Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], + getCodeActions: (context: CodeFixContext) => { + const sourceFile = context.sourceFile; + const token = getTokenAtPosition(sourceFile, context.span.start); + + if (token.kind !== SyntaxKind.ConstructorKeyword) { + return undefined; + } + + const newPosition = getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: getLocaleSpecificMessage(Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); +} \ No newline at end of file diff --git a/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts new file mode 100644 index 00000000000..1e72700ec01 --- /dev/null +++ b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts @@ -0,0 +1,49 @@ +/* @internal */ +namespace ts.codefix { + registerCodeFix({ + errorCodes: [Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code], + getCodeActions: (context: CodeFixContext) => { + const sourceFile = context.sourceFile; + const start = context.span.start; + const token = getTokenAtPosition(sourceFile, start); + const classDeclNode = getContainingClass(token); + if (!(token.kind === SyntaxKind.Identifier && isClassLike(classDeclNode))) { + return undefined; + } + + const heritageClauses = classDeclNode.heritageClauses; + if (!(heritageClauses && heritageClauses.length > 0)) { + return undefined; + } + + const extendsToken = heritageClauses[0].getFirstToken(); + if (!(extendsToken && extendsToken.kind === SyntaxKind.ExtendsKeyword)) { + return undefined; + } + + let changeStart = extendsToken.getStart(sourceFile); + let changeEnd = extendsToken.getEnd(); + const textChanges: TextChange[] = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + + // We replace existing keywords with commas. + for (let i = 1; i < heritageClauses.length; i++) { + const keywordToken = heritageClauses[i].getFirstToken(); + if (keywordToken) { + changeStart = keywordToken.getStart(sourceFile); + changeEnd = keywordToken.getEnd(); + textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + } + } + + const result = [{ + description: getLocaleSpecificMessage(Diagnostics.Change_extends_to_implements), + changes: [{ + fileName: sourceFile.fileName, + textChanges: textChanges + }] + }]; + + return result; + } + }); +} diff --git a/src/services/codefixes/fixes.ts b/src/services/codefixes/fixes.ts index a38b196cb00..10d6fa50158 100644 --- a/src/services/codefixes/fixes.ts +++ b/src/services/codefixes/fixes.ts @@ -1,3 +1,9 @@ -/// -/// -/// +/// +/// +/// +/// +/// +/// +/// +/// + diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts new file mode 100644 index 00000000000..7bee4f5a0ed --- /dev/null +++ b/src/services/codefixes/helpers.ts @@ -0,0 +1,156 @@ +/* @internal */ +namespace ts.codefix { + + /** + * Finds members of the resolved type that are missing in the class pointed to by class decl + * and generates source code for the missing members. + * @param possiblyMissingSymbols The collection of symbols to filter and then get insertions for. + * @returns Empty string iff there are no member insertions. + */ + export function getMissingMembersInsertion(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: Symbol[], checker: TypeChecker, newlineChar: string): string { + const classMembers = classDeclaration.symbol.members; + const missingMembers = possiblyMissingSymbols.filter(symbol => !classMembers.has(symbol.getName())); + + let insertion = ""; + + for (const symbol of missingMembers) { + insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + } + return insertion; + } + + /** + * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. + */ + function getInsertionForMemberSymbol(symbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker, newlineChar: string): string { + // const name = symbol.getName(); + const type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + const declarations = symbol.getDeclarations(); + if (!(declarations && declarations.length)) { + return ""; + } + + const declaration = declarations[0] as Declaration; + const name = declaration.name ? declaration.name.getText() : undefined; + const visibility = getVisibilityPrefix(getModifierFlags(declaration)); + + switch (declaration.kind) { + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.PropertySignature: + case SyntaxKind.PropertyDeclaration: + const typeString = checker.typeToString(type, enclosingDeclaration, TypeFormatFlags.None); + return `${visibility}${name}: ${typeString};${newlineChar}`; + + case SyntaxKind.MethodSignature: + case SyntaxKind.MethodDeclaration: + // The signature for the implementation appears as an entry in `signatures` iff + // there is only one signature. + // If there are overloads and an implementation signature, it appears as an + // extra declaration that isn't a signature for `type`. + // If there is more than one overload but no implementation signature + // (eg: an abstract method or interface declaration), there is a 1-1 + // correspondence of declarations and signatures. + const signatures = checker.getSignaturesOfType(type, SignatureKind.Call); + if (!(signatures && signatures.length > 0)) { + return ""; + } + if (declarations.length === 1) { + Debug.assert(signatures.length === 1); + const sigString = checker.signatureToString(signatures[0], enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); + return `${visibility}${name}${sigString}${getMethodBodyStub(newlineChar)}`; + } + + let result = ""; + for (let i = 0; i < signatures.length; i++) { + const sigString = checker.signatureToString(signatures[i], enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); + result += `${visibility}${name}${sigString};${newlineChar}`; + } + + // If there is a declaration with a body, it is the last declaration, + // and it isn't caught by `getSignaturesOfType`. + let bodySig: Signature | undefined = undefined; + if (declarations.length > signatures.length) { + bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration); + } + else { + Debug.assert(declarations.length === signatures.length); + bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); + } + const sigString = checker.signatureToString(bodySig, enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); + result += `${visibility}${name}${sigString}${getMethodBodyStub(newlineChar)}`; + + return result; + default: + return ""; + } + } + + function createBodySignatureWithAnyTypes(signatures: Signature[], enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker): Signature { + const newSignatureDeclaration = createNode(SyntaxKind.CallSignature) as SignatureDeclaration; + newSignatureDeclaration.parent = enclosingDeclaration; + newSignatureDeclaration.name = signatures[0].getDeclaration().name; + + let maxNonRestArgs = -1; + let maxArgsIndex = 0; + let minArgumentCount = signatures[0].minArgumentCount; + let hasRestParameter = false; + for (let i = 0; i < signatures.length; i++) { + const sig = signatures[i]; + minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); + hasRestParameter = hasRestParameter || sig.hasRestParameter; + const nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); + if (nonRestLength > maxNonRestArgs) { + maxNonRestArgs = nonRestLength; + maxArgsIndex = i; + } + } + const maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(symbol => symbol.getName()); + + const optionalToken = createToken(SyntaxKind.QuestionToken); + + newSignatureDeclaration.parameters = createNodeArray(); + for (let i = 0; i < maxNonRestArgs; i++) { + const newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); + newSignatureDeclaration.parameters.push(newParameter); + } + + if (hasRestParameter) { + const restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); + restParameter.dotDotDotToken = createToken(SyntaxKind.DotDotDotToken); + newSignatureDeclaration.parameters.push(restParameter); + } + + return checker.getSignatureFromDeclaration(newSignatureDeclaration); + + function createParameterDeclarationWithoutType(index: number, minArgCount: number, enclosingSignatureDeclaration: SignatureDeclaration): ParameterDeclaration { + const newParameter = createNode(SyntaxKind.Parameter) as ParameterDeclaration; + + newParameter.symbol = new SymbolConstructor(SymbolFlags.FunctionScopedVariable, maxArgsParameterSymbolNames[index] || "rest"); + newParameter.symbol.valueDeclaration = newParameter; + newParameter.symbol.declarations = [newParameter]; + newParameter.parent = enclosingSignatureDeclaration; + if (index >= minArgCount) { + newParameter.questionToken = optionalToken; + } + + return newParameter; + } + } + + function getMethodBodyStub(newLineChar: string) { + return ` {${newLineChar}throw new Error('Method not implemented.');${newLineChar}}${newLineChar}`; + } + + function getVisibilityPrefix(flags: ModifierFlags): string { + if (flags & ModifierFlags.Public) { + return "public "; + } + else if (flags & ModifierFlags.Protected) { + return "protected "; + } + return ""; + } + + const SymbolConstructor = objectAllocator.getSymbolConstructor(); +} \ No newline at end of file diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index bda310f2d33..49b8526a1e0 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -14,20 +14,21 @@ namespace ts.codefix { } class ImportCodeActionMap { - private symbolIdToActionMap = createMap(); + private symbolIdToActionMap: ImportCodeAction[][] = []; addAction(symbolId: number, newAction: ImportCodeAction) { if (!newAction) { return; } - if (!this.symbolIdToActionMap[symbolId]) { + const actions = this.symbolIdToActionMap[symbolId]; + if (!actions) { this.symbolIdToActionMap[symbolId] = [newAction]; return; } if (newAction.kind === "CodeChange") { - this.symbolIdToActionMap[symbolId].push(newAction); + actions.push(newAction); return; } @@ -73,8 +74,8 @@ namespace ts.codefix { getAllActions() { let result: ImportCodeAction[] = []; - for (const symbolId in this.symbolIdToActionMap) { - result = concatenate(result, this.symbolIdToActionMap[symbolId]); + for (const key in this.symbolIdToActionMap) { + result = concatenate(result, this.symbolIdToActionMap[key]) } return result; } @@ -112,7 +113,10 @@ namespace ts.codefix { } registerCodeFix({ - errorCodes: [Diagnostics.Cannot_find_name_0.code], + errorCodes: [ + Diagnostics.Cannot_find_name_0.code, + Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ], getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; const checker = context.program.getTypeChecker(); @@ -124,9 +128,15 @@ namespace ts.codefix { const symbolIdActionMap = new ImportCodeActionMap(); // this is a module id -> module import declaration map - const cachedImportDeclarations = createMap<(ImportDeclaration | ImportEqualsDeclaration)[]>(); + const cachedImportDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[][] = []; let cachedNewImportInsertPosition: number; + const currentTokenMeaning = getMeaningFromLocation(token); + if (context.errorCode === Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { + const symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); + return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true); + } + const allPotentialModules = checker.getAmbientModules(); for (const otherSourceFile of allSourceFiles) { if (otherSourceFile !== sourceFile && isExternalOrCommonJsModule(otherSourceFile)) { @@ -134,7 +144,6 @@ namespace ts.codefix { } } - const currentTokenMeaning = getMeaningFromLocation(token); for (const moduleSymbol of allPotentialModules) { context.cancellationToken.throwIfCancellationRequested(); @@ -162,8 +171,9 @@ namespace ts.codefix { function getImportDeclarations(moduleSymbol: Symbol) { const moduleSymbolId = getUniqueSymbolId(moduleSymbol); - if (cachedImportDeclarations[moduleSymbolId]) { - return cachedImportDeclarations[moduleSymbolId]; + const cached = cachedImportDeclarations[moduleSymbolId]; + if (cached) { + return cached; } const existingDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[] = []; @@ -203,7 +213,7 @@ namespace ts.codefix { return declarations ? some(symbol.declarations, decl => !!(getMeaningFromDeclaration(decl) & meaning)) : false; } - function getCodeActionForImport(moduleSymbol: Symbol, isDefault?: boolean): ImportCodeAction[] { + function getCodeActionForImport(moduleSymbol: Symbol, isDefault?: boolean, isNamespaceImport?: boolean): ImportCodeAction[] { const existingDeclarations = getImportDeclarations(moduleSymbol); if (existingDeclarations.length > 0) { // With an existing import statement, there are more than one actions the user can do. @@ -213,8 +223,6 @@ namespace ts.codefix { return [getCodeActionForNewImport()]; } - - function getCodeActionsForExistingImport(declarations: (ImportDeclaration | ImportEqualsDeclaration)[]): ImportCodeAction[] { const actions: ImportCodeAction[] = []; @@ -262,7 +270,7 @@ namespace ts.codefix { actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); } - if (namedImportDeclaration && namedImportDeclaration.importClause && + if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause && (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { /** * If the existing import declaration already has a named import list, just @@ -386,7 +394,9 @@ namespace ts.codefix { const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); const importStatementText = isDefault ? `import ${name} from "${moduleSpecifierWithoutQuotes}"` - : `import { ${name} } from "${moduleSpecifierWithoutQuotes}"`; + : isNamespaceImport + ? `import * as ${name} from "${moduleSpecifierWithoutQuotes}"` + : `import { ${name} } from "${moduleSpecifierWithoutQuotes}"`; // if this file doesn't have any import statements, insert an import statement and then insert a new line // between the only import statement and user code. Otherwise just insert the statement because chances @@ -412,10 +422,10 @@ namespace ts.codefix { const options = context.program.getCompilerOptions(); return tryGetModuleNameFromAmbientModule() || - tryGetModuleNameFromBaseUrl() || - tryGetModuleNameFromRootDirs() || tryGetModuleNameFromTypeRoots() || tryGetModuleNameAsNodeModule() || + tryGetModuleNameFromBaseUrl() || + tryGetModuleNameFromRootDirs() || removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule(): string { @@ -435,6 +445,7 @@ namespace ts.codefix { return undefined; } + const relativeNameWithIndex = removeFileExtension(relativeName); relativeName = removeExtensionAndIndexPostFix(relativeName); if (options.paths) { @@ -454,7 +465,7 @@ namespace ts.codefix { return key.replace("\*", matchedStar); } } - else if (pattern === relativeName) { + else if (pattern === relativeName || pattern === relativeNameWithIndex) { return key; } } diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index 8e14bdcb73e..2784a09a504 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -146,7 +146,7 @@ namespace ts.codefix { function createCodeFix(newText: string, start: number, length: number): CodeAction[] { return [{ - description: getLocaleSpecificMessage(Diagnostics.Remove_unused_identifiers), + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText, span: { start, length } }] diff --git a/src/services/completions.ts b/src/services/completions.ts index b710aa8cd78..d6d3a9ce060 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1,14 +1,14 @@ -/// - /* @internal */ namespace ts.Completions { - export function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo { + type Log = (message: string) => void; + + export function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: Log, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo | undefined { if (isInReferenceComment(sourceFile, position)) { - return getTripleSlashReferenceCompletion(sourceFile, position); + return getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); } if (isInString(sourceFile, position)) { - return getStringLiteralCompletionEntries(sourceFile, position); + return getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log); } const completionData = getCompletionData(typeChecker, log, sourceFile, position); @@ -26,8 +26,8 @@ namespace ts.Completions { const entries: CompletionEntry[] = []; if (isSourceFileJavaScript(sourceFile)) { - const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true); - addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); + const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); + addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target)); } else { if (!symbols || symbols.length === 0) { @@ -50,7 +50,7 @@ namespace ts.Completions { } } - getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true); + getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); } // Add keywords if this is not a member completion list @@ -59,691 +59,690 @@ namespace ts.Completions { } return { isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries }; + } - function getJavaScriptCompletionEntries(sourceFile: SourceFile, position: number, uniqueNames: Map): CompletionEntry[] { - const entries: CompletionEntry[] = []; + function getJavaScriptCompletionEntries(sourceFile: SourceFile, position: number, uniqueNames: Map, target: ScriptTarget): CompletionEntry[] { + const entries: CompletionEntry[] = []; - const nameTable = getNameTable(sourceFile); - for (const name in nameTable) { - // Skip identifiers produced only from the current location - if (nameTable[name] === position) { - continue; + const nameTable = getNameTable(sourceFile); + nameTable.forEach((pos, name) => { + // Skip identifiers produced only from the current location + if (pos === position) { + return; + } + + if (!uniqueNames.get(name)) { + uniqueNames.set(name, name); + const displayName = getCompletionEntryDisplayName(unescapeIdentifier(name), target, /*performCharacterChecks*/ true); + if (displayName) { + const entry = { + name: displayName, + kind: ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } + } + }); - if (!uniqueNames[name]) { - uniqueNames[name] = name; - const displayName = getCompletionEntryDisplayName(unescapeIdentifier(name), compilerOptions.target, /*performCharacterChecks*/ true); - if (displayName) { - const entry = { - name: displayName, - kind: ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; + return entries; + } + + function createCompletionEntry(symbol: Symbol, location: Node, performCharacterChecks: boolean, typeChecker: TypeChecker, target: ScriptTarget): CompletionEntry { + // Try to get a valid display name for this symbol, if we could not find one, then ignore it. + // We would like to only show things that can be added after a dot, so for instance numeric properties can + // not be accessed with a dot (a.1 <- invalid) + const displayName = getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, target, performCharacterChecks, location); + if (!displayName) { + return undefined; + } + + // TODO(drosen): Right now we just permit *all* semantic meanings when calling + // 'getSymbolKind' which is permissible given that it is backwards compatible; but + // really we should consider passing the meaning for the node so that we don't report + // that a suggestion for a value is an interface. We COULD also just do what + // 'getSymbolModifiers' does, which is to use the first declaration. + + // Use a 'sortText' of 0' so that all symbol completion entries come before any other + // entries (like JavaScript identifier entries). + return { + name: displayName, + kind: SymbolDisplay.getSymbolKind(typeChecker, symbol, location), + kindModifiers: SymbolDisplay.getSymbolModifiers(symbol), + sortText: "0", + }; + } + + function getCompletionEntriesFromSymbols(symbols: Symbol[], entries: Push, location: Node, performCharacterChecks: boolean, typeChecker: TypeChecker, target: ScriptTarget, log: Log): Map { + const start = timestamp(); + const uniqueNames = createMap(); + if (symbols) { + for (const symbol of symbols) { + const entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target); + if (entry) { + const id = escapeIdentifier(entry.name); + if (!uniqueNames.get(id)) { entries.push(entry); + uniqueNames.set(id, id); } } } - - return entries; } - function createCompletionEntry(symbol: Symbol, location: Node, performCharacterChecks: boolean): CompletionEntry { - // Try to get a valid display name for this symbol, if we could not find one, then ignore it. - // We would like to only show things that can be added after a dot, so for instance numeric properties can - // not be accessed with a dot (a.1 <- invalid) - const displayName = getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, compilerOptions.target, performCharacterChecks, location); - if (!displayName) { - return undefined; + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (timestamp() - start)); + return uniqueNames; + } + + function getStringLiteralCompletionEntries(sourceFile: SourceFile, position: number, typeChecker: TypeChecker, compilerOptions: CompilerOptions, host: LanguageServiceHost, log: Log): CompletionInfo | undefined { + const node = findPrecedingToken(position, sourceFile); + if (!node || node.kind !== SyntaxKind.StringLiteral) { + return undefined; + } + + if (node.parent.kind === SyntaxKind.PropertyAssignment && + node.parent.parent.kind === SyntaxKind.ObjectLiteralExpression && + (node.parent).name === node) { + // Get quoted name of properties of the object literal expression + // i.e. interface ConfigFiles { + // 'jspm:dev': string + // } + // let files: ConfigFiles = { + // '/*completion position*/' + // } + // + // function foo(c: ConfigFiles) {} + // foo({ + // '/*completion position*/' + // }); + return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent, typeChecker, compilerOptions.target, log); + } + else if (isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { + // Get all names of properties on the expression + // i.e. interface A { + // 'prop1': string + // } + // let a: A; + // a['/*completion position*/'] + return getStringLiteralCompletionEntriesFromElementAccess(node.parent, typeChecker, compilerOptions.target, log); + } + else if (node.parent.kind === SyntaxKind.ImportDeclaration || isExpressionOfExternalModuleImportEqualsDeclaration(node) || isRequireCall(node.parent, false)) { + // Get all known external module names or complete a path to a module + // i.e. import * as ns from "/*completion position*/"; + // import x = require("/*completion position*/"); + // var y = require("/*completion position*/"); + return getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker); + } + else { + const argumentInfo = SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile); + if (argumentInfo) { + // Get string literal completions from specialized signatures of the target + // i.e. declare function f(a: 'A'); + // f("/*completion position*/") + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker); } - // TODO(drosen): Right now we just permit *all* semantic meanings when calling - // 'getSymbolKind' which is permissible given that it is backwards compatible; but - // really we should consider passing the meaning for the node so that we don't report - // that a suggestion for a value is an interface. We COULD also just do what - // 'getSymbolModifiers' does, which is to use the first declaration. + // Get completion for string literal from string literal type + // i.e. var x: "hi" | "hello" = "/*completion position*/" + return getStringLiteralCompletionEntriesFromContextualType(node, typeChecker); + } + } - // Use a 'sortText' of 0' so that all symbol completion entries come before any other - // entries (like JavaScript identifier entries). - return { - name: displayName, - kind: SymbolDisplay.getSymbolKind(typeChecker, symbol, location), - kindModifiers: SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0", - }; + function getStringLiteralCompletionEntriesFromPropertyAssignment(element: ObjectLiteralElement, typeChecker: TypeChecker, target: ScriptTarget, log: Log): CompletionInfo | undefined { + const type = typeChecker.getContextualType((element.parent)); + const entries: CompletionEntry[] = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries }; + } + } + } + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo, typeChecker: TypeChecker): CompletionInfo | undefined { + const candidates: Signature[] = []; + const entries: CompletionEntry[] = []; + + typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); + + for (const candidate of candidates) { + addStringLiteralCompletionsFromType(typeChecker.getParameterType(candidate, argumentInfo.argumentIndex), entries, typeChecker); } - function getCompletionEntriesFromSymbols(symbols: Symbol[], entries: CompletionEntry[], location: Node, performCharacterChecks: boolean): Map { - const start = timestamp(); - const uniqueNames = createMap(); - if (symbols) { - for (const symbol of symbols) { - const entry = createCompletionEntry(symbol, location, performCharacterChecks); - if (entry) { - const id = escapeIdentifier(entry.name); - if (!uniqueNames[id]) { - entries.push(entry); - uniqueNames[id] = id; + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries }; + } + + return undefined; + } + + function getStringLiteralCompletionEntriesFromElementAccess(node: ElementAccessExpression, typeChecker: TypeChecker, target: ScriptTarget, log: Log): CompletionInfo | undefined { + const type = typeChecker.getTypeAtLocation(node.expression); + const entries: CompletionEntry[] = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries }; + } + } + return undefined; + } + + function getStringLiteralCompletionEntriesFromContextualType(node: StringLiteral, typeChecker: TypeChecker): CompletionInfo | undefined { + const type = typeChecker.getContextualType(node); + if (type) { + const entries: CompletionEntry[] = []; + addStringLiteralCompletionsFromType(type, entries, typeChecker); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries }; + } + } + return undefined; + } + + function addStringLiteralCompletionsFromType(type: Type, result: Push, typeChecker: TypeChecker): void { + if (type && type.flags & TypeFlags.TypeParameter) { + type = typeChecker.getApparentType(type); + } + if (!type) { + return; + } + if (type.flags & TypeFlags.Union) { + for (const t of (type).types) { + addStringLiteralCompletionsFromType(t, result, typeChecker); + } + } + else if (type.flags & TypeFlags.StringLiteral) { + result.push({ + name: (type).text, + kindModifiers: ScriptElementKindModifier.none, + kind: ScriptElementKind.variableElement, + sortText: "0" + }); + } + } + + function getStringLiteralCompletionEntriesFromModuleNames(node: StringLiteral, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker): CompletionInfo { + const literalValue = normalizeSlashes(node.text); + + const scriptPath = node.getSourceFile().path; + const scriptDirectory = getDirectoryPath(scriptPath); + + const span = getDirectoryFragmentTextSpan((node).text, node.getStart() + 1); + let entries: CompletionEntry[]; + if (isPathRelativeToScript(literalValue) || isRootedDiskPath(literalValue)) { + const extensions = getSupportedExtensions(compilerOptions); + if (compilerOptions.rootDirs) { + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs( + compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, /*includeExtensions*/false, span, compilerOptions, host, scriptPath); + } + else { + entries = getCompletionEntriesForDirectoryFragment( + literalValue, scriptDirectory, extensions, /*includeExtensions*/false, span, host, scriptPath); + } + } + else { + // Check for node modules + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); + } + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries + }; + } + + /** + * Takes a script path and returns paths for all potential folders that could be merged with its + * containing folder via the "rootDirs" compiler option + */ + function getBaseDirectoriesFromRootDirs(rootDirs: string[], basePath: string, scriptPath: string, ignoreCase: boolean): string[] { + // Make all paths absolute/normalized if they are not already + rootDirs = map(rootDirs, rootDirectory => normalizePath(isRootedDiskPath(rootDirectory) ? rootDirectory : combinePaths(basePath, rootDirectory))); + + // Determine the path to the directory containing the script relative to the root directory it is contained within + let relativeDirectory: string; + for (const rootDirectory of rootDirs) { + if (containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { + relativeDirectory = scriptPath.substr(rootDirectory.length); + break; + } + } + + // Now find a path for each potential directory that is to be merged with the one containing the script + return deduplicate(map(rootDirs, rootDirectory => combinePaths(rootDirectory, relativeDirectory))); + } + + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, compilerOptions: CompilerOptions, host: LanguageServiceHost, exclude?: string): CompletionEntry[] { + const basePath = compilerOptions.project || host.getCurrentDirectory(); + const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); + + const result: CompletionEntry[] = []; + + for (const baseDirectory of baseDirectories) { + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); + } + + return result; + } + + /** + * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. + */ + function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, host: LanguageServiceHost, exclude?: string, result: CompletionEntry[] = []): CompletionEntry[] { + if (fragment === undefined) { + fragment = ""; + } + + fragment = normalizeSlashes(fragment); + + /** + * Remove the basename from the path. Note that we don't use the basename to filter completions; + * the client is responsible for refining completions. + */ + fragment = getDirectoryPath(fragment); + + if (fragment === "") { + fragment = "." + directorySeparator; + } + + fragment = ensureTrailingDirectorySeparator(fragment); + + const absolutePath = normalizeAndPreserveTrailingSlash(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment)); + const baseDirectory = getDirectoryPath(absolutePath); + const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + + if (tryDirectoryExists(host, baseDirectory)) { + // Enumerate the available files if possible + const files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]); + + if (files) { + /** + * Multiple file entries might map to the same truncated name once we remove extensions + * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: + * + * both foo.ts and foo.tsx become foo + */ + const foundFiles = createMap(); + for (let filePath of files) { + filePath = normalizePath(filePath); + if (exclude && comparePaths(filePath, exclude, scriptPath, ignoreCase) === Comparison.EqualTo) { + continue; + } + + const foundFileName = includeExtensions ? getBaseFileName(filePath) : removeFileExtension(getBaseFileName(filePath)); + + if (!foundFiles.get(foundFileName)) { + foundFiles.set(foundFileName, true); + } + } + + forEachKey(foundFiles, foundFile => { + result.push(createCompletionEntryForModule(foundFile, ScriptElementKind.scriptElement, span)); + }); + } + + // If possible, get folder completion as well + const directories = tryGetDirectories(host, baseDirectory); + + if (directories) { + for (const directory of directories) { + const directoryName = getBaseFileName(normalizePath(directory)); + + result.push(createCompletionEntryForModule(directoryName, ScriptElementKind.directory, span)); + } + } + } + + return result; + } + + /** + * Check all of the declared modules and those in node modules. Possible sources of modules: + * Modules that are found by the type checker + * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) + * Modules from node_modules (i.e. those listed in package.json) + * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions + */ + function getCompletionEntriesForNonRelativeModules(fragment: string, scriptPath: string, span: TextSpan, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker): CompletionEntry[] { + const { baseUrl, paths } = compilerOptions; + + let result: CompletionEntry[]; + + if (baseUrl) { + const fileExtensions = getSupportedExtensions(compilerOptions); + const projectDir = compilerOptions.project || host.getCurrentDirectory(); + const absolute = isRootedDiskPath(baseUrl) ? baseUrl : combinePaths(projectDir, baseUrl); + result = getCompletionEntriesForDirectoryFragment(fragment, normalizePath(absolute), fileExtensions, /*includeExtensions*/false, span, host); + + if (paths) { + for (const path in paths) { + if (paths.hasOwnProperty(path)) { + if (path === "*") { + if (paths[path]) { + for (const pattern of paths[path]) { + for (const match of getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host)) { + result.push(createCompletionEntryForModule(match, ScriptElementKind.externalModuleName, span)); + } + } + } + } + else if (startsWith(path, fragment)) { + const entry = paths[path] && paths[path].length === 1 && paths[path][0]; + if (entry) { + result.push(createCompletionEntryForModule(path, ScriptElementKind.externalModuleName, span)); + } } } } } - - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (timestamp() - start)); - return uniqueNames; + } + else { + result = []; } - function getStringLiteralCompletionEntries(sourceFile: SourceFile, position: number) { - const node = findPrecedingToken(position, sourceFile); - if (!node || node.kind !== SyntaxKind.StringLiteral) { - return undefined; - } + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); - if (node.parent.kind === SyntaxKind.PropertyAssignment && - node.parent.parent.kind === SyntaxKind.ObjectLiteralExpression && - (node.parent).name === node) { - // Get quoted name of properties of the object literal expression - // i.e. interface ConfigFiles { - // 'jspm:dev': string - // } - // let files: ConfigFiles = { - // '/*completion position*/' - // } - // - // function foo(c: ConfigFiles) {} - // foo({ - // '/*completion position*/' - // }); - return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); + for (const moduleName of enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host)) { + result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); + } + + return result; + } + + function getModulesForPathsPattern(fragment: string, baseUrl: string, pattern: string, fileExtensions: string[], host: LanguageServiceHost): string[] { + if (host.readDirectory) { + const parsed = hasZeroOrOneAsteriskCharacter(pattern) ? tryParsePattern(pattern) : undefined; + if (parsed) { + // The prefix has two effective parts: the directory path and the base component after the filepath that is not a + // full directory component. For example: directory/path/of/prefix/base* + const normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); + const normalizedPrefixDirectory = getDirectoryPath(normalizedPrefix); + const normalizedPrefixBase = getBaseFileName(normalizedPrefix); + + const fragmentHasPath = fragment.indexOf(directorySeparator) !== -1; + + // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call + const expandedPrefixDirectory = fragmentHasPath ? combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + getDirectoryPath(fragment)) : normalizedPrefixDirectory; + + const normalizedSuffix = normalizePath(parsed.suffix); + const baseDirectory = combinePaths(baseUrl, expandedPrefixDirectory); + const completePrefix = fragmentHasPath ? baseDirectory : ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + + // If we have a suffix, then we need to read the directory all the way down. We could create a glob + // that encodes the suffix, but we would have to escape the character "?" which readDirectory + // doesn't support. For now, this is safer but slower + const includeGlob = normalizedSuffix ? "**/*" : "./*"; + + const matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); + if (matches) { + const result: string[] = []; + + // Trim away prefix and suffix + for (const match of matches) { + const normalizedMatch = normalizePath(match); + if (!endsWith(normalizedMatch, normalizedSuffix) || !startsWith(normalizedMatch, completePrefix)) { + continue; + } + + const start = completePrefix.length; + const length = normalizedMatch.length - start - normalizedSuffix.length; + + result.push(removeFileExtension(normalizedMatch.substr(start, length))); + } + return result; + } } - else if (isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { - // Get all names of properties on the expression - // i.e. interface A { - // 'prop1': string - // } - // let a: A; - // a['/*completion position*/'] - return getStringLiteralCompletionEntriesFromElementAccess(node.parent); + } + + return undefined; + } + + function enumeratePotentialNonRelativeModules(fragment: string, scriptPath: string, options: CompilerOptions, typeChecker: TypeChecker, host: LanguageServiceHost): string[] { + // Check If this is a nested module + const isNestedModule = fragment.indexOf(directorySeparator) !== -1; + const moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(directorySeparator)) : undefined; + + // Get modules that the type checker picked up + const ambientModules = map(typeChecker.getAmbientModules(), sym => stripQuotes(sym.name)); + let nonRelativeModules = filter(ambientModules, moduleName => startsWith(moduleName, fragment)); + + // Nested modules of the form "module-name/sub" need to be adjusted to only return the string + // after the last '/' that appears in the fragment because that's where the replacement span + // starts + if (isNestedModule) { + const moduleNameWithSeperator = ensureTrailingDirectorySeparator(moduleNameFragment); + nonRelativeModules = map(nonRelativeModules, moduleName => { + if (startsWith(fragment, moduleNameWithSeperator)) { + return moduleName.substr(moduleNameWithSeperator.length); + } + return moduleName; + }); + } + + + if (!options.moduleResolution || options.moduleResolution === ModuleResolutionKind.NodeJs) { + for (const visibleModule of enumerateNodeModulesVisibleToScript(host, scriptPath)) { + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.moduleName); + } + else if (startsWith(visibleModule.moduleName, moduleNameFragment)) { + const nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]); + if (nestedFiles) { + for (let f of nestedFiles) { + f = normalizePath(f); + const nestedModule = removeFileExtension(getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + } + } + } } - else if (node.parent.kind === SyntaxKind.ImportDeclaration || isExpressionOfExternalModuleImportEqualsDeclaration(node) || isRequireCall(node.parent, false)) { - // Get all known external module names or complete a path to a module - // i.e. import * as ns from "/*completion position*/"; - // import x = require("/*completion position*/"); - // var y = require("/*completion position*/"); - return getStringLiteralCompletionEntriesFromModuleNames(node); + } + + return deduplicate(nonRelativeModules); + } + + function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number, compilerOptions: CompilerOptions, host: LanguageServiceHost): CompletionInfo { + const token = getTokenAtPosition(sourceFile, position); + if (!token) { + return undefined; + } + const commentRanges: CommentRange[] = getLeadingCommentRanges(sourceFile.text, token.pos); + + if (!commentRanges || !commentRanges.length) { + return undefined; + } + + const range = forEach(commentRanges, commentRange => position >= commentRange.pos && position <= commentRange.end && commentRange); + + if (!range) { + return undefined; + } + + const completionInfo: CompletionInfo = { + /** + * We don't want the editor to offer any other completions, such as snippets, inside a comment. + */ + isGlobalCompletion: false, + isMemberCompletion: false, + /** + * The user may type in a path that doesn't yet exist, creating a "new identifier" + * with respect to the collection of identifiers the server is aware of. + */ + isNewIdentifierLocation: true, + + entries: [] + }; + + const text = sourceFile.text.substr(range.pos, position - range.pos); + + const match = tripleSlashDirectiveFragmentRegex.exec(text); + + if (match) { + const prefix = match[1]; + const kind = match[2]; + const toComplete = match[3]; + + const scriptPath = getDirectoryPath(sourceFile.path); + if (kind === "path") { + // Give completions for a relative path + const span: TextSpan = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(compilerOptions), /*includeExtensions*/true, span, host, sourceFile.path); } else { - const argumentInfo = SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); - if (argumentInfo) { - // Get string literal completions from specialized signatures of the target - // i.e. declare function f(a: 'A'); - // f("/*completion position*/") - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); - } - - // Get completion for string literal from string literal type - // i.e. var x: "hi" | "hello" = "/*completion position*/" - return getStringLiteralCompletionEntriesFromContextualType(node); + // Give completions based on the typings available + const span: TextSpan = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span); } } - function getStringLiteralCompletionEntriesFromPropertyAssignment(element: ObjectLiteralElement) { - const type = typeChecker.getContextualType((element.parent)); - const entries: CompletionEntry[] = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries }; + return completionInfo; + } + + function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, span: TextSpan, result: CompletionEntry[] = []): CompletionEntry[] { + // Check for typings specified in compiler options + if (options.types) { + for (const moduleName of options.types) { + result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); + } + } + else if (host.getDirectories) { + let typeRoots: string[]; + try { + // Wrap in try catch because getEffectiveTypeRoots touches the filesystem + typeRoots = getEffectiveTypeRoots(options, host); + } + catch (e) {} + + if (typeRoots) { + for (const root of typeRoots) { + getCompletionEntriesFromDirectories(host, root, span, result); } } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo) { - const candidates: Signature[] = []; - const entries: CompletionEntry[] = []; - - typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); - - for (const candidate of candidates) { - if (candidate.parameters.length > argumentInfo.argumentIndex) { - const parameter = candidate.parameters[argumentInfo.argumentIndex]; - addStringLiteralCompletionsFromType(typeChecker.getTypeAtLocation(parameter.valueDeclaration), entries); - } + if (host.getDirectories) { + // Also get all @types typings installed in visible node_modules directories + for (const packageJson of findPackageJsons(scriptPath, host)) { + const typesDir = combinePaths(getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, typesDir, span, result); } - - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries }; - } - - return undefined; } - function getStringLiteralCompletionEntriesFromElementAccess(node: ElementAccessExpression) { - const type = typeChecker.getTypeAtLocation(node.expression); - const entries: CompletionEntry[] = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries }; + return result; + } + + function getCompletionEntriesFromDirectories(host: LanguageServiceHost, directory: string, span: TextSpan, result: Push) { + if (host.getDirectories && tryDirectoryExists(host, directory)) { + const directories = tryGetDirectories(host, directory); + if (directories) { + for (let typeDirectory of directories) { + typeDirectory = normalizePath(typeDirectory); + result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName, span)); } } - return undefined; } + } - function getStringLiteralCompletionEntriesFromContextualType(node: StringLiteral) { - const type = typeChecker.getContextualType(node); - if (type) { - const entries: CompletionEntry[] = []; - addStringLiteralCompletionsFromType(type, entries); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries }; + function findPackageJsons(currentDir: string, host: LanguageServiceHost): string[] { + const paths: string[] = []; + let currentConfigPath: string; + while (true) { + currentConfigPath = findConfigFile(currentDir, (f) => tryFileExists(host, f), "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + + currentDir = getDirectoryPath(currentConfigPath); + const parent = getDirectoryPath(currentDir); + if (currentDir === parent) { + break; } - } - return undefined; - } - - function addStringLiteralCompletionsFromType(type: Type, result: CompletionEntry[]): void { - if (!type) { - return; - } - if (type.flags & TypeFlags.Union) { - forEach((type).types, t => addStringLiteralCompletionsFromType(t, result)); + currentDir = parent; } else { - if (type.flags & TypeFlags.StringLiteral) { + break; + } + } + + return paths; + } + + function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string) { + const result: VisibleModuleInfo[] = []; + + if (host.readFile && host.fileExists) { + for (const packageJson of findPackageJsons(scriptPath, host)) { + const contents = tryReadingPackageJson(packageJson); + if (!contents) { + return; + } + + const nodeModulesDir = combinePaths(getDirectoryPath(packageJson), "node_modules"); + const foundModuleNames: string[] = []; + + // Provide completions for all non @types dependencies + for (const key of nodeModulesDependencyKeys) { + addPotentialPackageNames(contents[key], foundModuleNames); + } + + for (const moduleName of foundModuleNames) { + const moduleDir = combinePaths(nodeModulesDir, moduleName); result.push({ - name: (type).text, - kindModifiers: ScriptElementKindModifier.none, - kind: ScriptElementKind.variableElement, - sortText: "0" + moduleName, + moduleDir }); } } } - function getStringLiteralCompletionEntriesFromModuleNames(node: StringLiteral): CompletionInfo { - const literalValue = normalizeSlashes(node.text); + return result; - const scriptPath = node.getSourceFile().path; - const scriptDirectory = getDirectoryPath(scriptPath); - - const span = getDirectoryFragmentTextSpan((node).text, node.getStart() + 1); - let entries: CompletionEntry[]; - if (isPathRelativeToScript(literalValue) || isRootedDiskPath(literalValue)) { - if (compilerOptions.rootDirs) { - entries = getCompletionEntriesForDirectoryFragmentWithRootDirs( - compilerOptions.rootDirs, literalValue, scriptDirectory, getSupportedExtensions(compilerOptions), /*includeExtensions*/false, span, scriptPath); - } - else { - entries = getCompletionEntriesForDirectoryFragment( - literalValue, scriptDirectory, getSupportedExtensions(compilerOptions), /*includeExtensions*/false, span, scriptPath); - } + function tryReadingPackageJson(filePath: string) { + try { + const fileText = tryReadFile(host, filePath); + return fileText ? JSON.parse(fileText) : undefined; } - else { - // Check for node modules - entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); - } - return { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries - }; - } - - /** - * Takes a script path and returns paths for all potential folders that could be merged with its - * containing folder via the "rootDirs" compiler option - */ - function getBaseDirectoriesFromRootDirs(rootDirs: string[], basePath: string, scriptPath: string, ignoreCase: boolean): string[] { - // Make all paths absolute/normalized if they are not already - rootDirs = map(rootDirs, rootDirectory => normalizePath(isRootedDiskPath(rootDirectory) ? rootDirectory : combinePaths(basePath, rootDirectory))); - - // Determine the path to the directory containing the script relative to the root directory it is contained within - let relativeDirectory: string; - for (const rootDirectory of rootDirs) { - if (containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { - relativeDirectory = scriptPath.substr(rootDirectory.length); - break; - } - } - - // Now find a path for each potential directory that is to be merged with the one containing the script - return deduplicate(map(rootDirs, rootDirectory => combinePaths(rootDirectory, relativeDirectory))); - } - - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, exclude?: string): CompletionEntry[] { - const basePath = compilerOptions.project || host.getCurrentDirectory(); - const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); - - const result: CompletionEntry[] = []; - - for (const baseDirectory of baseDirectories) { - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, exclude, result); - } - - return result; - } - - /** - * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. - */ - function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, exclude?: string, result: CompletionEntry[] = []): CompletionEntry[] { - if (fragment === undefined) { - fragment = ""; - } - - fragment = normalizeSlashes(fragment); - - /** - * Remove the basename from the path. Note that we don't use the basename to filter completions; - * the client is responsible for refining completions. - */ - fragment = getDirectoryPath(fragment); - - if (fragment === "") { - fragment = "." + directorySeparator; - } - - fragment = ensureTrailingDirectorySeparator(fragment); - - const absolutePath = normalizeAndPreserveTrailingSlash(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment)); - const baseDirectory = getDirectoryPath(absolutePath); - const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - - if (tryDirectoryExists(host, baseDirectory)) { - // Enumerate the available files if possible - const files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]); - - if (files) { - /** - * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: - * - * both foo.ts and foo.tsx become foo - */ - const foundFiles = createMap(); - for (let filePath of files) { - filePath = normalizePath(filePath); - if (exclude && comparePaths(filePath, exclude, scriptPath, ignoreCase) === Comparison.EqualTo) { - continue; - } - - const foundFileName = includeExtensions ? getBaseFileName(filePath) : removeFileExtension(getBaseFileName(filePath)); - - if (!foundFiles[foundFileName]) { - foundFiles[foundFileName] = true; - } - } - - for (const foundFile in foundFiles) { - result.push(createCompletionEntryForModule(foundFile, ScriptElementKind.scriptElement, span)); - } - } - - // If possible, get folder completion as well - const directories = tryGetDirectories(host, baseDirectory); - - if (directories) { - for (const directory of directories) { - const directoryName = getBaseFileName(normalizePath(directory)); - - result.push(createCompletionEntryForModule(directoryName, ScriptElementKind.directory, span)); - } - } - } - - return result; - } - - /** - * Check all of the declared modules and those in node modules. Possible sources of modules: - * Modules that are found by the type checker - * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) - * Modules from node_modules (i.e. those listed in package.json) - * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions - */ - function getCompletionEntriesForNonRelativeModules(fragment: string, scriptPath: string, span: TextSpan): CompletionEntry[] { - const { baseUrl, paths } = compilerOptions; - - let result: CompletionEntry[]; - - if (baseUrl) { - const fileExtensions = getSupportedExtensions(compilerOptions); - const projectDir = compilerOptions.project || host.getCurrentDirectory(); - const absolute = isRootedDiskPath(baseUrl) ? baseUrl : combinePaths(projectDir, baseUrl); - result = getCompletionEntriesForDirectoryFragment(fragment, normalizePath(absolute), fileExtensions, /*includeExtensions*/false, span); - - if (paths) { - for (const path in paths) { - if (paths.hasOwnProperty(path)) { - if (path === "*") { - if (paths[path]) { - for (const pattern of paths[path]) { - for (const match of getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions)) { - result.push(createCompletionEntryForModule(match, ScriptElementKind.externalModuleName, span)); - } - } - } - } - else if (startsWith(path, fragment)) { - const entry = paths[path] && paths[path].length === 1 && paths[path][0]; - if (entry) { - result.push(createCompletionEntryForModule(path, ScriptElementKind.externalModuleName, span)); - } - } - } - } - } - } - else { - result = []; - } - - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); - - for (const moduleName of enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions)) { - result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); - } - - return result; - } - - function getModulesForPathsPattern(fragment: string, baseUrl: string, pattern: string, fileExtensions: string[]): string[] { - if (host.readDirectory) { - const parsed = hasZeroOrOneAsteriskCharacter(pattern) ? tryParsePattern(pattern) : undefined; - if (parsed) { - // The prefix has two effective parts: the directory path and the base component after the filepath that is not a - // full directory component. For example: directory/path/of/prefix/base* - const normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); - const normalizedPrefixDirectory = getDirectoryPath(normalizedPrefix); - const normalizedPrefixBase = getBaseFileName(normalizedPrefix); - - const fragmentHasPath = fragment.indexOf(directorySeparator) !== -1; - - // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call - const expandedPrefixDirectory = fragmentHasPath ? combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + getDirectoryPath(fragment)) : normalizedPrefixDirectory; - - const normalizedSuffix = normalizePath(parsed.suffix); - const baseDirectory = combinePaths(baseUrl, expandedPrefixDirectory); - const completePrefix = fragmentHasPath ? baseDirectory : ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - - // If we have a suffix, then we need to read the directory all the way down. We could create a glob - // that encodes the suffix, but we would have to escape the character "?" which readDirectory - // doesn't support. For now, this is safer but slower - const includeGlob = normalizedSuffix ? "**/*" : "./*"; - - const matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); - if (matches) { - const result: string[] = []; - - // Trim away prefix and suffix - for (const match of matches) { - const normalizedMatch = normalizePath(match); - if (!endsWith(normalizedMatch, normalizedSuffix) || !startsWith(normalizedMatch, completePrefix)) { - continue; - } - - const start = completePrefix.length; - const length = normalizedMatch.length - start - normalizedSuffix.length; - - result.push(removeFileExtension(normalizedMatch.substr(start, length))); - } - return result; - } - } - } - - return undefined; - } - - function enumeratePotentialNonRelativeModules(fragment: string, scriptPath: string, options: CompilerOptions): string[] { - // Check If this is a nested module - const isNestedModule = fragment.indexOf(directorySeparator) !== -1; - const moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(directorySeparator)) : undefined; - - // Get modules that the type checker picked up - const ambientModules = map(typeChecker.getAmbientModules(), sym => stripQuotes(sym.name)); - let nonRelativeModules = filter(ambientModules, moduleName => startsWith(moduleName, fragment)); - - // Nested modules of the form "module-name/sub" need to be adjusted to only return the string - // after the last '/' that appears in the fragment because that's where the replacement span - // starts - if (isNestedModule) { - const moduleNameWithSeperator = ensureTrailingDirectorySeparator(moduleNameFragment); - nonRelativeModules = map(nonRelativeModules, moduleName => { - if (startsWith(fragment, moduleNameWithSeperator)) { - return moduleName.substr(moduleNameWithSeperator.length); - } - return moduleName; - }); - } - - - if (!options.moduleResolution || options.moduleResolution === ModuleResolutionKind.NodeJs) { - for (const visibleModule of enumerateNodeModulesVisibleToScript(host, scriptPath)) { - if (!isNestedModule) { - nonRelativeModules.push(visibleModule.moduleName); - } - else if (startsWith(visibleModule.moduleName, moduleNameFragment)) { - const nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]); - if (nestedFiles) { - for (let f of nestedFiles) { - f = normalizePath(f); - const nestedModule = removeFileExtension(getBaseFileName(f)); - nonRelativeModules.push(nestedModule); - } - } - } - } - } - - return deduplicate(nonRelativeModules); - } - - function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number): CompletionInfo { - const token = getTokenAtPosition(sourceFile, position); - if (!token) { + catch (e) { return undefined; } - const commentRanges: CommentRange[] = getLeadingCommentRanges(sourceFile.text, token.pos); - - if (!commentRanges || !commentRanges.length) { - return undefined; - } - - const range = forEach(commentRanges, commentRange => position >= commentRange.pos && position <= commentRange.end && commentRange); - - if (!range) { - return undefined; - } - - const completionInfo: CompletionInfo = { - /** - * We don't want the editor to offer any other completions, such as snippets, inside a comment. - */ - isGlobalCompletion: false, - isMemberCompletion: false, - /** - * The user may type in a path that doesn't yet exist, creating a "new identifier" - * with respect to the collection of identifiers the server is aware of. - */ - isNewIdentifierLocation: true, - - entries: [] - }; - - const text = sourceFile.text.substr(range.pos, position - range.pos); - - const match = tripleSlashDirectiveFragmentRegex.exec(text); - - if (match) { - const prefix = match[1]; - const kind = match[2]; - const toComplete = match[3]; - - const scriptPath = getDirectoryPath(sourceFile.path); - if (kind === "path") { - // Give completions for a relative path - const span: TextSpan = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(compilerOptions), /*includeExtensions*/true, span, sourceFile.path); - } - else { - // Give completions based on the typings available - const span: TextSpan = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span); - } - } - - return completionInfo; } - function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, span: TextSpan, result: CompletionEntry[] = []): CompletionEntry[] { - // Check for typings specified in compiler options - if (options.types) { - for (const moduleName of options.types) { - result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); - } - } - else if (host.getDirectories) { - let typeRoots: string[]; - try { - // Wrap in try catch because getEffectiveTypeRoots touches the filesystem - typeRoots = getEffectiveTypeRoots(options, host); - } - catch (e) {} - - if (typeRoots) { - for (const root of typeRoots) { - getCompletionEntriesFromDirectories(host, root, span, result); - } - } - } - - if (host.getDirectories) { - // Also get all @types typings installed in visible node_modules directories - for (const packageJson of findPackageJsons(scriptPath)) { - const typesDir = combinePaths(getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, typesDir, span, result); - } - } - - return result; - } - - function getCompletionEntriesFromDirectories(host: LanguageServiceHost, directory: string, span: TextSpan, result: CompletionEntry[]) { - if (host.getDirectories && tryDirectoryExists(host, directory)) { - const directories = tryGetDirectories(host, directory); - if (directories) { - for (let typeDirectory of directories) { - typeDirectory = normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName, span)); + function addPotentialPackageNames(dependencies: any, result: string[]) { + if (dependencies) { + for (const dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && !startsWith(dep, "@types/")) { + result.push(dep); } } } } + } - function findPackageJsons(currentDir: string): string[] { - const paths: string[] = []; - let currentConfigPath: string; - while (true) { - currentConfigPath = findConfigFile(currentDir, (f) => tryFileExists(host, f), "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); + function createCompletionEntryForModule(name: string, kind: string, replacementSpan: TextSpan): CompletionEntry { + return { name, kind, kindModifiers: ScriptElementKindModifier.none, sortText: name, replacementSpan }; + } - currentDir = getDirectoryPath(currentConfigPath); - const parent = getDirectoryPath(currentDir); - if (currentDir === parent) { - break; - } - currentDir = parent; - } - else { - break; - } - } + // Replace everything after the last directory seperator that appears + function getDirectoryFragmentTextSpan(text: string, textStart: number): TextSpan { + const index = text.lastIndexOf(directorySeparator); + const offset = index !== -1 ? index + 1 : 0; + return { start: textStart + offset, length: text.length - offset }; + } - return paths; + // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) + function isPathRelativeToScript(path: string) { + if (path && path.length >= 2 && path.charCodeAt(0) === CharacterCodes.dot) { + const slashIndex = path.length >= 3 && path.charCodeAt(1) === CharacterCodes.dot ? 2 : 1; + const slashCharCode = path.charCodeAt(slashIndex); + return slashCharCode === CharacterCodes.slash || slashCharCode === CharacterCodes.backslash; } + return false; + } - - function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string) { - const result: VisibleModuleInfo[] = []; - - if (host.readFile && host.fileExists) { - for (const packageJson of findPackageJsons(scriptPath)) { - const contents = tryReadingPackageJson(packageJson); - if (!contents) { - return; - } - - const nodeModulesDir = combinePaths(getDirectoryPath(packageJson), "node_modules"); - const foundModuleNames: string[] = []; - - // Provide completions for all non @types dependencies - for (const key of nodeModulesDependencyKeys) { - addPotentialPackageNames(contents[key], foundModuleNames); - } - - for (const moduleName of foundModuleNames) { - const moduleDir = combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName, - moduleDir - }); - } - } - } - - return result; - - function tryReadingPackageJson(filePath: string) { - try { - const fileText = tryReadFile(host, filePath); - return fileText ? JSON.parse(fileText) : undefined; - } - catch (e) { - return undefined; - } - } - - function addPotentialPackageNames(dependencies: any, result: string[]) { - if (dependencies) { - for (const dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !startsWith(dep, "@types/")) { - result.push(dep); - } - } - } - } - } - - function createCompletionEntryForModule(name: string, kind: string, replacementSpan: TextSpan): CompletionEntry { - return { name, kind, kindModifiers: ScriptElementKindModifier.none, sortText: name, replacementSpan }; - } - - // Replace everything after the last directory seperator that appears - function getDirectoryFragmentTextSpan(text: string, textStart: number): TextSpan { - const index = text.lastIndexOf(directorySeparator); - const offset = index !== -1 ? index + 1 : 0; - return { start: textStart + offset, length: text.length - offset }; - } - - // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) - function isPathRelativeToScript(path: string) { - if (path && path.length >= 2 && path.charCodeAt(0) === CharacterCodes.dot) { - const slashIndex = path.length >= 3 && path.charCodeAt(1) === CharacterCodes.dot ? 2 : 1; - const slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === CharacterCodes.slash || slashCharCode === CharacterCodes.backslash; - } - return false; - } - - function normalizeAndPreserveTrailingSlash(path: string) { - return hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalizePath(path)) : normalizePath(path); - } + function normalizeAndPreserveTrailingSlash(path: string) { + return hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalizePath(path)) : normalizePath(path); } export function getCompletionEntryDetails(typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number, entryName: string): CompletionEntryDetails { @@ -1317,14 +1316,14 @@ namespace ts.Completions { isMemberCompletion = true; isNewIdentifierLocation = false; - let exports: Symbol[]; - const moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + const moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); + if (!moduleSpecifierSymbol) { + symbols = emptyArray; + return true; } - symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : emptyArray; - + const exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); + symbols = filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements); return true; } @@ -1563,14 +1562,14 @@ namespace ts.Completions { } const name = element.propertyName || element.name; - existingImportsOrExports[name.text] = true; + existingImportsOrExports.set(name.text, true); } - if (!someProperties(existingImportsOrExports)) { + if (existingImportsOrExports.size === 0) { return filter(exportsOfModule, e => e.name !== "default"); } - return filter(exportsOfModule, e => e.name !== "default" && !existingImportsOrExports[e.name]); + return filter(exportsOfModule, e => e.name !== "default" && !existingImportsOrExports.get(e.name)); } /** @@ -1616,10 +1615,10 @@ namespace ts.Completions { existingName = (m.name).text; } - existingMemberNames[existingName] = true; + existingMemberNames.set(existingName, true); } - return filter(contextualMemberSymbols, m => !existingMemberNames[m.name]); + return filter(contextualMemberSymbols, m => !existingMemberNames.get(m.name)); } /** @@ -1637,11 +1636,11 @@ namespace ts.Completions { } if (attr.kind === SyntaxKind.JsxAttribute) { - seenNames[(attr).name.text] = true; + seenNames.set((attr).name.text, true); } } - return filter(symbols, a => !seenNames[a.name]); + return filter(symbols, a => !seenNames.get(a.name)); } } diff --git a/src/services/documentHighlights.ts b/src/services/documentHighlights.ts index 0f18427e568..212e145ca60 100644 --- a/src/services/documentHighlights.ts +++ b/src/services/documentHighlights.ts @@ -44,11 +44,11 @@ namespace ts.DocumentHighlights { for (const referencedSymbol of referencedSymbols) { for (const referenceEntry of referencedSymbol.references) { const fileName = referenceEntry.fileName; - let documentHighlights = fileNameToDocumentHighlights[fileName]; + let documentHighlights = fileNameToDocumentHighlights.get(fileName); if (!documentHighlights) { documentHighlights = { fileName, highlightSpans: [] }; - fileNameToDocumentHighlights[fileName] = documentHighlights; + fileNameToDocumentHighlights.set(fileName, documentHighlights); result.push(documentHighlights); } diff --git a/src/services/documentRegistry.ts b/src/services/documentRegistry.ts index d73e4d3b0a1..80b0133ccfe 100644 --- a/src/services/documentRegistry.ts +++ b/src/services/documentRegistry.ts @@ -1,4 +1,4 @@ -namespace ts { +namespace ts { /** * The document registry represents a store of SourceFile objects that can be shared between * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST) @@ -113,16 +113,16 @@ namespace ts { } function getBucketForCompilationSettings(key: DocumentRegistryBucketKey, createIfMissing: boolean): FileMap { - let bucket = buckets[key]; + let bucket = buckets.get(key); if (!bucket && createIfMissing) { - buckets[key] = bucket = createFileMap(); + buckets.set(key, bucket = createFileMap()); } return bucket; } function reportStats() { - const bucketInfoArray = Object.keys(buckets).filter(name => name && name.charAt(0) === "_").map(name => { - const entries = buckets[name]; + const bucketInfoArray = arrayFrom(buckets.keys()).filter(name => name && name.charAt(0) === "_").map(name => { + const entries = buckets.get(name); const sourceFiles: { name: string; refCount: number; references: string[]; }[] = []; entries.forEachValue((key, entry) => { sourceFiles.push({ diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 313a3d2ea3e..090357a56b2 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.FindAllReferences { export function findReferencedSymbols(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] { const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); @@ -30,20 +30,20 @@ namespace ts.FindAllReferences { const labelDefinition = getTargetLabel((node.parent), (node).text); // if we have a label definition, look within its statement for references, if not, then // the label is undefined and we have no results.. - return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; + return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, cancellationToken); } else { // it is a label definition and not a target, search within the parent labeledStatement - return getLabelReferencesInNode(node.parent, node); + return getLabelReferencesInNode(node.parent, node, cancellationToken); } } if (isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles); + return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken); } if (node.kind === SyntaxKind.SuperKeyword) { - return getReferencesForSuperKeyword(node); + return getReferencesForSuperKeyword(node, typeChecker, cancellationToken); } } @@ -52,10 +52,9 @@ namespace ts.FindAllReferences { const symbol = typeChecker.getSymbolAtLocation(node); if (!implementations && !symbol && node.kind === SyntaxKind.StringLiteral) { - return getReferencesForStringLiteral(node, sourceFiles); + return getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken); } - // Could not find a symbol e.g. unknown identifier if (!symbol) { // Can't have references to something that we have no symbol for. @@ -87,7 +86,7 @@ namespace ts.FindAllReferences { if (scope) { result = []; - getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken); } else { const internedName = getInternedName(symbol, node); @@ -96,1161 +95,1159 @@ namespace ts.FindAllReferences { const nameTable = getNameTable(sourceFile); - if (nameTable[internedName] !== undefined) { + if (nameTable.get(internedName) !== undefined) { result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken); } } } return result; + } - function getDefinition(symbol: Symbol): ReferencedSymbolDefinitionInfo { - const info = SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), getContainerNode(node), node); - const name = map(info.displayParts, p => p.text).join(""); - const declarations = symbol.declarations; - if (!declarations || declarations.length === 0) { - return undefined; - } - - return { - containerKind: "", - containerName: "", - name, - kind: info.symbolKind, - fileName: declarations[0].getSourceFile().fileName, - textSpan: createTextSpan(declarations[0].getStart(), 0), - displayParts: info.displayParts - }; - } - - function getAliasSymbolForPropertyNameSymbol(symbol: Symbol, location: Node): Symbol | undefined { - if (symbol.flags & SymbolFlags.Alias) { - // Default import get alias - const defaultImport = getDeclarationOfKind(symbol, SyntaxKind.ImportClause); - if (defaultImport) { - return typeChecker.getAliasedSymbol(symbol); - } - - const importOrExportSpecifier = forEach(symbol.declarations, - declaration => (declaration.kind === SyntaxKind.ImportSpecifier || - declaration.kind === SyntaxKind.ExportSpecifier) ? declaration : undefined); - if (importOrExportSpecifier && - // export { a } - (!importOrExportSpecifier.propertyName || - // export {a as class } where a is location - importOrExportSpecifier.propertyName === location)) { - // If Import specifier -> get alias - // else Export specifier -> get local target - return importOrExportSpecifier.kind === SyntaxKind.ImportSpecifier ? - typeChecker.getAliasedSymbol(symbol) : - typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); - } - } + function getDefinition(symbol: Symbol, node: Node, typeChecker: TypeChecker): ReferencedSymbolDefinitionInfo { + const info = SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), getContainerNode(node), node); + const name = map(info.displayParts, p => p.text).join(""); + const declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { return undefined; } - function followAliasIfNecessary(symbol: Symbol, location: Node): Symbol { - return getAliasSymbolForPropertyNameSymbol(symbol, location) || symbol; - } + return { + containerKind: "", + containerName: "", + name, + kind: info.symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: createTextSpan(declarations[0].getStart(), 0), + displayParts: info.displayParts + }; + } - function getPropertySymbolOfDestructuringAssignment(location: Node) { - return isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - typeChecker.getPropertySymbolOfDestructuringAssignment(location); - } + function getAliasSymbolForPropertyNameSymbol(symbol: Symbol, location: Node, typeChecker: TypeChecker): Symbol | undefined { + if (symbol.flags & SymbolFlags.Alias) { + // Default import get alias + const defaultImport = getDeclarationOfKind(symbol, SyntaxKind.ImportClause); + if (defaultImport) { + return typeChecker.getAliasedSymbol(symbol); + } - function isObjectBindingPatternElementWithoutPropertyName(symbol: Symbol) { + const importOrExportSpecifier = forEach(symbol.declarations, + declaration => (declaration.kind === SyntaxKind.ImportSpecifier || + declaration.kind === SyntaxKind.ExportSpecifier) ? declaration : undefined); + if (importOrExportSpecifier && + // export { a } + (!importOrExportSpecifier.propertyName || + // export {a as class } where a is location + importOrExportSpecifier.propertyName === location)) { + // If Import specifier -> get alias + // else Export specifier -> get local target + return importOrExportSpecifier.kind === SyntaxKind.ImportSpecifier ? + typeChecker.getAliasedSymbol(symbol) : + typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); + } + } + return undefined; + } + + function followAliasIfNecessary(symbol: Symbol, location: Node, typeChecker: TypeChecker): Symbol { + return getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) || symbol; + } + + function getPropertySymbolOfDestructuringAssignment(location: Node, typeChecker: TypeChecker) { + return isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && + typeChecker.getPropertySymbolOfDestructuringAssignment(location); + } + + function isObjectBindingPatternElementWithoutPropertyName(symbol: Symbol) { + const bindingElement = getDeclarationOfKind(symbol, SyntaxKind.BindingElement); + return bindingElement && + bindingElement.parent.kind === SyntaxKind.ObjectBindingPattern && + !bindingElement.propertyName; + } + + function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol: Symbol, typeChecker: TypeChecker) { + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { const bindingElement = getDeclarationOfKind(symbol, SyntaxKind.BindingElement); - return bindingElement && - bindingElement.parent.kind === SyntaxKind.ObjectBindingPattern && - !bindingElement.propertyName; + const typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); + return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, (bindingElement.name).text); + } + return undefined; + } + + function getInternedName(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 under the cursor. + if (isImportOrExportSpecifierName(location)) { + return location.getText(); } - function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol: Symbol) { - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - const bindingElement = getDeclarationOfKind(symbol, SyntaxKind.BindingElement); - const typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, (bindingElement.name).text); + // Try to get the local symbol if we're dealing with an 'export default' + // since that symbol has the "true" name. + const localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol); + symbol = localExportDefaultSymbol || symbol; + + 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 named function expression or named class expression, + // then named references are limited to its own scope. + const valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && (valueDeclaration.kind === SyntaxKind.FunctionExpression || valueDeclaration.kind === SyntaxKind.ClassExpression)) { + return valueDeclaration; + } + + // If this is private property or method, the scope is the containing class + if (symbol.flags & (SymbolFlags.Property | SymbolFlags.Method)) { + const privateDeclaration = forEach(symbol.getDeclarations(), d => (getModifierFlags(d) & ModifierFlags.Private) ? d : undefined); + if (privateDeclaration) { + return getAncestor(privateDeclaration, SyntaxKind.ClassDeclaration); } + } + + // If the symbol is an import we would like to find it if we are looking for what it imports. + // So consider it visible outside its declaration scope. + if (symbol.flags & SymbolFlags.Alias) { return undefined; } - function getInternedName(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 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. - const localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol); - symbol = localExportDefaultSymbol || symbol; - - return stripQuotes(symbol.name); + // If symbol is of object binding pattern element without property name we would want to + // look for property too and that could be anywhere + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + return undefined; } - /** - * 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 named function expression or named class expression, - // then named references are limited to its own scope. - const valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === SyntaxKind.FunctionExpression || valueDeclaration.kind === SyntaxKind.ClassExpression)) { - return valueDeclaration; - } - - // If this is private property or method, the scope is the containing class - if (symbol.flags & (SymbolFlags.Property | SymbolFlags.Method)) { - const privateDeclaration = forEach(symbol.getDeclarations(), d => (getModifierFlags(d) & ModifierFlags.Private) ? d : undefined); - if (privateDeclaration) { - return getAncestor(privateDeclaration, SyntaxKind.ClassDeclaration); - } - } - - // If the symbol is an import we would like to find it if we are looking for what it imports. - // So consider it visible outside its declaration scope. - if (symbol.flags & SymbolFlags.Alias) { - return undefined; - } - - // If symbol is of object binding pattern element without property name we would want to - // look for property too and that could be anywhere - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - return undefined; - } - - // if this symbol is visible from its parent container, e.g. exported, then bail out - // if symbol correspond to the union property - bail out - if (symbol.parent || (symbol.flags & SymbolFlags.SyntheticProperty)) { - return undefined; - } - - let scope: Node; - - const declarations = symbol.getDeclarations(); - if (declarations) { - for (const declaration of declarations) { - const container = getContainerNode(declaration); - - if (!container) { - return undefined; - } - - if (scope && scope !== container) { - // Different declarations have different containers, bail out - return undefined; - } - - if (container.kind === SyntaxKind.SourceFile && !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; - } - - // The search scope is the container node - scope = container; - } - } - - return scope; + // if this symbol is visible from its parent container, e.g. exported, then bail out + // if symbol correspond to the union property - bail out + if (symbol.parent || (symbol.flags & SymbolFlags.SyntheticProperty)) { + return undefined; } - function getPossibleSymbolReferencePositions(sourceFile: SourceFile, symbolName: string, start: number, end: number): number[] { - const positions: number[] = []; + let scope: Node; - /// TODO: Cache symbol existence for files to save text search - // Also, need to make this work for unicode escapes. + const declarations = symbol.getDeclarations(); + if (declarations) { + for (const declaration of declarations) { + const container = getContainerNode(declaration); - // Be resilient in the face of a symbol with no name or zero length name - if (!symbolName || !symbolName.length) { - return positions; - } - - const text = sourceFile.text; - const sourceLength = text.length; - const symbolNameLength = symbolName.length; - - let position = text.indexOf(symbolName, start); - while (position >= 0) { - cancellationToken.throwIfCancellationRequested(); - - // If we are past the end, stop looking - if (position > end) break; - - // We found a match. Make sure it's not part of a larger word (i.e. the char - // before and after it have to be a non-identifier char). - const endPosition = position + symbolNameLength; - - if ((position === 0 || !isIdentifierPart(text.charCodeAt(position - 1), ScriptTarget.Latest)) && - (endPosition === sourceLength || !isIdentifierPart(text.charCodeAt(endPosition), ScriptTarget.Latest))) { - // Found a real match. Keep searching. - positions.push(position); + if (!container) { + return undefined; } - position = text.indexOf(symbolName, position + symbolNameLength + 1); - } + if (scope && scope !== container) { + // Different declarations have different containers, bail out + return undefined; + } + + if (container.kind === SyntaxKind.SourceFile && !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; + } + + // The search scope is the container node + scope = container; + } + } + + return scope; + } + + function getPossibleSymbolReferencePositions(sourceFile: SourceFile, symbolName: string, start: number, end: number, cancellationToken: CancellationToken): number[] { + const positions: number[] = []; + + /// TODO: Cache symbol existence for files to save text search + // Also, need to make this work for unicode escapes. + + // Be resilient in the face of a symbol with no name or zero length name + if (!symbolName || !symbolName.length) { return positions; } - function getLabelReferencesInNode(container: Node, targetLabel: Identifier): ReferencedSymbol[] { - const references: ReferenceEntry[] = []; - const sourceFile = container.getSourceFile(); - const labelName = targetLabel.text; - const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); + const text = sourceFile.text; + const sourceLength = text.length; + const symbolNameLength = symbolName.length; + + let position = text.indexOf(symbolName, start); + while (position >= 0) { + cancellationToken.throwIfCancellationRequested(); + + // If we are past the end, stop looking + if (position > end) break; + + // We found a match. Make sure it's not part of a larger word (i.e. the char + // before and after it have to be a non-identifier char). + const endPosition = position + symbolNameLength; + + if ((position === 0 || !isIdentifierPart(text.charCodeAt(position - 1), ScriptTarget.Latest)) && + (endPosition === sourceLength || !isIdentifierPart(text.charCodeAt(endPosition), ScriptTarget.Latest))) { + // Found a real match. Keep searching. + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); + } + + return positions; + } + + function getLabelReferencesInNode(container: Node, targetLabel: Identifier, cancellationToken: CancellationToken): ReferencedSymbol[] { + const references: ReferenceEntry[] = []; + const sourceFile = container.getSourceFile(); + const labelName = targetLabel.text; + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd(), cancellationToken); + forEach(possiblePositions, position => { + cancellationToken.throwIfCancellationRequested(); + + const node = getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { + return; + } + + // Only pick labels that are either the target label, or have a target that is the target label + if (node === targetLabel || + (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel)) { + references.push(getReferenceEntryFromNode(node)); + } + }); + + const definition: ReferencedSymbolDefinitionInfo = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ScriptElementKind.label, + name: labelName, + textSpan: createTextSpanFromNode(targetLabel, sourceFile), + displayParts: [displayPart(labelName, SymbolDisplayPartKind.text)] + }; + + return [{ definition, references }]; + } + + function isValidReferencePosition(node: Node, searchSymbolName: string): boolean { + // Compare the length so we filter out strict superstrings of the symbol we are looking for + switch (node && node.kind) { + case SyntaxKind.Identifier: + return node.getWidth() === searchSymbolName.length; + + case SyntaxKind.StringLiteral: + return (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && + // For string literals we have two additional chars for the quotes + node.getWidth() === searchSymbolName.length + 2; + + case SyntaxKind.NumericLiteral: + return isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; + + default: + return false; + } + } + + /** Search within node "container" for references for a search value, where the search value is defined as a + * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). + * searchLocation: a node where the search value + */ + function getReferencesInNode(container: Node, + searchSymbol: Symbol, + searchText: string, + searchLocation: Node, + searchMeaning: SemanticMeaning, + findInStrings: boolean, + findInComments: boolean, + result: ReferencedSymbol[], + symbolToIndex: number[], + implementations: boolean, + typeChecker: TypeChecker, + cancellationToken: CancellationToken): void { + + const sourceFile = container.getSourceFile(); + + const start = findInComments ? container.getFullStart() : container.getStart(); + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken); + + const parents = getParentSymbolsOfPropertyAccess(); + const inheritsFromCache: Map = createMap(); + + if (possiblePositions.length) { + // Build the set of symbols to search for, initially it has only the current symbol + const searchSymbols = populateSearchSymbolSet(searchSymbol, searchLocation, typeChecker, implementations); + forEach(possiblePositions, position => { cancellationToken.throwIfCancellationRequested(); - const node = getTouchingWord(sourceFile, position); - if (!node || node.getWidth() !== labelName.length) { + const referenceLocation = getTouchingPropertyName(sourceFile, position); + if (!isValidReferencePosition(referenceLocation, searchText)) { + // This wasn't the start of a token. Check to see if it might be a + // match in a comment or string if that's what the caller is asking + // for. + if (!implementations && ((findInStrings && isInString(sourceFile, position)) || + (findInComments && isInNonReferenceComment(sourceFile, position)))) { + + // In the case where we're looking inside comments/strings, we don't have + // an actual definition. So just use 'undefined' here. Features like + // 'Rename' won't care (as they ignore the definitions), and features like + // 'FindReferences' will just filter out these results. + result.push({ + definition: undefined, + references: [{ + fileName: sourceFile.fileName, + textSpan: createTextSpan(position, searchText.length), + isWriteAccess: false, + isDefinition: false + }] + }); + } return; } - // Only pick labels that are either the target label, or have a target that is the target label - if (node === targetLabel || - (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); + if (!(getMeaningFromLocation(referenceLocation) & searchMeaning)) { + return; + } + + const referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); + if (referenceSymbol) { + const referenceSymbolDeclaration = referenceSymbol.valueDeclaration; + const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); + const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, + /*searchLocationIsConstructor*/ searchLocation.kind === SyntaxKind.ConstructorKeyword, parents, inheritsFromCache, typeChecker); + + if (relatedSymbol) { + addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); + } + /* Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment + * has two meaning : property name and property value. Therefore when we do findAllReference at the position where + * an identifier is declared, the language service should return the position of the variable declaration as well as + * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the + * 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) { + addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); + } + else if (searchLocation.kind === SyntaxKind.ConstructorKeyword) { + findAdditionalConstructorReferences(referenceSymbol, referenceLocation); + } } }); + } + return; - const definition: ReferencedSymbolDefinitionInfo = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ScriptElementKind.label, - name: labelName, - textSpan: createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()), - displayParts: [displayPart(labelName, SymbolDisplayPartKind.text)] - }; - - return [{ definition, references }]; + /* If we are just looking for implementations and this is a property access expression, we need to get the + * symbol of the local type of the symbol the property is being accessed on. This is because our search + * symbol may have a different parent symbol if the local type's symbol does not declare the property + * being accessed (i.e. it is declared in some parent class or interface) + */ + function getParentSymbolsOfPropertyAccess(): Symbol[] | undefined { + if (implementations) { + const propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); + if (propertyAccessExpression) { + const localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); + if (localParentType) { + if (localParentType.symbol && localParentType.symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) && localParentType.symbol !== searchSymbol.parent) { + return [localParentType.symbol]; + } + else if (localParentType.flags & TypeFlags.UnionOrIntersection) { + return getSymbolsForClassAndInterfaceComponents(localParentType); + } + } + } + } } - function isValidReferencePosition(node: Node, searchSymbolName: string): boolean { - if (node) { - // Compare the length so we filter out strict superstrings of the symbol we are looking for - switch (node.kind) { - case SyntaxKind.Identifier: - return node.getWidth() === searchSymbolName.length; - - case SyntaxKind.StringLiteral: - if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { - // For string literals we have two additional chars for the quotes - return node.getWidth() === searchSymbolName.length + 2; - } - break; - - case SyntaxKind.NumericLiteral: - if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return node.getWidth() === searchSymbolName.length; - } - break; - } - } - - return false; + function getPropertyAccessExpressionFromRightHandSide(node: Node): PropertyAccessExpression { + return isRightSideOfPropertyAccess(node) && node.parent; } - /** Search within node "container" for references for a search value, where the search value is defined as a - * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). - * searchLocation: a node where the search value - */ - function getReferencesInNode(container: Node, - searchSymbol: Symbol, - searchText: string, - searchLocation: Node, - searchMeaning: SemanticMeaning, - findInStrings: boolean, - findInComments: boolean, - result: ReferencedSymbol[], - symbolToIndex: number[]): void { + /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ + function findAdditionalConstructorReferences(referenceSymbol: Symbol, referenceLocation: Node): void { + Debug.assert(isClassLike(searchSymbol.valueDeclaration)); - const sourceFile = container.getSourceFile(); - - const start = findInComments ? container.getFullStart() : container.getStart(); - const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd()); - - const parents = getParentSymbolsOfPropertyAccess(); - const inheritsFromCache: Map = createMap(); - - if (possiblePositions.length) { - // Build the set of symbols to search for, initially it has only the current symbol - const searchSymbols = populateSearchSymbolSet(searchSymbol, searchLocation); - - forEach(possiblePositions, position => { - cancellationToken.throwIfCancellationRequested(); - - const referenceLocation = getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { - // This wasn't the start of a token. Check to see if it might be a - // match in a comment or string if that's what the caller is asking - // for. - if (!implementations && ((findInStrings && isInString(sourceFile, position)) || - (findInComments && isInNonReferenceComment(sourceFile, position)))) { - - // In the case where we're looking inside comments/strings, we don't have - // an actual definition. So just use 'undefined' here. Features like - // 'Rename' won't care (as they ignore the definitions), and features like - // 'FindReferences' will just filter out these results. - result.push({ - definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] - }); - } - return; - } - - if (!(getMeaningFromLocation(referenceLocation) & searchMeaning)) { - return; - } - - const referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); - if (referenceSymbol) { - const referenceSymbolDeclaration = referenceSymbol.valueDeclaration; - const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, - /*searchLocationIsConstructor*/ searchLocation.kind === SyntaxKind.ConstructorKeyword, parents, inheritsFromCache); - - if (relatedSymbol) { - addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); - } - /* Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment - * has two meaning : property name and property value. Therefore when we do findAllReference at the position where - * an identifier is declared, the language service should return the position of the variable declaration as well as - * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the - * 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) { - addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); - } - else if (searchLocation.kind === SyntaxKind.ConstructorKeyword) { - findAdditionalConstructorReferences(referenceSymbol, referenceLocation); - } - } - }); + const referenceClass = referenceLocation.parent; + if (referenceSymbol === searchSymbol && isClassLike(referenceClass)) { + Debug.assert(referenceClass.name === referenceLocation); + // This is the class declaration containing the constructor. + addReferences(findOwnConstructorCalls(searchSymbol)); } - return; - - /* If we are just looking for implementations and this is a property access expression, we need to get the - * symbol of the local type of the symbol the property is being accessed on. This is because our search - * symbol may have a different parent symbol if the local type's symbol does not declare the property - * being accessed (i.e. it is declared in some parent class or interface) - */ - function getParentSymbolsOfPropertyAccess(): Symbol[] | undefined { - if (implementations) { - const propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); - if (propertyAccessExpression) { - const localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); - if (localParentType) { - if (localParentType.symbol && localParentType.symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) && localParentType.symbol !== searchSymbol.parent) { - return [localParentType.symbol]; - } - else if (localParentType.flags & TypeFlags.UnionOrIntersection) { - return getSymbolsForClassAndInterfaceComponents(localParentType); - } - } - } + else { + // If this class appears in `extends C`, then the extending class' "super" calls are references. + const classExtending = tryGetClassByExtendingIdentifier(referenceLocation); + if (classExtending && isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation, typeChecker) === searchSymbol) { + addReferences(superConstructorAccesses(classExtending)); } } + } - function getPropertyAccessExpressionFromRightHandSide(node: Node): PropertyAccessExpression { - return isRightSideOfPropertyAccess(node) && node.parent; + function addReferences(references: Node[]): void { + if (references.length) { + const referencedSymbol = getReferencedSymbol(searchSymbol); + addRange(referencedSymbol.references, map(references, getReferenceEntryFromNode)); + } + } + + /** `classSymbol` is the class where the constructor was defined. + * Reference the constructor and all calls to `new this()`. + */ + function findOwnConstructorCalls(classSymbol: Symbol): Node[] { + const result: Node[] = []; + + for (const decl of classSymbol.members.get("__constructor").declarations) { + const ctrKeyword = ts.findChildOfKind(decl, ts.SyntaxKind.ConstructorKeyword, sourceFile)! + Debug.assert(decl.kind === SyntaxKind.Constructor && !!ctrKeyword); + result.push(ctrKeyword); } - /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ - function findAdditionalConstructorReferences(referenceSymbol: Symbol, referenceLocation: Node): void { - Debug.assert(isClassLike(searchSymbol.valueDeclaration)); - - const referenceClass = referenceLocation.parent; - if (referenceSymbol === searchSymbol && isClassLike(referenceClass)) { - Debug.assert(referenceClass.name === referenceLocation); - // This is the class declaration containing the constructor. - addReferences(findOwnConstructorCalls(searchSymbol)); - } - else { - // If this class appears in `extends C`, then the extending class' "super" calls are references. - const classExtending = tryGetClassByExtendingIdentifier(referenceLocation); - if (classExtending && isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation) === searchSymbol) { - addReferences(superConstructorAccesses(classExtending)); - } - } - } - - function addReferences(references: Node[]): void { - if (references.length) { - const referencedSymbol = getReferencedSymbol(searchSymbol); - addRange(referencedSymbol.references, map(references, getReferenceEntryFromNode)); - } - } - - /** `classSymbol` is the class where the constructor was defined. - * Reference the constructor and all calls to `new this()`. - */ - function findOwnConstructorCalls(classSymbol: Symbol): Node[] { - const result: Node[] = []; - - for (const decl of classSymbol.members["__constructor"].declarations) { - Debug.assert(decl.kind === SyntaxKind.Constructor); - const ctrKeyword = decl.getChildAt(0); - Debug.assert(ctrKeyword.kind === SyntaxKind.ConstructorKeyword); - result.push(ctrKeyword); - } - - forEachProperty(classSymbol.exports, member => { - const decl = member.valueDeclaration; - if (decl && decl.kind === SyntaxKind.MethodDeclaration) { - const body = (decl).body; - if (body) { - forEachDescendantOfKind(body, SyntaxKind.ThisKeyword, thisKeyword => { - if (isNewExpressionTarget(thisKeyword)) { - result.push(thisKeyword); - } - }); - } - } - }); - - return result; - } - - /** Find references to `super` in the constructor of an extending class. */ - function superConstructorAccesses(cls: ClassLikeDeclaration): Node[] { - const symbol = cls.symbol; - const ctr = symbol.members["__constructor"]; - if (!ctr) { - return []; - } - - const result: Node[] = []; - for (const decl of ctr.declarations) { - Debug.assert(decl.kind === SyntaxKind.Constructor); - const body = (decl).body; + classSymbol.exports.forEach(member => { + const decl = member.valueDeclaration; + if (decl && decl.kind === SyntaxKind.MethodDeclaration) { + const body = (decl).body; if (body) { - forEachDescendantOfKind(body, SyntaxKind.SuperKeyword, node => { - if (isCallExpressionTarget(node)) { - result.push(node); + forEachDescendantOfKind(body, SyntaxKind.ThisKeyword, thisKeyword => { + if (isNewExpressionTarget(thisKeyword)) { + result.push(thisKeyword); } }); } - }; - return result; - } - - function getReferencedSymbol(symbol: Symbol): ReferencedSymbol { - const symbolId = getSymbolId(symbol); - let index = symbolToIndex[symbolId]; - if (index === undefined) { - index = result.length; - symbolToIndex[symbolId] = index; - - result.push({ - definition: getDefinition(symbol), - references: [] - }); } + }); - return result[index]; - } - - function addReferenceToRelatedSymbol(node: Node, relatedSymbol: Symbol) { - const references = getReferencedSymbol(relatedSymbol).references; - if (implementations) { - getImplementationReferenceEntryForNode(node, references); - } - else { - references.push(getReferenceEntryFromNode(node)); - } - } - } - - function getImplementationReferenceEntryForNode(refNode: Node, result: ReferenceEntry[]): void { - // Check if we found a function/propertyAssignment/method with an implementation or initializer - if (isDeclarationName(refNode) && isImplementation(refNode.parent)) { - result.push(getReferenceEntryFromNode(refNode.parent)); - } - else if (refNode.kind === SyntaxKind.Identifier) { - if (refNode.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { - // Go ahead and dereference the shorthand assignment by going to its definition - getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); - } - - // Check if the node is within an extends or implements clause - const containingClass = getContainingClassIfInHeritageClause(refNode); - if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); - return; - } - - // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface - const containingTypeReference = getContainingTypeReference(refNode); - if (containingTypeReference) { - const parent = containingTypeReference.parent; - if (isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent.initializer)); - } - else if (isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { - if (parent.body.kind === SyntaxKind.Block) { - forEachReturnStatement(parent.body, returnStatement => { - if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { - maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); - } - }); - } - else if (isImplementationExpression(parent.body)) { - maybeAdd(getReferenceEntryFromNode(parent.body)); - } - } - else if (isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { - maybeAdd(getReferenceEntryFromNode(parent.expression)); - } - } - } - - // Type nodes can contain multiple references to the same type. For example: - // let x: Foo & (Foo & Bar) = ... - // Because we are returning the implementation locations and not the identifier locations, - // duplicate entries would be returned here as each of the type references is part of - // the same implementation. For that reason, check before we add a new entry - function maybeAdd(a: ReferenceEntry) { - if (!forEach(result, b => a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length)) { - result.push(a); - } - } - } - - function getSymbolsForClassAndInterfaceComponents(type: UnionOrIntersectionType, result: Symbol[] = []): Symbol[] { - for (const componentType of type.types) { - if (componentType.symbol && componentType.symbol.getFlags() & (SymbolFlags.Class | SymbolFlags.Interface)) { - result.push(componentType.symbol); - } - if (componentType.getFlags() & TypeFlags.UnionOrIntersection) { - getSymbolsForClassAndInterfaceComponents(componentType, result); - } - } return result; } - function getContainingTypeReference(node: Node): Node { - let topLevelTypeReference: Node = undefined; - - while (node) { - if (isTypeNode(node)) { - topLevelTypeReference = node; - } - node = node.parent; + /** Find references to `super` in the constructor of an extending class. */ + function superConstructorAccesses(cls: ClassLikeDeclaration): Node[] { + const symbol = cls.symbol; + const ctr = symbol.members.get("__constructor"); + if (!ctr) { + return []; } - return topLevelTypeReference; + const result: Node[] = []; + for (const decl of ctr.declarations) { + Debug.assert(decl.kind === SyntaxKind.Constructor); + const body = (decl).body; + if (body) { + forEachDescendantOfKind(body, SyntaxKind.SuperKeyword, node => { + if (isCallExpressionTarget(node)) { + result.push(node); + } + }); + } + }; + return result; } - function getContainingClassIfInHeritageClause(node: Node): ClassLikeDeclaration { - if (node && node.parent) { - if (node.kind === SyntaxKind.ExpressionWithTypeArguments - && node.parent.kind === SyntaxKind.HeritageClause - && isClassLike(node.parent.parent)) { - return node.parent.parent; - } + function getReferencedSymbol(symbol: Symbol): ReferencedSymbol { + const symbolId = getSymbolId(symbol); + let index = symbolToIndex[symbolId]; + if (index === undefined) { + index = result.length; + symbolToIndex[symbolId] = index; - else if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.PropertyAccessExpression) { - return getContainingClassIfInHeritageClause(node.parent); + result.push({ + definition: getDefinition(symbol, searchLocation, typeChecker), + references: [] + }); + } + + return result[index]; + } + + function addReferenceToRelatedSymbol(node: Node, relatedSymbol: Symbol) { + const references = getReferencedSymbol(relatedSymbol).references; + if (implementations) { + getImplementationReferenceEntryForNode(node, references, typeChecker); + } + else { + references.push(getReferenceEntryFromNode(node)); + } + } + } + + function getImplementationReferenceEntryForNode(refNode: Node, result: ReferenceEntry[], typeChecker: TypeChecker): void { + // Check if we found a function/propertyAssignment/method with an implementation or initializer + if (isDeclarationName(refNode) && isImplementation(refNode.parent)) { + result.push(getReferenceEntryFromNode(refNode.parent)); + } + else if (refNode.kind === SyntaxKind.Identifier) { + if (refNode.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { + // Go ahead and dereference the shorthand assignment by going to its definition + getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); + } + + // Check if the node is within an extends or implements clause + const containingClass = getContainingClassIfInHeritageClause(refNode); + if (containingClass) { + result.push(getReferenceEntryFromNode(containingClass)); + return; + } + + // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface + const containingTypeReference = getContainingTypeReference(refNode); + if (containingTypeReference) { + const parent = containingTypeReference.parent; + if (isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent.initializer)); + } + else if (isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { + if (parent.body.kind === SyntaxKind.Block) { + forEachReturnStatement(parent.body, returnStatement => { + if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { + maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); + } + }); + } + else if (isImplementationExpression(parent.body)) { + maybeAdd(getReferenceEntryFromNode(parent.body)); + } + } + else if (isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { + maybeAdd(getReferenceEntryFromNode(parent.expression)); } } - return undefined; } - /** - * Returns true if this is an expression that can be considered an implementation - */ - function isImplementationExpression(node: Expression): boolean { - // Unwrap parentheses - if (node.kind === SyntaxKind.ParenthesizedExpression) { + // Type nodes can contain multiple references to the same type. For example: + // let x: Foo & (Foo & Bar) = ... + // Because we are returning the implementation locations and not the identifier locations, + // duplicate entries would be returned here as each of the type references is part of + // the same implementation. For that reason, check before we add a new entry + function maybeAdd(a: ReferenceEntry) { + if (!forEach(result, b => a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length)) { + result.push(a); + } + } + } + + function getSymbolsForClassAndInterfaceComponents(type: UnionOrIntersectionType, result: Symbol[] = []): Symbol[] { + for (const componentType of type.types) { + if (componentType.symbol && componentType.symbol.getFlags() & (SymbolFlags.Class | SymbolFlags.Interface)) { + result.push(componentType.symbol); + } + if (componentType.getFlags() & TypeFlags.UnionOrIntersection) { + getSymbolsForClassAndInterfaceComponents(componentType, result); + } + } + return result; + } + + function getContainingTypeReference(node: Node): Node { + let topLevelTypeReference: Node = undefined; + + while (node) { + if (isTypeNode(node)) { + topLevelTypeReference = node; + } + node = node.parent; + } + + return topLevelTypeReference; + } + + function getContainingClassIfInHeritageClause(node: Node): ClassLikeDeclaration { + if (node && node.parent) { + if (node.kind === SyntaxKind.ExpressionWithTypeArguments + && node.parent.kind === SyntaxKind.HeritageClause + && isClassLike(node.parent.parent)) { + return node.parent.parent; + } + + else if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.PropertyAccessExpression) { + return getContainingClassIfInHeritageClause(node.parent); + } + } + return undefined; + } + + /** + * Returns true if this is an expression that can be considered an implementation + */ + function isImplementationExpression(node: Expression): boolean { + switch (node.kind) { + case SyntaxKind.ParenthesizedExpression: return isImplementationExpression((node).expression); + case SyntaxKind.ArrowFunction: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ObjectLiteralExpression: + case SyntaxKind.ClassExpression: + case SyntaxKind.ArrayLiteralExpression: + return true; + default: + return false; + } + } + + /** + * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol + * is an interface, determines if some ancestor of the child symbol extends or inherits from it. + * Also takes in a cache of previous results which makes this slightly more efficient and is + * necessary to avoid potential loops like so: + * class A extends B { } + * class B extends A { } + * + * We traverse the AST rather than using the type checker because users are typically only interested + * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling + * implementations of types that share a common ancestor with the type whose implementation we are + * searching for need to be filtered out of the results. The type checker doesn't let us make the + * distinction between structurally compatible implementations and explicit implementations, so we + * must use the AST. + * + * @param child A class or interface Symbol + * @param parent Another class or interface Symbol + * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results + */ + function explicitlyInheritsFrom(child: Symbol, parent: Symbol, cachedResults: Map, typeChecker: TypeChecker): boolean { + const parentIsInterface = parent.getFlags() & SymbolFlags.Interface; + return searchHierarchy(child); + + function searchHierarchy(symbol: Symbol): boolean { + if (symbol === parent) { + return true; } - return node.kind === SyntaxKind.ArrowFunction || - node.kind === SyntaxKind.FunctionExpression || - node.kind === SyntaxKind.ObjectLiteralExpression || - node.kind === SyntaxKind.ClassExpression || - node.kind === SyntaxKind.ArrayLiteralExpression; - } + const key = getSymbolId(symbol) + "," + getSymbolId(parent); + const cached = cachedResults.get(key); + if (cached !== undefined) { + return cached; + } - /** - * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol - * is an interface, determines if some ancestor of the child symbol extends or inherits from it. - * Also takes in a cache of previous results which makes this slightly more efficient and is - * necessary to avoid potential loops like so: - * class A extends B { } - * class B extends A { } - * - * We traverse the AST rather than using the type checker because users are typically only interested - * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling - * implementations of types that share a common ancestor with the type whose implementation we are - * searching for need to be filtered out of the results. The type checker doesn't let us make the - * distinction between structurally compatible implementations and explicit implementations, so we - * must use the AST. - * - * @param child A class or interface Symbol - * @param parent Another class or interface Symbol - * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results - */ - function explicitlyInheritsFrom(child: Symbol, parent: Symbol, cachedResults: Map): boolean { - const parentIsInterface = parent.getFlags() & SymbolFlags.Interface; - return searchHierarchy(child); + // Set the key so that we don't infinitely recurse + cachedResults.set(key, false); - function searchHierarchy(symbol: Symbol): boolean { - if (symbol === parent) { - return true; - } - - const key = getSymbolId(symbol) + "," + getSymbolId(parent); - if (key in cachedResults) { - return cachedResults[key]; - } - - // Set the key so that we don't infinitely recurse - cachedResults[key] = false; - - const inherits = forEach(symbol.getDeclarations(), declaration => { - if (isClassLike(declaration)) { - if (parentIsInterface) { - const interfaceReferences = getClassImplementsHeritageClauseElements(declaration); - if (interfaceReferences) { - for (const typeReference of interfaceReferences) { - if (searchTypeReference(typeReference)) { - return true; - } + const inherits = forEach(symbol.getDeclarations(), declaration => { + if (isClassLike(declaration)) { + if (parentIsInterface) { + const interfaceReferences = getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (const typeReference of interfaceReferences) { + if (searchTypeReference(typeReference)) { + return true; } } } - return searchTypeReference(getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === SyntaxKind.InterfaceDeclaration) { - if (parentIsInterface) { - return forEach(getInterfaceBaseTypeNodes(declaration), searchTypeReference); - } - } - return false; - }); - - cachedResults[key] = inherits; - return inherits; - } - - function searchTypeReference(typeReference: ExpressionWithTypeArguments): boolean { - if (typeReference) { - const type = typeChecker.getTypeAtLocation(typeReference); - if (type && type.symbol) { - return searchHierarchy(type.symbol); + return searchTypeReference(getClassExtendsHeritageClauseElement(declaration)); + } + else if (declaration.kind === SyntaxKind.InterfaceDeclaration) { + if (parentIsInterface) { + return forEach(getInterfaceBaseTypeNodes(declaration), searchTypeReference); } } return false; - } + }); + + cachedResults.set(key, inherits); + return inherits; } - function getReferencesForSuperKeyword(superKeyword: Node): ReferencedSymbol[] { - let searchSpaceNode = getSuperContainer(superKeyword, /*stopOnFunctions*/ false); - if (!searchSpaceNode) { + function searchTypeReference(typeReference: ExpressionWithTypeArguments): boolean { + if (typeReference) { + const type = typeChecker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol); + } + } + return false; + } + } + + function getReferencesForSuperKeyword(superKeyword: Node, typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] { + let searchSpaceNode = getSuperContainer(superKeyword, /*stopOnFunctions*/ false); + if (!searchSpaceNode) { + return undefined; + } + // Whether 'super' occurs in a static context within a class. + let staticFlag = ModifierFlags.Static; + + switch (searchSpaceNode.kind) { + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.Constructor: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + staticFlag &= getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + default: return undefined; - } - // Whether 'super' occurs in a static context within a class. - let staticFlag = ModifierFlags.Static; + } - switch (searchSpaceNode.kind) { - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.Constructor: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - staticFlag &= getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + const references: ReferenceEntry[] = []; + + const sourceFile = searchSpaceNode.getSourceFile(); + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + forEach(possiblePositions, position => { + cancellationToken.throwIfCancellationRequested(); + + const node = getTouchingWord(sourceFile, position); + + if (!node || node.kind !== SyntaxKind.SuperKeyword) { + return; + } + + const container = getSuperContainer(node, /*stopOnFunctions*/ false); + + // If we have a 'super' container, we must have an enclosing class. + // Now make sure the owning class is the same as the search-space + // and has the same static qualifier as the original 'super's owner. + if (container && (ModifierFlags.Static & getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(getReferenceEntryFromNode(node)); + } + }); + + const definition = getDefinition(searchSpaceNode.symbol, superKeyword, typeChecker); + return [{ definition, references }]; + } + + function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: SourceFile[], typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] { + let searchSpaceNode = getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); + + // Whether 'this' occurs in a static context within a class. + let staticFlag = ModifierFlags.Static; + + switch (searchSpaceNode.kind) { + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + if (isObjectLiteralMethod(searchSpaceNode)) { break; - default: + } + // fall through + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.Constructor: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + staticFlag &= getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + case SyntaxKind.SourceFile: + if (isExternalModule(searchSpaceNode)) { return undefined; - } + } + // Fall through + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.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. + default: + return undefined; + } - const references: ReferenceEntry[] = []; + const references: ReferenceEntry[] = []; + let possiblePositions: number[]; + if (searchSpaceNode.kind === SyntaxKind.SourceFile) { + forEach(sourceFiles, sourceFile => { + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); + } + else { const sourceFile = searchSpaceNode.getSourceFile(); - const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + } + + const thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); + + const displayParts = thisOrSuperSymbol && SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind( + typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; + + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: thisOrSuperKeyword.getSourceFile().fileName, + kind: ScriptElementKind.variableElement, + name: "this", + textSpan: createTextSpanFromNode(thisOrSuperKeyword), + displayParts + }, + references: references + }]; + + function getThisReferencesInFile(sourceFile: SourceFile, searchSpaceNode: Node, possiblePositions: number[], result: ReferenceEntry[]): void { forEach(possiblePositions, position => { cancellationToken.throwIfCancellationRequested(); const node = getTouchingWord(sourceFile, position); - - if (!node || node.kind !== SyntaxKind.SuperKeyword) { + if (!node || !isThis(node)) { return; } - const container = getSuperContainer(node, /*stopOnFunctions*/ false); + const container = getThisContainer(node, /* includeArrowFunctions */ false); - // If we have a 'super' container, we must have an enclosing class. - // Now make sure the owning class is the same as the search-space - // and has the same static qualifier as the original 'super's owner. - if (container && (ModifierFlags.Static & getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); - } - }); - - const definition = getDefinition(searchSpaceNode.symbol); - return [{ definition, references }]; - } - - function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: SourceFile[]): ReferencedSymbol[] { - let searchSpaceNode = getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); - - // Whether 'this' occurs in a static context within a class. - let staticFlag = ModifierFlags.Static; - - switch (searchSpaceNode.kind) { - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - if (isObjectLiteralMethod(searchSpaceNode)) { + switch (searchSpaceNode.kind) { + case SyntaxKind.FunctionExpression: + case SyntaxKind.FunctionDeclaration: + if (searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + if (isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case SyntaxKind.ClassExpression: + case SyntaxKind.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 && (getModifierFlags(container) & ModifierFlags.Static) === staticFlag) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case SyntaxKind.SourceFile: + if (container.kind === SyntaxKind.SourceFile && !isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); + } break; - } - // fall through - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - case SyntaxKind.Constructor: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - staticFlag &= getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class - break; - case SyntaxKind.SourceFile: - if (isExternalModule(searchSpaceNode)) { - return undefined; - } - // Fall through - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.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. - default: - return undefined; - } - - const references: ReferenceEntry[] = []; - - let possiblePositions: number[]; - if (searchSpaceNode.kind === SyntaxKind.SourceFile) { - forEach(sourceFiles, sourceFile => { - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); - }); - } - else { - const sourceFile = searchSpaceNode.getSourceFile(); - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); - } - - const thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); - - const displayParts = thisOrSuperSymbol && SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind( - typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; - - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ScriptElementKind.variableElement, - name: "this", - textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts - }, - references: references - }]; - - function getThisReferencesInFile(sourceFile: SourceFile, searchSpaceNode: Node, possiblePositions: number[], result: ReferenceEntry[]): void { - forEach(possiblePositions, position => { - cancellationToken.throwIfCancellationRequested(); - - const node = getTouchingWord(sourceFile, position); - if (!node || !isThis(node)) { - return; - } - - const container = getThisContainer(node, /* includeArrowFunctions */ false); - - switch (searchSpaceNode.kind) { - case SyntaxKind.FunctionExpression: - case SyntaxKind.FunctionDeclaration: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - if (isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case SyntaxKind.ClassExpression: - case SyntaxKind.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 && (getModifierFlags(container) & ModifierFlags.Static) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case SyntaxKind.SourceFile: - if (container.kind === SyntaxKind.SourceFile && !isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); - } - } - - - function getReferencesForStringLiteral(node: StringLiteral, sourceFiles: SourceFile[]): ReferencedSymbol[] { - const type = getStringLiteralTypeForNode(node, typeChecker); - - if (!type) { - // nothing to do here. moving on - return undefined; - } - - const references: ReferenceEntry[] = []; - - for (const sourceFile of sourceFiles) { - const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd()); - getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); - } - - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ScriptElementKind.variableElement, - name: type.text, - textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: [displayPart(getTextOfNode(node), SymbolDisplayPartKind.stringLiteral)] - }, - references: references - }]; - - function getReferencesForStringLiteralInFile(sourceFile: SourceFile, searchType: Type, possiblePositions: number[], references: ReferenceEntry[]): void { - for (const position of possiblePositions) { - cancellationToken.throwIfCancellationRequested(); - - const node = getTouchingWord(sourceFile, position); - if (!node || node.kind !== SyntaxKind.StringLiteral) { - return; - } - - const type = getStringLiteralTypeForNode(node, typeChecker); - if (type === searchType) { - references.push(getReferenceEntryFromNode(node)); - } - } - } - } - - function populateSearchSymbolSet(symbol: Symbol, location: Node): Symbol[] { - // The search set contains at least the current symbol - let result = [symbol]; - - // If the location is name of property symbol from object literal destructuring pattern - // Search the property symbol - // for ( { property: p2 } of elems) { } - const containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== SyntaxKind.ShorthandPropertyAssignment) { - const propertySymbol = getPropertySymbolOfDestructuringAssignment(location); - if (propertySymbol) { - result.push(propertySymbol); - } - } - - // If the symbol is an alias, add what it aliases to the list - // import {a} from "mod"; - // export {a} - // If the symbol is an alias to default declaration, add what it aliases to the list - // declare "mod" { export default class B { } } - // import B from "mod"; - //// For export specifiers, the exported name can be referring to a local symbol, e.g.: - //// import {a} from "mod"; - //// export {a as somethingElse} - //// We want the *local* declaration of 'a' as declared in the import, - //// *not* as declared within "mod" (or farther) - const aliasSymbol = getAliasSymbolForPropertyNameSymbol(symbol, location); - if (aliasSymbol) { - result = result.concat(populateSearchSymbolSet(aliasSymbol, location)); - } - - // If the location is in a context sensitive location (i.e. in an object literal) try - // to get a contextual type for it, and add the property symbol from the contextual - // type to the search set - if (containingObjectLiteralElement) { - forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), contextualSymbol => { - addRange(result, typeChecker.getRootSymbols(contextualSymbol)); - }); - - /* Because in short-hand property assignment, location has two meaning : property name and as value of the property - * When we do findAllReference at the position of the short-hand property assignment, we would want to have references to position of - * property name and variable declaration of the identifier. - * Like in below example, when querying for all references for an identifier 'name', of the property assignment, the language service - * should show both 'name' in 'obj' and 'name' in variable declaration - * const name = "Foo"; - * const obj = { name }; - * In order to do that, we will populate the search set with the value symbol of the identifier as a value of the property assignment - * so that when matching with potential reference symbol, both symbols from property declaration and variable declaration - * will be included correctly. - */ - const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); - if (shorthandValueSymbol) { - result.push(shorthandValueSymbol); - } - } - - // If the symbol.valueDeclaration is a property parameter declaration, - // we should include both parameter declaration symbol and property declaration symbol - // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. - // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.Parameter && - isParameterPropertyDeclaration(symbol.valueDeclaration)) { - result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); - } - - // If this is symbol of binding element without propertyName declaration in Object binding pattern - // Include the property in the search - const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol); - if (bindingElementPropertySymbol) { - result.push(bindingElementPropertySymbol); - } - - // If this is a union property, add all the symbols from all its source symbols in all unioned types. - // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list - forEach(typeChecker.getRootSymbols(symbol), rootSymbol => { - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - - // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap()); } }); - - return result; } + } - /** - * Find symbol of the given property-name and add the symbol to the given result array - * @param symbol a symbol to start searching for the given propertyName - * @param propertyName a name of property to search for - * @param result an array of symbol of found property symbols - * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. - * The value of previousIterationSymbol is undefined when the function is first called. - */ - function getPropertySymbolsFromBaseTypes(symbol: Symbol, propertyName: string, result: Symbol[], - previousIterationSymbolsCache: SymbolTable): void { - if (!symbol) { - return; - } + function getReferencesForStringLiteral(node: StringLiteral, sourceFiles: SourceFile[], typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] { + const type = getStringLiteralTypeForNode(node, typeChecker); - // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited - // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. - // For example: - // interface C extends C { - // /*findRef*/propName: string; - // } - // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, - // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, - // the function will add any found symbol of the property-name, then its sub-routine will call - // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already - // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. - if (symbol.name in previousIterationSymbolsCache) { - return; - } - - if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - forEach(symbol.getDeclarations(), declaration => { - if (isClassLike(declaration)) { - getPropertySymbolFromTypeReference(getClassExtendsHeritageClauseElement(declaration)); - forEach(getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === SyntaxKind.InterfaceDeclaration) { - forEach(getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); - } - }); - } - return; - - function getPropertySymbolFromTypeReference(typeReference: ExpressionWithTypeArguments) { - if (typeReference) { - const type = typeChecker.getTypeAtLocation(typeReference); - if (type) { - const propertySymbol = typeChecker.getPropertyOfType(type, propertyName); - if (propertySymbol) { - result.push(...typeChecker.getRootSymbols(propertySymbol)); - } - - // Visit the typeReference as well to see if it directly or indirectly use that property - previousIterationSymbolsCache[symbol.name] = symbol; - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache); - } - } - } - } - - function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node, searchLocationIsConstructor: boolean, parents: Symbol[] | undefined, cache: Map): Symbol { - if (contains(searchSymbols, referenceSymbol)) { - // If we are searching for constructor uses, they must be 'new' expressions. - return (!searchLocationIsConstructor || isNewExpressionTarget(referenceLocation)) && referenceSymbol; - } - - // If the reference symbol is an alias, check if what it is aliasing is one of the search - // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. - const aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation); - if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache); - } - - // If the reference location is in an object literal, try to get the contextual type for the - // object literal, lookup the property symbol in the contextual type, and use this symbol to - // compare to our searchSymbol - const containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation); - if (containingObjectLiteralElement) { - const contextualSymbol = forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), contextualSymbol => { - return forEach(typeChecker.getRootSymbols(contextualSymbol), s => searchSymbols.indexOf(s) >= 0 ? s : undefined); - }); - - if (contextualSymbol) { - return contextualSymbol; - } - - // If the reference location is the name of property from object literal destructuring pattern - // Get the property symbol from the object literal's type and look if thats the search symbol - // In below eg. get 'property' from type of elems iterating type - // for ( { property: p2 } of elems) { } - const propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation); - if (propertySymbol && searchSymbols.indexOf(propertySymbol) >= 0) { - return propertySymbol; - } - } - - // If the reference location is the binding element and doesn't have property name - // then include the binding element in the related symbols - // let { a } : { a }; - const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol); - if (bindingElementPropertySymbol && searchSymbols.indexOf(bindingElementPropertySymbol) >= 0) { - return bindingElementPropertySymbol; - } - - // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) - // Or a union property, use its underlying unioned symbols - return forEach(typeChecker.getRootSymbols(referenceSymbol), rootSymbol => { - // if it is in the list, then we are done - if (searchSymbols.indexOf(rootSymbol) >= 0) { - return rootSymbol; - } - - // Finally, try all properties with the same name in any type the containing type extended or implemented, and - // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the - // parent symbol - if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - // Parents will only be defined if implementations is true - if (parents) { - if (!forEach(parents, parent => explicitlyInheritsFrom(rootSymbol.parent, parent, cache))) { - return undefined; - } - } - - const result: Symbol[] = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap()); - return forEach(result, s => searchSymbols.indexOf(s) >= 0 ? s : undefined); - } - - return undefined; - }); - } - - function getNameFromObjectLiteralElement(node: ObjectLiteralElement) { - if (node.name.kind === SyntaxKind.ComputedPropertyName) { - const nameExpression = (node.name).expression; - // treat computed property names where expression is string/numeric literal as just string/numeric literal - if (isStringOrNumericLiteral(nameExpression)) { - return (nameExpression).text; - } - return undefined; - } - return (node.name).text; - } - - function getPropertySymbolsFromContextualType(node: ObjectLiteralElement): Symbol[] { - const objectLiteral = node.parent; - const contextualType = typeChecker.getContextualType(objectLiteral); - const name = getNameFromObjectLiteralElement(node); - if (name && contextualType) { - const result: Symbol[] = []; - const symbol = contextualType.getProperty(name); - if (symbol) { - result.push(symbol); - } - - if (contextualType.flags & TypeFlags.Union) { - forEach((contextualType).types, t => { - const symbol = t.getProperty(name); - if (symbol) { - result.push(symbol); - } - }); - } - return result; - } + if (!type) { + // nothing to do here. moving on return undefined; } - /** Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations - * of the corresponding symbol. e.g. if we are searching for "Foo" in value position, but "Foo" references a class - * then we need to widen the search to include type positions as well. - * On the contrary, if we are searching for "Bar" in type position and we trace bar to an interface, and an uninstantiated - * module, we want to keep the search limited to only types, as the two declarations (interface and uninstantiated module) - * do not intersect in any of the three spaces. - */ - function getIntersectingMeaningFromDeclarations(meaning: SemanticMeaning, declarations: Declaration[]): SemanticMeaning { - if (declarations) { - let lastIterationMeaning: SemanticMeaning; - do { - // The result is order-sensitive, for instance if initialMeaning === Namespace, and declarations = [class, instantiated module] - // we need to consider both as they initialMeaning intersects with the module in the namespace space, and the module - // intersects with the class in the value space. - // To achieve that we will keep iterating until the result stabilizes. + const references: ReferenceEntry[] = []; - // Remember the last meaning - lastIterationMeaning = meaning; + for (const sourceFile of sourceFiles) { + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); + } - for (const declaration of declarations) { - const declarationMeaning = getMeaningFromDeclaration(declaration); + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ScriptElementKind.variableElement, + name: type.text, + textSpan: createTextSpanFromNode(node), + displayParts: [displayPart(getTextOfNode(node), SymbolDisplayPartKind.stringLiteral)] + }, + references: references + }]; - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; - } + function getReferencesForStringLiteralInFile(sourceFile: SourceFile, searchType: Type, possiblePositions: number[], references: ReferenceEntry[]): void { + for (const position of possiblePositions) { + cancellationToken.throwIfCancellationRequested(); + + const node = getTouchingWord(sourceFile, position); + if (!node || node.kind !== SyntaxKind.StringLiteral) { + return; + } + + const type = getStringLiteralTypeForNode(node, typeChecker); + if (type === searchType) { + references.push(getReferenceEntryFromNode(node)); + } + } + } + } + + function populateSearchSymbolSet(symbol: Symbol, location: Node, typeChecker: TypeChecker, implementations: boolean): Symbol[] { + // The search set contains at least the current symbol + let result = [symbol]; + + // If the location is name of property symbol from object literal destructuring pattern + // Search the property symbol + // for ( { property: p2 } of elems) { } + const containingObjectLiteralElement = getContainingObjectLiteralElement(location); + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== SyntaxKind.ShorthandPropertyAssignment) { + const propertySymbol = getPropertySymbolOfDestructuringAssignment(location, typeChecker); + if (propertySymbol) { + result.push(propertySymbol); + } + } + + // If the symbol is an alias, add what it aliases to the list + // import {a} from "mod"; + // export {a} + // If the symbol is an alias to default declaration, add what it aliases to the list + // declare "mod" { export default class B { } } + // import B from "mod"; + //// For export specifiers, the exported name can be referring to a local symbol, e.g.: + //// import {a} from "mod"; + //// export {a as somethingElse} + //// We want the *local* declaration of 'a' as declared in the import, + //// *not* as declared within "mod" (or farther) + const aliasSymbol = getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker); + if (aliasSymbol) { + result = result.concat(populateSearchSymbolSet(aliasSymbol, location, typeChecker, implementations)); + } + + // If the location is in a context sensitive location (i.e. in an object literal) try + // to get a contextual type for it, and add the property symbol from the contextual + // type to the search set + if (containingObjectLiteralElement) { + forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), contextualSymbol => { + addRange(result, typeChecker.getRootSymbols(contextualSymbol)); + }); + + /* Because in short-hand property assignment, location has two meaning : property name and as value of the property + * When we do findAllReference at the position of the short-hand property assignment, we would want to have references to position of + * property name and variable declaration of the identifier. + * Like in below example, when querying for all references for an identifier 'name', of the property assignment, the language service + * should show both 'name' in 'obj' and 'name' in variable declaration + * const name = "Foo"; + * const obj = { name }; + * In order to do that, we will populate the search set with the value symbol of the identifier as a value of the property assignment + * so that when matching with potential reference symbol, both symbols from property declaration and variable declaration + * will be included correctly. + */ + const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); + if (shorthandValueSymbol) { + result.push(shorthandValueSymbol); + } + } + + // If the symbol.valueDeclaration is a property parameter declaration, + // we should include both parameter declaration symbol and property declaration symbol + // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. + // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.Parameter && + isParameterPropertyDeclaration(symbol.valueDeclaration)) { + result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); + } + + // If this is symbol of binding element without propertyName declaration in Object binding pattern + // Include the property in the search + const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker); + if (bindingElementPropertySymbol) { + result.push(bindingElementPropertySymbol); + } + + // If this is a union property, add all the symbols from all its source symbols in all unioned types. + // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list + forEach(typeChecker.getRootSymbols(symbol), rootSymbol => { + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + + // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap(), typeChecker); + } + }); + + return result; + } + + /** + * Find symbol of the given property-name and add the symbol to the given result array + * @param symbol a symbol to start searching for the given propertyName + * @param propertyName a name of property to search for + * @param result an array of symbol of found property symbols + * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. + * The value of previousIterationSymbol is undefined when the function is first called. + */ + function getPropertySymbolsFromBaseTypes(symbol: Symbol, propertyName: string, result: Symbol[], + previousIterationSymbolsCache: SymbolTable, typeChecker: TypeChecker): void { + if (!symbol) { + return; + } + + // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited + // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. + // For example: + // interface C extends C { + // /*findRef*/propName: string; + // } + // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, + // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, + // the function will add any found symbol of the property-name, then its sub-routine will call + // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already + // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. + if (previousIterationSymbolsCache.has(symbol.name)) { + return; + } + + if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + forEach(symbol.getDeclarations(), declaration => { + if (isClassLike(declaration)) { + getPropertySymbolFromTypeReference(getClassExtendsHeritageClauseElement(declaration)); + forEach(getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === SyntaxKind.InterfaceDeclaration) { + forEach(getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); + } + }); + } + return; + + function getPropertySymbolFromTypeReference(typeReference: ExpressionWithTypeArguments) { + if (typeReference) { + const type = typeChecker.getTypeAtLocation(typeReference); + if (type) { + const propertySymbol = typeChecker.getPropertyOfType(type, propertyName); + if (propertySymbol) { + result.push(...typeChecker.getRootSymbols(propertySymbol)); + } + + // Visit the typeReference as well to see if it directly or indirectly use that property + previousIterationSymbolsCache.set(symbol.name, symbol); + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, typeChecker); + } + } + } + } + + function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node, searchLocationIsConstructor: boolean, parents: Symbol[] | undefined, cache: Map, typeChecker: TypeChecker): Symbol { + if (contains(searchSymbols, referenceSymbol)) { + // If we are searching for constructor uses, they must be 'new' expressions. + return (!searchLocationIsConstructor || isNewExpressionTarget(referenceLocation)) && referenceSymbol; + } + + // If the reference symbol is an alias, check if what it is aliasing is one of the search + // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. + const aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation, typeChecker); + if (aliasSymbol) { + return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker); + } + + // If the reference location is in an object literal, try to get the contextual type for the + // object literal, lookup the property symbol in the contextual type, and use this symbol to + // compare to our searchSymbol + const containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation); + if (containingObjectLiteralElement) { + const contextualSymbol = forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), contextualSymbol => { + return forEach(typeChecker.getRootSymbols(contextualSymbol), s => searchSymbols.indexOf(s) >= 0 ? s : undefined); + }); + + if (contextualSymbol) { + return contextualSymbol; + } + + // If the reference location is the name of property from object literal destructuring pattern + // Get the property symbol from the object literal's type and look if thats the search symbol + // In below eg. get 'property' from type of elems iterating type + // for ( { property: p2 } of elems) { } + const propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, typeChecker); + if (propertySymbol && searchSymbols.indexOf(propertySymbol) >= 0) { + return propertySymbol; + } + } + + // If the reference location is the binding element and doesn't have property name + // then include the binding element in the related symbols + // let { a } : { a }; + const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, typeChecker); + if (bindingElementPropertySymbol && searchSymbols.indexOf(bindingElementPropertySymbol) >= 0) { + return bindingElementPropertySymbol; + } + + // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) + // Or a union property, use its underlying unioned symbols + return forEach(typeChecker.getRootSymbols(referenceSymbol), rootSymbol => { + // if it is in the list, then we are done + if (searchSymbols.indexOf(rootSymbol) >= 0) { + return rootSymbol; + } + + // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the + // parent symbol + if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + // Parents will only be defined if implementations is true + if (parents) { + if (!forEach(parents, parent => explicitlyInheritsFrom(rootSymbol.parent, parent, cache, typeChecker))) { + return undefined; } } - while (meaning !== lastIterationMeaning); + + const result: Symbol[] = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap(), typeChecker); + return forEach(result, s => searchSymbols.indexOf(s) >= 0 ? s : undefined); } - return meaning; + + return undefined; + }); + } + + function getNameFromObjectLiteralElement(node: ObjectLiteralElement) { + if (node.name.kind === SyntaxKind.ComputedPropertyName) { + const nameExpression = (node.name).expression; + // treat computed property names where expression is string/numeric literal as just string/numeric literal + if (isStringOrNumericLiteral(nameExpression)) { + return (nameExpression).text; + } + return undefined; } + return (node.name).text; + } + + function getPropertySymbolsFromContextualType(node: ObjectLiteralElement, typeChecker: TypeChecker): Symbol[] { + const objectLiteral = node.parent; + const contextualType = typeChecker.getContextualType(objectLiteral); + const name = getNameFromObjectLiteralElement(node); + if (name && contextualType) { + const result: Symbol[] = []; + const symbol = contextualType.getProperty(name); + if (symbol) { + result.push(symbol); + } + + if (contextualType.flags & TypeFlags.Union) { + forEach((contextualType).types, t => { + const symbol = t.getProperty(name); + if (symbol) { + result.push(symbol); + } + }); + } + return result; + } + return undefined; + } + + /** + * Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations + * of the corresponding symbol. e.g. if we are searching for "Foo" in value position, but "Foo" references a class + * then we need to widen the search to include type positions as well. + * On the contrary, if we are searching for "Bar" in type position and we trace bar to an interface, and an uninstantiated + * module, we want to keep the search limited to only types, as the two declarations (interface and uninstantiated module) + * do not intersect in any of the three spaces. + */ + function getIntersectingMeaningFromDeclarations(meaning: SemanticMeaning, declarations: Declaration[]): SemanticMeaning { + if (declarations) { + let lastIterationMeaning: SemanticMeaning; + do { + // The result is order-sensitive, for instance if initialMeaning === Namespace, and declarations = [class, instantiated module] + // we need to consider both as they initialMeaning intersects with the module in the namespace space, and the module + // intersects with the class in the value space. + // To achieve that we will keep iterating until the result stabilizes. + + // Remember the last meaning + lastIterationMeaning = meaning; + + for (const declaration of declarations) { + const declarationMeaning = getMeaningFromDeclaration(declaration); + + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } + while (meaning !== lastIterationMeaning); + } + return meaning; } export function convertReferences(referenceSymbols: ReferencedSymbol[]): ReferenceEntry[] { diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 8350b2a8dc8..201d64e4d7e 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -494,14 +494,26 @@ namespace ts.formatting { case SyntaxKind.WhileKeyword: case SyntaxKind.AtToken: return indentation; + case SyntaxKind.SlashToken: + case SyntaxKind.GreaterThanToken: { + if (container.kind === SyntaxKind.JsxOpeningElement || + container.kind === SyntaxKind.JsxClosingElement || + container.kind === SyntaxKind.JsxSelfClosingElement + ) { + return indentation; + } + break; + } case SyntaxKind.OpenBracketToken: - case SyntaxKind.CloseBracketToken: - return (container.kind === SyntaxKind.MappedType) ? - indentation + getEffectiveDelta(delta, container) : indentation; - default: - // if token line equals to the line of containing node (this is a first token in the node) - use node indentation - return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; + case SyntaxKind.CloseBracketToken: { + if (container.kind !== SyntaxKind.MappedType) { + return indentation; + } + break; + } } + // if token line equals to the line of containing node (this is a first token in the node) - use node indentation + return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; }, getIndentation: () => indentation, getDelta: child => getEffectiveDelta(delta, child), @@ -952,7 +964,7 @@ namespace ts.formatting { // shift all parts on the delta size const delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (let i = startIndex, len = parts.length; i < len; i++ , startLine++) { + for (let i = startIndex; i < parts.length; i++ , startLine++) { const startLinePos = getStartPositionOfLine(startLine, sourceFile); const nonWhitespaceCharacterAndColumn = i === 0 diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index db25ce0dcb8..b182b8e01f3 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -4,7 +4,7 @@ namespace ts.formatting { export class Rules { public getRuleName(rule: Rule) { - const o: ts.Map = this; + const o: ts.MapLike = this; for (const name in o) { if (o[name] === rule) { return name; @@ -245,6 +245,9 @@ namespace ts.formatting { public NoSpaceAfterTypeAssertion: Rule; public SpaceAfterTypeAssertion: Rule; + // No space before non-null assertion operator + public NoSpaceBeforeNonNullAssertionOperator: Rule; + constructor() { /// /// Common Rules @@ -264,12 +267,12 @@ namespace ts.formatting { this.SpaceAfterSemicolon = new Rule(RuleDescriptor.create3(SyntaxKind.SemicolonToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); // Space after }. - this.SpaceAfterCloseBrace = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), RuleAction.Space)); + this.SpaceAfterCloseBrace = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBraceToken, Shared.TokenRange.FromRange(SyntaxKind.FirstToken, SyntaxKind.LastToken, [SyntaxKind.CloseParenToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), RuleAction.Space)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied this.SpaceBetweenCloseBraceAndElse = new Rule(RuleDescriptor.create1(SyntaxKind.CloseBraceToken, SyntaxKind.ElseKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); this.SpaceBetweenCloseBraceAndWhile = new Rule(RuleDescriptor.create1(SyntaxKind.CloseBraceToken, SyntaxKind.WhileKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); - this.NoSpaceAfterCloseBrace = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBraceToken, Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.CloseBracketToken, SyntaxKind.CommaToken, SyntaxKind.SemicolonToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); + this.NoSpaceAfterCloseBrace = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBraceToken, Shared.TokenRange.FromTokens([SyntaxKind.CloseBracketToken, SyntaxKind.CommaToken, SyntaxKind.SemicolonToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); // No space for dot this.NoSpaceBeforeDot = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.DotToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); @@ -292,10 +295,10 @@ namespace ts.formatting { this.SpaceBeforeOpenBraceInControl = new Rule(RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSingleLineBlockContext), RuleAction.Space)); - this.SpaceBeforeCloseBrace = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSingleLineBlockContext), RuleAction.Space)); - this.NoSpaceAfterOpenBrace = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSingleLineBlockContext), RuleAction.Delete)); - this.NoSpaceBeforeCloseBrace = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSingleLineBlockContext), RuleAction.Delete)); + this.SpaceAfterOpenBrace = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsBraceWrappedContext), RuleAction.Space)); + this.SpaceBeforeCloseBrace = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsBraceWrappedContext), RuleAction.Space)); + this.NoSpaceAfterOpenBrace = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsBraceWrappedContext), RuleAction.Delete)); + this.NoSpaceBeforeCloseBrace = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsBraceWrappedContext), RuleAction.Delete)); this.NoSpaceBetweenEmptyBraceBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), RuleAction.Delete)); // Insert new line after { and before } in multi-line contexts. @@ -410,6 +413,9 @@ namespace ts.formatting { this.NoSpaceBeforeEqualInJsxAttribute = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.EqualsToken), RuleOperation.create2(new RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); this.NoSpaceAfterEqualInJsxAttribute = new Rule(RuleDescriptor.create3(SyntaxKind.EqualsToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); + // No space before non-null assertion operator + this.NoSpaceBeforeNonNullAssertionOperator = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.ExclamationToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), RuleAction.Delete)); + // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -456,6 +462,7 @@ namespace ts.formatting { this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, + this.NoSpaceBeforeNonNullAssertionOperator ]; // These rules are lower in priority than user-configurable rules. @@ -617,6 +624,10 @@ namespace ts.formatting { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); } + static IsBraceWrappedContext(context: FormattingContext): boolean { + return context.contextNode.kind === SyntaxKind.ObjectBindingPattern || Rules.IsSingleLineBlockContext(context); + } + // This check is done before an open brace in a control construct, a function, or a typescript block declaration static IsBeforeMultilineBlockContext(context: FormattingContext): boolean { return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); @@ -710,11 +721,18 @@ namespace ts.formatting { case SyntaxKind.ClassDeclaration: case SyntaxKind.ModuleDeclaration: case SyntaxKind.EnumDeclaration: - case SyntaxKind.Block: case SyntaxKind.CatchClause: case SyntaxKind.ModuleBlock: case SyntaxKind.SwitchStatement: return true; + case SyntaxKind.Block: { + const blockParent = context.currentTokenParent.parent; + if (blockParent.kind !== SyntaxKind.ArrowFunction && + blockParent.kind !== SyntaxKind.FunctionExpression + ) { + return true; + } + } } return false; } @@ -871,5 +889,9 @@ namespace ts.formatting { static IsYieldOrYieldStarWithOperand(context: FormattingContext): boolean { return context.contextNode.kind === SyntaxKind.YieldExpression && (context.contextNode).expression !== undefined; } + + static IsNonNullAssertionContext(context: FormattingContext): boolean { + return context.contextNode.kind === SyntaxKind.NonNullExpression; + } } } \ No newline at end of file diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 4c005640d6a..ab35a17fcef 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -14,11 +14,9 @@ namespace ts.GoToDefinition { // Type reference directives const typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { - const referenceFile = program.getResolvedTypeReferenceDirectives()[typeReferenceDirective.fileName]; - if (referenceFile && referenceFile.resolvedFileName) { - return [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; - } - return undefined; + const referenceFile = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); + return referenceFile && referenceFile.resolvedFileName && + [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; } const node = getTouchingPropertyName(sourceFile, position); @@ -30,7 +28,7 @@ namespace ts.GoToDefinition { if (isJumpStatementTarget(node)) { const labelName = (node).text; const label = getTargetLabel((node.parent), (node).text); - return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; } const typeChecker = program.getTypeChecker(); @@ -171,33 +169,38 @@ namespace ts.GoToDefinition { function tryAddSignature(signatureDeclarations: Declaration[], selectConstructors: boolean, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) { const declarations: Declaration[] = []; - let definition: Declaration; + let definition: Declaration | undefined; - forEach(signatureDeclarations, d => { - if ((selectConstructors && d.kind === SyntaxKind.Constructor) || - (!selectConstructors && (d.kind === SyntaxKind.FunctionDeclaration || d.kind === SyntaxKind.MethodDeclaration || d.kind === SyntaxKind.MethodSignature))) { + for (const d of signatureDeclarations) { + if (selectConstructors ? d.kind === SyntaxKind.Constructor : isSignatureDeclaration(d)) { declarations.push(d); if ((d).body) definition = d; } - }); - - if (definition) { - result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); - return true; - } - else if (declarations.length) { - result.push(createDefinitionInfo(lastOrUndefined(declarations), symbolKind, symbolName, containerName)); - return true; } + if (declarations.length) { + result.push(createDefinitionInfo(definition || lastOrUndefined(declarations), symbolKind, symbolName, containerName)); + return true; + } return false; } } - function createDefinitionInfo(node: Node, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo { + function isSignatureDeclaration(node: Node): boolean { + return node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature + } + + /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */ + function createDefinitionInfo(node: Declaration, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo { + return createDefinitionInfoFromName(node.name || node, symbolKind, symbolName, containerName); + } + + /** Creates a DefinitionInfo directly from the name of a declaration. */ + function createDefinitionInfoFromName(name: Node, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo { + const sourceFile = name.getSourceFile(); return { - fileName: node.getSourceFile().fileName, - textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()), + fileName: sourceFile.fileName, + textSpan: createTextSpanFromNode(name, sourceFile), kind: symbolKind, name: symbolName, containerKind: undefined, diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 0e65d3b264e..08a51a63e63 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -76,7 +76,7 @@ namespace ts.JsDoc { */ function forEachUnique(array: T[], callback: (element: T, index: number) => U): U { if (array) { - for (let i = 0, len = array.length; i < len; i++) { + for (let i = 0; i < array.length; i++) { if (indexOf(array, array[i]) === i) { const result = callback(array[i], i); if (result) { @@ -170,7 +170,7 @@ namespace ts.JsDoc { const isJavaScriptFile = hasJavaScriptFileExtension(sourceFile.fileName); let docParams = ""; - for (let i = 0, numParams = parameters.length; i < numParams; i++) { + for (let i = 0; i < parameters.length; i++) { const currentName = parameters[i].name; const paramName = currentName.kind === SyntaxKind.Identifier ? (currentName).text : diff --git a/src/services/jsTyping.ts b/src/services/jsTyping.ts index 04ac60c4e74..248ceef1bd3 100644 --- a/src/services/jsTyping.ts +++ b/src/services/jsTyping.ts @@ -17,11 +17,11 @@ namespace ts.JsTyping { interface PackageJson { _requiredBy?: string[]; - dependencies?: Map; - devDependencies?: Map; + dependencies?: MapLike; + devDependencies?: MapLike; name?: string; - optionalDependencies?: Map; - peerDependencies?: Map; + optionalDependencies?: MapLike; + peerDependencies?: MapLike; typings?: string; }; @@ -76,7 +76,7 @@ namespace ts.JsTyping { if (!safeList) { const result = readConfigFile(safeListPath, (path: string) => host.readFile(path)); - safeList = result.config ? createMap(result.config) : EmptySafeList; + safeList = result.config ? createMapFromTemplate(result.config) : EmptySafeList; } const filesToWatch: string[] = []; @@ -107,34 +107,34 @@ namespace ts.JsTyping { // add typings for unresolved imports if (unresolvedImports) { for (const moduleId of unresolvedImports) { - const typingName = moduleId in nodeCoreModules ? "node" : moduleId; - if (!(typingName in inferredTypings)) { - inferredTypings[typingName] = undefined; + const typingName = nodeCoreModules.has(moduleId) ? "node" : moduleId; + if (!inferredTypings.has(typingName)) { + inferredTypings.set(typingName, undefined); } } } // Add the cached typing locations for inferred typings that are already installed - for (const name in packageNameToTypingLocation) { - if (name in inferredTypings && !inferredTypings[name]) { - inferredTypings[name] = packageNameToTypingLocation[name]; + packageNameToTypingLocation.forEach((typingLocation, name) => { + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined) { + inferredTypings.set(name, typingLocation); } - } + }); // Remove typings that the user has added to the exclude list for (const excludeTypingName of exclude) { - delete inferredTypings[excludeTypingName]; + inferredTypings.delete(excludeTypingName); } const newTypingNames: string[] = []; const cachedTypingPaths: string[] = []; - for (const typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); + inferredTypings.forEach((inferred, typing) => { + if (inferred !== undefined) { + cachedTypingPaths.push(inferred); } else { newTypingNames.push(typing); } - } + }); return { cachedTypingPaths, newTypingNames, filesToWatch }; /** @@ -146,8 +146,8 @@ namespace ts.JsTyping { } for (const typing of typingNames) { - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; + if (!inferredTypings.has(typing)) { + inferredTypings.set(typing, undefined); } } } @@ -189,7 +189,7 @@ namespace ts.JsTyping { const cleanedTypingNames = map(inferredTypingNames, f => f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, "")); if (safeList !== EmptySafeList) { - mergeTypings(filter(cleanedTypingNames, f => f in safeList)); + mergeTypings(filter(cleanedTypingNames, f => safeList.has(f))); } const hasJsxFile = forEach(fileNames, f => ensureScriptKind(f, getScriptKindFromFileName(f)) === ScriptKind.JSX); @@ -236,7 +236,7 @@ namespace ts.JsTyping { } if (packageJson.typings) { const absolutePath = getNormalizedAbsolutePath(packageJson.typings, getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; + inferredTypings.set(packageJson.name, absolutePath); } else { typingNames.push(packageJson.name); diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 82f4dd49f2b..05ccbcc71f4 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.NavigateTo { type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration }; @@ -7,23 +7,21 @@ namespace ts.NavigateTo { let rawItems: RawNavigateToItem[] = []; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - forEach(sourceFiles, sourceFile => { + for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && fileExtensionIs(sourceFile.fileName, ".d.ts")) { - return; + continue; } - const nameToDeclarations = sourceFile.getNamedDeclarations(); - for (const name in nameToDeclarations) { - const declarations = nameToDeclarations[name]; + forEachEntry(sourceFile.getNamedDeclarations(), (declarations, name) => { 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. let matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); if (!matches) { - continue; + return; // continue to next named declarations } for (const declaration of declarations) { @@ -32,13 +30,13 @@ namespace ts.NavigateTo { if (patternMatcher.patternContainsDots) { const containers = getContainers(declaration); if (!containers) { - return undefined; + return true; // Break out of named declarations and go to the next source file. } matches = patternMatcher.getMatches(containers, name); if (!matches) { - continue; + return; // continue to next named declarations } } @@ -47,8 +45,8 @@ namespace ts.NavigateTo { rawItems.push({ name, fileName, matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration }); } } - } - }); + }); + } // Remove imports when the imported declaration is already in the list and has the same name. rawItems = filter(rawItems, item => { @@ -199,7 +197,7 @@ namespace ts.NavigateTo { matchKind: PatternMatchKind[rawItem.matchKind], isCaseSensitive: rawItem.isCaseSensitive, fileName: rawItem.fileName, - textSpan: createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), + textSpan: createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: container && container.name ? (container.name).text : "", containerKind: container && container.name ? getNodeKind(container) : "" diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 1cbaa3d640f..9aa102e67b9 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -146,7 +146,7 @@ namespace ts.NavigationBar { break; case SyntaxKind.ImportClause: - let importClause = node; + const importClause = node; // Handle default import case e.g.: // import d from "mod"; if (importClause.name) { @@ -248,9 +248,9 @@ namespace ts.NavigationBar { return true; } - const itemsWithSameName = nameToItems[name]; + const itemsWithSameName = nameToItems.get(name); if (!itemsWithSameName) { - nameToItems[name] = child; + nameToItems.set(name, child); return true; } @@ -268,7 +268,7 @@ namespace ts.NavigationBar { if (tryMerge(itemWithSameName, child)) { return false; } - nameToItems[name] = [itemWithSameName, child]; + nameToItems.set(name, [itemWithSameName, child]); return true; } @@ -514,7 +514,7 @@ namespace ts.NavigationBar { return { text: getItemName(n.node), kind: getNodeKind(n.node), - kindModifiers: getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: map(n.children, convertToTree) }; @@ -524,7 +524,7 @@ namespace ts.NavigationBar { return { text: getItemName(n.node), kind: getNodeKind(n.node), - kindModifiers: getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: map(n.children, convertToChildItem) || emptyChildItemArray, indent: n.indent, @@ -591,7 +591,14 @@ namespace ts.NavigationBar { function getNodeSpan(node: Node): TextSpan { return node.kind === SyntaxKind.SourceFile ? createTextSpanFromBounds(node.getFullStart(), node.getEnd()) - : createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); + : createTextSpanFromNode(node, curSourceFile); + } + + function getModifiers(node: ts.Node): string { + if (node.parent && node.parent.kind === SyntaxKind.VariableDeclaration) { + node = node.parent; + } + return getNodeModifiers(node); } function getFunctionOrClassName(node: FunctionExpression | FunctionDeclaration | ArrowFunction | ClassLikeDeclaration): string { @@ -626,15 +633,15 @@ namespace ts.NavigationBar { /** * Matches all whitespace characters in a string. Eg: - * + * * "app. - * + * * onactivated" - * + * * matches because of the newline, whereas - * + * * "app.onactivated" - * + * * does not match. */ const whiteSpaceRegex = /\s+/g; diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index dc2e4a59773..2ad20a7ed0c 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -8,7 +8,7 @@ namespace ts.OutliningElementsCollector { if (hintSpanNode && startElement && endElement) { const span: OutliningSpan = { textSpan: createTextSpanFromBounds(startElement.pos, endElement.end), - hintSpan: createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), + hintSpan: createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse }; @@ -135,7 +135,7 @@ namespace ts.OutliningElementsCollector { // Block was a standalone block. In this case we want to only collapse // the span of the block, independent of any parent span. - const span = createTextSpanFromBounds(n.getStart(), n.end); + const span = createTextSpanFromNode(n); elements.push({ textSpan: span, hintSpan: span, diff --git a/src/services/patternMatcher.ts b/src/services/patternMatcher.ts index b4f67ca056d..396e53810ce 100644 --- a/src/services/patternMatcher.ts +++ b/src/services/patternMatcher.ts @@ -188,11 +188,11 @@ namespace ts { } function getWordSpans(word: string): TextSpan[] { - if (!(word in stringToWordSpans)) { - stringToWordSpans[word] = breakIntoWordSpans(word); + let spans = stringToWordSpans.get(word); + if (!spans) { + stringToWordSpans.set(word, spans = breakIntoWordSpans(word)); } - - return stringToWordSpans[word]; + return spans; } function matchTextChunk(candidate: string, chunk: TextChunk, punctuationStripped: boolean): PatternMatch { @@ -516,7 +516,8 @@ namespace ts { // Assumes 'value' is already lowercase. function indexOfIgnoringCase(string: string, value: string): number { - for (let i = 0, n = string.length - value.length; i <= n; i++) { + const n = string.length - value.length; + for (let i = 0; i <= n; i++) { if (startsWithIgnoringCase(string, value, i)) { return i; } @@ -527,7 +528,7 @@ namespace ts { // Assumes 'value' is already lowercase. function startsWithIgnoringCase(string: string, value: string, start: number): boolean { - for (let i = 0, n = value.length; i < n; i++) { + for (let i = 0; i < value.length; i++) { const ch1 = toLowerCase(string.charCodeAt(i + start)); const ch2 = value.charCodeAt(i); @@ -613,7 +614,7 @@ namespace ts { const result: TextSpan[] = []; let wordStart = 0; - for (let i = 1, n = identifier.length; i < n; i++) { + for (let i = 1; i < identifier.length; i++) { const lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); const currentIsDigit = isDigit(identifier.charCodeAt(i)); diff --git a/src/services/services.ts b/src/services/services.ts index cf6df71d45b..26374eccbfd 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -24,7 +24,7 @@ /// /// /// -/// +/// /// namespace ts { @@ -518,7 +518,7 @@ namespace ts { } private computeNamedDeclarations(): Map { - const result = createMap(); + const result = createMultiMap(); forEachChild(this, visit); @@ -527,12 +527,16 @@ namespace ts { function addDeclaration(declaration: Declaration) { const name = getDeclarationName(declaration); if (name) { - multiMapAdd(result, name, declaration); + result.add(name, declaration); } } function getDeclarations(name: string) { - return result[name] || (result[name] = []); + let declarations = result.get(name); + if (!declarations) { + result.set(name, declarations = []); + } + return declarations; } function getDeclarationName(declaration: Declaration) { @@ -1793,7 +1797,7 @@ namespace ts { } let descriptor: TodoCommentDescriptor = undefined; - for (let i = 0, n = descriptors.length; i < n; i++) { + for (let i = 0; i < descriptors.length; i++) { if (matchArray[i + firstDescriptorCaptureIndex]) { descriptor = descriptors[i]; } @@ -1955,9 +1959,11 @@ namespace ts { function walk(node: Node) { switch (node.kind) { - case SyntaxKind.Identifier: - nameTable[(node).text] = nameTable[(node).text] === undefined ? node.pos : -1; + case SyntaxKind.Identifier: { + const text = (node).text; + nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); break; + } case SyntaxKind.StringLiteral: case SyntaxKind.NumericLiteral: // We want to store any numbers/strings if they were a name that could be @@ -1969,7 +1975,8 @@ namespace ts { isArgumentOfElementAccessExpression(node) || isLiteralComputedPropertyDeclarationName(node)) { - nameTable[(node).text] = nameTable[(node).text] === undefined ? node.pos : -1; + const text = (node).text; + nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); } break; default: diff --git a/src/services/shims.ts b/src/services/shims.ts index 22fd093561e..99dde70742d 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -1239,7 +1239,7 @@ namespace ts { } public unregisterShim(shim: Shim): void { - for (let i = 0, n = this._shims.length; i < n; i++) { + for (let i = 0; i < this._shims.length; i++) { if (this._shims[i] === shim) { delete this._shims[i]; return; diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 44c2ede9fbb..a78370dba72 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -237,7 +237,7 @@ namespace ts.SignatureHelp { const typeChecker = program.getTypeChecker(); for (const sourceFile of program.getSourceFiles()) { const nameToDeclarations = sourceFile.getNamedDeclarations(); - const declarations = nameToDeclarations[name.text]; + const declarations = nameToDeclarations.get(name.text); if (declarations) { for (const declaration of declarations) { @@ -260,7 +260,7 @@ namespace ts.SignatureHelp { * Returns relevant information for the argument list and the current argument if we are * in the argument of an invocation; returns undefined otherwise. */ - function getImmediatelyContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile): ArgumentListInfo { + export function getImmediatelyContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile): ArgumentListInfo { if (node.parent.kind === SyntaxKind.CallExpression || node.parent.kind === SyntaxKind.NewExpression) { const callExpression = node.parent; // There are 3 cases to handle: diff --git a/src/services/transpile.ts b/src/services/transpile.ts index da54faed1a2..0b90e9d030b 100644 --- a/src/services/transpile.ts +++ b/src/services/transpile.ts @@ -1,4 +1,4 @@ -namespace ts { +namespace ts { export interface TranspileOptions { compilerOptions?: CompilerOptions; fileName?: string; @@ -63,7 +63,7 @@ namespace ts { } if (transpileOptions.renamedDependencies) { - sourceFile.renamedDependencies = createMap(transpileOptions.renamedDependencies); + sourceFile.renamedDependencies = createMapFromTemplate(transpileOptions.renamedDependencies); } const newLine = getNewLineCharacter(options); @@ -126,7 +126,7 @@ namespace ts { function fixupCompilerOptions(options: CompilerOptions, diagnostics: Diagnostic[]): CompilerOptions { // Lazily create this value to fix module loading errors. commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || filter(optionDeclarations, o => - typeof o.type === "object" && !forEachProperty(o.type, v => typeof v !== "number")); + typeof o.type === "object" && !forEachEntry(o.type, v => typeof v !== "number")); options = clone(options); @@ -142,7 +142,7 @@ namespace ts { options[opt.name] = parseCustomTypeOption(opt, value, diagnostics); } else { - if (!forEachProperty(opt.type, v => v === value)) { + if (!forEachEntry(opt.type, v => v === value)) { // Supplied value isn't a valid enum value. diagnostics.push(createCompilerDiagnosticForInvalidCustomType(opt)); } diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index fdab9006046..b0a9275f62a 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -1,19 +1,9 @@ { + "extends": "../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": true, "removeComments": false, - "preserveConstEnums": true, - "pretty": true, "outFile": "../../built/local/typescriptServices.js", - "sourceMap": true, - "stripInternal": true, - "noResolve": false, - "declaration": true, - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true, - "types": [] + "declaration": true }, "files": [ "../compiler/core.ts", @@ -88,7 +78,15 @@ "formatting/rulesProvider.ts", "formatting/smartIndenter.ts", "formatting/tokenRange.ts", - "codeFixes/codeFixProvider.ts", - "codeFixes/fixes.ts" + "codeFixProvider.ts", + "codefixes/fixExtendsInterfaceBecomesImplements.ts", + "codefixes/fixClassIncorrectlyImplementsInterface.ts", + "codefixes/fixClassDoesntImplementInheritedAbstractMember.ts", + "codefixes/fixClassSuperMustPrecedeThisAccess.ts", + "codefixes/fixConstructorForDerivedNeedSuperCall.ts", + "codefixes/fixes.ts", + "codefixes/helpers.ts", + "codefixes/importFixes.ts", + "codefixes/unusedIdentifierFixes.ts" ] -} +} \ No newline at end of file diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 9af2b689a51..739d9f77fb5 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -600,7 +600,7 @@ namespace ts { return !!findChildOfKind(n, kind, sourceFile); } - export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node { + export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node | undefined { return forEach(n.getChildren(sourceFile), c => c.kind === kind && c); } @@ -675,8 +675,7 @@ namespace ts { } // find the child that contains 'position' - for (let i = 0, n = current.getChildCount(sourceFile); i < n; i++) { - const child = current.getChildAt(i); + for (const child of current.getChildren()) { // all jsDocComment nodes were already visited if (isJSDocNode(child)) { continue; @@ -766,7 +765,7 @@ namespace ts { } const children = n.getChildren(); - for (let i = 0, len = children.length; i < len; i++) { + for (let i = 0; i < children.length; i++) { const child = children[i]; // condition 'position < child.end' checks if child node end after the position // in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc' @@ -1113,6 +1112,10 @@ namespace ts { return !tripleSlashDirectivePrefixRegex.test(commentText); } } + + export function createTextSpanFromNode(node: Node, sourceFile?: SourceFile): TextSpan { + return createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); + } } // Display-part writer helpers @@ -1335,4 +1338,9 @@ namespace ts { } return ensureScriptKind(fileName, scriptKind); } + + export function getOpenBraceEnd(constructor: ConstructorDeclaration, sourceFile: SourceFile) { + // First token is the open curly, this is where we want to put the 'super' call. + return constructor.body.getFirstToken(sourceFile).getEnd(); + } } diff --git a/src/tsconfig-base.json b/src/tsconfig-base.json new file mode 100644 index 00000000000..2eb1851dc5c --- /dev/null +++ b/src/tsconfig-base.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "noEmitOnError": true, + "noImplicitAny": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "pretty": true, + "preserveConstEnums": true, + "stripInternal": true, + "sourceMap": true, + "target": "es5", + "types": [] + } +} \ No newline at end of file diff --git a/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js b/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js index ec0ed5494a4..c3084700547 100644 --- a/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js +++ b/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js @@ -21,11 +21,16 @@ module A { //// [ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A; (function (A) { var Point = (function () { @@ -38,7 +43,7 @@ var A; var Point3d = (function (_super) { __extends(Point3d, _super); function Point3d() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Point3d; }(Point)); diff --git a/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js b/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js index bae9593fb98..fe4308281d1 100644 --- a/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js +++ b/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js @@ -25,11 +25,16 @@ module A { //// [ExportClassWithInaccessibleTypeInTypeParameterConstraint.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A; (function (A) { var Point = (function () { @@ -41,7 +46,7 @@ var A; var Point3d = (function (_super) { __extends(Point3d, _super); function Point3d() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Point3d; }(Point)); diff --git a/tests/baselines/reference/abstractClassInLocalScope.js b/tests/baselines/reference/abstractClassInLocalScope.js index db5144be399..d841911b0bf 100644 --- a/tests/baselines/reference/abstractClassInLocalScope.js +++ b/tests/baselines/reference/abstractClassInLocalScope.js @@ -8,11 +8,16 @@ //// [abstractClassInLocalScope.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); (function () { var A = (function () { function A() { @@ -22,7 +27,7 @@ var __extends = (this && this.__extends) || function (d, b) { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.js b/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.js index 1b3e11cfa32..a513ce3d88e 100644 --- a/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.js +++ b/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.js @@ -8,11 +8,16 @@ //// [abstractClassInLocalScopeIsAbstract.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); (function () { var A = (function () { function A() { @@ -22,7 +27,7 @@ var __extends = (this && this.__extends) || function (d, b) { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/abstractProperty.js b/tests/baselines/reference/abstractProperty.js index fb7deaa09dd..f4b2d432f24 100644 --- a/tests/baselines/reference/abstractProperty.js +++ b/tests/baselines/reference/abstractProperty.js @@ -22,11 +22,16 @@ class C extends B { } //// [abstractProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { } @@ -35,7 +40,7 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.raw = "edge"; _this.ro = "readonly please"; return _this; diff --git a/tests/baselines/reference/abstractPropertyNegative.js b/tests/baselines/reference/abstractPropertyNegative.js index bebf9026a0e..5ff6708b89a 100644 --- a/tests/baselines/reference/abstractPropertyNegative.js +++ b/tests/baselines/reference/abstractPropertyNegative.js @@ -44,11 +44,16 @@ abstract class AbstractAccessorMismatch { //// [abstractPropertyNegative.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { } @@ -57,7 +62,7 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.ro = "readonly please"; return _this; } @@ -78,7 +83,7 @@ var WrongTypeProperty = (function () { var WrongTypePropertyImpl = (function (_super) { __extends(WrongTypePropertyImpl, _super); function WrongTypePropertyImpl() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.num = "nope, wrong"; return _this; } @@ -92,7 +97,7 @@ var WrongTypeAccessor = (function () { var WrongTypeAccessorImpl = (function (_super) { __extends(WrongTypeAccessorImpl, _super); function WrongTypeAccessorImpl() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(WrongTypeAccessorImpl.prototype, "num", { get: function () { return "nope, wrong"; }, @@ -104,7 +109,7 @@ var WrongTypeAccessorImpl = (function (_super) { var WrongTypeAccessorImpl2 = (function (_super) { __extends(WrongTypeAccessorImpl2, _super); function WrongTypeAccessorImpl2() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.num = "nope, wrong"; return _this; } diff --git a/tests/baselines/reference/accessOverriddenBaseClassMember1.js b/tests/baselines/reference/accessOverriddenBaseClassMember1.js index 02d092dfd39..1fdf137a7e7 100644 --- a/tests/baselines/reference/accessOverriddenBaseClassMember1.js +++ b/tests/baselines/reference/accessOverriddenBaseClassMember1.js @@ -16,11 +16,16 @@ class ColoredPoint extends Point { //// [accessOverriddenBaseClassMember1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Point = (function () { function Point(x, y) { this.x = x; diff --git a/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt b/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt index 5393eee87d4..278de87e729 100644 --- a/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt +++ b/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,55): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,48): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,54): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,47): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(6,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(8,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(9,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -20,13 +20,13 @@ tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(12,16): error TS1 public get AnnotatedSetter_SetterFirst() { return ""; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~ + ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'number'. public get AnnotatedSetter_SetterLast() { return ""; } ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~ + ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'number'. public set AnnotatedSetter_SetterLast(a: number) { } ~~~~~~~~~~~~~~~~~~~~~~~~~~ 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 dbaeec1f688..8d9ef160e2e 100644 --- a/tests/baselines/reference/accessors_spec_section-4.5_inference.js +++ b/tests/baselines/reference/accessors_spec_section-4.5_inference.js @@ -25,11 +25,16 @@ class LanguageSpec_section_4_5_inference { } //// [accessors_spec_section-4.5_inference.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -38,7 +43,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.errors.txt b/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.errors.txt index d18a9a13d8c..5f0d78c59d5 100644 --- a/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.errors.txt +++ b/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(11,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(12,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(13,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(14,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(15,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(16,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(19,10): error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'true' and 'true'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(21,10): error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(22,11): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(23,11): error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(11,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(12,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(13,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(14,14): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(15,14): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(16,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(19,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(20,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(21,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(22,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(23,11): error TS2531: Object is possibly 'null'. ==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts (11 errors) ==== @@ -23,37 +23,37 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe // null + boolean/Object var r1 = null + a; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r2 = null + b; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r3 = null + c; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r4 = a + null; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r5 = b + null; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r6 = null + c; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. // other cases var r7 = null + d; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r8 = null + true; - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'true' and 'true'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r9 = null + { a: '' }; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r10 = null + foo(); - ~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r11 = null + (() => { }); - ~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'. \ No newline at end of file + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.errors.txt b/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.errors.txt new file mode 100644 index 00000000000..db01a42c8bd --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.errors.txt @@ -0,0 +1,63 @@ +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(15,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(16,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(17,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(18,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(19,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(20,14): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(21,14): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(22,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(23,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(24,20): error TS2531: Object is possibly 'null'. + + +==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts (10 errors) ==== + // If one operand is the null or undefined value, it is treated as having the type of the other operand. + + enum E { a, b, c } + + var a: any; + var b: number; + var c: E; + var d: string; + + // null + any + var r1: any = null + a; + var r2: any = a + null; + + // null + number/enum + var r3 = null + b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4 = null + 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r5 = null + c; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r6 = null + E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r7 = null + E['a']; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r8 = b + null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r9 = 1 + null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r10 = c + null + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r11 = E.a + null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r12 = E['a'] + null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // null + string + var r13 = null + d; + var r14 = null + ''; + var r15 = d + null; + var r16 = '' + null; \ No newline at end of file diff --git a/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.errors.txt b/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.errors.txt index 9e7e4c01ad2..aef66891be0 100644 --- a/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.errors.txt +++ b/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.errors.txt @@ -1,20 +1,32 @@ -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(2,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(3,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(4,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(5,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(2,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(2,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(3,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(3,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(4,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(4,22): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(5,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(5,22): error TS2532: Object is possibly 'undefined'. -==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts (4 errors) ==== +==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts (8 errors) ==== // bug 819721 var r1 = null + null; - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r2 = null + undefined; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r3 = undefined + null; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r4 = undefined + undefined; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. \ No newline at end of file + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/additionOperatorWithTypeParameter.errors.txt b/tests/baselines/reference/additionOperatorWithTypeParameter.errors.txt index ff7120c145d..478c4fdee3f 100644 --- a/tests/baselines/reference/additionOperatorWithTypeParameter.errors.txt +++ b/tests/baselines/reference/additionOperatorWithTypeParameter.errors.txt @@ -8,8 +8,8 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(27,15): error TS2365: Operator '+' cannot be applied to types 'Object' and 'T'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(28,15): error TS2365: Operator '+' cannot be applied to types 'E' and 'T'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(29,15): error TS2365: Operator '+' cannot be applied to types 'void' and 'T'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(32,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(33,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(32,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(33,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(34,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(35,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'U'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(36,15): error TS2365: Operator '+' cannot be applied to types 'T' and '() => void'. @@ -69,11 +69,11 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe // other cases var r15 = t + null; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r16 = t + undefined; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r17 = t + t; ~~~~~ !!! error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. diff --git a/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.errors.txt b/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.errors.txt index d61f101a544..06e8c67b105 100644 --- a/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.errors.txt +++ b/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(11,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(12,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(13,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(14,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(15,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(16,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(19,10): error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'true' and 'true'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(21,10): error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(22,11): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(23,11): error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(11,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(12,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(13,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(14,14): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(15,14): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(16,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(19,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(20,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(21,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(22,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(23,11): error TS2532: Object is possibly 'undefined'. ==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts (11 errors) ==== @@ -23,37 +23,37 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe // undefined + boolean/Object var r1 = undefined + a; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r2 = undefined + b; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r3 = undefined + c; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r4 = a + undefined; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r5 = b + undefined; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r6 = undefined + c; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // other cases var r7 = undefined + d; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r8 = undefined + true; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'true' and 'true'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r9 = undefined + { a: '' }; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r10 = undefined + foo(); - ~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r11 = undefined + (() => { }); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'. \ No newline at end of file + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.errors.txt b/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.errors.txt new file mode 100644 index 00000000000..04c0e2f3266 --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.errors.txt @@ -0,0 +1,63 @@ +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(15,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(16,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(17,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(18,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(19,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(20,14): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(21,14): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(22,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(23,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(24,20): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts (10 errors) ==== + // If one operand is the null or undefined value, it is treated as having the type of the other operand. + + enum E { a, b, c } + + var a: any; + var b: number; + var c: E; + var d: string; + + // undefined + any + var r1: any = undefined + a; + var r2: any = a + undefined; + + // undefined + number/enum + var r3 = undefined + b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r4 = undefined + 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r5 = undefined + c; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r6 = undefined + E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r7 = undefined + E['a']; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r8 = b + undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r9 = 1 + undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r10 = c + undefined + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r11 = E.a + undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r12 = E['a'] + undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // undefined + string + var r13 = undefined + d; + var r14 = undefined + ''; + var r15 = d + undefined; + var r16 = '' + undefined; \ No newline at end of file diff --git a/tests/baselines/reference/aliasUsageInAccessorsOfClass.js b/tests/baselines/reference/aliasUsageInAccessorsOfClass.js index 8b60ed8e76d..41a2bb06664 100644 --- a/tests/baselines/reference/aliasUsageInAccessorsOfClass.js +++ b/tests/baselines/reference/aliasUsageInAccessorsOfClass.js @@ -37,16 +37,21 @@ var Model = (function () { exports.Model = Model; //// [aliasUsage1_moduleA.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Backbone = require("./aliasUsage1_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); diff --git a/tests/baselines/reference/aliasUsageInArray.js b/tests/baselines/reference/aliasUsageInArray.js index bf573aa9abb..1f3e1490332 100644 --- a/tests/baselines/reference/aliasUsageInArray.js +++ b/tests/baselines/reference/aliasUsageInArray.js @@ -31,16 +31,21 @@ var Model = (function () { exports.Model = Model; //// [aliasUsageInArray_moduleA.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Backbone = require("./aliasUsageInArray_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); diff --git a/tests/baselines/reference/aliasUsageInFunctionExpression.js b/tests/baselines/reference/aliasUsageInFunctionExpression.js index 49bdd493aac..a6fc0e97f68 100644 --- a/tests/baselines/reference/aliasUsageInFunctionExpression.js +++ b/tests/baselines/reference/aliasUsageInFunctionExpression.js @@ -30,16 +30,21 @@ var Model = (function () { exports.Model = Model; //// [aliasUsageInFunctionExpression_moduleA.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Backbone = require("./aliasUsageInFunctionExpression_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); diff --git a/tests/baselines/reference/aliasUsageInGenericFunction.js b/tests/baselines/reference/aliasUsageInGenericFunction.js index dc3a8a88bab..a991207971c 100644 --- a/tests/baselines/reference/aliasUsageInGenericFunction.js +++ b/tests/baselines/reference/aliasUsageInGenericFunction.js @@ -34,16 +34,21 @@ var Model = (function () { exports.Model = Model; //// [aliasUsageInGenericFunction_moduleA.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Backbone = require("./aliasUsageInGenericFunction_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); diff --git a/tests/baselines/reference/aliasUsageInIndexerOfClass.js b/tests/baselines/reference/aliasUsageInIndexerOfClass.js index cb7ad3027ca..d57b2f6379d 100644 --- a/tests/baselines/reference/aliasUsageInIndexerOfClass.js +++ b/tests/baselines/reference/aliasUsageInIndexerOfClass.js @@ -36,16 +36,21 @@ var Model = (function () { exports.Model = Model; //// [aliasUsageInIndexerOfClass_moduleA.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Backbone = require("./aliasUsageInIndexerOfClass_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); diff --git a/tests/baselines/reference/aliasUsageInObjectLiteral.js b/tests/baselines/reference/aliasUsageInObjectLiteral.js index 81e3e621e85..15818c82cb9 100644 --- a/tests/baselines/reference/aliasUsageInObjectLiteral.js +++ b/tests/baselines/reference/aliasUsageInObjectLiteral.js @@ -31,16 +31,21 @@ var Model = (function () { exports.Model = Model; //// [aliasUsageInObjectLiteral_moduleA.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Backbone = require("./aliasUsageInObjectLiteral_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); diff --git a/tests/baselines/reference/aliasUsageInOrExpression.js b/tests/baselines/reference/aliasUsageInOrExpression.js index 4faa41dd034..99360ea648d 100644 --- a/tests/baselines/reference/aliasUsageInOrExpression.js +++ b/tests/baselines/reference/aliasUsageInOrExpression.js @@ -34,16 +34,21 @@ var Model = (function () { exports.Model = Model; //// [aliasUsageInOrExpression_moduleA.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Backbone = require("./aliasUsageInOrExpression_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); diff --git a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js index 2cf4aefab6c..47f0c30d28b 100644 --- a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js +++ b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js @@ -34,27 +34,37 @@ var Model = (function () { exports.Model = Model; //// [aliasUsageInTypeArgumentOfExtendsClause_moduleA.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInTypeArgumentOfExtendsClause_main.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var moduleA = require("./aliasUsageInTypeArgumentOfExtendsClause_moduleA"); var C = (function () { function C() { @@ -64,7 +74,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = moduleA; return _this; } diff --git a/tests/baselines/reference/aliasUsageInVarAssignment.js b/tests/baselines/reference/aliasUsageInVarAssignment.js index 80bb2dca20e..666e32e1546 100644 --- a/tests/baselines/reference/aliasUsageInVarAssignment.js +++ b/tests/baselines/reference/aliasUsageInVarAssignment.js @@ -30,16 +30,21 @@ var Model = (function () { exports.Model = Model; //// [aliasUsageInVarAssignment_moduleA.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Backbone = require("./aliasUsageInVarAssignment_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); diff --git a/tests/baselines/reference/ambientWithStatements.errors.txt b/tests/baselines/reference/ambientWithStatements.errors.txt index 6fb6aafd864..3e134970a1f 100644 --- a/tests/baselines/reference/ambientWithStatements.errors.txt +++ b/tests/baselines/reference/ambientWithStatements.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/ambientWithStatements.ts(2,5): error TS1036: Statements are not allowed in ambient contexts. tests/cases/compiler/ambientWithStatements.ts(3,5): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. -tests/cases/compiler/ambientWithStatements.ts(7,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +tests/cases/compiler/ambientWithStatements.ts(7,15): error TS2531: Object is possibly 'null'. tests/cases/compiler/ambientWithStatements.ts(11,5): error TS1108: A 'return' statement can only be used within a function body. tests/cases/compiler/ambientWithStatements.ts(25,5): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'. @@ -18,7 +18,7 @@ tests/cases/compiler/ambientWithStatements.ts(25,5): error TS2410: The 'with' st var x; for (x in null) { } ~~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +!!! error TS2531: Object is possibly 'null'. if (true) { } else { } 1; L: var y; diff --git a/tests/baselines/reference/ambiguousOverloadResolution.js b/tests/baselines/reference/ambiguousOverloadResolution.js index 01002792921..12d0f01cf4a 100644 --- a/tests/baselines/reference/ambiguousOverloadResolution.js +++ b/tests/baselines/reference/ambiguousOverloadResolution.js @@ -9,11 +9,16 @@ var x: B; var t: number = f(x, x); // Not an error //// [ambiguousOverloadResolution.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -22,7 +27,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/anonymousDefaultExportsUmd.js b/tests/baselines/reference/anonymousDefaultExportsUmd.js index 97910161999..85ed1d30444 100644 --- a/tests/baselines/reference/anonymousDefaultExportsUmd.js +++ b/tests/baselines/reference/anonymousDefaultExportsUmd.js @@ -7,14 +7,15 @@ export default class {} export default function() {} //// [a.js] -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { "use strict"; class default_1 { } @@ -22,14 +23,15 @@ export default function() {} exports.default = default_1; }); //// [b.js] -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { "use strict"; function default_1() { } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/apparentTypeSubtyping.js b/tests/baselines/reference/apparentTypeSubtyping.js index 6ca9d343a72..df266c20951 100644 --- a/tests/baselines/reference/apparentTypeSubtyping.js +++ b/tests/baselines/reference/apparentTypeSubtyping.js @@ -24,11 +24,16 @@ class Derived2 extends Base2 { // error because of the prototy //// [apparentTypeSubtyping.js] // subtype checks use the apparent type of the target type // S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -38,7 +43,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -51,7 +56,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/apparentTypeSupertype.js b/tests/baselines/reference/apparentTypeSupertype.js index c6d3378872e..16d43e8316c 100644 --- a/tests/baselines/reference/apparentTypeSupertype.js +++ b/tests/baselines/reference/apparentTypeSupertype.js @@ -14,11 +14,16 @@ class Derived extends Base { // error //// [apparentTypeSupertype.js] // subtype checks use the apparent type of the target type // S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -28,7 +33,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.errors.txt b/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.errors.txt index c043cda8e68..16a0264a805 100644 --- a/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.errors.txt +++ b/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.errors.txt @@ -1,234 +1,246 @@ -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(9,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(9,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(9,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(10,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(10,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(10,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(11,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(11,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(11,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(13,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(13,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(13,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(14,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(14,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(14,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(15,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(15,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(17,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(15,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(17,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(17,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(18,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(18,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(18,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(19,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(19,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(19,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(21,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(21,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(21,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(22,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(22,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(22,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(23,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(23,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(26,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(23,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(26,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(26,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(27,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(27,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(27,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(28,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(28,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(28,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(30,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(30,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(30,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(31,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(31,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(31,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(32,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(32,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(34,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(32,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(34,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(34,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(35,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(35,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(35,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(36,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(36,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(36,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(38,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(38,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(38,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(39,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(39,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(39,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(40,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(40,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(43,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(40,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(43,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(43,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(44,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(44,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(44,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(45,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(45,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(45,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(47,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(47,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(47,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(48,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(48,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(48,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(49,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(49,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(51,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(49,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(51,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(51,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(52,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(52,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(52,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(53,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(53,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(53,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(55,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(55,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(55,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(56,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(56,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(56,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(57,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(57,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(60,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(57,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(60,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(60,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(61,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(61,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(61,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(62,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(62,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(62,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(64,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(64,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(64,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(65,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(65,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(65,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(66,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(66,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(68,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(66,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(68,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(68,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(69,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(69,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(69,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(70,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(70,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(70,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(72,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(72,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(72,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(73,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(73,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(73,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(74,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(74,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(77,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(74,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(77,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(77,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(78,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(78,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(78,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(79,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(79,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(79,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(81,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(81,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(81,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(82,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(82,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(82,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(83,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(83,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(85,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(83,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(85,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(85,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(86,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(86,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(86,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(87,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(87,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(87,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(89,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(89,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(89,20): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(90,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(90,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(90,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(91,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(91,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(94,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(91,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(94,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(94,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(95,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(95,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(95,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(96,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(96,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(96,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(98,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(98,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(98,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(99,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(99,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(99,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(100,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(100,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(102,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(100,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(102,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(102,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(103,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(103,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(103,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(104,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(104,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(104,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(106,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(106,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(106,20): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(107,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(107,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(107,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(108,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(108,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(111,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(108,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(111,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(111,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(112,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(112,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(112,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(113,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(113,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(113,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(115,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(115,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(115,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(116,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(116,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(116,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(117,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(117,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(119,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(117,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(119,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(119,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(120,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(120,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(120,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(121,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(121,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(121,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(123,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(123,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(123,21): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(124,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(124,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(124,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(125,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(125,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(128,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(129,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(125,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(128,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(128,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(129,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(129,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(130,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(130,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(130,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(132,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(132,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(132,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(133,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(133,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(133,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(134,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(134,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(136,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(137,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(134,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(136,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(136,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(137,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(137,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(138,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(138,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(138,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(140,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(140,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(140,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(141,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(141,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(141,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(142,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(142,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(145,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(146,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(142,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(145,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(145,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(146,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(146,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(147,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(147,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(147,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(149,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(149,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(149,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(150,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(150,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(150,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(151,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(151,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(153,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(154,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(151,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(153,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(153,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(154,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(154,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(155,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(155,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(155,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(157,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(157,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(157,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(158,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(158,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(158,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(159,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(159,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(162,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(163,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(159,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(162,13): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(162,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(163,13): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(163,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(164,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(164,13): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(164,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(166,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(166,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(166,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(167,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(167,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(167,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(168,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(168,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(170,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(171,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(168,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(170,13): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(170,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(171,13): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(171,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(172,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(172,13): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(172,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(174,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(174,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(174,20): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(175,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(175,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(175,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(176,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(176,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(176,18): error TS2531: Object is possibly 'null'. -==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts (228 errors) ==== +==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts (240 errors) ==== // If one operand is the null or undefined value, it is treated as having the type of the // other operand. @@ -239,17 +251,17 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti // operator * var r1a1 = null * a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a2 = null * b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a3 = null * c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -257,31 +269,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1b2 = b * null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1b3 = c * null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1c1 = null * true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c2 = null * ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c3 = null * {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -289,32 +301,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1d2 = '' * null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1d3 = {} * null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator / var r2a1 = null / a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2a2 = null / b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2a3 = null / c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -322,31 +334,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r2b2 = b / null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r2b3 = c / null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r2c1 = null / true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2c2 = null / ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2c3 = null / {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -354,32 +366,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r2d2 = '' / null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r2d3 = {} / null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator % var r3a1 = null % a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3a2 = null % b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3a3 = null % c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -387,31 +399,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r3b2 = b % null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r3b3 = c % null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r3c1 = null % true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3c2 = null % ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3c3 = null % {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -419,32 +431,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r3d2 = '' % null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r3d3 = {} % null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator - var r4a1 = null - a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4a2 = null - b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4a3 = null - c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -452,31 +464,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r4b2 = b - null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r4b3 = c - null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r4c1 = null - true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4c2 = null - ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4c3 = null - {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -484,32 +496,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r4d2 = '' - null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r4d3 = {} - null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator << var r5a1 = null << a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5a2 = null << b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5a3 = null << c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -517,31 +529,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r5b2 = b << null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r5b3 = c << null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r5c1 = null << true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5c2 = null << ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5c3 = null << {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -549,32 +561,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r5d2 = '' << null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r5d3 = {} << null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator >> var r6a1 = null >> a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6a2 = null >> b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6a3 = null >> c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -582,31 +594,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r6b2 = b >> null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r6b3 = c >> null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r6c1 = null >> true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6c2 = null >> ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6c3 = null >> {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -614,32 +626,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r6d2 = '' >> null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r6d3 = {} >> null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator >>> var r7a1 = null >>> a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7a2 = null >>> b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7a3 = null >>> c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -647,31 +659,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r7b2 = b >>> null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r7b3 = c >>> null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r7c1 = null >>> true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7c2 = null >>> ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7c3 = null >>> {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -679,185 +691,209 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r7d2 = '' >>> null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r7d3 = {} >>> null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator & var r8a1 = null & a; - ~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8a2 = null & b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8a3 = null & c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8b1 = a & null; - ~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r8b2 = b & null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r8b3 = c & null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r8c1 = null & true; - ~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8c2 = null & ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8c3 = null & {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8d1 = true & null; - ~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r8d2 = '' & null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r8d3 = {} & null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator ^ var r9a1 = null ^ a; - ~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9a2 = null ^ b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9a3 = null ^ c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9b1 = a ^ null; - ~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r9b2 = b ^ null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r9b3 = c ^ null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r9c1 = null ^ true; - ~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9c2 = null ^ ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9c3 = null ^ {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9d1 = true ^ null; - ~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r9d2 = '' ^ null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r9d3 = {} ^ null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator | var r10a1 = null | a; - ~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10a2 = null | b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10a3 = null | c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10b1 = a | null; - ~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r10b2 = b | null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r10b3 = c | null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r10c1 = null | true; - ~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10c2 = null | ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10c3 = null | {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10d1 = true | null; - ~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r10d2 = '' | null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r10d3 = {} | null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.errors.txt b/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.errors.txt new file mode 100644 index 00000000000..426db291224 --- /dev/null +++ b/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.errors.txt @@ -0,0 +1,353 @@ +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(13,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(14,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(15,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(16,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(17,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(18,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(19,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(20,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(23,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(24,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(25,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(26,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(27,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(28,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(29,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(30,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(33,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(34,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(35,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(36,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(37,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(38,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(39,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(40,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(43,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(44,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(45,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(46,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(47,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(48,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(49,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(50,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(53,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(54,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(55,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(56,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(57,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(58,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(59,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(60,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(63,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(64,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(65,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(66,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(67,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(68,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(69,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(70,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(73,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(74,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(75,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(76,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(77,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(78,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(79,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(80,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(83,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(84,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(85,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(86,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(87,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(88,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(89,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(90,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(93,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(94,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(95,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(96,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(97,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(98,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(99,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(100,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(103,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(104,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(105,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(106,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(107,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(108,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(109,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(110,17): error TS2531: Object is possibly 'null'. + + +==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts (80 errors) ==== + // If one operand is the null or undefined value, it is treated as having the type of the + // other operand. + + enum E { + a, + b + } + + var a: any; + var b: number; + + // operator * + var ra1 = null * a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra2 = null * b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra3 = null * 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra4 = null * E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra5 = a * null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra6 = b * null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra7 = 0 * null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra8 = E.b * null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator / + var rb1 = null / a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb2 = null / b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb3 = null / 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb4 = null / E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb5 = a / null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb6 = b / null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb7 = 0 / null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb8 = E.b / null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator % + var rc1 = null % a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc2 = null % b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc3 = null % 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc4 = null % E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc5 = a % null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc6 = b % null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc7 = 0 % null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc8 = E.b % null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator - + var rd1 = null - a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd2 = null - b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd3 = null - 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd4 = null - E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd5 = a - null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd6 = b - null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd7 = 0 - null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd8 = E.b - null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator << + var re1 = null << a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re2 = null << b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re3 = null << 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re4 = null << E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re5 = a << null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re6 = b << null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re7 = 0 << null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re8 = E.b << null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator >> + var rf1 = null >> a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf2 = null >> b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf3 = null >> 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf4 = null >> E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf5 = a >> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf6 = b >> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf7 = 0 >> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf8 = E.b >> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator >>> + var rg1 = null >>> a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg2 = null >>> b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg3 = null >>> 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg4 = null >>> E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg5 = a >>> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg6 = b >>> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg7 = 0 >>> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg8 = E.b >>> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator & + var rh1 = null & a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh2 = null & b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh3 = null & 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh4 = null & E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh5 = a & null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh6 = b & null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh7 = 0 & null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh8 = E.b & null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator ^ + var ri1 = null ^ a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri2 = null ^ b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri3 = null ^ 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri4 = null ^ E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri5 = a ^ null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri6 = b ^ null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri7 = 0 ^ null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri8 = E.b ^ null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator | + var rj1 = null | a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj2 = null | b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj3 = null | 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj4 = null | E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj5 = a | null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj6 = b | null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj7 = 0 | null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj8 = E.b | null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.errors.txt b/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.errors.txt index d00eee1d4dd..e67db44a780 100644 --- a/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.errors.txt +++ b/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.errors.txt @@ -1,302 +1,302 @@ -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(2,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(2,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(3,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(3,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(4,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(4,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(5,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(5,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(8,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(8,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(9,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(9,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(10,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(10,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(11,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(11,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(14,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(14,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(15,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(15,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(16,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(16,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(17,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(17,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(20,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(20,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(21,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(21,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(22,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(22,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(23,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(23,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(26,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(26,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(27,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(27,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(28,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(28,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(29,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(29,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(32,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(32,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(33,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(33,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(34,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(34,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(35,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(35,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(38,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(38,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(39,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(39,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(40,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(40,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(41,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(41,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(44,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(44,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(45,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(45,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(46,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(46,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(47,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(47,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(50,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(50,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(51,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(51,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(52,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(52,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(53,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(53,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(56,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(56,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(57,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(57,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(58,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(58,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(59,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(59,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(2,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(2,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(3,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(3,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(4,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(4,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(5,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(5,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(8,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(8,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(9,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(9,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(10,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(10,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(11,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(11,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(14,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(14,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(15,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(15,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(16,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(16,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(17,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(17,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(20,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(20,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(21,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(21,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(22,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(22,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(23,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(23,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(26,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(26,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(27,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(27,19): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(28,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(28,24): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(29,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(29,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(32,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(32,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(33,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(33,19): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(34,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(34,24): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(35,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(35,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(38,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(38,20): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(39,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(39,20): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(40,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(40,25): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(41,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(41,25): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(44,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(44,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(45,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(45,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(46,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(46,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(47,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(47,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(50,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(50,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(51,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(51,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(52,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(52,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(53,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(53,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(56,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(56,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(57,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(57,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(58,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(58,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(59,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(59,23): error TS2532: Object is possibly 'undefined'. ==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts (80 errors) ==== // operator * var ra1 = null * null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var ra2 = null * undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var ra3 = undefined * null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var ra4 = undefined * undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator / var rb1 = null / null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rb2 = null / undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rb3 = undefined / null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rb4 = undefined / undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator % var rc1 = null % null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rc2 = null % undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rc3 = undefined % null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rc4 = undefined % undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator - var rd1 = null - null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rd2 = null - undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rd3 = undefined - null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rd4 = undefined - undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator << var re1 = null << null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var re2 = null << undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var re3 = undefined << null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var re4 = undefined << undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator >> var rf1 = null >> null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rf2 = null >> undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rf3 = undefined >> null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rf4 = undefined >> undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator >>> var rg1 = null >>> null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rg2 = null >>> undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rg3 = undefined >>> null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rg4 = undefined >>> undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator & var rh1 = null & null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rh2 = null & undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rh3 = undefined & null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rh4 = undefined & undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator ^ var ri1 = null ^ null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var ri2 = null ^ undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var ri3 = undefined ^ null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var ri4 = undefined ^ undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator | var rj1 = null | null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rj2 = null | undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rj3 = undefined | null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rj4 = undefined | undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.errors.txt b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.errors.txt index 9ee53c2f15c..8a9d014f2c2 100644 --- a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.errors.txt +++ b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.errors.txt @@ -1,234 +1,246 @@ -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(9,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(9,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(9,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(10,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(10,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(10,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(11,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(11,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(11,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(13,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(13,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(13,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(14,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(14,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(14,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(15,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(15,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(17,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(15,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(17,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(17,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(18,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(18,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(18,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(19,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(19,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(19,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(21,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(21,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(21,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(22,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(22,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(22,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(23,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(23,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(26,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(23,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(26,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(26,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(27,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(27,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(27,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(28,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(28,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(28,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(30,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(30,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(30,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(31,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(31,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(31,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(32,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(32,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(34,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(32,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(34,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(34,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(35,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(35,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(35,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(36,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(36,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(36,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(38,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(38,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(38,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(39,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(39,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(39,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(40,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(40,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(43,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(40,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(43,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(43,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(44,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(44,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(44,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(45,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(45,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(45,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(47,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(47,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(47,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(48,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(48,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(48,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(49,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(49,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(51,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(49,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(51,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(51,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(52,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(52,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(52,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(53,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(53,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(53,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(55,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(55,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(55,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(56,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(56,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(56,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(57,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(57,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(60,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(57,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(60,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(60,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(61,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(61,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(61,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(62,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(62,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(62,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(64,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(64,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(64,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(65,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(65,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(65,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(66,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(66,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(68,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(66,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(68,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(68,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(69,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(69,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(69,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(70,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(70,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(70,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(72,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(72,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(72,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(73,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(73,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(73,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(74,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(74,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(77,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(74,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(77,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(77,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(78,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(78,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(78,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(79,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(79,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(79,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(81,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(81,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(81,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(82,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(82,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(82,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(83,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(83,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(85,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(83,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(85,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(85,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(86,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(86,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(86,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(87,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(87,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(87,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(89,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(89,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(89,20): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(90,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(90,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(90,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(91,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(91,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(94,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(91,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(94,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(94,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(95,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(95,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(95,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(96,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(96,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(96,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(98,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(98,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(98,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(99,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(99,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(99,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(100,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(100,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(102,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(100,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(102,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(102,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(103,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(103,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(103,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(104,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(104,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(104,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(106,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(106,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(106,20): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(107,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(107,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(107,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(108,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(108,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(111,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(108,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(111,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(111,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(112,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(112,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(112,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(113,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(113,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(113,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(115,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(115,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(115,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(116,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(116,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(116,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(117,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(117,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(119,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(117,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(119,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(119,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(120,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(120,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(120,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(121,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(121,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(121,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(123,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(123,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(123,21): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(124,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(124,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(124,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(125,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(125,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(128,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(129,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(125,19): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(128,12): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(128,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(129,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(129,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(130,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(130,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(130,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(132,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(132,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(132,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(133,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(133,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(133,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(134,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(134,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(136,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(137,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(134,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(136,12): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(136,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(137,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(137,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(138,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(138,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(138,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(140,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(140,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(140,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(141,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(141,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(141,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(142,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(142,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(145,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(146,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(142,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(145,12): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(145,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(146,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(146,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(147,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(147,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(147,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(149,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(149,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(149,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(150,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(150,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(150,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(151,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(151,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(153,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(154,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(151,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(153,12): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(153,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(154,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(154,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(155,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(155,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(155,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(157,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(157,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(157,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(158,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(158,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(158,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(159,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(159,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(162,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(163,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(159,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(162,13): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(162,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(163,13): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(163,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(164,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(164,13): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(164,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(166,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(166,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(166,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(167,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(167,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(167,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(168,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(168,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(170,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(171,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(168,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(170,13): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(170,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(171,13): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(171,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(172,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(172,13): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(172,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(174,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(174,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(174,20): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(175,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(175,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(175,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(176,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(176,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(176,18): error TS2532: Object is possibly 'undefined'. -==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts (228 errors) ==== +==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts (240 errors) ==== // If one operand is the undefined or undefined value, it is treated as having the type of the // other operand. @@ -239,17 +251,17 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti // operator * var r1a1 = undefined * a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a2 = undefined * b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a3 = undefined * c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -257,31 +269,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1b2 = b * undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1b3 = c * undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1c1 = undefined * true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c2 = undefined * ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c3 = undefined * {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -289,32 +301,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1d2 = '' * undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1d3 = {} * undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator / var r2a1 = undefined / a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2a2 = undefined / b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2a3 = undefined / c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -322,31 +334,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r2b2 = b / undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r2b3 = c / undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r2c1 = undefined / true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2c2 = undefined / ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2c3 = undefined / {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -354,32 +366,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r2d2 = '' / undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r2d3 = {} / undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator % var r3a1 = undefined % a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3a2 = undefined % b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3a3 = undefined % c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -387,31 +399,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r3b2 = b % undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r3b3 = c % undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r3c1 = undefined % true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3c2 = undefined % ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3c3 = undefined % {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -419,32 +431,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r3d2 = '' % undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r3d3 = {} % undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator - var r4a1 = undefined - a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4a2 = undefined - b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4a3 = undefined - c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -452,31 +464,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r4b2 = b - undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r4b3 = c - undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r4c1 = undefined - true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4c2 = undefined - ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4c3 = undefined - {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -484,32 +496,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r4d2 = '' - undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r4d3 = {} - undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator << var r5a1 = undefined << a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5a2 = undefined << b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5a3 = undefined << c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -517,31 +529,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r5b2 = b << undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r5b3 = c << undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r5c1 = undefined << true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5c2 = undefined << ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5c3 = undefined << {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -549,32 +561,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r5d2 = '' << undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r5d3 = {} << undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator >> var r6a1 = undefined >> a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6a2 = undefined >> b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6a3 = undefined >> c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -582,31 +594,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r6b2 = b >> undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r6b3 = c >> undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r6c1 = undefined >> true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6c2 = undefined >> ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6c3 = undefined >> {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -614,32 +626,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r6d2 = '' >> undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r6d3 = {} >> undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator >>> var r7a1 = undefined >>> a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7a2 = undefined >>> b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7a3 = undefined >>> c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -647,31 +659,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r7b2 = b >>> undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r7b3 = c >>> undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r7c1 = undefined >>> true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7c2 = undefined >>> ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7c3 = undefined >>> {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -679,185 +691,209 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r7d2 = '' >>> undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r7d3 = {} >>> undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator & var r8a1 = undefined & a; - ~~~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8a2 = undefined & b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8a3 = undefined & c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8b1 = a & undefined; - ~~~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r8b2 = b & undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r8b3 = c & undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r8c1 = undefined & true; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8c2 = undefined & ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8c3 = undefined & {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8d1 = true & undefined; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r8d2 = '' & undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r8d3 = {} & undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator ^ var r9a1 = undefined ^ a; - ~~~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9a2 = undefined ^ b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9a3 = undefined ^ c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9b1 = a ^ undefined; - ~~~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r9b2 = b ^ undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r9b3 = c ^ undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r9c1 = undefined ^ true; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9c2 = undefined ^ ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9c3 = undefined ^ {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9d1 = true ^ undefined; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r9d2 = '' ^ undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r9d3 = {} ^ undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator | var r10a1 = undefined | a; - ~~~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10a2 = undefined | b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10a3 = undefined | c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10b1 = a | undefined; - ~~~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r10b2 = b | undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r10b3 = c | undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r10c1 = undefined | true; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10c2 = undefined | ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10c3 = undefined | {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10d1 = true | undefined; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r10d2 = '' | undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r10d3 = {} | undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.errors.txt b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.errors.txt new file mode 100644 index 00000000000..246b642603c --- /dev/null +++ b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.errors.txt @@ -0,0 +1,353 @@ +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(13,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(14,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(15,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(16,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(17,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(18,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(19,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(20,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(23,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(24,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(25,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(26,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(27,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(28,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(29,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(30,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(33,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(34,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(35,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(36,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(37,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(38,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(39,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(40,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(43,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(44,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(45,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(46,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(47,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(48,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(49,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(50,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(53,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(54,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(55,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(56,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(57,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(58,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(59,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(60,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(63,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(64,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(65,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(66,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(67,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(68,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(69,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(70,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(73,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(74,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(75,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(76,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(77,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(78,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(79,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(80,19): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(83,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(84,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(85,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(86,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(87,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(88,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(89,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(90,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(93,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(94,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(95,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(96,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(97,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(98,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(99,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(100,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(103,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(104,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(105,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(106,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(107,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(108,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(109,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(110,17): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts (80 errors) ==== + // If one operand is the undefined or undefined value, it is treated as having the type of the + // other operand. + + enum E { + a, + b + } + + var a: any; + var b: number; + + // operator * + var ra1 = undefined * a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra2 = undefined * b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra3 = undefined * 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra4 = undefined * E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra5 = a * undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra6 = b * undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra7 = 0 * undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra8 = E.b * undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator / + var rb1 = undefined / a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb2 = undefined / b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb3 = undefined / 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb4 = undefined / E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb5 = a / undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb6 = b / undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb7 = 0 / undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb8 = E.b / undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator % + var rc1 = undefined % a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc2 = undefined % b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc3 = undefined % 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc4 = undefined % E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc5 = a % undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc6 = b % undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc7 = 0 % undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc8 = E.b % undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator - + var rd1 = undefined - a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd2 = undefined - b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd3 = undefined - 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd4 = undefined - E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd5 = a - undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd6 = b - undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd7 = 0 - undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd8 = E.b - undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator << + var re1 = undefined << a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re2 = undefined << b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re3 = undefined << 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re4 = undefined << E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re5 = a << undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re6 = b << undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re7 = 0 << undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re8 = E.b << undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator >> + var rf1 = undefined >> a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf2 = undefined >> b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf3 = undefined >> 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf4 = undefined >> E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf5 = a >> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf6 = b >> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf7 = 0 >> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf8 = E.b >> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator >>> + var rg1 = undefined >>> a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg2 = undefined >>> b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg3 = undefined >>> 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg4 = undefined >>> E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg5 = a >>> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg6 = b >>> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg7 = 0 >>> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg8 = E.b >>> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator & + var rh1 = undefined & a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh2 = undefined & b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh3 = undefined & 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh4 = undefined & E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh5 = a & undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh6 = b & undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh7 = 0 & undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh8 = E.b & undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator ^ + var ri1 = undefined ^ a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri2 = undefined ^ b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri3 = undefined ^ 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri4 = undefined ^ E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri5 = a ^ undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri6 = b ^ undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri7 = 0 ^ undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri8 = E.b ^ undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator | + var rj1 = undefined | a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj2 = undefined | b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj3 = undefined | 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj4 = undefined | E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj5 = a | undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj6 = b | undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj7 = 0 | undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj8 = E.b | undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/arrayAssignmentTest1.js b/tests/baselines/reference/arrayAssignmentTest1.js index a887203cd5e..511d37b1752 100644 --- a/tests/baselines/reference/arrayAssignmentTest1.js +++ b/tests/baselines/reference/arrayAssignmentTest1.js @@ -86,11 +86,16 @@ arr_any = c3; // should be an error - is arr_any = i1; // should be an error - is //// [arrayAssignmentTest1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1() { } @@ -101,7 +106,7 @@ var C1 = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C2.prototype.C2M1 = function () { return null; }; return C2; diff --git a/tests/baselines/reference/arrayAssignmentTest2.js b/tests/baselines/reference/arrayAssignmentTest2.js index d82dedff29d..233ea1b1159 100644 --- a/tests/baselines/reference/arrayAssignmentTest2.js +++ b/tests/baselines/reference/arrayAssignmentTest2.js @@ -60,11 +60,16 @@ arr_any = i1; // should be an error - is //// [arrayAssignmentTest2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1() { } @@ -75,7 +80,7 @@ var C1 = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C2.prototype.C2M1 = function () { return null; }; return C2; diff --git a/tests/baselines/reference/arrayBestCommonTypes.js b/tests/baselines/reference/arrayBestCommonTypes.js index b7ddaa5d6da..3a0ab1a5cf5 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.js +++ b/tests/baselines/reference/arrayBestCommonTypes.js @@ -108,11 +108,16 @@ module NonEmptyTypes { //// [arrayBestCommonTypes.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var EmptyTypes; (function (EmptyTypes) { var base = (function () { @@ -128,7 +133,7 @@ var EmptyTypes; var derived = (function (_super) { __extends(derived, _super); function derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return derived; }(base)); @@ -187,7 +192,7 @@ var NonEmptyTypes; var derived = (function (_super) { __extends(derived, _super); function derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return derived; }(base)); diff --git a/tests/baselines/reference/arrayLiteralTypeInference.js b/tests/baselines/reference/arrayLiteralTypeInference.js index 919d3a5e922..d9b830e8184 100644 --- a/tests/baselines/reference/arrayLiteralTypeInference.js +++ b/tests/baselines/reference/arrayLiteralTypeInference.js @@ -52,11 +52,16 @@ var z3: { id: number }[] = //// [arrayLiteralTypeInference.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Action = (function () { function Action() { } @@ -65,14 +70,14 @@ var Action = (function () { var ActionA = (function (_super) { __extends(ActionA, _super); function ActionA() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ActionA; }(Action)); var ActionB = (function (_super) { __extends(ActionB, _super); function ActionB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ActionB; }(Action)); diff --git a/tests/baselines/reference/arrayLiterals.js b/tests/baselines/reference/arrayLiterals.js index 530cdedec73..8041ac399f0 100644 --- a/tests/baselines/reference/arrayLiterals.js +++ b/tests/baselines/reference/arrayLiterals.js @@ -38,11 +38,16 @@ var context4: Base[] = [new Derived1(), new Derived1()]; //// [arrayLiterals.js] // Empty array literal with no contextual type has type 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var arr1 = [[], [1], ['']]; var arr2 = [[null], [1], ['']]; // Array literal with elements of only EveryType E has type E[] @@ -70,7 +75,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived1; }(Base)); @@ -78,7 +83,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js index c0f320ac1e5..8321a572178 100644 --- a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js +++ b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js @@ -26,11 +26,16 @@ var myDerivedList: DerivedList; var as = [list, myDerivedList]; // List[] //// [arrayLiteralsWithRecursiveGenerics.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var List = (function () { function List() { } @@ -39,7 +44,7 @@ var List = (function () { var DerivedList = (function (_super) { __extends(DerivedList, _super); function DerivedList() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return DerivedList; }(List)); diff --git a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js index d1d75e8041c..b2164a07b81 100644 --- a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js +++ b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js @@ -20,11 +20,16 @@ rrb = cra; // error: 'A' is not assignable to 'B' //// [arrayOfSubtypeIsAssignableToReadonlyArray.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -33,14 +38,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(Array)); diff --git a/tests/baselines/reference/arraySlice.js b/tests/baselines/reference/arraySlice.js new file mode 100644 index 00000000000..a5e4ba1546e --- /dev/null +++ b/tests/baselines/reference/arraySlice.js @@ -0,0 +1,8 @@ +//// [arraySlice.ts] +var arr: string[] | number[]; +arr.splice(1, 1); + + +//// [arraySlice.js] +var arr; +arr.splice(1, 1); diff --git a/tests/baselines/reference/arraySlice.symbols b/tests/baselines/reference/arraySlice.symbols new file mode 100644 index 00000000000..3b6545f9349 --- /dev/null +++ b/tests/baselines/reference/arraySlice.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/arraySlice.ts === +var arr: string[] | number[]; +>arr : Symbol(arr, Decl(arraySlice.ts, 0, 3)) + +arr.splice(1, 1); +>arr.splice : Symbol(splice, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>arr : Symbol(arr, Decl(arraySlice.ts, 0, 3)) +>splice : Symbol(splice, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/arraySlice.types b/tests/baselines/reference/arraySlice.types new file mode 100644 index 00000000000..d1ee482ccaa --- /dev/null +++ b/tests/baselines/reference/arraySlice.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/arraySlice.ts === +var arr: string[] | number[]; +>arr : string[] | number[] + +arr.splice(1, 1); +>arr.splice(1, 1) : string[] | number[] +>arr.splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } | { (start: number, deleteCount?: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; } +>arr : string[] | number[] +>splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } | { (start: number, deleteCount?: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; } +>1 : 1 +>1 : 1 + diff --git a/tests/baselines/reference/arrowFunctionContexts.js b/tests/baselines/reference/arrowFunctionContexts.js index 1af0797b41f..2285aadd3d5 100644 --- a/tests/baselines/reference/arrowFunctionContexts.js +++ b/tests/baselines/reference/arrowFunctionContexts.js @@ -97,11 +97,16 @@ var asserted2: any; //// [arrowFunctionContexts.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _this = this; // Arrow function used in with statement with (window) { diff --git a/tests/baselines/reference/assignObjectToNonPrimitive.js b/tests/baselines/reference/assignObjectToNonPrimitive.js new file mode 100644 index 00000000000..ec0015fba8a --- /dev/null +++ b/tests/baselines/reference/assignObjectToNonPrimitive.js @@ -0,0 +1,14 @@ +//// [assignObjectToNonPrimitive.ts] +var x = {}; +var y = {foo: "bar"}; +var a: object; +a = x; +a = y; + + +//// [assignObjectToNonPrimitive.js] +var x = {}; +var y = { foo: "bar" }; +var a; +a = x; +a = y; diff --git a/tests/baselines/reference/assignObjectToNonPrimitive.symbols b/tests/baselines/reference/assignObjectToNonPrimitive.symbols new file mode 100644 index 00000000000..5c806e09b94 --- /dev/null +++ b/tests/baselines/reference/assignObjectToNonPrimitive.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/types/nonPrimitive/assignObjectToNonPrimitive.ts === +var x = {}; +>x : Symbol(x, Decl(assignObjectToNonPrimitive.ts, 0, 3)) + +var y = {foo: "bar"}; +>y : Symbol(y, Decl(assignObjectToNonPrimitive.ts, 1, 3)) +>foo : Symbol(foo, Decl(assignObjectToNonPrimitive.ts, 1, 9)) + +var a: object; +>a : Symbol(a, Decl(assignObjectToNonPrimitive.ts, 2, 3)) + +a = x; +>a : Symbol(a, Decl(assignObjectToNonPrimitive.ts, 2, 3)) +>x : Symbol(x, Decl(assignObjectToNonPrimitive.ts, 0, 3)) + +a = y; +>a : Symbol(a, Decl(assignObjectToNonPrimitive.ts, 2, 3)) +>y : Symbol(y, Decl(assignObjectToNonPrimitive.ts, 1, 3)) + diff --git a/tests/baselines/reference/assignObjectToNonPrimitive.types b/tests/baselines/reference/assignObjectToNonPrimitive.types new file mode 100644 index 00000000000..f16c2287155 --- /dev/null +++ b/tests/baselines/reference/assignObjectToNonPrimitive.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/types/nonPrimitive/assignObjectToNonPrimitive.ts === +var x = {}; +>x : {} +>{} : {} + +var y = {foo: "bar"}; +>y : { foo: string; } +>{foo: "bar"} : { foo: string; } +>foo : string +>"bar" : "bar" + +var a: object; +>a : object + +a = x; +>a = x : {} +>a : object +>x : {} + +a = y; +>a = y : { foo: string; } +>a : object +>y : { foo: string; } + diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures3.js b/tests/baselines/reference/assignmentCompatWithCallSignatures3.js index c5a1f415437..58fd19326ee 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures3.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures3.js @@ -101,11 +101,16 @@ b18 = a18; // ok //// [assignmentCompatWithCallSignatures3.js] // these are all permitted with the current rules, since we do not do contextual signature instantiation -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -114,21 +119,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.js b/tests/baselines/reference/assignmentCompatWithCallSignatures4.js index 58faf663ea8..37030895006 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures4.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.js @@ -100,11 +100,16 @@ module Errors { //// [assignmentCompatWithCallSignatures4.js] // These are mostly permitted with the current loose rules. All ok unless otherwise noted. -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Errors; (function (Errors) { var Base = (function () { @@ -115,21 +120,21 @@ var Errors; var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures5.js b/tests/baselines/reference/assignmentCompatWithCallSignatures5.js index 87506cad08f..17ebf51308b 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures5.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures5.js @@ -67,11 +67,16 @@ b18 = a18; // ok //// [assignmentCompatWithCallSignatures5.js] // checking assignment compat for function types. No errors in this file -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -80,21 +85,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures6.js b/tests/baselines/reference/assignmentCompatWithCallSignatures6.js index 2c05d5960b2..905ef432786 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures6.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures6.js @@ -44,11 +44,16 @@ b16 = x.a16; //// [assignmentCompatWithCallSignatures6.js] // checking assignment compatibility relations for function types. All 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -57,21 +62,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js index 76ad53e4e05..25f267c19c8 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js @@ -101,11 +101,16 @@ b18 = a18; // ok //// [assignmentCompatWithConstructSignatures3.js] // checking assignment compatibility relations for function types. All of these are 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -114,21 +119,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js index f516df153c6..879b24a3dde 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js @@ -100,11 +100,16 @@ module Errors { //// [assignmentCompatWithConstructSignatures4.js] // checking assignment compatibility relations for function types. -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Errors; (function (Errors) { var Base = (function () { @@ -115,21 +120,21 @@ var Errors; var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js index ef7de7f011b..b2d722c6791 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js @@ -67,11 +67,16 @@ b18 = a18; // ok //// [assignmentCompatWithConstructSignatures5.js] // checking assignment compat for function types. All 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -80,21 +85,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js index 3d58ae707a5..6c68a3edbfe 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js @@ -44,11 +44,16 @@ b16 = x.a16; //// [assignmentCompatWithConstructSignatures6.js] // checking assignment compatibility relations for function types. All 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -57,21 +62,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer.js b/tests/baselines/reference/assignmentCompatWithNumericIndexer.js index 37160506683..e05538472fe 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer.js +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer.js @@ -45,11 +45,16 @@ module Generics { //// [assignmentCompatWithNumericIndexer.js] // Derived type indexer must be subtype of base type indexer -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -72,7 +77,7 @@ var Generics; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js index 2e6ecd72741..6ea115fde33 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js @@ -42,11 +42,16 @@ module Generics { //// [assignmentCompatWithNumericIndexer3.js] // Derived type indexer must be subtype of base type indexer -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -59,7 +64,7 @@ b = a; // ok var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers4.js b/tests/baselines/reference/assignmentCompatWithObjectMembers4.js index 2cc2510c8da..bdd502ee027 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembers4.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers4.js @@ -93,11 +93,16 @@ module WithBase { //// [assignmentCompatWithObjectMembers4.js] // members N and M of types S and T have the same name, same accessibility, same optionality, and N is not assignable 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var OnlyDerived; (function (OnlyDerived) { var Base = (function () { @@ -108,14 +113,14 @@ var OnlyDerived; var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); @@ -167,14 +172,14 @@ var WithBase; var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js index 3b12701b3d9..b5274280b31 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js @@ -90,11 +90,16 @@ module SourceHasOptional { //// [assignmentCompatWithObjectMembersOptionality.js] // Derived member is not optional but base member is, should be 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -103,14 +108,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js index f965d18e2ce..e158a787878 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js @@ -92,11 +92,16 @@ module SourceHasOptional { //// [assignmentCompatWithObjectMembersOptionality2.js] // M is optional and S contains no property with the same name as M // N is optional and T contains no property with the same name as 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -105,14 +110,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer.js b/tests/baselines/reference/assignmentCompatWithStringIndexer.js index 8d081c90794..8f3b23cfffb 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer.js +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer.js @@ -55,11 +55,16 @@ module Generics { //// [assignmentCompatWithStringIndexer.js] // index signatures must be compatible in assignments -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -82,7 +87,7 @@ var Generics; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -93,7 +98,7 @@ var Generics; var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); diff --git a/tests/baselines/reference/assignmentLHSIsValue.js b/tests/baselines/reference/assignmentLHSIsValue.js index 155fa26fa81..34e0df7cacd 100644 --- a/tests/baselines/reference/assignmentLHSIsValue.js +++ b/tests/baselines/reference/assignmentLHSIsValue.js @@ -71,11 +71,16 @@ foo() = value; (foo()) = value; //// [assignmentLHSIsValue.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // expected error for all the LHS of assignments var value; // this diff --git a/tests/baselines/reference/asyncAwaitWithCapturedBlockScopeVar.js b/tests/baselines/reference/asyncAwaitWithCapturedBlockScopeVar.js index 49566904ae1..6d167a00089 100644 --- a/tests/baselines/reference/asyncAwaitWithCapturedBlockScopeVar.js +++ b/tests/baselines/reference/asyncAwaitWithCapturedBlockScopeVar.js @@ -57,8 +57,7 @@ function fn1() { i = 0; _a.label = 1; case 1: - if (!(i < 1)) - return [3 /*break*/, 4]; + if (!(i < 1)) return [3 /*break*/, 4]; return [5 /*yield**/, _loop_1(i)]; case 2: _a.sent(); @@ -92,8 +91,7 @@ function fn2() { i = 0; _a.label = 1; case 1: - if (!(i < 1)) - return [3 /*break*/, 4]; + if (!(i < 1)) return [3 /*break*/, 4]; return [5 /*yield**/, _loop_2(i)]; case 2: state_1 = _a.sent(); @@ -129,8 +127,7 @@ function fn3() { i = 0; _a.label = 1; case 1: - if (!(i < 1)) - return [3 /*break*/, 4]; + if (!(i < 1)) return [3 /*break*/, 4]; return [5 /*yield**/, _loop_3(i)]; case 2: _a.sent(); @@ -164,8 +161,7 @@ function fn4() { i = 0; _a.label = 1; case 1: - if (!(i < 1)) - return [3 /*break*/, 4]; + if (!(i < 1)) return [3 /*break*/, 4]; return [5 /*yield**/, _loop_4(i)]; case 2: state_2 = _a.sent(); diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt index d5da3432264..33cd913a2eb 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt @@ -4,10 +4,11 @@ tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclarati tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,33): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,38): error TS1005: ';' expected. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,39): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,49): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,53): error TS1109: Expression expected. -==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts (7 errors) ==== +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts (8 errors) ==== async function foo(a = await => await): Promise { ~~~~~~~~~ !!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. @@ -21,6 +22,8 @@ tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclarati !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es5.errors.txt index dc814e9c887..b974eacd882 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es5.errors.txt @@ -4,10 +4,11 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1 tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,33): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,38): error TS1005: ';' expected. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,39): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,49): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,53): error TS1109: Expression expected. -==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts (7 errors) ==== +==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts (8 errors) ==== async function foo(a = await => await): Promise { ~~~~~~~~~ !!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. @@ -21,6 +22,8 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1 !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt index 15ceb3e60c7..b752ec94a45 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt @@ -4,10 +4,11 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,38): error TS1005: ';' expected. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,39): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,49): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,53): error TS1109: Expression expected. -==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts (7 errors) ==== +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts (8 errors) ==== async function foo(a = await => await): Promise { ~~~~~~~~~ !!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. @@ -21,6 +22,8 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1 !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt index ad8c0280206..1fc74dfa0a2 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt @@ -2,10 +2,11 @@ tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclarati tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,20): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,25): error TS1005: ';' expected. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,26): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,36): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,40): error TS1109: Expression expected. -==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts (5 errors) ==== +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts (6 errors) ==== async function foo(await): Promise { ~~~~~ !!! error TS1138: Parameter declaration expected. @@ -15,6 +16,8 @@ tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclarati !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration5_es5.errors.txt index 3060c2c836b..48299773218 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es5.errors.txt @@ -2,10 +2,11 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5 tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,20): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,25): error TS1005: ';' expected. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,26): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,36): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,40): error TS1109: Expression expected. -==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts (5 errors) ==== +==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts (6 errors) ==== async function foo(await): Promise { ~~~~~ !!! error TS1138: Parameter declaration expected. @@ -15,6 +16,8 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5 !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt index a6944e0c6e6..2e907d13400 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt @@ -2,10 +2,11 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,20): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,25): error TS1005: ';' expected. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,26): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,36): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,40): error TS1109: Expression expected. -==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts (5 errors) ==== +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts (6 errors) ==== async function foo(await): Promise { ~~~~~ !!! error TS1138: Parameter declaration expected. @@ -15,6 +16,8 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5 !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionReturnType.js b/tests/baselines/reference/asyncFunctionReturnType.js index dcdead47c6b..6e39e72ae4c 100644 --- a/tests/baselines/reference/asyncFunctionReturnType.js +++ b/tests/baselines/reference/asyncFunctionReturnType.js @@ -8,7 +8,72 @@ async function fAsyncExplicit(): Promise<[number, boolean]> { // This is contextually typed as a tuple. return [1, true]; } - + +// https://github.com/Microsoft/TypeScript/issues/13128 +interface Obj { + stringProp: string; + anyProp: any; +} + +async function fIndexedTypeForStringProp(obj: Obj): Promise { + return obj.stringProp; +} + +async function fIndexedTypeForPromiseOfStringProp(obj: Obj): Promise { + return Promise.resolve(obj.stringProp); +} + +async function fIndexedTypeForExplicitPromiseOfStringProp(obj: Obj): Promise { + return Promise.resolve(obj.stringProp); +} + +async function fIndexedTypeForAnyProp(obj: Obj): Promise { + return obj.anyProp; +} + +async function fIndexedTypeForPromiseOfAnyProp(obj: Obj): Promise { + return Promise.resolve(obj.anyProp); +} + +async function fIndexedTypeForExplicitPromiseOfAnyProp(obj: Obj): Promise { + return Promise.resolve(obj.anyProp); +} + +async function fGenericIndexedTypeForStringProp(obj: TObj): Promise { + return obj.stringProp; +} + +async function fGenericIndexedTypeForPromiseOfStringProp(obj: TObj): Promise { + return Promise.resolve(obj.stringProp); +} + +async function fGenericIndexedTypeForExplicitPromiseOfStringProp(obj: TObj): Promise { + return Promise.resolve(obj.stringProp); +} + +async function fGenericIndexedTypeForAnyProp(obj: TObj): Promise { + return obj.anyProp; +} + +async function fGenericIndexedTypeForPromiseOfAnyProp(obj: TObj): Promise { + return Promise.resolve(obj.anyProp); +} + +async function fGenericIndexedTypeForExplicitPromiseOfAnyProp(obj: TObj): Promise { + return Promise.resolve(obj.anyProp); +} + +async function fGenericIndexedTypeForKProp(obj: TObj, key: K): Promise { + return obj[key]; +} + +async function fGenericIndexedTypeForPromiseOfKProp(obj: TObj, key: K): Promise { + return Promise.resolve(obj[key]); +} + +async function fGenericIndexedTypeForExplicitPromiseOfKProp(obj: TObj, key: K): Promise { + return Promise.resolve(obj[key]); +} //// [asyncFunctionReturnType.js] var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { @@ -31,3 +96,78 @@ function fAsyncExplicit() { return [1, true]; }); } +function fIndexedTypeForStringProp(obj) { + return __awaiter(this, void 0, void 0, function* () { + return obj.stringProp; + }); +} +function fIndexedTypeForPromiseOfStringProp(obj) { + return __awaiter(this, void 0, void 0, function* () { + return Promise.resolve(obj.stringProp); + }); +} +function fIndexedTypeForExplicitPromiseOfStringProp(obj) { + return __awaiter(this, void 0, void 0, function* () { + return Promise.resolve(obj.stringProp); + }); +} +function fIndexedTypeForAnyProp(obj) { + return __awaiter(this, void 0, void 0, function* () { + return obj.anyProp; + }); +} +function fIndexedTypeForPromiseOfAnyProp(obj) { + return __awaiter(this, void 0, void 0, function* () { + return Promise.resolve(obj.anyProp); + }); +} +function fIndexedTypeForExplicitPromiseOfAnyProp(obj) { + return __awaiter(this, void 0, void 0, function* () { + return Promise.resolve(obj.anyProp); + }); +} +function fGenericIndexedTypeForStringProp(obj) { + return __awaiter(this, void 0, void 0, function* () { + return obj.stringProp; + }); +} +function fGenericIndexedTypeForPromiseOfStringProp(obj) { + return __awaiter(this, void 0, void 0, function* () { + return Promise.resolve(obj.stringProp); + }); +} +function fGenericIndexedTypeForExplicitPromiseOfStringProp(obj) { + return __awaiter(this, void 0, void 0, function* () { + return Promise.resolve(obj.stringProp); + }); +} +function fGenericIndexedTypeForAnyProp(obj) { + return __awaiter(this, void 0, void 0, function* () { + return obj.anyProp; + }); +} +function fGenericIndexedTypeForPromiseOfAnyProp(obj) { + return __awaiter(this, void 0, void 0, function* () { + return Promise.resolve(obj.anyProp); + }); +} +function fGenericIndexedTypeForExplicitPromiseOfAnyProp(obj) { + return __awaiter(this, void 0, void 0, function* () { + return Promise.resolve(obj.anyProp); + }); +} +function fGenericIndexedTypeForKProp(obj, key) { + return __awaiter(this, void 0, void 0, function* () { + return obj[key]; + }); +} +function fGenericIndexedTypeForPromiseOfKProp(obj, key) { + return __awaiter(this, void 0, void 0, function* () { + return Promise.resolve(obj[key]); + }); +} +function fGenericIndexedTypeForExplicitPromiseOfKProp(obj, key) { + return __awaiter(this, void 0, void 0, function* () { + return Promise.resolve(obj[key]); + }); +} diff --git a/tests/baselines/reference/asyncFunctionReturnType.symbols b/tests/baselines/reference/asyncFunctionReturnType.symbols index 75e456b6a8b..d5aa71c9e51 100644 --- a/tests/baselines/reference/asyncFunctionReturnType.symbols +++ b/tests/baselines/reference/asyncFunctionReturnType.symbols @@ -14,3 +14,274 @@ async function fAsyncExplicit(): Promise<[number, boolean]> { return [1, true]; } +// https://github.com/Microsoft/TypeScript/issues/13128 +interface Obj { +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) + + stringProp: string; +>stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15)) + + anyProp: any; +>anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23)) +} + +async function fIndexedTypeForStringProp(obj: Obj): Promise { +>fIndexedTypeForStringProp : Symbol(fIndexedTypeForStringProp, Decl(asyncFunctionReturnType.ts, 14, 1)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 16, 41)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) + + return obj.stringProp; +>obj.stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 16, 41)) +>stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15)) +} + +async function fIndexedTypeForPromiseOfStringProp(obj: Obj): Promise { +>fIndexedTypeForPromiseOfStringProp : Symbol(fIndexedTypeForPromiseOfStringProp, Decl(asyncFunctionReturnType.ts, 18, 1)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 20, 50)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) + + return Promise.resolve(obj.stringProp); +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>obj.stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 20, 50)) +>stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15)) +} + +async function fIndexedTypeForExplicitPromiseOfStringProp(obj: Obj): Promise { +>fIndexedTypeForExplicitPromiseOfStringProp : Symbol(fIndexedTypeForExplicitPromiseOfStringProp, Decl(asyncFunctionReturnType.ts, 22, 1)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 24, 58)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) + + return Promise.resolve(obj.stringProp); +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) +>obj.stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 24, 58)) +>stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15)) +} + +async function fIndexedTypeForAnyProp(obj: Obj): Promise { +>fIndexedTypeForAnyProp : Symbol(fIndexedTypeForAnyProp, Decl(asyncFunctionReturnType.ts, 26, 1)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 28, 38)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) + + return obj.anyProp; +>obj.anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 28, 38)) +>anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23)) +} + +async function fIndexedTypeForPromiseOfAnyProp(obj: Obj): Promise { +>fIndexedTypeForPromiseOfAnyProp : Symbol(fIndexedTypeForPromiseOfAnyProp, Decl(asyncFunctionReturnType.ts, 30, 1)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 32, 47)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) + + return Promise.resolve(obj.anyProp); +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>obj.anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 32, 47)) +>anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23)) +} + +async function fIndexedTypeForExplicitPromiseOfAnyProp(obj: Obj): Promise { +>fIndexedTypeForExplicitPromiseOfAnyProp : Symbol(fIndexedTypeForExplicitPromiseOfAnyProp, Decl(asyncFunctionReturnType.ts, 34, 1)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 36, 55)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) + + return Promise.resolve(obj.anyProp); +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) +>obj.anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 36, 55)) +>anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23)) +} + +async function fGenericIndexedTypeForStringProp(obj: TObj): Promise { +>fGenericIndexedTypeForStringProp : Symbol(fGenericIndexedTypeForStringProp, Decl(asyncFunctionReturnType.ts, 38, 1)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 40, 48)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 40, 66)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 40, 48)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 40, 48)) + + return obj.stringProp; +>obj.stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 40, 66)) +>stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15)) +} + +async function fGenericIndexedTypeForPromiseOfStringProp(obj: TObj): Promise { +>fGenericIndexedTypeForPromiseOfStringProp : Symbol(fGenericIndexedTypeForPromiseOfStringProp, Decl(asyncFunctionReturnType.ts, 42, 1)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 44, 57)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 44, 75)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 44, 57)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 44, 57)) + + return Promise.resolve(obj.stringProp); +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>obj.stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 44, 75)) +>stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15)) +} + +async function fGenericIndexedTypeForExplicitPromiseOfStringProp(obj: TObj): Promise { +>fGenericIndexedTypeForExplicitPromiseOfStringProp : Symbol(fGenericIndexedTypeForExplicitPromiseOfStringProp, Decl(asyncFunctionReturnType.ts, 46, 1)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 48, 65)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 48, 83)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 48, 65)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 48, 65)) + + return Promise.resolve(obj.stringProp); +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 48, 65)) +>obj.stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 48, 83)) +>stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15)) +} + +async function fGenericIndexedTypeForAnyProp(obj: TObj): Promise { +>fGenericIndexedTypeForAnyProp : Symbol(fGenericIndexedTypeForAnyProp, Decl(asyncFunctionReturnType.ts, 50, 1)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 52, 45)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 52, 63)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 52, 45)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 52, 45)) + + return obj.anyProp; +>obj.anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 52, 63)) +>anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23)) +} + +async function fGenericIndexedTypeForPromiseOfAnyProp(obj: TObj): Promise { +>fGenericIndexedTypeForPromiseOfAnyProp : Symbol(fGenericIndexedTypeForPromiseOfAnyProp, Decl(asyncFunctionReturnType.ts, 54, 1)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 56, 54)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 56, 72)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 56, 54)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 56, 54)) + + return Promise.resolve(obj.anyProp); +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>obj.anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 56, 72)) +>anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23)) +} + +async function fGenericIndexedTypeForExplicitPromiseOfAnyProp(obj: TObj): Promise { +>fGenericIndexedTypeForExplicitPromiseOfAnyProp : Symbol(fGenericIndexedTypeForExplicitPromiseOfAnyProp, Decl(asyncFunctionReturnType.ts, 58, 1)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 60, 62)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 60, 80)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 60, 62)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 60, 62)) + + return Promise.resolve(obj.anyProp); +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 60, 62)) +>obj.anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 60, 80)) +>anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23)) +} + +async function fGenericIndexedTypeForKProp(obj: TObj, key: K): Promise { +>fGenericIndexedTypeForKProp : Symbol(fGenericIndexedTypeForKProp, Decl(asyncFunctionReturnType.ts, 62, 1)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 64, 43)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) +>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 64, 60)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 64, 43)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 64, 83)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 64, 43)) +>key : Symbol(key, Decl(asyncFunctionReturnType.ts, 64, 93)) +>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 64, 60)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 64, 43)) +>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 64, 60)) + + return obj[key]; +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 64, 83)) +>key : Symbol(key, Decl(asyncFunctionReturnType.ts, 64, 93)) +} + +async function fGenericIndexedTypeForPromiseOfKProp(obj: TObj, key: K): Promise { +>fGenericIndexedTypeForPromiseOfKProp : Symbol(fGenericIndexedTypeForPromiseOfKProp, Decl(asyncFunctionReturnType.ts, 66, 1)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 68, 52)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) +>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 68, 69)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 68, 52)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 68, 92)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 68, 52)) +>key : Symbol(key, Decl(asyncFunctionReturnType.ts, 68, 102)) +>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 68, 69)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 68, 52)) +>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 68, 69)) + + return Promise.resolve(obj[key]); +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 68, 92)) +>key : Symbol(key, Decl(asyncFunctionReturnType.ts, 68, 102)) +} + +async function fGenericIndexedTypeForExplicitPromiseOfKProp(obj: TObj, key: K): Promise { +>fGenericIndexedTypeForExplicitPromiseOfKProp : Symbol(fGenericIndexedTypeForExplicitPromiseOfKProp, Decl(asyncFunctionReturnType.ts, 70, 1)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 72, 60)) +>Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) +>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 72, 77)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 72, 60)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 72, 100)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 72, 60)) +>key : Symbol(key, Decl(asyncFunctionReturnType.ts, 72, 110)) +>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 72, 77)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 72, 60)) +>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 72, 77)) + + return Promise.resolve(obj[key]); +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 72, 60)) +>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 72, 77)) +>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 72, 100)) +>key : Symbol(key, Decl(asyncFunctionReturnType.ts, 72, 110)) +} diff --git a/tests/baselines/reference/asyncFunctionReturnType.types b/tests/baselines/reference/asyncFunctionReturnType.types index db9f8e42d52..d1dab14ba87 100644 --- a/tests/baselines/reference/asyncFunctionReturnType.types +++ b/tests/baselines/reference/asyncFunctionReturnType.types @@ -20,3 +20,287 @@ async function fAsyncExplicit(): Promise<[number, boolean]> { >true : true } +// https://github.com/Microsoft/TypeScript/issues/13128 +interface Obj { +>Obj : Obj + + stringProp: string; +>stringProp : string + + anyProp: any; +>anyProp : any +} + +async function fIndexedTypeForStringProp(obj: Obj): Promise { +>fIndexedTypeForStringProp : (obj: Obj) => Promise +>obj : Obj +>Obj : Obj +>Promise : Promise +>Obj : Obj + + return obj.stringProp; +>obj.stringProp : string +>obj : Obj +>stringProp : string +} + +async function fIndexedTypeForPromiseOfStringProp(obj: Obj): Promise { +>fIndexedTypeForPromiseOfStringProp : (obj: Obj) => Promise +>obj : Obj +>Obj : Obj +>Promise : Promise +>Obj : Obj + + return Promise.resolve(obj.stringProp); +>Promise.resolve(obj.stringProp) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>obj.stringProp : string +>obj : Obj +>stringProp : string +} + +async function fIndexedTypeForExplicitPromiseOfStringProp(obj: Obj): Promise { +>fIndexedTypeForExplicitPromiseOfStringProp : (obj: Obj) => Promise +>obj : Obj +>Obj : Obj +>Promise : Promise +>Obj : Obj + + return Promise.resolve(obj.stringProp); +>Promise.resolve(obj.stringProp) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Obj : Obj +>obj.stringProp : string +>obj : Obj +>stringProp : string +} + +async function fIndexedTypeForAnyProp(obj: Obj): Promise { +>fIndexedTypeForAnyProp : (obj: Obj) => Promise +>obj : Obj +>Obj : Obj +>Promise : Promise +>Obj : Obj + + return obj.anyProp; +>obj.anyProp : any +>obj : Obj +>anyProp : any +} + +async function fIndexedTypeForPromiseOfAnyProp(obj: Obj): Promise { +>fIndexedTypeForPromiseOfAnyProp : (obj: Obj) => Promise +>obj : Obj +>Obj : Obj +>Promise : Promise +>Obj : Obj + + return Promise.resolve(obj.anyProp); +>Promise.resolve(obj.anyProp) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>obj.anyProp : any +>obj : Obj +>anyProp : any +} + +async function fIndexedTypeForExplicitPromiseOfAnyProp(obj: Obj): Promise { +>fIndexedTypeForExplicitPromiseOfAnyProp : (obj: Obj) => Promise +>obj : Obj +>Obj : Obj +>Promise : Promise +>Obj : Obj + + return Promise.resolve(obj.anyProp); +>Promise.resolve(obj.anyProp) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Obj : Obj +>obj.anyProp : any +>obj : Obj +>anyProp : any +} + +async function fGenericIndexedTypeForStringProp(obj: TObj): Promise { +>fGenericIndexedTypeForStringProp : (obj: TObj) => Promise +>TObj : TObj +>Obj : Obj +>obj : TObj +>TObj : TObj +>Promise : Promise +>TObj : TObj + + return obj.stringProp; +>obj.stringProp : string +>obj : TObj +>stringProp : string +} + +async function fGenericIndexedTypeForPromiseOfStringProp(obj: TObj): Promise { +>fGenericIndexedTypeForPromiseOfStringProp : (obj: TObj) => Promise +>TObj : TObj +>Obj : Obj +>obj : TObj +>TObj : TObj +>Promise : Promise +>TObj : TObj + + return Promise.resolve(obj.stringProp); +>Promise.resolve(obj.stringProp) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>obj.stringProp : string +>obj : TObj +>stringProp : string +} + +async function fGenericIndexedTypeForExplicitPromiseOfStringProp(obj: TObj): Promise { +>fGenericIndexedTypeForExplicitPromiseOfStringProp : (obj: TObj) => Promise +>TObj : TObj +>Obj : Obj +>obj : TObj +>TObj : TObj +>Promise : Promise +>TObj : TObj + + return Promise.resolve(obj.stringProp); +>Promise.resolve(obj.stringProp) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>TObj : TObj +>obj.stringProp : string +>obj : TObj +>stringProp : string +} + +async function fGenericIndexedTypeForAnyProp(obj: TObj): Promise { +>fGenericIndexedTypeForAnyProp : (obj: TObj) => Promise +>TObj : TObj +>Obj : Obj +>obj : TObj +>TObj : TObj +>Promise : Promise +>TObj : TObj + + return obj.anyProp; +>obj.anyProp : any +>obj : TObj +>anyProp : any +} + +async function fGenericIndexedTypeForPromiseOfAnyProp(obj: TObj): Promise { +>fGenericIndexedTypeForPromiseOfAnyProp : (obj: TObj) => Promise +>TObj : TObj +>Obj : Obj +>obj : TObj +>TObj : TObj +>Promise : Promise +>TObj : TObj + + return Promise.resolve(obj.anyProp); +>Promise.resolve(obj.anyProp) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>obj.anyProp : any +>obj : TObj +>anyProp : any +} + +async function fGenericIndexedTypeForExplicitPromiseOfAnyProp(obj: TObj): Promise { +>fGenericIndexedTypeForExplicitPromiseOfAnyProp : (obj: TObj) => Promise +>TObj : TObj +>Obj : Obj +>obj : TObj +>TObj : TObj +>Promise : Promise +>TObj : TObj + + return Promise.resolve(obj.anyProp); +>Promise.resolve(obj.anyProp) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>TObj : TObj +>obj.anyProp : any +>obj : TObj +>anyProp : any +} + +async function fGenericIndexedTypeForKProp(obj: TObj, key: K): Promise { +>fGenericIndexedTypeForKProp : (obj: TObj, key: K) => Promise +>TObj : TObj +>Obj : Obj +>K : K +>TObj : TObj +>obj : TObj +>TObj : TObj +>key : K +>K : K +>Promise : Promise +>TObj : TObj +>K : K + + return obj[key]; +>obj[key] : TObj[K] +>obj : TObj +>key : K +} + +async function fGenericIndexedTypeForPromiseOfKProp(obj: TObj, key: K): Promise { +>fGenericIndexedTypeForPromiseOfKProp : (obj: TObj, key: K) => Promise +>TObj : TObj +>Obj : Obj +>K : K +>TObj : TObj +>obj : TObj +>TObj : TObj +>key : K +>K : K +>Promise : Promise +>TObj : TObj +>K : K + + return Promise.resolve(obj[key]); +>Promise.resolve(obj[key]) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>obj[key] : TObj[K] +>obj : TObj +>key : K +} + +async function fGenericIndexedTypeForExplicitPromiseOfKProp(obj: TObj, key: K): Promise { +>fGenericIndexedTypeForExplicitPromiseOfKProp : (obj: TObj, key: K) => Promise +>TObj : TObj +>Obj : Obj +>K : K +>TObj : TObj +>obj : TObj +>TObj : TObj +>key : K +>K : K +>Promise : Promise +>TObj : TObj +>K : K + + return Promise.resolve(obj[key]); +>Promise.resolve(obj[key]) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>TObj : TObj +>K : K +>obj[key] : TObj[K] +>obj : TObj +>key : K +} diff --git a/tests/baselines/reference/asyncImportedPromise_es5.js b/tests/baselines/reference/asyncImportedPromise_es5.js index 641b8e0381f..280e8a87916 100644 --- a/tests/baselines/reference/asyncImportedPromise_es5.js +++ b/tests/baselines/reference/asyncImportedPromise_es5.js @@ -11,15 +11,20 @@ class Test { //// [task.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Task = (function (_super) { __extends(Task, _super); function Task() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Task; }(Promise)); diff --git a/tests/baselines/reference/asyncMethodWithSuper_es5.js b/tests/baselines/reference/asyncMethodWithSuper_es5.js index 235f2763f9f..c68b1ed036f 100644 --- a/tests/baselines/reference/asyncMethodWithSuper_es5.js +++ b/tests/baselines/reference/asyncMethodWithSuper_es5.js @@ -61,7 +61,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } // async method with only call/get on 'super' does not require a binding B.prototype.simple = function () { diff --git a/tests/baselines/reference/asyncQualifiedReturnType_es5.js b/tests/baselines/reference/asyncQualifiedReturnType_es5.js index dd54f6ee833..3cae9ea6b56 100644 --- a/tests/baselines/reference/asyncQualifiedReturnType_es5.js +++ b/tests/baselines/reference/asyncQualifiedReturnType_es5.js @@ -13,7 +13,7 @@ var X; var MyPromise = (function (_super) { __extends(MyPromise, _super); function MyPromise() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return MyPromise; }(Promise)); diff --git a/tests/baselines/reference/autolift4.js b/tests/baselines/reference/autolift4.js index 1c29bfeeff7..6d91c61d59d 100644 --- a/tests/baselines/reference/autolift4.js +++ b/tests/baselines/reference/autolift4.js @@ -24,11 +24,16 @@ class Point3D extends Point { //// [autolift4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Point = (function () { function Point(x, y) { this.x = x; diff --git a/tests/baselines/reference/awaitClassExpression_es5.js b/tests/baselines/reference/awaitClassExpression_es5.js index b207ba08f8d..9cb8ce22f63 100644 --- a/tests/baselines/reference/awaitClassExpression_es5.js +++ b/tests/baselines/reference/awaitClassExpression_es5.js @@ -17,7 +17,7 @@ function func() { _a = function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }; diff --git a/tests/baselines/reference/await_unaryExpression_es2017_1.errors.txt b/tests/baselines/reference/await_unaryExpression_es2017_1.errors.txt new file mode 100644 index 00000000000..4a38371829d --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_1.errors.txt @@ -0,0 +1,29 @@ +tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts(7,12): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts(11,12): error TS2703: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts (2 errors) ==== + + async function bar() { + !await 42; // OK + } + + async function bar1() { + delete await 42; // OK + ~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + } + + async function bar2() { + delete await 42; // OK + ~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + } + + async function bar3() { + void await 42; + } + + async function bar4() { + +await 42; + } \ No newline at end of file diff --git a/tests/baselines/reference/await_unaryExpression_es2017_2.errors.txt b/tests/baselines/reference/await_unaryExpression_es2017_2.errors.txt new file mode 100644 index 00000000000..0f80ec02334 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_2.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts(3,12): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts(7,12): error TS2703: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts (2 errors) ==== + + async function bar1() { + delete await 42; + ~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + } + + async function bar2() { + delete await 42; + ~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + } + + async function bar3() { + void await 42; + } \ No newline at end of file diff --git a/tests/baselines/reference/await_unaryExpression_es6_1.errors.txt b/tests/baselines/reference/await_unaryExpression_es6_1.errors.txt new file mode 100644 index 00000000000..8212c2dd291 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_1.errors.txt @@ -0,0 +1,29 @@ +tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts(7,12): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts(11,12): error TS2703: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts (2 errors) ==== + + async function bar() { + !await 42; // OK + } + + async function bar1() { + delete await 42; // OK + ~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + } + + async function bar2() { + delete await 42; // OK + ~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + } + + async function bar3() { + void await 42; + } + + async function bar4() { + +await 42; + } \ No newline at end of file diff --git a/tests/baselines/reference/await_unaryExpression_es6_2.errors.txt b/tests/baselines/reference/await_unaryExpression_es6_2.errors.txt new file mode 100644 index 00000000000..cde22cc5549 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_2.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts(3,12): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts(7,12): error TS2703: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts (2 errors) ==== + + async function bar1() { + delete await 42; + ~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + } + + async function bar2() { + delete await 42; + ~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + } + + async function bar3() { + void await 42; + } \ No newline at end of file diff --git a/tests/baselines/reference/baseCheck.js b/tests/baselines/reference/baseCheck.js index 870f811c09f..2b4f90d27b1 100644 --- a/tests/baselines/reference/baseCheck.js +++ b/tests/baselines/reference/baseCheck.js @@ -30,11 +30,16 @@ function f() { //// [baseCheck.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 7e922cf83b2..e57e5272ade 100644 --- a/tests/baselines/reference/baseIndexSignatureResolution.js +++ b/tests/baselines/reference/baseIndexSignatureResolution.js @@ -25,11 +25,16 @@ var z: Derived = b.foo(); */ //// [baseIndexSignatureResolution.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -38,7 +43,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/baseTypeOrderChecking.js b/tests/baselines/reference/baseTypeOrderChecking.js index ec96b80a999..06e7dd0c681 100644 --- a/tests/baselines/reference/baseTypeOrderChecking.js +++ b/tests/baselines/reference/baseTypeOrderChecking.js @@ -37,11 +37,16 @@ class Class4 extends Class3 //// [baseTypeOrderChecking.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var someVariable; var Class1 = (function () { function Class1() { @@ -51,7 +56,7 @@ var Class1 = (function () { var Class2 = (function (_super) { __extends(Class2, _super); function Class2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Class2; }(Class1)); @@ -63,7 +68,7 @@ var Class3 = (function () { var Class4 = (function (_super) { __extends(Class4, _super); function Class4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Class4; }(Class3)); diff --git a/tests/baselines/reference/baseTypeWrappingInstantiationChain.js b/tests/baselines/reference/baseTypeWrappingInstantiationChain.js index 5f8dcbd0e10..7442d1e0e6a 100644 --- a/tests/baselines/reference/baseTypeWrappingInstantiationChain.js +++ b/tests/baselines/reference/baseTypeWrappingInstantiationChain.js @@ -28,11 +28,16 @@ class C extends CBase { //// [baseTypeWrappingInstantiationChain.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var CBaseBase = (function () { function CBaseBase(x) { } @@ -41,7 +46,7 @@ var CBaseBase = (function () { var CBase = (function (_super) { __extends(CBase, _super); function CBase() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return CBase; }(CBaseBase)); @@ -59,7 +64,7 @@ var Wrapper = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.works = function () { new CBaseBase(this); diff --git a/tests/baselines/reference/bases.js b/tests/baselines/reference/bases.js index 6b73eb9556b..529eacfad04 100644 --- a/tests/baselines/reference/bases.js +++ b/tests/baselines/reference/bases.js @@ -21,11 +21,16 @@ new C().y; //// [bases.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { this.y; @@ -36,7 +41,7 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - var _this; + var _this = this; _this.x; any; return _this; diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js index 6d0f19dd37d..efd55a9ca18 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js @@ -29,11 +29,16 @@ function foo5(t: T, u: U): Object { //// [bestCommonTypeOfConditionalExpressions.js] // conditional expressions return the best common type of the branches plus contextual type (using the first candidate if multiple BCTs exist) // no errors expected here -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a; var b; var Base = (function () { @@ -44,14 +49,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js index 2e2d0bcb1e2..b68b5c3d97c 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js @@ -27,11 +27,16 @@ function foo3(t: T, u: U) { //// [bestCommonTypeOfConditionalExpressions2.js] // conditional expressions return the best common type of the branches plus contextual type (using the first candidate if multiple BCTs exist) // these are 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -40,14 +45,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/bestCommonTypeOfTuple2.js b/tests/baselines/reference/bestCommonTypeOfTuple2.js index 928909f4c38..39712f873bc 100644 --- a/tests/baselines/reference/bestCommonTypeOfTuple2.js +++ b/tests/baselines/reference/bestCommonTypeOfTuple2.js @@ -23,11 +23,16 @@ var e51 = t5[2]; // {} //// [bestCommonTypeOfTuple2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -46,7 +51,7 @@ var E = (function () { var F = (function (_super) { __extends(F, _super); function F() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return F; }(C)); @@ -59,7 +64,7 @@ var C1 = (function () { var D1 = (function (_super) { __extends(D1, _super); function D1() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.i = "bar"; return _this; } diff --git a/tests/baselines/reference/binaryArithmatic1.errors.txt b/tests/baselines/reference/binaryArithmatic1.errors.txt new file mode 100644 index 00000000000..51c0b649890 --- /dev/null +++ b/tests/baselines/reference/binaryArithmatic1.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/binaryArithmatic1.ts(1,13): error TS2531: Object is possibly 'null'. + + +==== tests/cases/compiler/binaryArithmatic1.ts (1 errors) ==== + var v = 4 | null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/binaryArithmatic2.errors.txt b/tests/baselines/reference/binaryArithmatic2.errors.txt new file mode 100644 index 00000000000..28f379c30e2 --- /dev/null +++ b/tests/baselines/reference/binaryArithmatic2.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/binaryArithmatic2.ts(1,13): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/compiler/binaryArithmatic2.ts (1 errors) ==== + var v = 4 | undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/binaryArithmatic3.errors.txt b/tests/baselines/reference/binaryArithmatic3.errors.txt index 6dffe5e150c..1457407a7b8 100644 --- a/tests/baselines/reference/binaryArithmatic3.errors.txt +++ b/tests/baselines/reference/binaryArithmatic3.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/binaryArithmatic3.ts(1,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/compiler/binaryArithmatic3.ts(1,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/compiler/binaryArithmatic3.ts(1,9): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/binaryArithmatic3.ts(1,21): error TS2532: Object is possibly 'undefined'. ==== tests/cases/compiler/binaryArithmatic3.ts (2 errors) ==== var v = undefined | undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/binaryArithmatic4.errors.txt b/tests/baselines/reference/binaryArithmatic4.errors.txt index f72c23073ca..fe7523e0884 100644 --- a/tests/baselines/reference/binaryArithmatic4.errors.txt +++ b/tests/baselines/reference/binaryArithmatic4.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/binaryArithmatic4.ts(1,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/compiler/binaryArithmatic4.ts(1,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/compiler/binaryArithmatic4.ts(1,9): error TS2531: Object is possibly 'null'. +tests/cases/compiler/binaryArithmatic4.ts(1,16): error TS2531: Object is possibly 'null'. ==== tests/cases/compiler/binaryArithmatic4.ts (2 errors) ==== var v = null | null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt index 66d4cbb628e..c3e9f220a3a 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt @@ -1,9 +1,14 @@ -tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(48,26): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(49,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(35,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(36,24): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,26): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,33): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(48,26): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(48,33): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(49,26): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(49,38): error TS2532: Object is possibly 'undefined'. -==== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts (3 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts (8 errors) ==== // ~ operator on any type @@ -39,7 +44,11 @@ tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNot // any type literal var ResultIsNumber6 = ~undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber7 = ~null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. // any type expressions var ResultIsNumber8 = ~ANY2[0] @@ -51,14 +60,20 @@ tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNot var ResultIsNumber14 = ~A.foo(); var ResultIsNumber15 = ~(ANY + ANY1); var ResultIsNumber16 = ~(null + undefined); - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber17 = ~(null + null); - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber18 = ~(undefined + undefined); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // multiple ~ operators var ResultIsNumber19 = ~~ANY; diff --git a/tests/baselines/reference/cacheResolutions.trace.json b/tests/baselines/reference/cacheResolutions.trace.json index 8e7adfb9898..bf3653b489a 100644 --- a/tests/baselines/reference/cacheResolutions.trace.json +++ b/tests/baselines/reference/cacheResolutions.trace.json @@ -13,18 +13,10 @@ "File '/tslib.ts' does not exist.", "File '/tslib.tsx' does not exist.", "File '/tslib.d.ts' does not exist.", - "File '/a/b/c/node_modules/@types/tslib.d.ts' does not exist.", - "File '/a/b/c/node_modules/@types/tslib/package.json' does not exist.", - "File '/a/b/c/node_modules/@types/tslib/index.d.ts' does not exist.", - "File '/a/b/node_modules/@types/tslib.d.ts' does not exist.", - "File '/a/b/node_modules/@types/tslib/package.json' does not exist.", - "File '/a/b/node_modules/@types/tslib/index.d.ts' does not exist.", - "File '/a/node_modules/@types/tslib.d.ts' does not exist.", - "File '/a/node_modules/@types/tslib/package.json' does not exist.", - "File '/a/node_modules/@types/tslib/index.d.ts' does not exist.", - "File '/node_modules/@types/tslib.d.ts' does not exist.", - "File '/node_modules/@types/tslib/package.json' does not exist.", - "File '/node_modules/@types/tslib/index.d.ts' does not exist.", + "Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", "File '/a/b/c/tslib.js' does not exist.", "File '/a/b/c/tslib.jsx' does not exist.", "File '/a/b/tslib.js' does not exist.", @@ -35,9 +27,9 @@ "File '/tslib.jsx' does not exist.", "======== Module name 'tslib' was not resolved. ========", "======== Resolving module 'tslib' from '/a/b/c/lib1.ts'. ========", - "Resolution for module 'tslib' was found in cache", + "Resolution for module 'tslib' was found in cache.", "======== Module name 'tslib' was not resolved. ========", "======== Resolving module 'tslib' from '/a/b/c/lib2.ts'. ========", - "Resolution for module 'tslib' was found in cache", + "Resolution for module 'tslib' was found in cache.", "======== Module name 'tslib' was not resolved. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/cachedModuleResolution1.trace.json b/tests/baselines/reference/cachedModuleResolution1.trace.json index dbb0e6068be..ba59e8df8e8 100644 --- a/tests/baselines/reference/cachedModuleResolution1.trace.json +++ b/tests/baselines/reference/cachedModuleResolution1.trace.json @@ -1,37 +1,10 @@ [ "======== Resolving module 'foo' from '/a/b/c/d/e/app.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module 'foo' from 'node_modules' folder.", - "File '/a/b/c/d/e/node_modules/foo.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/foo.tsx' does not exist.", - "File '/a/b/c/d/e/node_modules/foo.d.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/index.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/index.tsx' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/index.d.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo.tsx' does not exist.", - "File '/a/b/c/d/node_modules/foo.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/d/node_modules/foo/index.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo/index.tsx' does not exist.", - "File '/a/b/c/d/node_modules/foo/index.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/b/c/node_modules/foo.ts' does not exist.", - "File '/a/b/c/node_modules/foo.tsx' does not exist.", - "File '/a/b/c/node_modules/foo.d.ts' does not exist.", - "File '/a/b/c/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/node_modules/foo/index.ts' does not exist.", - "File '/a/b/c/node_modules/foo/index.tsx' does not exist.", - "File '/a/b/c/node_modules/foo/index.d.ts' does not exist.", - "File '/a/b/c/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/node_modules/@types/foo/index.d.ts' does not exist.", + "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it.", "File '/a/b/node_modules/foo.ts' does not exist.", "File '/a/b/node_modules/foo.tsx' does not exist.", "File '/a/b/node_modules/foo.d.ts' exist - use it as a name resolution result.", @@ -39,8 +12,8 @@ "======== Module name 'foo' was successfully resolved to '/a/b/node_modules/foo.d.ts'. ========", "======== Resolving module 'foo' from '/a/b/c/lib.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module 'foo' from 'node_modules' folder.", - "Resolution for module 'foo' was found in cache", + "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "Resolution for module 'foo' was found in cache.", "Resolving real path for '/a/b/node_modules/foo.d.ts', result '/a/b/node_modules/foo.d.ts'", "======== Module name 'foo' was successfully resolved to '/a/b/node_modules/foo.d.ts'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/cachedModuleResolution2.trace.json b/tests/baselines/reference/cachedModuleResolution2.trace.json index 1d4b40bbc08..eb18792122a 100644 --- a/tests/baselines/reference/cachedModuleResolution2.trace.json +++ b/tests/baselines/reference/cachedModuleResolution2.trace.json @@ -1,17 +1,8 @@ [ "======== Resolving module 'foo' from '/a/b/c/lib.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module 'foo' from 'node_modules' folder.", - "File '/a/b/c/node_modules/foo.ts' does not exist.", - "File '/a/b/c/node_modules/foo.tsx' does not exist.", - "File '/a/b/c/node_modules/foo.d.ts' does not exist.", - "File '/a/b/c/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/node_modules/foo/index.ts' does not exist.", - "File '/a/b/c/node_modules/foo/index.tsx' does not exist.", - "File '/a/b/c/node_modules/foo/index.d.ts' does not exist.", - "File '/a/b/c/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/node_modules/@types/foo/index.d.ts' does not exist.", + "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it.", "File '/a/b/node_modules/foo.ts' does not exist.", "File '/a/b/node_modules/foo.tsx' does not exist.", "File '/a/b/node_modules/foo.d.ts' exist - use it as a name resolution result.", @@ -19,28 +10,10 @@ "======== Module name 'foo' was successfully resolved to '/a/b/node_modules/foo.d.ts'. ========", "======== Resolving module 'foo' from '/a/b/c/d/e/app.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module 'foo' from 'node_modules' folder.", - "File '/a/b/c/d/e/node_modules/foo.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/foo.tsx' does not exist.", - "File '/a/b/c/d/e/node_modules/foo.d.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/index.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/index.tsx' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/index.d.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo.tsx' does not exist.", - "File '/a/b/c/d/node_modules/foo.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/d/node_modules/foo/index.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo/index.tsx' does not exist.", - "File '/a/b/c/d/node_modules/foo/index.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo/index.d.ts' does not exist.", - "Resolution for module 'foo' was found in cache", + "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it.", + "Resolution for module 'foo' was found in cache.", "Resolving real path for '/a/b/node_modules/foo.d.ts', result '/a/b/node_modules/foo.d.ts'", "======== Module name 'foo' was successfully resolved to '/a/b/node_modules/foo.d.ts'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/cachedModuleResolution3.trace.json b/tests/baselines/reference/cachedModuleResolution3.trace.json index 2dbaea53f47..6cbab2e0796 100644 --- a/tests/baselines/reference/cachedModuleResolution3.trace.json +++ b/tests/baselines/reference/cachedModuleResolution3.trace.json @@ -16,6 +16,6 @@ "======== Module name 'foo' was successfully resolved to '/a/b/foo.d.ts'. ========", "======== Resolving module 'foo' from '/a/b/c/lib.ts'. ========", "Explicitly specified module resolution kind: 'Classic'.", - "Resolution for module 'foo' was found in cache", + "Resolution for module 'foo' was found in cache.", "======== Module name 'foo' was successfully resolved to '/a/b/foo.d.ts'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/cachedModuleResolution4.trace.json b/tests/baselines/reference/cachedModuleResolution4.trace.json index 7249d948e1c..c100c0c3814 100644 --- a/tests/baselines/reference/cachedModuleResolution4.trace.json +++ b/tests/baselines/reference/cachedModuleResolution4.trace.json @@ -16,6 +16,6 @@ "File '/a/b/c/d/foo.ts' does not exist.", "File '/a/b/c/d/foo.tsx' does not exist.", "File '/a/b/c/d/foo.d.ts' does not exist.", - "Resolution for module 'foo' was found in cache", + "Resolution for module 'foo' was found in cache.", "======== Module name 'foo' was successfully resolved to '/a/b/foo.d.ts'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/cachedModuleResolution5.trace.json b/tests/baselines/reference/cachedModuleResolution5.trace.json index d263465ff12..f489afffbe9 100644 --- a/tests/baselines/reference/cachedModuleResolution5.trace.json +++ b/tests/baselines/reference/cachedModuleResolution5.trace.json @@ -1,37 +1,10 @@ [ "======== Resolving module 'foo' from '/a/b/c/d/e/app.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module 'foo' from 'node_modules' folder.", - "File '/a/b/c/d/e/node_modules/foo.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/foo.tsx' does not exist.", - "File '/a/b/c/d/e/node_modules/foo.d.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/index.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/index.tsx' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/index.d.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo.tsx' does not exist.", - "File '/a/b/c/d/node_modules/foo.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/d/node_modules/foo/index.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo/index.tsx' does not exist.", - "File '/a/b/c/d/node_modules/foo/index.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/b/c/node_modules/foo.ts' does not exist.", - "File '/a/b/c/node_modules/foo.tsx' does not exist.", - "File '/a/b/c/node_modules/foo.d.ts' does not exist.", - "File '/a/b/c/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/node_modules/foo/index.ts' does not exist.", - "File '/a/b/c/node_modules/foo/index.tsx' does not exist.", - "File '/a/b/c/node_modules/foo/index.d.ts' does not exist.", - "File '/a/b/c/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/node_modules/@types/foo/index.d.ts' does not exist.", + "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it.", "File '/a/b/node_modules/foo.ts' does not exist.", "File '/a/b/node_modules/foo.tsx' does not exist.", "File '/a/b/node_modules/foo.d.ts' exist - use it as a name resolution result.", @@ -39,8 +12,8 @@ "======== Module name 'foo' was successfully resolved to '/a/b/node_modules/foo.d.ts'. ========", "======== Resolving module 'foo' from '/a/b/lib.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module 'foo' from 'node_modules' folder.", - "Resolution for module 'foo' was found in cache", + "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "Resolution for module 'foo' was found in cache.", "Resolving real path for '/a/b/node_modules/foo.d.ts', result '/a/b/node_modules/foo.d.ts'", "======== Module name 'foo' was successfully resolved to '/a/b/node_modules/foo.d.ts'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/cachedModuleResolution6.trace.json b/tests/baselines/reference/cachedModuleResolution6.trace.json index 02d52befc94..50c1c15b3e1 100644 --- a/tests/baselines/reference/cachedModuleResolution6.trace.json +++ b/tests/baselines/reference/cachedModuleResolution6.trace.json @@ -1,102 +1,24 @@ [ "======== Resolving module 'foo' from '/a/b/c/d/e/app.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module 'foo' from 'node_modules' folder.", - "File '/a/b/c/d/e/node_modules/foo.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/foo.tsx' does not exist.", - "File '/a/b/c/d/e/node_modules/foo.d.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/index.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/index.tsx' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/index.d.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo.tsx' does not exist.", - "File '/a/b/c/d/node_modules/foo.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/d/node_modules/foo/index.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo/index.tsx' does not exist.", - "File '/a/b/c/d/node_modules/foo/index.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/b/c/node_modules/foo.ts' does not exist.", - "File '/a/b/c/node_modules/foo.tsx' does not exist.", - "File '/a/b/c/node_modules/foo.d.ts' does not exist.", - "File '/a/b/c/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/node_modules/foo/index.ts' does not exist.", - "File '/a/b/c/node_modules/foo/index.tsx' does not exist.", - "File '/a/b/c/node_modules/foo/index.d.ts' does not exist.", - "File '/a/b/c/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/b/node_modules/foo.ts' does not exist.", - "File '/a/b/node_modules/foo.tsx' does not exist.", - "File '/a/b/node_modules/foo.d.ts' does not exist.", - "File '/a/b/node_modules/foo/package.json' does not exist.", - "File '/a/b/node_modules/foo/index.ts' does not exist.", - "File '/a/b/node_modules/foo/index.tsx' does not exist.", - "File '/a/b/node_modules/foo/index.d.ts' does not exist.", - "File '/a/b/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/node_modules/foo.ts' does not exist.", - "File '/a/node_modules/foo.tsx' does not exist.", - "File '/a/node_modules/foo.d.ts' does not exist.", - "File '/a/node_modules/foo/package.json' does not exist.", - "File '/a/node_modules/foo/index.ts' does not exist.", - "File '/a/node_modules/foo/index.tsx' does not exist.", - "File '/a/node_modules/foo/index.d.ts' does not exist.", - "File '/a/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/node_modules/@types/foo/package.json' does not exist.", - "File '/a/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/node_modules/foo.ts' does not exist.", - "File '/node_modules/foo.tsx' does not exist.", - "File '/node_modules/foo.d.ts' does not exist.", - "File '/node_modules/foo/package.json' does not exist.", - "File '/node_modules/foo/index.ts' does not exist.", - "File '/node_modules/foo/index.tsx' does not exist.", - "File '/node_modules/foo/index.d.ts' does not exist.", - "File '/node_modules/@types/foo.d.ts' does not exist.", - "File '/node_modules/@types/foo/package.json' does not exist.", - "File '/node_modules/@types/foo/index.d.ts' does not exist.", - "Loading module 'foo' from 'node_modules' folder.", - "File '/a/b/c/d/e/node_modules/foo.js' does not exist.", - "File '/a/b/c/d/e/node_modules/foo.jsx' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/index.js' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/index.jsx' does not exist.", - "File '/a/b/c/d/node_modules/foo.js' does not exist.", - "File '/a/b/c/d/node_modules/foo.jsx' does not exist.", - "File '/a/b/c/d/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/d/node_modules/foo/index.js' does not exist.", - "File '/a/b/c/d/node_modules/foo/index.jsx' does not exist.", - "File '/a/b/c/node_modules/foo.js' does not exist.", - "File '/a/b/c/node_modules/foo.jsx' does not exist.", - "File '/a/b/c/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/node_modules/foo/index.js' does not exist.", - "File '/a/b/c/node_modules/foo/index.jsx' does not exist.", - "File '/a/b/node_modules/foo.js' does not exist.", - "File '/a/b/node_modules/foo.jsx' does not exist.", - "File '/a/b/node_modules/foo/package.json' does not exist.", - "File '/a/b/node_modules/foo/index.js' does not exist.", - "File '/a/b/node_modules/foo/index.jsx' does not exist.", - "File '/a/node_modules/foo.js' does not exist.", - "File '/a/node_modules/foo.jsx' does not exist.", - "File '/a/node_modules/foo/package.json' does not exist.", - "File '/a/node_modules/foo/index.js' does not exist.", - "File '/a/node_modules/foo/index.jsx' does not exist.", - "File '/node_modules/foo.js' does not exist.", - "File '/node_modules/foo.jsx' does not exist.", - "File '/node_modules/foo/package.json' does not exist.", - "File '/node_modules/foo/index.js' does not exist.", - "File '/node_modules/foo/index.jsx' does not exist.", + "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", + "Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name 'foo' was not resolved. ========", "======== Resolving module 'foo' from '/a/b/c/lib.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module 'foo' from 'node_modules' folder.", - "Resolution for module 'foo' was found in cache", + "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "Resolution for module 'foo' was found in cache.", "======== Module name 'foo' was not resolved. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/cachedModuleResolution7.trace.json b/tests/baselines/reference/cachedModuleResolution7.trace.json index ce5bf08861d..fa1db9d115e 100644 --- a/tests/baselines/reference/cachedModuleResolution7.trace.json +++ b/tests/baselines/reference/cachedModuleResolution7.trace.json @@ -1,92 +1,22 @@ [ "======== Resolving module 'foo' from '/a/b/c/lib.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module 'foo' from 'node_modules' folder.", - "File '/a/b/c/node_modules/foo.ts' does not exist.", - "File '/a/b/c/node_modules/foo.tsx' does not exist.", - "File '/a/b/c/node_modules/foo.d.ts' does not exist.", - "File '/a/b/c/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/node_modules/foo/index.ts' does not exist.", - "File '/a/b/c/node_modules/foo/index.tsx' does not exist.", - "File '/a/b/c/node_modules/foo/index.d.ts' does not exist.", - "File '/a/b/c/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/b/node_modules/foo.ts' does not exist.", - "File '/a/b/node_modules/foo.tsx' does not exist.", - "File '/a/b/node_modules/foo.d.ts' does not exist.", - "File '/a/b/node_modules/foo/package.json' does not exist.", - "File '/a/b/node_modules/foo/index.ts' does not exist.", - "File '/a/b/node_modules/foo/index.tsx' does not exist.", - "File '/a/b/node_modules/foo/index.d.ts' does not exist.", - "File '/a/b/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/node_modules/foo.ts' does not exist.", - "File '/a/node_modules/foo.tsx' does not exist.", - "File '/a/node_modules/foo.d.ts' does not exist.", - "File '/a/node_modules/foo/package.json' does not exist.", - "File '/a/node_modules/foo/index.ts' does not exist.", - "File '/a/node_modules/foo/index.tsx' does not exist.", - "File '/a/node_modules/foo/index.d.ts' does not exist.", - "File '/a/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/node_modules/@types/foo/package.json' does not exist.", - "File '/a/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/node_modules/foo.ts' does not exist.", - "File '/node_modules/foo.tsx' does not exist.", - "File '/node_modules/foo.d.ts' does not exist.", - "File '/node_modules/foo/package.json' does not exist.", - "File '/node_modules/foo/index.ts' does not exist.", - "File '/node_modules/foo/index.tsx' does not exist.", - "File '/node_modules/foo/index.d.ts' does not exist.", - "File '/node_modules/@types/foo.d.ts' does not exist.", - "File '/node_modules/@types/foo/package.json' does not exist.", - "File '/node_modules/@types/foo/index.d.ts' does not exist.", - "Loading module 'foo' from 'node_modules' folder.", - "File '/a/b/c/node_modules/foo.js' does not exist.", - "File '/a/b/c/node_modules/foo.jsx' does not exist.", - "File '/a/b/c/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/node_modules/foo/index.js' does not exist.", - "File '/a/b/c/node_modules/foo/index.jsx' does not exist.", - "File '/a/b/node_modules/foo.js' does not exist.", - "File '/a/b/node_modules/foo.jsx' does not exist.", - "File '/a/b/node_modules/foo/package.json' does not exist.", - "File '/a/b/node_modules/foo/index.js' does not exist.", - "File '/a/b/node_modules/foo/index.jsx' does not exist.", - "File '/a/node_modules/foo.js' does not exist.", - "File '/a/node_modules/foo.jsx' does not exist.", - "File '/a/node_modules/foo/package.json' does not exist.", - "File '/a/node_modules/foo/index.js' does not exist.", - "File '/a/node_modules/foo/index.jsx' does not exist.", - "File '/node_modules/foo.js' does not exist.", - "File '/node_modules/foo.jsx' does not exist.", - "File '/node_modules/foo/package.json' does not exist.", - "File '/node_modules/foo/index.js' does not exist.", - "File '/node_modules/foo/index.jsx' does not exist.", + "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", + "Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name 'foo' was not resolved. ========", "======== Resolving module 'foo' from '/a/b/c/d/e/app.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module 'foo' from 'node_modules' folder.", - "File '/a/b/c/d/e/node_modules/foo.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/foo.tsx' does not exist.", - "File '/a/b/c/d/e/node_modules/foo.d.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/index.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/index.tsx' does not exist.", - "File '/a/b/c/d/e/node_modules/foo/index.d.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo.tsx' does not exist.", - "File '/a/b/c/d/node_modules/foo.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo/package.json' does not exist.", - "File '/a/b/c/d/node_modules/foo/index.ts' does not exist.", - "File '/a/b/c/d/node_modules/foo/index.tsx' does not exist.", - "File '/a/b/c/d/node_modules/foo/index.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo/index.d.ts' does not exist.", - "Resolution for module 'foo' was found in cache", + "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it.", + "Resolution for module 'foo' was found in cache.", "======== Module name 'foo' was not resolved. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/cachedModuleResolution8.trace.json b/tests/baselines/reference/cachedModuleResolution8.trace.json index f833f56d819..e5241278349 100644 --- a/tests/baselines/reference/cachedModuleResolution8.trace.json +++ b/tests/baselines/reference/cachedModuleResolution8.trace.json @@ -19,24 +19,12 @@ "File '/foo.ts' does not exist.", "File '/foo.tsx' does not exist.", "File '/foo.d.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/d/e/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/d/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/b/c/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/b/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/node_modules/@types/foo/package.json' does not exist.", - "File '/a/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/node_modules/@types/foo.d.ts' does not exist.", - "File '/node_modules/@types/foo/package.json' does not exist.", - "File '/node_modules/@types/foo/index.d.ts' does not exist.", + "Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", "File '/a/b/c/d/e/foo.js' does not exist.", "File '/a/b/c/d/e/foo.jsx' does not exist.", "File '/a/b/c/d/foo.js' does not exist.", @@ -52,6 +40,6 @@ "======== Module name 'foo' was not resolved. ========", "======== Resolving module 'foo' from '/a/b/c/lib.ts'. ========", "Explicitly specified module resolution kind: 'Classic'.", - "Resolution for module 'foo' was found in cache", + "Resolution for module 'foo' was found in cache.", "======== Module name 'foo' was not resolved. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/cachedModuleResolution9.trace.json b/tests/baselines/reference/cachedModuleResolution9.trace.json index 10a79576bfc..bd148cc7ee2 100644 --- a/tests/baselines/reference/cachedModuleResolution9.trace.json +++ b/tests/baselines/reference/cachedModuleResolution9.trace.json @@ -13,18 +13,10 @@ "File '/foo.ts' does not exist.", "File '/foo.tsx' does not exist.", "File '/foo.d.ts' does not exist.", - "File '/a/b/c/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/c/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/c/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/b/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/b/node_modules/@types/foo/package.json' does not exist.", - "File '/a/b/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/a/node_modules/@types/foo.d.ts' does not exist.", - "File '/a/node_modules/@types/foo/package.json' does not exist.", - "File '/a/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/node_modules/@types/foo.d.ts' does not exist.", - "File '/node_modules/@types/foo/package.json' does not exist.", - "File '/node_modules/@types/foo/index.d.ts' does not exist.", + "Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", "File '/a/b/c/foo.js' does not exist.", "File '/a/b/c/foo.jsx' does not exist.", "File '/a/b/foo.js' does not exist.", @@ -42,6 +34,6 @@ "File '/a/b/c/d/foo.ts' does not exist.", "File '/a/b/c/d/foo.tsx' does not exist.", "File '/a/b/c/d/foo.d.ts' does not exist.", - "Resolution for module 'foo' was found in cache", + "Resolution for module 'foo' was found in cache.", "======== Module name 'foo' was not resolved. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js index 0ae7648c7f9..a71613bc545 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js @@ -71,11 +71,16 @@ interface I extends A { //// [callSignatureAssignabilityInInheritance2.js] // checking subtype relations for function types as it relates to contextual signature instantiation -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -84,21 +89,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js index 7a7791280ad..7f9d616281b 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js @@ -116,11 +116,16 @@ module Errors { //// [callSignatureAssignabilityInInheritance3.js] // checking subtype relations for function types as it relates to contextual signature instantiation // error cases -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Errors; (function (Errors) { var Base = (function () { @@ -131,21 +136,21 @@ var Errors; var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js index 19d66ce8d46..6c5d7508fc9 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js @@ -51,11 +51,16 @@ interface I extends A { //// [callSignatureAssignabilityInInheritance4.js] // checking subtype relations for function types as it relates to contextual signature instantiation -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -64,21 +69,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js index 1c53de5d26e..fe260d62119 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js @@ -51,11 +51,16 @@ interface I extends B { //// [callSignatureAssignabilityInInheritance5.js] // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithCallSignatures2 just with an extra level of indirection in the inheritance chain -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -64,21 +69,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js index c42e36389ca..c6054d2411d 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js @@ -54,11 +54,16 @@ interface I9 extends A { // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithCallSignatures4 but using class type parameters instead of generic signatures // all are 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -67,21 +72,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/callWithSpread.js b/tests/baselines/reference/callWithSpread.js index 69f7e4e30b0..23c1fff2d09 100644 --- a/tests/baselines/reference/callWithSpread.js +++ b/tests/baselines/reference/callWithSpread.js @@ -59,11 +59,16 @@ class D extends C { //// [callWithSpread.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function foo(x, y) { var z = []; for (var _i = 2; _i < arguments.length; _i++) { diff --git a/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.js b/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.js index 7fde44106c6..98ca7cb47d7 100644 --- a/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.js +++ b/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.js @@ -12,11 +12,16 @@ class B extends A { } //// [captureSuperPropertyAccessInSuperCall01.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(f) { } @@ -26,7 +31,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - var _this = _super.call(this, function () { return _super.blah.call(_this); }) || this; + var _this = _super.call(this, function () { return _super.prototype.blah.call(_this); }) || this; return _this; } return B; diff --git a/tests/baselines/reference/captureThisInSuperCall.js b/tests/baselines/reference/captureThisInSuperCall.js index 069871f598e..ccca2e6562f 100644 --- a/tests/baselines/reference/captureThisInSuperCall.js +++ b/tests/baselines/reference/captureThisInSuperCall.js @@ -9,11 +9,16 @@ class B extends A { } //// [captureThisInSuperCall.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 f0178dcbbf0..fea3bd9a238 100644 --- a/tests/baselines/reference/castingTuple.js +++ b/tests/baselines/reference/castingTuple.js @@ -33,11 +33,16 @@ t4[2] = 10; //// [castingTuple.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { this.a = 10; @@ -59,7 +64,7 @@ var D = (function () { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(A)); @@ -67,7 +72,7 @@ var E = (function (_super) { var F = (function (_super) { __extends(F, _super); function F() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return F; }(A)); diff --git a/tests/baselines/reference/chainedAssignment3.js b/tests/baselines/reference/chainedAssignment3.js index 3857867043c..c85845f6d35 100644 --- a/tests/baselines/reference/chainedAssignment3.js +++ b/tests/baselines/reference/chainedAssignment3.js @@ -23,11 +23,16 @@ a = b = new A(); //// [chainedAssignment3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -36,7 +41,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js index 26d341e1f6a..99bd90139ae 100644 --- a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js +++ b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js @@ -20,11 +20,16 @@ class C extends B { (new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A); //// [chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Chain = (function () { function Chain(value) { this.value = value; @@ -42,14 +47,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); diff --git a/tests/baselines/reference/checkForObjectTooStrict.js b/tests/baselines/reference/checkForObjectTooStrict.js index ade99e9319b..6d330285f6e 100644 --- a/tests/baselines/reference/checkForObjectTooStrict.js +++ b/tests/baselines/reference/checkForObjectTooStrict.js @@ -32,11 +32,16 @@ class Baz extends Object { //// [checkForObjectTooStrict.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo; (function (Foo) { var Object = (function () { diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing1.js b/tests/baselines/reference/checkSuperCallBeforeThisAccessing1.js index 8ced6fce500..40717cb4759 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing1.js +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing1.js @@ -11,11 +11,16 @@ class Derived extends Based { } //// [checkSuperCallBeforeThisAccessing1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Based = (function () { function Based() { } diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing2.js b/tests/baselines/reference/checkSuperCallBeforeThisAccessing2.js index 95b34f27b68..bbe56823ee5 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing2.js +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing2.js @@ -11,11 +11,16 @@ class Derived extends Based { } //// [checkSuperCallBeforeThisAccessing2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Based = (function () { function Based() { } @@ -24,7 +29,7 @@ var Based = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this; + var _this = this; _this.x = 100; _this = _super.call(this) || this; _this.x = 10; diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.js b/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.js index 0e882f71fdb..dc7e0309ab6 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.js +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.js @@ -16,11 +16,16 @@ class Derived extends Based { } //// [checkSuperCallBeforeThisAccessing3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Based = (function () { function Based() { } @@ -29,7 +34,7 @@ var Based = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this; + var _this = this; var innver = (function () { function innver() { this.y = true; diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing4.js b/tests/baselines/reference/checkSuperCallBeforeThisAccessing4.js index 00f2ed22fbf..b8240b27aea 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing4.js +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing4.js @@ -20,11 +20,16 @@ class Derived extends Based { } //// [checkSuperCallBeforeThisAccessing4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Based = (function () { function Based() { } @@ -33,7 +38,7 @@ var Based = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this; + var _this = this; (function () { _this; // No error }); diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing5.js b/tests/baselines/reference/checkSuperCallBeforeThisAccessing5.js index ded73f57baf..9936c7d97dc 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing5.js +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing5.js @@ -8,11 +8,16 @@ class Derived extends Based { } //// [checkSuperCallBeforeThisAccessing5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Based = (function () { function Based() { var arg = []; diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing6.js b/tests/baselines/reference/checkSuperCallBeforeThisAccessing6.js index 782e3236271..a40791a4eba 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing6.js +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing6.js @@ -11,11 +11,16 @@ class Super extends Base { } //// [checkSuperCallBeforeThisAccessing6.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { var arg = []; @@ -28,7 +33,7 @@ var Base = (function () { var Super = (function (_super) { __extends(Super, _super); function Super() { - var _this; + var _this = this; (function () { return _this; }); // No Error _this = _super.call(this) || this; return _this; diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing7.js b/tests/baselines/reference/checkSuperCallBeforeThisAccessing7.js index 364aed4d4b0..4cb05a35aa0 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing7.js +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing7.js @@ -10,11 +10,16 @@ class Super extends Base { } //// [checkSuperCallBeforeThisAccessing7.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(func) { } diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing8.js b/tests/baselines/reference/checkSuperCallBeforeThisAccessing8.js index 5dd3708a3bb..92f13921d2a 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing8.js +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing8.js @@ -11,11 +11,16 @@ class Super extends Base { } //// [checkSuperCallBeforeThisAccessing8.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { var arg = []; @@ -28,7 +33,7 @@ var Base = (function () { var Super = (function (_super) { __extends(Super, _super); function Super() { - var _this; + var _this = this; var that = _this; _this = _super.call(this) || this; return _this; diff --git a/tests/baselines/reference/circularImportAlias.js b/tests/baselines/reference/circularImportAlias.js index 6fe5e604e57..7c05d6dc3d3 100644 --- a/tests/baselines/reference/circularImportAlias.js +++ b/tests/baselines/reference/circularImportAlias.js @@ -21,18 +21,23 @@ var c = new B.a.C(); //// [circularImportAlias.js] // expected no 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B; (function (B) { B.a = A; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(B.a.C)); diff --git a/tests/baselines/reference/circularIndexedAccessErrors.errors.txt b/tests/baselines/reference/circularIndexedAccessErrors.errors.txt index e3076e08b7e..f76cfca073e 100644 --- a/tests/baselines/reference/circularIndexedAccessErrors.errors.txt +++ b/tests/baselines/reference/circularIndexedAccessErrors.errors.txt @@ -1,14 +1,12 @@ tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(3,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(7,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. -tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(15,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(19,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(23,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. -tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(27,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. -tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(28,5): error TS2502: 'y' is referenced directly or indirectly in its own type annotation. -tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(29,5): error TS2502: 'z' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(38,24): error TS2313: Type parameter 'T' has a circular constraint. +tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(38,30): error TS2536: Type '"hello"' cannot be used to index type 'T'. -==== tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts (8 errors) ==== +==== tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts (6 errors) ==== type T1 = { x: T1["x"]; // Error @@ -27,9 +25,7 @@ tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(29,5): error let x2x = x2.x; interface T3> { - x: T["x"]; // Error - ~~~~~~~~~~ -!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation. + x: T["x"]; } interface T4> { @@ -45,13 +41,21 @@ tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(29,5): error } class C2 { - x: this["y"]; // Error - ~~~~~~~~~~~~~ -!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation. - y: this["z"]; // Error - ~~~~~~~~~~~~~ -!!! error TS2502: 'y' is referenced directly or indirectly in its own type annotation. - z: this["x"]; // Error - ~~~~~~~~~~~~~ -!!! error TS2502: 'z' is referenced directly or indirectly in its own type annotation. - } \ No newline at end of file + x: this["y"]; + y: this["z"]; + z: this["x"]; + } + + // Repro from #12627 + + interface Foo { + hello: boolean; + } + + function foo() { + ~~~~~~~~~~~~~~~~ +!!! error TS2313: Type parameter 'T' has a circular constraint. + ~~~~~~~~~~ +!!! error TS2536: Type '"hello"' cannot be used to index type 'T'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/circularIndexedAccessErrors.js b/tests/baselines/reference/circularIndexedAccessErrors.js index 46784ae8d18..97d059bce19 100644 --- a/tests/baselines/reference/circularIndexedAccessErrors.js +++ b/tests/baselines/reference/circularIndexedAccessErrors.js @@ -13,7 +13,7 @@ declare let x2: T2<"x">; let x2x = x2.x; interface T3> { - x: T["x"]; // Error + x: T["x"]; } interface T4> { @@ -25,10 +25,20 @@ class C1 { } class C2 { - x: this["y"]; // Error - y: this["z"]; // Error - z: this["x"]; // Error -} + x: this["y"]; + y: this["z"]; + z: this["x"]; +} + +// Repro from #12627 + +interface Foo { + hello: boolean; +} + +function foo() { +} + //// [circularIndexedAccessErrors.js] var x2x = x2.x; @@ -42,6 +52,8 @@ var C2 = (function () { } return C2; }()); +function foo() { +} //// [circularIndexedAccessErrors.d.ts] @@ -68,3 +80,7 @@ declare class C2 { y: this["z"]; z: this["x"]; } +interface Foo { + hello: boolean; +} +declare function foo(): void; diff --git a/tests/baselines/reference/circularTypeofWithFunctionModule.js b/tests/baselines/reference/circularTypeofWithFunctionModule.js index 1c38b9625e3..a94de5d55e2 100644 --- a/tests/baselines/reference/circularTypeofWithFunctionModule.js +++ b/tests/baselines/reference/circularTypeofWithFunctionModule.js @@ -14,11 +14,16 @@ namespace maker { //// [circularTypeofWithFunctionModule.js] // Repro from #6072 -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -31,7 +36,7 @@ function maker(value) { var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar; }(Foo)); diff --git a/tests/baselines/reference/classAbstractConstructorAssignability.js b/tests/baselines/reference/classAbstractConstructorAssignability.js index 35d9e75884f..5df6d169e04 100644 --- a/tests/baselines/reference/classAbstractConstructorAssignability.js +++ b/tests/baselines/reference/classAbstractConstructorAssignability.js @@ -15,11 +15,16 @@ new BB; new CC; //// [classAbstractConstructorAssignability.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -28,14 +33,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); diff --git a/tests/baselines/reference/classAbstractCrashedOnce.js b/tests/baselines/reference/classAbstractCrashedOnce.js index fe23e60c94f..7801b61cdd9 100644 --- a/tests/baselines/reference/classAbstractCrashedOnce.js +++ b/tests/baselines/reference/classAbstractCrashedOnce.js @@ -11,11 +11,16 @@ class bar extends foo { var x = new bar(); //// [classAbstractCrashedOnce.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var foo = (function () { function foo() { } @@ -24,7 +29,7 @@ var foo = (function () { var bar = (function (_super) { __extends(bar, _super); function bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } bar.prototype.test = function () { this. diff --git a/tests/baselines/reference/classAbstractExtends.js b/tests/baselines/reference/classAbstractExtends.js index e899cb82d6d..69c962509db 100644 --- a/tests/baselines/reference/classAbstractExtends.js +++ b/tests/baselines/reference/classAbstractExtends.js @@ -17,11 +17,16 @@ class E extends B { } //// [classAbstractExtends.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -31,28 +36,28 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(B)); var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.bar = function () { }; return E; diff --git a/tests/baselines/reference/classAbstractFactoryFunction.js b/tests/baselines/reference/classAbstractFactoryFunction.js index 50e232a9fca..abc3235a3d3 100644 --- a/tests/baselines/reference/classAbstractFactoryFunction.js +++ b/tests/baselines/reference/classAbstractFactoryFunction.js @@ -18,11 +18,16 @@ NewB(A); NewB(B); //// [classAbstractFactoryFunction.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -31,7 +36,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/classAbstractGeneric.js b/tests/baselines/reference/classAbstractGeneric.js index 96df8f5f19e..6d20869ba73 100644 --- a/tests/baselines/reference/classAbstractGeneric.js +++ b/tests/baselines/reference/classAbstractGeneric.js @@ -26,11 +26,16 @@ class G extends A { } //// [classAbstractGeneric.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -39,28 +44,28 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); // error -- inherits abstract methods var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(A)); // error -- inherits abstract methods var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.foo = function () { return this.t; }; return E; @@ -68,7 +73,7 @@ var E = (function (_super) { var F = (function (_super) { __extends(F, _super); function F() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } F.prototype.bar = function (t) { }; return F; @@ -76,7 +81,7 @@ var F = (function (_super) { var G = (function (_super) { __extends(G, _super); function G() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } G.prototype.foo = function () { return this.t; }; G.prototype.bar = function (t) { }; diff --git a/tests/baselines/reference/classAbstractInAModule.js b/tests/baselines/reference/classAbstractInAModule.js index c6a9e206bcc..4bbe7a40dc5 100644 --- a/tests/baselines/reference/classAbstractInAModule.js +++ b/tests/baselines/reference/classAbstractInAModule.js @@ -8,11 +8,16 @@ new M.A; new M.B; //// [classAbstractInAModule.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { var A = (function () { @@ -24,7 +29,7 @@ var M; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/classAbstractInheritance.js b/tests/baselines/reference/classAbstractInheritance.js index 297a80dd99c..a39ef662d76 100644 --- a/tests/baselines/reference/classAbstractInheritance.js +++ b/tests/baselines/reference/classAbstractInheritance.js @@ -22,11 +22,16 @@ class FF extends CC {} abstract class GG extends CC {} //// [classAbstractInheritance.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -35,14 +40,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); @@ -54,42 +59,42 @@ var AA = (function () { var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return BB; }(AA)); var CC = (function (_super) { __extends(CC, _super); function CC() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return CC; }(AA)); var DD = (function (_super) { __extends(DD, _super); function DD() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return DD; }(BB)); var EE = (function (_super) { __extends(EE, _super); function EE() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return EE; }(BB)); var FF = (function (_super) { __extends(FF, _super); function FF() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return FF; }(CC)); var GG = (function (_super) { __extends(GG, _super); function GG() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return GG; }(CC)); diff --git a/tests/baselines/reference/classAbstractInstantiations1.js b/tests/baselines/reference/classAbstractInstantiations1.js index 5abbb9c1baa..6722665b62d 100644 --- a/tests/baselines/reference/classAbstractInstantiations1.js +++ b/tests/baselines/reference/classAbstractInstantiations1.js @@ -28,11 +28,16 @@ c = new B; // // Calling new with (non)abstract classes. // -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -41,14 +46,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); diff --git a/tests/baselines/reference/classAbstractInstantiations2.js b/tests/baselines/reference/classAbstractInstantiations2.js index dea4c744ae0..7d400c9fb05 100644 --- a/tests/baselines/reference/classAbstractInstantiations2.js +++ b/tests/baselines/reference/classAbstractInstantiations2.js @@ -52,11 +52,16 @@ class H { // error -- not declared abstract } //// [classAbstractInstantiations2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -82,21 +87,21 @@ new x; // okay -- undefined behavior at runtime var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); // error -- not declared abstract var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(B)); // okay var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.bar = function () { return 1; }; return E; @@ -104,7 +109,7 @@ var E = (function (_super) { var F = (function (_super) { __extends(F, _super); function F() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } F.prototype.bar = function () { return 2; }; return F; diff --git a/tests/baselines/reference/classAbstractOverrideWithAbstract.js b/tests/baselines/reference/classAbstractOverrideWithAbstract.js index 4ecebdf7b32..496dc7f241a 100644 --- a/tests/baselines/reference/classAbstractOverrideWithAbstract.js +++ b/tests/baselines/reference/classAbstractOverrideWithAbstract.js @@ -24,11 +24,16 @@ class DD extends BB { } //// [classAbstractOverrideWithAbstract.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -38,7 +43,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -51,7 +56,7 @@ var AA = (function () { var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } BB.prototype.bar = function () { }; return BB; @@ -59,14 +64,14 @@ var BB = (function (_super) { var CC = (function (_super) { __extends(CC, _super); function CC() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return CC; }(BB)); // error var DD = (function (_super) { __extends(DD, _super); function DD() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } DD.prototype.foo = function () { }; return DD; diff --git a/tests/baselines/reference/classAbstractSuperCalls.js b/tests/baselines/reference/classAbstractSuperCalls.js index 0197f48a429..125f5b3883f 100644 --- a/tests/baselines/reference/classAbstractSuperCalls.js +++ b/tests/baselines/reference/classAbstractSuperCalls.js @@ -28,11 +28,16 @@ abstract class BB extends AA { //// [classAbstractSuperCalls.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -42,7 +47,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { _super.prototype.foo.call(this); }; B.prototype.baz = function () { return this.foo; }; @@ -51,7 +56,7 @@ var B = (function (_super) { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.foo = function () { return 2; }; C.prototype.qux = function () { return _super.prototype.foo.call(this) || _super.prototype.foo; }; // 2 errors, foo is abstract @@ -68,7 +73,7 @@ var AA = (function () { var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return BB; }(AA)); diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethod1.js b/tests/baselines/reference/classAbstractUsingAbstractMethod1.js index 74b5d62aaf5..8781fc6c05f 100644 --- a/tests/baselines/reference/classAbstractUsingAbstractMethod1.js +++ b/tests/baselines/reference/classAbstractUsingAbstractMethod1.js @@ -18,11 +18,16 @@ a = new C; // error, cannot instantiate abstract class. a.foo(); //// [classAbstractUsingAbstractMethod1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -31,7 +36,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.foo = function () { return 1; }; return B; @@ -39,7 +44,7 @@ var B = (function (_super) { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethods2.js b/tests/baselines/reference/classAbstractUsingAbstractMethods2.js index 25cf1a307c7..6016ab249f1 100644 --- a/tests/baselines/reference/classAbstractUsingAbstractMethods2.js +++ b/tests/baselines/reference/classAbstractUsingAbstractMethods2.js @@ -28,11 +28,16 @@ class DD extends AA { } //// [classAbstractUsingAbstractMethods2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -41,21 +46,21 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.foo = function () { }; return D; @@ -63,7 +68,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.foo = function () { }; return E; @@ -76,21 +81,21 @@ var AA = (function () { var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return BB; }(AA)); var CC = (function (_super) { __extends(CC, _super); function CC() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return CC; }(AA)); var DD = (function (_super) { __extends(DD, _super); function DD() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } DD.prototype.foo = function () { }; return DD; diff --git a/tests/baselines/reference/classConstructorAccessibility2.js b/tests/baselines/reference/classConstructorAccessibility2.js index ef637611e8d..7c77d13dffb 100644 --- a/tests/baselines/reference/classConstructorAccessibility2.js +++ b/tests/baselines/reference/classConstructorAccessibility2.js @@ -47,11 +47,16 @@ var dc = new DerivedC(1); //// [classConstructorAccessibility2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var BaseA = (function () { function BaseA(x) { this.x = x; diff --git a/tests/baselines/reference/classConstructorAccessibility4.js b/tests/baselines/reference/classConstructorAccessibility4.js index 4772ac68d11..f6370729971 100644 --- a/tests/baselines/reference/classConstructorAccessibility4.js +++ b/tests/baselines/reference/classConstructorAccessibility4.js @@ -31,11 +31,16 @@ class D { } //// [classConstructorAccessibility4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -51,7 +56,7 @@ var A = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); @@ -73,7 +78,7 @@ var D = (function () { var F = (function (_super) { __extends(F, _super); function F() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return F; }(D)); diff --git a/tests/baselines/reference/classConstructorAccessibility5.js b/tests/baselines/reference/classConstructorAccessibility5.js index d658349c2a5..d409265d89d 100644 --- a/tests/baselines/reference/classConstructorAccessibility5.js +++ b/tests/baselines/reference/classConstructorAccessibility5.js @@ -12,11 +12,16 @@ class Unrelated { //// [classConstructorAccessibility5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -25,7 +30,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.make = function () { new Base(); }; // ok return Derived; diff --git a/tests/baselines/reference/classConstructorParametersAccessibility.js b/tests/baselines/reference/classConstructorParametersAccessibility.js index e0e75bcfeeb..497f662a8b0 100644 --- a/tests/baselines/reference/classConstructorParametersAccessibility.js +++ b/tests/baselines/reference/classConstructorParametersAccessibility.js @@ -27,11 +27,16 @@ class Derived extends C3 { //// [classConstructorParametersAccessibility.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1(x) { this.x = x; diff --git a/tests/baselines/reference/classConstructorParametersAccessibility2.js b/tests/baselines/reference/classConstructorParametersAccessibility2.js index 84da66c3e3c..7a885bbd8d6 100644 --- a/tests/baselines/reference/classConstructorParametersAccessibility2.js +++ b/tests/baselines/reference/classConstructorParametersAccessibility2.js @@ -27,11 +27,16 @@ class Derived extends C3 { //// [classConstructorParametersAccessibility2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1(x) { this.x = x; diff --git a/tests/baselines/reference/classConstructorParametersAccessibility3.js b/tests/baselines/reference/classConstructorParametersAccessibility3.js index db9f94cf0fb..f96f0171046 100644 --- a/tests/baselines/reference/classConstructorParametersAccessibility3.js +++ b/tests/baselines/reference/classConstructorParametersAccessibility3.js @@ -14,11 +14,16 @@ var d: Derived; d.p; // public, OK //// [classConstructorParametersAccessibility3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(p) { this.p = p; diff --git a/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.js b/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.js index 5a5440a92b5..4a0edb610d5 100644 --- a/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.js +++ b/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.js @@ -12,11 +12,16 @@ module M { } //// [classDeclarationMergedInModuleWithContinuation.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { var N = (function () { @@ -33,7 +38,7 @@ var M; var O = (function (_super) { __extends(O, _super); function O() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return O; }(M.N)); diff --git a/tests/baselines/reference/classDeclaredBeforeClassFactory.js b/tests/baselines/reference/classDeclaredBeforeClassFactory.js index 3dd1e7a4aaf..40cfd576644 100644 --- a/tests/baselines/reference/classDeclaredBeforeClassFactory.js +++ b/tests/baselines/reference/classDeclaredBeforeClassFactory.js @@ -8,16 +8,21 @@ function makeBaseClass() { //// [classDeclaredBeforeClassFactory.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // Should be OK due to hoisting var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(makeBaseClass())); diff --git a/tests/baselines/reference/classDoesNotDependOnBaseTypes.js b/tests/baselines/reference/classDoesNotDependOnBaseTypes.js index 076412e164d..c1642125fe9 100644 --- a/tests/baselines/reference/classDoesNotDependOnBaseTypes.js +++ b/tests/baselines/reference/classDoesNotDependOnBaseTypes.js @@ -13,11 +13,16 @@ class StringTreeCollectionBase { class StringTreeCollection extends StringTreeCollectionBase { } //// [classDoesNotDependOnBaseTypes.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x; if (typeof x !== "string") { x[0] = ""; @@ -31,7 +36,7 @@ var StringTreeCollectionBase = (function () { var StringTreeCollection = (function (_super) { __extends(StringTreeCollection, _super); function StringTreeCollection() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return StringTreeCollection; }(StringTreeCollectionBase)); diff --git a/tests/baselines/reference/classExpression2.js b/tests/baselines/reference/classExpression2.js index 59b62c60cfe..7f48463e81a 100644 --- a/tests/baselines/reference/classExpression2.js +++ b/tests/baselines/reference/classExpression2.js @@ -3,11 +3,16 @@ 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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var D = (function () { function D() { } @@ -16,7 +21,7 @@ var D = (function () { var v = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(D)); diff --git a/tests/baselines/reference/classExpression3.js b/tests/baselines/reference/classExpression3.js index c0376c54c27..2582aa80398 100644 --- a/tests/baselines/reference/classExpression3.js +++ b/tests/baselines/reference/classExpression3.js @@ -7,15 +7,20 @@ 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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + 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() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.c = 3; return _this; } @@ -23,7 +28,7 @@ var C = (function (_super) { }((function (_super) { __extends(class_2, _super); function class_2() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.b = 2; return _this; } diff --git a/tests/baselines/reference/classExpressionExtendingAbstractClass.js b/tests/baselines/reference/classExpressionExtendingAbstractClass.js index 7312ab6567d..814753be4d7 100644 --- a/tests/baselines/reference/classExpressionExtendingAbstractClass.js +++ b/tests/baselines/reference/classExpressionExtendingAbstractClass.js @@ -9,11 +9,16 @@ var C = class extends A { // no error reported! //// [classExpressionExtendingAbstractClass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -22,7 +27,7 @@ var A = (function () { var C = (function (_super) { __extends(class_1, _super); function class_1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class_1; }(A)); diff --git a/tests/baselines/reference/classExtendingBuiltinType.js b/tests/baselines/reference/classExtendingBuiltinType.js index 4c95e3008ea..6fdead50a44 100644 --- a/tests/baselines/reference/classExtendingBuiltinType.js +++ b/tests/baselines/reference/classExtendingBuiltinType.js @@ -12,78 +12,83 @@ 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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function (_super) { __extends(C1, _super); function C1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C1; }(Object)); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(Function)); var C3 = (function (_super) { __extends(C3, _super); function C3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C3; }(String)); var C4 = (function (_super) { __extends(C4, _super); function C4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C4; }(Boolean)); var C5 = (function (_super) { __extends(C5, _super); function C5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C5; }(Number)); var C6 = (function (_super) { __extends(C6, _super); function C6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C6; }(Date)); var C7 = (function (_super) { __extends(C7, _super); function C7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C7; }(RegExp)); var C8 = (function (_super) { __extends(C8, _super); function C8() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C8; }(Error)); var C9 = (function (_super) { __extends(C9, _super); function C9() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C9; }(Array)); var C10 = (function (_super) { __extends(C10, _super); function C10() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C10; }(Array)); diff --git a/tests/baselines/reference/classExtendingClass.js b/tests/baselines/reference/classExtendingClass.js index 91e3752980c..52b415ccb77 100644 --- a/tests/baselines/reference/classExtendingClass.js +++ b/tests/baselines/reference/classExtendingClass.js @@ -32,11 +32,16 @@ var r7 = d2.thing(''); var r8 = D2.other(1); //// [classExtendingClass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -47,7 +52,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); @@ -66,7 +71,7 @@ var C2 = (function () { var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(C2)); diff --git a/tests/baselines/reference/classExtendingClassLikeType.js b/tests/baselines/reference/classExtendingClassLikeType.js index bfc10c23563..6ba82a0a08b 100644 --- a/tests/baselines/reference/classExtendingClassLikeType.js +++ b/tests/baselines/reference/classExtendingClassLikeType.js @@ -59,16 +59,21 @@ 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 __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + 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() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D0; }(Base)); @@ -107,7 +112,7 @@ var D3 = (function (_super) { var D4 = (function (_super) { __extends(D4, _super); function D4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D4; }(getBase())); @@ -115,7 +120,7 @@ var D4 = (function (_super) { var D5 = (function (_super) { __extends(D5, _super); function D5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D5; }(getBadBase())); diff --git a/tests/baselines/reference/classExtendingNonConstructor.js b/tests/baselines/reference/classExtendingNonConstructor.js index 574d5004486..bfe716b0029 100644 --- a/tests/baselines/reference/classExtendingNonConstructor.js +++ b/tests/baselines/reference/classExtendingNonConstructor.js @@ -15,11 +15,16 @@ 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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x; function foo() { this.x = 1; @@ -27,49 +32,49 @@ function foo() { var C1 = (function (_super) { __extends(C1, _super); function C1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C1; }(undefined)); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(true)); var C3 = (function (_super) { __extends(C3, _super); function C3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C3; }(false)); var C4 = (function (_super) { __extends(C4, _super); function C4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C4; }(42)); var C5 = (function (_super) { __extends(C5, _super); function C5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C5; }("hello")); var C6 = (function (_super) { __extends(C6, _super); function C6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C6; }(x)); var C7 = (function (_super) { __extends(C7, _super); function C7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C7; }(foo)); diff --git a/tests/baselines/reference/classExtendingNull.js b/tests/baselines/reference/classExtendingNull.js index 8d5d73329aa..6725bcc7d9e 100644 --- a/tests/baselines/reference/classExtendingNull.js +++ b/tests/baselines/reference/classExtendingNull.js @@ -4,22 +4,25 @@ 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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function (_super) { __extends(C1, _super); function C1() { - return _super.apply(this, arguments) || this; } return C1; }(null)); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; } return C2; }((null))); diff --git a/tests/baselines/reference/classExtendingPrimitive.js b/tests/baselines/reference/classExtendingPrimitive.js index 53cb45c2081..fac6ada65ec 100644 --- a/tests/baselines/reference/classExtendingPrimitive.js +++ b/tests/baselines/reference/classExtendingPrimitive.js @@ -16,36 +16,41 @@ class C8 extends E { } //// [classExtendingPrimitive.js] // classes cannot extend primitives -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(number)); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(string)); var C3 = (function (_super) { __extends(C3, _super); function C3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C3; }(boolean)); var C4 = (function (_super) { __extends(C4, _super); function C4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C4; }(Void)); @@ -58,28 +63,27 @@ void {}; var C5 = (function (_super) { __extends(C5, _super); function C5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C5; }(Null)); var C5a = (function (_super) { __extends(C5a, _super); function C5a() { - return _super.apply(this, arguments) || this; } return C5a; }(null)); var C6 = (function (_super) { __extends(C6, _super); function C6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C6; }(undefined)); var C7 = (function (_super) { __extends(C7, _super); function C7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C7; }(Undefined)); @@ -90,7 +94,7 @@ var E; var C8 = (function (_super) { __extends(C8, _super); function C8() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C8; }(E)); diff --git a/tests/baselines/reference/classExtendingPrimitive2.js b/tests/baselines/reference/classExtendingPrimitive2.js index b32dc31a5b4..2b9cd6de6b6 100644 --- a/tests/baselines/reference/classExtendingPrimitive2.js +++ b/tests/baselines/reference/classExtendingPrimitive2.js @@ -6,11 +6,16 @@ class C5a extends null { } //// [classExtendingPrimitive2.js] // classes cannot extend primitives -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C4a = (function () { function C4a() { } @@ -20,7 +25,6 @@ void {}; var C5a = (function (_super) { __extends(C5a, _super); function C5a() { - return _super.apply(this, arguments) || this; } return C5a; }(null)); diff --git a/tests/baselines/reference/classExtendingQualifiedName.js b/tests/baselines/reference/classExtendingQualifiedName.js index fced8c2a373..24c61fd0bd6 100644 --- a/tests/baselines/reference/classExtendingQualifiedName.js +++ b/tests/baselines/reference/classExtendingQualifiedName.js @@ -8,11 +8,16 @@ module M { } //// [classExtendingQualifiedName.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { var C = (function () { @@ -23,7 +28,7 @@ var M; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(M.C)); diff --git a/tests/baselines/reference/classExtendingQualifiedName2.js b/tests/baselines/reference/classExtendingQualifiedName2.js index c133ceb87dc..633cd4d9ef4 100644 --- a/tests/baselines/reference/classExtendingQualifiedName2.js +++ b/tests/baselines/reference/classExtendingQualifiedName2.js @@ -8,11 +8,16 @@ module M { } //// [classExtendingQualifiedName2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { var C = (function () { @@ -24,7 +29,7 @@ var M; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(M.C)); diff --git a/tests/baselines/reference/classExtendsAcrossFiles.js b/tests/baselines/reference/classExtendsAcrossFiles.js index 5be0ab8f9c0..6fcce5c5982 100644 --- a/tests/baselines/reference/classExtendsAcrossFiles.js +++ b/tests/baselines/reference/classExtendsAcrossFiles.js @@ -21,11 +21,16 @@ export const b = { //// [b.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a_1 = require("./a"); exports.b = { f: function () { @@ -37,7 +42,7 @@ exports.b = { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -46,11 +51,16 @@ exports.b = { }; //// [a.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var b_1 = require("./b"); exports.a = { f: function () { @@ -62,7 +72,7 @@ exports.a = { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.js b/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.js index 91f96450d87..3b835f86755 100644 --- a/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.js +++ b/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.js @@ -14,11 +14,16 @@ module Foo { } //// [classExtendsClauseClassMergedWithModuleNotReferingConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -32,7 +37,7 @@ var Foo; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.js b/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.js index 6c3dc789445..d0377bdfc18 100644 --- a/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.js +++ b/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.js @@ -7,11 +7,16 @@ module Foo { //// [classExtendsClauseClassNotReferringConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -23,7 +28,7 @@ var Foo; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/classExtendsEveryObjectType.js b/tests/baselines/reference/classExtendsEveryObjectType.js index a19f5d5cdd6..946f2c70f91 100644 --- a/tests/baselines/reference/classExtendsEveryObjectType.js +++ b/tests/baselines/reference/classExtendsEveryObjectType.js @@ -17,22 +17,27 @@ class C5 extends foo { } // error class C6 extends []{ } // error //// [classExtendsEveryObjectType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(I)); // error var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }({ foo: string })); // error @@ -40,7 +45,7 @@ var x; var C3 = (function (_super) { __extends(C3, _super); function C3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C3; }(x)); // error @@ -51,7 +56,7 @@ var M; var C4 = (function (_super) { __extends(C4, _super); function C4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C4; }(M)); // error @@ -59,14 +64,14 @@ function foo() { } var C5 = (function (_super) { __extends(C5, _super); function C5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C5; }(foo)); // error var C6 = (function (_super) { __extends(C6, _super); function C6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C6; }([])); // error diff --git a/tests/baselines/reference/classExtendsEveryObjectType2.js b/tests/baselines/reference/classExtendsEveryObjectType2.js index fbc364ca5da..d8dbdbb5721 100644 --- a/tests/baselines/reference/classExtendsEveryObjectType2.js +++ b/tests/baselines/reference/classExtendsEveryObjectType2.js @@ -4,22 +4,27 @@ class C2 extends { foo: string; } { } // error class C6 extends []{ } // error //// [classExtendsEveryObjectType2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }({ foo: string })); // error var C6 = (function (_super) { __extends(C6, _super); function C6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C6; }([])); // error diff --git a/tests/baselines/reference/classExtendsInterface.js b/tests/baselines/reference/classExtendsInterface.js index b5946224317..cd86c42ae0b 100644 --- a/tests/baselines/reference/classExtendsInterface.js +++ b/tests/baselines/reference/classExtendsInterface.js @@ -9,15 +9,20 @@ class B2 implements Comparable2 {} //// [classExtendsInterface.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function (_super) { __extends(A, _super); function A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A; }(Comparable)); @@ -29,7 +34,7 @@ var B = (function () { var A2 = (function (_super) { __extends(A2, _super); function A2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A2; }(Comparable2)); diff --git a/tests/baselines/reference/classExtendsInterfaceInExpression.js b/tests/baselines/reference/classExtendsInterfaceInExpression.js index 9dcd8dd7279..1bbdae0370e 100644 --- a/tests/baselines/reference/classExtendsInterfaceInExpression.js +++ b/tests/baselines/reference/classExtendsInterfaceInExpression.js @@ -9,18 +9,23 @@ class C extends factory(A) {} //// [classExtendsInterfaceInExpression.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function factory(a) { return null; } var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(factory(A))); diff --git a/tests/baselines/reference/classExtendsInterfaceInModule.js b/tests/baselines/reference/classExtendsInterfaceInModule.js index 9da8831a138..96b2906e54f 100644 --- a/tests/baselines/reference/classExtendsInterfaceInModule.js +++ b/tests/baselines/reference/classExtendsInterfaceInModule.js @@ -16,29 +16,34 @@ class D extends Mod.Nested.I {} //// [classExtendsInterfaceInModule.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function (_super) { __extends(C1, _super); function C1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C1; }(M.I1)); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(M.I2)); var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(Mod.Nested.I)); diff --git a/tests/baselines/reference/classExtendsItself.js b/tests/baselines/reference/classExtendsItself.js index 36f2263d671..197f76edb80 100644 --- a/tests/baselines/reference/classExtendsItself.js +++ b/tests/baselines/reference/classExtendsItself.js @@ -6,29 +6,34 @@ class D extends D { } // error class E extends E { } // error //// [classExtendsItself.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(C)); // error var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(D)); // error var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(E)); // error diff --git a/tests/baselines/reference/classExtendsItselfIndirectly.js b/tests/baselines/reference/classExtendsItselfIndirectly.js index 0f3f48d2f2c..e5bd50ae80a 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly.js +++ b/tests/baselines/reference/classExtendsItselfIndirectly.js @@ -12,50 +12,55 @@ class D2 extends C2 { bar: T; } class E2 extends D2 { baz: T; } //// [classExtendsItselfIndirectly.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(E)); // error var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(D)); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(E2)); // error var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(C2)); var E2 = (function (_super) { __extends(E2, _super); function E2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E2; }(D2)); diff --git a/tests/baselines/reference/classExtendsItselfIndirectly2.js b/tests/baselines/reference/classExtendsItselfIndirectly2.js index e215a07c357..ae3bf4ed788 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly2.js +++ b/tests/baselines/reference/classExtendsItselfIndirectly2.js @@ -23,15 +23,20 @@ module O { } //// [classExtendsItselfIndirectly2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(N.E)); // error @@ -40,7 +45,7 @@ var M; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); @@ -51,7 +56,7 @@ var N; var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(M.D)); @@ -62,7 +67,7 @@ var O; var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(Q.E2)); // error @@ -71,7 +76,7 @@ var O; var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(C2)); @@ -82,7 +87,7 @@ var O; var E2 = (function (_super) { __extends(E2, _super); function E2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E2; }(P.D2)); diff --git a/tests/baselines/reference/classExtendsItselfIndirectly3.js b/tests/baselines/reference/classExtendsItselfIndirectly3.js index f8366d77e13..8f004a44cfe 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly3.js +++ b/tests/baselines/reference/classExtendsItselfIndirectly3.js @@ -19,80 +19,110 @@ class D2 extends C2 { bar: T; } class E2 extends D2 { baz: T; } //// [classExtendsItselfIndirectly_file1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(E)); // error //// [classExtendsItselfIndirectly_file2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); //// [classExtendsItselfIndirectly_file3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(D)); //// [classExtendsItselfIndirectly_file4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(E2)); // error //// [classExtendsItselfIndirectly_file5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(C2)); //// [classExtendsItselfIndirectly_file6.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var E2 = (function (_super) { __extends(E2, _super); function E2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E2; }(D2)); diff --git a/tests/baselines/reference/classExtendsMultipleBaseClasses.js b/tests/baselines/reference/classExtendsMultipleBaseClasses.js index cd9c28ad283..830bf6fb988 100644 --- a/tests/baselines/reference/classExtendsMultipleBaseClasses.js +++ b/tests/baselines/reference/classExtendsMultipleBaseClasses.js @@ -4,11 +4,16 @@ class B { } class C extends A,B { } //// [classExtendsMultipleBaseClasses.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -22,7 +27,7 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/classExtendsNull.js b/tests/baselines/reference/classExtendsNull.js index 1eeb5172cad..674b212f98e 100644 --- a/tests/baselines/reference/classExtendsNull.js +++ b/tests/baselines/reference/classExtendsNull.js @@ -13,15 +13,20 @@ class D extends null { } //// [classExtendsNull.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - var _this = _super.call(this) || this; + _this = _super.call(this) || this; return Object.create(null); } return C; @@ -29,7 +34,6 @@ var C = (function (_super) { var D = (function (_super) { __extends(D, _super); function D() { - var _this; return Object.create(null); } return D; diff --git a/tests/baselines/reference/classExtendsShadowedConstructorFunction.js b/tests/baselines/reference/classExtendsShadowedConstructorFunction.js index ddaadc2dc62..391a6e52fa3 100644 --- a/tests/baselines/reference/classExtendsShadowedConstructorFunction.js +++ b/tests/baselines/reference/classExtendsShadowedConstructorFunction.js @@ -9,11 +9,16 @@ module M { } //// [classExtendsShadowedConstructorFunction.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -25,7 +30,7 @@ var M; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/classExtendsValidConstructorFunction.js b/tests/baselines/reference/classExtendsValidConstructorFunction.js index 31bff6e430c..e6f9b389739 100644 --- a/tests/baselines/reference/classExtendsValidConstructorFunction.js +++ b/tests/baselines/reference/classExtendsValidConstructorFunction.js @@ -6,17 +6,22 @@ var x = new foo(); // can be used as a constructor function class C extends foo { } // error, cannot extend it though //// [classExtendsValidConstructorFunction.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function foo() { } var x = new foo(); // can be used as a constructor function var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(foo)); // error, cannot extend it though diff --git a/tests/baselines/reference/classHeritageWithTrailingSeparator.js b/tests/baselines/reference/classHeritageWithTrailingSeparator.js index 12265f569bd..4d863741ada 100644 --- a/tests/baselines/reference/classHeritageWithTrailingSeparator.js +++ b/tests/baselines/reference/classHeritageWithTrailingSeparator.js @@ -4,11 +4,16 @@ class D extends C, { } //// [classHeritageWithTrailingSeparator.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -17,7 +22,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/classImplementsClass2.js b/tests/baselines/reference/classImplementsClass2.js index 5e3eae46543..330a9a7dece 100644 --- a/tests/baselines/reference/classImplementsClass2.js +++ b/tests/baselines/reference/classImplementsClass2.js @@ -14,11 +14,16 @@ c = c2; c2 = c; //// [classImplementsClass2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -33,7 +38,7 @@ var C = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C2.prototype.foo = function () { return 1; diff --git a/tests/baselines/reference/classImplementsClass3.js b/tests/baselines/reference/classImplementsClass3.js index 5fd003e93b9..649afb528a3 100644 --- a/tests/baselines/reference/classImplementsClass3.js +++ b/tests/baselines/reference/classImplementsClass3.js @@ -15,11 +15,16 @@ c = c2; c2 = c; //// [classImplementsClass3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -37,7 +42,7 @@ var C = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(A)); diff --git a/tests/baselines/reference/classImplementsClass4.js b/tests/baselines/reference/classImplementsClass4.js index 477288972df..0d7a8661ed1 100644 --- a/tests/baselines/reference/classImplementsClass4.js +++ b/tests/baselines/reference/classImplementsClass4.js @@ -17,11 +17,16 @@ c = c2; c2 = c; //// [classImplementsClass4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { this.x = 1; @@ -40,7 +45,7 @@ var C = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(A)); diff --git a/tests/baselines/reference/classImplementsClass5.js b/tests/baselines/reference/classImplementsClass5.js index 0ec258ab77b..4b5229bdfc6 100644 --- a/tests/baselines/reference/classImplementsClass5.js +++ b/tests/baselines/reference/classImplementsClass5.js @@ -18,11 +18,16 @@ c = c2; c2 = c; //// [classImplementsClass5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { this.x = 1; @@ -42,7 +47,7 @@ var C = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(A)); diff --git a/tests/baselines/reference/classImplementsClass6.js b/tests/baselines/reference/classImplementsClass6.js index 0771c56415c..fb42e9451a7 100644 --- a/tests/baselines/reference/classImplementsClass6.js +++ b/tests/baselines/reference/classImplementsClass6.js @@ -22,11 +22,16 @@ c.bar(); // error c2.bar(); // should error //// [classImplementsClass6.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -47,7 +52,7 @@ var C = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(A)); diff --git a/tests/baselines/reference/classIndexer3.js b/tests/baselines/reference/classIndexer3.js index 2e55c894645..344baf039e1 100644 --- a/tests/baselines/reference/classIndexer3.js +++ b/tests/baselines/reference/classIndexer3.js @@ -11,11 +11,16 @@ class D123 extends C123 { } //// [classIndexer3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C123 = (function () { function C123() { } @@ -24,7 +29,7 @@ var C123 = (function () { var D123 = (function (_super) { __extends(D123, _super); function D123() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D123; }(C123)); diff --git a/tests/baselines/reference/classInheritence.js b/tests/baselines/reference/classInheritence.js index f68d76fad47..a43cf9c8bb8 100644 --- a/tests/baselines/reference/classInheritence.js +++ b/tests/baselines/reference/classInheritence.js @@ -3,22 +3,27 @@ class B extends A { } class A extends A { } //// [classInheritence.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var A = (function (_super) { __extends(A, _super); function A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A; }(A)); diff --git a/tests/baselines/reference/classIsSubtypeOfBaseType.js b/tests/baselines/reference/classIsSubtypeOfBaseType.js index 52300987d8e..adfa94b4b7e 100644 --- a/tests/baselines/reference/classIsSubtypeOfBaseType.js +++ b/tests/baselines/reference/classIsSubtypeOfBaseType.js @@ -16,11 +16,16 @@ class Derived2 extends Base<{ bar: string; }> { } //// [classIsSubtypeOfBaseType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -29,14 +34,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/classOrder2.js b/tests/baselines/reference/classOrder2.js index 63490fa29b1..897089b8b57 100644 --- a/tests/baselines/reference/classOrder2.js +++ b/tests/baselines/reference/classOrder2.js @@ -20,15 +20,20 @@ a.foo(); //// [classOrder2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function (_super) { __extends(A, _super); function A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } A.prototype.foo = function () { this.bar(); }; return A; diff --git a/tests/baselines/reference/classOrderBug.js b/tests/baselines/reference/classOrderBug.js index e21a5ed64cf..71f407a14f5 100644 --- a/tests/baselines/reference/classOrderBug.js +++ b/tests/baselines/reference/classOrderBug.js @@ -16,11 +16,16 @@ class foo extends baz {} //// [classOrderBug.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var bar = (function () { function bar() { this.baz = new foo(); @@ -35,7 +40,7 @@ var baz = (function () { var foo = (function (_super) { __extends(foo, _super); function foo() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return foo; }(baz)); diff --git a/tests/baselines/reference/classSideInheritance1.js b/tests/baselines/reference/classSideInheritance1.js index 9443509032c..549d9451199 100644 --- a/tests/baselines/reference/classSideInheritance1.js +++ b/tests/baselines/reference/classSideInheritance1.js @@ -16,11 +16,16 @@ A.bar(); // valid C2.bar(); // valid //// [classSideInheritance1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -33,7 +38,7 @@ var A = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(A)); diff --git a/tests/baselines/reference/classSideInheritance2.js b/tests/baselines/reference/classSideInheritance2.js index 67ee666749b..9887472615f 100644 --- a/tests/baselines/reference/classSideInheritance2.js +++ b/tests/baselines/reference/classSideInheritance2.js @@ -21,11 +21,16 @@ class TextBase implements IText { } //// [classSideInheritance2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var SubText = (function (_super) { __extends(SubText, _super); function SubText(text, span) { diff --git a/tests/baselines/reference/classSideInheritance3.js b/tests/baselines/reference/classSideInheritance3.js index 589dd81c5c6..9ce60d012f4 100644 --- a/tests/baselines/reference/classSideInheritance3.js +++ b/tests/baselines/reference/classSideInheritance3.js @@ -19,11 +19,16 @@ var r2: new (x: string) => A = B; // error var r3: typeof A = C; // ok //// [classSideInheritance3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(x) { this.x = x; diff --git a/tests/baselines/reference/classUpdateTests.js b/tests/baselines/reference/classUpdateTests.js index 53ef71d0e4b..84a619d0461 100644 --- a/tests/baselines/reference/classUpdateTests.js +++ b/tests/baselines/reference/classUpdateTests.js @@ -114,11 +114,16 @@ class R { } //// [classUpdateTests.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // // test codegen for instance properties // @@ -157,7 +162,7 @@ var D = (function () { var E = (function (_super) { __extends(E, _super); function E() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.p1 = 0; return _this; } @@ -166,7 +171,7 @@ var E = (function (_super) { var F = (function (_super) { __extends(F, _super); function F() { - var _this; + var _this = this; return _this; } // ERROR - super call required return F; @@ -205,7 +210,7 @@ var J = (function (_super) { var K = (function (_super) { __extends(K, _super); function K(p1) { - var _this; + var _this = this; _this.p1 = p1; var i = 0; _this = _super.call(this) || this; @@ -225,7 +230,7 @@ var L = (function (_super) { var M = (function (_super) { __extends(M, _super); function M(p1) { - var _this; + var _this = this; _this.p1 = p1; var i = 0; _this = _super.call(this) || this; diff --git a/tests/baselines/reference/classWithBaseClassButNoConstructor.js b/tests/baselines/reference/classWithBaseClassButNoConstructor.js index c25687d3c74..a9f7fbc7700 100644 --- a/tests/baselines/reference/classWithBaseClassButNoConstructor.js +++ b/tests/baselines/reference/classWithBaseClassButNoConstructor.js @@ -41,11 +41,16 @@ var d5 = new D(); // error var d6 = new D(1); // ok //// [classWithBaseClassButNoConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(x) { } @@ -54,7 +59,7 @@ var Base = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(Base)); @@ -69,7 +74,7 @@ var Base2 = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(Base2)); @@ -80,7 +85,7 @@ var d2 = new D(1); // ok var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(Base2)); @@ -90,7 +95,7 @@ var d4 = new D(1); // ok var D3 = (function (_super) { __extends(D3, _super); function D3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D3; }(Base2)); diff --git a/tests/baselines/reference/classWithConstructors.js b/tests/baselines/reference/classWithConstructors.js index f445d22d18f..822f1e3014f 100644 --- a/tests/baselines/reference/classWithConstructors.js +++ b/tests/baselines/reference/classWithConstructors.js @@ -50,11 +50,16 @@ module Generics { } //// [classWithConstructors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var NonGeneric; (function (NonGeneric) { var C = (function () { @@ -75,7 +80,7 @@ var NonGeneric; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C2)); @@ -103,7 +108,7 @@ var Generics; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C2)); diff --git a/tests/baselines/reference/classWithProtectedProperty.js b/tests/baselines/reference/classWithProtectedProperty.js index 2cb8a4e0a50..2b12741d38f 100644 --- a/tests/baselines/reference/classWithProtectedProperty.js +++ b/tests/baselines/reference/classWithProtectedProperty.js @@ -29,11 +29,16 @@ class D extends C { //// [classWithProtectedProperty.js] // accessing any protected outside the class is 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { this.a = ''; @@ -48,7 +53,7 @@ C.g = function () { return ''; }; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.method = function () { // No errors diff --git a/tests/baselines/reference/classWithStaticMembers.js b/tests/baselines/reference/classWithStaticMembers.js index 9e79780d5cc..e4f4805b42f 100644 --- a/tests/baselines/reference/classWithStaticMembers.js +++ b/tests/baselines/reference/classWithStaticMembers.js @@ -20,11 +20,16 @@ var r2 = r.x; var r3 = r.foo; //// [classWithStaticMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C(a, b) { this.a = a; @@ -45,7 +50,7 @@ var r3 = r.foo; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/classdecl.js b/tests/baselines/reference/classdecl.js index a3059757d2f..e1e1313dae2 100644 --- a/tests/baselines/reference/classdecl.js +++ b/tests/baselines/reference/classdecl.js @@ -94,11 +94,16 @@ class e { } //// [classdecl.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a(ns) { } @@ -136,7 +141,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); @@ -161,7 +166,7 @@ var m2; var c = (function (_super) { __extends(c, _super); function c() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return c; }(b)); @@ -177,7 +182,7 @@ var m2; var c = (function (_super) { __extends(c, _super); function c() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return c; }(m1.b)); diff --git a/tests/baselines/reference/clodulesDerivedClasses.js b/tests/baselines/reference/clodulesDerivedClasses.js index ea4bfcf301f..e643ed17578 100644 --- a/tests/baselines/reference/clodulesDerivedClasses.js +++ b/tests/baselines/reference/clodulesDerivedClasses.js @@ -23,11 +23,16 @@ module Path.Utils { //// [clodulesDerivedClasses.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Shape = (function () { function Shape() { } @@ -43,7 +48,7 @@ var Shape = (function () { var Path = (function (_super) { __extends(Path, _super); function Path() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Path; }(Shape)); diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js b/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js index 85c0e398fbd..7d8e23cd508 100644 --- a/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js @@ -40,11 +40,16 @@ class c extends Foo { } //// [collisionSuperAndLocalFunctionInAccessors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function _super() { } var Foo = (function () { @@ -68,7 +73,7 @@ var Foo = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(b.prototype, "prop2", { get: function () { @@ -88,7 +93,7 @@ var b = (function (_super) { var c = (function (_super) { __extends(c, _super); function c() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(c.prototype, "prop2", { get: function () { diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInConstructor.js b/tests/baselines/reference/collisionSuperAndLocalFunctionInConstructor.js index d4a22b731f2..d516c06ad18 100644 --- a/tests/baselines/reference/collisionSuperAndLocalFunctionInConstructor.js +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInConstructor.js @@ -25,11 +25,16 @@ class c extends Foo { } //// [collisionSuperAndLocalFunctionInConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function _super() { } var Foo = (function () { diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInMethod.js b/tests/baselines/reference/collisionSuperAndLocalFunctionInMethod.js index 81c069da169..b211b3e4eac 100644 --- a/tests/baselines/reference/collisionSuperAndLocalFunctionInMethod.js +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInMethod.js @@ -29,11 +29,16 @@ class c extends Foo { } //// [collisionSuperAndLocalFunctionInMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function _super() { } var Foo = (function () { @@ -50,7 +55,7 @@ var Foo = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.prototype.foo = function () { function _super() { @@ -63,7 +68,7 @@ var b = (function (_super) { var c = (function (_super) { __extends(c, _super); function c() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } c.prototype.foo = function () { var x = function () { diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInProperty.js b/tests/baselines/reference/collisionSuperAndLocalFunctionInProperty.js index 67b7f0e3991..9701e9b4fc4 100644 --- a/tests/baselines/reference/collisionSuperAndLocalFunctionInProperty.js +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInProperty.js @@ -19,11 +19,16 @@ class b extends Foo { } //// [collisionSuperAndLocalFunctionInProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function _super() { } var Foo = (function () { @@ -40,7 +45,7 @@ var Foo = (function () { var b = (function (_super) { __extends(b, _super); function b() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.prop2 = { doStuff: function () { function _super() { diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js b/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js index 26f782c0d17..3a6e8b9e772 100644 --- a/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js +++ b/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js @@ -33,11 +33,16 @@ class c extends Foo { } //// [collisionSuperAndLocalVarInAccessors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _super = 10; // No Error var Foo = (function () { function Foo() { @@ -58,7 +63,7 @@ var Foo = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(b.prototype, "prop2", { get: function () { @@ -76,7 +81,7 @@ var b = (function (_super) { var c = (function (_super) { __extends(c, _super); function c() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(c.prototype, "prop2", { get: function () { diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInConstructor.js b/tests/baselines/reference/collisionSuperAndLocalVarInConstructor.js index e3069352c08..dcbf08024a9 100644 --- a/tests/baselines/reference/collisionSuperAndLocalVarInConstructor.js +++ b/tests/baselines/reference/collisionSuperAndLocalVarInConstructor.js @@ -21,11 +21,16 @@ class c extends Foo { } //// [collisionSuperAndLocalVarInConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _super = 10; // No Error var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInMethod.js b/tests/baselines/reference/collisionSuperAndLocalVarInMethod.js index 0524d993ba1..c6cce551d93 100644 --- a/tests/baselines/reference/collisionSuperAndLocalVarInMethod.js +++ b/tests/baselines/reference/collisionSuperAndLocalVarInMethod.js @@ -19,11 +19,16 @@ class c extends Foo { } //// [collisionSuperAndLocalVarInMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _super = 10; // No Error var Foo = (function () { function Foo() { @@ -36,7 +41,7 @@ var Foo = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.prototype.foo = function () { var _super = 10; // Should be error @@ -46,7 +51,7 @@ var b = (function (_super) { var c = (function (_super) { __extends(c, _super); function c() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } c.prototype.foo = function () { var x = function () { diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInProperty.js b/tests/baselines/reference/collisionSuperAndLocalVarInProperty.js index d793e022c6b..b88513b53dd 100644 --- a/tests/baselines/reference/collisionSuperAndLocalVarInProperty.js +++ b/tests/baselines/reference/collisionSuperAndLocalVarInProperty.js @@ -18,11 +18,16 @@ class b extends Foo { } //// [collisionSuperAndLocalVarInProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _super = 10; // No Error var Foo = (function () { function Foo() { @@ -38,7 +43,7 @@ var Foo = (function () { var b = (function (_super) { __extends(b, _super); function b() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.prop2 = { doStuff: function () { var _super = 10; // Should be error diff --git a/tests/baselines/reference/collisionSuperAndNameResolution.js b/tests/baselines/reference/collisionSuperAndNameResolution.js index cb5636ec904..c35c30ec84e 100644 --- a/tests/baselines/reference/collisionSuperAndNameResolution.js +++ b/tests/baselines/reference/collisionSuperAndNameResolution.js @@ -12,11 +12,16 @@ class Foo extends base { } //// [collisionSuperAndNameResolution.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var console; var _super = 10; // No error var base = (function () { @@ -27,7 +32,7 @@ var base = (function () { var Foo = (function (_super) { __extends(Foo, _super); function Foo() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Foo.prototype.x = function () { console.log(_super); // Error as this doesnt not resolve to user defined _super diff --git a/tests/baselines/reference/collisionSuperAndParameter.js b/tests/baselines/reference/collisionSuperAndParameter.js index f5765043c55..e2771fadf1f 100644 --- a/tests/baselines/reference/collisionSuperAndParameter.js +++ b/tests/baselines/reference/collisionSuperAndParameter.js @@ -63,11 +63,16 @@ class Foo4 extends Foo { } //// [collisionSuperAndParameter.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 ed19500f9d4..8bc3fc19b5b 100644 --- a/tests/baselines/reference/collisionSuperAndParameter1.js +++ b/tests/baselines/reference/collisionSuperAndParameter1.js @@ -10,11 +10,16 @@ class Foo2 extends Foo { } //// [collisionSuperAndParameter1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -23,7 +28,7 @@ var Foo = (function () { var Foo2 = (function (_super) { __extends(Foo2, _super); function Foo2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Foo2.prototype.x = function () { var lambda = function (_super) { diff --git a/tests/baselines/reference/collisionSuperAndPropertyNameAsConstuctorParameter.js b/tests/baselines/reference/collisionSuperAndPropertyNameAsConstuctorParameter.js index 5fa7fe29091..f905e520866 100644 --- a/tests/baselines/reference/collisionSuperAndPropertyNameAsConstuctorParameter.js +++ b/tests/baselines/reference/collisionSuperAndPropertyNameAsConstuctorParameter.js @@ -31,11 +31,16 @@ class b4 extends a { } //// [collisionSuperAndPropertyNameAsConstuctorParameter.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 9e8132c6883..d0d5059adec 100644 --- a/tests/baselines/reference/collisionThisExpressionAndLocalVarWithSuperExperssion.js +++ b/tests/baselines/reference/collisionThisExpressionAndLocalVarWithSuperExperssion.js @@ -19,11 +19,16 @@ class b2 extends a { } //// [collisionThisExpressionAndLocalVarWithSuperExperssion.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -34,7 +39,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.prototype.foo = function () { var _this = this; @@ -46,7 +51,7 @@ var b = (function (_super) { var b2 = (function (_super) { __extends(b2, _super); function b2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b2.prototype.foo = function () { var _this = this; diff --git a/tests/baselines/reference/commentsInheritance.js b/tests/baselines/reference/commentsInheritance.js index 3527f5d23bb..53fcab2cf3f 100644 --- a/tests/baselines/reference/commentsInheritance.js +++ b/tests/baselines/reference/commentsInheritance.js @@ -152,11 +152,16 @@ i2_i = i3_i; //// [commentsInheritance.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var c1 = (function () { function c1() { } @@ -258,7 +263,7 @@ c2_i = c3_i; var c4 = (function (_super) { __extends(c4, _super); function c4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return c4; }(c2)); diff --git a/tests/baselines/reference/comparisonOperatorWithIdenticalObjects.js b/tests/baselines/reference/comparisonOperatorWithIdenticalObjects.js index a263a30e382..f017fe974bc 100644 --- a/tests/baselines/reference/comparisonOperatorWithIdenticalObjects.js +++ b/tests/baselines/reference/comparisonOperatorWithIdenticalObjects.js @@ -195,11 +195,16 @@ var r8b6 = b5 !== a5; var r8b7 = b6 !== a6; //// [comparisonOperatorWithIdenticalObjects.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A1 = (function () { function A1() { } @@ -227,14 +232,14 @@ var Base = (function () { var A2 = (function (_super) { __extends(A2, _super); function A2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A2; }(Base)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithIdenticalPrimitiveType.errors.txt b/tests/baselines/reference/comparisonOperatorWithIdenticalPrimitiveType.errors.txt new file mode 100644 index 00000000000..ad41a280aad --- /dev/null +++ b/tests/baselines/reference/comparisonOperatorWithIdenticalPrimitiveType.errors.txt @@ -0,0 +1,130 @@ +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(15,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(15,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(16,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(16,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(24,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(24,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(25,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(25,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(33,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(33,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(34,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(34,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(42,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(42,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(43,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(43,24): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts (16 errors) ==== + enum E { a, b, c } + + var a: number; + var b: boolean; + var c: string; + var d: void; + var e: E; + + // operator < + var ra1 = a < a; + var ra2 = b < b; + var ra3 = c < c; + var ra4 = d < d; + var ra5 = e < e; + var ra6 = null < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra7 = undefined < undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator > + var rb1 = a > a; + var rb2 = b > b; + var rb3 = c > c; + var rb4 = d > d; + var rb5 = e > e; + var rb6 = null > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb7 = undefined > undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator <= + var rc1 = a <= a; + var rc2 = b <= b; + var rc3 = c <= c; + var rc4 = d <= d; + var rc5 = e <= e; + var rc6 = null <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc7 = undefined <= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator >= + var rd1 = a >= a; + var rd2 = b >= b; + var rd3 = c >= c; + var rd4 = d >= d; + var rd5 = e >= e; + var rd6 = null >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd7 = undefined >= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator == + var re1 = a == a; + var re2 = b == b; + var re3 = c == c; + var re4 = d == d; + var re5 = e == e; + var re6 = null == null; + var re7 = undefined == undefined; + + // operator != + var rf1 = a != a; + var rf2 = b != b; + var rf3 = c != c; + var rf4 = d != d; + var rf5 = e != e; + var rf6 = null != null; + var rf7 = undefined != undefined; + + // operator === + var rg1 = a === a; + var rg2 = b === b; + var rg3 = c === c; + var rg4 = d === d; + var rg5 = e === e; + var rg6 = null === null; + var rg7 = undefined === undefined; + + // operator !== + var rh1 = a !== a; + var rh2 = b !== b; + var rh3 = c !== c; + var rh4 = d !== d; + var rh5 = e !== e; + var rh6 = null !== null; + var rh7 = undefined !== undefined; \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.js index b8584522b7b..b63b2fa7110 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.js @@ -169,11 +169,16 @@ var r8b6 = b6 !== a6; var r8b7 = b7 !== a7; //// [comparisonOperatorWithNoRelationshipObjectsOnCallSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -182,7 +187,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.js index 93e1e876a7f..cecdb97e164 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.js @@ -169,11 +169,16 @@ var r8b6 = b6 !== a6; var r8b7 = b7 !== a7; //// [comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -182,7 +187,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.js index a8973bf2c10..6fc8effabd0 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.js @@ -112,11 +112,16 @@ var r8b3 = b3 !== a3; var r8b4 = b4 !== a4; //// [comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -125,7 +130,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.js index 4539538782d..fd9f0ffabe1 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.js @@ -150,11 +150,16 @@ var r8b5 = b5 !== a5; var r8b6 = b6 !== a6; //// [comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -163,7 +168,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.js index 5e8412bc361..5898bdd6f2b 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.js @@ -150,11 +150,16 @@ var r8b5 = b5 !== a5; var r8b6 = b6 !== a6; //// [comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -163,7 +168,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithOneOperandIsNull.errors.txt b/tests/baselines/reference/comparisonOperatorWithOneOperandIsNull.errors.txt new file mode 100644 index 00000000000..c74ab997a59 --- /dev/null +++ b/tests/baselines/reference/comparisonOperatorWithOneOperandIsNull.errors.txt @@ -0,0 +1,360 @@ +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(4,22): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(5,22): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(6,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(7,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(13,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(14,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(15,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(16,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(32,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(33,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(34,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(35,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(36,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(37,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(38,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(40,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(41,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(42,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(43,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(44,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(45,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(46,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(49,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(50,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(51,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(52,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(53,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(54,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(55,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(57,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(58,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(59,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(60,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(61,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(62,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(63,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(66,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(67,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(68,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(69,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(70,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(71,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(72,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(74,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(75,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(76,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(77,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(78,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(79,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(80,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(83,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(84,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(85,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(86,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(87,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(88,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(89,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(91,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(92,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(93,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(94,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(95,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(96,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(97,17): error TS2531: Object is possibly 'null'. + + +==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts (64 errors) ==== + enum E { a, b, c } + + function foo(t: T) { + var foo_r1 = t < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r2 = t > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r3 = t <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r4 = t >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r5 = t == null; + var foo_r6 = t != null; + var foo_r7 = t === null; + var foo_r8 = t !== null; + + var foo_r1 = null < t; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r2 = null > t; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r3 = null <= t; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r4 = null >= t; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r5 = null == t; + var foo_r6 = null != t; + var foo_r7 = null === t; + var foo_r8 = null !== t; + } + + var a: boolean; + var b: number; + var c: string; + var d: void; + var e: E; + var f: {}; + var g: string[]; + + // operator < + var r1a1 = null < a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a2 = null < b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a3 = null < c; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a4 = null < d; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a5 = null < e; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a6 = null < f; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a7 = null < g; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + var r1b1 = a < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b2 = b < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b3 = c < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b4 = d < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b5 = e < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b6 = f < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b7 = g < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator > + var r2a1 = null > a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a2 = null > b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a3 = null > c; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a4 = null > d; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a5 = null > e; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a6 = null > f; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a7 = null > g; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + var r2b1 = a > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b2 = b > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b3 = c > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b4 = d > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b5 = e > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b6 = f > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b7 = g > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator <= + var r3a1 = null <= a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a2 = null <= b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a3 = null <= c; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a4 = null <= d; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a5 = null <= e; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a6 = null <= f; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a7 = null <= g; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + var r3b1 = a <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b2 = b <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b3 = c <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b4 = d <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b5 = e <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b6 = f <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b7 = g <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator >= + var r4a1 = null >= a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a2 = null >= b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a3 = null >= c; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a4 = null >= d; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a5 = null >= e; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a6 = null >= f; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a7 = null >= g; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + var r4b1 = a >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b2 = b >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b3 = c >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b4 = d >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b5 = e >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b6 = f >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b7 = g >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator == + var r5a1 = null == a; + var r5a2 = null == b; + var r5a3 = null == c; + var r5a4 = null == d; + var r5a5 = null == e; + var r5a6 = null == f; + var r5a7 = null == g; + + var r5b1 = a == null; + var r5b2 = b == null; + var r5b3 = c == null; + var r5b4 = d == null; + var r5b5 = e == null; + var r5b6 = f == null; + var r5b7 = g == null; + + // operator != + var r6a1 = null != a; + var r6a2 = null != b; + var r6a3 = null != c; + var r6a4 = null != d; + var r6a5 = null != e; + var r6a6 = null != f; + var r6a7 = null != g; + + var r6b1 = a != null; + var r6b2 = b != null; + var r6b3 = c != null; + var r6b4 = d != null; + var r6b5 = e != null; + var r6b6 = f != null; + var r6b7 = g != null; + + // operator === + var r7a1 = null === a; + var r7a2 = null === b; + var r7a3 = null === c; + var r7a4 = null === d; + var r7a5 = null === e; + var r7a6 = null === f; + var r7a7 = null === g; + + var r7b1 = a === null; + var r7b2 = b === null; + var r7b3 = c === null; + var r7b4 = d === null; + var r7b5 = e === null; + var r7b6 = f === null; + var r7b7 = g === null; + + // operator !== + var r8a1 = null !== a; + var r8a2 = null !== b; + var r8a3 = null !== c; + var r8a4 = null !== d; + var r8a5 = null !== e; + var r8a6 = null !== f; + var r8a7 = null !== g; + + var r8b1 = a !== null; + var r8b2 = b !== null; + var r8b3 = c !== null; + var r8b4 = d !== null; + var r8b5 = e !== null; + var r8b6 = f !== null; + var r8b7 = g !== null; \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js index d30c3586b12..1a3bdca7d95 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js @@ -260,11 +260,16 @@ var r8b11 = b11 !== a11; //var r8b12 = b12 !== a12; //// [comparisonOperatorWithSubtypeObjectOnCallSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -273,7 +278,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js index 4235c1352d4..8f23651af05 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js @@ -222,11 +222,16 @@ var r8b9 = b9 !== a9; //var r8b10 = b10 !== a10; //// [comparisonOperatorWithSubtypeObjectOnConstructorSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -235,7 +240,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnIndexSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnIndexSignature.js index 9a6fecd668d..b77b5dd6e4a 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnIndexSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnIndexSignature.js @@ -108,11 +108,16 @@ var r8b1 = b3 !== a3; var r8b1 = b4 !== a4; //// [comparisonOperatorWithSubtypeObjectOnIndexSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -121,7 +126,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js index 5721a452486..b82063b4aed 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js @@ -165,11 +165,16 @@ var r8b6 = b6 !== a6; //var r8b7 = b7 !== a7; //// [comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -178,7 +183,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js index b6bf8a16e61..d83b7b2d5c0 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js @@ -165,11 +165,16 @@ var r8b6 = b6 !== a6; //var r8b7 = b7 !== a7; //// [comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -178,7 +183,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnProperty.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnProperty.js index 690214fc00f..e0befa2237e 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnProperty.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnProperty.js @@ -79,11 +79,16 @@ var rh3 = b1 !== a1; var rh4 = b2 !== a2; //// [comparisonOperatorWithSubtypeObjectOnProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -92,7 +97,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -114,7 +119,7 @@ var A2 = (function () { var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A2)); diff --git a/tests/baselines/reference/complexClassRelationships.js b/tests/baselines/reference/complexClassRelationships.js index 4f48e5fc2c5..2bc345bd499 100644 --- a/tests/baselines/reference/complexClassRelationships.js +++ b/tests/baselines/reference/complexClassRelationships.js @@ -48,16 +48,21 @@ class FooBase { } //// [complexClassRelationships.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // There should be no errors in this file var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.createEmpty = function () { var item = new Derived(); diff --git a/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.js b/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.js index 326c0830c4f..bc9bbcdaa16 100644 --- a/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.js +++ b/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.js @@ -6,15 +6,20 @@ class S18 extends S18 //// [complicatedGenericRecursiveBaseClassReference.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var S18 = (function (_super) { __extends(S18, _super); function S18() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return S18; }(S18)); diff --git a/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.errors.txt b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.errors.txt new file mode 100644 index 00000000000..08d8fd0c6d3 --- /dev/null +++ b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.errors.txt @@ -0,0 +1,65 @@ +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(32,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(33,7): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(39,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(40,7): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts (4 errors) ==== + enum E { a, b } + + var a: any; + var b: void; + + var x1: any; + x1 += a; + x1 += b; + x1 += true; + x1 += 0; + x1 += ''; + x1 += E.a; + x1 += {}; + x1 += null; + x1 += undefined; + + var x2: string; + x2 += a; + x2 += b; + x2 += true; + x2 += 0; + x2 += ''; + x2 += E.a; + x2 += {}; + x2 += null; + x2 += undefined; + + var x3: number; + x3 += a; + x3 += 0; + x3 += E.a; + x3 += null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x3 += undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x4: E; + x4 += a; + x4 += 0; + x4 += E.a; + x4 += null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x4 += undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x5: boolean; + x5 += a; + + var x6: {}; + x6 += a; + x6 += ''; + + var x7: void; + x7 += a; \ No newline at end of file diff --git a/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt b/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt index cadc5c945d1..1812065f149 100644 --- a/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt +++ b/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt @@ -3,22 +3,22 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(8,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and '0'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(9,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'E.a'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(10,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and '{}'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(11,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'boolean'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(12,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'boolean'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(11,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(12,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(15,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'void'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(16,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'true'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(17,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '0'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(18,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'E.a'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(19,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(20,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(21,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(20,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(21,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(24,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(25,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'true'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(26,1): error TS2365: Operator '+=' cannot be applied to types 'void' and '0'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(27,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'E.a'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(28,1): error TS2365: Operator '+=' cannot be applied to types 'void' and '{}'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(29,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(30,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(29,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(30,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(33,1): error TS2365: Operator '+=' cannot be applied to types 'number' and 'void'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(34,1): error TS2365: Operator '+=' cannot be applied to types 'number' and 'true'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(35,1): error TS2365: Operator '+=' cannot be applied to types 'number' and '{}'. @@ -49,11 +49,11 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen ~~~~~~~~ !!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and '{}'. x1 += null; - ~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'boolean'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. x1 += undefined; - ~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'boolean'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x2: {}; x2 += a; @@ -72,11 +72,11 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen ~~~~~~~~ !!! error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. x2 += null; - ~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. x2 += undefined; - ~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x3: void; x3 += a; @@ -95,11 +95,11 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen ~~~~~~~~ !!! error TS2365: Operator '+=' cannot be applied to types 'void' and '{}'. x3 += null; - ~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. x3 += undefined; - ~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x4: number; x4 += a; diff --git a/tests/baselines/reference/compoundArithmeticAssignmentLHSCanBeAssigned.errors.txt b/tests/baselines/reference/compoundArithmeticAssignmentLHSCanBeAssigned.errors.txt new file mode 100644 index 00000000000..f438045a45f --- /dev/null +++ b/tests/baselines/reference/compoundArithmeticAssignmentLHSCanBeAssigned.errors.txt @@ -0,0 +1,47 @@ +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(11,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(12,7): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(18,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(19,7): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(25,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(26,7): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts (6 errors) ==== + enum E { a, b, c } + + var a: any; + var b: number; + var c: E; + + var x1: any; + x1 *= a; + x1 *= b; + x1 *= c; + x1 *= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x1 *= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x2: number; + x2 *= a; + x2 *= b; + x2 *= c; + x2 *= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x2 *= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x3: E; + x3 *= a; + x3 *= b; + x3 *= c; + x3 *= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x3 *= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/compoundArithmeticAssignmentWithInvalidOperands.errors.txt b/tests/baselines/reference/compoundArithmeticAssignmentWithInvalidOperands.errors.txt index 9367285ef93..7429445b422 100644 --- a/tests/baselines/reference/compoundArithmeticAssignmentWithInvalidOperands.errors.txt +++ b/tests/baselines/reference/compoundArithmeticAssignmentWithInvalidOperands.errors.txt @@ -10,9 +10,9 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(13,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(13,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(14,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(14,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(14,7): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(15,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(15,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(15,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(18,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(19,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(19,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -25,9 +25,9 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(24,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(24,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(25,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(25,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(25,7): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(26,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(26,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(26,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(29,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(30,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(30,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -40,9 +40,9 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(35,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(35,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(36,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(36,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(36,7): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(37,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(37,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(37,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(40,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(41,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(41,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -55,9 +55,9 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(46,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(46,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(47,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(47,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(47,7): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(48,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(48,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(48,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(51,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(52,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(53,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -108,12 +108,12 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. x1 *= undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var x2: string; x2 *= a; @@ -149,12 +149,12 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. x2 *= undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var x3: {}; x3 *= a; @@ -190,12 +190,12 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. x3 *= undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var x4: void; x4 *= a; @@ -231,12 +231,12 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. x4 *= undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var x5: number; x5 *= b; diff --git a/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt b/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt index bc6bb41b27f..8948467c590 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt +++ b/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt @@ -17,6 +17,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(41,1): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(42,1): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(45,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(45,1): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(46,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(47,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(48,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -55,6 +56,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(104,2): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(105,2): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(106,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(106,1): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(107,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(108,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(109,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -74,7 +76,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(123,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. -==== tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts (74 errors) ==== +==== tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts (76 errors) ==== // expected error for all the LHS of compound assignments (arithmetic and addition) var value: any; @@ -158,6 +160,8 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa null *= value; ~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. null += value; ~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -295,6 +299,8 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa (null) *= value; ~~~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. + ~~~~~~ +!!! error TS2531: Object is possibly 'null'. (null) += value; ~~~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. diff --git a/tests/baselines/reference/compoundAssignmentLHSIsValue.js b/tests/baselines/reference/compoundAssignmentLHSIsValue.js index df3015731c7..064f2157c1e 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsValue.js +++ b/tests/baselines/reference/compoundAssignmentLHSIsValue.js @@ -124,11 +124,16 @@ foo() += value; (foo()) += value; //// [compoundAssignmentLHSIsValue.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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; // this diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSCanBeAssigned1.errors.txt b/tests/baselines/reference/compoundExponentiationAssignmentLHSCanBeAssigned1.errors.txt new file mode 100644 index 00000000000..26f23028dfa --- /dev/null +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSCanBeAssigned1.errors.txt @@ -0,0 +1,47 @@ +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(11,8): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(12,8): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(18,8): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(19,8): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(25,8): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(26,8): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts (6 errors) ==== + enum E { a, b, c } + + var a: any; + var b: number; + var c: E; + + var x1: any; + x1 **= a; + x1 **= b; + x1 **= c; + x1 **= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x1 **= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x2: number; + x2 **= a; + x2 **= b; + x2 **= c; + x2 **= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x2 **= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x3: E; + x3 **= a; + x3 **= b; + x3 **= c; + x3 **= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x3 **= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSCannotBeAssigned.errors.txt b/tests/baselines/reference/compoundExponentiationAssignmentLHSCannotBeAssigned.errors.txt index 8d152712808..6d48d968638 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSCannotBeAssigned.errors.txt +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSCannotBeAssigned.errors.txt @@ -10,9 +10,9 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(13,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(13,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(14,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(14,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(14,8): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(15,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(15,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(15,8): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(18,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(19,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(19,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -25,9 +25,9 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(24,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(24,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(25,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(25,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(25,8): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(26,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(26,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(26,8): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(29,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(30,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(30,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -40,9 +40,9 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(35,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(35,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(36,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(36,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(36,8): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(37,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(37,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(37,8): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(40,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(41,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(41,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -55,9 +55,9 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(46,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(46,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(47,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(47,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(47,8): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(48,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(48,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(48,8): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(51,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(52,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(53,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -108,12 +108,12 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. x1 **= undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var x2: string; x2 **= a; @@ -149,12 +149,12 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. x2 **= undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var x3: {}; x3 **= a; @@ -190,12 +190,12 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. x3 **= undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var x4: void; x4 **= a; @@ -231,12 +231,12 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. x4 **= undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var x5: number; x5 **= b; diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt index 22eeb18ac4a..51b69f81620 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt @@ -8,6 +8,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(30,1): error TS2539: Cannot assign to 'E' because it is not a variable. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(32,1): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(35,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(35,1): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(36,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(37,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(38,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -28,6 +29,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(75,2): error TS2539: Cannot assign to 'E' because it is not a variable. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(76,2): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(77,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(77,1): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(78,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(79,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(80,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -38,7 +40,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(85,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -==== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts (38 errors) ==== +==== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts (40 errors) ==== // expected error for all the LHS of compound assignments (arithmetic and addition) var value: any; @@ -94,6 +96,8 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm null **= value; ~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. true **= value; ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -176,6 +180,8 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm (null) **= value; ~~~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. + ~~~~~~ +!!! error TS2531: Object is possibly 'null'. (true) **= value; ~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.js b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.js index d188a592588..bd152ea11ad 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.js +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.js @@ -86,11 +86,16 @@ foo() **= value; (foo()) **= value; //// [compoundExponentiationAssignmentLHSIsValue.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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; // this diff --git a/tests/baselines/reference/computedPropertyNames10_ES5.types b/tests/baselines/reference/computedPropertyNames10_ES5.types index 650890fb10e..96130979298 100644 --- a/tests/baselines/reference/computedPropertyNames10_ES5.types +++ b/tests/baselines/reference/computedPropertyNames10_ES5.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; } ->{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; } +>v : { [x: string]: () => void; [x: number]: () => void; [""](): void; [0](): void; } +>{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [x: string]: () => void; [x: number]: () => void; [""](): void; [0](): void; } [s]() { }, >s : string diff --git a/tests/baselines/reference/computedPropertyNames10_ES6.types b/tests/baselines/reference/computedPropertyNames10_ES6.types index 2ff86ed9712..5bbda2e8f19 100644 --- a/tests/baselines/reference/computedPropertyNames10_ES6.types +++ b/tests/baselines/reference/computedPropertyNames10_ES6.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; } ->{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; } +>v : { [x: string]: () => void; [x: number]: () => void; [""](): void; [0](): void; } +>{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [x: string]: () => void; [x: number]: () => void; [""](): void; [0](): void; } [s]() { }, >s : string diff --git a/tests/baselines/reference/computedPropertyNames11_ES5.types b/tests/baselines/reference/computedPropertyNames11_ES5.types index 0787a889f40..88fbc690323 100644 --- a/tests/baselines/reference/computedPropertyNames11_ES5.types +++ b/tests/baselines/reference/computedPropertyNames11_ES5.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: any; [x: number]: any; readonly [0]: number; [""]: any; } ->{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { [x: string]: any; [x: number]: any; readonly [0]: number; [""]: any; } +>v : { [x: string]: any; [x: number]: any; [""]: any; readonly [0]: number; } +>{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { [x: string]: any; [x: number]: any; [""]: any; readonly [0]: number; } get [s]() { return 0; }, >s : string diff --git a/tests/baselines/reference/computedPropertyNames11_ES6.types b/tests/baselines/reference/computedPropertyNames11_ES6.types index 4783d07a2af..458d6d1de49 100644 --- a/tests/baselines/reference/computedPropertyNames11_ES6.types +++ b/tests/baselines/reference/computedPropertyNames11_ES6.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: any; [x: number]: any; readonly [0]: number; [""]: any; } ->{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { [x: string]: any; [x: number]: any; readonly [0]: number; [""]: any; } +>v : { [x: string]: any; [x: number]: any; [""]: any; readonly [0]: number; } +>{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { [x: string]: any; [x: number]: any; [""]: any; readonly [0]: number; } get [s]() { return 0; }, >s : string diff --git a/tests/baselines/reference/computedPropertyNames24_ES5.js b/tests/baselines/reference/computedPropertyNames24_ES5.js index ff9112755bd..dd229bdcae2 100644 --- a/tests/baselines/reference/computedPropertyNames24_ES5.js +++ b/tests/baselines/reference/computedPropertyNames24_ES5.js @@ -9,11 +9,16 @@ class C extends Base { } //// [computedPropertyNames24_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -25,7 +30,7 @@ var Base = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype[_super.bar.call(this)] = function () { }; return C; diff --git a/tests/baselines/reference/computedPropertyNames25_ES5.js b/tests/baselines/reference/computedPropertyNames25_ES5.js index dad9c5c291a..18ee07301e7 100644 --- a/tests/baselines/reference/computedPropertyNames25_ES5.js +++ b/tests/baselines/reference/computedPropertyNames25_ES5.js @@ -14,11 +14,16 @@ class C extends Base { } //// [computedPropertyNames25_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -30,7 +35,7 @@ var Base = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.foo = function () { var obj = (_a = {}, diff --git a/tests/baselines/reference/computedPropertyNames26_ES5.js b/tests/baselines/reference/computedPropertyNames26_ES5.js index 5db7768270a..78a7ef3af77 100644 --- a/tests/baselines/reference/computedPropertyNames26_ES5.js +++ b/tests/baselines/reference/computedPropertyNames26_ES5.js @@ -11,11 +11,16 @@ class C extends Base { } //// [computedPropertyNames26_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -27,7 +32,7 @@ var Base = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype[(_a = {}, _a[_super.bar.call(this)] = 1, _a)[0]] = function () { }; return C; diff --git a/tests/baselines/reference/computedPropertyNames27_ES5.js b/tests/baselines/reference/computedPropertyNames27_ES5.js index 381805659e2..9af56a8835b 100644 --- a/tests/baselines/reference/computedPropertyNames27_ES5.js +++ b/tests/baselines/reference/computedPropertyNames27_ES5.js @@ -6,11 +6,16 @@ class C extends Base { } //// [computedPropertyNames27_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -19,7 +24,7 @@ var Base = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype[(_this = _super.call(this) || this, "prop")] = function () { }; return C; diff --git a/tests/baselines/reference/computedPropertyNames28_ES5.js b/tests/baselines/reference/computedPropertyNames28_ES5.js index ab765c56dd7..c6e2c5d7732 100644 --- a/tests/baselines/reference/computedPropertyNames28_ES5.js +++ b/tests/baselines/reference/computedPropertyNames28_ES5.js @@ -11,11 +11,16 @@ class C extends Base { } //// [computedPropertyNames28_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 c2c7cddd971..f029b9b8651 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES5.js +++ b/tests/baselines/reference/computedPropertyNames30_ES5.js @@ -16,11 +16,16 @@ class C extends Base { } //// [computedPropertyNames30_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 00cc765f4cc..95caabc4bda 100644 --- a/tests/baselines/reference/computedPropertyNames31_ES5.js +++ b/tests/baselines/reference/computedPropertyNames31_ES5.js @@ -16,11 +16,16 @@ class C extends Base { } //// [computedPropertyNames31_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -32,7 +37,7 @@ var Base = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.foo = function () { var _this = this; diff --git a/tests/baselines/reference/computedPropertyNames3_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames3_ES5.errors.txt index fd6f8e8bdc1..4c54e9ad61f 100644 --- a/tests/baselines/reference/computedPropertyNames3_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames3_ES5.errors.txt @@ -2,12 +2,13 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(4,1 tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,9): error TS2378: A 'get' accessor must return a value. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,17): error TS1102: 'delete' cannot be called on an identifier in strict mode. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,17): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(7,16): error TS2378: A 'get' accessor must return a value. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. -==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts (7 errors) ==== +==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts (8 errors) ==== var id; class C { [0 + 1]() { } @@ -21,6 +22,8 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(7,1 !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. ~~ !!! error TS1102: 'delete' cannot be called on an identifier in strict mode. + ~~ +!!! error TS2703: The operand of a delete operator must be a property reference set [[0, 1]](v) { } ~~~~~~~~ !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. diff --git a/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt index 4299437777d..9b7221563c2 100644 --- a/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt @@ -2,12 +2,13 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(4,1 tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,9): error TS2378: A 'get' accessor must return a value. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,17): error TS1102: 'delete' cannot be called on an identifier in strict mode. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,17): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,16): error TS2378: A 'get' accessor must return a value. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. -==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts (7 errors) ==== +==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts (8 errors) ==== var id; class C { [0 + 1]() { } @@ -21,6 +22,8 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,1 !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. ~~ !!! error TS1102: 'delete' cannot be called on an identifier in strict mode. + ~~ +!!! error TS2703: The operand of a delete operator must be a property reference set [[0, 1]](v) { } ~~~~~~~~ !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. diff --git a/tests/baselines/reference/computedPropertyNames43_ES5.js b/tests/baselines/reference/computedPropertyNames43_ES5.js index b1bb0fec72c..100683519ec 100644 --- a/tests/baselines/reference/computedPropertyNames43_ES5.js +++ b/tests/baselines/reference/computedPropertyNames43_ES5.js @@ -13,11 +13,16 @@ class D extends C { } //// [computedPropertyNames43_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -36,7 +41,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(D.prototype, "get1", { // Computed properties diff --git a/tests/baselines/reference/computedPropertyNames44_ES5.js b/tests/baselines/reference/computedPropertyNames44_ES5.js index bf940f15014..0291e337591 100644 --- a/tests/baselines/reference/computedPropertyNames44_ES5.js +++ b/tests/baselines/reference/computedPropertyNames44_ES5.js @@ -12,11 +12,16 @@ class D extends C { } //// [computedPropertyNames44_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -40,7 +45,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(D.prototype, "set1", { set: function (p) { }, diff --git a/tests/baselines/reference/computedPropertyNames45_ES5.js b/tests/baselines/reference/computedPropertyNames45_ES5.js index 5b5d64f9bf0..3bc7e6e350d 100644 --- a/tests/baselines/reference/computedPropertyNames45_ES5.js +++ b/tests/baselines/reference/computedPropertyNames45_ES5.js @@ -13,11 +13,16 @@ class D extends C { } //// [computedPropertyNames45_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -41,7 +46,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(D.prototype, "set1", { set: function (p) { }, diff --git a/tests/baselines/reference/computedPropertyNames4_ES5.types b/tests/baselines/reference/computedPropertyNames4_ES5.types index 64ef5f6a611..6f875aaddac 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES5.types +++ b/tests/baselines/reference/computedPropertyNames4_ES5.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: string | number; [x: number]: string | number; [0]: number; [""]: number; } ->{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [0]: number; [""]: number; } +>v : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } +>{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } [s]: 0, >s : string diff --git a/tests/baselines/reference/computedPropertyNames4_ES6.types b/tests/baselines/reference/computedPropertyNames4_ES6.types index 0c608e21601..e9feac0a81f 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES6.types +++ b/tests/baselines/reference/computedPropertyNames4_ES6.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: string | number; [x: number]: string | number; [0]: number; [""]: number; } ->{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [0]: number; [""]: number; } +>v : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } +>{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } [s]: 0, >s : string diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types index 91ad88c8ade..f144bb9d020 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types @@ -19,7 +19,7 @@ declare function foo(obj: I): T foo({ >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: true | "" | (() => void) | 0 | number[]; [x: number]: (() => void) | 0 | number[]; 0: () => void; p: ""; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: true | "" | (() => void) | 0 | number[]; [x: number]: (() => void) | 0 | number[]; p: ""; 0: () => void; } p: "", >p : string diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types index 131e49dd173..6b8c8ae2e34 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types @@ -19,7 +19,7 @@ declare function foo(obj: I): T foo({ >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: true | "" | (() => void) | 0 | number[]; [x: number]: (() => void) | 0 | number[]; 0: () => void; p: ""; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: true | "" | (() => void) | 0 | number[]; [x: number]: (() => void) | 0 | number[]; p: ""; 0: () => void; } p: "", >p : string diff --git a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.js b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.js index 408571af42a..5d864bce0d6 100644 --- a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.js +++ b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.js @@ -48,11 +48,16 @@ var result11: any = true ? 1 : 'string'; //// [conditionalOperatorWithIdenticalBCT.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 () { function X() { @@ -63,7 +68,7 @@ var X = (function () { var A = (function (_super) { __extends(A, _super); function A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A; }(X)); @@ -71,7 +76,7 @@ var A = (function (_super) { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(X)); diff --git a/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js b/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js index 0ac935a582a..b5715163ad5 100644 --- a/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js +++ b/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js @@ -24,11 +24,16 @@ var result61: (t: X) => number| string = true ? (m) => m.propertyX1 : (n) => n.p //// [conditionalOperatorWithoutIdenticalBCT.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 () { function X() { @@ -39,7 +44,7 @@ var X = (function () { var A = (function (_super) { __extends(A, _super); function A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A; }(X)); @@ -47,7 +52,7 @@ var A = (function (_super) { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(X)); diff --git a/tests/baselines/reference/constantOverloadFunction.js b/tests/baselines/reference/constantOverloadFunction.js index 160191c5ca0..f501623bae5 100644 --- a/tests/baselines/reference/constantOverloadFunction.js +++ b/tests/baselines/reference/constantOverloadFunction.js @@ -14,11 +14,16 @@ function foo(tagName: any): Base { //// [constantOverloadFunction.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -28,7 +33,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.prototype.bar = function () { }; return Derived1; @@ -36,7 +41,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.prototype.baz = function () { }; return Derived2; @@ -44,7 +49,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived3.prototype.biz = function () { }; return Derived3; diff --git a/tests/baselines/reference/constantOverloadFunctionNoSubtypeError.js b/tests/baselines/reference/constantOverloadFunctionNoSubtypeError.js index 509f9ba70e6..2a86fb0c9a3 100644 --- a/tests/baselines/reference/constantOverloadFunctionNoSubtypeError.js +++ b/tests/baselines/reference/constantOverloadFunctionNoSubtypeError.js @@ -15,11 +15,16 @@ function foo(tagName: any): Base { //// [constantOverloadFunctionNoSubtypeError.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -29,7 +34,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.prototype.bar = function () { }; return Derived1; @@ -37,7 +42,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.prototype.baz = function () { }; return Derived2; @@ -45,7 +50,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived3.prototype.biz = function () { }; return Derived3; diff --git a/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.js b/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.js index 7908d36a56a..5b69a2dfae1 100644 --- a/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.js +++ b/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.js @@ -20,11 +20,16 @@ class Container { } //// [constraintCheckInGenericBaseTypeReference.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // No errors var Constraint = (function () { function Constraint() { @@ -40,7 +45,7 @@ var GenericBase = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(GenericBase)); diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js index 6b308d88896..742a03577e5 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js @@ -71,11 +71,16 @@ interface I extends A { //// [constructSignatureAssignabilityInInheritance2.js] // checking subtype relations for function types as it relates to contextual signature instantiation -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -84,21 +89,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.js index 09abd6e0868..fd083159fb1 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.js @@ -114,11 +114,16 @@ module Errors { //// [constructSignatureAssignabilityInInheritance3.js] // checking subtype relations for function types as it relates to contextual signature instantiation // error cases -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Errors; (function (Errors) { var Base = (function () { @@ -129,21 +134,21 @@ var Errors; var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.js index 4e9a8c59bf9..f1fad68d4ca 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.js @@ -61,11 +61,16 @@ interface I extends A { //// [constructSignatureAssignabilityInInheritance4.js] // checking subtype relations for function types as it relates to contextual signature instantiation -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -74,21 +79,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js index 91ec3b313bb..dc08f25c912 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js @@ -51,11 +51,16 @@ interface I extends B { //// [constructSignatureAssignabilityInInheritance5.js] // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithConstructSignatures2 just with an extra level of indirection in the inheritance chain -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -64,21 +69,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.js index edafb009916..e755e3cacc3 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.js @@ -54,11 +54,16 @@ interface I9 extends A { // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithConstructSignatures4 but using class type parameters instead of generic signatures // all are 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -67,21 +72,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/constructorArgs.js b/tests/baselines/reference/constructorArgs.js index 6bbea0fddf7..877cef3dd0a 100644 --- a/tests/baselines/reference/constructorArgs.js +++ b/tests/baselines/reference/constructorArgs.js @@ -16,11 +16,16 @@ class Sub extends Super { //// [constructorArgs.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 45ed976e191..323c9a4c6d8 100644 --- a/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType.js +++ b/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType.js @@ -20,11 +20,16 @@ class Derived2 extends Base { } //// [constructorFunctionTypeIsAssignableToBaseType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -33,14 +38,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.js b/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.js index c5e27748f52..56891defbe0 100644 --- a/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.js +++ b/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.js @@ -34,11 +34,16 @@ class Derived2 extends Base { //// [constructorFunctionTypeIsAssignableToBaseType2.js] // the constructor function itself does not need to be a subtype of the base type constructor 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 a16694cdbf5..64fa9d9099d 100644 --- a/tests/baselines/reference/constructorHasPrototypeProperty.js +++ b/tests/baselines/reference/constructorHasPrototypeProperty.js @@ -32,11 +32,16 @@ module Generic { } //// [constructorHasPrototypeProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var NonGeneric; (function (NonGeneric) { var C = (function () { @@ -47,7 +52,7 @@ var NonGeneric; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); @@ -66,7 +71,7 @@ var Generic; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/constructorOverloads2.js b/tests/baselines/reference/constructorOverloads2.js index 2d26194f2e7..291ea545733 100644 --- a/tests/baselines/reference/constructorOverloads2.js +++ b/tests/baselines/reference/constructorOverloads2.js @@ -26,11 +26,16 @@ f1.bar1(); //// [constructorOverloads2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 c0ae9b452f9..94b29ad89ab 100644 --- a/tests/baselines/reference/constructorOverloads3.js +++ b/tests/baselines/reference/constructorOverloads3.js @@ -23,15 +23,20 @@ f1.bar1(); //// [constructorOverloads3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function (_super) { __extends(Foo, _super); function Foo(x, y) { - var _this; + var _this = this; return _this; } Foo.prototype.bar1 = function () { }; diff --git a/tests/baselines/reference/constructorReturnsInvalidType.errors.txt b/tests/baselines/reference/constructorReturnsInvalidType.errors.txt index a1a5c5e75b9..a615d7177cf 100644 --- a/tests/baselines/reference/constructorReturnsInvalidType.errors.txt +++ b/tests/baselines/reference/constructorReturnsInvalidType.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2322: Type '1' is not assignable to type 'X'. -tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/compiler/constructorReturnsInvalidType.ts(3,9): error TS2322: Type '1' is not assignable to type 'X'. +tests/cases/compiler/constructorReturnsInvalidType.ts(3,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class ==== tests/cases/compiler/constructorReturnsInvalidType.ts (2 errors) ==== class X { constructor() { return 1; - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'X'. - ~ + ~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } foo() { } diff --git a/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt b/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt index 77c63a217e7..f5948382d64 100644 --- a/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt +++ b/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,16): error TS2322: Type '1' is not assignable to type 'D'. -tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class -tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,16): error TS2322: Type '{ x: number; }' is not assignable to type 'F'. +tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,9): error TS2322: Type '1' is not assignable to type 'D'. +tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,9): error TS2322: Type '{ x: number; }' is not assignable to type 'F'. Types of property 'x' are incompatible. Type 'number' is not assignable to type 'T'. -tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class ==== tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts (4 errors) ==== @@ -19,9 +19,9 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl x: number; constructor() { return 1; // error - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'D'. - ~ + ~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } @@ -37,11 +37,11 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl x: T; constructor() { return { x: 1 }; // error - ~~~~~~~~ + ~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ x: number; }' is not assignable to type 'F'. !!! error TS2322: Types of property 'x' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'T'. - ~~~~~~~~ + ~~~~~~~~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } diff --git a/tests/baselines/reference/constructorWithCapturedSuper.js b/tests/baselines/reference/constructorWithCapturedSuper.js index 895f78eb04b..503742de9fe 100644 --- a/tests/baselines/reference/constructorWithCapturedSuper.js +++ b/tests/baselines/reference/constructorWithCapturedSuper.js @@ -53,11 +53,16 @@ class D extends A { } //// [constructorWithCapturedSuper.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var oneA; var A = (function () { function A() { diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js index d4cd737ab46..afdfa36e4a6 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js @@ -281,11 +281,16 @@ TypeScriptAllInOne.Program.Main(); //// [constructorWithIncompleteTypeAnnotation.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var fs = module; ("fs"); var TypeScriptAllInOne; @@ -525,7 +530,7 @@ method2(); var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.method2 = function () { return this.method1(2); diff --git a/tests/baselines/reference/contextualTypingArrayOfLambdas.js b/tests/baselines/reference/contextualTypingArrayOfLambdas.js index caf7ed445e5..5d8b40e39f0 100644 --- a/tests/baselines/reference/contextualTypingArrayOfLambdas.js +++ b/tests/baselines/reference/contextualTypingArrayOfLambdas.js @@ -15,11 +15,16 @@ var xs = [(x: A) => { }, (x: B) => { }, (x: C) => { }]; //// [contextualTypingArrayOfLambdas.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -28,14 +33,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/contextualTypingOfConditionalExpression.js b/tests/baselines/reference/contextualTypingOfConditionalExpression.js index a6ce98f61e2..fd5ec50ebb4 100644 --- a/tests/baselines/reference/contextualTypingOfConditionalExpression.js +++ b/tests/baselines/reference/contextualTypingOfConditionalExpression.js @@ -15,11 +15,16 @@ var x2: (a: A) => void = true ? (a) => a.foo : (b) => b.foo; //// [contextualTypingOfConditionalExpression.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 () { function A() { @@ -29,14 +34,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/contextualTypingOfConditionalExpression2.js b/tests/baselines/reference/contextualTypingOfConditionalExpression2.js index e3bd1643cfb..f5063fa003a 100644 --- a/tests/baselines/reference/contextualTypingOfConditionalExpression2.js +++ b/tests/baselines/reference/contextualTypingOfConditionalExpression2.js @@ -13,11 +13,16 @@ var x2: (a: A) => void = true ? (a: C) => a.foo : (b: number) => { }; //// [contextualTypingOfConditionalExpression2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -26,14 +31,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/contextuallyTypedIife.js b/tests/baselines/reference/contextuallyTypedIife.js index d2eaaf9c2d5..0f3315d66a2 100644 --- a/tests/baselines/reference/contextuallyTypedIife.js +++ b/tests/baselines/reference/contextuallyTypedIife.js @@ -28,6 +28,9 @@ // contextually typed parameters. let twelve = (f => f(12))(i => i); let eleven = (o => o.a(11))({ a: function(n) { return n; } }); +// missing arguments +(function(x, undefined) { return x; })(42); +((x, y, z) => 42)(); //// [contextuallyTypedIife.js] @@ -102,3 +105,6 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } }); // contextually typed parameters. var twelve = (function (f) { return f(12); })(function (i) { return i; }); var eleven = (function (o) { return o.a(11); })({ a: function (n) { return n; } }); +// missing arguments +(function (x, undefined) { return x; })(42); +(function (x, y, z) { return 42; })(); diff --git a/tests/baselines/reference/contextuallyTypedIife.symbols b/tests/baselines/reference/contextuallyTypedIife.symbols index 4512b4db8a2..7a73beaad16 100644 --- a/tests/baselines/reference/contextuallyTypedIife.symbols +++ b/tests/baselines/reference/contextuallyTypedIife.symbols @@ -119,3 +119,14 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } }); >n : Symbol(n, Decl(contextuallyTypedIife.ts, 28, 42)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 28, 42)) +// missing arguments +(function(x, undefined) { return x; })(42); +>x : Symbol(x, Decl(contextuallyTypedIife.ts, 30, 10)) +>undefined : Symbol(undefined, Decl(contextuallyTypedIife.ts, 30, 12)) +>x : Symbol(x, Decl(contextuallyTypedIife.ts, 30, 10)) + +((x, y, z) => 42)(); +>x : Symbol(x, Decl(contextuallyTypedIife.ts, 31, 2)) +>y : Symbol(y, Decl(contextuallyTypedIife.ts, 31, 4)) +>z : Symbol(z, Decl(contextuallyTypedIife.ts, 31, 7)) + diff --git a/tests/baselines/reference/contextuallyTypedIife.types b/tests/baselines/reference/contextuallyTypedIife.types index e6f41265e9a..15038e7dd26 100644 --- a/tests/baselines/reference/contextuallyTypedIife.types +++ b/tests/baselines/reference/contextuallyTypedIife.types @@ -250,3 +250,22 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } }); >n : any >n : any +// missing arguments +(function(x, undefined) { return x; })(42); +>(function(x, undefined) { return x; })(42) : number +>(function(x, undefined) { return x; }) : (x: number, undefined: any) => number +>function(x, undefined) { return x; } : (x: number, undefined: any) => number +>x : number +>undefined : any +>x : number +>42 : 42 + +((x, y, z) => 42)(); +>((x, y, z) => 42)() : number +>((x, y, z) => 42) : (x: any, y: any, z: any) => number +>(x, y, z) => 42 : (x: any, y: any, z: any) => number +>x : any +>y : any +>z : any +>42 : 42 + diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.errors.txt b/tests/baselines/reference/contextuallyTypedIifeStrict.errors.txt new file mode 100644 index 00000000000..220204fc536 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts(14,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts(15,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts(16,17): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts (3 errors) ==== + // arrow + (jake => { })("build"); + // function expression + (function (cats) { })("lol"); + // Lots of Irritating Superfluous Parentheses + (function (x) { } ("!")); + ((((function (y) { }))))("-"); + // multiple arguments + ((a, b, c) => { })("foo", 101, false); + // default parameters + ((m = 10) => m + 1)(12); + ((n = 10) => n + 1)(); + // optional parameters + ((j?) => j + 1)(12); + ~ +!!! error TS2532: Object is possibly 'undefined'. + ((k?) => k + 1)(); + ~ +!!! error TS2532: Object is possibly 'undefined'. + ((l, o?) => l + o)(12); // o should be any + ~ +!!! error TS2532: Object is possibly 'undefined'. + // rest parameters + ((...numbers) => numbers.every(n => n > 0))(5,6,7); + ((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); + ((...noNumbers) => noNumbers.some(n => n > 0))(); + ((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); + // destructuring parameters (with defaults too!) + (({ q }) => q)({ q : 13 }); + (({ p = 14 }) => p)({ p : 15 }); + (({ r = 17 } = { r: 18 }) => r)({r : 19}); + (({ u = 22 } = { u: 23 }) => u)(); + // contextually typed parameters. + let twelve = (f => f(12))(i => i); + let eleven = (o => o.a(11))({ a: function(n) { return n; } }); + // missing arguments + (function(x, undefined) { return x; })(42); + ((x, y, z) => 42)(); + \ No newline at end of file diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.js b/tests/baselines/reference/contextuallyTypedIifeStrict.js new file mode 100644 index 00000000000..c5455ab84c8 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.js @@ -0,0 +1,110 @@ +//// [contextuallyTypedIifeStrict.ts] +// arrow +(jake => { })("build"); +// function expression +(function (cats) { })("lol"); +// Lots of Irritating Superfluous Parentheses +(function (x) { } ("!")); +((((function (y) { }))))("-"); +// multiple arguments +((a, b, c) => { })("foo", 101, false); +// default parameters +((m = 10) => m + 1)(12); +((n = 10) => n + 1)(); +// optional parameters +((j?) => j + 1)(12); +((k?) => k + 1)(); +((l, o?) => l + o)(12); // o should be any +// rest parameters +((...numbers) => numbers.every(n => n > 0))(5,6,7); +((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); +((...noNumbers) => noNumbers.some(n => n > 0))(); +((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); +// destructuring parameters (with defaults too!) +(({ q }) => q)({ q : 13 }); +(({ p = 14 }) => p)({ p : 15 }); +(({ r = 17 } = { r: 18 }) => r)({r : 19}); +(({ u = 22 } = { u: 23 }) => u)(); +// contextually typed parameters. +let twelve = (f => f(12))(i => i); +let eleven = (o => o.a(11))({ a: function(n) { return n; } }); +// missing arguments +(function(x, undefined) { return x; })(42); +((x, y, z) => 42)(); + + +//// [contextuallyTypedIifeStrict.js] +// arrow +(function (jake) { })("build"); +// function expression +(function (cats) { })("lol"); +// Lots of Irritating Superfluous Parentheses +(function (x) { }("!")); +((((function (y) { }))))("-"); +// multiple arguments +(function (a, b, c) { })("foo", 101, false); +// default parameters +(function (m) { + if (m === void 0) { m = 10; } + return m + 1; +})(12); +(function (n) { + if (n === void 0) { n = 10; } + return n + 1; +})(); +// optional parameters +(function (j) { return j + 1; })(12); +(function (k) { return k + 1; })(); +(function (l, o) { return l + o; })(12); // o should be any +// rest parameters +(function () { + var numbers = []; + for (var _i = 0; _i < arguments.length; _i++) { + numbers[_i] = arguments[_i]; + } + return numbers.every(function (n) { return n > 0; }); +})(5, 6, 7); +(function () { + var mixed = []; + for (var _i = 0; _i < arguments.length; _i++) { + mixed[_i] = arguments[_i]; + } + return mixed.every(function (n) { return !!n; }); +})(5, 'oops', 'oh no'); +(function () { + var noNumbers = []; + for (var _i = 0; _i < arguments.length; _i++) { + noNumbers[_i] = arguments[_i]; + } + return noNumbers.some(function (n) { return n > 0; }); +})(); +(function (first) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + return first ? [] : rest.map(function (n) { return n > 0; }); +})(8, 9, 10); +// destructuring parameters (with defaults too!) +(function (_a) { + var q = _a.q; + return q; +})({ q: 13 }); +(function (_a) { + var _b = _a.p, p = _b === void 0 ? 14 : _b; + return p; +})({ p: 15 }); +(function (_a) { + var _b = (_a === void 0 ? { r: 18 } : _a).r, r = _b === void 0 ? 17 : _b; + return r; +})({ r: 19 }); +(function (_a) { + var _b = (_a === void 0 ? { u: 23 } : _a).u, u = _b === void 0 ? 22 : _b; + return u; +})(); +// contextually typed parameters. +var twelve = (function (f) { return f(12); })(function (i) { return i; }); +var eleven = (function (o) { return o.a(11); })({ a: function (n) { return n; } }); +// missing arguments +(function (x, undefined) { return x; })(42); +(function (x, y, z) { return 42; })(); diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.symbols b/tests/baselines/reference/contextuallyTypedIifeStrict.symbols new file mode 100644 index 00000000000..f76c9caa104 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.symbols @@ -0,0 +1,132 @@ +=== tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts === +// arrow +(jake => { })("build"); +>jake : Symbol(jake, Decl(contextuallyTypedIifeStrict.ts, 1, 1)) + +// function expression +(function (cats) { })("lol"); +>cats : Symbol(cats, Decl(contextuallyTypedIifeStrict.ts, 3, 11)) + +// Lots of Irritating Superfluous Parentheses +(function (x) { } ("!")); +>x : Symbol(x, Decl(contextuallyTypedIifeStrict.ts, 5, 11)) + +((((function (y) { }))))("-"); +>y : Symbol(y, Decl(contextuallyTypedIifeStrict.ts, 6, 14)) + +// multiple arguments +((a, b, c) => { })("foo", 101, false); +>a : Symbol(a, Decl(contextuallyTypedIifeStrict.ts, 8, 2)) +>b : Symbol(b, Decl(contextuallyTypedIifeStrict.ts, 8, 4)) +>c : Symbol(c, Decl(contextuallyTypedIifeStrict.ts, 8, 7)) + +// default parameters +((m = 10) => m + 1)(12); +>m : Symbol(m, Decl(contextuallyTypedIifeStrict.ts, 10, 2)) +>m : Symbol(m, Decl(contextuallyTypedIifeStrict.ts, 10, 2)) + +((n = 10) => n + 1)(); +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 11, 2)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 11, 2)) + +// optional parameters +((j?) => j + 1)(12); +>j : Symbol(j, Decl(contextuallyTypedIifeStrict.ts, 13, 2)) +>j : Symbol(j, Decl(contextuallyTypedIifeStrict.ts, 13, 2)) + +((k?) => k + 1)(); +>k : Symbol(k, Decl(contextuallyTypedIifeStrict.ts, 14, 2)) +>k : Symbol(k, Decl(contextuallyTypedIifeStrict.ts, 14, 2)) + +((l, o?) => l + o)(12); // o should be any +>l : Symbol(l, Decl(contextuallyTypedIifeStrict.ts, 15, 2)) +>o : Symbol(o, Decl(contextuallyTypedIifeStrict.ts, 15, 4)) +>l : Symbol(l, Decl(contextuallyTypedIifeStrict.ts, 15, 2)) +>o : Symbol(o, Decl(contextuallyTypedIifeStrict.ts, 15, 4)) + +// rest parameters +((...numbers) => numbers.every(n => n > 0))(5,6,7); +>numbers : Symbol(numbers, Decl(contextuallyTypedIifeStrict.ts, 17, 2)) +>numbers.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>numbers : Symbol(numbers, Decl(contextuallyTypedIifeStrict.ts, 17, 2)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 17, 31)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 17, 31)) + +((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); +>mixed : Symbol(mixed, Decl(contextuallyTypedIifeStrict.ts, 18, 2)) +>mixed.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>mixed : Symbol(mixed, Decl(contextuallyTypedIifeStrict.ts, 18, 2)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 18, 27)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 18, 27)) + +((...noNumbers) => noNumbers.some(n => n > 0))(); +>noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIifeStrict.ts, 19, 2)) +>noNumbers.some : Symbol(Array.some, Decl(lib.d.ts, --, --)) +>noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIifeStrict.ts, 19, 2)) +>some : Symbol(Array.some, Decl(lib.d.ts, --, --)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 19, 34)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 19, 34)) + +((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); +>first : Symbol(first, Decl(contextuallyTypedIifeStrict.ts, 20, 2)) +>rest : Symbol(rest, Decl(contextuallyTypedIifeStrict.ts, 20, 8)) +>first : Symbol(first, Decl(contextuallyTypedIifeStrict.ts, 20, 2)) +>rest.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>rest : Symbol(rest, Decl(contextuallyTypedIifeStrict.ts, 20, 8)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 20, 43)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 20, 43)) + +// destructuring parameters (with defaults too!) +(({ q }) => q)({ q : 13 }); +>q : Symbol(q, Decl(contextuallyTypedIifeStrict.ts, 22, 3)) +>q : Symbol(q, Decl(contextuallyTypedIifeStrict.ts, 22, 3)) +>q : Symbol(q, Decl(contextuallyTypedIifeStrict.ts, 22, 16)) + +(({ p = 14 }) => p)({ p : 15 }); +>p : Symbol(p, Decl(contextuallyTypedIifeStrict.ts, 23, 3)) +>p : Symbol(p, Decl(contextuallyTypedIifeStrict.ts, 23, 3)) +>p : Symbol(p, Decl(contextuallyTypedIifeStrict.ts, 23, 21)) + +(({ r = 17 } = { r: 18 }) => r)({r : 19}); +>r : Symbol(r, Decl(contextuallyTypedIifeStrict.ts, 24, 3)) +>r : Symbol(r, Decl(contextuallyTypedIifeStrict.ts, 24, 16)) +>r : Symbol(r, Decl(contextuallyTypedIifeStrict.ts, 24, 3)) +>r : Symbol(r, Decl(contextuallyTypedIifeStrict.ts, 24, 33)) + +(({ u = 22 } = { u: 23 }) => u)(); +>u : Symbol(u, Decl(contextuallyTypedIifeStrict.ts, 25, 3)) +>u : Symbol(u, Decl(contextuallyTypedIifeStrict.ts, 25, 16)) +>u : Symbol(u, Decl(contextuallyTypedIifeStrict.ts, 25, 3)) + +// contextually typed parameters. +let twelve = (f => f(12))(i => i); +>twelve : Symbol(twelve, Decl(contextuallyTypedIifeStrict.ts, 27, 3)) +>f : Symbol(f, Decl(contextuallyTypedIifeStrict.ts, 27, 14)) +>f : Symbol(f, Decl(contextuallyTypedIifeStrict.ts, 27, 14)) +>i : Symbol(i, Decl(contextuallyTypedIifeStrict.ts, 27, 26)) +>i : Symbol(i, Decl(contextuallyTypedIifeStrict.ts, 27, 26)) + +let eleven = (o => o.a(11))({ a: function(n) { return n; } }); +>eleven : Symbol(eleven, Decl(contextuallyTypedIifeStrict.ts, 28, 3)) +>o : Symbol(o, Decl(contextuallyTypedIifeStrict.ts, 28, 14)) +>o.a : Symbol(a, Decl(contextuallyTypedIifeStrict.ts, 28, 29)) +>o : Symbol(o, Decl(contextuallyTypedIifeStrict.ts, 28, 14)) +>a : Symbol(a, Decl(contextuallyTypedIifeStrict.ts, 28, 29)) +>a : Symbol(a, Decl(contextuallyTypedIifeStrict.ts, 28, 29)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 28, 42)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 28, 42)) + +// missing arguments +(function(x, undefined) { return x; })(42); +>x : Symbol(x, Decl(contextuallyTypedIifeStrict.ts, 30, 10)) +>undefined : Symbol(undefined, Decl(contextuallyTypedIifeStrict.ts, 30, 12)) +>x : Symbol(x, Decl(contextuallyTypedIifeStrict.ts, 30, 10)) + +((x, y, z) => 42)(); +>x : Symbol(x, Decl(contextuallyTypedIifeStrict.ts, 31, 2)) +>y : Symbol(y, Decl(contextuallyTypedIifeStrict.ts, 31, 4)) +>z : Symbol(z, Decl(contextuallyTypedIifeStrict.ts, 31, 7)) + diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.types b/tests/baselines/reference/contextuallyTypedIifeStrict.types new file mode 100644 index 00000000000..cbeee53ec2e --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.types @@ -0,0 +1,271 @@ +=== tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts === +// arrow +(jake => { })("build"); +>(jake => { })("build") : void +>(jake => { }) : (jake: string) => void +>jake => { } : (jake: string) => void +>jake : string +>"build" : "build" + +// function expression +(function (cats) { })("lol"); +>(function (cats) { })("lol") : void +>(function (cats) { }) : (cats: string) => void +>function (cats) { } : (cats: string) => void +>cats : string +>"lol" : "lol" + +// Lots of Irritating Superfluous Parentheses +(function (x) { } ("!")); +>(function (x) { } ("!")) : void +>function (x) { } ("!") : void +>function (x) { } : (x: string) => void +>x : string +>"!" : "!" + +((((function (y) { }))))("-"); +>((((function (y) { }))))("-") : void +>((((function (y) { })))) : (y: string) => void +>(((function (y) { }))) : (y: string) => void +>((function (y) { })) : (y: string) => void +>(function (y) { }) : (y: string) => void +>function (y) { } : (y: string) => void +>y : string +>"-" : "-" + +// multiple arguments +((a, b, c) => { })("foo", 101, false); +>((a, b, c) => { })("foo", 101, false) : void +>((a, b, c) => { }) : (a: string, b: number, c: boolean) => void +>(a, b, c) => { } : (a: string, b: number, c: boolean) => void +>a : string +>b : number +>c : boolean +>"foo" : "foo" +>101 : 101 +>false : false + +// default parameters +((m = 10) => m + 1)(12); +>((m = 10) => m + 1)(12) : number +>((m = 10) => m + 1) : (m?: number) => number +>(m = 10) => m + 1 : (m?: number) => number +>m : number +>10 : 10 +>m + 1 : number +>m : number +>1 : 1 +>12 : 12 + +((n = 10) => n + 1)(); +>((n = 10) => n + 1)() : number +>((n = 10) => n + 1) : (n?: number) => number +>(n = 10) => n + 1 : (n?: number) => number +>n : number +>10 : 10 +>n + 1 : number +>n : number +>1 : 1 + +// optional parameters +((j?) => j + 1)(12); +>((j?) => j + 1)(12) : number +>((j?) => j + 1) : (j?: number | undefined) => number +>(j?) => j + 1 : (j?: number | undefined) => number +>j : number | undefined +>j + 1 : number +>j : number | undefined +>1 : 1 +>12 : 12 + +((k?) => k + 1)(); +>((k?) => k + 1)() : number +>((k?) => k + 1) : (k?: undefined) => number +>(k?) => k + 1 : (k?: undefined) => number +>k : undefined +>k + 1 : number +>k : undefined +>1 : 1 + +((l, o?) => l + o)(12); // o should be any +>((l, o?) => l + o)(12) : number +>((l, o?) => l + o) : (l: number, o?: undefined) => number +>(l, o?) => l + o : (l: number, o?: undefined) => number +>l : number +>o : undefined +>l + o : number +>l : number +>o : undefined +>12 : 12 + +// rest parameters +((...numbers) => numbers.every(n => n > 0))(5,6,7); +>((...numbers) => numbers.every(n => n > 0))(5,6,7) : boolean +>((...numbers) => numbers.every(n => n > 0)) : (...numbers: number[]) => boolean +>(...numbers) => numbers.every(n => n > 0) : (...numbers: number[]) => boolean +>numbers : number[] +>numbers.every(n => n > 0) : boolean +>numbers.every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>numbers : number[] +>every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>n => n > 0 : (n: number) => boolean +>n : number +>n > 0 : boolean +>n : number +>0 : 0 +>5 : 5 +>6 : 6 +>7 : 7 + +((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); +>((...mixed) => mixed.every(n => !!n))(5,'oops','oh no') : boolean +>((...mixed) => mixed.every(n => !!n)) : (...mixed: (string | number)[]) => boolean +>(...mixed) => mixed.every(n => !!n) : (...mixed: (string | number)[]) => boolean +>mixed : (string | number)[] +>mixed.every(n => !!n) : boolean +>mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>mixed : (string | number)[] +>every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>n => !!n : (n: string | number) => boolean +>n : string | number +>!!n : boolean +>!n : boolean +>n : string | number +>5 : 5 +>'oops' : "oops" +>'oh no' : "oh no" + +((...noNumbers) => noNumbers.some(n => n > 0))(); +>((...noNumbers) => noNumbers.some(n => n > 0))() : boolean +>((...noNumbers) => noNumbers.some(n => n > 0)) : (...noNumbers: any[]) => boolean +>(...noNumbers) => noNumbers.some(n => n > 0) : (...noNumbers: any[]) => boolean +>noNumbers : any[] +>noNumbers.some(n => n > 0) : boolean +>noNumbers.some : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean +>noNumbers : any[] +>some : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean +>n => n > 0 : (n: any) => boolean +>n : any +>n > 0 : boolean +>n : any +>0 : 0 + +((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); +>((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10) : boolean[] +>((first, ...rest) => first ? [] : rest.map(n => n > 0)) : (first: number, ...rest: number[]) => boolean[] +>(first, ...rest) => first ? [] : rest.map(n => n > 0) : (first: number, ...rest: number[]) => boolean[] +>first : number +>rest : number[] +>first ? [] : rest.map(n => n > 0) : boolean[] +>first : number +>[] : never[] +>rest.map(n => n > 0) : boolean[] +>rest.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>rest : number[] +>map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>n => n > 0 : (n: number) => boolean +>n : number +>n > 0 : boolean +>n : number +>0 : 0 +>8 : 8 +>9 : 9 +>10 : 10 + +// destructuring parameters (with defaults too!) +(({ q }) => q)({ q : 13 }); +>(({ q }) => q)({ q : 13 }) : number +>(({ q }) => q) : ({q}: { q: number; }) => number +>({ q }) => q : ({q}: { q: number; }) => number +>q : number +>q : number +>{ q : 13 } : { q: number; } +>q : number +>13 : 13 + +(({ p = 14 }) => p)({ p : 15 }); +>(({ p = 14 }) => p)({ p : 15 }) : number +>(({ p = 14 }) => p) : ({p}: { p: number; }) => number +>({ p = 14 }) => p : ({p}: { p: number; }) => number +>p : number +>14 : 14 +>p : number +>{ p : 15 } : { p: number; } +>p : number +>15 : 15 + +(({ r = 17 } = { r: 18 }) => r)({r : 19}); +>(({ r = 17 } = { r: 18 }) => r)({r : 19}) : number +>(({ r = 17 } = { r: 18 }) => r) : ({r}?: { r: number; }) => number +>({ r = 17 } = { r: 18 }) => r : ({r}?: { r: number; }) => number +>r : number +>17 : 17 +>{ r: 18 } : { r: number; } +>r : number +>18 : 18 +>r : number +>{r : 19} : { r: number; } +>r : number +>19 : 19 + +(({ u = 22 } = { u: 23 }) => u)(); +>(({ u = 22 } = { u: 23 }) => u)() : number +>(({ u = 22 } = { u: 23 }) => u) : ({u}?: { u?: number; }) => number +>({ u = 22 } = { u: 23 }) => u : ({u}?: { u?: number; }) => number +>u : number +>22 : 22 +>{ u: 23 } : { u?: number; } +>u : number +>23 : 23 +>u : number + +// contextually typed parameters. +let twelve = (f => f(12))(i => i); +>twelve : any +>(f => f(12))(i => i) : any +>(f => f(12)) : (f: (i: any) => any) => any +>f => f(12) : (f: (i: any) => any) => any +>f : (i: any) => any +>f(12) : any +>f : (i: any) => any +>12 : 12 +>i => i : (i: any) => any +>i : any +>i : any + +let eleven = (o => o.a(11))({ a: function(n) { return n; } }); +>eleven : any +>(o => o.a(11))({ a: function(n) { return n; } }) : any +>(o => o.a(11)) : (o: { a: (n: any) => any; }) => any +>o => o.a(11) : (o: { a: (n: any) => any; }) => any +>o : { a: (n: any) => any; } +>o.a(11) : any +>o.a : (n: any) => any +>o : { a: (n: any) => any; } +>a : (n: any) => any +>11 : 11 +>{ a: function(n) { return n; } } : { a: (n: any) => any; } +>a : (n: any) => any +>function(n) { return n; } : (n: any) => any +>n : any +>n : any + +// missing arguments +(function(x, undefined) { return x; })(42); +>(function(x, undefined) { return x; })(42) : number +>(function(x, undefined) { return x; }) : (x: number, undefined: undefined) => number +>function(x, undefined) { return x; } : (x: number, undefined: undefined) => number +>x : number +>undefined : undefined +>x : number +>42 : 42 + +((x, y, z) => 42)(); +>((x, y, z) => 42)() : number +>((x, y, z) => 42) : (x: undefined, y: undefined, z: undefined) => number +>(x, y, z) => 42 : (x: undefined, y: undefined, z: undefined) => number +>x : undefined +>y : undefined +>z : undefined +>42 : 42 + diff --git a/tests/baselines/reference/controlFlowDeleteOperator.errors.txt b/tests/baselines/reference/controlFlowDeleteOperator.errors.txt new file mode 100644 index 00000000000..de84d602c95 --- /dev/null +++ b/tests/baselines/reference/controlFlowDeleteOperator.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(15,12): error TS2703: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts (1 errors) ==== + + function f() { + let x: { a?: number | string, b: number | string } = { b: 1 }; + x.a; + x.b; + x.a = 1; + x.b = 1; + x.a; + x.b; + delete x.a; + delete x.b; + x.a; + x.b; + x; + delete x; // No effect + ~ +!!! error TS2703: The operand of a delete operator must be a property reference + x; + } \ No newline at end of file diff --git a/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.js b/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.js index 89979da4812..725409c2c7f 100644 --- a/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.js +++ b/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.js @@ -11,11 +11,16 @@ var a: D = foo("hi", []); //// [crashInsourcePropertyIsRelatableToTargetProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { this.x = 1; @@ -25,7 +30,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/declFileClassExtendsNull.js b/tests/baselines/reference/declFileClassExtendsNull.js index 30ddc3f08bf..a7ea02011fe 100644 --- a/tests/baselines/reference/declFileClassExtendsNull.js +++ b/tests/baselines/reference/declFileClassExtendsNull.js @@ -4,15 +4,19 @@ class ExtendsNull extends null { } //// [declFileClassExtendsNull.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ExtendsNull = (function (_super) { __extends(ExtendsNull, _super); function ExtendsNull() { - return _super.apply(this, arguments) || this; } return ExtendsNull; }(null)); diff --git a/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.js b/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.js index 442007d9b9a..9bdd0fc09a7 100644 --- a/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.js +++ b/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.js @@ -10,11 +10,16 @@ interface I extends X<() => number> { //// [declFileForFunctionTypeAsTypeParameter.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var X = (function () { function X() { } @@ -23,7 +28,7 @@ var X = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(X)); diff --git a/tests/baselines/reference/declFileGenericClassWithGenericExtendedClass.js b/tests/baselines/reference/declFileGenericClassWithGenericExtendedClass.js index 47593dc9d68..58d7bb774f1 100644 --- a/tests/baselines/reference/declFileGenericClassWithGenericExtendedClass.js +++ b/tests/baselines/reference/declFileGenericClassWithGenericExtendedClass.js @@ -13,11 +13,16 @@ class Baz implements IBar { //// [declFileGenericClassWithGenericExtendedClass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -26,7 +31,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/declFileGenericType.js b/tests/baselines/reference/declFileGenericType.js index b2e99a73ad7..c17463a6d15 100644 --- a/tests/baselines/reference/declFileGenericType.js +++ b/tests/baselines/reference/declFileGenericType.js @@ -41,11 +41,16 @@ export var j = C.F6; //// [declFileGenericType.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C; (function (C) { var A = (function () { @@ -91,7 +96,7 @@ exports.g = C.F5(); var h = (function (_super) { __extends(h, _super); function h() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return h; }(C.A)); diff --git a/tests/baselines/reference/declFileGenericType2.js b/tests/baselines/reference/declFileGenericType2.js index 720be79b28d..1c6f2002da2 100644 --- a/tests/baselines/reference/declFileGenericType2.js +++ b/tests/baselines/reference/declFileGenericType2.js @@ -43,11 +43,16 @@ module templa.dom.mvc.composite { //// [declFileGenericType2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // Module var templa; (function (templa) { diff --git a/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.js b/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.js index 17d885788dd..da1ebb2a8f3 100644 --- a/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.js +++ b/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.js @@ -21,11 +21,16 @@ module X.Y.base.Z { //// [declFileWithClassNameConflictingWithClassReferredByExtendsClause.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var X; (function (X) { var Y; @@ -35,7 +40,7 @@ var X; var W = (function (_super) { __extends(W, _super); function W() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return W; }(A.B.Base.W)); @@ -53,7 +58,7 @@ var X; var W = (function (_super) { __extends(W, _super); function W() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return W; }(X.Y.base.W)); diff --git a/tests/baselines/reference/declFileWithExtendsClauseThatHasItsContainerNameConflict.js b/tests/baselines/reference/declFileWithExtendsClauseThatHasItsContainerNameConflict.js index 70d0cd5a3dd..d369da3902b 100644 --- a/tests/baselines/reference/declFileWithExtendsClauseThatHasItsContainerNameConflict.js +++ b/tests/baselines/reference/declFileWithExtendsClauseThatHasItsContainerNameConflict.js @@ -19,11 +19,16 @@ module A.B.C { } //// [declFileWithExtendsClauseThatHasItsContainerNameConflict.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A; (function (A) { var B; @@ -44,7 +49,7 @@ var A; var ContextMenu = (function (_super) { __extends(ContextMenu, _super); function ContextMenu() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ContextMenu; }(B.EventManager)); diff --git a/tests/baselines/reference/declarationEmitExpressionInExtends.js b/tests/baselines/reference/declarationEmitExpressionInExtends.js index 726c7b22446..884897a9cf6 100644 --- a/tests/baselines/reference/declarationEmitExpressionInExtends.js +++ b/tests/baselines/reference/declarationEmitExpressionInExtends.js @@ -15,11 +15,16 @@ var q: B; q.s; //// [declarationEmitExpressionInExtends.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x; var Q = (function () { function Q() { @@ -29,7 +34,7 @@ var Q = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(x)); diff --git a/tests/baselines/reference/declarationEmitExpressionInExtends2.js b/tests/baselines/reference/declarationEmitExpressionInExtends2.js index 4081de6d3ed..86c79dda8a8 100644 --- a/tests/baselines/reference/declarationEmitExpressionInExtends2.js +++ b/tests/baselines/reference/declarationEmitExpressionInExtends2.js @@ -13,11 +13,16 @@ class MyClass extends getClass(2) { } //// [declarationEmitExpressionInExtends2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -29,7 +34,7 @@ function getClass(c) { var MyClass = (function (_super) { __extends(MyClass, _super); function MyClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return MyClass; }(getClass(2))); diff --git a/tests/baselines/reference/declarationEmitExpressionInExtends3.js b/tests/baselines/reference/declarationEmitExpressionInExtends3.js index f36a7e250a2..960a7af6780 100644 --- a/tests/baselines/reference/declarationEmitExpressionInExtends3.js +++ b/tests/baselines/reference/declarationEmitExpressionInExtends3.js @@ -45,11 +45,16 @@ export class MyClass4 extends getExportedClass(undefined)= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { "use strict"; var decorator; let Foo = class Foo { @@ -45,14 +46,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { "use strict"; var decorator; let default_1 = class { diff --git a/tests/baselines/reference/decoratorOnClassConstructor2.js b/tests/baselines/reference/decoratorOnClassConstructor2.js index ce323e8ed1e..dd6209b6d64 100644 --- a/tests/baselines/reference/decoratorOnClassConstructor2.js +++ b/tests/baselines/reference/decoratorOnClassConstructor2.js @@ -26,11 +26,16 @@ function foo(target, propertyKey, parameterIndex) { } exports.foo = foo; //// [2.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); diff --git a/tests/baselines/reference/decoratorOnClassConstructor3.js b/tests/baselines/reference/decoratorOnClassConstructor3.js index f06bf80b21d..a1a3e331f36 100644 --- a/tests/baselines/reference/decoratorOnClassConstructor3.js +++ b/tests/baselines/reference/decoratorOnClassConstructor3.js @@ -28,11 +28,16 @@ function foo(target, propertyKey, parameterIndex) { } exports.foo = foo; //// [2.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); diff --git a/tests/baselines/reference/decoratorOnClassConstructor4.js b/tests/baselines/reference/decoratorOnClassConstructor4.js index 22414e89e43..75286943417 100644 --- a/tests/baselines/reference/decoratorOnClassConstructor4.js +++ b/tests/baselines/reference/decoratorOnClassConstructor4.js @@ -15,11 +15,16 @@ class C extends A { } //// [decoratorOnClassConstructor4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); @@ -49,7 +54,7 @@ B = __decorate([ var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/decoratorOnClassMethod12.js b/tests/baselines/reference/decoratorOnClassMethod12.js index 7dd5f698182..c9ff30307f0 100644 --- a/tests/baselines/reference/decoratorOnClassMethod12.js +++ b/tests/baselines/reference/decoratorOnClassMethod12.js @@ -10,11 +10,16 @@ module M { } //// [decoratorOnClassMethod12.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); @@ -32,7 +37,7 @@ var M; var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.method = function () { }; return C; diff --git a/tests/baselines/reference/decrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt b/tests/baselines/reference/decrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt index e42b6ff67b4..33e31bc9478 100644 --- a/tests/baselines/reference/decrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt +++ b/tests/baselines/reference/decrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt @@ -9,29 +9,37 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(33,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(34,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(37,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(39,26): error TS2539: Cannot assign to 'undefined' because it is not a variable. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(42,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(43,24): error TS2539: Cannot assign to 'undefined' because it is not a variable. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(46,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(47,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,34): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,34): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,39): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(51,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(52,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(54,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(55,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,32): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,32): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,37): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(59,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(60,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(63,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -50,7 +58,7 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(72,12): error TS1109: Expression expected. -==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts (50 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts (58 errors) ==== // -- operator on any type var ANY1: any; var ANY2: any[] = ["", ""]; @@ -112,14 +120,18 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. var ResultIsNumber12 = --null; ~~~~ -!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber13 = --undefined; ~~~~~~~~~ !!! error TS2539: Cannot assign to 'undefined' because it is not a variable. var ResultIsNumber14 = null--; ~~~~ -!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber15 = {}--; ~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -137,18 +149,24 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp var ResultIsNumber19 = --(null + undefined); ~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber20 = --(null + null); ~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber21 = --(undefined + undefined); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber22 = --obj1.x; ~~~~~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -165,18 +183,24 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp var ResultIsNumber26 = (null + undefined)--; ~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber27 = (null + null)--; ~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber28 = (undefined + undefined)--; ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber29 = obj1.x--; ~~~~~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. diff --git a/tests/baselines/reference/defaultExportInAwaitExpression01.js b/tests/baselines/reference/defaultExportInAwaitExpression01.js index 9a122ae99c5..66d100ad07d 100644 --- a/tests/baselines/reference/defaultExportInAwaitExpression01.js +++ b/tests/baselines/reference/defaultExportInAwaitExpression01.js @@ -13,14 +13,15 @@ import x from './a'; //// [a.js] -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { "use strict"; const x = new Promise((resolve, reject) => { resolve({}); }); Object.defineProperty(exports, "__esModule", { value: true }); @@ -35,14 +36,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports", "./a"], factory); } -})(["require", "exports", "./a"], function (require, exports) { +})(function (require, exports) { "use strict"; const a_1 = require("./a"); (function () { diff --git a/tests/baselines/reference/defaultExportsGetExportedUmd.js b/tests/baselines/reference/defaultExportsGetExportedUmd.js index 79d88222806..71aa347ce32 100644 --- a/tests/baselines/reference/defaultExportsGetExportedUmd.js +++ b/tests/baselines/reference/defaultExportsGetExportedUmd.js @@ -8,14 +8,15 @@ export default function foo() {} //// [a.js] -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { "use strict"; class Foo { } @@ -23,14 +24,15 @@ export default function foo() {} exports.default = Foo; }); //// [b.js] -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { "use strict"; function foo() { } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/deleteOperator1.errors.txt b/tests/baselines/reference/deleteOperator1.errors.txt index 964bdec9ea2..09a839d10b4 100644 --- a/tests/baselines/reference/deleteOperator1.errors.txt +++ b/tests/baselines/reference/deleteOperator1.errors.txt @@ -1,10 +1,19 @@ +tests/cases/compiler/deleteOperator1.ts(2,25): error TS2703: The operand of a delete operator must be a property reference +tests/cases/compiler/deleteOperator1.ts(3,21): error TS2703: The operand of a delete operator must be a property reference tests/cases/compiler/deleteOperator1.ts(4,5): error TS2322: Type 'boolean' is not assignable to type 'number'. +tests/cases/compiler/deleteOperator1.ts(4,24): error TS2703: The operand of a delete operator must be a property reference -==== tests/cases/compiler/deleteOperator1.ts (1 errors) ==== +==== tests/cases/compiler/deleteOperator1.ts (4 errors) ==== var a; var x: boolean = delete a; + ~ +!!! error TS2703: The operand of a delete operator must be a property reference var y: any = delete a; + ~ +!!! error TS2703: The operand of a delete operator must be a property reference var z: number = delete a; ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'number'. \ No newline at end of file +!!! error TS2322: Type 'boolean' is not assignable to type 'number'. + ~ +!!! error TS2703: The operand of a delete operator must be a property reference \ No newline at end of file diff --git a/tests/baselines/reference/deleteOperatorInStrictMode.errors.txt b/tests/baselines/reference/deleteOperatorInStrictMode.errors.txt index 5952d8b8296..16d3b772351 100644 --- a/tests/baselines/reference/deleteOperatorInStrictMode.errors.txt +++ b/tests/baselines/reference/deleteOperatorInStrictMode.errors.txt @@ -1,9 +1,12 @@ tests/cases/compiler/deleteOperatorInStrictMode.ts(3,8): error TS1102: 'delete' cannot be called on an identifier in strict mode. +tests/cases/compiler/deleteOperatorInStrictMode.ts(3,8): error TS2703: The operand of a delete operator must be a property reference -==== tests/cases/compiler/deleteOperatorInStrictMode.ts (1 errors) ==== +==== tests/cases/compiler/deleteOperatorInStrictMode.ts (2 errors) ==== "use strict" var a; delete a; ~ -!!! error TS1102: 'delete' cannot be called on an identifier in strict mode. \ No newline at end of file +!!! error TS1102: 'delete' cannot be called on an identifier in strict mode. + ~ +!!! error TS2703: The operand of a delete operator must be a property reference \ No newline at end of file diff --git a/tests/baselines/reference/deleteOperatorInvalidOperations.errors.txt b/tests/baselines/reference/deleteOperatorInvalidOperations.errors.txt index d50be713d0a..3e581f5a77b 100644 --- a/tests/baselines/reference/deleteOperatorInvalidOperations.errors.txt +++ b/tests/baselines/reference/deleteOperatorInvalidOperations.errors.txt @@ -1,10 +1,13 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(5,20): error TS1005: ',' expected. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(5,26): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(5,27): error TS1109: Expression expected. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(8,22): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(8,23): error TS1109: Expression expected. tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(13,16): error TS1102: 'delete' cannot be called on an identifier in strict mode. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(13,16): error TS2703: The operand of a delete operator must be a property reference -==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts (4 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts (7 errors) ==== // Unary operator delete var ANY; @@ -12,11 +15,15 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator var BOOLEAN1 = ANY delete ; //expect error ~~~~~~ !!! error TS1005: ',' expected. + +!!! error TS2703: The operand of a delete operator must be a property reference ~ !!! error TS1109: Expression expected. // miss an operand var BOOLEAN2 = delete ; + +!!! error TS2703: The operand of a delete operator must be a property reference ~ !!! error TS1109: Expression expected. @@ -26,5 +33,7 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator delete s; //expect error ~ !!! error TS1102: 'delete' cannot be called on an identifier in strict mode. + ~ +!!! error TS2703: The operand of a delete operator must be a property reference } } \ No newline at end of file diff --git a/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt index 73ddab1a33c..819f1c39050 100644 --- a/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt @@ -1,9 +1,34 @@ -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(25,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(26,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(27,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(28,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(29,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(30,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(33,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(34,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(42,32): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(43,32): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(44,33): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,40): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,40): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,45): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(50,32): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(50,39): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,32): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,39): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,47): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(54,8): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(55,8): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(57,8): error TS2703: The operand of a delete operator must be a property reference -==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts (3 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts (28 errors) ==== // delete operator on any type var ANY: any; @@ -29,15 +54,31 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator // any type var var ResultIsBoolean1 = delete ANY1; + ~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference var ResultIsBoolean2 = delete ANY2; + ~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference var ResultIsBoolean3 = delete A; + ~ +!!! error TS2703: The operand of a delete operator must be a property reference var ResultIsBoolean4 = delete M; + ~ +!!! error TS2703: The operand of a delete operator must be a property reference var ResultIsBoolean5 = delete obj; + ~~~ +!!! error TS2703: The operand of a delete operator must be a property reference var ResultIsBoolean6 = delete obj1; + ~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference // any type literal var ResultIsBoolean7 = delete undefined; + ~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference var ResultIsBoolean8 = delete null; + ~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference // any type expressions var ResultIsBoolean9 = delete ANY2[0]; @@ -46,27 +87,61 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator var ResultIsBoolean12 = delete objA.a; var ResultIsBoolean13 = delete M.n; var ResultIsBoolean14 = delete foo(); + ~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference var ResultIsBoolean15 = delete A.foo(); + ~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference var ResultIsBoolean16 = delete (ANY + ANY1); + ~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference var ResultIsBoolean17 = delete (null + undefined); + ~~~~ +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +!!! error TS2703: The operand of a delete operator must be a property reference + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsBoolean18 = delete (null + null); + ~~~~ +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. +!!! error TS2703: The operand of a delete operator must be a property reference + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsBoolean19 = delete (undefined + undefined); + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +!!! error TS2703: The operand of a delete operator must be a property reference + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // multiple delete operators var ResultIsBoolean20 = delete delete ANY; + ~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + ~~~ +!!! error TS2703: The operand of a delete operator must be a property reference var ResultIsBoolean21 = delete delete delete (ANY + ANY1); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + ~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference // miss assignment operators delete ANY; + ~~~ +!!! error TS2703: The operand of a delete operator must be a property reference delete ANY1; + ~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference delete ANY2[0]; delete ANY, ANY1; + ~~~ +!!! error TS2703: The operand of a delete operator must be a property reference delete obj1.x; delete obj1.y; delete objA.a; diff --git a/tests/baselines/reference/deleteOperatorWithBooleanType.errors.txt b/tests/baselines/reference/deleteOperatorWithBooleanType.errors.txt new file mode 100644 index 00000000000..83ce7db9f33 --- /dev/null +++ b/tests/baselines/reference/deleteOperatorWithBooleanType.errors.txt @@ -0,0 +1,74 @@ +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(17,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(20,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(21,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(26,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(27,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(30,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(30,38): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(33,8): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(34,8): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(35,8): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(36,8): error TS2703: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts (11 errors) ==== + // delete operator on boolean type + var BOOLEAN: boolean; + + function foo(): boolean { return true; } + + class A { + public a: boolean; + static foo() { return false; } + } + module M { + export var n: boolean; + } + + var objA = new A(); + + // boolean type var + var ResultIsBoolean1 = delete BOOLEAN; + ~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + + // boolean type literal + var ResultIsBoolean2 = delete true; + ~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + var ResultIsBoolean3 = delete { x: true, y: false }; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + + // boolean type expressions + var ResultIsBoolean4 = delete objA.a; + var ResultIsBoolean5 = delete M.n; + var ResultIsBoolean6 = delete foo(); + ~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + var ResultIsBoolean7 = delete A.foo(); + ~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + + // multiple delete operator + var ResultIsBoolean8 = delete delete BOOLEAN; + ~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + ~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + + // miss assignment operators + delete true; + ~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + delete BOOLEAN; + ~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + delete foo(); + ~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + delete true, false; + ~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + delete objA.a; + delete M.n; \ No newline at end of file diff --git a/tests/baselines/reference/deleteOperatorWithEnumType.errors.txt b/tests/baselines/reference/deleteOperatorWithEnumType.errors.txt new file mode 100644 index 00000000000..84c1ed48017 --- /dev/null +++ b/tests/baselines/reference/deleteOperatorWithEnumType.errors.txt @@ -0,0 +1,64 @@ +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(7,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(8,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(11,31): error TS2704: The operand of a delete operator cannot be a read-only property +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(12,32): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(15,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(15,38): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(16,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(16,38): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(16,46): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(19,8): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(20,8): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(21,8): error TS2704: The operand of a delete operator cannot be a read-only property +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(22,8): error TS2703: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts (13 errors) ==== + // delete operator on enum type + + enum ENUM { }; + enum ENUM1 { A, B, "" }; + + // enum type var + var ResultIsBoolean1 = delete ENUM; + ~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + var ResultIsBoolean2 = delete ENUM1; + ~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + + // enum type expressions + var ResultIsBoolean3 = delete ENUM1["A"]; + ~~~~~~~~~~ +!!! error TS2704: The operand of a delete operator cannot be a read-only property + var ResultIsBoolean4 = delete (ENUM[0] + ENUM1["B"]); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + + // multiple delete operators + var ResultIsBoolean5 = delete delete ENUM; + ~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + ~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + var ResultIsBoolean6 = delete delete delete (ENUM[0] + ENUM1["B"]); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + + // miss assignment operators + delete ENUM; + ~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + delete ENUM1; + ~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + delete ENUM1.B; + ~~~~~~~ +!!! error TS2704: The operand of a delete operator cannot be a read-only property + delete ENUM, ENUM1; + ~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference \ No newline at end of file diff --git a/tests/baselines/reference/deleteOperatorWithNumberType.errors.txt b/tests/baselines/reference/deleteOperatorWithNumberType.errors.txt new file mode 100644 index 00000000000..b43c7aa8e3d --- /dev/null +++ b/tests/baselines/reference/deleteOperatorWithNumberType.errors.txt @@ -0,0 +1,99 @@ +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(18,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(19,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(22,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(23,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(24,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(30,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(31,32): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(32,33): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(35,32): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(35,39): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(36,32): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(36,39): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(36,47): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(39,8): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(40,8): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(41,8): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(42,8): error TS2703: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts (17 errors) ==== + // delete operator on number type + var NUMBER: number; + var NUMBER1: number[] = [1, 2]; + + function foo(): number { return 1; } + + class A { + public a: number; + static foo() { return 1; } + } + module M { + export var n: number; + } + + var objA = new A(); + + // number type var + var ResultIsBoolean1 = delete NUMBER; + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + var ResultIsBoolean2 = delete NUMBER1; + ~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + + // number type literal + var ResultIsBoolean3 = delete 1; + ~ +!!! error TS2703: The operand of a delete operator must be a property reference + var ResultIsBoolean4 = delete { x: 1, y: 2}; + ~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + var ResultIsBoolean5 = delete { x: 1, y: (n: number) => { return n; } }; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + + // number type expressions + var ResultIsBoolean6 = delete objA.a; + var ResultIsBoolean7 = delete M.n; + var ResultIsBoolean8 = delete NUMBER1[0]; + var ResultIsBoolean9 = delete foo(); + ~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + var ResultIsBoolean10 = delete A.foo(); + ~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + var ResultIsBoolean11 = delete (NUMBER + NUMBER); + ~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + + // multiple delete operator + var ResultIsBoolean12 = delete delete NUMBER; + ~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + var ResultIsBoolean13 = delete delete delete (NUMBER + NUMBER); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + ~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + + // miss assignment operators + delete 1; + ~ +!!! error TS2703: The operand of a delete operator must be a property reference + delete NUMBER; + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + delete NUMBER1; + ~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + delete foo(); + ~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + delete objA.a; + delete M.n; + delete objA.a, M.n; \ No newline at end of file diff --git a/tests/baselines/reference/deleteOperatorWithStringType.errors.txt b/tests/baselines/reference/deleteOperatorWithStringType.errors.txt new file mode 100644 index 00000000000..37859d3ab24 --- /dev/null +++ b/tests/baselines/reference/deleteOperatorWithStringType.errors.txt @@ -0,0 +1,101 @@ +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(18,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(19,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(22,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(23,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(24,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(30,31): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(31,32): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(32,33): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(33,32): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(36,32): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(36,39): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(37,32): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(37,39): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(37,47): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(40,8): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(41,8): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(42,8): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(43,8): error TS2703: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts (18 errors) ==== + // delete operator on string type + var STRING: string; + var STRING1: string[] = ["", "abc"]; + + function foo(): string { return "abc"; } + + class A { + public a: string; + static foo() { return ""; } + } + module M { + export var n: string; + } + + var objA = new A(); + + // string type var + var ResultIsBoolean1 = delete STRING; + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + var ResultIsBoolean2 = delete STRING1; + ~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + + // string type literal + var ResultIsBoolean3 = delete ""; + ~~ +!!! error TS2703: The operand of a delete operator must be a property reference + var ResultIsBoolean4 = delete { x: "", y: "" }; + ~~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + var ResultIsBoolean5 = delete { x: "", y: (s: string) => { return s; } }; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + + // string type expressions + var ResultIsBoolean6 = delete objA.a; + var ResultIsBoolean7 = delete M.n; + var ResultIsBoolean8 = delete STRING1[0]; + var ResultIsBoolean9 = delete foo(); + ~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + var ResultIsBoolean10 = delete A.foo(); + ~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + var ResultIsBoolean11 = delete (STRING + STRING); + ~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + var ResultIsBoolean12 = delete STRING.charAt(0); + ~~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + + // multiple delete operator + var ResultIsBoolean13 = delete delete STRING; + ~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + var ResultIsBoolean14 = delete delete delete (STRING + STRING); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + ~~~~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + + // miss assignment operators + delete ""; + ~~ +!!! error TS2703: The operand of a delete operator must be a property reference + delete STRING; + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + delete STRING1; + ~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + delete foo(); + ~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + delete objA.a,M.n; \ No newline at end of file diff --git a/tests/baselines/reference/deleteReadonly.errors.txt b/tests/baselines/reference/deleteReadonly.errors.txt new file mode 100644 index 00000000000..4e5a3275b80 --- /dev/null +++ b/tests/baselines/reference/deleteReadonly.errors.txt @@ -0,0 +1,33 @@ +tests/cases/compiler/deleteReadonly.ts(8,8): error TS2704: The operand of a delete operator cannot be a read-only property +tests/cases/compiler/deleteReadonly.ts(18,8): error TS2542: Index signature in type 'B' only permits reading. +tests/cases/compiler/deleteReadonly.ts(20,12): error TS2542: Index signature in type 'B' only permits reading. + + +==== tests/cases/compiler/deleteReadonly.ts (3 errors) ==== + interface A { + readonly b + } + var a: A = { + b: 123 + }; + + delete a.b; + ~~~ +!!! error TS2704: The operand of a delete operator cannot be a read-only property + + interface B { + readonly [k: string]: string + } + + var b: B = { + 'test': 'test' + }; + + delete b['test']; + ~~~~~~~~~ +!!! error TS2542: Index signature in type 'B' only permits reading. + + delete ((((b['test'])))); + ~~~~~~~~~ +!!! error TS2542: Index signature in type 'B' only permits reading. + \ No newline at end of file diff --git a/tests/baselines/reference/deleteReadonly.js b/tests/baselines/reference/deleteReadonly.js new file mode 100644 index 00000000000..bdfdf155546 --- /dev/null +++ b/tests/baselines/reference/deleteReadonly.js @@ -0,0 +1,33 @@ +//// [deleteReadonly.ts] +interface A { + readonly b +} +var a: A = { + b: 123 +}; + +delete a.b; + +interface B { + readonly [k: string]: string +} + +var b: B = { + 'test': 'test' +}; + +delete b['test']; + +delete ((((b['test'])))); + + +//// [deleteReadonly.js] +var a = { + b: 123 +}; +delete a.b; +var b = { + 'test': 'test' +}; +delete b['test']; +delete ((((b['test'])))); diff --git a/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.js b/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.js index 4ab447d8e32..a1e9399c563 100644 --- a/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.js +++ b/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.js @@ -35,11 +35,16 @@ class D extends C { } //// [derivedClassConstructorWithExplicitReturns01.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C(value) { this.cProp = 10; diff --git a/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.js.map b/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.js.map index 8b9037e40c9..f2acf9427cf 100644 --- a/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.js.map +++ b/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.js.map @@ -1,2 +1,2 @@ //// [derivedClassConstructorWithExplicitReturns01.js.map] -{"version":3,"file":"derivedClassConstructorWithExplicitReturns01.js","sourceRoot":"","sources":["derivedClassConstructorWithExplicitReturns01.ts"],"names":[],"mappings":";;;;;AACA;IAKI,WAAY,KAAa;QAJzB,UAAK,GAAG,EAAE,CAAC;QAKP,MAAM,CAAC;YACH,KAAK,EAAE,KAAK;YACZ,GAAG;gBACC,MAAM,CAAC,8BAA8B,CAAC;YAC1C,CAAC;SACJ,CAAA;IACL,CAAC;IATD,eAAG,GAAH,cAAQ,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC;IAU7C,QAAC;AAAD,CAAC,AAbD,IAaC;AAED;IAAgB,qBAAC;IAGb,WAAY,CAAO;QAAP,kBAAA,EAAA,OAAO;QAAnB,YACI,kBAAM,CAAC,CAAC,SAYX;QAfD,WAAK,GAAG,cAAM,OAAA,KAAI,EAAJ,CAAI,CAAC;QAKf,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;YACtB,UAAU,CAAA;YACV,MAAM,CAAC;gBACH,KAAK,EAAE,CAAC;gBACR,KAAK,EAAE,cAAM,OAAA,KAAI,EAAJ,CAAI;gBACjB,GAAG,gBAAK,MAAM,CAAC,cAAc,CAAA,CAAC,CAAC;aAClC,CAAC;QACN,CAAC;QACD,IAAI;YACA,MAAM,CAAC,IAAI,CAAC;IACpB,CAAC;IACL,QAAC;AAAD,CAAC,AAjBD,CAAgB,CAAC,GAiBhB"} \ No newline at end of file +{"version":3,"file":"derivedClassConstructorWithExplicitReturns01.js","sourceRoot":"","sources":["derivedClassConstructorWithExplicitReturns01.ts"],"names":[],"mappings":";;;;;;;;;;AACA;IAKI,WAAY,KAAa;QAJzB,UAAK,GAAG,EAAE,CAAC;QAKP,MAAM,CAAC;YACH,KAAK,EAAE,KAAK;YACZ,GAAG;gBACC,MAAM,CAAC,8BAA8B,CAAC;YAC1C,CAAC;SACJ,CAAA;IACL,CAAC;IATD,eAAG,GAAH,cAAQ,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC;IAU7C,QAAC;AAAD,CAAC,AAbD,IAaC;AAED;IAAgB,qBAAC;IAGb,WAAY,CAAO;QAAP,kBAAA,EAAA,OAAO;QAAnB,YACI,kBAAM,CAAC,CAAC,SAYX;QAfD,WAAK,GAAG,cAAM,OAAA,KAAI,EAAJ,CAAI,CAAC;QAKf,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;YACtB,UAAU,CAAA;YACV,MAAM,CAAC;gBACH,KAAK,EAAE,CAAC;gBACR,KAAK,EAAE,cAAM,OAAA,KAAI,EAAJ,CAAI;gBACjB,GAAG,gBAAK,MAAM,CAAC,cAAc,CAAA,CAAC,CAAC;aAClC,CAAC;QACN,CAAC;QACD,IAAI;YACA,MAAM,CAAC,IAAI,CAAC;IACpB,CAAC;IACL,QAAC;AAAD,CAAC,AAjBD,CAAgB,CAAC,GAiBhB"} \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.sourcemap.txt b/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.sourcemap.txt index d452115ceb7..42d415430e2 100644 --- a/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.sourcemap.txt +++ b/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.sourcemap.txt @@ -8,17 +8,22 @@ sources: derivedClassConstructorWithExplicitReturns01.ts emittedFile:tests/cases/compiler/derivedClassConstructorWithExplicitReturns01.js sourceFile:derivedClassConstructorWithExplicitReturns01.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; } ->>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); ->>>}; +>>>var __extends = (this && this.__extends) || (function () { +>>> var extendStatics = Object.setPrototypeOf || +>>> ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || +>>> function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; +>>> return function (d, b) { +>>> extendStatics(d, b); +>>> function __() { this.constructor = d; } +>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +>>> }; +>>>})(); >>>var C = (function () { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(6, 1) Source(2, 1) + SourceIndex(0) +1 >Emitted(11, 1) Source(2, 1) + SourceIndex(0) --- >>> function C(value) { 1->^^^^ @@ -33,9 +38,9 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > 2 > constructor( 3 > value: number -1->Emitted(7, 5) Source(7, 5) + SourceIndex(0) -2 >Emitted(7, 16) Source(7, 17) + SourceIndex(0) -3 >Emitted(7, 21) Source(7, 30) + SourceIndex(0) +1->Emitted(12, 5) Source(7, 5) + SourceIndex(0) +2 >Emitted(12, 16) Source(7, 17) + SourceIndex(0) +3 >Emitted(12, 21) Source(7, 30) + SourceIndex(0) --- >>> this.cProp = 10; 1->^^^^^^^^ @@ -48,11 +53,11 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 3 > = 4 > 10 5 > ; -1->Emitted(8, 9) Source(3, 5) + SourceIndex(0) -2 >Emitted(8, 19) Source(3, 10) + SourceIndex(0) -3 >Emitted(8, 22) Source(3, 13) + SourceIndex(0) -4 >Emitted(8, 24) Source(3, 15) + SourceIndex(0) -5 >Emitted(8, 25) Source(3, 16) + SourceIndex(0) +1->Emitted(13, 9) Source(3, 5) + SourceIndex(0) +2 >Emitted(13, 19) Source(3, 10) + SourceIndex(0) +3 >Emitted(13, 22) Source(3, 13) + SourceIndex(0) +4 >Emitted(13, 24) Source(3, 15) + SourceIndex(0) +5 >Emitted(13, 25) Source(3, 16) + SourceIndex(0) --- >>> return { 1 >^^^^^^^^ @@ -67,9 +72,9 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > 2 > return 3 > -1 >Emitted(9, 9) Source(8, 9) + SourceIndex(0) -2 >Emitted(9, 15) Source(8, 15) + SourceIndex(0) -3 >Emitted(9, 16) Source(8, 16) + SourceIndex(0) +1 >Emitted(14, 9) Source(8, 9) + SourceIndex(0) +2 >Emitted(14, 15) Source(8, 15) + SourceIndex(0) +3 >Emitted(14, 16) Source(8, 16) + SourceIndex(0) --- >>> cProp: value, 1->^^^^^^^^^^^^ @@ -82,10 +87,10 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 2 > cProp 3 > : 4 > value -1->Emitted(10, 13) Source(9, 13) + SourceIndex(0) -2 >Emitted(10, 18) Source(9, 18) + SourceIndex(0) -3 >Emitted(10, 20) Source(9, 20) + SourceIndex(0) -4 >Emitted(10, 25) Source(9, 25) + SourceIndex(0) +1->Emitted(15, 13) Source(9, 13) + SourceIndex(0) +2 >Emitted(15, 18) Source(9, 18) + SourceIndex(0) +3 >Emitted(15, 20) Source(9, 20) + SourceIndex(0) +4 >Emitted(15, 25) Source(9, 25) + SourceIndex(0) --- >>> foo: function () { 1->^^^^^^^^^^^^ @@ -94,8 +99,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1->, > 2 > foo -1->Emitted(11, 13) Source(10, 13) + SourceIndex(0) -2 >Emitted(11, 16) Source(10, 16) + SourceIndex(0) +1->Emitted(16, 13) Source(10, 13) + SourceIndex(0) +2 >Emitted(16, 16) Source(10, 16) + SourceIndex(0) --- >>> return "well this looks kinda C-ish."; 1->^^^^^^^^^^^^^^^^ @@ -109,11 +114,11 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 3 > 4 > "well this looks kinda C-ish." 5 > ; -1->Emitted(12, 17) Source(11, 17) + SourceIndex(0) -2 >Emitted(12, 23) Source(11, 23) + SourceIndex(0) -3 >Emitted(12, 24) Source(11, 24) + SourceIndex(0) -4 >Emitted(12, 54) Source(11, 54) + SourceIndex(0) -5 >Emitted(12, 55) Source(11, 55) + SourceIndex(0) +1->Emitted(17, 17) Source(11, 17) + SourceIndex(0) +2 >Emitted(17, 23) Source(11, 23) + SourceIndex(0) +3 >Emitted(17, 24) Source(11, 24) + SourceIndex(0) +4 >Emitted(17, 54) Source(11, 54) + SourceIndex(0) +5 >Emitted(17, 55) Source(11, 55) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^ @@ -121,8 +126,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1 > > 2 > } -1 >Emitted(13, 13) Source(12, 13) + SourceIndex(0) -2 >Emitted(13, 14) Source(12, 14) + SourceIndex(0) +1 >Emitted(18, 13) Source(12, 13) + SourceIndex(0) +2 >Emitted(18, 14) Source(12, 14) + SourceIndex(0) --- >>> }; 1 >^^^^^^^^^ @@ -130,8 +135,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1 > > } 2 > -1 >Emitted(14, 10) Source(13, 10) + SourceIndex(0) -2 >Emitted(14, 11) Source(13, 10) + SourceIndex(0) +1 >Emitted(19, 10) Source(13, 10) + SourceIndex(0) +2 >Emitted(19, 11) Source(13, 10) + SourceIndex(0) --- >>> } 1 >^^^^ @@ -140,8 +145,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1 > > 2 > } -1 >Emitted(15, 5) Source(14, 5) + SourceIndex(0) -2 >Emitted(15, 6) Source(14, 6) + SourceIndex(0) +1 >Emitted(20, 5) Source(14, 5) + SourceIndex(0) +2 >Emitted(20, 6) Source(14, 6) + SourceIndex(0) --- >>> C.prototype.foo = function () { return "this never gets used."; }; 1->^^^^ @@ -164,16 +169,16 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 8 > ; 9 > 10> } -1->Emitted(16, 5) Source(5, 5) + SourceIndex(0) -2 >Emitted(16, 20) Source(5, 8) + SourceIndex(0) -3 >Emitted(16, 23) Source(5, 5) + SourceIndex(0) -4 >Emitted(16, 37) Source(5, 13) + SourceIndex(0) -5 >Emitted(16, 43) Source(5, 19) + SourceIndex(0) -6 >Emitted(16, 44) Source(5, 20) + SourceIndex(0) -7 >Emitted(16, 67) Source(5, 43) + SourceIndex(0) -8 >Emitted(16, 68) Source(5, 44) + SourceIndex(0) -9 >Emitted(16, 69) Source(5, 45) + SourceIndex(0) -10>Emitted(16, 70) Source(5, 46) + SourceIndex(0) +1->Emitted(21, 5) Source(5, 5) + SourceIndex(0) +2 >Emitted(21, 20) Source(5, 8) + SourceIndex(0) +3 >Emitted(21, 23) Source(5, 5) + SourceIndex(0) +4 >Emitted(21, 37) Source(5, 13) + SourceIndex(0) +5 >Emitted(21, 43) Source(5, 19) + SourceIndex(0) +6 >Emitted(21, 44) Source(5, 20) + SourceIndex(0) +7 >Emitted(21, 67) Source(5, 43) + SourceIndex(0) +8 >Emitted(21, 68) Source(5, 44) + SourceIndex(0) +9 >Emitted(21, 69) Source(5, 45) + SourceIndex(0) +10>Emitted(21, 70) Source(5, 46) + SourceIndex(0) --- >>> return C; 1 >^^^^ @@ -190,8 +195,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > } > 2 > } -1 >Emitted(17, 5) Source(15, 1) + SourceIndex(0) -2 >Emitted(17, 13) Source(15, 2) + SourceIndex(0) +1 >Emitted(22, 5) Source(15, 1) + SourceIndex(0) +2 >Emitted(22, 13) Source(15, 2) + SourceIndex(0) --- >>>}()); 1 > @@ -216,10 +221,10 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > } > } > } -1 >Emitted(18, 1) Source(15, 1) + SourceIndex(0) -2 >Emitted(18, 2) Source(15, 2) + SourceIndex(0) -3 >Emitted(18, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(18, 6) Source(15, 2) + SourceIndex(0) +1 >Emitted(23, 1) Source(15, 1) + SourceIndex(0) +2 >Emitted(23, 2) Source(15, 2) + SourceIndex(0) +3 >Emitted(23, 2) Source(2, 1) + SourceIndex(0) +4 >Emitted(23, 6) Source(15, 2) + SourceIndex(0) --- >>>var D = (function (_super) { 1-> @@ -227,15 +232,15 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1-> > > -1->Emitted(19, 1) Source(17, 1) + SourceIndex(0) +1->Emitted(24, 1) Source(17, 1) + SourceIndex(0) --- >>> __extends(D, _super); 1->^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^ 1->class D extends 2 > C -1->Emitted(20, 5) Source(17, 17) + SourceIndex(0) -2 >Emitted(20, 26) Source(17, 18) + SourceIndex(0) +1->Emitted(25, 5) Source(17, 17) + SourceIndex(0) +2 >Emitted(25, 26) Source(17, 18) + SourceIndex(0) --- >>> function D(a) { 1 >^^^^ @@ -248,9 +253,9 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > 2 > constructor( 3 > a = 100 -1 >Emitted(21, 5) Source(20, 5) + SourceIndex(0) -2 >Emitted(21, 16) Source(20, 17) + SourceIndex(0) -3 >Emitted(21, 17) Source(20, 24) + SourceIndex(0) +1 >Emitted(26, 5) Source(20, 5) + SourceIndex(0) +2 >Emitted(26, 16) Source(20, 17) + SourceIndex(0) +3 >Emitted(26, 17) Source(20, 24) + SourceIndex(0) --- >>> if (a === void 0) { a = 100; } 1->^^^^^^^^ @@ -262,10 +267,10 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 2 > 3 > 4 > a = 100 -1->Emitted(22, 9) Source(20, 17) + SourceIndex(0) -2 >Emitted(22, 27) Source(20, 17) + SourceIndex(0) -3 >Emitted(22, 29) Source(20, 17) + SourceIndex(0) -4 >Emitted(22, 36) Source(20, 24) + SourceIndex(0) +1->Emitted(27, 9) Source(20, 17) + SourceIndex(0) +2 >Emitted(27, 27) Source(20, 17) + SourceIndex(0) +3 >Emitted(27, 29) Source(20, 17) + SourceIndex(0) +4 >Emitted(27, 36) Source(20, 24) + SourceIndex(0) --- >>> var _this = _super.call(this, a) || this; 1->^^^^^^^^ @@ -294,12 +299,12 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > else > return null; > } -1->Emitted(23, 9) Source(20, 5) + SourceIndex(0) -2 >Emitted(23, 21) Source(21, 9) + SourceIndex(0) -3 >Emitted(23, 39) Source(21, 15) + SourceIndex(0) -4 >Emitted(23, 40) Source(21, 16) + SourceIndex(0) -5 >Emitted(23, 41) Source(21, 17) + SourceIndex(0) -6 >Emitted(23, 50) Source(33, 6) + SourceIndex(0) +1->Emitted(28, 9) Source(20, 5) + SourceIndex(0) +2 >Emitted(28, 21) Source(21, 9) + SourceIndex(0) +3 >Emitted(28, 39) Source(21, 15) + SourceIndex(0) +4 >Emitted(28, 40) Source(21, 16) + SourceIndex(0) +5 >Emitted(28, 41) Source(21, 17) + SourceIndex(0) +6 >Emitted(28, 50) Source(33, 6) + SourceIndex(0) --- >>> _this.dProp = function () { return _this; }; 1->^^^^^^^^ @@ -320,15 +325,15 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 7 > 8 > this 9 > ; -1->Emitted(24, 9) Source(18, 5) + SourceIndex(0) -2 >Emitted(24, 20) Source(18, 10) + SourceIndex(0) -3 >Emitted(24, 23) Source(18, 13) + SourceIndex(0) -4 >Emitted(24, 37) Source(18, 19) + SourceIndex(0) -5 >Emitted(24, 44) Source(18, 19) + SourceIndex(0) -6 >Emitted(24, 49) Source(18, 23) + SourceIndex(0) -7 >Emitted(24, 51) Source(18, 19) + SourceIndex(0) -8 >Emitted(24, 52) Source(18, 23) + SourceIndex(0) -9 >Emitted(24, 53) Source(18, 24) + SourceIndex(0) +1->Emitted(29, 9) Source(18, 5) + SourceIndex(0) +2 >Emitted(29, 20) Source(18, 10) + SourceIndex(0) +3 >Emitted(29, 23) Source(18, 13) + SourceIndex(0) +4 >Emitted(29, 37) Source(18, 19) + SourceIndex(0) +5 >Emitted(29, 44) Source(18, 19) + SourceIndex(0) +6 >Emitted(29, 49) Source(18, 23) + SourceIndex(0) +7 >Emitted(29, 51) Source(18, 19) + SourceIndex(0) +8 >Emitted(29, 52) Source(18, 23) + SourceIndex(0) +9 >Emitted(29, 53) Source(18, 24) + SourceIndex(0) --- >>> if (Math.random() < 0.5) { 1 >^^^^^^^^ @@ -362,19 +367,19 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 11> ) 12> 13> { -1 >Emitted(25, 9) Source(23, 9) + SourceIndex(0) -2 >Emitted(25, 11) Source(23, 11) + SourceIndex(0) -3 >Emitted(25, 12) Source(23, 12) + SourceIndex(0) -4 >Emitted(25, 13) Source(23, 13) + SourceIndex(0) -5 >Emitted(25, 17) Source(23, 17) + SourceIndex(0) -6 >Emitted(25, 18) Source(23, 18) + SourceIndex(0) -7 >Emitted(25, 24) Source(23, 24) + SourceIndex(0) -8 >Emitted(25, 26) Source(23, 26) + SourceIndex(0) -9 >Emitted(25, 29) Source(23, 29) + SourceIndex(0) -10>Emitted(25, 32) Source(23, 32) + SourceIndex(0) -11>Emitted(25, 33) Source(23, 33) + SourceIndex(0) -12>Emitted(25, 34) Source(23, 34) + SourceIndex(0) -13>Emitted(25, 35) Source(23, 35) + SourceIndex(0) +1 >Emitted(30, 9) Source(23, 9) + SourceIndex(0) +2 >Emitted(30, 11) Source(23, 11) + SourceIndex(0) +3 >Emitted(30, 12) Source(23, 12) + SourceIndex(0) +4 >Emitted(30, 13) Source(23, 13) + SourceIndex(0) +5 >Emitted(30, 17) Source(23, 17) + SourceIndex(0) +6 >Emitted(30, 18) Source(23, 18) + SourceIndex(0) +7 >Emitted(30, 24) Source(23, 24) + SourceIndex(0) +8 >Emitted(30, 26) Source(23, 26) + SourceIndex(0) +9 >Emitted(30, 29) Source(23, 29) + SourceIndex(0) +10>Emitted(30, 32) Source(23, 32) + SourceIndex(0) +11>Emitted(30, 33) Source(23, 33) + SourceIndex(0) +12>Emitted(30, 34) Source(23, 34) + SourceIndex(0) +13>Emitted(30, 35) Source(23, 35) + SourceIndex(0) --- >>> "You win!"; 1 >^^^^^^^^^^^^ @@ -384,9 +389,9 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > 2 > "You win!" 3 > -1 >Emitted(26, 13) Source(24, 13) + SourceIndex(0) -2 >Emitted(26, 23) Source(24, 23) + SourceIndex(0) -3 >Emitted(26, 24) Source(24, 23) + SourceIndex(0) +1 >Emitted(31, 13) Source(24, 13) + SourceIndex(0) +2 >Emitted(31, 23) Source(24, 23) + SourceIndex(0) +3 >Emitted(31, 24) Source(24, 23) + SourceIndex(0) --- >>> return { 1 >^^^^^^^^^^^^ @@ -397,9 +402,9 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > 2 > return 3 > -1 >Emitted(27, 13) Source(25, 13) + SourceIndex(0) -2 >Emitted(27, 19) Source(25, 19) + SourceIndex(0) -3 >Emitted(27, 20) Source(25, 20) + SourceIndex(0) +1 >Emitted(32, 13) Source(25, 13) + SourceIndex(0) +2 >Emitted(32, 19) Source(25, 19) + SourceIndex(0) +3 >Emitted(32, 20) Source(25, 20) + SourceIndex(0) --- >>> cProp: 1, 1->^^^^^^^^^^^^^^^^ @@ -412,10 +417,10 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 2 > cProp 3 > : 4 > 1 -1->Emitted(28, 17) Source(26, 17) + SourceIndex(0) -2 >Emitted(28, 22) Source(26, 22) + SourceIndex(0) -3 >Emitted(28, 24) Source(26, 24) + SourceIndex(0) -4 >Emitted(28, 25) Source(26, 25) + SourceIndex(0) +1->Emitted(33, 17) Source(26, 17) + SourceIndex(0) +2 >Emitted(33, 22) Source(26, 22) + SourceIndex(0) +3 >Emitted(33, 24) Source(26, 24) + SourceIndex(0) +4 >Emitted(33, 25) Source(26, 25) + SourceIndex(0) --- >>> dProp: function () { return _this; }, 1->^^^^^^^^^^^^^^^^ @@ -436,14 +441,14 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 6 > this 7 > 8 > this -1->Emitted(29, 17) Source(27, 17) + SourceIndex(0) -2 >Emitted(29, 22) Source(27, 22) + SourceIndex(0) -3 >Emitted(29, 24) Source(27, 24) + SourceIndex(0) -4 >Emitted(29, 38) Source(27, 30) + SourceIndex(0) -5 >Emitted(29, 45) Source(27, 30) + SourceIndex(0) -6 >Emitted(29, 50) Source(27, 34) + SourceIndex(0) -7 >Emitted(29, 52) Source(27, 30) + SourceIndex(0) -8 >Emitted(29, 53) Source(27, 34) + SourceIndex(0) +1->Emitted(34, 17) Source(27, 17) + SourceIndex(0) +2 >Emitted(34, 22) Source(27, 22) + SourceIndex(0) +3 >Emitted(34, 24) Source(27, 24) + SourceIndex(0) +4 >Emitted(34, 38) Source(27, 30) + SourceIndex(0) +5 >Emitted(34, 45) Source(27, 30) + SourceIndex(0) +6 >Emitted(34, 50) Source(27, 34) + SourceIndex(0) +7 >Emitted(34, 52) Source(27, 30) + SourceIndex(0) +8 >Emitted(34, 53) Source(27, 34) + SourceIndex(0) --- >>> foo: function () { return "You win!!!!!"; } 1->^^^^^^^^^^^^^^^^ @@ -465,15 +470,15 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 7 > 8 > 9 > } -1->Emitted(30, 17) Source(28, 17) + SourceIndex(0) -2 >Emitted(30, 20) Source(28, 20) + SourceIndex(0) -3 >Emitted(30, 36) Source(28, 25) + SourceIndex(0) -4 >Emitted(30, 42) Source(28, 31) + SourceIndex(0) -5 >Emitted(30, 43) Source(28, 32) + SourceIndex(0) -6 >Emitted(30, 57) Source(28, 46) + SourceIndex(0) -7 >Emitted(30, 58) Source(28, 46) + SourceIndex(0) -8 >Emitted(30, 59) Source(28, 47) + SourceIndex(0) -9 >Emitted(30, 60) Source(28, 48) + SourceIndex(0) +1->Emitted(35, 17) Source(28, 17) + SourceIndex(0) +2 >Emitted(35, 20) Source(28, 20) + SourceIndex(0) +3 >Emitted(35, 36) Source(28, 25) + SourceIndex(0) +4 >Emitted(35, 42) Source(28, 31) + SourceIndex(0) +5 >Emitted(35, 43) Source(28, 32) + SourceIndex(0) +6 >Emitted(35, 57) Source(28, 46) + SourceIndex(0) +7 >Emitted(35, 58) Source(28, 46) + SourceIndex(0) +8 >Emitted(35, 59) Source(28, 47) + SourceIndex(0) +9 >Emitted(35, 60) Source(28, 48) + SourceIndex(0) --- >>> }; 1 >^^^^^^^^^^^^^ @@ -481,8 +486,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1 > > } 2 > ; -1 >Emitted(31, 14) Source(29, 14) + SourceIndex(0) -2 >Emitted(31, 15) Source(29, 15) + SourceIndex(0) +1 >Emitted(36, 14) Source(29, 14) + SourceIndex(0) +2 >Emitted(36, 15) Source(29, 15) + SourceIndex(0) --- >>> } 1 >^^^^^^^^ @@ -491,8 +496,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1 > > 2 > } -1 >Emitted(32, 9) Source(30, 9) + SourceIndex(0) -2 >Emitted(32, 10) Source(30, 10) + SourceIndex(0) +1 >Emitted(37, 9) Source(30, 9) + SourceIndex(0) +2 >Emitted(37, 10) Source(30, 10) + SourceIndex(0) --- >>> else 1->^^^^^^^^ @@ -501,8 +506,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1-> > 2 > else -1->Emitted(33, 9) Source(31, 9) + SourceIndex(0) -2 >Emitted(33, 13) Source(31, 13) + SourceIndex(0) +1->Emitted(38, 9) Source(31, 9) + SourceIndex(0) +2 >Emitted(38, 13) Source(31, 13) + SourceIndex(0) --- >>> return null; 1->^^^^^^^^^^^^ @@ -516,11 +521,11 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 3 > 4 > null 5 > ; -1->Emitted(34, 13) Source(32, 13) + SourceIndex(0) -2 >Emitted(34, 19) Source(32, 19) + SourceIndex(0) -3 >Emitted(34, 20) Source(32, 20) + SourceIndex(0) -4 >Emitted(34, 24) Source(32, 24) + SourceIndex(0) -5 >Emitted(34, 25) Source(32, 25) + SourceIndex(0) +1->Emitted(39, 13) Source(32, 13) + SourceIndex(0) +2 >Emitted(39, 19) Source(32, 19) + SourceIndex(0) +3 >Emitted(39, 20) Source(32, 20) + SourceIndex(0) +4 >Emitted(39, 24) Source(32, 24) + SourceIndex(0) +5 >Emitted(39, 25) Source(32, 25) + SourceIndex(0) --- >>> } 1 >^^^^ @@ -529,8 +534,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1 > > 2 > } -1 >Emitted(35, 5) Source(33, 5) + SourceIndex(0) -2 >Emitted(35, 6) Source(33, 6) + SourceIndex(0) +1 >Emitted(40, 5) Source(33, 5) + SourceIndex(0) +2 >Emitted(40, 6) Source(33, 6) + SourceIndex(0) --- >>> return D; 1->^^^^ @@ -538,8 +543,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1-> > 2 > } -1->Emitted(36, 5) Source(34, 1) + SourceIndex(0) -2 >Emitted(36, 13) Source(34, 2) + SourceIndex(0) +1->Emitted(41, 5) Source(34, 1) + SourceIndex(0) +2 >Emitted(41, 13) Source(34, 2) + SourceIndex(0) --- >>>}(C)); 1 > @@ -572,11 +577,11 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > return null; > } > } -1 >Emitted(37, 1) Source(34, 1) + SourceIndex(0) -2 >Emitted(37, 2) Source(34, 2) + SourceIndex(0) -3 >Emitted(37, 2) Source(17, 1) + SourceIndex(0) -4 >Emitted(37, 3) Source(17, 17) + SourceIndex(0) -5 >Emitted(37, 4) Source(17, 18) + SourceIndex(0) -6 >Emitted(37, 7) Source(34, 2) + SourceIndex(0) +1 >Emitted(42, 1) Source(34, 1) + SourceIndex(0) +2 >Emitted(42, 2) Source(34, 2) + SourceIndex(0) +3 >Emitted(42, 2) Source(17, 1) + SourceIndex(0) +4 >Emitted(42, 3) Source(17, 17) + SourceIndex(0) +5 >Emitted(42, 4) Source(17, 18) + SourceIndex(0) +6 >Emitted(42, 7) Source(34, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=derivedClassConstructorWithExplicitReturns01.js.map \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.js b/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.js index e76f3445c8e..960fea90a0c 100644 --- a/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.js +++ b/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.js @@ -34,11 +34,16 @@ class Derived4 extends Base2 { //// [derivedClassConstructorWithoutSuperCall.js] // derived class constructors must contain a super call -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -47,7 +52,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this; + var _this = this; return _this; } return Derived; @@ -60,7 +65,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - var _this; + var _this = this; var r2 = function () { return _this = _super.call(this) || this; }; // error for misplaced super call (nested function) return _this; } @@ -69,7 +74,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - var _this; + var _this = this; var r = function () { _this = _super.call(this) || this; }; // error return _this; } @@ -78,7 +83,7 @@ var Derived3 = (function (_super) { var Derived4 = (function (_super) { __extends(Derived4, _super); function Derived4() { - var _this; + var _this = this; var r = _this = _super.call(this) || this; // ok return _this; } diff --git a/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js b/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js index 7f6b83593ca..23a4233d124 100644 --- a/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js +++ b/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js @@ -15,11 +15,16 @@ class Derived extends Base { } //// [derivedClassFunctionOverridesBaseClassAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -38,7 +43,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.prototype.x = function () { return 1; diff --git a/tests/baselines/reference/derivedClassIncludesInheritedMembers.js b/tests/baselines/reference/derivedClassIncludesInheritedMembers.js index 8224473cb54..8d2010b3346 100644 --- a/tests/baselines/reference/derivedClassIncludesInheritedMembers.js +++ b/tests/baselines/reference/derivedClassIncludesInheritedMembers.js @@ -41,11 +41,16 @@ var r8 = d2[1]; //// [derivedClassIncludesInheritedMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(x) { } @@ -68,7 +73,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -89,7 +94,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/derivedClassOverridesIndexersWithAssignmentCompatibility.js b/tests/baselines/reference/derivedClassOverridesIndexersWithAssignmentCompatibility.js index 4753e395390..fceefd905cc 100644 --- a/tests/baselines/reference/derivedClassOverridesIndexersWithAssignmentCompatibility.js +++ b/tests/baselines/reference/derivedClassOverridesIndexersWithAssignmentCompatibility.js @@ -18,11 +18,16 @@ class Derived2 extends Base2 { } //// [derivedClassOverridesIndexersWithAssignmentCompatibility.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -32,7 +37,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -45,7 +50,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/derivedClassOverridesPrivateFunction1.js b/tests/baselines/reference/derivedClassOverridesPrivateFunction1.js index 981c072d47c..a7c35a96ac3 100644 --- a/tests/baselines/reference/derivedClassOverridesPrivateFunction1.js +++ b/tests/baselines/reference/derivedClassOverridesPrivateFunction1.js @@ -16,11 +16,16 @@ class DerivedClass extends BaseClass { new DerivedClass(); //// [derivedClassOverridesPrivateFunction1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var BaseClass = (function () { function BaseClass() { this._init(); diff --git a/tests/baselines/reference/derivedClassOverridesPrivates.js b/tests/baselines/reference/derivedClassOverridesPrivates.js index 1a58c038fea..642453857c5 100644 --- a/tests/baselines/reference/derivedClassOverridesPrivates.js +++ b/tests/baselines/reference/derivedClassOverridesPrivates.js @@ -16,11 +16,16 @@ class Derived2 extends Base2 { } //// [derivedClassOverridesPrivates.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -29,7 +34,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -41,7 +46,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers.js b/tests/baselines/reference/derivedClassOverridesProtectedMembers.js index b8997769eb7..9230a295f5b 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers.js +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers.js @@ -37,11 +37,16 @@ class Derived extends Base { //// [derivedClassOverridesProtectedMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x; var y; var Base = (function () { diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers2.js b/tests/baselines/reference/derivedClassOverridesProtectedMembers2.js index 6797eef0e77..6eef011e0f4 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers2.js +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers2.js @@ -64,11 +64,16 @@ var r8 = d2[1]; //// [derivedClassOverridesProtectedMembers2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x; var y; var Base = (function () { @@ -131,7 +136,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers3.js b/tests/baselines/reference/derivedClassOverridesProtectedMembers3.js index d0d9d8fa0f5..615bdcddcf0 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers3.js +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers3.js @@ -72,11 +72,16 @@ class Derived10 extends Base { } //// [derivedClassOverridesProtectedMembers3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x; var y; var Base = (function () { diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers4.js b/tests/baselines/reference/derivedClassOverridesProtectedMembers4.js index 06f80997600..594e8166e5e 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers4.js +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers4.js @@ -15,11 +15,16 @@ class Derived2 extends Derived1 { } //// [derivedClassOverridesProtectedMembers4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x; var y; var Base = (function () { @@ -30,14 +35,14 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived1; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived1)); diff --git a/tests/baselines/reference/derivedClassOverridesPublicMembers.js b/tests/baselines/reference/derivedClassOverridesPublicMembers.js index 7943d904dea..af9a013a3d8 100644 --- a/tests/baselines/reference/derivedClassOverridesPublicMembers.js +++ b/tests/baselines/reference/derivedClassOverridesPublicMembers.js @@ -63,11 +63,16 @@ var r8 = d2[1]; //// [derivedClassOverridesPublicMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x; var y; var Base = (function () { @@ -129,7 +134,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/derivedClassOverridesWithoutSubtype.js b/tests/baselines/reference/derivedClassOverridesWithoutSubtype.js index e42ff9c9e1d..fa7eb924653 100644 --- a/tests/baselines/reference/derivedClassOverridesWithoutSubtype.js +++ b/tests/baselines/reference/derivedClassOverridesWithoutSubtype.js @@ -24,11 +24,16 @@ class Derived2 extends Base2 { } //// [derivedClassOverridesWithoutSubtype.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -37,7 +42,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -49,7 +54,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/derivedClassParameterProperties.js b/tests/baselines/reference/derivedClassParameterProperties.js index 27dcc4b7d5d..d8d93e35078 100644 --- a/tests/baselines/reference/derivedClassParameterProperties.js +++ b/tests/baselines/reference/derivedClassParameterProperties.js @@ -96,11 +96,16 @@ class Derived10 extends Base2 { //// [derivedClassParameterProperties.js] // ordering of super calls in derived constructors matters depending on other class contents -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -109,7 +114,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived(y) { - var _this; + var _this = this; var a = 1; _this = _super.call(this) || this; // ok return _this; @@ -119,7 +124,7 @@ var Derived = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2(y) { - var _this; + var _this = this; _this.y = y; var a = 1; _this = _super.call(this) || this; // error @@ -140,7 +145,7 @@ var Derived3 = (function (_super) { var Derived4 = (function (_super) { __extends(Derived4, _super); function Derived4(y) { - var _this; + var _this = this; _this.a = 1; var b = 2; _this = _super.call(this) || this; // error @@ -161,7 +166,7 @@ var Derived5 = (function (_super) { var Derived6 = (function (_super) { __extends(Derived6, _super); function Derived6(y) { - var _this; + var _this = this; _this.a = 1; var b = 2; _this = _super.call(this) || this; // error: "super" has to be called before "this" accessing @@ -172,7 +177,7 @@ var Derived6 = (function (_super) { var Derived7 = (function (_super) { __extends(Derived7, _super); function Derived7(y) { - var _this; + var _this = this; _this.a = 1; _this.a = 3; _this.b = 3; @@ -201,7 +206,7 @@ var Base2 = (function () { var Derived9 = (function (_super) { __extends(Derived9, _super); function Derived9(y) { - var _this; + var _this = this; _this.a = 1; _this.a = 3; _this.b = 3; diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js index b778d7bbca2..8703215a631 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js @@ -33,11 +33,16 @@ class Derived extends Base { //// [derivedClassSuperCallsInNonConstructorMembers.js] // error to use super calls outside a constructor -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -46,7 +51,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.a = _this = _super.call(this) || this; return _this; } diff --git a/tests/baselines/reference/derivedClassSuperCallsWithThisArg.js b/tests/baselines/reference/derivedClassSuperCallsWithThisArg.js index 039e25919f8..f63a8076a0b 100644 --- a/tests/baselines/reference/derivedClassSuperCallsWithThisArg.js +++ b/tests/baselines/reference/derivedClassSuperCallsWithThisArg.js @@ -29,11 +29,16 @@ class Derived4 extends Base { } //// [derivedClassSuperCallsWithThisArg.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 a76ac8101a0..83a750c707d 100644 --- a/tests/baselines/reference/derivedClassTransitivity.js +++ b/tests/baselines/reference/derivedClassTransitivity.js @@ -22,11 +22,16 @@ var r2 = e.foo(''); //// [derivedClassTransitivity.js] // subclassing is not transitive when you can remove required parameters and add optional parameters -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -36,7 +41,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.foo = function () { }; // ok to drop parameters return D; @@ -44,7 +49,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.foo = function (x) { }; // ok to add optional parameters return E; diff --git a/tests/baselines/reference/derivedClassTransitivity2.js b/tests/baselines/reference/derivedClassTransitivity2.js index a3894863696..7cd7d73d604 100644 --- a/tests/baselines/reference/derivedClassTransitivity2.js +++ b/tests/baselines/reference/derivedClassTransitivity2.js @@ -22,11 +22,16 @@ var r2 = e.foo(1, ''); //// [derivedClassTransitivity2.js] // subclassing is not transitive when you can remove required parameters and add optional parameters -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -36,7 +41,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.foo = function (x) { }; // ok to drop parameters return D; @@ -44,7 +49,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.foo = function (x, y) { }; // ok to add optional parameters return E; diff --git a/tests/baselines/reference/derivedClassTransitivity3.js b/tests/baselines/reference/derivedClassTransitivity3.js index 71dfecb346f..35a080f1800 100644 --- a/tests/baselines/reference/derivedClassTransitivity3.js +++ b/tests/baselines/reference/derivedClassTransitivity3.js @@ -22,11 +22,16 @@ var r2 = e.foo('', 1); //// [derivedClassTransitivity3.js] // subclassing is not transitive when you can remove required parameters and add optional parameters -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -36,7 +41,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.foo = function (x) { }; // ok to drop parameters return D; @@ -44,7 +49,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.foo = function (x, y) { }; // ok to add optional parameters return E; diff --git a/tests/baselines/reference/derivedClassTransitivity4.js b/tests/baselines/reference/derivedClassTransitivity4.js index 0030ce702d8..e0f82d55a7c 100644 --- a/tests/baselines/reference/derivedClassTransitivity4.js +++ b/tests/baselines/reference/derivedClassTransitivity4.js @@ -22,11 +22,16 @@ var r2 = e.foo(''); //// [derivedClassTransitivity4.js] // subclassing is not transitive when you can remove required parameters and add optional parameters on protected members -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -36,7 +41,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.foo = function () { }; // ok to drop parameters return D; @@ -44,7 +49,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.foo = function (x) { }; // ok to add optional parameters return E; diff --git a/tests/baselines/reference/derivedClassWithAny.js b/tests/baselines/reference/derivedClassWithAny.js index 2a199e55861..c8ed8ce5cad 100644 --- a/tests/baselines/reference/derivedClassWithAny.js +++ b/tests/baselines/reference/derivedClassWithAny.js @@ -60,11 +60,16 @@ var r = c.foo(); // e.foo would return string //// [derivedClassWithAny.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -91,7 +96,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(D.prototype, "X", { get: function () { @@ -119,7 +124,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(E.prototype, "X", { get: function () { return ''; }, diff --git a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingProtectedInstance.js b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingProtectedInstance.js index 0542815c4e4..07cc9c43539 100644 --- a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingProtectedInstance.js +++ b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingProtectedInstance.js @@ -23,11 +23,16 @@ class Derived extends Base { //// [derivedClassWithPrivateInstanceShadowingProtectedInstance.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -46,7 +51,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.prototype.fn = function () { return ''; diff --git a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js index 41869cad416..36c6cb56563 100644 --- a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js +++ b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js @@ -33,11 +33,16 @@ var r6 = Derived.a; // error Derived.a = 2; // error //// [derivedClassWithPrivateInstanceShadowingPublicInstance.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -56,7 +61,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.prototype.fn = function () { return ''; diff --git a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingProtectedStatic.js b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingProtectedStatic.js index 10ae3cb35c8..52a50a8aa77 100644 --- a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingProtectedStatic.js +++ b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingProtectedStatic.js @@ -22,11 +22,16 @@ class Derived extends Base { } //// [derivedClassWithPrivateStaticShadowingProtectedStatic.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -45,7 +50,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.fn = function () { return ''; diff --git a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js index 3f2c2a3b811..6e39028ce34 100644 --- a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js +++ b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js @@ -34,11 +34,16 @@ var r6 = Derived.a; // error Derived.a = 2; // error //// [derivedClassWithPrivateStaticShadowingPublicStatic.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -58,7 +63,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.fn = function () { return ''; diff --git a/tests/baselines/reference/derivedClassWithoutExplicitConstructor.js b/tests/baselines/reference/derivedClassWithoutExplicitConstructor.js index 7a6a7ecbb63..1fd02f5ba62 100644 --- a/tests/baselines/reference/derivedClassWithoutExplicitConstructor.js +++ b/tests/baselines/reference/derivedClassWithoutExplicitConstructor.js @@ -26,11 +26,16 @@ var d = new D(); // error var d2 = new D(new Date()); // ok //// [derivedClassWithoutExplicitConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(x) { this.a = 1; @@ -41,7 +46,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = 1; _this.y = 'hello'; return _this; @@ -59,7 +64,7 @@ var Base2 = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = 2; _this.y = null; return _this; diff --git a/tests/baselines/reference/derivedClassWithoutExplicitConstructor2.js b/tests/baselines/reference/derivedClassWithoutExplicitConstructor2.js index 62beb4bf28f..178ca2be16d 100644 --- a/tests/baselines/reference/derivedClassWithoutExplicitConstructor2.js +++ b/tests/baselines/reference/derivedClassWithoutExplicitConstructor2.js @@ -34,11 +34,16 @@ var d3 = new D(new Date(), new Date()); var d4 = new D(new Date(), new Date(), new Date()); //// [derivedClassWithoutExplicitConstructor2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(x) { this.a = 1; @@ -49,7 +54,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = 1; _this.y = 'hello'; return _this; @@ -69,7 +74,7 @@ var Base2 = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = 2; _this.y = null; return _this; diff --git a/tests/baselines/reference/derivedClassWithoutExplicitConstructor3.js b/tests/baselines/reference/derivedClassWithoutExplicitConstructor3.js index c96d0c96723..86f69433504 100644 --- a/tests/baselines/reference/derivedClassWithoutExplicitConstructor3.js +++ b/tests/baselines/reference/derivedClassWithoutExplicitConstructor3.js @@ -48,11 +48,16 @@ var d3 = new D2(new Date(), new Date()); // ok //// [derivedClassWithoutExplicitConstructor3.js] // automatic constructors with a class hieararchy of depth > 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(x) { this.a = 1; @@ -73,7 +78,7 @@ var Derived = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = 1; _this.y = 'hello'; return _this; @@ -102,7 +107,7 @@ var D = (function (_super) { var D2 = (function (_super) { __extends(D2, _super); function D2() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = 2; _this.y = null; return _this; diff --git a/tests/baselines/reference/derivedClasses.js b/tests/baselines/reference/derivedClasses.js index 3e097a9b139..b23161d00d2 100644 --- a/tests/baselines/reference/derivedClasses.js +++ b/tests/baselines/reference/derivedClasses.js @@ -31,15 +31,20 @@ b.hue(); //// [derivedClasses.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Red = (function (_super) { __extends(Red, _super); function Red() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Red.prototype.shade = function () { var _this = this; @@ -58,7 +63,7 @@ var Color = (function () { var Blue = (function (_super) { __extends(Blue, _super); function Blue() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Blue.prototype.shade = function () { var _this = this; diff --git a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt index 81e43f7d8fe..359fab212e9 100644 --- a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt +++ b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt @@ -2,8 +2,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(11,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(19,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,25): error TS2322: Type '""' is not assignable to type 'T'. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(32,16): error TS2322: Type '""' is not assignable to type 'T'. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,18): error TS2322: Type '""' is not assignable to type 'T'. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(32,9): error TS2322: Type '""' is not assignable to type 'T'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(41,1): error TS2322: Type 'E' is not assignable to type 'C'. Types of property 'x' are incompatible. Type 'string' is not assignable to type 'number'. @@ -48,11 +48,11 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC get X(): T { return ''; } // error ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~ + ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'T'. foo(): T { return ''; // error - ~~ + ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'T'. } } diff --git a/tests/baselines/reference/derivedGenericClassWithAny.js b/tests/baselines/reference/derivedGenericClassWithAny.js index 1822f3fcc47..0cf4c316a44 100644 --- a/tests/baselines/reference/derivedGenericClassWithAny.js +++ b/tests/baselines/reference/derivedGenericClassWithAny.js @@ -43,11 +43,16 @@ c = e; var r = c.foo(); // e.foo would return string //// [derivedGenericClassWithAny.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -64,7 +69,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(D.prototype, "X", { get: function () { @@ -92,7 +97,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(E.prototype, "X", { get: function () { return ''; } // error diff --git a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.js b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.js index c17922e05ee..a190b26901c 100644 --- a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.js +++ b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.js @@ -18,11 +18,16 @@ class Derived extends Base { } //// [derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -34,7 +39,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.prototype.foo = function (x) { return null; diff --git a/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.js b/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.js index 6fe690fd692..26f4408e41e 100644 --- a/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.js +++ b/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.js @@ -21,11 +21,16 @@ b = d2; var r: Base[] = [d1, d2]; //// [derivedTypeDoesNotRequireExtendsClause.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -39,7 +44,7 @@ var Derived = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.errors.txt new file mode 100644 index 00000000000..a68affcf73d --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts(2,22): error TS2448: Block-scoped variable 'e' used before its declaration. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts(3,22): error TS2448: Block-scoped variable 'i' used before its declaration. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts(7,27): error TS2372: Parameter 'e' cannot be referenced in its initializer. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts(9,27): error TS2373: Initializer of parameter 'h' cannot reference identifier 'i' declared after it. + + +==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts (4 errors) ==== + const [a, b = a] = [1]; // ok + const [c, d = c, e = e] = [1]; // error for e = e + ~ +!!! error TS2448: Block-scoped variable 'e' used before its declaration. + const [f, g = f, h = i, i = f] = [1]; // error for h = i + ~ +!!! error TS2448: Block-scoped variable 'i' used before its declaration. + + (function ([a, b = a]) { // ok + })([1]); + (function ([c, d = c, e = e]) { // error for e = e + ~ +!!! error TS2372: Parameter 'e' cannot be referenced in its initializer. + })([1]); + (function ([f, g = f, h = i, i = f]) { // error for h = i + ~ +!!! error TS2373: Initializer of parameter 'h' cannot reference identifier 'i' declared after it. + })([1]) + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.js b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.js new file mode 100644 index 00000000000..7073061dec6 --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.js @@ -0,0 +1,26 @@ +//// [destructuringArrayBindingPatternAndAssignment3.ts] +const [a, b = a] = [1]; // ok +const [c, d = c, e = e] = [1]; // error for e = e +const [f, g = f, h = i, i = f] = [1]; // error for h = i + +(function ([a, b = a]) { // ok +})([1]); +(function ([c, d = c, e = e]) { // error for e = e +})([1]); +(function ([f, g = f, h = i, i = f]) { // error for h = i +})([1]) + + +//// [destructuringArrayBindingPatternAndAssignment3.js] +var _a = [1], a = _a[0], _b = _a[1], b = _b === void 0 ? a : _b; // ok +var _c = [1], c = _c[0], _d = _c[1], d = _d === void 0 ? c : _d, _e = _c[2], e = _e === void 0 ? e : _e; // error for e = e +var _f = [1], f = _f[0], _g = _f[1], g = _g === void 0 ? f : _g, _h = _f[2], h = _h === void 0 ? i : _h, _j = _f[3], i = _j === void 0 ? f : _j; // error for h = i +(function (_a) { + var a = _a[0], _b = _a[1], b = _b === void 0 ? a : _b; +})([1]); +(function (_a) { + var c = _a[0], _b = _a[1], d = _b === void 0 ? c : _b, _c = _a[2], e = _c === void 0 ? e : _c; +})([1]); +(function (_a) { + var f = _a[0], _b = _a[1], g = _b === void 0 ? f : _b, _c = _a[2], h = _c === void 0 ? i : _c, _d = _a[3], i = _d === void 0 ? f : _d; +})([1]); diff --git a/tests/baselines/reference/destructuringInVariableDeclarations5.js b/tests/baselines/reference/destructuringInVariableDeclarations5.js index 48053fdbc4f..94530d8d258 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations5.js +++ b/tests/baselines/reference/destructuringInVariableDeclarations5.js @@ -6,14 +6,15 @@ export let { toString } = 1; //// [destructuringInVariableDeclarations5.js] -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { "use strict"; exports.toString = (1).toString; { diff --git a/tests/baselines/reference/destructuringInVariableDeclarations6.js b/tests/baselines/reference/destructuringInVariableDeclarations6.js index 479d4ee34af..c16a0a7d0a2 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations6.js +++ b/tests/baselines/reference/destructuringInVariableDeclarations6.js @@ -7,14 +7,15 @@ export {}; //// [destructuringInVariableDeclarations6.js] -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { "use strict"; let { toString } = 1; { diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment4.errors.txt b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment4.errors.txt new file mode 100644 index 00000000000..6a3f0f2b457 --- /dev/null +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment4.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment4.ts(6,9): error TS2448: Block-scoped variable 'f' used before its declaration. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment4.ts(7,9): error TS2448: Block-scoped variable 'f' used before its declaration. + + +==== tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment4.ts (2 errors) ==== + const { + a = 1, + b = 2, + c = b, // ok + d = a, // ok + e = f, // error + ~ +!!! error TS2448: Block-scoped variable 'f' used before its declaration. + f = f // error + ~ +!!! error TS2448: Block-scoped variable 'f' used before its declaration. + } = { } as any; + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment4.js b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment4.js new file mode 100644 index 00000000000..c34cbb62c1c --- /dev/null +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment4.js @@ -0,0 +1,21 @@ +//// [destructuringObjectBindingPatternAndAssignment4.ts] +const { + a = 1, + b = 2, + c = b, // ok + d = a, // ok + e = f, // error + f = f // error +} = { } as any; + + +//// [destructuringObjectBindingPatternAndAssignment4.js] +var _a = {}, _b = _a.a, a = _b === void 0 ? 1 : _b, _c = _a.b, b = _c === void 0 ? 2 : _c, _d = _a.c, c = _d === void 0 ? b : _d, // ok +_e = _a.d, // ok +d = _e === void 0 ? a : _e, // ok +_f = _a.e, // ok +e = _f === void 0 ? f : _f, // error +_g = _a.f // error +, // error +f = _g === void 0 ? f : _g // error +; diff --git a/tests/baselines/reference/destructuringParameterDeclaration5.js b/tests/baselines/reference/destructuringParameterDeclaration5.js index 7ba178823df..d2499528735 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration5.js +++ b/tests/baselines/reference/destructuringParameterDeclaration5.js @@ -52,11 +52,16 @@ d3({ y: "world" }); //// [destructuringParameterDeclaration5.js] // Parameter Declaration with 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Class = (function () { function Class() { } diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types index 94a5f2173aa..32e5b33e411 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types @@ -1,8 +1,8 @@ === tests/cases/conformance/es7/exponentiationOperator/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts === var object = { ->object : { 0: number; _0: number; } ->{ _0: 2, get 0() { return this._0; }, set 0(x: number) { this._0 = x; },} : { 0: number; _0: number; } +>object : { _0: number; 0: number; } +>{ _0: 2, get 0() { return this._0; }, set 0(x: number) { this._0 = x; },} : { _0: number; 0: number; } _0: 2, >_0 : number @@ -30,31 +30,31 @@ var object = { object[0] **= object[0]; >object[0] **= object[0] : number >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 object[0] **= object[0] **= 2; >object[0] **= object[0] **= 2 : number >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 >object[0] **= 2 : number >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 >2 : 2 object[0] **= object[0] ** 2; >object[0] **= object[0] ** 2 : number >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 >object[0] ** 2 : number >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 >2 : 2 diff --git a/tests/baselines/reference/emitExponentiationOperator4.errors.txt b/tests/baselines/reference/emitExponentiationOperator4.errors.txt new file mode 100644 index 00000000000..e8f46874ad8 --- /dev/null +++ b/tests/baselines/reference/emitExponentiationOperator4.errors.txt @@ -0,0 +1,70 @@ +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(14,1): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(15,1): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(16,1): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(17,1): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(18,1): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(21,6): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(22,6): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(23,6): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(24,6): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(25,6): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts (10 errors) ==== + var temp: any; + + (temp) ** 3; + (--temp) ** 3; + (++temp) ** 3; + (temp--) ** 3; + (temp++) ** 3; + + 1 ** (--temp) ** 3; + 1 ** (++temp) ** 3; + 1 ** (temp--) ** 3; + 1 ** (temp++) ** 3; + + (void --temp) ** 3; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + (void temp--) ** 3; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + (void 3) ** 4; + ~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + (void temp++) ** 4; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + (void temp--) ** 4; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + + 1 ** (void --temp) ** 3; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + 1 ** (void temp--) ** 3; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + 1 ** (void 3) ** 4; + ~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + 1 ** (void temp++) ** 4; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + 1 ** (void temp--) ** 4; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + (~ --temp) ** 3; + (~ temp--) ** 3; + (~ 3) ** 4; + (~ temp++) ** 4; + (~ temp--) ** 4; + + 1 ** (~ --temp) ** 3; + 1 ** (~ temp--) ** 3; + 1 ** (~ 3) ** 4; + 1 ** (~ temp++) ** 4; + 1 ** (~ temp--) ** 4; \ No newline at end of file diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js index 05b061116d3..3a8bbdb0c73 100644 --- a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js +++ b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js @@ -14,11 +14,16 @@ class B extends A { //// [emitSuperCallBeforeEmitParameterPropertyDeclaration1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { this.blub = 6; diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.js b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.js index 2cf2cb02073..d8145f6dc27 100644 --- a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.js +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.js @@ -16,11 +16,16 @@ class B extends A { } //// [emitSuperCallBeforeEmitPropertyDeclaration1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { this.blub = 6; diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js index eaa52e39285..75c618d84db 100644 --- a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js @@ -14,11 +14,16 @@ class B extends A { } //// [emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { this.blub = 6; diff --git a/tests/baselines/reference/emitThisInSuperMethodCall.js b/tests/baselines/reference/emitThisInSuperMethodCall.js index 1f7ed8bfa94..2d800d562c2 100644 --- a/tests/baselines/reference/emitThisInSuperMethodCall.js +++ b/tests/baselines/reference/emitThisInSuperMethodCall.js @@ -28,11 +28,16 @@ class RegisteredUser extends User { //// [emitThisInSuperMethodCall.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var User = (function () { function User() { } @@ -43,7 +48,7 @@ var User = (function () { var RegisteredUser = (function (_super) { __extends(RegisteredUser, _super); function RegisteredUser() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } RegisteredUser.prototype.f = function () { (function () { diff --git a/tests/baselines/reference/emptyModuleName.js b/tests/baselines/reference/emptyModuleName.js index 3ed21cf217a..1d8401803a7 100644 --- a/tests/baselines/reference/emptyModuleName.js +++ b/tests/baselines/reference/emptyModuleName.js @@ -5,16 +5,21 @@ class B extends A { //// [emptyModuleName.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = require(""); var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/equalityStrictNulls.errors.txt b/tests/baselines/reference/equalityStrictNulls.errors.txt index e0793542b84..16772d8eeab 100644 --- a/tests/baselines/reference/equalityStrictNulls.errors.txt +++ b/tests/baselines/reference/equalityStrictNulls.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(60,9): error TS2365: Operator '>' cannot be applied to types 'number' and 'undefined'. -tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(62,9): error TS2365: Operator '<' cannot be applied to types 'number' and 'undefined'. -tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(64,9): error TS2365: Operator '>=' cannot be applied to types 'number' and 'undefined'. -tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(66,9): error TS2365: Operator '<=' cannot be applied to types 'number' and 'undefined'. +tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(60,13): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(62,13): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(64,14): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(66,14): error TS2532: Object is possibly 'undefined'. ==== tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts (4 errors) ==== @@ -65,20 +65,20 @@ tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.t function f4(x: number) { if (x > undefined) { - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'number' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. } if (x < undefined) { - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'number' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. } if (x >= undefined) { - ~~~~~~~~~~~~~~ -!!! error TS2365: Operator '>=' cannot be applied to types 'number' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. } if (x <= undefined) { - ~~~~~~~~~~~~~~ -!!! error TS2365: Operator '<=' cannot be applied to types 'number' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. } } function f5(x: string) { diff --git a/tests/baselines/reference/errorForwardReferenceForwadingConstructor.js b/tests/baselines/reference/errorForwardReferenceForwadingConstructor.js index ed2e1aa7f06..27f05f3f8ea 100644 --- a/tests/baselines/reference/errorForwardReferenceForwadingConstructor.js +++ b/tests/baselines/reference/errorForwardReferenceForwadingConstructor.js @@ -12,11 +12,16 @@ class derived extends base { } //// [errorForwardReferenceForwadingConstructor.js] // Error forward referencing derived class with forwarding constructor -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function f() { var d1 = new derived(); var d2 = new derived(4); @@ -30,7 +35,7 @@ var base = (function () { var derived = (function (_super) { __extends(derived, _super); function derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return derived; }(base)); diff --git a/tests/baselines/reference/errorSuperCalls.js b/tests/baselines/reference/errorSuperCalls.js index 720894e50c0..ebe9de27f42 100644 --- a/tests/baselines/reference/errorSuperCalls.js +++ b/tests/baselines/reference/errorSuperCalls.js @@ -75,11 +75,16 @@ class OtherDerived extends OtherBase { //// [errorSuperCalls.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); //super call in class constructor with no base type var NoBase = (function () { function NoBase() { @@ -132,7 +137,7 @@ var Derived = (function (_super) { __extends(Derived, _super); //super call with type arguments function Derived() { - var _this; + var _this = this; _super.prototype..call(_this); _this = _super.call(this) || this; return _this; @@ -147,7 +152,7 @@ var OtherBase = (function () { var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; //super call in class member initializer of derived type _this.t = _this = _super.call(this) || this; return _this; diff --git a/tests/baselines/reference/errorSuperPropertyAccess.js b/tests/baselines/reference/errorSuperPropertyAccess.js index e12a758b053..b33755e245a 100644 --- a/tests/baselines/reference/errorSuperPropertyAccess.js +++ b/tests/baselines/reference/errorSuperPropertyAccess.js @@ -129,11 +129,16 @@ var obj = { n: super.wat, p: super.foo() }; //// [errorSuperPropertyAccess.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 //super property access in instance member accessor(get and set) of class with no base type @@ -247,7 +252,7 @@ var SomeDerived2 = (function (_super) { var SomeDerived3 = (function (_super) { __extends(SomeDerived3, _super); function SomeDerived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SomeDerived3.fn = function () { _super.publicStaticMember = 3; diff --git a/tests/baselines/reference/errorsInGenericTypeReference.js b/tests/baselines/reference/errorsInGenericTypeReference.js index 6dd9f62edcb..2e54d0cf71c 100644 --- a/tests/baselines/reference/errorsInGenericTypeReference.js +++ b/tests/baselines/reference/errorsInGenericTypeReference.js @@ -73,11 +73,16 @@ interface testInterface2 { //// [errorsInGenericTypeReference.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -135,7 +140,7 @@ var testClass6 = (function () { var testClass7 = (function (_super) { __extends(testClass7, _super); function testClass7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return testClass7; }(Foo)); // error: could not find symbol V diff --git a/tests/baselines/reference/es3-oldStyleOctalLiteralInEnums.errors.txt b/tests/baselines/reference/es3-oldStyleOctalLiteralInEnums.errors.txt new file mode 100644 index 00000000000..137b76f660d --- /dev/null +++ b/tests/baselines/reference/es3-oldStyleOctalLiteralInEnums.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/es3-oldStyleOctalLiteralInEnums.ts(2,7): error TS8018: Octal literals are not allowed in enums members initializer. Use the syntax '-0o1'. +tests/cases/compiler/es3-oldStyleOctalLiteralInEnums.ts(3,7): error TS8018: Octal literals are not allowed in enums members initializer. Use the syntax '0o2'. + + +==== tests/cases/compiler/es3-oldStyleOctalLiteralInEnums.ts (2 errors) ==== + enum E { + x = -01, + ~~~ +!!! error TS8018: Octal literals are not allowed in enums members initializer. Use the syntax '-0o1'. + y = 02, + ~~ +!!! error TS8018: Octal literals are not allowed in enums members initializer. Use the syntax '0o2'. + } \ No newline at end of file diff --git a/tests/baselines/reference/es3-oldStyleOctalLiteralInEnums.js b/tests/baselines/reference/es3-oldStyleOctalLiteralInEnums.js new file mode 100644 index 00000000000..0098d841f2a --- /dev/null +++ b/tests/baselines/reference/es3-oldStyleOctalLiteralInEnums.js @@ -0,0 +1,12 @@ +//// [es3-oldStyleOctalLiteralInEnums.ts] +enum E { + x = -01, + y = 02, +} + +//// [es3-oldStyleOctalLiteralInEnums.js] +var E; +(function (E) { + E[E["x"] = -1] = "x"; + E[E["y"] = 2] = "y"; +})(E || (E = {})); diff --git a/tests/baselines/reference/es3-oldStyleOctalLiteralTypes.errors.txt b/tests/baselines/reference/es3-oldStyleOctalLiteralTypes.errors.txt new file mode 100644 index 00000000000..5fc9843989c --- /dev/null +++ b/tests/baselines/reference/es3-oldStyleOctalLiteralTypes.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/es3-oldStyleOctalLiteralTypes.ts(1,8): error TS8017: Octal literal types must use ES2015 syntax. Use the syntax '0o10'. +tests/cases/compiler/es3-oldStyleOctalLiteralTypes.ts(2,8): error TS8017: Octal literal types must use ES2015 syntax. Use the syntax '-0o20'. + + +==== tests/cases/compiler/es3-oldStyleOctalLiteralTypes.ts (2 errors) ==== + let x: 010; + ~~~ +!!! error TS8017: Octal literal types must use ES2015 syntax. Use the syntax '0o10'. + let y: -020; + ~~~~ +!!! error TS8017: Octal literal types must use ES2015 syntax. Use the syntax '-0o20'. + \ No newline at end of file diff --git a/tests/baselines/reference/es3-oldStyleOctalLiteralTypes.js b/tests/baselines/reference/es3-oldStyleOctalLiteralTypes.js new file mode 100644 index 00000000000..5ac915400cd --- /dev/null +++ b/tests/baselines/reference/es3-oldStyleOctalLiteralTypes.js @@ -0,0 +1,8 @@ +//// [es3-oldStyleOctalLiteralTypes.ts] +let x: 010; +let y: -020; + + +//// [es3-oldStyleOctalLiteralTypes.js] +var x; +var y; diff --git a/tests/baselines/reference/es5-asyncFunctionBinaryExpressions.js b/tests/baselines/reference/es5-asyncFunctionBinaryExpressions.js index a7aff630256..23a79cef343 100644 --- a/tests/baselines/reference/es5-asyncFunctionBinaryExpressions.js +++ b/tests/baselines/reference/es5-asyncFunctionBinaryExpressions.js @@ -169,8 +169,7 @@ function binaryLogicalAnd1() { switch (_b.label) { case 0: _a = x; - if (!_a) - return [3 /*break*/, 2]; + if (!_a) return [3 /*break*/, 2]; return [4 /*yield*/, y]; case 1: _a = (_b.sent()); diff --git a/tests/baselines/reference/es5-asyncFunctionConditionals.js b/tests/baselines/reference/es5-asyncFunctionConditionals.js index b42b0c07b0a..e9fc995fc2d 100644 --- a/tests/baselines/reference/es5-asyncFunctionConditionals.js +++ b/tests/baselines/reference/es5-asyncFunctionConditionals.js @@ -32,8 +32,7 @@ function conditional1() { return __generator(this, function (_b) { switch (_b.label) { case 0: - if (!x) - return [3 /*break*/, 2]; + if (!x) return [3 /*break*/, 2]; return [4 /*yield*/, y]; case 1: _a = _b.sent(); @@ -54,8 +53,7 @@ function conditional2() { return __generator(this, function (_b) { switch (_b.label) { case 0: - if (!x) - return [3 /*break*/, 1]; + if (!x) return [3 /*break*/, 1]; _a = y; return [3 /*break*/, 3]; case 1: return [4 /*yield*/, z]; diff --git a/tests/baselines/reference/es5-asyncFunctionDoStatements.js b/tests/baselines/reference/es5-asyncFunctionDoStatements.js index 7151446dddf..32a7e9b0435 100644 --- a/tests/baselines/reference/es5-asyncFunctionDoStatements.js +++ b/tests/baselines/reference/es5-asyncFunctionDoStatements.js @@ -97,8 +97,7 @@ function doStatement1() { _a.sent(); _a.label = 2; case 2: - if (y) - return [3 /*break*/, 0]; + if (y) return [3 /*break*/, 0]; _a.label = 3; case 3: return [2 /*return*/]; } @@ -114,8 +113,7 @@ function doStatement2() { _a.label = 1; case 1: return [4 /*yield*/, y]; case 2: - if (_a.sent()) - return [3 /*break*/, 0]; + if (_a.sent()) return [3 /*break*/, 0]; _a.label = 3; case 3: return [2 /*return*/]; } @@ -141,8 +139,7 @@ function doStatement4() { _a.sent(); return [3 /*break*/, 2]; case 2: - if (y) - return [3 /*break*/, 0]; + if (y) return [3 /*break*/, 0]; _a.label = 3; case 3: return [2 /*return*/]; } @@ -161,8 +158,7 @@ function doStatement5() { _a.sent(); _a.label = 2; case 2: - if (y) - return [3 /*break*/, 0]; + if (y) return [3 /*break*/, 0]; _a.label = 3; case 3: return [2 /*return*/]; } @@ -176,8 +172,7 @@ function doStatement6() { case 0: return [3 /*break*/, 1]; case 1: return [4 /*yield*/, y]; case 2: - if (_a.sent()) - return [3 /*break*/, 0]; + if (_a.sent()) return [3 /*break*/, 0]; _a.label = 3; case 3: return [2 /*return*/]; } @@ -203,8 +198,7 @@ function doStatement8() { _a.sent(); return [3 /*break*/, 2]; case 2: - if (y) - return [3 /*break*/, 0]; + if (y) return [3 /*break*/, 0]; _a.label = 3; case 3: return [2 /*return*/]; } @@ -223,8 +217,7 @@ function doStatement9() { _a.sent(); _a.label = 2; case 2: - if (y) - return [3 /*break*/, 0]; + if (y) return [3 /*break*/, 0]; _a.label = 3; case 3: return [2 /*return*/]; } @@ -238,8 +231,7 @@ function doStatement10() { case 0: return [3 /*break*/, 1]; case 1: return [4 /*yield*/, y]; case 2: - if (_a.sent()) - return [3 /*break*/, 0]; + if (_a.sent()) return [3 /*break*/, 0]; _a.label = 3; case 3: return [2 /*return*/]; } @@ -265,8 +257,7 @@ function doStatement12() { _a.sent(); return [3 /*break*/, 3]; case 2: - if (y) - return [3 /*break*/, 0]; + if (y) return [3 /*break*/, 0]; _a.label = 3; case 3: return [2 /*return*/]; } @@ -285,8 +276,7 @@ function doStatement13() { _a.sent(); _a.label = 2; case 2: - if (y) - return [3 /*break*/, 0]; + if (y) return [3 /*break*/, 0]; _a.label = 3; case 3: return [2 /*return*/]; } @@ -300,8 +290,7 @@ function doStatement14() { case 0: return [3 /*break*/, 3]; case 1: return [4 /*yield*/, y]; case 2: - if (_a.sent()) - return [3 /*break*/, 0]; + if (_a.sent()) return [3 /*break*/, 0]; _a.label = 3; case 3: return [2 /*return*/]; } @@ -327,8 +316,7 @@ function doStatement16() { _a.sent(); return [3 /*break*/, 3]; case 2: - if (y) - return [3 /*break*/, 0]; + if (y) return [3 /*break*/, 0]; _a.label = 3; case 3: return [2 /*return*/]; } @@ -347,8 +335,7 @@ function doStatement17() { _a.sent(); _a.label = 2; case 2: - if (y) - return [3 /*break*/, 0]; + if (y) return [3 /*break*/, 0]; _a.label = 3; case 3: return [2 /*return*/]; } @@ -362,8 +349,7 @@ function doStatement18() { case 0: return [3 /*break*/, 3]; case 1: return [4 /*yield*/, y]; case 2: - if (_a.sent()) - return [3 /*break*/, 0]; + if (_a.sent()) return [3 /*break*/, 0]; _a.label = 3; case 3: return [2 /*return*/]; } diff --git a/tests/baselines/reference/es5-asyncFunctionForInStatements.js b/tests/baselines/reference/es5-asyncFunctionForInStatements.js index 30946fca56d..ec6bfbb97e1 100644 --- a/tests/baselines/reference/es5-asyncFunctionForInStatements.js +++ b/tests/baselines/reference/es5-asyncFunctionForInStatements.js @@ -62,8 +62,7 @@ function forInStatement1() { _i = 0; _c.label = 2; case 2: - if (!(_i < _a.length)) - return [3 /*break*/, 4]; + if (!(_i < _a.length)) return [3 /*break*/, 4]; x = _a[_i]; z; _c.label = 3; @@ -87,8 +86,7 @@ function forInStatement2() { _i = 0; _c.label = 1; case 1: - if (!(_i < _a.length)) - return [3 /*break*/, 4]; + if (!(_i < _a.length)) return [3 /*break*/, 4]; x = _a[_i]; return [4 /*yield*/, z]; case 2: @@ -114,8 +112,7 @@ function forInStatement3() { _i = 0; _c.label = 1; case 1: - if (!(_i < _a.length)) - return [3 /*break*/, 4]; + if (!(_i < _a.length)) return [3 /*break*/, 4]; return [4 /*yield*/, x]; case 2: (_c.sent()).a = _a[_i]; @@ -143,8 +140,7 @@ function forInStatement4() { _i = 0; _c.label = 2; case 2: - if (!(_i < _a.length)) - return [3 /*break*/, 4]; + if (!(_i < _a.length)) return [3 /*break*/, 4]; x.a = _a[_i]; z; _c.label = 3; @@ -168,8 +164,7 @@ function forInStatement5() { _i = 0; _c.label = 1; case 1: - if (!(_i < _a.length)) - return [3 /*break*/, 4]; + if (!(_i < _a.length)) return [3 /*break*/, 4]; x.a = _a[_i]; return [4 /*yield*/, z]; case 2: @@ -208,8 +203,7 @@ function forInStatement7() { _i = 0; _c.label = 2; case 2: - if (!(_i < _a.length)) - return [3 /*break*/, 4]; + if (!(_i < _a.length)) return [3 /*break*/, 4]; b = _a[_i]; z; _c.label = 3; @@ -233,8 +227,7 @@ function forInStatement8() { _i = 0; _c.label = 1; case 1: - if (!(_i < _a.length)) - return [3 /*break*/, 4]; + if (!(_i < _a.length)) return [3 /*break*/, 4]; c = _a[_i]; return [4 /*yield*/, z]; case 2: diff --git a/tests/baselines/reference/es5-asyncFunctionForOfStatements.js b/tests/baselines/reference/es5-asyncFunctionForOfStatements.js index e12f1e18d44..9cf1d0098b2 100644 --- a/tests/baselines/reference/es5-asyncFunctionForOfStatements.js +++ b/tests/baselines/reference/es5-asyncFunctionForOfStatements.js @@ -102,8 +102,7 @@ function forOfStatement1() { _a = _b.sent(); _b.label = 2; case 2: - if (!(_i < _a.length)) - return [3 /*break*/, 4]; + if (!(_i < _a.length)) return [3 /*break*/, 4]; x = _a[_i]; z; _b.label = 3; @@ -124,8 +123,7 @@ function forOfStatement2() { _i = 0, y_2 = y; _a.label = 1; case 1: - if (!(_i < y_2.length)) - return [3 /*break*/, 4]; + if (!(_i < y_2.length)) return [3 /*break*/, 4]; x = y_2[_i]; return [4 /*yield*/, z]; case 2: @@ -148,8 +146,7 @@ function forOfStatement3() { _i = 0, y_3 = y; _a.label = 1; case 1: - if (!(_i < y_3.length)) - return [3 /*break*/, 4]; + if (!(_i < y_3.length)) return [3 /*break*/, 4]; return [4 /*yield*/, x]; case 2: (_a.sent()).a = y_3[_i]; @@ -175,8 +172,7 @@ function forOfStatement4() { _a = _b.sent(); _b.label = 2; case 2: - if (!(_i < _a.length)) - return [3 /*break*/, 4]; + if (!(_i < _a.length)) return [3 /*break*/, 4]; x.a = _a[_i]; z; _b.label = 3; @@ -197,8 +193,7 @@ function forOfStatement5() { _i = 0, y_4 = y; _a.label = 1; case 1: - if (!(_i < y_4.length)) - return [3 /*break*/, 4]; + if (!(_i < y_4.length)) return [3 /*break*/, 4]; x.a = y_4[_i]; return [4 /*yield*/, z]; case 2: @@ -236,8 +231,7 @@ function forOfStatement7() { _a = _b.sent(); _b.label = 2; case 2: - if (!(_i < _a.length)) - return [3 /*break*/, 4]; + if (!(_i < _a.length)) return [3 /*break*/, 4]; c = _a[_i]; z; _b.label = 3; @@ -258,8 +252,7 @@ function forOfStatement8() { _i = 0, y_6 = y; _a.label = 1; case 1: - if (!(_i < y_6.length)) - return [3 /*break*/, 4]; + if (!(_i < y_6.length)) return [3 /*break*/, 4]; d = y_6[_i]; return [4 /*yield*/, z]; case 2: @@ -285,8 +278,7 @@ function forOfStatement9() { _a = _b.sent(); _b.label = 2; case 2: - if (!(_i < _a.length)) - return [3 /*break*/, 4]; + if (!(_i < _a.length)) return [3 /*break*/, 4]; x = _a[_i][0]; z; _b.label = 3; @@ -307,8 +299,7 @@ function forOfStatement10() { _i = 0, y_7 = y; _a.label = 1; case 1: - if (!(_i < y_7.length)) - return [3 /*break*/, 4]; + if (!(_i < y_7.length)) return [3 /*break*/, 4]; x = y_7[_i][0]; return [4 /*yield*/, z]; case 2: @@ -331,11 +322,9 @@ function forOfStatement11() { _i = 0, y_8 = y; _c.label = 1; case 1: - if (!(_i < y_8.length)) - return [3 /*break*/, 6]; + if (!(_i < y_8.length)) return [3 /*break*/, 6]; _b = y_8[_i][0]; - if (!(_b === void 0)) - return [3 /*break*/, 3]; + if (!(_b === void 0)) return [3 /*break*/, 3]; return [4 /*yield*/, a]; case 2: _a = _c.sent(); @@ -367,8 +356,7 @@ function forOfStatement12() { _a = _c.sent(); _c.label = 2; case 2: - if (!(_i < _a.length)) - return [3 /*break*/, 4]; + if (!(_i < _a.length)) return [3 /*break*/, 4]; _b = _a[_i][0], x = _b === void 0 ? a : _b; z; _c.label = 3; @@ -389,8 +377,7 @@ function forOfStatement13() { _i = 0, y_9 = y; _b.label = 1; case 1: - if (!(_i < y_9.length)) - return [3 /*break*/, 4]; + if (!(_i < y_9.length)) return [3 /*break*/, 4]; _a = y_9[_i][0], x = _a === void 0 ? a : _a; return [4 /*yield*/, z]; case 2: @@ -416,8 +403,7 @@ function forOfStatement14() { _a = _b.sent(); _b.label = 2; case 2: - if (!(_i < _a.length)) - return [3 /*break*/, 4]; + if (!(_i < _a.length)) return [3 /*break*/, 4]; x = _a[_i].x; z; _b.label = 3; @@ -438,8 +424,7 @@ function forOfStatement15() { _i = 0, y_10 = y; _a.label = 1; case 1: - if (!(_i < y_10.length)) - return [3 /*break*/, 4]; + if (!(_i < y_10.length)) return [3 /*break*/, 4]; x = y_10[_i].x; return [4 /*yield*/, z]; case 2: @@ -462,11 +447,9 @@ function forOfStatement16() { _i = 0, y_11 = y; _c.label = 1; case 1: - if (!(_i < y_11.length)) - return [3 /*break*/, 6]; + if (!(_i < y_11.length)) return [3 /*break*/, 6]; _b = y_11[_i].x; - if (!(_b === void 0)) - return [3 /*break*/, 3]; + if (!(_b === void 0)) return [3 /*break*/, 3]; return [4 /*yield*/, a]; case 2: _a = _c.sent(); @@ -498,8 +481,7 @@ function forOfStatement17() { _a = _c.sent(); _c.label = 2; case 2: - if (!(_i < _a.length)) - return [3 /*break*/, 4]; + if (!(_i < _a.length)) return [3 /*break*/, 4]; _b = _a[_i].x, x = _b === void 0 ? a : _b; z; _c.label = 3; @@ -520,8 +502,7 @@ function forOfStatement18() { _i = 0, y_12 = y; _b.label = 1; case 1: - if (!(_i < y_12.length)) - return [3 /*break*/, 4]; + if (!(_i < y_12.length)) return [3 /*break*/, 4]; _a = y_12[_i].x, x = _a === void 0 ? a : _a; return [4 /*yield*/, z]; case 2: diff --git a/tests/baselines/reference/es5-asyncFunctionForStatements.js b/tests/baselines/reference/es5-asyncFunctionForStatements.js index e02d20c7864..aad8a1f46ef 100644 --- a/tests/baselines/reference/es5-asyncFunctionForStatements.js +++ b/tests/baselines/reference/es5-asyncFunctionForStatements.js @@ -49,8 +49,7 @@ function forStatement1() { _a.sent(); _a.label = 2; case 2: - if (!y) - return [3 /*break*/, 4]; + if (!y) return [3 /*break*/, 4]; a; _a.label = 3; case 3: @@ -70,8 +69,7 @@ function forStatement2() { _a.label = 1; case 1: return [4 /*yield*/, y]; case 2: - if (!_a.sent()) - return [3 /*break*/, 4]; + if (!_a.sent()) return [3 /*break*/, 4]; a; _a.label = 3; case 3: @@ -90,8 +88,7 @@ function forStatement3() { x; _a.label = 1; case 1: - if (!y) - return [3 /*break*/, 4]; + if (!y) return [3 /*break*/, 4]; a; _a.label = 2; case 2: return [4 /*yield*/, z]; @@ -111,8 +108,7 @@ function forStatement4() { x; _a.label = 1; case 1: - if (!y) - return [3 /*break*/, 4]; + if (!y) return [3 /*break*/, 4]; return [4 /*yield*/, a]; case 2: _a.sent(); diff --git a/tests/baselines/reference/es5-asyncFunctionIfStatements.js b/tests/baselines/reference/es5-asyncFunctionIfStatements.js index 7ac35c995e7..39fc2ade726 100644 --- a/tests/baselines/reference/es5-asyncFunctionIfStatements.js +++ b/tests/baselines/reference/es5-asyncFunctionIfStatements.js @@ -36,8 +36,7 @@ function ifStatement2() { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (!x) - return [3 /*break*/, 2]; + if (!x) return [3 /*break*/, 2]; return [4 /*yield*/, y]; case 1: _a.sent(); @@ -55,8 +54,7 @@ function ifStatement3() { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (!x) - return [3 /*break*/, 1]; + if (!x) return [3 /*break*/, 1]; y; return [3 /*break*/, 3]; case 1: return [4 /*yield*/, z]; diff --git a/tests/baselines/reference/es5-asyncFunctionNestedLoops.js b/tests/baselines/reference/es5-asyncFunctionNestedLoops.js index 28ccc288b7e..36408e241a0 100644 --- a/tests/baselines/reference/es5-asyncFunctionNestedLoops.js +++ b/tests/baselines/reference/es5-asyncFunctionNestedLoops.js @@ -19,8 +19,7 @@ function nestedLoops() { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (!x) - return [3 /*break*/, 2]; + if (!x) return [3 /*break*/, 2]; return [4 /*yield*/, y]; case 1: _a.sent(); diff --git a/tests/baselines/reference/es5-asyncFunctionWhileStatements.js b/tests/baselines/reference/es5-asyncFunctionWhileStatements.js index c85aabb01e3..750673fb6c4 100644 --- a/tests/baselines/reference/es5-asyncFunctionWhileStatements.js +++ b/tests/baselines/reference/es5-asyncFunctionWhileStatements.js @@ -94,8 +94,7 @@ function whileStatement1() { switch (_a.label) { case 0: return [4 /*yield*/, x]; case 1: - if (!_a.sent()) - return [3 /*break*/, 2]; + if (!_a.sent()) return [3 /*break*/, 2]; y; return [3 /*break*/, 0]; case 2: return [2 /*return*/]; @@ -108,8 +107,7 @@ function whileStatement2() { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (!x) - return [3 /*break*/, 2]; + if (!x) return [3 /*break*/, 2]; return [4 /*yield*/, y]; case 1: _a.sent(); @@ -135,8 +133,7 @@ function whileStatement4() { switch (_a.label) { case 0: return [4 /*yield*/, x]; case 1: - if (!_a.sent()) - return [3 /*break*/, 2]; + if (!_a.sent()) return [3 /*break*/, 2]; return [3 /*break*/, 0]; case 2: return [2 /*return*/]; } @@ -148,8 +145,7 @@ function whileStatement5() { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (!x) - return [3 /*break*/, 2]; + if (!x) return [3 /*break*/, 2]; return [4 /*yield*/, y]; case 1: _a.sent(); @@ -164,8 +160,7 @@ function whileStatement6() { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (!x) - return [3 /*break*/, 2]; + if (!x) return [3 /*break*/, 2]; if (1) return [3 /*break*/, 0]; return [4 /*yield*/, y]; @@ -193,8 +188,7 @@ function whileStatement8() { switch (_a.label) { case 0: return [4 /*yield*/, x]; case 1: - if (!_a.sent()) - return [3 /*break*/, 2]; + if (!_a.sent()) return [3 /*break*/, 2]; return [3 /*break*/, 0]; case 2: return [2 /*return*/]; } @@ -206,8 +200,7 @@ function whileStatement9() { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (!x) - return [3 /*break*/, 2]; + if (!x) return [3 /*break*/, 2]; return [4 /*yield*/, y]; case 1: _a.sent(); @@ -222,8 +215,7 @@ function whileStatement10() { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (!x) - return [3 /*break*/, 2]; + if (!x) return [3 /*break*/, 2]; if (1) return [3 /*break*/, 0]; return [4 /*yield*/, y]; @@ -251,8 +243,7 @@ function whileStatement12() { switch (_a.label) { case 0: return [4 /*yield*/, x]; case 1: - if (!_a.sent()) - return [3 /*break*/, 2]; + if (!_a.sent()) return [3 /*break*/, 2]; return [3 /*break*/, 2]; case 2: return [2 /*return*/]; } @@ -264,8 +255,7 @@ function whileStatement13() { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (!x) - return [3 /*break*/, 2]; + if (!x) return [3 /*break*/, 2]; return [4 /*yield*/, y]; case 1: _a.sent(); @@ -280,8 +270,7 @@ function whileStatement14() { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (!x) - return [3 /*break*/, 2]; + if (!x) return [3 /*break*/, 2]; if (1) return [3 /*break*/, 2]; return [4 /*yield*/, y]; @@ -309,8 +298,7 @@ function whileStatement16() { switch (_a.label) { case 0: return [4 /*yield*/, x]; case 1: - if (!_a.sent()) - return [3 /*break*/, 2]; + if (!_a.sent()) return [3 /*break*/, 2]; return [3 /*break*/, 2]; case 2: return [2 /*return*/]; } @@ -322,8 +310,7 @@ function whileStatement17() { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (!x) - return [3 /*break*/, 2]; + if (!x) return [3 /*break*/, 2]; return [4 /*yield*/, y]; case 1: _a.sent(); @@ -338,8 +325,7 @@ function whileStatement18() { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (!x) - return [3 /*break*/, 2]; + if (!x) return [3 /*break*/, 2]; if (1) return [3 /*break*/, 2]; return [4 /*yield*/, y]; diff --git a/tests/baselines/reference/es5-oldStyleOctalLiteralInEnums.errors.txt b/tests/baselines/reference/es5-oldStyleOctalLiteralInEnums.errors.txt new file mode 100644 index 00000000000..a504568ce20 --- /dev/null +++ b/tests/baselines/reference/es5-oldStyleOctalLiteralInEnums.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/es5-oldStyleOctalLiteralInEnums.ts(2,7): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '-0o1'. +tests/cases/compiler/es5-oldStyleOctalLiteralInEnums.ts(3,7): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '0o2'. + + +==== tests/cases/compiler/es5-oldStyleOctalLiteralInEnums.ts (2 errors) ==== + enum E { + x = -01, + ~~~ +!!! error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '-0o1'. + y = 02, + ~~ +!!! error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '0o2'. + } \ No newline at end of file diff --git a/tests/baselines/reference/es5-oldStyleOctalLiteralInEnums.js b/tests/baselines/reference/es5-oldStyleOctalLiteralInEnums.js new file mode 100644 index 00000000000..71f718054fe --- /dev/null +++ b/tests/baselines/reference/es5-oldStyleOctalLiteralInEnums.js @@ -0,0 +1,12 @@ +//// [es5-oldStyleOctalLiteralInEnums.ts] +enum E { + x = -01, + y = 02, +} + +//// [es5-oldStyleOctalLiteralInEnums.js] +var E; +(function (E) { + E[E["x"] = -1] = "x"; + E[E["y"] = 2] = "y"; +})(E || (E = {})); diff --git a/tests/baselines/reference/es5-umd2.js b/tests/baselines/reference/es5-umd2.js index 592c5d63ffe..76333572abe 100644 --- a/tests/baselines/reference/es5-umd2.js +++ b/tests/baselines/reference/es5-umd2.js @@ -15,14 +15,15 @@ export class A //// [es5-umd2.js] -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { "use strict"; var A = (function () { function A() { diff --git a/tests/baselines/reference/es5-umd3.js b/tests/baselines/reference/es5-umd3.js index 7ac960d1d39..0689ef19da3 100644 --- a/tests/baselines/reference/es5-umd3.js +++ b/tests/baselines/reference/es5-umd3.js @@ -15,14 +15,15 @@ export default class A //// [es5-umd3.js] -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { "use strict"; var A = (function () { function A() { diff --git a/tests/baselines/reference/es5-umd4.js b/tests/baselines/reference/es5-umd4.js index b4034058dcd..ea3cba50ac0 100644 --- a/tests/baselines/reference/es5-umd4.js +++ b/tests/baselines/reference/es5-umd4.js @@ -17,14 +17,15 @@ export = A; //// [es5-umd4.js] -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { "use strict"; var A = (function () { function A() { diff --git a/tests/baselines/reference/es6-umd2.js b/tests/baselines/reference/es6-umd2.js index ed5ce4aacb8..dc094122d9d 100644 --- a/tests/baselines/reference/es6-umd2.js +++ b/tests/baselines/reference/es6-umd2.js @@ -14,14 +14,15 @@ export class A } //// [es6-umd2.js] -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { "use strict"; class A { constructor() { diff --git a/tests/baselines/reference/es6ClassSuperCodegenBug.js b/tests/baselines/reference/es6ClassSuperCodegenBug.js index 2eec250211e..1945726d218 100644 --- a/tests/baselines/reference/es6ClassSuperCodegenBug.js +++ b/tests/baselines/reference/es6ClassSuperCodegenBug.js @@ -15,11 +15,16 @@ class B extends A { //// [es6ClassSuperCodegenBug.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(str1, str2) { } @@ -28,7 +33,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - var _this; + var _this = this; if (true) { _this = _super.call(this, 'a1', 'b1') || this; } diff --git a/tests/baselines/reference/es6ClassTest.js b/tests/baselines/reference/es6ClassTest.js index 067e57c2581..9d66d2d8dc8 100644 --- a/tests/baselines/reference/es6ClassTest.js +++ b/tests/baselines/reference/es6ClassTest.js @@ -85,11 +85,16 @@ declare module AmbientMod { //// [es6ClassTest.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 533b332422d..e86d04bccd0 100644 --- a/tests/baselines/reference/es6ClassTest2.js +++ b/tests/baselines/reference/es6ClassTest2.js @@ -159,11 +159,16 @@ var ccwc = new ChildClassWithoutConstructor(1, "s"); //// [es6ClassTest2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var BasicMonster = (function () { function BasicMonster(name, health) { this.name = name; @@ -314,7 +319,7 @@ var BaseClassWithConstructor = (function () { var ChildClassWithoutConstructor = (function (_super) { __extends(ChildClassWithoutConstructor, _super); function ChildClassWithoutConstructor() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ChildClassWithoutConstructor; }(BaseClassWithConstructor)); diff --git a/tests/baselines/reference/es6ClassTest7.js b/tests/baselines/reference/es6ClassTest7.js index f786fce4461..8251d5ec476 100644 --- a/tests/baselines/reference/es6ClassTest7.js +++ b/tests/baselines/reference/es6ClassTest7.js @@ -9,15 +9,20 @@ class Bar extends M.Foo { //// [es6ClassTest7.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar; }(M.Foo)); diff --git a/tests/baselines/reference/exponentiationOperatorSyntaxError2.errors.txt b/tests/baselines/reference/exponentiationOperatorSyntaxError2.errors.txt index 134a883540e..1075c505794 100644 --- a/tests/baselines/reference/exponentiationOperatorSyntaxError2.errors.txt +++ b/tests/baselines/reference/exponentiationOperatorSyntaxError2.errors.txt @@ -1,19 +1,27 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(5,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(5,1): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(5,8): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(6,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(6,1): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(6,8): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(7,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(7,1): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(7,8): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(8,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(8,1): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(8,8): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(11,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(11,6): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(11,13): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(12,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(12,6): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(12,13): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(13,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(13,6): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(13,13): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(14,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(14,6): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(14,13): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(16,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(16,1): error TS17006: An unary expression with the 'typeof' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(17,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -34,15 +42,25 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxE tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(25,6): error TS17006: An unary expression with the 'typeof' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(26,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(26,6): error TS17006: An unary expression with the 'typeof' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(28,1): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(28,1): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(29,1): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(29,1): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(30,1): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(30,1): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(31,1): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(31,1): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(32,1): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(32,1): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(34,6): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(34,6): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(35,6): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(35,6): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(36,6): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(36,6): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(37,6): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(37,6): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(38,6): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(38,6): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(40,1): error TS17006: An unary expression with the '~' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(41,1): error TS17006: An unary expression with the '~' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. @@ -81,7 +99,7 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxE tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(68,1): error TS17007: A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. -==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts (81 errors) ==== +==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts (99 errors) ==== // Error: early syntax error using ES7 SimpleUnaryExpression on left-hand side without () var temp: any; @@ -91,21 +109,29 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxE !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference delete ++temp ** 3; ~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference delete temp-- ** 3; ~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference delete temp++ ** 3; ~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference 1 ** delete --temp ** 3; @@ -113,21 +139,29 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxE !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference 1 ** delete ++temp ** 3; ~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference 1 ** delete temp-- ** 3; ~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference 1 ** delete temp++ ** 3; ~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference typeof --temp ** 3; ~~~~~~~~~~~~~ @@ -183,34 +217,54 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxE void --temp ** 3; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. void temp-- ** 3; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. void 3 ** 4; ~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. void temp++ ** 4; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. void temp-- ** 4; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. 1 ** void --temp ** 3; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. 1 ** void temp-- ** 3; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. 1 ** void 3 ** 4; ~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. 1 ** void temp++ ** 4; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. 1 ** void temp-- ** 4 ; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. ~ --temp ** 3; diff --git a/tests/baselines/reference/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.errors.txt b/tests/baselines/reference/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.errors.txt index f43cbd0042a..b643a71c5c8 100644 --- a/tests/baselines/reference/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.errors.txt +++ b/tests/baselines/reference/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.errors.txt @@ -19,16 +19,24 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInv tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(25,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(26,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(28,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(28,9): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(29,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(29,9): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(30,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(30,9): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(31,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(31,9): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(33,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(33,14): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(34,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(34,14): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(35,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(35,14): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(36,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(36,14): error TS2703: The operand of a delete operator must be a property reference -==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts (28 errors) ==== +==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts (36 errors) ==== var temp: any; // Error: incorrect type on left-hand side @@ -99,25 +107,41 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInv (delete --temp) ** 3; ~~~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference (delete ++temp) ** 3; ~~~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference (delete temp--) ** 3; ~~~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference (delete temp++) ** 3; ~~~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference 1 ** (delete --temp) ** 3; ~~~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference 1 ** (delete ++temp) ** 3; ~~~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference 1 ** (delete temp--) ** 3; ~~~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference 1 ** (delete temp++) ** 3; ~~~~~~~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference \ No newline at end of file diff --git a/tests/baselines/reference/exponentiationOperatorWithNullValueAndInvalidOperands.errors.txt b/tests/baselines/reference/exponentiationOperatorWithNullValueAndInvalidOperands.errors.txt index 99535985628..2d0b76f28cc 100644 --- a/tests/baselines/reference/exponentiationOperatorWithNullValueAndInvalidOperands.errors.txt +++ b/tests/baselines/reference/exponentiationOperatorWithNullValueAndInvalidOperands.errors.txt @@ -1,27 +1,27 @@ -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(9,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(9,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(9,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(10,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(10,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(10,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(11,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(11,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(11,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(13,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(13,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(13,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(14,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(14,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(14,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(15,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(15,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(17,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(15,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(17,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(17,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(18,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(18,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(18,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(19,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(19,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(19,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(21,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(21,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(21,20): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(22,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(22,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(22,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(23,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(23,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(23,18): error TS2531: Object is possibly 'null'. ==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts (24 errors) ==== @@ -35,17 +35,17 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNul // operator ** var r1a1 = null ** a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a2 = null ** b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a3 = null ** c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -53,31 +53,31 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNul ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1b2 = b ** null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1b3 = c ** null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1c1 = null ** true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c2 = null ** ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c3 = null ** {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -85,14 +85,14 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNul ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1d2 = '' ** null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1d3 = {} ** null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/exponentiationOperatorWithNullValueAndValidOperands.errors.txt b/tests/baselines/reference/exponentiationOperatorWithNullValueAndValidOperands.errors.txt new file mode 100644 index 00000000000..c8a462c0f54 --- /dev/null +++ b/tests/baselines/reference/exponentiationOperatorWithNullValueAndValidOperands.errors.txt @@ -0,0 +1,47 @@ +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(13,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(14,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(15,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(16,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(17,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(18,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(19,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(20,17): error TS2531: Object is possibly 'null'. + + +==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts (8 errors) ==== + // If one operand is the null or undefined value, it is treated as having the type of the + // other operand. + + enum E { + a, + b + } + + var a: any; + var b: number; + + // operator ** + var r1 = null ** a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2 = null ** b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3 = null ** 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4 = null ** E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r5 = a ** null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r6 = b ** null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r7 = 0 ** null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r8 = E.b ** null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.errors.txt b/tests/baselines/reference/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.errors.txt index 86f4930e77c..20b004625ca 100644 --- a/tests/baselines/reference/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.errors.txt +++ b/tests/baselines/reference/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.errors.txt @@ -1,33 +1,33 @@ -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(2,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(2,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(3,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(3,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(4,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(4,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(5,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(5,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(2,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(2,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(3,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(3,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(4,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(4,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(5,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(5,23): error TS2532: Object is possibly 'undefined'. ==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts (8 errors) ==== // operator ** var r1 = null ** null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r2 = null ** undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r3 = undefined ** null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r4 = undefined ** undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndInvalidOperands.errors.txt b/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndInvalidOperands.errors.txt index f456e0f554f..ce14298d02d 100644 --- a/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndInvalidOperands.errors.txt +++ b/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndInvalidOperands.errors.txt @@ -1,27 +1,27 @@ -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(9,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(9,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(9,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(10,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(10,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(10,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(11,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(11,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(11,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(13,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(13,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(13,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(14,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(14,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(14,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(15,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(15,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(17,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(15,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(17,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(17,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(18,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(18,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(18,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(19,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(19,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(19,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(21,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(21,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(21,20): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(22,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(22,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(22,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(23,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(23,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(23,18): error TS2532: Object is possibly 'undefined'. ==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts (24 errors) ==== @@ -35,17 +35,17 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUnd // operator ** var r1a1 = undefined ** a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a2 = undefined ** b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a3 = undefined ** c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -53,31 +53,31 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUnd ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1b2 = b ** undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1b3 = c ** undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1c1 = undefined ** true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c2 = undefined ** ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c3 = undefined ** {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -85,14 +85,14 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUnd ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1d2 = '' ** undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1d3 = {} ** undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndValidOperands.errors.txt b/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndValidOperands.errors.txt new file mode 100644 index 00000000000..ce9843a9612 --- /dev/null +++ b/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndValidOperands.errors.txt @@ -0,0 +1,47 @@ +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(13,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(14,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(15,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(16,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(17,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(18,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(19,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(20,18): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts (8 errors) ==== + // If one operand is the undefined or undefined value, it is treated as having the type of the + // other operand. + + enum E { + a, + b + } + + var a: any; + var b: number; + + // operator * + var rk1 = undefined ** a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk2 = undefined ** b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk3 = undefined ** 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk4 = undefined ** E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk5 = a ** undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk6 = b ** undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk7 = 0 ** undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk8 = E.b ** undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/exportAssignmentOfGenericType1.js b/tests/baselines/reference/exportAssignmentOfGenericType1.js index 7c1831ecac4..bab7c815f19 100644 --- a/tests/baselines/reference/exportAssignmentOfGenericType1.js +++ b/tests/baselines/reference/exportAssignmentOfGenericType1.js @@ -24,17 +24,22 @@ define(["require", "exports"], function (require, exports) { return T; }); //// [exportAssignmentOfGenericType1_1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); define(["require", "exports", "exportAssignmentOfGenericType1_0"], function (require, exports, q) { "use strict"; var M = (function (_super) { __extends(M, _super); function M() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return M; }(q)); diff --git a/tests/baselines/reference/exportDeclarationInInternalModule.js b/tests/baselines/reference/exportDeclarationInInternalModule.js index b6d6d982a32..dde865bd2c7 100644 --- a/tests/baselines/reference/exportDeclarationInInternalModule.js +++ b/tests/baselines/reference/exportDeclarationInInternalModule.js @@ -19,11 +19,16 @@ var a: Bbb.SomeType; //// [exportDeclarationInInternalModule.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Bbb = (function () { function Bbb() { } @@ -32,7 +37,7 @@ var Bbb = (function () { var Aaa = (function (_super) { __extends(Aaa, _super); function Aaa() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Aaa; }(Bbb)); diff --git a/tests/baselines/reference/exportEqualsUmd.js b/tests/baselines/reference/exportEqualsUmd.js index 500c8795dc7..2201f2b8407 100644 --- a/tests/baselines/reference/exportEqualsUmd.js +++ b/tests/baselines/reference/exportEqualsUmd.js @@ -2,14 +2,15 @@ export = { ["hi"]: "there" }; //// [exportEqualsUmd.js] -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { "use strict"; var _a; return _a = {}, _a["hi"] = "there", _a; diff --git a/tests/baselines/reference/exportNonInitializedVariablesUMD.js b/tests/baselines/reference/exportNonInitializedVariablesUMD.js index 5cbf6d381b0..796818c650c 100644 --- a/tests/baselines/reference/exportNonInitializedVariablesUMD.js +++ b/tests/baselines/reference/exportNonInitializedVariablesUMD.js @@ -35,14 +35,15 @@ export let h1: D = new D; //// [exportNonInitializedVariablesUMD.js] -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { "use strict"; var ; let; diff --git a/tests/baselines/reference/exportStarForValues10.js b/tests/baselines/reference/exportStarForValues10.js index 3da80002780..f7dd6e94ce5 100644 --- a/tests/baselines/reference/exportStarForValues10.js +++ b/tests/baselines/reference/exportStarForValues10.js @@ -42,8 +42,7 @@ System.register(["file0"], function (exports_1, context_1) { function exportStar_1(m) { var exports = {}; for (var n in m) { - if (n !== "default") - exports[n] = m[n]; + if (n !== "default") exports[n] = m[n]; } exports_1(exports); } diff --git a/tests/baselines/reference/extBaseClass1.js b/tests/baselines/reference/extBaseClass1.js index 91dfba7a9bf..6cf7b42962e 100644 --- a/tests/baselines/reference/extBaseClass1.js +++ b/tests/baselines/reference/extBaseClass1.js @@ -20,11 +20,16 @@ module N { //// [extBaseClass1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { var B = (function () { @@ -37,7 +42,7 @@ var M; var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); @@ -47,7 +52,7 @@ var M; var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(M.B)); @@ -58,7 +63,7 @@ var N; var C3 = (function (_super) { __extends(C3, _super); function C3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C3; }(M.B)); diff --git a/tests/baselines/reference/extBaseClass2.js b/tests/baselines/reference/extBaseClass2.js index 3ab217eb019..7ef8adec3df 100644 --- a/tests/baselines/reference/extBaseClass2.js +++ b/tests/baselines/reference/extBaseClass2.js @@ -11,17 +11,22 @@ module M { //// [extBaseClass2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var N; (function (N) { var C4 = (function (_super) { __extends(C4, _super); function C4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C4; }(M.B)); @@ -32,7 +37,7 @@ var M; var C5 = (function (_super) { __extends(C5, _super); function C5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C5; }(B)); diff --git a/tests/baselines/reference/extendAndImplementTheSameBaseType.js b/tests/baselines/reference/extendAndImplementTheSameBaseType.js index 74bbf3a27ac..d2942220bf1 100644 --- a/tests/baselines/reference/extendAndImplementTheSameBaseType.js +++ b/tests/baselines/reference/extendAndImplementTheSameBaseType.js @@ -14,11 +14,16 @@ d.baz(); d.foo; //// [extendAndImplementTheSameBaseType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -28,7 +33,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.baz = function () { }; return D; diff --git a/tests/baselines/reference/extendAndImplementTheSameBaseType2.js b/tests/baselines/reference/extendAndImplementTheSameBaseType2.js index fa7963487d5..40b3425966e 100644 --- a/tests/baselines/reference/extendAndImplementTheSameBaseType2.js +++ b/tests/baselines/reference/extendAndImplementTheSameBaseType2.js @@ -17,11 +17,16 @@ var r3: string = d.bar(); var r4: number = d.bar(); //// [extendAndImplementTheSameBaseType2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -33,7 +38,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.baz = function () { }; return D; diff --git a/tests/baselines/reference/extendBaseClassBeforeItsDeclared.js b/tests/baselines/reference/extendBaseClassBeforeItsDeclared.js index 596ab319b2c..28c9ef2f22e 100644 --- a/tests/baselines/reference/extendBaseClassBeforeItsDeclared.js +++ b/tests/baselines/reference/extendBaseClassBeforeItsDeclared.js @@ -4,15 +4,20 @@ class derived extends base { } class base { constructor (public n: number) { } } //// [extendBaseClassBeforeItsDeclared.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var derived = (function (_super) { __extends(derived, _super); function derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return derived; }(base)); diff --git a/tests/baselines/reference/extendClassExpressionFromModule.js b/tests/baselines/reference/extendClassExpressionFromModule.js index 895cdedfaff..7353c6970e8 100644 --- a/tests/baselines/reference/extendClassExpressionFromModule.js +++ b/tests/baselines/reference/extendClassExpressionFromModule.js @@ -21,17 +21,22 @@ var x = (function () { module.exports = x; //// [foo2.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var foo1 = require("./foo1"); var x = foo1; var y = (function (_super) { __extends(y, _super); function y() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return y; }(x)); diff --git a/tests/baselines/reference/extendConstructSignatureInInterface.js b/tests/baselines/reference/extendConstructSignatureInInterface.js index 4bf92dd0315..3067fdc706e 100644 --- a/tests/baselines/reference/extendConstructSignatureInInterface.js +++ b/tests/baselines/reference/extendConstructSignatureInInterface.js @@ -11,16 +11,21 @@ var e: E = new E(1); //// [extendConstructSignatureInInterface.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var CStatic; var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(CStatic)); diff --git a/tests/baselines/reference/extendNonClassSymbol1.js b/tests/baselines/reference/extendNonClassSymbol1.js index b23b601bc29..b4e59aa9711 100644 --- a/tests/baselines/reference/extendNonClassSymbol1.js +++ b/tests/baselines/reference/extendNonClassSymbol1.js @@ -4,11 +4,16 @@ var x = A; class C extends x { } // error, could not find symbol xs //// [extendNonClassSymbol1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -19,7 +24,7 @@ var x = A; var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(x)); // error, could not find symbol xs diff --git a/tests/baselines/reference/extendNonClassSymbol2.js b/tests/baselines/reference/extendNonClassSymbol2.js index 78dfaa91827..f029193175f 100644 --- a/tests/baselines/reference/extendNonClassSymbol2.js +++ b/tests/baselines/reference/extendNonClassSymbol2.js @@ -6,11 +6,16 @@ var x = new Foo(); // legal, considered a constructor function class C extends Foo {} // error, could not find symbol Foo //// [extendNonClassSymbol2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function Foo() { this.x = 1; } @@ -18,7 +23,7 @@ var x = new Foo(); // legal, considered a constructor function var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(Foo)); // error, could not find symbol Foo diff --git a/tests/baselines/reference/extendPrivateConstructorClass.js b/tests/baselines/reference/extendPrivateConstructorClass.js index 8893e9735ff..12540d9cd38 100644 --- a/tests/baselines/reference/extendPrivateConstructorClass.js +++ b/tests/baselines/reference/extendPrivateConstructorClass.js @@ -10,15 +10,20 @@ class C extends abc.XYZ { //// [extendPrivateConstructorClass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(abc.XYZ)); diff --git a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js index da081154d8a..2d1add18ae0 100644 --- a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js +++ b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js @@ -42,32 +42,42 @@ var Model = (function () { exports.Model = Model; //// [extendingClassFromAliasAndUsageInIndexer_moduleA.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); exports.VisualizationModel = VisualizationModel; //// [extendingClassFromAliasAndUsageInIndexer_moduleB.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); diff --git a/tests/baselines/reference/extendsClauseAlreadySeen.js b/tests/baselines/reference/extendsClauseAlreadySeen.js index 267cd86eed0..f6e43d5ddc6 100644 --- a/tests/baselines/reference/extendsClauseAlreadySeen.js +++ b/tests/baselines/reference/extendsClauseAlreadySeen.js @@ -7,11 +7,16 @@ class D extends C extends C { } //// [extendsClauseAlreadySeen.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -20,7 +25,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.baz = function () { }; return D; diff --git a/tests/baselines/reference/extendsClauseAlreadySeen2.js b/tests/baselines/reference/extendsClauseAlreadySeen2.js index 76fbc3365af..99bccf44479 100644 --- a/tests/baselines/reference/extendsClauseAlreadySeen2.js +++ b/tests/baselines/reference/extendsClauseAlreadySeen2.js @@ -7,11 +7,16 @@ class D extends C extends C { } //// [extendsClauseAlreadySeen2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -20,7 +25,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.baz = function () { }; return D; diff --git a/tests/baselines/reference/fixSignatureCaching.errors.txt b/tests/baselines/reference/fixSignatureCaching.errors.txt index 6677afc174a..7a5c43c966e 100644 --- a/tests/baselines/reference/fixSignatureCaching.errors.txt +++ b/tests/baselines/reference/fixSignatureCaching.errors.txt @@ -1,4 +1,3 @@ -tests/cases/conformance/fixSignatureCaching.ts(3,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/fixSignatureCaching.ts(9,10): error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. tests/cases/conformance/fixSignatureCaching.ts(284,10): error TS2339: Property 'detectMobileBrowsers' does not exist on type '{}'. tests/cases/conformance/fixSignatureCaching.ts(293,10): error TS2339: Property 'FALLBACK_PHONE' does not exist on type '{}'. @@ -62,7 +61,6 @@ tests/cases/conformance/fixSignatureCaching.ts(961,57): error TS2339: Property ' tests/cases/conformance/fixSignatureCaching.ts(964,22): error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. tests/cases/conformance/fixSignatureCaching.ts(968,18): error TS2339: Property '_impl' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. tests/cases/conformance/fixSignatureCaching.ts(970,18): error TS2339: Property 'version' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. -tests/cases/conformance/fixSignatureCaching.ts(974,4): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/fixSignatureCaching.ts(975,16): error TS2304: Cannot find name 'module'. tests/cases/conformance/fixSignatureCaching.ts(975,42): error TS2304: Cannot find name 'module'. tests/cases/conformance/fixSignatureCaching.ts(976,37): error TS2304: Cannot find name 'module'. @@ -73,2128 +71,1131 @@ tests/cases/conformance/fixSignatureCaching.ts(979,23): error TS2304: Cannot fin tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot find name 'window'. -==== tests/cases/conformance/fixSignatureCaching.ts (73 errors) ==== +==== tests/cases/conformance/fixSignatureCaching.ts (71 errors) ==== // Repro from #10697 (function (define, undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ define(function () { - ~~~~~~~~~~~~~~~~~~~~ 'use strict'; - ~~~~~~~~~~~~~~~~~ - var impl = {}; - ~~~~~~~~~~~~~~~~~~ - impl.mobileDetectRules = { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. "phones": { - ~~~~~~~~~~~~~~~ "iPhone": "\\biPhone\\b|\\biPod\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerry": "BlackBerry|\\bBB10\\b|rim[0-9]+", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "HTC": "HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\\bEVO\\b|T-Mobile G1|Z520m", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Nexus": "Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Dell": "Dell.*Streak|Dell.*Aero|Dell.*Venue|DELL.*Venue Pro|Dell Flash|Dell Smoke|Dell Mini 3iX|XCD28|XCD35|\\b001DL\\b|\\b101DL\\b|\\bGS01\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Motorola": "Motorola|DROIDX|DROID BIONIC|\\bDroid\\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\\bMoto E\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Samsung": "Samsung|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205|SM-G9350|SM-J120F", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "LG": "\\bLG\\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Sony": "SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Asus": "Asus.*Galaxy|PadFone.*Mobile", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NokiaLumia": "Lumia [0-9]{3,4}", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Micromax": "Micromax.*\\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Palm": "PalmSource|Palm", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Vertu": "Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Pantech": "PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Fly": "IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Wiko": "KITE 4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX 4G|RAINBOW|BLOOM|SUNSET|GOA(?!nna)|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|CINK KING|CINK PEAX|CINK SLIM|SUBLIM", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iMobile": "i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SimValley": "\\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Wolfgang": "AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Alcatel": "Alcatel", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Nintendo": "Nintendo 3DS", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Amoi": "Amoi", - ~~~~~~~~~~~~~~~~~~~~~~~ "INQ": "INQ", - ~~~~~~~~~~~~~~~~~~~~~ "GenericPhone": "Tapatalk|PDA;|SAGEM|\\bmmp\\b|pocket|\\bpsp\\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\\bwap\\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~ "tablets": { - ~~~~~~~~~~~~~~~~ "iPad": "iPad|iPad.*Mobile", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NexusTablet": "Android.*Nexus[\\s]+(7|9|10)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SamsungTablet": "SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Kindle": "Kindle|Silk.*Accelerated|Android.*\\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SurfaceTablet": "Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "HPTablet": "HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AsusTablet": "^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\\bK00F\\b|\\bK00C\\b|\\bK00E\\b|\\bK00L\\b|TX201LA|ME176C|ME102A|\\bM80TA\\b|ME372CL|ME560CG|ME372CG|ME302KL| K010 | K017 |ME572C|ME103K|ME170C|ME171C|\\bME70C\\b|ME581C|ME581CL|ME8510C|ME181C|P01Y|PO1MA", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerryTablet": "PlayBook|RIM Tablet", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "HTCtablet": "HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MotorolaTablet": "xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NookTablet": "Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AcerTablet": "Android.*; \\b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\\b|W3-810|\\bA3-A10\\b|\\bA3-A11\\b|\\bA3-A20", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ToshibaTablet": "Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "LGTablet": "\\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "FujitsuTablet": "Android.*\\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PrestigioTablet": "PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "LenovoTablet": "Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DellTablet": "Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "YarvikTablet": "Android.*\\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MedionTablet": "Android.*\\bOYO\\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ArnovaTablet": "AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IntensoTablet": "INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IRUTablet": "M702pro", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MegafonTablet": "MegaFon V9|\\bZTE V9\\b|Android.*\\bMT7A\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "EbodaTablet": "E-Boda (Supreme|Impresspeed|Izzycomm|Essential)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AllViewTablet": "Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ArchosTablet": "\\b(101G9|80G9|A101IT)\\b|Qilive 97R|Archos5|\\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|)(G10| Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AinolTablet": "NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NokiaLumiaTablet": "Lumia 2520", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SonyTablet": "Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551|SGP621|SGP612|SOT31", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PhilipsTablet": "\\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CubeTablet": "Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CobyTablet": "MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MIDTablet": "M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733|MID4X10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MSITablet": "MSI \\b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SMiTTablet": "Android.*(\\bMID\\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "RockChipTablet": "Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "FlyTablet": "IQ310|Fly Vision", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "bqTablet": "Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris E10)|Maxwell.*Lite|Maxwell.*Plus", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "HuaweiTablet": "MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NecTablet": "\\bN-06D|\\bN-08D", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PantechTablet": "Pantech.*P4100", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BronchoTablet": "Broncho.*(N701|N708|N802|a710)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "VersusTablet": "TOUCHPAD.*[78910]|\\bTOUCHTAB\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ZyncTablet": "z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PositivoTablet": "TB07STA|TB10STA|TB07FTA|TB10FTA", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NabiTablet": "Android.*\\bNabi", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "KoboTablet": "Kobo Touch|\\bK080\\b|\\bVox\\b Build|\\bArc\\b Build", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DanewTablet": "DSlide.*\\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TexetTablet": "NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PlaystationTablet": "Playstation.*(Portable|Vita)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TrekstorTablet": "ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PyleAudioTablet": "\\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AdvanTablet": "Android.* \\b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\\b ", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DanyTechTablet": "Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB GII|Genius TAB GIII|Genius Tab S1", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "GalapadTablet": "Android.*\\bG1\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MicromaxTablet": "Funbook|Micromax.*\\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "KarbonnTablet": "Android.*\\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AllFineTablet": "Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PROSCANTablet": "\\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "YONESTablet": "BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ChangJiaTablet": "TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "GUTablet": "TX-A1301|TX-M9002|Q702|kf026", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PointOfViewTablet": "TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "OvermaxTablet": "OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "HCLTablet": "HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DPSTablet": "DPS Dream 9|DPS Dual 7", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "VistureTablet": "V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CrestaTablet": "CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MediatekTablet": "\\bMT8125|MT8389|MT8135|MT8377\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ConcordeTablet": "Concorde([ ]+)?Tab|ConCorde ReadMan", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "GoCleverTablet": "GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ModecomTablet": "FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "VoninoTablet": "\\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\\bQ8\\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ECSTablet": "V07OT2|TM105A|S10OT1|TR10CS1", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "StorexTablet": "eZee[_']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "VodafoneTablet": "SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "EssentielBTablet": "Smart[ ']?TAB[ ]+?[0-9]+|Family[ ']?TAB2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "RossMoorTablet": "RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iMobileTablet": "i-mobile i-note", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TolinoTablet": "tolino tab [0-9.]+|tolino shine", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AudioSonicTablet": "\\bC-22Q|T7-QC|T-17B|T-17P\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AMPETablet": "Android.* A78 ", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SkkTablet": "Android.* (SKYPAD|PHOENIX|CYCLOPS)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TecnoTablet": "TECNO P9", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "JXDTablet": "Android.* \\b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iJoyTablet": "Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "FX2Tablet": "FX2 PAD7|FX2 PAD10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "XoroTablet": "KidsPAD 701|PAD[ ]?712|PAD[ ]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|PAD[ ]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[ ]?9718DR|PAD[ ]?9719QR|PAD[ ]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|TelePAD795|MegaPAD 1331|MegaPAD 1851|MegaPAD 2151", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ViewsonicTablet": "ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "OdysTablet": "LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\\bXELIO\\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CaptivaTablet": "CAPTIVA PAD", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IconbitTablet": "NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TeclastTablet": "T98 4G|\\bP80\\b|\\bX90HD\\b|X98 Air|X98 Air 3G|\\bX89\\b|P80 3G|\\bX80h\\b|P98 Air|\\bX89HD\\b|P98 3G|\\bP90HD\\b|P89 3G|X98 3G|\\bP70h\\b|P79HD 3G|G18d 3G|\\bP79HD\\b|\\bP89s\\b|\\bA88\\b|\\bP10HD\\b|\\bP19HD\\b|G18 3G|\\bP78HD\\b|\\bA78\\b|\\bP75\\b|G17s 3G|G17h 3G|\\bP85t\\b|\\bP90\\b|\\bP11\\b|\\bP98t\\b|\\bP98HD\\b|\\bG18d\\b|\\bP85s\\b|\\bP11HD\\b|\\bP88s\\b|\\bA80HD\\b|\\bA80se\\b|\\bA10h\\b|\\bP89\\b|\\bP78s\\b|\\bG18\\b|\\bP85\\b|\\bA70h\\b|\\bA70\\b|\\bG17\\b|\\bP18\\b|\\bA80s\\b|\\bA11s\\b|\\bP88HD\\b|\\bA80h\\b|\\bP76s\\b|\\bP76h\\b|\\bP98\\b|\\bA10HD\\b|\\bP78\\b|\\bP88\\b|\\bA11\\b|\\bA10t\\b|\\bP76a\\b|\\bP76t\\b|\\bP76e\\b|\\bP85HD\\b|\\bP85a\\b|\\bP86\\b|\\bP75HD\\b|\\bP76v\\b|\\bA12\\b|\\bP75a\\b|\\bA15\\b|\\bP76Ti\\b|\\bP81HD\\b|\\bA10\\b|\\bT760VE\\b|\\bT720HD\\b|\\bP76\\b|\\bP73\\b|\\bP71\\b|\\bP72\\b|\\bT720SE\\b|\\bC520Ti\\b|\\bT760\\b|\\bT720VE\\b|T720-3GE|T720-WiFi", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "OndaTablet": "\\b(V975i|Vi30|VX530|V701|Vi60|V701s|Vi50|V801s|V719|Vx610w|VX610W|V819i|Vi10|VX580W|Vi10|V711s|V813|V811|V820w|V820|Vi20|V711|VI30W|V712|V891w|V972|V819w|V820w|Vi60|V820w|V711|V813s|V801|V819|V975s|V801|V819|V819|V818|V811|V712|V975m|V101w|V961w|V812|V818|V971|V971s|V919|V989|V116w|V102w|V973|Vi40)\\b[\\s]+", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "JaytechTablet": "TPC-PA762", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlaupunktTablet": "Endeavour 800NG|Endeavour 1010", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DigmaTablet": "\\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "EvolioTablet": "ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\\bEvotab\\b|\\bNeura\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "LavaTablet": "QPAD E704|\\bIvoryS\\b|E-TAB IVORY|\\bE-TAB\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AocTablet": "MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MpmanTablet": "MP11 OCTA|MP10 OCTA|MPQC1114|MPQC1004|MPQC994|MPQC974|MPQC973|MPQC804|MPQC784|MPQC780|\\bMPG7\\b|MPDCG75|MPDCG71|MPDC1006|MP101DC|MPDC9000|MPDC905|MPDC706HD|MPDC706|MPDC705|MPDC110|MPDC100|MPDC99|MPDC97|MPDC88|MPDC8|MPDC77|MP709|MID701|MID711|MID170|MPDC703|MPQC1010", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CelkonTablet": "CT695|CT888|CT[\\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\\bCT-1\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "WolderTablet": "miTab \\b(DIAMOND|SPACE|BROOKLYN|NEO|FLY|MANHATTAN|FUNK|EVOLUTION|SKY|GOCAR|IRON|GENIUS|POP|MINT|EPSILON|BROADWAY|JUMP|HOP|LEGEND|NEW AGE|LINE|ADVANCE|FEEL|FOLLOW|LIKE|LINK|LIVE|THINK|FREEDOM|CHICAGO|CLEVELAND|BALTIMORE-GH|IOWA|BOSTON|SEATTLE|PHOENIX|DALLAS|IN 101|MasterChef)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MiTablet": "\\bMI PAD\\b|\\bHM NOTE 1W\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NibiruTablet": "Nibiru M1|Nibiru Jupiter One", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NexoTablet": "NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "LeaderTablet": "TBLT10Q|TBLT10I|TBL-10WDKB|TBL-10WDKBO2013|TBL-W230V2|TBL-W450|TBL-W500|SV572|TBLT7I|TBA-AC7-8G|TBLT79|TBL-8W16|TBL-10W32|TBL-10WKB|TBL-W100", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "UbislateTablet": "UbiSlate[\\s]?7C", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PocketBookTablet": "Pocketbook", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "KocasoTablet": "\\b(TB-1207)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Hudl": "Hudl HT7S3|Hudl 2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TelstraTablet": "T-Hub2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "GenericTablet": "Android.*\\b97D\\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\\bA7EB\\b|CatNova8|A1_07|CT704|CT1002|\\bM721\\b|rk30sdk|\\bEVOTAB\\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\\bM6pro\\b|CT1020W|arc 10HD|\\bJolla\\b|\\bTP750\\b" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~ "oss": { - ~~~~~~~~~~~~ "AndroidOS": "Android", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerryOS": "blackberry|\\bBB10\\b|rim tablet os", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PalmOS": "PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SymbianOS": "Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\\bS60\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "WindowsMobileOS": "Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "WindowsPhoneOS": "Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iOS": "\\biPhone.*Mobile|\\biPod|\\biPad", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MeeGoOS": "MeeGo", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MaemoOS": "Maemo", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "JavaOS": "J2ME\/|\\bMIDP\\b|\\bCLDC\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "webOS": "webOS|hpwOS", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "badaOS": "\\bBada\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BREWOS": "BREW" - ~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~ "uas": { - ~~~~~~~~~~~~ "Vivaldi": "Vivaldi", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Chrome": "\\bCrMo\\b|CriOS|Android.*Chrome\/[.0-9]* (Mobile)?", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Dolfin": "\\bDolfin\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Opera": "Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR\/[0-9.]+|Coast\/[0-9.]+", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Skyfire": "Skyfire", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Edge": "Mobile Safari\/[.0-9]* Edge", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IE": "IEMobile|MSIEMobile", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Firefox": "fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Bolt": "bolt", - ~~~~~~~~~~~~~~~~~~~~~~~ "TeaShark": "teashark", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Blazer": "Blazer", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Safari": "Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Tizen": "Tizen", - ~~~~~~~~~~~~~~~~~~~~~~~~~ "UCBrowser": "UC.*Browser|UCWEB", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "baiduboxapp": "baiduboxapp", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "baidubrowser": "baidubrowser", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DiigoBrowser": "DiigoBrowser", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Puffin": "Puffin", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Mercury": "\\bMercury\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ObigoBrowser": "Obigo", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NetFront": "NF-Browser", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "GenericBrowser": "NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PaleMoon": "Android.*PaleMoon|Mobile.*PaleMoon" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~ "props": { - ~~~~~~~~~~~~~~ "Mobile": "Mobile\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Build": "Build\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Version": "Version\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "VendorID": "VendorID\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iPad": "iPad.*CPU[a-z ]+[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iPhone": "iPhone.*CPU[a-z ]+[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iPod": "iPod.*CPU[a-z ]+[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Kindle": "Kindle\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Chrome": [ - ~~~~~~~~~~~~~~~~~~~ "Chrome\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CriOS\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CrMo\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "Coast": [ - ~~~~~~~~~~~~~~~~~~ "Coast\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "Dolfin": "Dolfin\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Firefox": "Firefox\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Fennec": "Fennec\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Edge": "Edge\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IE": [ - ~~~~~~~~~~~~~~~ "IEMobile\/[VER];", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IEMobile [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MSIE [VER];", - ~~~~~~~~~~~~~~~~~~~~~~~~~~ "Trident\/[0-9.]+;.*rv:[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "NetFront": "NetFront\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NokiaBrowser": "NokiaBrowser\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Opera": [ - ~~~~~~~~~~~~~~~~~~ " OPR\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~ "Opera Mini\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Version\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "Opera Mini": "Opera Mini\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Opera Mobi": "Version\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "UC Browser": "UC Browser[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MQQBrowser": "MQQBrowser\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MicroMessenger": "MicroMessenger\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "baiduboxapp": "baiduboxapp\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "baidubrowser": "baidubrowser\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Iron": "Iron\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Safari": [ - ~~~~~~~~~~~~~~~~~~~ "Version\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Safari\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "Skyfire": "Skyfire\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Tizen": "Tizen\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Webkit": "webkit[ \/][VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PaleMoon": "PaleMoon\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Gecko": "Gecko\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Trident": "Trident\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Presto": "Presto\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Goanna": "Goanna\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iOS": " \\bi?OS\\b [VER][ ;]{1}", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Android": "Android [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerry": [ - ~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerry[\\w]+\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerry.*Version\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Version\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "BREW": "BREW [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Java": "Java\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Windows Phone OS": [ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Windows Phone OS [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Windows Phone [VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "Windows Phone": "Windows Phone [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Windows CE": "Windows CE\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Windows NT": "Windows NT [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Symbian": [ - ~~~~~~~~~~~~~~~~~~~~ "SymbianOS\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Symbian\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "webOS": [ - ~~~~~~~~~~~~~~~~~~ "webOS\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "hpwOS\/[VER];" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ] - ~~~~~~~~~ }, - ~~~~~~ "utils": { - ~~~~~~~~~~~~~~ "Bot": "Googlebot|facebookexternalhit|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MobileBot": "Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker\/M1A1-R2D2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DesktopMode": "WPDesktop", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TV": "SonyDTV|HbbTV", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "WebKit": "(webkit)[ \/]([\\w.]+)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Console": "\\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Watch": "SM-V700" - ~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ }; - ~~ - // following patterns come from http://detectmobilebrowsers.com/ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ impl.detectMobileBrowsers = { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'detectMobileBrowsers' does not exist on type '{}'. fullPattern: /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ shortPattern: /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tabletPattern: /android|ipad|playbook|silk/i - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - var hasOwnProp = Object.prototype.hasOwnProperty, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ isArray; - ~~~~~~~~~~~~~~~~ - impl.FALLBACK_PHONE = 'UnknownPhone'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_PHONE' does not exist on type '{}'. impl.FALLBACK_TABLET = 'UnknownTablet'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_TABLET' does not exist on type '{}'. impl.FALLBACK_MOBILE = 'UnknownMobile'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_MOBILE' does not exist on type '{}'. - isArray = ('isArray' in Array) ? - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Array.isArray : function (value) { return Object.prototype.toString.call(value) === '[object Array]'; }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - function equalIC(a, b) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return a != null && b != null && a.toLowerCase() === b.toLowerCase(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ - function containsIC(array, value) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var valueLC, i, len = array.length; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (!len || !value) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return false; - ~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ valueLC = value.toLowerCase(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (i = 0; i < len; ++i) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (valueLC === array[i].toLowerCase()) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return true; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ return false; - ~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ - function convertPropsToRegExp(object) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (var key in object) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (hasOwnProp.call(object, key)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ object[key] = new RegExp(object[key], 'i'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ } - ~~~~~ - (function init() { - ~~~~~~~~~~~~~~~~~~~~~~ var key, values, value, i, len, verPos, mobileDetectRules = impl.mobileDetectRules; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. for (key in mobileDetectRules.props) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (hasOwnProp.call(mobileDetectRules.props, key)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ values = mobileDetectRules.props[key]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (!isArray(values)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ values = [values]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~ len = values.length; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (i = 0; i < len; ++i) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = values[i]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ verPos = value.indexOf('[VER]'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (verPos >= 0) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = value.substring(0, verPos) + '([\\w._\\+]+)' + value.substring(verPos + 5); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~~~~~ values[i] = new RegExp(value, 'i'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~ mobileDetectRules.props[key] = values; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ convertPropsToRegExp(mobileDetectRules.oss); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ convertPropsToRegExp(mobileDetectRules.phones); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ convertPropsToRegExp(mobileDetectRules.tablets); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ convertPropsToRegExp(mobileDetectRules.uas); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ convertPropsToRegExp(mobileDetectRules.utils); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // copy some patterns to oss0 which are tested first (see issue#15) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mobileDetectRules.oss0 = { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WindowsPhoneOS: mobileDetectRules.oss.WindowsPhoneOS, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WindowsMobileOS: mobileDetectRules.oss.WindowsMobileOS - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~~~~~ }()); - ~~~~~~~~~ - /** - ~~~~~~~ * Test userAgent string against a set of rules and find the first matched key. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {Object} rules (key is String, value is RegExp) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {String} userAgent the navigator.userAgent (or HTTP-Header 'User-Agent'). - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {String|null} the matched key if found, otherwise null - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @private - ~~~~~~~~~~~~~~~ */ - ~~~~~~~ impl.findMatch = function(rules, userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. for (var key in rules) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (hasOwnProp.call(rules, key)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (rules[key].test(userAgent)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return key; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ return null; - ~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - /** - ~~~~~~~ * Test userAgent string against a set of rules and return an array of matched keys. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {Object} rules (key is String, value is RegExp) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {String} userAgent the navigator.userAgent (or HTTP-Header 'User-Agent'). - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {Array} an array of matched keys, may be empty when there is no match, but not null - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @private - ~~~~~~~~~~~~~~~ */ - ~~~~~~~ impl.findMatches = function(rules, userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2339: Property 'findMatches' does not exist on type '{}'. var result = []; - ~~~~~~~~~~~~~~~~~~~~~~~~ for (var key in rules) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (hasOwnProp.call(rules, key)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (rules[key].test(userAgent)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ result.push(key); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ return result; - ~~~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - /** - ~~~~~~~ * Check the version of the given property in the User-Agent. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~ * @param {String} propertyName - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {String} userAgent - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @return {String} version or null if version not found - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @private - ~~~~~~~~~~~~~~~ */ - ~~~~~~~ impl.getVersionStr = function (propertyName, userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2339: Property 'getVersionStr' does not exist on type '{}'. var props = impl.mobileDetectRules.props, patterns, i, len, match; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. if (hasOwnProp.call(props, propertyName)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ patterns = props[propertyName]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ len = patterns.length; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (i = 0; i < len; ++i) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ match = patterns[i].exec(userAgent); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (match !== null) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return match[1]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ return null; - ~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - /** - ~~~~~~~ * Check the version of the given property in the User-Agent. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~ * @param {String} propertyName - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {String} userAgent - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @return {Number} version or NaN if version not found - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @private - ~~~~~~~~~~~~~~~ */ - ~~~~~~~ impl.getVersion = function (propertyName, userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ !!! error TS2339: Property 'getVersion' does not exist on type '{}'. var version = impl.getVersionStr(propertyName, userAgent); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2339: Property 'getVersionStr' does not exist on type '{}'. return version ? impl.prepareVersionNo(version) : NaN; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareVersionNo' does not exist on type '{}'. }; - ~~~~~~ - /** - ~~~~~~~ * Prepare the version number. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~ * @param {String} version - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @return {Number} the version number as a floating number - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @private - ~~~~~~~~~~~~~~~ */ - ~~~~~~~ impl.prepareVersionNo = function (version) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareVersionNo' does not exist on type '{}'. var numbers; - ~~~~~~~~~~~~~~~~~~~~ - numbers = version.split(/[a-z._ \/\-]/i); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (numbers.length === 1) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ version = numbers[0]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ if (numbers.length > 1) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ version = numbers[0] + '.'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ numbers.shift(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ version += numbers.join(''); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ return Number(version); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - impl.isMobileFallback = function (userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'isMobileFallback' does not exist on type '{}'. return impl.detectMobileBrowsers.fullPattern.test(userAgent) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'detectMobileBrowsers' does not exist on type '{}'. impl.detectMobileBrowsers.shortPattern.test(userAgent.substr(0,4)); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'detectMobileBrowsers' does not exist on type '{}'. }; - ~~~~~~ - impl.isTabletFallback = function (userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'isTabletFallback' does not exist on type '{}'. return impl.detectMobileBrowsers.tabletPattern.test(userAgent); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'detectMobileBrowsers' does not exist on type '{}'. }; - ~~~~~~ - impl.prepareDetectionCache = function (cache, userAgent, maxPhoneWidth) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. if (cache.mobile !== undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return; - ~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ var phone, tablet, phoneSized; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // first check for stronger tablet rules, then phone (see issue#5) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tablet = impl.findMatch(impl.mobileDetectRules.tablets, userAgent); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. if (tablet) { - ~~~~~~~~~~~~~~~~~~~~~ cache.mobile = cache.tablet = tablet; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cache.phone = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return; // unambiguously identified as tablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ - phone = impl.findMatch(impl.mobileDetectRules.phones, userAgent); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. if (phone) { - ~~~~~~~~~~~~~~~~~~~~ cache.mobile = cache.phone = phone; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cache.tablet = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return; // unambiguously identified as phone - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ - // our rules haven't found a match -> try more general fallback rules - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (impl.isMobileFallback(userAgent)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'isMobileFallback' does not exist on type '{}'. phoneSized = MobileDetect.isPhoneSized(maxPhoneWidth); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ !!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. if (phoneSized === undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cache.mobile = impl.FALLBACK_MOBILE; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_MOBILE' does not exist on type '{}'. cache.tablet = cache.phone = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else if (phoneSized) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cache.mobile = cache.phone = impl.FALLBACK_PHONE; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_PHONE' does not exist on type '{}'. cache.tablet = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else { - ~~~~~~~~~~~~~~~~~~~~ cache.mobile = cache.tablet = impl.FALLBACK_TABLET; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_TABLET' does not exist on type '{}'. cache.phone = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } else if (impl.isTabletFallback(userAgent)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'isTabletFallback' does not exist on type '{}'. cache.mobile = cache.tablet = impl.FALLBACK_TABLET; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_TABLET' does not exist on type '{}'. cache.phone = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else { - ~~~~~~~~~~~~~~~~ // not mobile at all! - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cache.mobile = cache.tablet = cache.phone = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ }; - ~~~~~~ - // t is a reference to a MobileDetect instance - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ impl.mobileGrade = function (t) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2339: Property 'mobileGrade' does not exist on type '{}'. // impl note: - ~~~~~~~~~~~~~~~~~~~~~ // To keep in sync w/ Mobile_Detect.php easily, the following code is tightly aligned to the PHP version. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // When changes are made in Mobile_Detect.php, copy this method and replace: - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // $this-> / t. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ // self::MOBILE_GRADE_(.) / '$1' - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // , self::VERSION_TYPE_FLOAT / (nothing) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // isIOS() / os('iOS') - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // [reg] / (nothing) <-- jsdelivr complaining about unescaped unicode character U+00AE - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var $isMobile = t.mobile() !== null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - if ( - ~~~~~~~~~~~~ // Apple iOS 3.2-5.1 - Tested on the original iPad (4.3 / 5.0), iPad 2 (4.3), iPad 3 (5.1), original iPhone (3.1), iPhone 3 (3.2), 3GS (4.3), 4 (4.3 / 5.0), and 4S (5.1) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.os('iOS') && t.version('iPad')>=4.3 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.os('iOS') && t.version('iPhone')>=3.1 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.os('iOS') && t.version('iPod')>=3.1 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Android 2.1-2.3 - Tested on the HTC Incredible (2.2), original Droid (2.2), HTC Aria (2.1), Google Nexus S (2.3). Functional on 1.5 & 1.6 but performance may be sluggish, tested on Google G1 (1.5) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.version('Android')>2.1 && t.is('Webkit') ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Windows Phone 7-7.5 - Tested on the HTC Surround (7.0) HTC Trophy (7.5), LG-E900 (7.5), Nokia Lumia 800 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Windows Phone OS')>=7.0 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Blackberry 7 - Tested on BlackBerry Torch 9810 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Blackberry 6.0 - Tested on the Torch 9800 and Style 9670 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('BlackBerry') && t.version('BlackBerry')>=6.0 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Blackberry Playbook (1.0-2.0) - Tested on PlayBook - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.match('Playbook.*Tablet') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Palm WebOS (1.4-2.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.version('webOS')>=1.4 && t.match('Palm|Pre|Pixi') ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Palm WebOS 3.0 - Tested on HP TouchPad - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.match('hp.*TouchPad') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Firefox Mobile (12 Beta) - Tested on Android 2.3 device - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.is('Firefox') && t.version('Firefox')>=12 ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Chrome for Android - Tested on Android 4.0, 4.1 device - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.is('Chrome') && t.is('AndroidOS') && t.version('Android')>=4.0 ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Skyfire 4.1 - Tested on Android 2.3 device - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.is('Skyfire') && t.version('Skyfire')>=4.1 && t.is('AndroidOS') && t.version('Android')>=2.3 ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Opera Mobile 11.5-12: Tested on Android 2.3 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.is('Opera') && t.version('Opera Mobi')>11 && t.is('AndroidOS') ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Meego 1.2 - Tested on Nokia 950 and N9 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('MeeGoOS') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Tizen (pre-release) - Tested on early hardware - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('Tizen') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @todo: more tests here! - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('Dolfin') && t.version('Bada')>=2.0 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // UC Browser - Tested on Android 2.3 device - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( (t.is('UC Browser') || t.is('Dolfin')) && t.version('Android')>=2.3 ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Kindle 3 and Fire - Tested on the built-in WebKit browser for each - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.match('Kindle Fire') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('Kindle') && t.version('Kindle')>=3.0 ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('AndroidOS') && t.is('NookTablet') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Chrome Desktop 11-21 - Tested on OS X 10.7 and Windows 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Chrome')>=11 && !$isMobile || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Safari Desktop 4-5 - Tested on OS X 10.7 and Windows 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Safari')>=5.0 && !$isMobile || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Firefox Desktop 4-13 - Tested on OS X 10.7 and Windows 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Firefox')>=4.0 && !$isMobile || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('MSIE')>=7.0 && !$isMobile || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @reference: http://my.opera.com/community/openweb/idopera/ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Opera')>=10 && !$isMobile - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ){ - ~~~~~~~~~~~~~~ return 'A'; - ~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ - if ( - ~~~~~~~~~~~~ t.os('iOS') && t.version('iPad')<4.3 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.os('iOS') && t.version('iPhone')<3.1 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.os('iOS') && t.version('iPod')<3.1 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('Blackberry') && t.version('BlackBerry')>=5 && t.version('BlackBerry')<6 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.version('Opera Mini')>=5.0 && t.version('Opera Mini')<=6.5 && - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (t.version('Android')>=2.3 || t.is('iOS')) ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // @todo: report this (tested on Nokia N71) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Opera Mobi')>=11 && t.is('SymbianOS') - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ){ - ~~~~~~~~~~~~~~ return 'B'; - ~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ - if ( - ~~~~~~~~~~~~ // Blackberry 4.x - Tested on the Curve 8330 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('BlackBerry')<5.0 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Windows Mobile - Tested on the HTC Leo (WinMo 5.2) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.match('MSIEMobile|Windows CE.*Mobile') || t.version('Windows Mobile')<=5.2 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ){ - ~~~~~~~~~~~~~~ return 'C'; - ~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ - //All older smartphone platforms and featurephones - Any device that doesn't support media queries - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //will receive the basic, C grade experience. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return 'C'; - ~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - impl.detectOS = function (ua) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ !!! error TS2339: Property 'detectOS' does not exist on type '{}'. return impl.findMatch(impl.mobileDetectRules.oss0, ua) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. impl.findMatch(impl.mobileDetectRules.oss, ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. }; - ~~~~~~ - impl.getDeviceSmallerSide = function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'getDeviceSmallerSide' does not exist on type '{}'. return window.screen.width < window.screen.height ? - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. ~~~~~~ !!! error TS2304: Cannot find name 'window'. window.screen.width : - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. window.screen.height; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. }; - ~~~~~~ - /** - ~~~~~~~ * Constructor for MobileDetect object. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~ * Such an object will keep a reference to the given user-agent string and cache most of the detect queries.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Find information how to download and install: - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * github.com/hgoebl/mobile-detect.js/ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~ * - ~~~~~~ * @example
-    ~~~~~~~~~~~~~~~~~~~~~
          *     var md = new MobileDetect(window.navigator.userAgent);
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          *     if (md.mobile()) {
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          *         location.href = (md.mobileGrade() === 'A') ? '/mobile/' : '/lynx/';
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          *     }
-    ~~~~~~~~~~~~
          * 
- ~~~~~~~~~~~~~ * - ~~~~~~ * @param {string} userAgent typically taken from window.navigator.userAgent or http_header['User-Agent'] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {number} [maxPhoneWidth=600] only for browsers specify a value for the maximum - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * width of smallest device side (in logical "CSS" pixels) until a device detected as mobile will be handled - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * as phone. - ~~~~~~~~~~~~~~~~~~~~~~~ * This is only used in cases where the device cannot be classified as phone or tablet.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * See Declaring Tablet Layouts - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * for Android.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * If you provide a value < 0, then this "fuzzy" check is disabled. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @constructor - ~~~~~~~~~~~~~~~~~~~ * @global - ~~~~~~~~~~~~~~ */ - ~~~~~~~ function MobileDetect(userAgent, maxPhoneWidth) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this.ua = userAgent || ''; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this._cache = {}; - ~~~~~~~~~~~~~~~~~~~~~~~~~ //600dp is typical 7" tablet minimum width - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this.maxPhoneWidth = maxPhoneWidth || 600; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ - MobileDetect.prototype = { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ constructor: MobileDetect, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the detected phone or tablet type or null if it is not a mobile device. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * For a list of possible return values see {@link MobileDetect#phone} and {@link MobileDetect#tablet}.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * If the device is not detected by the regular expressions from Mobile-Detect, a test is made against - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * the patterns of detectmobilebrowsers.com. If this test - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * is positive, a value of UnknownPhone, UnknownTablet or - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * UnknownMobile is returned.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * When used in browser, the decision whether phone or tablet is made based on screen.width/height.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * When used server-side (node.js), there is no way to tell the difference between UnknownTablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * and UnknownMobile, so you will get UnknownMobile here.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Be aware that since v1.0.0 in this special case you will get UnknownMobile only for: - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * {@link MobileDetect#mobile}, not for {@link MobileDetect#phone} and {@link MobileDetect#tablet}. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * In versions before v1.0.0 all 3 methods returned UnknownMobile which was tedious to use. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * In most cases you will use the return value just as a boolean. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the key for the phone family or tablet family, e.g. "Nexus". - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#mobile - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ mobile: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ impl.prepareDetectionCache(this._cache, this.ua, this.maxPhoneWidth); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. return this._cache.mobile; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the detected phone type/family string or null. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * The returned tablet (family or producer) is one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
iPhone, BlackBerry, HTC, Nexus, Dell, Motorola, Samsung, LG, Sony, Asus, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * NokiaLumia, Micromax, Palm, Vertu, Pantech, Fly, Wiko, iMobile, SimValley, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Wolfgang, Alcatel, Nintendo, Amoi, INQ, GenericPhone
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * If the device is not detected by the regular expressions from Mobile-Detect, a test is made against - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * the patterns of detectmobilebrowsers.com. If this test - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * is positive, a value of UnknownPhone or UnknownMobile is returned.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * When used in browser, the decision whether phone or tablet is made based on screen.width/height.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * When used server-side (node.js), there is no way to tell the difference between UnknownTablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * and UnknownMobile, so you will get null here, while {@link MobileDetect#mobile} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * will return UnknownMobile.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Be aware that since v1.0.0 in this special case you will get UnknownMobile only for: - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * {@link MobileDetect#mobile}, not for {@link MobileDetect#phone} and {@link MobileDetect#tablet}. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * In versions before v1.0.0 all 3 methods returned UnknownMobile which was tedious to use. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * In most cases you will use the return value just as a boolean. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the key of the phone family or producer, e.g. "iPhone" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#phone - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ phone: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ impl.prepareDetectionCache(this._cache, this.ua, this.maxPhoneWidth); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. return this._cache.phone; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the detected tablet type/family string or null. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * The returned tablet (family or producer) is one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
iPad, NexusTablet, SamsungTablet, Kindle, SurfaceTablet, HPTablet, AsusTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * BlackBerryTablet, HTCtablet, MotorolaTablet, NookTablet, AcerTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ToshibaTablet, LGTablet, FujitsuTablet, PrestigioTablet, LenovoTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * DellTablet, YarvikTablet, MedionTablet, ArnovaTablet, IntensoTablet, IRUTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * MegafonTablet, EbodaTablet, AllViewTablet, ArchosTablet, AinolTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * NokiaLumiaTablet, SonyTablet, PhilipsTablet, CubeTablet, CobyTablet, MIDTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * MSITablet, SMiTTablet, RockChipTablet, FlyTablet, bqTablet, HuaweiTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * NecTablet, PantechTablet, BronchoTablet, VersusTablet, ZyncTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * PositivoTablet, NabiTablet, KoboTablet, DanewTablet, TexetTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * PlaystationTablet, TrekstorTablet, PyleAudioTablet, AdvanTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * DanyTechTablet, GalapadTablet, MicromaxTablet, KarbonnTablet, AllFineTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * PROSCANTablet, YONESTablet, ChangJiaTablet, GUTablet, PointOfViewTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * OvermaxTablet, HCLTablet, DPSTablet, VistureTablet, CrestaTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * MediatekTablet, ConcordeTablet, GoCleverTablet, ModecomTablet, VoninoTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ECSTablet, StorexTablet, VodafoneTablet, EssentielBTablet, RossMoorTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * iMobileTablet, TolinoTablet, AudioSonicTablet, AMPETablet, SkkTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * TecnoTablet, JXDTablet, iJoyTablet, FX2Tablet, XoroTablet, ViewsonicTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * OdysTablet, CaptivaTablet, IconbitTablet, TeclastTablet, OndaTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * JaytechTablet, BlaupunktTablet, DigmaTablet, EvolioTablet, LavaTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * AocTablet, MpmanTablet, CelkonTablet, WolderTablet, MiTablet, NibiruTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * NexoTablet, LeaderTablet, UbislateTablet, PocketBookTablet, KocasoTablet, Hudl, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * TelstraTablet, GenericTablet
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * If the device is not detected by the regular expressions from Mobile-Detect, a test is made against - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * the patterns of detectmobilebrowsers.com. If this test - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * is positive, a value of UnknownTablet or UnknownMobile is returned.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * When used in browser, the decision whether phone or tablet is made based on screen.width/height.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * When used server-side (node.js), there is no way to tell the difference between UnknownTablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * and UnknownMobile, so you will get null here, while {@link MobileDetect#mobile} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * will return UnknownMobile.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Be aware that since v1.0.0 in this special case you will get UnknownMobile only for: - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * {@link MobileDetect#mobile}, not for {@link MobileDetect#phone} and {@link MobileDetect#tablet}. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * In versions before v1.0.0 all 3 methods returned UnknownMobile which was tedious to use. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * In most cases you will use the return value just as a boolean. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the key of the tablet family or producer, e.g. "SamsungTablet" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#tablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ tablet: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ impl.prepareDetectionCache(this._cache, this.ua, this.maxPhoneWidth); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. return this._cache.tablet; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the (first) detected user-agent string or null. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * The returned user-agent is one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Vivaldi, Chrome, Dolfin, Opera, Skyfire, Edge, IE, Firefox, Bolt, TeaShark, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Blazer, Safari, Tizen, UCBrowser, baiduboxapp, baidubrowser, DiigoBrowser, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Puffin, Mercury, ObigoBrowser, NetFront, GenericBrowser, PaleMoon
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * In most cases calling {@link MobileDetect#userAgent} will be sufficient. But there are rare - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * cases where a mobile device pretends to be more than one particular browser. You can get the - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * list of all matches with {@link MobileDetect#userAgents} or check for a particular value by - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * providing one of the defined keys as first argument to {@link MobileDetect#is}. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the key for the detected user-agent or null - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#userAgent - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ userAgent: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this._cache.userAgent === undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this._cache.userAgent = impl.findMatch(impl.mobileDetectRules.uas, this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. } - ~~~~~~~~~~~~~ return this._cache.userAgent; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns all detected user-agent strings. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * The array is empty or contains one or more of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Vivaldi, Chrome, Dolfin, Opera, Skyfire, Edge, IE, Firefox, Bolt, TeaShark, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Blazer, Safari, Tizen, UCBrowser, baiduboxapp, baidubrowser, DiigoBrowser, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Puffin, Mercury, ObigoBrowser, NetFront, GenericBrowser, PaleMoon
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * In most cases calling {@link MobileDetect#userAgent} will be sufficient. But there are rare - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * cases where a mobile device pretends to be more than one particular browser. You can get the - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * list of all matches with {@link MobileDetect#userAgents} or check for a particular value by - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * providing one of the defined keys as first argument to {@link MobileDetect#is}. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {Array} the array of detected user-agent keys or [] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#userAgents - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ userAgents: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this._cache.userAgents === undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this._cache.userAgents = impl.findMatches(impl.mobileDetectRules.uas, this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2339: Property 'findMatches' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. } - ~~~~~~~~~~~~~ return this._cache.userAgents; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the detected operating system string or null. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * The operating system is one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
AndroidOS, BlackBerryOS, PalmOS, SymbianOS, WindowsMobileOS, WindowsPhoneOS, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * iOS, MeeGoOS, MaemoOS, JavaOS, webOS, badaOS, BREWOS
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the key for the detected operating system. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#os - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ os: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~ if (this._cache.os === undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this._cache.os = impl.detectOS(this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ !!! error TS2339: Property 'detectOS' does not exist on type '{}'. } - ~~~~~~~~~~~~~ return this._cache.os; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Get the version (as Number) of the given property in the User-Agent. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @param {String} key a key defining a thing which has a version.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * You can use one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Mobile, Build, Version, VendorID, iPad, iPhone, iPod, Kindle, Chrome, Coast, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Dolfin, Firefox, Fennec, Edge, IE, NetFront, NokiaBrowser, Opera, Opera Mini, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Opera Mobi, UC Browser, MQQBrowser, MicroMessenger, baiduboxapp, baidubrowser, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Iron, Safari, Skyfire, Tizen, Webkit, PaleMoon, Gecko, Trident, Presto, Goanna, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * iOS, Android, BlackBerry, BREW, Java, Windows Phone OS, Windows Phone, Windows - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * CE, Windows NT, Symbian, webOS
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {Number} the version as float or NaN if User-Agent doesn't contain this version. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Be careful when comparing this value with '==' operator! - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#version - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ version: function (key) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return impl.getVersion(key, this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ !!! error TS2339: Property 'getVersion' does not exist on type '{}'. }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Get the version (as String) of the given property in the User-Agent. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @param {String} key a key defining a thing which has a version.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * You can use one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Mobile, Build, Version, VendorID, iPad, iPhone, iPod, Kindle, Chrome, Coast, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Dolfin, Firefox, Fennec, Edge, IE, NetFront, NokiaBrowser, Opera, Opera Mini, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Opera Mobi, UC Browser, MQQBrowser, MicroMessenger, baiduboxapp, baidubrowser, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Iron, Safari, Skyfire, Tizen, Webkit, PaleMoon, Gecko, Trident, Presto, Goanna, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * iOS, Android, BlackBerry, BREW, Java, Windows Phone OS, Windows Phone, Windows - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * CE, Windows NT, Symbian, webOS
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the "raw" version as String or null if User-Agent doesn't contain this version. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @function MobileDetect#versionStr - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ versionStr: function (key) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return impl.getVersionStr(key, this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2339: Property 'getVersionStr' does not exist on type '{}'. }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Global test key against userAgent, os, phone, tablet and some other properties of userAgent string. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @param {String} key the key (case-insensitive) of a userAgent, an operating system, phone or - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * tablet family.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * For a complete list of possible values, see {@link MobileDetect#userAgent}, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * {@link MobileDetect#os}, {@link MobileDetect#phone}, {@link MobileDetect#tablet}.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Additionally you have following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Bot, MobileBot, DesktopMode, TV, WebKit, Console, Watch
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {boolean} true when the given key is one of the defined keys of userAgent, os, phone, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * tablet or one of the listed additional keys, otherwise false - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#is - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ is: function (key) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return containsIC(this.userAgents(), key) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ equalIC(key, this.os()) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ equalIC(key, this.phone()) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ equalIC(key, this.tablet()) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ containsIC(impl.findMatches(impl.mobileDetectRules.utils, this.ua), key); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2339: Property 'findMatches' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Do a quick test against navigator::userAgent. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @param {String|RegExp} pattern the pattern, either as String or RegExp - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * (a string will be converted to a case-insensitive RegExp). - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {boolean} true when the pattern matches, otherwise false - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#match - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ match: function (pattern) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (!(pattern instanceof RegExp)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pattern = new RegExp(pattern, 'i'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ return pattern.test(this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Checks whether the mobile device can be considered as phone regarding screen.width. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * Obviously this method makes sense in browser environments only (not for Node.js)! - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {number} [maxPhoneWidth] the maximum logical pixels (aka. CSS-pixels) to be considered as phone.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * The argument is optional and if not present or falsy, the value of the constructor is taken. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {boolean|undefined} undefined if screen size wasn't detectable, else true - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * when screen.width is less or equal to maxPhoneWidth, otherwise false.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Will always return undefined server-side. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ isPhoneSized: function (maxPhoneWidth) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return MobileDetect.isPhoneSized(maxPhoneWidth || this.maxPhoneWidth); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ !!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the mobile grade ('A', 'B', 'C'). - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} one of the mobile grades ('A', 'B', 'C'). - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#mobileGrade - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ mobileGrade: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this._cache.grade === undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this._cache.grade = impl.mobileGrade(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2339: Property 'mobileGrade' does not exist on type '{}'. } - ~~~~~~~~~~~~~ return this._cache.grade; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ }; - ~~~~~~ - // environment-dependent - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (typeof window !== 'undefined' && window.screen) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. ~~~~~~ !!! error TS2304: Cannot find name 'window'. MobileDetect.isPhoneSized = function (maxPhoneWidth) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ !!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. return maxPhoneWidth < 0 ? undefined : impl.getDeviceSmallerSide() <= maxPhoneWidth; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'getDeviceSmallerSide' does not exist on type '{}'. }; - ~~~~~~~~~~ } else { - ~~~~~~~~~~~~ MobileDetect.isPhoneSized = function () {}; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ !!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. } - ~~~~~ - // should not be replaced by a completely new object - just overwrite existing methods - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MobileDetect._impl = impl; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ !!! error TS2339: Property '_impl' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. - ~~~~ MobileDetect.version = '1.3.3 2016-07-31'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~ !!! error TS2339: Property 'version' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. - return MobileDetect; - ~~~~~~~~~~~~~~~~~~~~~~~~ }); // end of call of define() - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ })((function (undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~ if (typeof module !== 'undefined' && module.exports) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'module'. ~~~~~~ !!! error TS2304: Cannot find name 'module'. return function (factory) { module.exports = factory(); }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'module'. } else if (typeof define === 'function' && define.amd) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'define'. ~~~~~~ !!! error TS2304: Cannot find name 'define'. return define; - ~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'define'. } else if (typeof window !== 'undefined') { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. return function (factory) { window.MobileDetect = factory(); }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. } else { - ~~~~~~~~~~~~ - ~~~~~~~~~~~~ // please file a bug if you get this error! - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ throw new Error('unknown environment'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ - ~~~~~ - })()); - ~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. - ~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file + })()); \ No newline at end of file diff --git a/tests/baselines/reference/fluentClasses.js b/tests/baselines/reference/fluentClasses.js index ac44416e133..f9c8181aa49 100644 --- a/tests/baselines/reference/fluentClasses.js +++ b/tests/baselines/reference/fluentClasses.js @@ -19,11 +19,16 @@ var z = c.foo().bar().baz(); // Fluent pattern //// [fluentClasses.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -35,7 +40,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { return this; @@ -45,7 +50,7 @@ var B = (function (_super) { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.baz = function () { return this; diff --git a/tests/baselines/reference/for-inStatements.js b/tests/baselines/reference/for-inStatements.js index 15d771bf587..18ccb37b416 100644 --- a/tests/baselines/reference/for-inStatements.js +++ b/tests/baselines/reference/for-inStatements.js @@ -81,11 +81,16 @@ for (var x in Color.Blue) { } //// [for-inStatements.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var aString; for (aString in {}) { } var anAny; @@ -126,7 +131,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.boz = function () { for (var x in this.biz()) { } diff --git a/tests/baselines/reference/for-inStatementsInvalid.js b/tests/baselines/reference/for-inStatementsInvalid.js index d1181760a36..d70da450f08 100644 --- a/tests/baselines/reference/for-inStatementsInvalid.js +++ b/tests/baselines/reference/for-inStatementsInvalid.js @@ -64,11 +64,16 @@ for (var x in i[42]) { } //// [for-inStatementsInvalid.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var aNumber; for (aNumber in {}) { } var aBoolean; @@ -107,7 +112,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.boz = function () { for (var x in this.biz()) { } diff --git a/tests/baselines/reference/forStatementsMultipleInvalidDecl.js b/tests/baselines/reference/forStatementsMultipleInvalidDecl.js index 3666ad930a6..27284f8b272 100644 --- a/tests/baselines/reference/forStatementsMultipleInvalidDecl.js +++ b/tests/baselines/reference/forStatementsMultipleInvalidDecl.js @@ -55,11 +55,16 @@ for(var m: typeof M;;){} for( var m = M.A;;){} //// [forStatementsMultipleInvalidDecl.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -68,7 +73,7 @@ var C = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(C)); diff --git a/tests/baselines/reference/functionImplementationErrors.js b/tests/baselines/reference/functionImplementationErrors.js index 433418af41d..e227693b386 100644 --- a/tests/baselines/reference/functionImplementationErrors.js +++ b/tests/baselines/reference/functionImplementationErrors.js @@ -75,11 +75,16 @@ var f13 = () => { //// [functionImplementationErrors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 () { return ''; @@ -134,14 +139,14 @@ var AnotherClass = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived1; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/functionImplementations.js b/tests/baselines/reference/functionImplementations.js index 86636b84a87..994ff36da56 100644 --- a/tests/baselines/reference/functionImplementations.js +++ b/tests/baselines/reference/functionImplementations.js @@ -158,11 +158,16 @@ var f12: (x: number) => any = x => { // should be (x: number) => Base | AnotherC } //// [functionImplementations.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 () { }(); // FunctionExpression f with no return type annotation and directly references f in its body returns any @@ -236,7 +241,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -287,7 +292,7 @@ function f6() { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/functionSubtypingOfVarArgs.js b/tests/baselines/reference/functionSubtypingOfVarArgs.js index 55917962184..a4b43c3a1a1 100644 --- a/tests/baselines/reference/functionSubtypingOfVarArgs.js +++ b/tests/baselines/reference/functionSubtypingOfVarArgs.js @@ -15,11 +15,16 @@ class StringEvent extends EventBase { // should work //// [functionSubtypingOfVarArgs.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var EventBase = (function () { function EventBase() { this._listeners = []; @@ -32,7 +37,7 @@ var EventBase = (function () { var StringEvent = (function (_super) { __extends(StringEvent, _super); function StringEvent() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } StringEvent.prototype.add = function (listener) { _super.prototype.add.call(this, listener); diff --git a/tests/baselines/reference/functionSubtypingOfVarArgs2.js b/tests/baselines/reference/functionSubtypingOfVarArgs2.js index a676316459f..829440c12d4 100644 --- a/tests/baselines/reference/functionSubtypingOfVarArgs2.js +++ b/tests/baselines/reference/functionSubtypingOfVarArgs2.js @@ -15,11 +15,16 @@ class StringEvent extends EventBase { //// [functionSubtypingOfVarArgs2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var EventBase = (function () { function EventBase() { this._listeners = []; @@ -32,7 +37,7 @@ var EventBase = (function () { var StringEvent = (function (_super) { __extends(StringEvent, _super); function StringEvent() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } StringEvent.prototype.add = function (listener) { _super.prototype.add.call(this, listener); diff --git a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt index 1ccc296b75b..e0c552141b2 100644 --- a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt +++ b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt @@ -1,10 +1,11 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(3,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(101,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(106,16): error TS2378: A 'get' accessor must return a value. +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(128,15): error TS2532: Object is possibly 'undefined'. tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(129,5): error TS1003: Identifier expected. -==== tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts (4 errors) ==== +==== tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts (5 errors) ==== function f1(): string { @@ -139,6 +140,8 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(129,5): e // if no return statements are present but we are a get accessor. throw null; throw undefined. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. } ~ !!! error TS1003: Identifier expected. diff --git a/tests/baselines/reference/fuzzy.errors.txt b/tests/baselines/reference/fuzzy.errors.txt index 19f0ad56a5e..c3f05fd7f2f 100644 --- a/tests/baselines/reference/fuzzy.errors.txt +++ b/tests/baselines/reference/fuzzy.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/fuzzy.ts(13,18): error TS2420: Class 'C' incorrectly implements interface 'I'. Property 'alsoWorks' is missing in type 'C'. -tests/cases/compiler/fuzzy.ts(21,20): error TS2322: Type '{ anything: number; oneI: this; }' is not assignable to type 'R'. +tests/cases/compiler/fuzzy.ts(21,13): error TS2322: Type '{ anything: number; oneI: this; }' is not assignable to type 'R'. Types of property 'oneI' are incompatible. Type 'this' is not assignable to type 'I'. Type 'C' is not assignable to type 'I'. @@ -33,7 +33,7 @@ tests/cases/compiler/fuzzy.ts(25,20): error TS2352: Type '{ oneI: this; }' canno doesntWork():R { return { anything:1, oneI:this }; - ~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ anything: number; oneI: this; }' is not assignable to type 'R'. !!! error TS2322: Types of property 'oneI' are incompatible. !!! error TS2322: Type 'this' is not assignable to type 'I'. diff --git a/tests/baselines/reference/generatedContextualTyping.js b/tests/baselines/reference/generatedContextualTyping.js index 2a6911d9cf5..f8dc2863470 100644 --- a/tests/baselines/reference/generatedContextualTyping.js +++ b/tests/baselines/reference/generatedContextualTyping.js @@ -356,11 +356,16 @@ var x355 = function(n: (s: Base[]) => any) { }; x355(n => { var n: Base[]; retur var x356 = function(n: Genric) { }; x356({ func: n => { return [d1, d2]; } }); //// [generatedContextualTyping.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -369,14 +374,14 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived1; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/generatorTransformFinalLabel.js b/tests/baselines/reference/generatorTransformFinalLabel.js index 32272ae0748..58cffc80bee 100644 --- a/tests/baselines/reference/generatorTransformFinalLabel.js +++ b/tests/baselines/reference/generatorTransformFinalLabel.js @@ -14,8 +14,7 @@ function test(skip) { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (!!skip) - return [3 /*break*/, 2]; + if (!!skip) return [3 /*break*/, 2]; return [4 /*yield*/, 1]; case 1: _a.sent(); diff --git a/tests/baselines/reference/genericBaseClassLiteralProperty.js b/tests/baselines/reference/genericBaseClassLiteralProperty.js index a075eff9550..0c3a5ee6129 100644 --- a/tests/baselines/reference/genericBaseClassLiteralProperty.js +++ b/tests/baselines/reference/genericBaseClassLiteralProperty.js @@ -13,11 +13,16 @@ class SubClass extends BaseClass { } //// [genericBaseClassLiteralProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var BaseClass = (function () { function BaseClass() { } @@ -26,7 +31,7 @@ var BaseClass = (function () { var SubClass = (function (_super) { __extends(SubClass, _super); function SubClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SubClass.prototype.Error = function () { var x = this._getValue1(); diff --git a/tests/baselines/reference/genericBaseClassLiteralProperty2.js b/tests/baselines/reference/genericBaseClassLiteralProperty2.js index 2b562742bf7..e2ef30f9ce8 100644 --- a/tests/baselines/reference/genericBaseClassLiteralProperty2.js +++ b/tests/baselines/reference/genericBaseClassLiteralProperty2.js @@ -16,11 +16,16 @@ class DataView2 extends BaseCollection2 { //// [genericBaseClassLiteralProperty2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var CollectionItem2 = (function () { function CollectionItem2() { } @@ -35,7 +40,7 @@ var BaseCollection2 = (function () { var DataView2 = (function (_super) { __extends(DataView2, _super); function DataView2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } DataView2.prototype.fillItems = function (item) { this._itemsByKey['dummy'] = item; diff --git a/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference.js b/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference.js index afef6224ba1..3ccdb5b6b55 100644 --- a/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference.js +++ b/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference.js @@ -109,11 +109,16 @@ var r11 = i.foo8(); // Base //// [genericCallWithConstraintsTypeArgumentInference.js] // Basic type inference with generic calls and constraints, no errors expected -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -122,14 +127,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgs2.js b/tests/baselines/reference/genericCallWithObjectTypeArgs2.js index 7b621b3ffd9..c5de24019b2 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgs2.js +++ b/tests/baselines/reference/genericCallWithObjectTypeArgs2.js @@ -33,11 +33,16 @@ var i: I; var r4 = f2(i); // Base => Derived //// [genericCallWithObjectTypeArgs2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -46,14 +51,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints2.js b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints2.js index 892cda0ee2d..a4f8172a312 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints2.js +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints2.js @@ -41,11 +41,16 @@ var r7 = f3(null, x => x); // any //// [genericCallWithObjectTypeArgsAndConstraints2.js] // Generic call with constraints infering type parameter from object member properties // No errors expected -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -54,7 +59,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.js b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.js index addfbc756a8..074b25fdeea 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.js +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.js @@ -39,11 +39,16 @@ var r6 = f3(x => x, null); //// [genericCallWithObjectTypeArgsAndConstraints3.js] // Generic call with constraints infering type parameter from object member properties -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -52,14 +57,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/genericCallbacksAndClassHierarchy.js b/tests/baselines/reference/genericCallbacksAndClassHierarchy.js index c2ad2ba29a3..b7b9e35a543 100644 --- a/tests/baselines/reference/genericCallbacksAndClassHierarchy.js +++ b/tests/baselines/reference/genericCallbacksAndClassHierarchy.js @@ -24,11 +24,16 @@ module M { } //// [genericCallbacksAndClassHierarchy.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { var C1 = (function () { @@ -46,7 +51,7 @@ var M; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(C1)); diff --git a/tests/baselines/reference/genericClassExpressionInFunction.js b/tests/baselines/reference/genericClassExpressionInFunction.js index dc574dedb00..e1a47ffaac7 100644 --- a/tests/baselines/reference/genericClassExpressionInFunction.js +++ b/tests/baselines/reference/genericClassExpressionInFunction.js @@ -32,11 +32,16 @@ s.genericVar = 12; //// [genericClassExpressionInFunction.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -47,7 +52,7 @@ function B1() { return (function (_super) { __extends(class_1, _super); function class_1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class_1; }(A)); @@ -57,7 +62,7 @@ var B2 = (function () { this.anon = (function (_super) { __extends(class_2, _super); function class_2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class_2; }(A)); @@ -68,7 +73,7 @@ function B3() { return (function (_super) { __extends(Inner, _super); function Inner() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Inner; }(A)); @@ -77,14 +82,14 @@ function B3() { var K = (function (_super) { __extends(K, _super); function K() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return K; }(B1())); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }((new B2().anon))); @@ -92,7 +97,7 @@ var b3Number = B3(); var S = (function (_super) { __extends(S, _super); function S() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return S; }(b3Number)); diff --git a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.js b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.js index 1f3a6e17f14..c8a5b3ac0c4 100644 --- a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.js +++ b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.js @@ -6,22 +6,27 @@ class C { } //// [genericClassInheritsConstructorFromNonGenericClass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function (_super) { __extends(A, _super); function A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A; }(B)); var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(C)); diff --git a/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.js b/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.js index 28eaf464968..b5c8f47bfd4 100644 --- a/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.js +++ b/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.js @@ -76,11 +76,16 @@ class ViewModel implements Contract { //// [genericClassPropertyInheritanceSpecialization.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Portal; (function (Portal) { var Controls; diff --git a/tests/baselines/reference/genericClassStaticMethod.js b/tests/baselines/reference/genericClassStaticMethod.js index 4609e3bc9db..803950f58df 100644 --- a/tests/baselines/reference/genericClassStaticMethod.js +++ b/tests/baselines/reference/genericClassStaticMethod.js @@ -11,11 +11,16 @@ class Bar extends Foo { //// [genericClassStaticMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -26,7 +31,7 @@ var Foo = (function () { var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Bar.getFoo = function () { }; diff --git a/tests/baselines/reference/genericClasses3.js b/tests/baselines/reference/genericClasses3.js index 5371e2479aa..95eb5db106a 100644 --- a/tests/baselines/reference/genericClasses3.js +++ b/tests/baselines/reference/genericClasses3.js @@ -18,11 +18,16 @@ var z = v2.b; //// [genericClasses3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { } @@ -31,7 +36,7 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); diff --git a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.js b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.js index d990f76d2c3..c66279ec873 100644 --- a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.js +++ b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.js @@ -27,11 +27,16 @@ module EndGate.Tweening { } //// [genericConstraintOnExtendedBuiltinTypes.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var EndGate; (function (EndGate) { var Tweening; diff --git a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.js b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.js index 4291b315933..af5f46c3c57 100644 --- a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.js +++ b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.js @@ -26,11 +26,16 @@ module EndGate.Tweening { } //// [genericConstraintOnExtendedBuiltinTypes2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var EndGate; (function (EndGate) { var Tweening; diff --git a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase.js b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase.js index 1b455073196..cd028bb28b2 100644 --- a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase.js +++ b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase.js @@ -13,11 +13,16 @@ x = y; // error //// [genericDerivedTypeWithSpecializedBase.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -26,7 +31,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.js b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.js index 0abd655e1da..694bc87c453 100644 --- a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.js +++ b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.js @@ -13,11 +13,16 @@ x = y; // error //// [genericDerivedTypeWithSpecializedBase2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -26,7 +31,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/genericInheritedDefaultConstructors.js b/tests/baselines/reference/genericInheritedDefaultConstructors.js index 059a3213b7a..15848c10874 100644 --- a/tests/baselines/reference/genericInheritedDefaultConstructors.js +++ b/tests/baselines/reference/genericInheritedDefaultConstructors.js @@ -11,11 +11,16 @@ var c:Constructor> = B; // shouldn't error here //// [genericInheritedDefaultConstructors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -24,7 +29,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/genericPrototypeProperty2.js b/tests/baselines/reference/genericPrototypeProperty2.js index eac025cce9b..66f058090dc 100644 --- a/tests/baselines/reference/genericPrototypeProperty2.js +++ b/tests/baselines/reference/genericPrototypeProperty2.js @@ -16,11 +16,16 @@ class MyEventWrapper extends BaseEventWrapper { } //// [genericPrototypeProperty2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var BaseEvent = (function () { function BaseEvent() { } @@ -29,7 +34,7 @@ var BaseEvent = (function () { var MyEvent = (function (_super) { __extends(MyEvent, _super); function MyEvent() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return MyEvent; }(BaseEvent)); @@ -41,7 +46,7 @@ var BaseEventWrapper = (function () { var MyEventWrapper = (function (_super) { __extends(MyEventWrapper, _super); function MyEventWrapper() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return MyEventWrapper; }(BaseEventWrapper)); diff --git a/tests/baselines/reference/genericPrototypeProperty3.js b/tests/baselines/reference/genericPrototypeProperty3.js index 9e3ede0019d..1fef7a9b407 100644 --- a/tests/baselines/reference/genericPrototypeProperty3.js +++ b/tests/baselines/reference/genericPrototypeProperty3.js @@ -15,11 +15,16 @@ class MyEventWrapper extends BaseEventWrapper { } //// [genericPrototypeProperty3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var BaseEvent = (function () { function BaseEvent() { } @@ -28,7 +33,7 @@ var BaseEvent = (function () { var MyEvent = (function (_super) { __extends(MyEvent, _super); function MyEvent() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return MyEvent; }(BaseEvent)); @@ -40,7 +45,7 @@ var BaseEventWrapper = (function () { var MyEventWrapper = (function (_super) { __extends(MyEventWrapper, _super); function MyEventWrapper() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return MyEventWrapper; }(BaseEventWrapper)); diff --git a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.js b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.js index 401a2e94b68..22886334aad 100644 --- a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.js +++ b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.js @@ -27,11 +27,16 @@ module TypeScript2 { //// [genericRecursiveImplicitConstructorErrors2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var TypeScript2; (function (TypeScript2) { ; @@ -57,7 +62,7 @@ var TypeScript2; var PullTypeSymbol = (function (_super) { __extends(PullTypeSymbol, _super); function PullTypeSymbol() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PullTypeSymbol; }(PullSymbol)); diff --git a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.js b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.js index c7643d4a9a2..d0bf08113d2 100644 --- a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.js +++ b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.js @@ -31,11 +31,16 @@ module TypeScript { //// [genericRecursiveImplicitConstructorErrors3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var TypeScript; (function (TypeScript) { var MemberName = (function () { @@ -58,7 +63,7 @@ var TypeScript; var PullTypeSymbol = (function (_super) { __extends(PullTypeSymbol, _super); function PullTypeSymbol() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this._elementType = null; return _this; } diff --git a/tests/baselines/reference/genericTypeAssertions2.js b/tests/baselines/reference/genericTypeAssertions2.js index 687d593f01e..160967e83de 100644 --- a/tests/baselines/reference/genericTypeAssertions2.js +++ b/tests/baselines/reference/genericTypeAssertions2.js @@ -14,11 +14,16 @@ var r4: A = >new A(); var r5: A = >[]; // error //// [genericTypeAssertions2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -28,7 +33,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { return null; diff --git a/tests/baselines/reference/genericTypeAssertions4.js b/tests/baselines/reference/genericTypeAssertions4.js index 50dbe5debbd..991db3822ac 100644 --- a/tests/baselines/reference/genericTypeAssertions4.js +++ b/tests/baselines/reference/genericTypeAssertions4.js @@ -26,11 +26,16 @@ function foo2(x: T) { } //// [genericTypeAssertions4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -40,7 +45,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { return 1; }; return B; @@ -48,7 +53,7 @@ var B = (function (_super) { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.baz = function () { return 1; }; return C; diff --git a/tests/baselines/reference/genericTypeAssertions6.js b/tests/baselines/reference/genericTypeAssertions6.js index 7bbd7351f1d..069e567ab10 100644 --- a/tests/baselines/reference/genericTypeAssertions6.js +++ b/tests/baselines/reference/genericTypeAssertions6.js @@ -25,11 +25,16 @@ var b: B; var c: A = >b; //// [genericTypeAssertions6.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(x) { var y = x; @@ -44,7 +49,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.g = function (x) { var a = x; diff --git a/tests/baselines/reference/genericTypeConstraints.js b/tests/baselines/reference/genericTypeConstraints.js index 67303166aa3..cbb03b683a8 100644 --- a/tests/baselines/reference/genericTypeConstraints.js +++ b/tests/baselines/reference/genericTypeConstraints.js @@ -14,11 +14,16 @@ class BarExtended extends Bar { } //// [genericTypeConstraints.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js index cf19feede34..8fc00dcc08f 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js @@ -40,11 +40,16 @@ var k = null; //// [genericTypeReferenceWithoutTypeArgument.js] // it is an error to use a generic type without type arguments // all of these are 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -60,7 +65,7 @@ var g = function f(x) { var y; return y; }; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); @@ -76,7 +81,7 @@ var M; var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(M.E)); diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js index 973ee231762..9730afdee04 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js @@ -40,11 +40,16 @@ var k = null; //// [genericTypeReferenceWithoutTypeArgument2.js] // it is an error to use a generic type without type arguments // all of these are 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var c; var a; var b; @@ -55,14 +60,14 @@ var g = function f(x) { var y; return y; }; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(I)); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(M.C)); diff --git a/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.js b/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.js index d6fb98b67ca..5498d3d1fad 100644 --- a/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.js +++ b/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.js @@ -15,11 +15,16 @@ export class ListItem extends CollectionItem { //// [genericWithIndexerOfTypeParameterType2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); define(["require", "exports"], function (require, exports) { "use strict"; var Collection = (function () { @@ -31,7 +36,7 @@ define(["require", "exports"], function (require, exports) { var List = (function (_super) { __extends(List, _super); function List() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } List.prototype.Bar = function () { }; return List; @@ -46,7 +51,7 @@ define(["require", "exports"], function (require, exports) { var ListItem = (function (_super) { __extends(ListItem, _super); function ListItem() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ListItem; }(CollectionItem)); diff --git a/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt b/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt index 845a4011d9f..dc77d530e01 100644 --- a/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt +++ b/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts(8,16): error TS2322: Type '"string"' is not assignable to type 'number'. +tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts(8,9): error TS2322: Type '"string"' is not assignable to type 'number'. ==== tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts (1 errors) ==== @@ -10,7 +10,7 @@ tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyp set X(x: number) { } get X() { return "string"; // Error; get contextual type by set accessor parameter type annotation - ~~~~~~~~ + ~~~~~~~~~~~~~~~~ !!! error TS2322: Type '"string"' is not assignable to type 'number'. } diff --git a/tests/baselines/reference/heterogeneousArrayLiterals.js b/tests/baselines/reference/heterogeneousArrayLiterals.js index 9b15cf743f0..f65fac6fb5d 100644 --- a/tests/baselines/reference/heterogeneousArrayLiterals.js +++ b/tests/baselines/reference/heterogeneousArrayLiterals.js @@ -133,11 +133,16 @@ function foo4(t: T, u: U) { //// [heterogeneousArrayLiterals.js] // type of an array is the best common type of its elements (plus its contextual type if it exists) -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = [1, '']; // {}[] var b = [1, null]; // number[] var c = [1, '', null]; // {}[] @@ -160,14 +165,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/ifDoWhileStatements.js b/tests/baselines/reference/ifDoWhileStatements.js index 483370bee5c..22dd78a9687 100644 --- a/tests/baselines/reference/ifDoWhileStatements.js +++ b/tests/baselines/reference/ifDoWhileStatements.js @@ -164,11 +164,16 @@ do { }while(fn) //// [ifDoWhileStatements.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -177,7 +182,7 @@ var C = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(C)); diff --git a/tests/baselines/reference/illegalSuperCallsInConstructor.js b/tests/baselines/reference/illegalSuperCallsInConstructor.js index 868d53daad5..bb29e857e9b 100644 --- a/tests/baselines/reference/illegalSuperCallsInConstructor.js +++ b/tests/baselines/reference/illegalSuperCallsInConstructor.js @@ -21,11 +21,16 @@ class Derived extends Base { } //// [illegalSuperCallsInConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -34,7 +39,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this; + var _this = this; var r2 = function () { return _this = _super.call(this) || this; }; var r3 = function () { _this = _super.call(this) || this; }; var r4 = function () { _this = _super.call(this) || this; }; diff --git a/tests/baselines/reference/implementClausePrecedingExtends.js b/tests/baselines/reference/implementClausePrecedingExtends.js index df725cde43a..8c6c591138e 100644 --- a/tests/baselines/reference/implementClausePrecedingExtends.js +++ b/tests/baselines/reference/implementClausePrecedingExtends.js @@ -3,11 +3,16 @@ class C { foo: number } class D implements C extends C { } //// [implementClausePrecedingExtends.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -16,7 +21,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.js b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.js index a5a5e02c156..d492e7fa7e2 100644 --- a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.js +++ b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.js @@ -86,11 +86,16 @@ module M2 { } //// [implementingAnInterfaceExtendingClassWithPrivates2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -99,21 +104,21 @@ var Foo = (function () { var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar; }(Foo)); var Bar2 = (function (_super) { __extends(Bar2, _super); function Bar2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar2; }(Foo)); var Bar3 = (function (_super) { __extends(Bar3, _super); function Bar3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar3; }(Foo)); @@ -128,28 +133,28 @@ var M; var Baz = (function (_super) { __extends(Baz, _super); function Baz() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Baz; }(Foo)); var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar; }(Foo)); var Bar2 = (function (_super) { __extends(Bar2, _super); function Bar2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar2; }(Foo)); var Bar3 = (function (_super) { __extends(Bar3, _super); function Bar3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar3; }(Foo)); @@ -165,14 +170,14 @@ var M2; var Baz = (function (_super) { __extends(Baz, _super); function Baz() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Baz; }(Foo)); var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar; }(Foo)); @@ -183,14 +188,14 @@ var M2; var Bar2 = (function (_super) { __extends(Bar2, _super); function Bar2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar2; }(Foo)); var Bar3 = (function (_super) { __extends(Bar3, _super); function Bar3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar3; }(Foo)); diff --git a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js index d0f74847141..6bffdf9d4e7 100644 --- a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js +++ b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js @@ -42,11 +42,16 @@ class Bar8 extends Foo implements I { //// [implementingAnInterfaceExtendingClassWithProtecteds.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -75,28 +80,28 @@ var Bar4 = (function () { var Bar5 = (function (_super) { __extends(Bar5, _super); function Bar5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar5; }(Foo)); var Bar6 = (function (_super) { __extends(Bar6, _super); function Bar6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar6; }(Foo)); var Bar7 = (function (_super) { __extends(Bar7, _super); function Bar7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar7; }(Foo)); var Bar8 = (function (_super) { __extends(Bar8, _super); function Bar8() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar8; }(Foo)); diff --git a/tests/baselines/reference/importAsBaseClass.js b/tests/baselines/reference/importAsBaseClass.js index b4f45cac806..75d6e68d4c5 100644 --- a/tests/baselines/reference/importAsBaseClass.js +++ b/tests/baselines/reference/importAsBaseClass.js @@ -21,16 +21,21 @@ var Greeter = (function () { exports.Greeter = Greeter; //// [importAsBaseClass_1.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Hello; }(Greeter)); diff --git a/tests/baselines/reference/importHelpers.js b/tests/baselines/reference/importHelpers.js index 762f0778945..fea4ee2db27 100644 --- a/tests/baselines/reference/importHelpers.js +++ b/tests/baselines/reference/importHelpers.js @@ -45,7 +45,7 @@ exports.A = A; var B = (function (_super) { tslib_1.__extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -67,11 +67,16 @@ C = tslib_1.__decorate([ dec ], C); //// [script.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); @@ -92,7 +97,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/importHelpersAmd.js b/tests/baselines/reference/importHelpersAmd.js index fea93840fa9..6054e147386 100644 --- a/tests/baselines/reference/importHelpersAmd.js +++ b/tests/baselines/reference/importHelpersAmd.js @@ -32,7 +32,7 @@ define(["require", "exports", "tslib", "./a"], function (require, exports, tslib var B = (function (_super) { tslib_1.__extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(a_1.A)); diff --git a/tests/baselines/reference/importHelpersInAmbientContext.js b/tests/baselines/reference/importHelpersInAmbientContext.js new file mode 100644 index 00000000000..b9db8c4751f --- /dev/null +++ b/tests/baselines/reference/importHelpersInAmbientContext.js @@ -0,0 +1,59 @@ +//// [tests/cases/compiler/importHelpersInAmbientContext.ts] //// + +//// [a.d.ts] + +export { }; + +// Extends +declare class C { } +declare class D extends C { } + +// Destructuring +interface I { + ({descendants, read}?: { + descendants?: boolean; + read?: any; + }): any; +} + + +// Object Rest +interface Foo { + a: number; b: string; +} +export var { a, ...x } : Foo; + +//// [b.ts] +export {}; +declare namespace N { + // Extends + class C { } + class D extends C { } + + // Destructuring + interface I { + ({descendants, read}?: { + descendants?: boolean; + read?: any; + }): any; + } + + + // Object Rest + interface Foo { + a: number; b: string; + } + export var { a, ...x } : Foo; +} + +//// [tslib.d.ts] +export declare function __extends(d: Function, b: Function): void; +export declare function __assign(t: any, ...sources: any[]): any; +export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; +export declare function __param(paramIndex: number, decorator: Function): Function; +export declare function __metadata(metadataKey: any, metadataValue: any): Function; +export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any; + + +//// [b.js] +"use strict"; diff --git a/tests/baselines/reference/importHelpersInAmbientContext.symbols b/tests/baselines/reference/importHelpersInAmbientContext.symbols new file mode 100644 index 00000000000..7da1ea95042 --- /dev/null +++ b/tests/baselines/reference/importHelpersInAmbientContext.symbols @@ -0,0 +1,131 @@ +=== tests/cases/compiler/a.d.ts === + +export { }; + +// Extends +declare class C { } +>C : Symbol(C, Decl(a.d.ts, 1, 11)) + +declare class D extends C { } +>D : Symbol(D, Decl(a.d.ts, 4, 19)) +>C : Symbol(C, Decl(a.d.ts, 1, 11)) + +// Destructuring +interface I { +>I : Symbol(I, Decl(a.d.ts, 5, 29)) + + ({descendants, read}?: { +>descendants : Symbol(descendants, Decl(a.d.ts, 9, 6)) +>read : Symbol(read, Decl(a.d.ts, 9, 18)) + + descendants?: boolean; +>descendants : Symbol(descendants, Decl(a.d.ts, 9, 28)) + + read?: any; +>read : Symbol(read, Decl(a.d.ts, 10, 30)) + + }): any; +} + + +// Object Rest +interface Foo { +>Foo : Symbol(Foo, Decl(a.d.ts, 13, 1)) + + a: number; b: string; +>a : Symbol(Foo.a, Decl(a.d.ts, 17, 15)) +>b : Symbol(Foo.b, Decl(a.d.ts, 18, 14)) +} +export var { a, ...x } : Foo; +>a : Symbol(a, Decl(a.d.ts, 20, 12)) +>x : Symbol(x, Decl(a.d.ts, 20, 15)) +>Foo : Symbol(Foo, Decl(a.d.ts, 13, 1)) + +=== tests/cases/compiler/b.ts === +export {}; +declare namespace N { +>N : Symbol(N, Decl(b.ts, 0, 10)) + + // Extends + class C { } +>C : Symbol(C, Decl(b.ts, 1, 21)) + + class D extends C { } +>D : Symbol(D, Decl(b.ts, 3, 12)) +>C : Symbol(C, Decl(b.ts, 1, 21)) + + // Destructuring + interface I { +>I : Symbol(I, Decl(b.ts, 4, 22)) + + ({descendants, read}?: { +>descendants : Symbol(descendants, Decl(b.ts, 8, 4)) +>read : Symbol(read, Decl(b.ts, 8, 16)) + + descendants?: boolean; +>descendants : Symbol(descendants, Decl(b.ts, 8, 26)) + + read?: any; +>read : Symbol(read, Decl(b.ts, 9, 25)) + + }): any; + } + + + // Object Rest + interface Foo { +>Foo : Symbol(Foo, Decl(b.ts, 12, 2)) + + a: number; b: string; +>a : Symbol(Foo.a, Decl(b.ts, 16, 16)) +>b : Symbol(Foo.b, Decl(b.ts, 17, 12)) + } + export var { a, ...x } : Foo; +>a : Symbol(a, Decl(b.ts, 19, 13)) +>x : Symbol(x, Decl(b.ts, 19, 16)) +>Foo : Symbol(Foo, Decl(b.ts, 12, 2)) +} + +=== tests/cases/compiler/tslib.d.ts === +export declare function __extends(d: Function, b: Function): void; +>__extends : Symbol(__extends, Decl(tslib.d.ts, --, --)) +>d : Symbol(d, Decl(tslib.d.ts, --, --)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>b : Symbol(b, Decl(tslib.d.ts, --, --)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +export declare function __assign(t: any, ...sources: any[]): any; +>__assign : Symbol(__assign, Decl(tslib.d.ts, --, --)) +>t : Symbol(t, Decl(tslib.d.ts, --, --)) +>sources : Symbol(sources, Decl(tslib.d.ts, --, --)) + +export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; +>__decorate : Symbol(__decorate, Decl(tslib.d.ts, --, --)) +>decorators : Symbol(decorators, Decl(tslib.d.ts, --, --)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>target : Symbol(target, Decl(tslib.d.ts, --, --)) +>key : Symbol(key, Decl(tslib.d.ts, --, --)) +>desc : Symbol(desc, Decl(tslib.d.ts, --, --)) + +export declare function __param(paramIndex: number, decorator: Function): Function; +>__param : Symbol(__param, Decl(tslib.d.ts, --, --)) +>paramIndex : Symbol(paramIndex, Decl(tslib.d.ts, --, --)) +>decorator : Symbol(decorator, Decl(tslib.d.ts, --, --)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +export declare function __metadata(metadataKey: any, metadataValue: any): Function; +>__metadata : Symbol(__metadata, Decl(tslib.d.ts, --, --)) +>metadataKey : Symbol(metadataKey, Decl(tslib.d.ts, --, --)) +>metadataValue : Symbol(metadataValue, Decl(tslib.d.ts, --, --)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any; +>__awaiter : Symbol(__awaiter, Decl(tslib.d.ts, --, --)) +>thisArg : Symbol(thisArg, Decl(tslib.d.ts, --, --)) +>_arguments : Symbol(_arguments, Decl(tslib.d.ts, --, --)) +>P : Symbol(P, Decl(tslib.d.ts, --, --)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>generator : Symbol(generator, Decl(tslib.d.ts, --, --)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/importHelpersInAmbientContext.types b/tests/baselines/reference/importHelpersInAmbientContext.types new file mode 100644 index 00000000000..5f3102b68f5 --- /dev/null +++ b/tests/baselines/reference/importHelpersInAmbientContext.types @@ -0,0 +1,131 @@ +=== tests/cases/compiler/a.d.ts === + +export { }; + +// Extends +declare class C { } +>C : C + +declare class D extends C { } +>D : D +>C : C + +// Destructuring +interface I { +>I : I + + ({descendants, read}?: { +>descendants : boolean +>read : any + + descendants?: boolean; +>descendants : boolean + + read?: any; +>read : any + + }): any; +} + + +// Object Rest +interface Foo { +>Foo : Foo + + a: number; b: string; +>a : number +>b : string +} +export var { a, ...x } : Foo; +>a : number +>x : { b: string; } +>Foo : Foo + +=== tests/cases/compiler/b.ts === +export {}; +declare namespace N { +>N : typeof N + + // Extends + class C { } +>C : C + + class D extends C { } +>D : D +>C : C + + // Destructuring + interface I { +>I : I + + ({descendants, read}?: { +>descendants : boolean +>read : any + + descendants?: boolean; +>descendants : boolean + + read?: any; +>read : any + + }): any; + } + + + // Object Rest + interface Foo { +>Foo : Foo + + a: number; b: string; +>a : number +>b : string + } + export var { a, ...x } : Foo; +>a : number +>x : { b: string; } +>Foo : Foo +} + +=== tests/cases/compiler/tslib.d.ts === +export declare function __extends(d: Function, b: Function): void; +>__extends : (d: Function, b: Function) => void +>d : Function +>Function : Function +>b : Function +>Function : Function + +export declare function __assign(t: any, ...sources: any[]): any; +>__assign : (t: any, ...sources: any[]) => any +>t : any +>sources : any[] + +export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; +>__decorate : (decorators: Function[], target: any, key?: string | symbol, desc?: any) => any +>decorators : Function[] +>Function : Function +>target : any +>key : string | symbol +>desc : any + +export declare function __param(paramIndex: number, decorator: Function): Function; +>__param : (paramIndex: number, decorator: Function) => Function +>paramIndex : number +>decorator : Function +>Function : Function +>Function : Function + +export declare function __metadata(metadataKey: any, metadataValue: any): Function; +>__metadata : (metadataKey: any, metadataValue: any) => Function +>metadataKey : any +>metadataValue : any +>Function : Function + +export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any; +>__awaiter : (thisArg: any, _arguments: any, P: Function, generator: Function) => any +>thisArg : any +>_arguments : any +>P : Function +>Function : Function +>generator : Function +>Function : Function + diff --git a/tests/baselines/reference/importHelpersInIsolatedModules.js b/tests/baselines/reference/importHelpersInIsolatedModules.js index 5c395ea0b9f..429a71c1ab8 100644 --- a/tests/baselines/reference/importHelpersInIsolatedModules.js +++ b/tests/baselines/reference/importHelpersInIsolatedModules.js @@ -45,7 +45,7 @@ exports.A = A; var B = (function (_super) { tslib_1.__extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -77,7 +77,7 @@ var A = (function () { var B = (function (_super) { tslib_1.__extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/importHelpersNoHelpers.js b/tests/baselines/reference/importHelpersNoHelpers.js index 560e16d1cca..53b4b326819 100644 --- a/tests/baselines/reference/importHelpersNoHelpers.js +++ b/tests/baselines/reference/importHelpersNoHelpers.js @@ -44,7 +44,7 @@ exports.A = A; var B = (function (_super) { tslib_1.__extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -69,11 +69,16 @@ var o = { a: 1 }; var y = tslib_1.__assign({}, o); var x = tslib_1.__rest(y, []); //// [script.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); @@ -94,7 +99,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/importHelpersNoModule.js b/tests/baselines/reference/importHelpersNoModule.js index 65a004eb66c..f84666ae198 100644 --- a/tests/baselines/reference/importHelpersNoModule.js +++ b/tests/baselines/reference/importHelpersNoModule.js @@ -37,7 +37,7 @@ exports.A = A; var B = (function (_super) { tslib_1.__extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -59,11 +59,16 @@ C = tslib_1.__decorate([ dec ], C); //// [script.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); @@ -84,7 +89,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/importHelpersOutFile.js b/tests/baselines/reference/importHelpersOutFile.js index a45f6285782..572115ba4bb 100644 --- a/tests/baselines/reference/importHelpersOutFile.js +++ b/tests/baselines/reference/importHelpersOutFile.js @@ -35,7 +35,7 @@ define("b", ["require", "exports", "tslib", "a"], function (require, exports, ts var B = (function (_super) { tslib_1.__extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(a_1.A)); @@ -46,7 +46,7 @@ define("c", ["require", "exports", "tslib", "a"], function (require, exports, ts var C = (function (_super) { tslib_2.__extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(a_2.A)); diff --git a/tests/baselines/reference/importHelpersSystem.js b/tests/baselines/reference/importHelpersSystem.js index 20f2d299c52..b7c10ee3c34 100644 --- a/tests/baselines/reference/importHelpersSystem.js +++ b/tests/baselines/reference/importHelpersSystem.js @@ -51,7 +51,7 @@ System.register(["tslib", "./a"], function (exports_1, context_1) { B = (function (_super) { tslib_1.__extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(a_1.A)); diff --git a/tests/baselines/reference/importShadowsGlobalName.js b/tests/baselines/reference/importShadowsGlobalName.js index 34cc0604e7a..94be0dfd5a0 100644 --- a/tests/baselines/reference/importShadowsGlobalName.js +++ b/tests/baselines/reference/importShadowsGlobalName.js @@ -21,17 +21,22 @@ define(["require", "exports"], function (require, exports) { return Foo; }); //// [Bar.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); define(["require", "exports", "Foo"], function (require, exports, Error) { "use strict"; var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar; }(Error)); diff --git a/tests/baselines/reference/importUsedInExtendsList1.js b/tests/baselines/reference/importUsedInExtendsList1.js index a40c3a51a78..4075719c9c5 100644 --- a/tests/baselines/reference/importUsedInExtendsList1.js +++ b/tests/baselines/reference/importUsedInExtendsList1.js @@ -21,17 +21,22 @@ var Super = (function () { exports.Super = Super; //// [importUsedInExtendsList1_1.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); /// var foo = require("./importUsedInExtendsList1_require"); var Sub = (function (_super) { __extends(Sub, _super); function Sub() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Sub; }(foo.Super)); diff --git a/tests/baselines/reference/importWithTrailingSlash.trace.json b/tests/baselines/reference/importWithTrailingSlash.trace.json index 56de914f395..3efe8c1ba51 100644 --- a/tests/baselines/reference/importWithTrailingSlash.trace.json +++ b/tests/baselines/reference/importWithTrailingSlash.trace.json @@ -1,23 +1,23 @@ [ "======== Resolving module '.' from '/a/test.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module as file / folder, candidate module location '/a'.", + "Loading module as file / folder, candidate module location '/a', target file type 'TypeScript'.", "File '/a.ts' exist - use it as a name resolution result.", "======== Module name '.' was successfully resolved to '/a.ts'. ========", "======== Resolving module './' from '/a/test.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module as file / folder, candidate module location '/a/'.", + "Loading module as file / folder, candidate module location '/a/', target file type 'TypeScript'.", "File '/a/package.json' does not exist.", "File '/a/index.ts' exist - use it as a name resolution result.", "======== Module name './' was successfully resolved to '/a/index.ts'. ========", "======== Resolving module '..' from '/a/b/test.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module as file / folder, candidate module location '/a'.", + "Loading module as file / folder, candidate module location '/a', target file type 'TypeScript'.", "File '/a.ts' exist - use it as a name resolution result.", "======== Module name '..' was successfully resolved to '/a.ts'. ========", "======== Resolving module '../' from '/a/b/test.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module as file / folder, candidate module location '/a/'.", + "Loading module as file / folder, candidate module location '/a/', target file type 'TypeScript'.", "File '/a/package.json' does not exist.", "File '/a/index.ts' exist - use it as a name resolution result.", "======== Module name '../' was successfully resolved to '/a/index.ts'. ========" diff --git a/tests/baselines/reference/importWithTrailingSlash_noResolve.trace.json b/tests/baselines/reference/importWithTrailingSlash_noResolve.trace.json index 55b75c57dde..1ee467c3789 100644 --- a/tests/baselines/reference/importWithTrailingSlash_noResolve.trace.json +++ b/tests/baselines/reference/importWithTrailingSlash_noResolve.trace.json @@ -1,14 +1,9 @@ [ "======== Resolving module './foo/' from '/a.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module as file / folder, candidate module location '/foo/'.", - "File '/foo/package.json' does not exist.", - "File '/foo/index.ts' does not exist.", - "File '/foo/index.tsx' does not exist.", - "File '/foo/index.d.ts' does not exist.", - "Loading module as file / folder, candidate module location '/foo/'.", - "File '/foo/package.json' does not exist.", - "File '/foo/index.js' does not exist.", - "File '/foo/index.jsx' does not exist.", + "Loading module as file / folder, candidate module location '/foo/', target file type 'TypeScript'.", + "Directory '/foo/' does not exist, skipping all lookups in it.", + "Loading module as file / folder, candidate module location '/foo/', target file type 'JavaScript'.", + "Directory '/foo/' does not exist, skipping all lookups in it.", "======== Module name './foo/' was not resolved. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/inOperatorWithInvalidOperands.errors.txt b/tests/baselines/reference/inOperatorWithInvalidOperands.errors.txt index 5aeae5f160e..7615008d89c 100644 --- a/tests/baselines/reference/inOperatorWithInvalidOperands.errors.txt +++ b/tests/baselines/reference/inOperatorWithInvalidOperands.errors.txt @@ -1,6 +1,8 @@ tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(12,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(13,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(14,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. +tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(16,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(17,11): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(19,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(20,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(30,16): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter @@ -11,13 +13,13 @@ tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInv tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(35,16): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(36,16): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(37,16): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter -tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(38,16): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter -tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(39,17): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter +tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(38,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(39,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(43,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(43,17): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter -==== tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts (17 errors) ==== +==== tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts (19 errors) ==== enum E { a } var x: any; @@ -40,7 +42,11 @@ tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInv !!! error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. var ra4 = a4 in x; var ra5 = null in x; + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ra6 = undefined in x; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ra7 = E.a in x; var ra8 = false in x; ~~~~~ @@ -83,10 +89,10 @@ tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInv !!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter var rb9 = x in null; ~~~~ -!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter +!!! error TS2531: Object is possibly 'null'. var rb10 = x in undefined; ~~~~~~~~~ -!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter +!!! error TS2532: Object is possibly 'undefined'. // both operands are invalid diff --git a/tests/baselines/reference/incrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt b/tests/baselines/reference/incrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt index 0a303d12bf3..afdddab86a7 100644 --- a/tests/baselines/reference/incrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt +++ b/tests/baselines/reference/incrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt @@ -9,29 +9,37 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(33,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(34,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(37,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(39,26): error TS2539: Cannot assign to 'undefined' because it is not a variable. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(42,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(43,24): error TS2539: Cannot assign to 'undefined' because it is not a variable. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(46,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(47,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,34): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,34): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,39): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(51,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(52,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(54,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(55,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,32): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,32): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,37): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(59,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(60,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(63,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -45,7 +53,7 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(69,12): error TS1109: Expression expected. -==== tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts (45 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts (53 errors) ==== // ++ operator on any type var ANY1: any; var ANY2: any[] = [1, 2]; @@ -107,14 +115,18 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. var ResultIsNumber12 = ++null; ~~~~ -!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber13 = ++undefined; ~~~~~~~~~ !!! error TS2539: Cannot assign to 'undefined' because it is not a variable. var ResultIsNumber14 = null++; ~~~~ -!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber15 = {}++; ~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -132,18 +144,24 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp var ResultIsNumber19 = ++(null + undefined); ~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber20 = ++(null + null); ~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber21 = ++(undefined + undefined); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber22 = ++obj1.x; ~~~~~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -160,18 +178,24 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp var ResultIsNumber26 = (null + undefined)++; ~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber27 = (null + null)++; ~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber28 = (undefined + undefined)++; ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber29 = obj1.x++; ~~~~~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. diff --git a/tests/baselines/reference/indexerConstraints2.js b/tests/baselines/reference/indexerConstraints2.js index d7357f021d0..4336fd2ff32 100644 --- a/tests/baselines/reference/indexerConstraints2.js +++ b/tests/baselines/reference/indexerConstraints2.js @@ -29,11 +29,16 @@ class K extends J { } //// [indexerConstraints2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -42,7 +47,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -55,7 +60,7 @@ var F = (function () { var G = (function (_super) { __extends(G, _super); function G() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return G; }(F)); @@ -68,7 +73,7 @@ var H = (function () { var I = (function (_super) { __extends(I, _super); function I() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return I; }(H)); @@ -81,7 +86,7 @@ var J = (function () { var K = (function (_super) { __extends(K, _super); function K() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return K; }(J)); diff --git a/tests/baselines/reference/indirectSelfReference.js b/tests/baselines/reference/indirectSelfReference.js index 2f4f37b9b53..6410e463dbb 100644 --- a/tests/baselines/reference/indirectSelfReference.js +++ b/tests/baselines/reference/indirectSelfReference.js @@ -3,22 +3,27 @@ class a extends b{ } class b extends a{ } //// [indirectSelfReference.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function (_super) { __extends(a, _super); function a() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return a; }(b)); var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/indirectSelfReferenceGeneric.js b/tests/baselines/reference/indirectSelfReferenceGeneric.js index 9171bb0eeb6..695970159d9 100644 --- a/tests/baselines/reference/indirectSelfReferenceGeneric.js +++ b/tests/baselines/reference/indirectSelfReferenceGeneric.js @@ -3,22 +3,27 @@ class a extends b { } class b extends a { } //// [indirectSelfReferenceGeneric.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function (_super) { __extends(a, _super); function a() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return a; }(b)); var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inferSetterParamType.errors.txt b/tests/baselines/reference/inferSetterParamType.errors.txt index 02c02ba69d5..7b28c52d48b 100644 --- a/tests/baselines/reference/inferSetterParamType.errors.txt +++ b/tests/baselines/reference/inferSetterParamType.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/inferSetterParamType.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inferSetterParamType.ts(6,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inferSetterParamType.ts(12,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/inferSetterParamType.ts(13,16): error TS2322: Type '0' is not assignable to type 'string'. +tests/cases/compiler/inferSetterParamType.ts(13,9): error TS2322: Type '0' is not assignable to type 'string'. tests/cases/compiler/inferSetterParamType.ts(15,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -25,7 +25,7 @@ tests/cases/compiler/inferSetterParamType.ts(15,9): error TS1056: Accessors are ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. return 0; // should be an error - can't coerce infered return type to match setter annotated type - ~ + ~~~~~~~~~ !!! error TS2322: Type '0' is not assignable to type 'string'. } set bar(n:string) { diff --git a/tests/baselines/reference/infinitelyExpandingTypesNonGenericBase.js b/tests/baselines/reference/infinitelyExpandingTypesNonGenericBase.js index ad1a063bfb0..fd9bbac1623 100644 --- a/tests/baselines/reference/infinitelyExpandingTypesNonGenericBase.js +++ b/tests/baselines/reference/infinitelyExpandingTypesNonGenericBase.js @@ -25,11 +25,16 @@ o(A); //// [infinitelyExpandingTypesNonGenericBase.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Functionality = (function () { function Functionality() { } @@ -43,7 +48,7 @@ var Base = (function () { var A = (function (_super) { __extends(A, _super); function A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A; }(Base)); diff --git a/tests/baselines/reference/inheritFromGenericTypeParameter.js b/tests/baselines/reference/inheritFromGenericTypeParameter.js index 40e6abd3e53..f8145ec2c01 100644 --- a/tests/baselines/reference/inheritFromGenericTypeParameter.js +++ b/tests/baselines/reference/inheritFromGenericTypeParameter.js @@ -3,15 +3,20 @@ class C extends T { } interface I extends T { } //// [inheritFromGenericTypeParameter.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(T)); diff --git a/tests/baselines/reference/inheritSameNamePrivatePropertiesFromSameOrigin.js b/tests/baselines/reference/inheritSameNamePrivatePropertiesFromSameOrigin.js index a0874eb1c72..138e3aa5694 100644 --- a/tests/baselines/reference/inheritSameNamePrivatePropertiesFromSameOrigin.js +++ b/tests/baselines/reference/inheritSameNamePrivatePropertiesFromSameOrigin.js @@ -11,11 +11,16 @@ interface A extends C, C2 { // ok } //// [inheritSameNamePrivatePropertiesFromSameOrigin.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { } @@ -24,14 +29,14 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(B)); diff --git a/tests/baselines/reference/inheritance.js b/tests/baselines/reference/inheritance.js index cbfef2d3382..48d96b10f9c 100644 --- a/tests/baselines/reference/inheritance.js +++ b/tests/baselines/reference/inheritance.js @@ -35,11 +35,16 @@ class Baad extends Good { //// [inheritance.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B1 = (function () { function B1() { } @@ -53,14 +58,14 @@ var B2 = (function () { var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(B1)); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(B2)); @@ -72,7 +77,7 @@ var N = (function () { var ND = (function (_super) { __extends(ND, _super); function ND() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ND; }(N)); @@ -86,7 +91,7 @@ var Good = (function () { var Baad = (function (_super) { __extends(Baad, _super); function Baad() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Baad.prototype.f = function () { return 0; }; Baad.prototype.g = function (n) { return 0; }; diff --git a/tests/baselines/reference/inheritance1.js b/tests/baselines/reference/inheritance1.js index 86de0b76350..a00330e8556 100644 --- a/tests/baselines/reference/inheritance1.js +++ b/tests/baselines/reference/inheritance1.js @@ -62,11 +62,16 @@ l1 = sc; l1 = c; //// [inheritance1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Control = (function () { function Control() { } @@ -75,7 +80,7 @@ var Control = (function () { var Button = (function (_super) { __extends(Button, _super); function Button() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Button.prototype.select = function () { }; return Button; @@ -83,7 +88,7 @@ var Button = (function (_super) { var TextBox = (function (_super) { __extends(TextBox, _super); function TextBox() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } TextBox.prototype.select = function () { }; return TextBox; @@ -91,14 +96,14 @@ var TextBox = (function (_super) { var ImageBase = (function (_super) { __extends(ImageBase, _super); function ImageBase() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ImageBase; }(Control)); var Image1 = (function (_super) { __extends(Image1, _super); function Image1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Image1; }(Control)); diff --git a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.js b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.js index 57a9c897583..52ab48573fd 100644 --- a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.js +++ b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.js @@ -11,11 +11,16 @@ class C extends B { //// [inheritanceGrandParentPrivateMemberCollision.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -25,14 +30,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.myMethod = function () { }; return C; diff --git a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.js b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.js index 83c5aa3e4cd..c64a0e4259c 100644 --- a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.js +++ b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.js @@ -11,11 +11,16 @@ class C extends B { //// [inheritanceGrandParentPrivateMemberCollisionWithPublicMember.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -25,14 +30,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.myMethod = function () { }; return C; diff --git a/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.js b/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.js index b11b6e318a7..9ac0fe18592 100644 --- a/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.js +++ b/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.js @@ -11,11 +11,16 @@ class C extends B { //// [inheritanceGrandParentPublicMemberCollisionWithPrivateMember.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -25,14 +30,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.myMethod = function () { }; return C; diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js b/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js index 09ea08899d9..fae79488dce 100644 --- a/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js @@ -18,11 +18,16 @@ class b extends a { } //// [inheritanceMemberAccessorOverridingAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -40,7 +45,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(b.prototype, "x", { get: function () { diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js b/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js index 59d2abdaab2..3fc6417afaf 100644 --- a/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js @@ -15,11 +15,16 @@ class b extends a { } //// [inheritanceMemberAccessorOverridingMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -31,7 +36,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(b.prototype, "x", { get: function () { diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js b/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js index 98a95747a8e..1d0a8f09a40 100644 --- a/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js @@ -13,11 +13,16 @@ class b extends a { } //// [inheritanceMemberAccessorOverridingProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -26,7 +31,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(b.prototype, "x", { get: function () { diff --git a/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js b/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js index 0d54e5d42fa..93b72b73c8b 100644 --- a/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js @@ -15,11 +15,16 @@ class b extends a { } //// [inheritanceMemberFuncOverridingAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -37,7 +42,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.prototype.x = function () { return "20"; diff --git a/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.js b/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.js index 9af25c6fdb8..0f189aa50cc 100644 --- a/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.js +++ b/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.js @@ -12,11 +12,16 @@ class b extends a { } //// [inheritanceMemberFuncOverridingMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -28,7 +33,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.prototype.x = function () { return "20"; diff --git a/tests/baselines/reference/inheritanceMemberFuncOverridingProperty.js b/tests/baselines/reference/inheritanceMemberFuncOverridingProperty.js index 5c77ce08101..996138a53d9 100644 --- a/tests/baselines/reference/inheritanceMemberFuncOverridingProperty.js +++ b/tests/baselines/reference/inheritanceMemberFuncOverridingProperty.js @@ -10,11 +10,16 @@ class b extends a { } //// [inheritanceMemberFuncOverridingProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -23,7 +28,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.prototype.x = function () { return "20"; diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js b/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js index 82c7a94d17c..97b856980ea 100644 --- a/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js @@ -14,11 +14,16 @@ class b extends a { } //// [inheritanceMemberPropertyOverridingAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -37,7 +42,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.js b/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.js index e6929218e63..c7c6c84f9d0 100644 --- a/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.js +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.js @@ -10,11 +10,16 @@ class b extends a { } //// [inheritanceMemberPropertyOverridingMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -26,7 +31,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.js b/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.js index 85764cddc52..c8e9c5ef9d4 100644 --- a/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.js +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.js @@ -8,11 +8,16 @@ class b extends a { } //// [inheritanceMemberPropertyOverridingProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -21,7 +26,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inheritanceOfGenericConstructorMethod1.js b/tests/baselines/reference/inheritanceOfGenericConstructorMethod1.js index 28fe8144509..62355930d92 100644 --- a/tests/baselines/reference/inheritanceOfGenericConstructorMethod1.js +++ b/tests/baselines/reference/inheritanceOfGenericConstructorMethod1.js @@ -8,11 +8,16 @@ var b3 = new B(); // error, could not select overload for 'new' expression //// [inheritanceOfGenericConstructorMethod1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -21,7 +26,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.js b/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.js index 0cc71e168f4..12c5eac07e9 100644 --- a/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.js +++ b/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.js @@ -15,11 +15,16 @@ var n3 = new N.D2(); // no error, D2 //// [inheritanceOfGenericConstructorMethod2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { var C1 = (function () { @@ -40,7 +45,7 @@ var N; var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(M.C1)); @@ -48,7 +53,7 @@ var N; var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(M.C2)); diff --git a/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js b/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js index bb91ee5f9ea..4af25e03d13 100644 --- a/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js @@ -18,11 +18,16 @@ class b extends a { } //// [inheritanceStaticAccessorOverridingAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -40,7 +45,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(b, "x", { get: function () { diff --git a/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js b/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js index 363852a84bf..904868fecd9 100644 --- a/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js +++ b/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js @@ -15,11 +15,16 @@ class b extends a { } //// [inheritanceStaticAccessorOverridingMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -31,7 +36,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(b, "x", { get: function () { diff --git a/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js b/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js index ba8df7a5f0b..cf6e23685f1 100644 --- a/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js +++ b/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js @@ -13,11 +13,16 @@ class b extends a { } //// [inheritanceStaticAccessorOverridingProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -26,7 +31,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(b, "x", { get: function () { diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js index e464029fba5..91946af7478 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js @@ -15,11 +15,16 @@ class b extends a { } //// [inheritanceStaticFuncOverridingAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -37,7 +42,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.x = function () { return "20"; diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js index cc825cfa9b5..9b7e0dd925c 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js @@ -12,11 +12,16 @@ class b extends a { } //// [inheritanceStaticFuncOverridingAccessorOfFuncType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -32,7 +37,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.x = function () { return "20"; diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.js b/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.js index 466c65fa7d5..7e50c2c0318 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.js @@ -12,11 +12,16 @@ class b extends a { } //// [inheritanceStaticFuncOverridingMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -28,7 +33,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.x = function () { return "20"; diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingProperty.js b/tests/baselines/reference/inheritanceStaticFuncOverridingProperty.js index dfc0ce2c13f..fab0f4fb579 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingProperty.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingProperty.js @@ -10,11 +10,16 @@ class b extends a { } //// [inheritanceStaticFuncOverridingProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -23,7 +28,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.x = function () { return "20"; diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.js b/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.js index da7850f2071..b973095e5b8 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.js @@ -10,11 +10,16 @@ class b extends a { } //// [inheritanceStaticFuncOverridingPropertyOfFuncType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -23,7 +28,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.x = function () { return "20"; diff --git a/tests/baselines/reference/inheritanceStaticFunctionOverridingInstanceProperty.js b/tests/baselines/reference/inheritanceStaticFunctionOverridingInstanceProperty.js index d5916a9d452..017adeea3c7 100644 --- a/tests/baselines/reference/inheritanceStaticFunctionOverridingInstanceProperty.js +++ b/tests/baselines/reference/inheritanceStaticFunctionOverridingInstanceProperty.js @@ -10,11 +10,16 @@ class b extends a { } //// [inheritanceStaticFunctionOverridingInstanceProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -23,7 +28,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.x = function () { return new b().x; diff --git a/tests/baselines/reference/inheritanceStaticMembersCompatible.js b/tests/baselines/reference/inheritanceStaticMembersCompatible.js index b4cae99b64b..96416e977fa 100644 --- a/tests/baselines/reference/inheritanceStaticMembersCompatible.js +++ b/tests/baselines/reference/inheritanceStaticMembersCompatible.js @@ -8,11 +8,16 @@ class b extends a { } //// [inheritanceStaticMembersCompatible.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -21,7 +26,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inheritanceStaticMembersIncompatible.js b/tests/baselines/reference/inheritanceStaticMembersIncompatible.js index 38c637dd8d1..15f3298f2cc 100644 --- a/tests/baselines/reference/inheritanceStaticMembersIncompatible.js +++ b/tests/baselines/reference/inheritanceStaticMembersIncompatible.js @@ -8,11 +8,16 @@ class b extends a { } //// [inheritanceStaticMembersIncompatible.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -21,7 +26,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js b/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js index 49dc86fc500..79d2e88b646 100644 --- a/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js @@ -13,11 +13,16 @@ class b extends a { } //// [inheritanceStaticPropertyOverridingAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -36,7 +41,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inheritanceStaticPropertyOverridingMethod.js b/tests/baselines/reference/inheritanceStaticPropertyOverridingMethod.js index bcd63537540..1ec8e5f5f65 100644 --- a/tests/baselines/reference/inheritanceStaticPropertyOverridingMethod.js +++ b/tests/baselines/reference/inheritanceStaticPropertyOverridingMethod.js @@ -10,11 +10,16 @@ class b extends a { } //// [inheritanceStaticPropertyOverridingMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -26,7 +31,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inheritanceStaticPropertyOverridingProperty.js b/tests/baselines/reference/inheritanceStaticPropertyOverridingProperty.js index c1bdd9b66a2..6c83789d51d 100644 --- a/tests/baselines/reference/inheritanceStaticPropertyOverridingProperty.js +++ b/tests/baselines/reference/inheritanceStaticPropertyOverridingProperty.js @@ -8,11 +8,16 @@ class b extends a { } //// [inheritanceStaticPropertyOverridingProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -21,7 +26,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inheritedConstructorWithRestParams.js b/tests/baselines/reference/inheritedConstructorWithRestParams.js index 6a30836d728..5e7e3736885 100644 --- a/tests/baselines/reference/inheritedConstructorWithRestParams.js +++ b/tests/baselines/reference/inheritedConstructorWithRestParams.js @@ -15,11 +15,16 @@ new Derived("", 3); new Derived(3); //// [inheritedConstructorWithRestParams.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { var a = []; @@ -32,7 +37,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/inheritedConstructorWithRestParams2.js b/tests/baselines/reference/inheritedConstructorWithRestParams2.js index 9a1b13a8434..c27b723b562 100644 --- a/tests/baselines/reference/inheritedConstructorWithRestParams2.js +++ b/tests/baselines/reference/inheritedConstructorWithRestParams2.js @@ -35,11 +35,16 @@ new Derived("", 3, "", 3); new Derived("", 3, "", ""); //// [inheritedConstructorWithRestParams2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var IBaseBase = (function () { function IBaseBase(x) { } @@ -53,14 +58,14 @@ var BaseBase2 = (function () { var Base = (function (_super) { __extends(Base, _super); function Base() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Base; }(BaseBase)); var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/inheritedModuleMembersForClodule.js b/tests/baselines/reference/inheritedModuleMembersForClodule.js index cd49009fed9..be7aec77731 100644 --- a/tests/baselines/reference/inheritedModuleMembersForClodule.js +++ b/tests/baselines/reference/inheritedModuleMembersForClodule.js @@ -22,11 +22,16 @@ class E extends D { //// [inheritedModuleMembersForClodule.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -38,7 +43,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); @@ -52,7 +57,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.bar = function () { return this.foo(); diff --git a/tests/baselines/reference/instanceOfAssignability.js b/tests/baselines/reference/instanceOfAssignability.js index b8f39c5b0e2..db5554596af 100644 --- a/tests/baselines/reference/instanceOfAssignability.js +++ b/tests/baselines/reference/instanceOfAssignability.js @@ -90,11 +90,16 @@ function fn8(x: Alpha|Beta|Gamma) { //// [instanceOfAssignability.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // Derived1 is assignable to, but not a subtype of, Base var Derived1 = (function () { function Derived1() { @@ -115,14 +120,14 @@ var Animal = (function () { var Mammal = (function (_super) { __extends(Mammal, _super); function Mammal() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Mammal; }(Animal)); var Giraffe = (function (_super) { __extends(Giraffe, _super); function Giraffe() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Giraffe; }(Mammal)); diff --git a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js index 8dc5227685f..44c781c8c98 100644 --- a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js +++ b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js @@ -43,11 +43,16 @@ module Generic { } //// [instancePropertiesInheritedIntoClassType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var NonGeneric; (function (NonGeneric) { var C = (function () { @@ -69,7 +74,7 @@ var NonGeneric; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); @@ -101,7 +106,7 @@ var Generic; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/instanceSubtypeCheck2.js b/tests/baselines/reference/instanceSubtypeCheck2.js index 914f3796001..0a02162d707 100644 --- a/tests/baselines/reference/instanceSubtypeCheck2.js +++ b/tests/baselines/reference/instanceSubtypeCheck2.js @@ -8,11 +8,16 @@ class C2 extends C1 { } //// [instanceSubtypeCheck2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1() { } @@ -21,7 +26,7 @@ var C1 = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(C1)); diff --git a/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.js b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.js new file mode 100644 index 00000000000..bf5a6f7bce1 --- /dev/null +++ b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.js @@ -0,0 +1,34 @@ +//// [instanceofOperatorWithInvalidStaticToString.ts] +declare class StaticToString { + static toString(): void; +} + +function foo(staticToString: StaticToString) { + return staticToString instanceof StaticToString; +} + +declare class StaticToNumber { + static toNumber(): void; +} +function bar(staticToNumber: StaticToNumber) { + return staticToNumber instanceof StaticToNumber; +} + +declare class NormalToString { + toString(): void; +} +function baz(normal: NormalToString) { + return normal instanceof NormalToString; +} + + +//// [instanceofOperatorWithInvalidStaticToString.js] +function foo(staticToString) { + return staticToString instanceof StaticToString; +} +function bar(staticToNumber) { + return staticToNumber instanceof StaticToNumber; +} +function baz(normal) { + return normal instanceof NormalToString; +} diff --git a/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.symbols b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.symbols new file mode 100644 index 00000000000..4f4dbda611a --- /dev/null +++ b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.symbols @@ -0,0 +1,50 @@ +=== tests/cases/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidStaticToString.ts === +declare class StaticToString { +>StaticToString : Symbol(StaticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 0, 0)) + + static toString(): void; +>toString : Symbol(StaticToString.toString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 0, 30)) +} + +function foo(staticToString: StaticToString) { +>foo : Symbol(foo, Decl(instanceofOperatorWithInvalidStaticToString.ts, 2, 1)) +>staticToString : Symbol(staticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 4, 13)) +>StaticToString : Symbol(StaticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 0, 0)) + + return staticToString instanceof StaticToString; +>staticToString : Symbol(staticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 4, 13)) +>StaticToString : Symbol(StaticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 0, 0)) +} + +declare class StaticToNumber { +>StaticToNumber : Symbol(StaticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 6, 1)) + + static toNumber(): void; +>toNumber : Symbol(StaticToNumber.toNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 8, 30)) +} +function bar(staticToNumber: StaticToNumber) { +>bar : Symbol(bar, Decl(instanceofOperatorWithInvalidStaticToString.ts, 10, 1)) +>staticToNumber : Symbol(staticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 11, 13)) +>StaticToNumber : Symbol(StaticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 6, 1)) + + return staticToNumber instanceof StaticToNumber; +>staticToNumber : Symbol(staticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 11, 13)) +>StaticToNumber : Symbol(StaticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 6, 1)) +} + +declare class NormalToString { +>NormalToString : Symbol(NormalToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 13, 1)) + + toString(): void; +>toString : Symbol(NormalToString.toString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 15, 30)) +} +function baz(normal: NormalToString) { +>baz : Symbol(baz, Decl(instanceofOperatorWithInvalidStaticToString.ts, 17, 1)) +>normal : Symbol(normal, Decl(instanceofOperatorWithInvalidStaticToString.ts, 18, 13)) +>NormalToString : Symbol(NormalToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 13, 1)) + + return normal instanceof NormalToString; +>normal : Symbol(normal, Decl(instanceofOperatorWithInvalidStaticToString.ts, 18, 13)) +>NormalToString : Symbol(NormalToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 13, 1)) +} + diff --git a/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.types b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.types new file mode 100644 index 00000000000..11efa0cffc3 --- /dev/null +++ b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.types @@ -0,0 +1,53 @@ +=== tests/cases/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidStaticToString.ts === +declare class StaticToString { +>StaticToString : StaticToString + + static toString(): void; +>toString : () => void +} + +function foo(staticToString: StaticToString) { +>foo : (staticToString: StaticToString) => boolean +>staticToString : StaticToString +>StaticToString : StaticToString + + return staticToString instanceof StaticToString; +>staticToString instanceof StaticToString : boolean +>staticToString : StaticToString +>StaticToString : typeof StaticToString +} + +declare class StaticToNumber { +>StaticToNumber : StaticToNumber + + static toNumber(): void; +>toNumber : () => void +} +function bar(staticToNumber: StaticToNumber) { +>bar : (staticToNumber: StaticToNumber) => boolean +>staticToNumber : StaticToNumber +>StaticToNumber : StaticToNumber + + return staticToNumber instanceof StaticToNumber; +>staticToNumber instanceof StaticToNumber : boolean +>staticToNumber : StaticToNumber +>StaticToNumber : typeof StaticToNumber +} + +declare class NormalToString { +>NormalToString : NormalToString + + toString(): void; +>toString : () => void +} +function baz(normal: NormalToString) { +>baz : (normal: NormalToString) => boolean +>normal : NormalToString +>NormalToString : NormalToString + + return normal instanceof NormalToString; +>normal instanceof NormalToString : boolean +>normal : NormalToString +>NormalToString : typeof NormalToString +} + diff --git a/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.js b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.js index 54a574238e5..b7d2ec46914 100644 --- a/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.js +++ b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.js @@ -72,11 +72,16 @@ function goo(x: A) { //// [instanceofWithStructurallyIdenticalTypes.js] // Repro from #7271 -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1() { } @@ -128,7 +133,7 @@ var A = (function () { var A1 = (function (_super) { __extends(A1, _super); function A1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A1; }(A)); @@ -140,7 +145,7 @@ var A2 = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/instantiatedReturnTypeContravariance.js b/tests/baselines/reference/instantiatedReturnTypeContravariance.js index bc496a63632..52f96561f20 100644 --- a/tests/baselines/reference/instantiatedReturnTypeContravariance.js +++ b/tests/baselines/reference/instantiatedReturnTypeContravariance.js @@ -31,11 +31,16 @@ return null; //// [instantiatedReturnTypeContravariance.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var c = (function () { function c() { } @@ -47,7 +52,7 @@ var c = (function () { var d = (function (_super) { __extends(d, _super); function d() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } d.prototype.foo = function () { return null; diff --git a/tests/baselines/reference/interfaceClassMerging.js b/tests/baselines/reference/interfaceClassMerging.js index 6542376a19b..e2167776f22 100644 --- a/tests/baselines/reference/interfaceClassMerging.js +++ b/tests/baselines/reference/interfaceClassMerging.js @@ -41,11 +41,16 @@ obj = bar; //// [interfaceClassMerging.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -57,7 +62,7 @@ var Foo = (function () { var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Bar.prototype.method = function (a) { return this.optionalProperty; diff --git a/tests/baselines/reference/interfaceClassMerging2.js b/tests/baselines/reference/interfaceClassMerging2.js index 70a62da4131..4c879ba4cab 100644 --- a/tests/baselines/reference/interfaceClassMerging2.js +++ b/tests/baselines/reference/interfaceClassMerging2.js @@ -37,11 +37,16 @@ foo = bar; //// [interfaceClassMerging2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -53,7 +58,7 @@ var Foo = (function () { var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Bar.prototype.classBarMethod = function () { return this; diff --git a/tests/baselines/reference/interfaceExtendsClass1.js b/tests/baselines/reference/interfaceExtendsClass1.js index 8324a001f91..69560e82557 100644 --- a/tests/baselines/reference/interfaceExtendsClass1.js +++ b/tests/baselines/reference/interfaceExtendsClass1.js @@ -19,11 +19,16 @@ class Location { //// [interfaceExtendsClass1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Control = (function () { function Control() { } @@ -32,7 +37,7 @@ var Control = (function () { var Button = (function (_super) { __extends(Button, _super); function Button() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Button.prototype.select = function () { }; return Button; @@ -40,7 +45,7 @@ var Button = (function (_super) { var TextBox = (function (_super) { __extends(TextBox, _super); function TextBox() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } TextBox.prototype.select = function () { }; return TextBox; @@ -48,7 +53,7 @@ var TextBox = (function (_super) { var Image = (function (_super) { __extends(Image, _super); function Image() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Image; }(Control)); diff --git a/tests/baselines/reference/interfaceExtendsClassWithPrivate1.js b/tests/baselines/reference/interfaceExtendsClassWithPrivate1.js index 1179ff101df..12d1539bb3d 100644 --- a/tests/baselines/reference/interfaceExtendsClassWithPrivate1.js +++ b/tests/baselines/reference/interfaceExtendsClassWithPrivate1.js @@ -28,11 +28,16 @@ c = d; d = c; // error //// [interfaceExtendsClassWithPrivate1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { this.x = 1; @@ -43,7 +48,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.foo = function (x) { return x; }; D.prototype.other = function (x) { return x; }; diff --git a/tests/baselines/reference/interfaceExtendsClassWithPrivate2.js b/tests/baselines/reference/interfaceExtendsClassWithPrivate2.js index 49b5efbd012..cec3eed8497 100644 --- a/tests/baselines/reference/interfaceExtendsClassWithPrivate2.js +++ b/tests/baselines/reference/interfaceExtendsClassWithPrivate2.js @@ -24,11 +24,16 @@ class D2 extends C implements I { // error } //// [interfaceExtendsClassWithPrivate2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { this.x = 1; @@ -39,7 +44,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = 2; _this.y = 3; return _this; @@ -52,7 +57,7 @@ var D = (function (_super) { var D2 = (function (_super) { __extends(D2, _super); function D2() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = ""; return _this; } diff --git a/tests/baselines/reference/interfaceImplementation8.js b/tests/baselines/reference/interfaceImplementation8.js index afb5a795264..c966cdc2c14 100644 --- a/tests/baselines/reference/interfaceImplementation8.js +++ b/tests/baselines/reference/interfaceImplementation8.js @@ -41,11 +41,16 @@ class C8 extends C7 implements i2{ //// [interfaceImplementation8.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1() { } @@ -64,21 +69,21 @@ var C3 = (function () { var C4 = (function (_super) { __extends(C4, _super); function C4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C4; }(C1)); var C5 = (function (_super) { __extends(C5, _super); function C5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C5; }(C2)); var C6 = (function (_super) { __extends(C6, _super); function C6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C6; }(C3)); @@ -90,7 +95,7 @@ var C7 = (function () { var C8 = (function (_super) { __extends(C8, _super); function C8() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C8; }(C7)); diff --git a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js index 6e9b09c906f..2ca72edf3c1 100644 --- a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js +++ b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js @@ -80,11 +80,16 @@ module YYY4 { //// [invalidModuleWithStatementsOfEveryKind.js] // All of these 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Y; (function (Y) { var A = (function () { @@ -95,7 +100,7 @@ var Y; var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return BB; }(A)); @@ -110,7 +115,7 @@ var Y2; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(AA)); @@ -144,7 +149,7 @@ var YY; var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return BB; }(A)); @@ -159,7 +164,7 @@ var YY2; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(AA)); @@ -193,7 +198,7 @@ var YYY; var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return BB; }(A)); @@ -208,7 +213,7 @@ var YYY2; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(AA)); diff --git a/tests/baselines/reference/invalidMultipleVariableDeclarations.js b/tests/baselines/reference/invalidMultipleVariableDeclarations.js index 340429cc398..7e1616cfca4 100644 --- a/tests/baselines/reference/invalidMultipleVariableDeclarations.js +++ b/tests/baselines/reference/invalidMultipleVariableDeclarations.js @@ -54,11 +54,16 @@ var m: typeof M; var m = M.A; //// [invalidMultipleVariableDeclarations.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -67,7 +72,7 @@ var C = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(C)); diff --git a/tests/baselines/reference/invalidNewTarget.es5.errors.txt b/tests/baselines/reference/invalidNewTarget.es5.errors.txt new file mode 100644 index 00000000000..080267c36eb --- /dev/null +++ b/tests/baselines/reference/invalidNewTarget.es5.errors.txt @@ -0,0 +1,78 @@ +tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts(1,11): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts(2,17): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts(5,6): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts(6,18): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts(7,22): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts(8,20): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts(9,15): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts(11,13): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts(12,25): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts(13,29): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts(14,27): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts(15,22): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts(19,6): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts(20,18): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts(21,22): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts(22,20): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts(23,8): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + + +==== tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts (17 errors) ==== + const a = new.target; + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + const b = () => new.target; + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + + class C { + [new.target]() { } + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + c() { return new.target; } + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + get d() { return new.target; } + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + set e(_) { _ = new.target; } + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + f = () => new.target; + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + + static [new.target]() { } + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + static g() { return new.target; } + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + static get h() { return new.target; } + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + static set i(_) { _ = new.target; } + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + static j = () => new.target; + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + } + + const O = { + [new.target]: undefined, + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + k() { return new.target; }, + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + get l() { return new.target; }, + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + set m(_) { _ = new.target; }, + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + n: new.target, + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + }; \ No newline at end of file diff --git a/tests/baselines/reference/invalidNewTarget.es5.js b/tests/baselines/reference/invalidNewTarget.es5.js new file mode 100644 index 00000000000..866dac270af --- /dev/null +++ b/tests/baselines/reference/invalidNewTarget.es5.js @@ -0,0 +1,77 @@ +//// [invalidNewTarget.es5.ts] +const a = new.target; +const b = () => new.target; + +class C { + [new.target]() { } + c() { return new.target; } + get d() { return new.target; } + set e(_) { _ = new.target; } + f = () => new.target; + + static [new.target]() { } + static g() { return new.target; } + static get h() { return new.target; } + static set i(_) { _ = new.target; } + static j = () => new.target; +} + +const O = { + [new.target]: undefined, + k() { return new.target; }, + get l() { return new.target; }, + set m(_) { _ = new.target; }, + n: new.target, +}; + +//// [invalidNewTarget.es5.js] +var a = _newTarget; +var b = function () { return _newTarget; }; +var C = (function () { + function C() { + var _newTarget = this.constructor; + this.f = function () { return _newTarget; }; + } + C.prototype[_newTarget] = function () { }; + C.prototype.c = function () { var _newTarget = void 0; return _newTarget; }; + Object.defineProperty(C.prototype, "d", { + get: function () { var _newTarget = void 0; return _newTarget; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "e", { + set: function (_) { var _newTarget = void 0; _ = _newTarget; }, + enumerable: true, + configurable: true + }); + C[_newTarget] = function () { }; + C.g = function () { var _newTarget = void 0; return _newTarget; }; + Object.defineProperty(C, "h", { + get: function () { var _newTarget = void 0; return _newTarget; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "i", { + set: function (_) { var _newTarget = void 0; _ = _newTarget; }, + enumerable: true, + configurable: true + }); + return C; +}()); +C.j = function () { return _newTarget; }; +var O = (_a = {}, + _a[_newTarget] = undefined, + _a.k = function () { var _newTarget = void 0; return _newTarget; }, + Object.defineProperty(_a, "l", { + get: function () { var _newTarget = void 0; return _newTarget; }, + enumerable: true, + configurable: true + }), + Object.defineProperty(_a, "m", { + set: function (_) { var _newTarget = void 0; _ = _newTarget; }, + enumerable: true, + configurable: true + }), + _a.n = _newTarget, + _a); +var _a; diff --git a/tests/baselines/reference/invalidNewTarget.es6.errors.txt b/tests/baselines/reference/invalidNewTarget.es6.errors.txt new file mode 100644 index 00000000000..ee5404ed781 --- /dev/null +++ b/tests/baselines/reference/invalidNewTarget.es6.errors.txt @@ -0,0 +1,78 @@ +tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts(1,11): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts(2,17): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts(5,6): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts(6,18): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts(7,22): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts(8,20): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts(9,15): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts(11,13): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts(12,25): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts(13,29): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts(14,27): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts(15,22): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts(19,6): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts(20,18): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts(21,22): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts(22,20): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. +tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts(23,8): error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + + +==== tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts (17 errors) ==== + const a = new.target; + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + const b = () => new.target; + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + + class C { + [new.target]() { } + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + c() { return new.target; } + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + get d() { return new.target; } + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + set e(_) { _ = new.target; } + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + f = () => new.target; + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + + static [new.target]() { } + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + static g() { return new.target; } + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + static get h() { return new.target; } + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + static set i(_) { _ = new.target; } + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + static j = () => new.target; + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + } + + const O = { + [new.target]: undefined, + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + k() { return new.target; }, + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + get l() { return new.target; }, + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + set m(_) { _ = new.target; }, + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + n: new.target, + ~~~~~~~~~~ +!!! error TS17013: Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor. + }; \ No newline at end of file diff --git a/tests/baselines/reference/invalidNewTarget.es6.js b/tests/baselines/reference/invalidNewTarget.es6.js new file mode 100644 index 00000000000..ed1b2cc1592 --- /dev/null +++ b/tests/baselines/reference/invalidNewTarget.es6.js @@ -0,0 +1,50 @@ +//// [invalidNewTarget.es6.ts] +const a = new.target; +const b = () => new.target; + +class C { + [new.target]() { } + c() { return new.target; } + get d() { return new.target; } + set e(_) { _ = new.target; } + f = () => new.target; + + static [new.target]() { } + static g() { return new.target; } + static get h() { return new.target; } + static set i(_) { _ = new.target; } + static j = () => new.target; +} + +const O = { + [new.target]: undefined, + k() { return new.target; }, + get l() { return new.target; }, + set m(_) { _ = new.target; }, + n: new.target, +}; + +//// [invalidNewTarget.es6.js] +const a = new.target; +const b = () => new.target; +class C { + constructor() { + this.f = () => new.target; + } + [new.target]() { } + c() { return new.target; } + get d() { return new.target; } + set e(_) { _ = new.target; } + static [new.target]() { } + static g() { return new.target; } + static get h() { return new.target; } + static set i(_) { _ = new.target; } +} +C.j = () => new.target; +const O = { + [new.target]: undefined, + k() { return new.target; }, + get l() { return new.target; }, + set m(_) { _ = new.target; }, + n: new.target, +}; diff --git a/tests/baselines/reference/invalidReturnStatements.errors.txt b/tests/baselines/reference/invalidReturnStatements.errors.txt index 6fbe961cd54..0f51e75a47d 100644 --- a/tests/baselines/reference/invalidReturnStatements.errors.txt +++ b/tests/baselines/reference/invalidReturnStatements.errors.txt @@ -2,9 +2,9 @@ tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(2 tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(3,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(4,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(5,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(16,29): error TS2322: Type '{ id: number; }' is not assignable to type 'D'. +tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(16,22): error TS2322: Type '{ id: number; }' is not assignable to type 'D'. Property 'name' is missing in type '{ id: number; }'. -tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(18,29): error TS2322: Type 'C' is not assignable to type 'D'. +tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(18,22): error TS2322: Type 'C' is not assignable to type 'D'. Property 'name' is missing in type 'C'. @@ -33,12 +33,12 @@ tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(1 name: string; } function fn10(): D { return { id: 12 }; } - ~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ id: number; }' is not assignable to type 'D'. !!! error TS2322: Property 'name' is missing in type '{ id: number; }'. function fn11(): D { return new C(); } - ~~~~~~~ + ~~~~~~~~~~~~~~~ !!! error TS2322: Type 'C' is not assignable to type 'D'. !!! error TS2322: Property 'name' is missing in type 'C'. diff --git a/tests/baselines/reference/invalidReturnStatements.js b/tests/baselines/reference/invalidReturnStatements.js index a6b07b7d7bd..af20c18c853 100644 --- a/tests/baselines/reference/invalidReturnStatements.js +++ b/tests/baselines/reference/invalidReturnStatements.js @@ -21,11 +21,16 @@ function fn11(): D { return new C(); } //// [invalidReturnStatements.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // all the following should be error function fn1() { } function fn2() { } @@ -41,7 +46,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/invalidSplice.types b/tests/baselines/reference/invalidSplice.types index 876846d3da9..9ff59021725 100644 --- a/tests/baselines/reference/invalidSplice.types +++ b/tests/baselines/reference/invalidSplice.types @@ -2,9 +2,9 @@ var arr = [].splice(0,3,4,5); >arr : any[] >[].splice(0,3,4,5) : any[] ->[].splice : { (start: number): any[]; (start: number, deleteCount: number, ...items: any[]): any[]; } +>[].splice : { (start: number, deleteCount?: number): any[]; (start: number, deleteCount: number, ...items: any[]): any[]; } >[] : undefined[] ->splice : { (start: number): any[]; (start: number, deleteCount: number, ...items: any[]): any[]; } +>splice : { (start: number, deleteCount?: number): any[]; (start: number, deleteCount: number, ...items: any[]): any[]; } >0 : 0 >3 : 3 >4 : 4 diff --git a/tests/baselines/reference/isolatedModulesImportExportElision.js b/tests/baselines/reference/isolatedModulesImportExportElision.js index 6f1d38dcbb5..80f47941e60 100644 --- a/tests/baselines/reference/isolatedModulesImportExportElision.js +++ b/tests/baselines/reference/isolatedModulesImportExportElision.js @@ -15,18 +15,23 @@ export var z = x; //// [file1.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var module_1 = require("module"); var module_2 = require("module"); var ns = require("module"); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(module_2.c2.C)); diff --git a/tests/baselines/reference/isolatedModulesPlainFile-UMD.js b/tests/baselines/reference/isolatedModulesPlainFile-UMD.js index ecc8ade69b7..ece949b9100 100644 --- a/tests/baselines/reference/isolatedModulesPlainFile-UMD.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-UMD.js @@ -5,14 +5,15 @@ run(1); //// [isolatedModulesPlainFile-UMD.js] -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { "use strict"; run(1); }); diff --git a/tests/baselines/reference/jsxAttributeWithoutExpressionReact.errors.txt b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.errors.txt new file mode 100644 index 00000000000..3801562709a --- /dev/null +++ b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.errors.txt @@ -0,0 +1,33 @@ +tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(3,2): error TS2304: Cannot find name 'View'. +tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(4,6): error TS2304: Cannot find name 'ListView'. +tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(5,10): error TS2304: Cannot find name 'RefreshControl'. +tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(5,35): error TS17000: JSX attributes must only be assigned a non-empty 'expression'. +tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(6,44): error TS17000: JSX attributes must only be assigned a non-empty 'expression'. +tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(7,7): error TS2304: Cannot find name 'ListView'. +tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(8,3): error TS2304: Cannot find name 'View'. + + +==== tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx (7 errors) ==== + + declare var React: any; + + ~~~~ +!!! error TS2304: Cannot find name 'View'. + + ~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'RefreshControl'. + ~~ +!!! error TS17000: JSX attributes must only be assigned a non-empty 'expression'. + } dataSource={this.state.ds} renderRow={}> + ~~ +!!! error TS17000: JSX attributes must only be assigned a non-empty 'expression'. + + ~~~~~~~~ +!!! error TS2304: Cannot find name 'ListView'. + + ~~~~ +!!! error TS2304: Cannot find name 'View'. + \ No newline at end of file diff --git a/tests/baselines/reference/jsxAttributeWithoutExpressionReact.js b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.js new file mode 100644 index 00000000000..f07cbabd7f8 --- /dev/null +++ b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.js @@ -0,0 +1,14 @@ +//// [jsxAttributeWithoutExpressionReact.tsx] + +declare var React: any; + + + } dataSource={this.state.ds} renderRow={}> + + + + +//// [jsxAttributeWithoutExpressionReact.js] +React.createElement(View, null, + React.createElement(ListView, { refreshControl: React.createElement(RefreshControl, { onRefresh: true, refreshing: true }), dataSource: this.state.ds, renderRow: true })); diff --git a/tests/baselines/reference/jsxInExtendsClause.js b/tests/baselines/reference/jsxInExtendsClause.js new file mode 100644 index 00000000000..779b2d4cf8a --- /dev/null +++ b/tests/baselines/reference/jsxInExtendsClause.js @@ -0,0 +1,40 @@ +//// [jsxInExtendsClause.tsx] +// https://github.com/Microsoft/TypeScript/issues/13157 +declare namespace React { + interface ComponentClass

{ new (): Component; } + class Component {} +} +declare function createComponentClass

(factory: () => React.ComponentClass

): React.ComponentClass

; +class Foo extends createComponentClass(() => class extends React.Component<{}, {}> { + render() { + return Hello, world!; + } +}) {} + +//// [jsxInExtendsClause.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var Foo = (function (_super) { + __extends(Foo, _super); + function Foo() { + return _super !== null && _super.apply(this, arguments) || this; + } + return Foo; +}(createComponentClass(function () { return (function (_super) { + __extends(class_1, _super); + function class_1() { + return _super !== null && _super.apply(this, arguments) || this; + } + class_1.prototype.render = function () { + return React.createElement("span", null, "Hello, world!"); + }; + return class_1; +}(React.Component)); }))); diff --git a/tests/baselines/reference/jsxInExtendsClause.symbols b/tests/baselines/reference/jsxInExtendsClause.symbols new file mode 100644 index 00000000000..b7f3635bfd9 --- /dev/null +++ b/tests/baselines/reference/jsxInExtendsClause.symbols @@ -0,0 +1,42 @@ +=== tests/cases/compiler/jsxInExtendsClause.tsx === +// https://github.com/Microsoft/TypeScript/issues/13157 +declare namespace React { +>React : Symbol(React, Decl(jsxInExtendsClause.tsx, 0, 0)) + + interface ComponentClass

{ new (): Component; } +>ComponentClass : Symbol(ComponentClass, Decl(jsxInExtendsClause.tsx, 1, 25)) +>P : Symbol(P, Decl(jsxInExtendsClause.tsx, 2, 27)) +>Component : Symbol(Component, Decl(jsxInExtendsClause.tsx, 2, 59)) +>P : Symbol(P, Decl(jsxInExtendsClause.tsx, 2, 27)) + + class Component {} +>Component : Symbol(Component, Decl(jsxInExtendsClause.tsx, 2, 59)) +>A : Symbol(A, Decl(jsxInExtendsClause.tsx, 3, 18)) +>B : Symbol(B, Decl(jsxInExtendsClause.tsx, 3, 20)) +} +declare function createComponentClass

(factory: () => React.ComponentClass

): React.ComponentClass

; +>createComponentClass : Symbol(createComponentClass, Decl(jsxInExtendsClause.tsx, 4, 1)) +>P : Symbol(P, Decl(jsxInExtendsClause.tsx, 5, 38)) +>factory : Symbol(factory, Decl(jsxInExtendsClause.tsx, 5, 41)) +>React : Symbol(React, Decl(jsxInExtendsClause.tsx, 0, 0)) +>ComponentClass : Symbol(React.ComponentClass, Decl(jsxInExtendsClause.tsx, 1, 25)) +>P : Symbol(P, Decl(jsxInExtendsClause.tsx, 5, 38)) +>React : Symbol(React, Decl(jsxInExtendsClause.tsx, 0, 0)) +>ComponentClass : Symbol(React.ComponentClass, Decl(jsxInExtendsClause.tsx, 1, 25)) +>P : Symbol(P, Decl(jsxInExtendsClause.tsx, 5, 38)) + +class Foo extends createComponentClass(() => class extends React.Component<{}, {}> { +>Foo : Symbol(Foo, Decl(jsxInExtendsClause.tsx, 5, 106)) +>createComponentClass : Symbol(createComponentClass, Decl(jsxInExtendsClause.tsx, 4, 1)) +>React.Component : Symbol(React.Component, Decl(jsxInExtendsClause.tsx, 2, 59)) +>React : Symbol(React, Decl(jsxInExtendsClause.tsx, 0, 0)) +>Component : Symbol(React.Component, Decl(jsxInExtendsClause.tsx, 2, 59)) + + render() { +>render : Symbol((Anonymous class).render, Decl(jsxInExtendsClause.tsx, 6, 84)) + + return Hello, world!; +>span : Symbol(unknown) +>span : Symbol(unknown) + } +}) {} diff --git a/tests/baselines/reference/jsxInExtendsClause.types b/tests/baselines/reference/jsxInExtendsClause.types new file mode 100644 index 00000000000..5363c16a944 --- /dev/null +++ b/tests/baselines/reference/jsxInExtendsClause.types @@ -0,0 +1,46 @@ +=== tests/cases/compiler/jsxInExtendsClause.tsx === +// https://github.com/Microsoft/TypeScript/issues/13157 +declare namespace React { +>React : typeof React + + interface ComponentClass

{ new (): Component; } +>ComponentClass : ComponentClass

+>P : P +>Component : Component +>P : P + + class Component {} +>Component : Component +>A : A +>B : B +} +declare function createComponentClass

(factory: () => React.ComponentClass

): React.ComponentClass

; +>createComponentClass :

(factory: () => React.ComponentClass

) => React.ComponentClass

+>P : P +>factory : () => React.ComponentClass

+>React : any +>ComponentClass : React.ComponentClass

+>P : P +>React : any +>ComponentClass : React.ComponentClass

+>P : P + +class Foo extends createComponentClass(() => class extends React.Component<{}, {}> { +>Foo : Foo +>createComponentClass(() => class extends React.Component<{}, {}> { render() { return Hello, world!; }}) : React.Component<{}, {}> +>createComponentClass :

(factory: () => React.ComponentClass

) => React.ComponentClass

+>() => class extends React.Component<{}, {}> { render() { return Hello, world!; }} : () => typeof (Anonymous class) +>class extends React.Component<{}, {}> { render() { return Hello, world!; }} : typeof (Anonymous class) +>React.Component : React.Component<{}, {}> +>React : typeof React +>Component : typeof React.Component + + render() { +>render : () => any + + return Hello, world!; +>Hello, world! : any +>span : any +>span : any + } +}) {} diff --git a/tests/baselines/reference/jsxViaImport.2.js b/tests/baselines/reference/jsxViaImport.2.js index 19432238e0b..7310da92e92 100644 --- a/tests/baselines/reference/jsxViaImport.2.js +++ b/tests/baselines/reference/jsxViaImport.2.js @@ -25,17 +25,22 @@ class TestComponent extends React.Component { //// [consumer.jsx] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); /// var BaseComponent_1 = require("BaseComponent"); var TestComponent = (function (_super) { __extends(TestComponent, _super); function TestComponent() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } TestComponent.prototype.render = function () { return ; diff --git a/tests/baselines/reference/jsxViaImport.js b/tests/baselines/reference/jsxViaImport.js index 604787af744..cee60d848ab 100644 --- a/tests/baselines/reference/jsxViaImport.js +++ b/tests/baselines/reference/jsxViaImport.js @@ -25,17 +25,22 @@ class TestComponent extends React.Component { //// [consumer.jsx] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); /// var BaseComponent = require("BaseComponent"); var TestComponent = (function (_super) { __extends(TestComponent, _super); function TestComponent() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } TestComponent.prototype.render = function () { return ; diff --git a/tests/baselines/reference/keyofAndIndexedAccess.js b/tests/baselines/reference/keyofAndIndexedAccess.js index 4b93897fdc4..05658d50515 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.js +++ b/tests/baselines/reference/keyofAndIndexedAccess.js @@ -296,6 +296,30 @@ class C1 { } } +type S2 = { + a: string; + b: string; +}; + +function f90(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) { + x1 = x2; + x1 = x3; + x1 = x4; + x2 = x1; + x2 = x3; + x2 = x4; + x3 = x1; + x3 = x2; + x3 = x4; + x4 = x1; + x4 = x2; + x4 = x3; + x1.length; + x2.length; + x3.length; + x4.length; +} + // Repros from #12011 class Base { @@ -429,14 +453,66 @@ type SomeMethodDescriptor = { returnValue: string[]; } -let result = dispatchMethod("someMethod", ["hello", 35]); +let result = dispatchMethod("someMethod", ["hello", 35]); + +// Repro from #13073 + +type KeyTypes = "a" | "b" +let MyThingy: { [key in KeyTypes]: string[] }; + +function addToMyThingy(key: S) { + MyThingy[key].push("a"); +} + +// Repro from #13102 + +type Handler = { + onChange: (name: keyof T) => void; +}; + +function onChangeGenericFunction(handler: Handler) { + handler.onChange('preset') +} + +// Repro from #13285 + +function updateIds, K extends string>( + obj: T, + idFields: K[], + idMapping: { [oldId: string]: string } +): Record { + for (const idField of idFields) { + const newId = idMapping[obj[idField]]; + if (newId) { + obj[idField] = newId; + } + } + return obj; +} + +// Repro from #13285 + +function updateIds2( + obj: T, + key: K, + stringMap: { [oldId: string]: string } +) { + var x = obj[key]; + stringMap[x]; // Should be OK. +} + //// [keyofAndIndexedAccess.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Shape = (function () { function Shape() { } @@ -445,7 +521,7 @@ var Shape = (function () { var TaggedShape = (function (_super) { __extends(TaggedShape, _super); function TaggedShape() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return TaggedShape; }(Shape)); @@ -644,6 +720,24 @@ var C1 = (function () { }; return C1; }()); +function f90(x1, x2, x3, x4) { + x1 = x2; + x1 = x3; + x1 = x4; + x2 = x1; + x2 = x3; + x2 = x4; + x3 = x1; + x3 = x2; + x3 = x4; + x4 = x1; + x4 = x2; + x4 = x3; + x1.length; + x2.length; + x3.length; + x4.length; +} // Repros from #12011 var Base = (function () { function Base() { @@ -713,6 +807,29 @@ function f(p) { a[p].add; // any } var result = dispatchMethod("someMethod", ["hello", 35]); +var MyThingy; +function addToMyThingy(key) { + MyThingy[key].push("a"); +} +function onChangeGenericFunction(handler) { + handler.onChange('preset'); +} +// Repro from #13285 +function updateIds(obj, idFields, idMapping) { + for (var _i = 0, idFields_1 = idFields; _i < idFields_1.length; _i++) { + var idField = idFields_1[_i]; + var newId = idMapping[obj[idField]]; + if (newId) { + obj[idField] = newId; + } + } + return obj; +} +// Repro from #13285 +function updateIds2(obj, key, stringMap) { + var x = obj[key]; + stringMap[x]; // Should be OK. +} //// [keyofAndIndexedAccess.d.ts] @@ -848,6 +965,11 @@ declare class C1 { set(key: K, value: this[K]): void; foo(): void; } +declare type S2 = { + a: string; + b: string; +}; +declare function f90(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]): void; declare class Base { get(prop: K): this[K]; set(prop: K, value: this[K]): void; @@ -920,3 +1042,22 @@ declare type SomeMethodDescriptor = { returnValue: string[]; }; declare let result: string[]; +declare type KeyTypes = "a" | "b"; +declare let MyThingy: { + [key in KeyTypes]: string[]; +}; +declare function addToMyThingy(key: S): void; +declare type Handler = { + onChange: (name: keyof T) => void; +}; +declare function onChangeGenericFunction(handler: Handler): void; +declare function updateIds, K extends string>(obj: T, idFields: K[], idMapping: { + [oldId: string]: string; +}): Record; +declare function updateIds2(obj: T, key: K, stringMap: { + [oldId: string]: string; +}): void; diff --git a/tests/baselines/reference/keyofAndIndexedAccess.symbols b/tests/baselines/reference/keyofAndIndexedAccess.symbols index 1c69d4959d8..d7bc419af24 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.symbols +++ b/tests/baselines/reference/keyofAndIndexedAccess.symbols @@ -1139,440 +1139,670 @@ class C1 { } } +type S2 = { +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) + + a: string; +>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 297, 11)) + + b: string; +>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 298, 14)) + +}; + +function f90(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) { +>f90 : Symbol(f90, Decl(keyofAndIndexedAccess.ts, 300, 2)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 302, 13)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 302, 26)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 302, 13)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 302, 26)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 302, 13)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 302, 26)) + + x1 = x2; +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) + + x1 = x3; +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) + + x1 = x4; +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) + + x2 = x1; +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) + + x2 = x3; +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) + + x2 = x4; +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) + + x3 = x1; +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) + + x3 = x2; +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) + + x3 = x4; +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) + + x4 = x1; +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) + + x4 = x2; +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) + + x4 = x3; +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) + + x1.length; +>x1.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + + x2.length; +>x2.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + + x3.length; +>x3.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + + x4.length; +>x4.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) +} + // Repros from #12011 class Base { ->Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1)) get(prop: K) { ->get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 299, 12)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 300, 8)) ->prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 300, 30)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 300, 8)) +>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 323, 12)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 324, 8)) +>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 324, 30)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 324, 8)) return this[prop]; ->this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1)) ->prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 300, 30)) +>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1)) +>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 324, 30)) } set(prop: K, value: this[K]) { ->set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 302, 5)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 303, 8)) ->prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 303, 30)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 303, 8)) ->value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 303, 38)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 303, 8)) +>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 326, 5)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 327, 8)) +>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 327, 30)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 327, 8)) +>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 327, 38)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 327, 8)) this[prop] = value; ->this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1)) ->prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 303, 30)) ->value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 303, 38)) +>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1)) +>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 327, 30)) +>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 327, 38)) } } class Person extends Base { ->Person : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 306, 1)) ->Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>Person : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 330, 1)) +>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1)) parts: number; ->parts : Symbol(Person.parts, Decl(keyofAndIndexedAccess.ts, 308, 27)) +>parts : Symbol(Person.parts, Decl(keyofAndIndexedAccess.ts, 332, 27)) constructor(parts: number) { ->parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 310, 16)) +>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 334, 16)) super(); ->super : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>super : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1)) this.set("parts", parts); ->this.set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 302, 5)) ->this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 306, 1)) ->set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 302, 5)) ->parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 310, 16)) +>this.set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 326, 5)) +>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 330, 1)) +>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 326, 5)) +>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 334, 16)) } getParts() { ->getParts : Symbol(Person.getParts, Decl(keyofAndIndexedAccess.ts, 313, 5)) +>getParts : Symbol(Person.getParts, Decl(keyofAndIndexedAccess.ts, 337, 5)) return this.get("parts") ->this.get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 299, 12)) ->this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 306, 1)) ->get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 299, 12)) +>this.get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 323, 12)) +>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 330, 1)) +>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 323, 12)) } } class OtherPerson { ->OtherPerson : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 317, 1)) +>OtherPerson : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 341, 1)) parts: number; ->parts : Symbol(OtherPerson.parts, Decl(keyofAndIndexedAccess.ts, 319, 19)) +>parts : Symbol(OtherPerson.parts, Decl(keyofAndIndexedAccess.ts, 343, 19)) constructor(parts: number) { ->parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 321, 16)) +>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 345, 16)) setProperty(this, "parts", parts); >setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 81, 1)) ->this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 317, 1)) ->parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 321, 16)) +>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 341, 1)) +>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 345, 16)) } getParts() { ->getParts : Symbol(OtherPerson.getParts, Decl(keyofAndIndexedAccess.ts, 323, 5)) +>getParts : Symbol(OtherPerson.getParts, Decl(keyofAndIndexedAccess.ts, 347, 5)) return getProperty(this, "parts") >getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 77, 26)) ->this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 317, 1)) +>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 341, 1)) } } // Modified repro from #12544 function path(obj: T, key1: K1): T[K1]; ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 331, 16)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 331, 37)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14)) ->key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 331, 44)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 331, 16)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 331, 16)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 355, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 355, 16)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 355, 14)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 355, 37)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 355, 14)) +>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 355, 44)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 355, 16)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 355, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 355, 16)) function path(obj: T, key1: K1, key2: K2): T[K1][K2]; ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 332, 36)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 332, 61)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14)) ->key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 332, 68)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16)) ->key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 332, 78)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 332, 36)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 332, 36)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 356, 16)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 356, 36)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 356, 16)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 356, 61)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14)) +>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 356, 68)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 356, 16)) +>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 356, 78)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 356, 36)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 356, 16)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 356, 36)) function path(obj: T, key1: K1, key2: K2, key3: K3): T[K1][K2][K3]; ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16)) ->K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 333, 60)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 333, 89)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 333, 96)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16)) ->key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 333, 106)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36)) ->key3 : Symbol(key3, Decl(keyofAndIndexedAccess.ts, 333, 116)) ->K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 333, 60)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36)) ->K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 333, 60)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 357, 36)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16)) +>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 357, 60)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 357, 36)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 357, 89)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 357, 96)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16)) +>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 357, 106)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 357, 36)) +>key3 : Symbol(key3, Decl(keyofAndIndexedAccess.ts, 357, 116)) +>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 357, 60)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 357, 36)) +>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 357, 60)) function path(obj: any, ...keys: (string | number)[]): any; ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 334, 14)) ->keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 334, 23)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 358, 14)) +>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 358, 23)) function path(obj: any, ...keys: (string | number)[]): any { ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 335, 14)) ->keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 335, 23)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 359, 14)) +>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 359, 23)) let result = obj; ->result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 335, 14)) +>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 360, 7)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 359, 14)) for (let k of keys) { ->k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 337, 12)) ->keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 335, 23)) +>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 361, 12)) +>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 359, 23)) result = result[k]; ->result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7)) ->result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7)) ->k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 337, 12)) +>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 360, 7)) +>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 360, 7)) +>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 361, 12)) } return result; ->result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7)) +>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 360, 7)) } type Thing = { ->Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 341, 1)) +>Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 365, 1)) a: { x: number, y: string }, ->a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 343, 14)) ->x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 344, 8)) ->y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 344, 19)) +>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 367, 14)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 368, 8)) +>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 368, 19)) b: boolean ->b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 344, 32)) +>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 368, 32)) }; function f1(thing: Thing) { ->f1 : Symbol(f1, Decl(keyofAndIndexedAccess.ts, 346, 2)) ->thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12)) ->Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 341, 1)) +>f1 : Symbol(f1, Decl(keyofAndIndexedAccess.ts, 370, 2)) +>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12)) +>Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 365, 1)) let x1 = path(thing, 'a'); // { x: number, y: string } ->x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 350, 7)) ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 374, 7)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12)) let x2 = path(thing, 'a', 'y'); // string ->x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 351, 7)) ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 375, 7)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12)) let x3 = path(thing, 'b'); // boolean ->x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 352, 7)) ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 376, 7)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12)) let x4 = path(thing, ...['a', 'x']); // any ->x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 353, 7)) ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 377, 7)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12)) } // Repro from comment in #12114 const assignTo2 = (object: T, key1: K1, key2: K2) => ->assignTo2 : Symbol(assignTo2, Decl(keyofAndIndexedAccess.ts, 358, 5)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 358, 41)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21)) ->object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 358, 66)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19)) ->key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 358, 76)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21)) ->key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 358, 86)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 358, 41)) +>assignTo2 : Symbol(assignTo2, Decl(keyofAndIndexedAccess.ts, 382, 5)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 382, 21)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 382, 41)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 382, 21)) +>object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 382, 66)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19)) +>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 382, 76)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 382, 21)) +>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 382, 86)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 382, 41)) (value: T[K1][K2]) => object[key1][key2] = value; ->value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 359, 5)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 358, 41)) ->object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 358, 66)) ->key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 358, 76)) ->key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 358, 86)) ->value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 359, 5)) +>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 383, 5)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 382, 21)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 382, 41)) +>object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 382, 66)) +>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 382, 76)) +>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 382, 86)) +>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 383, 5)) // Modified repro from #12573 declare function one(handler: (t: T) => void): T ->one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 359, 53)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 363, 21)) ->handler : Symbol(handler, Decl(keyofAndIndexedAccess.ts, 363, 24)) ->t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 363, 34)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 363, 21)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 363, 21)) +>one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 383, 53)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 387, 21)) +>handler : Symbol(handler, Decl(keyofAndIndexedAccess.ts, 387, 24)) +>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 387, 34)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 387, 21)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 387, 21)) var empty = one(() => {}) // inferred as {}, expected ->empty : Symbol(empty, Decl(keyofAndIndexedAccess.ts, 364, 3)) ->one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 359, 53)) +>empty : Symbol(empty, Decl(keyofAndIndexedAccess.ts, 388, 3)) +>one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 383, 53)) type Handlers = { [K in keyof T]: (t: T[K]) => void } ->Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 364, 25)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 366, 14)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 366, 22)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 366, 14)) ->t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 366, 38)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 366, 14)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 366, 22)) +>Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 388, 25)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 390, 14)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 390, 22)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 390, 14)) +>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 390, 38)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 390, 14)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 390, 22)) declare function on(handlerHash: Handlers): T ->on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 366, 56)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 367, 20)) ->handlerHash : Symbol(handlerHash, Decl(keyofAndIndexedAccess.ts, 367, 23)) ->Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 364, 25)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 367, 20)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 367, 20)) +>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 390, 56)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 391, 20)) +>handlerHash : Symbol(handlerHash, Decl(keyofAndIndexedAccess.ts, 391, 23)) +>Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 388, 25)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 391, 20)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 391, 20)) var hashOfEmpty1 = on({ test: () => {} }); // {} ->hashOfEmpty1 : Symbol(hashOfEmpty1, Decl(keyofAndIndexedAccess.ts, 368, 3)) ->on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 366, 56)) ->test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 368, 23)) +>hashOfEmpty1 : Symbol(hashOfEmpty1, Decl(keyofAndIndexedAccess.ts, 392, 3)) +>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 390, 56)) +>test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 392, 23)) var hashOfEmpty2 = on({ test: (x: boolean) => {} }); // { test: boolean } ->hashOfEmpty2 : Symbol(hashOfEmpty2, Decl(keyofAndIndexedAccess.ts, 369, 3)) ->on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 366, 56)) ->test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 369, 23)) ->x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 369, 31)) +>hashOfEmpty2 : Symbol(hashOfEmpty2, Decl(keyofAndIndexedAccess.ts, 393, 3)) +>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 390, 56)) +>test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 393, 23)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 393, 31)) // Repro from #12624 interface Options1 { ->Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 369, 52)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 373, 19)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 373, 24)) +>Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 393, 52)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 397, 19)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 397, 24)) data?: Data ->data : Symbol(Options1.data, Decl(keyofAndIndexedAccess.ts, 373, 36)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 373, 19)) +>data : Symbol(Options1.data, Decl(keyofAndIndexedAccess.ts, 397, 36)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 397, 19)) computed?: Computed; ->computed : Symbol(Options1.computed, Decl(keyofAndIndexedAccess.ts, 374, 15)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 373, 24)) +>computed : Symbol(Options1.computed, Decl(keyofAndIndexedAccess.ts, 398, 15)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 397, 24)) } declare class Component1 { ->Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 376, 1)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30)) +>Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 400, 1)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 402, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 402, 30)) constructor(options: Options1); ->options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 379, 16)) ->Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 369, 52)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30)) +>options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 403, 16)) +>Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 393, 52)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 402, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 402, 30)) get(key: K): (Data & Computed)[K]; ->get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 379, 51)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 380, 8)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30)) ->key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 380, 43)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 380, 8)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 380, 8)) +>get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 403, 51)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 404, 8)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 402, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 402, 30)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 404, 43)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 404, 8)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 402, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 402, 30)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 404, 8)) } let c1 = new Component1({ ->c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 383, 3)) ->Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 376, 1)) +>c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 407, 3)) +>Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 400, 1)) data: { ->data : Symbol(data, Decl(keyofAndIndexedAccess.ts, 383, 25)) +>data : Symbol(data, Decl(keyofAndIndexedAccess.ts, 407, 25)) hello: "" ->hello : Symbol(hello, Decl(keyofAndIndexedAccess.ts, 384, 11)) +>hello : Symbol(hello, Decl(keyofAndIndexedAccess.ts, 408, 11)) } }); c1.get("hello"); ->c1.get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 379, 51)) ->c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 383, 3)) ->get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 379, 51)) +>c1.get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 403, 51)) +>c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 407, 3)) +>get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 403, 51)) // Repro from #12625 interface Options2 { ->Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 389, 16)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 393, 19)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 393, 24)) +>Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 413, 16)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 417, 19)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 417, 24)) data?: Data ->data : Symbol(Options2.data, Decl(keyofAndIndexedAccess.ts, 393, 36)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 393, 19)) +>data : Symbol(Options2.data, Decl(keyofAndIndexedAccess.ts, 417, 36)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 417, 19)) computed?: Computed; ->computed : Symbol(Options2.computed, Decl(keyofAndIndexedAccess.ts, 394, 15)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 393, 24)) +>computed : Symbol(Options2.computed, Decl(keyofAndIndexedAccess.ts, 418, 15)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 417, 24)) } declare class Component2 { ->Component2 : Symbol(Component2, Decl(keyofAndIndexedAccess.ts, 396, 1)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30)) +>Component2 : Symbol(Component2, Decl(keyofAndIndexedAccess.ts, 420, 1)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 422, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 422, 30)) constructor(options: Options2); ->options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 399, 16)) ->Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 389, 16)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30)) +>options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 423, 16)) +>Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 413, 16)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 422, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 422, 30)) get(key: K): (Data & Computed)[K]; ->get : Symbol(Component2.get, Decl(keyofAndIndexedAccess.ts, 399, 51)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 400, 8)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30)) ->key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 400, 47)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 400, 8)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 400, 8)) +>get : Symbol(Component2.get, Decl(keyofAndIndexedAccess.ts, 423, 51)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 424, 8)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 422, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 422, 30)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 424, 47)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 424, 8)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 422, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 422, 30)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 424, 8)) } // Repro from #12641 interface R { ->R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 401, 1)) +>R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 425, 1)) p: number; ->p : Symbol(R.p, Decl(keyofAndIndexedAccess.ts, 405, 13)) +>p : Symbol(R.p, Decl(keyofAndIndexedAccess.ts, 429, 13)) } function f(p: K) { ->f : Symbol(f, Decl(keyofAndIndexedAccess.ts, 407, 1)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 409, 11)) ->R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 401, 1)) ->p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 409, 30)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 409, 11)) +>f : Symbol(f, Decl(keyofAndIndexedAccess.ts, 431, 1)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 433, 11)) +>R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 425, 1)) +>p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 433, 30)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 433, 11)) let a: any; ->a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 410, 7)) +>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 434, 7)) a[p].add; // any ->a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 410, 7)) ->p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 409, 30)) +>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 434, 7)) +>p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 433, 30)) } // Repro from #12651 type MethodDescriptor = { ->MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 412, 1)) +>MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 436, 1)) name: string; ->name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 416, 25)) +>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 440, 25)) args: any[]; ->args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 417, 14)) +>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 441, 14)) returnValue: any; ->returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 418, 13)) +>returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 442, 13)) } declare function dispatchMethod(name: M['name'], args: M['args']): M['returnValue']; ->dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 420, 1)) ->M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32)) ->MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 412, 1)) ->name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 422, 60)) ->M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32)) ->args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 422, 76)) ->M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32)) ->M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32)) +>dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 444, 1)) +>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 446, 32)) +>MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 436, 1)) +>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 446, 60)) +>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 446, 32)) +>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 446, 76)) +>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 446, 32)) +>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 446, 32)) type SomeMethodDescriptor = { ->SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 422, 112)) +>SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 446, 112)) name: "someMethod"; ->name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 424, 29)) +>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 448, 29)) args: [string, number]; ->args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 425, 20)) +>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 449, 20)) returnValue: string[]; ->returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 426, 24)) +>returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 450, 24)) } let result = dispatchMethod("someMethod", ["hello", 35]); ->result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 430, 3)) ->dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 420, 1)) ->SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 422, 112)) +>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 454, 3)) +>dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 444, 1)) +>SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 446, 112)) + +// Repro from #13073 + +type KeyTypes = "a" | "b" +>KeyTypes : Symbol(KeyTypes, Decl(keyofAndIndexedAccess.ts, 454, 79)) + +let MyThingy: { [key in KeyTypes]: string[] }; +>MyThingy : Symbol(MyThingy, Decl(keyofAndIndexedAccess.ts, 459, 3)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 459, 17)) +>KeyTypes : Symbol(KeyTypes, Decl(keyofAndIndexedAccess.ts, 454, 79)) + +function addToMyThingy(key: S) { +>addToMyThingy : Symbol(addToMyThingy, Decl(keyofAndIndexedAccess.ts, 459, 46)) +>S : Symbol(S, Decl(keyofAndIndexedAccess.ts, 461, 23)) +>KeyTypes : Symbol(KeyTypes, Decl(keyofAndIndexedAccess.ts, 454, 79)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 461, 43)) +>S : Symbol(S, Decl(keyofAndIndexedAccess.ts, 461, 23)) + + MyThingy[key].push("a"); +>MyThingy[key].push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>MyThingy : Symbol(MyThingy, Decl(keyofAndIndexedAccess.ts, 459, 3)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 461, 43)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +} + +// Repro from #13102 + +type Handler = { +>Handler : Symbol(Handler, Decl(keyofAndIndexedAccess.ts, 463, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 467, 13)) + + onChange: (name: keyof T) => void; +>onChange : Symbol(onChange, Decl(keyofAndIndexedAccess.ts, 467, 19)) +>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 468, 15)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 467, 13)) + +}; + +function onChangeGenericFunction(handler: Handler) { +>onChangeGenericFunction : Symbol(onChangeGenericFunction, Decl(keyofAndIndexedAccess.ts, 469, 2)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 471, 33)) +>handler : Symbol(handler, Decl(keyofAndIndexedAccess.ts, 471, 36)) +>Handler : Symbol(Handler, Decl(keyofAndIndexedAccess.ts, 463, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 471, 33)) +>preset : Symbol(preset, Decl(keyofAndIndexedAccess.ts, 471, 58)) + + handler.onChange('preset') +>handler.onChange : Symbol(onChange, Decl(keyofAndIndexedAccess.ts, 467, 19)) +>handler : Symbol(handler, Decl(keyofAndIndexedAccess.ts, 471, 36)) +>onChange : Symbol(onChange, Decl(keyofAndIndexedAccess.ts, 467, 19)) +} + +// Repro from #13285 + +function updateIds, K extends string>( +>updateIds : Symbol(updateIds, Decl(keyofAndIndexedAccess.ts, 473, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 477, 19)) +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 477, 47)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 477, 47)) + + obj: T, +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 477, 66)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 477, 19)) + + idFields: K[], +>idFields : Symbol(idFields, Decl(keyofAndIndexedAccess.ts, 478, 11)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 477, 47)) + + idMapping: { [oldId: string]: string } +>idMapping : Symbol(idMapping, Decl(keyofAndIndexedAccess.ts, 479, 18)) +>oldId : Symbol(oldId, Decl(keyofAndIndexedAccess.ts, 480, 18)) + +): Record { +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 477, 47)) + + for (const idField of idFields) { +>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 482, 14)) +>idFields : Symbol(idFields, Decl(keyofAndIndexedAccess.ts, 478, 11)) + + const newId = idMapping[obj[idField]]; +>newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 483, 13)) +>idMapping : Symbol(idMapping, Decl(keyofAndIndexedAccess.ts, 479, 18)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 477, 66)) +>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 482, 14)) + + if (newId) { +>newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 483, 13)) + + obj[idField] = newId; +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 477, 66)) +>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 482, 14)) +>newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 483, 13)) + } + } + return obj; +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 477, 66)) +} + +// Repro from #13285 + +function updateIds2( +>updateIds2 : Symbol(updateIds2, Decl(keyofAndIndexedAccess.ts, 489, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 493, 20)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 493, 33)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 493, 54)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 493, 20)) + + obj: T, +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 493, 74)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 493, 20)) + + key: K, +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 494, 11)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 493, 54)) + + stringMap: { [oldId: string]: string } +>stringMap : Symbol(stringMap, Decl(keyofAndIndexedAccess.ts, 495, 11)) +>oldId : Symbol(oldId, Decl(keyofAndIndexedAccess.ts, 496, 18)) + +) { + var x = obj[key]; +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 498, 7)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 493, 74)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 494, 11)) + + stringMap[x]; // Should be OK. +>stringMap : Symbol(stringMap, Decl(keyofAndIndexedAccess.ts, 495, 11)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 498, 7)) +} diff --git a/tests/baselines/reference/keyofAndIndexedAccess.types b/tests/baselines/reference/keyofAndIndexedAccess.types index f94249806f6..543c39b3c92 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.types +++ b/tests/baselines/reference/keyofAndIndexedAccess.types @@ -1385,6 +1385,117 @@ class C1 { } } +type S2 = { +>S2 : S2 + + a: string; +>a : string + + b: string; +>b : string + +}; + +function f90(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) { +>f90 : (x1: string, x2: T["a" | "b"], x3: S2[K], x4: T[K]) => void +>T : T +>S2 : S2 +>K : K +>S2 : S2 +>x1 : string +>S2 : S2 +>S2 : S2 +>x2 : T["a" | "b"] +>T : T +>S2 : S2 +>x3 : S2[K] +>S2 : S2 +>K : K +>x4 : T[K] +>T : T +>K : K + + x1 = x2; +>x1 = x2 : T["a" | "b"] +>x1 : string +>x2 : T["a" | "b"] + + x1 = x3; +>x1 = x3 : S2[K] +>x1 : string +>x3 : S2[K] + + x1 = x4; +>x1 = x4 : T[K] +>x1 : string +>x4 : T[K] + + x2 = x1; +>x2 = x1 : string +>x2 : T["a" | "b"] +>x1 : string + + x2 = x3; +>x2 = x3 : S2[K] +>x2 : T["a" | "b"] +>x3 : S2[K] + + x2 = x4; +>x2 = x4 : T[K] +>x2 : T["a" | "b"] +>x4 : T[K] + + x3 = x1; +>x3 = x1 : string +>x3 : S2[K] +>x1 : string + + x3 = x2; +>x3 = x2 : T["a" | "b"] +>x3 : S2[K] +>x2 : T["a" | "b"] + + x3 = x4; +>x3 = x4 : T[K] +>x3 : S2[K] +>x4 : T[K] + + x4 = x1; +>x4 = x1 : string +>x4 : T[K] +>x1 : string + + x4 = x2; +>x4 = x2 : T["a" | "b"] +>x4 : T[K] +>x2 : T["a" | "b"] + + x4 = x3; +>x4 = x3 : S2[K] +>x4 : T[K] +>x3 : S2[K] + + x1.length; +>x1.length : number +>x1 : string +>length : number + + x2.length; +>x2.length : number +>x2 : T["a" | "b"] +>length : number + + x3.length; +>x3.length : number +>x3 : S2[K] +>length : number + + x4.length; +>x4.length : number +>x4 : T[K] +>length : number +} + // Repros from #12011 class Base { @@ -1875,3 +1986,145 @@ let result = dispatchMethod("someMethod", ["hello", 35]); >"hello" : "hello" >35 : 35 +// Repro from #13073 + +type KeyTypes = "a" | "b" +>KeyTypes : "a" | "b" + +let MyThingy: { [key in KeyTypes]: string[] }; +>MyThingy : { a: string[]; b: string[]; } +>key : key +>KeyTypes : "a" | "b" + +function addToMyThingy(key: S) { +>addToMyThingy : (key: S) => void +>S : S +>KeyTypes : "a" | "b" +>key : S +>S : S + + MyThingy[key].push("a"); +>MyThingy[key].push("a") : number +>MyThingy[key].push : (...items: string[]) => number +>MyThingy[key] : { a: string[]; b: string[]; }[S] +>MyThingy : { a: string[]; b: string[]; } +>key : S +>push : (...items: string[]) => number +>"a" : "a" +} + +// Repro from #13102 + +type Handler = { +>Handler : Handler +>T : T + + onChange: (name: keyof T) => void; +>onChange : (name: keyof T) => void +>name : keyof T +>T : T + +}; + +function onChangeGenericFunction(handler: Handler) { +>onChangeGenericFunction : (handler: Handler) => void +>T : T +>handler : Handler +>Handler : Handler +>T : T +>preset : number + + handler.onChange('preset') +>handler.onChange('preset') : void +>handler.onChange : (name: keyof (T & { preset: number; })) => void +>handler : Handler +>onChange : (name: keyof (T & { preset: number; })) => void +>'preset' : "preset" +} + +// Repro from #13285 + +function updateIds, K extends string>( +>updateIds : , K extends string>(obj: T, idFields: K[], idMapping: { [oldId: string]: string; }) => Record +>T : T +>Record : Record +>K : K +>K : K + + obj: T, +>obj : T +>T : T + + idFields: K[], +>idFields : K[] +>K : K + + idMapping: { [oldId: string]: string } +>idMapping : { [oldId: string]: string; } +>oldId : string + +): Record { +>Record : Record +>K : K + + for (const idField of idFields) { +>idField : K +>idFields : K[] + + const newId = idMapping[obj[idField]]; +>newId : { [oldId: string]: string; }[T[K]] +>idMapping[obj[idField]] : { [oldId: string]: string; }[T[K]] +>idMapping : { [oldId: string]: string; } +>obj[idField] : T[K] +>obj : T +>idField : K + + if (newId) { +>newId : { [oldId: string]: string; }[T[K]] + + obj[idField] = newId; +>obj[idField] = newId : { [oldId: string]: string; }[T[K]] +>obj[idField] : T[K] +>obj : T +>idField : K +>newId : { [oldId: string]: string; }[T[K]] + } + } + return obj; +>obj : T +} + +// Repro from #13285 + +function updateIds2( +>updateIds2 : (obj: T, key: K, stringMap: { [oldId: string]: string; }) => void +>T : T +>x : string +>K : K +>T : T + + obj: T, +>obj : T +>T : T + + key: K, +>key : K +>K : K + + stringMap: { [oldId: string]: string } +>stringMap : { [oldId: string]: string; } +>oldId : string + +) { + var x = obj[key]; +>x : T[K] +>obj[key] : T[K] +>obj : T +>key : K + + stringMap[x]; // Should be OK. +>stringMap[x] : { [oldId: string]: string; }[T[K]] +>stringMap : { [oldId: string]: string; } +>x : T[K] +} + diff --git a/tests/baselines/reference/lambdaArgCrash.js b/tests/baselines/reference/lambdaArgCrash.js index 47db7f3ce64..9a903b513d9 100644 --- a/tests/baselines/reference/lambdaArgCrash.js +++ b/tests/baselines/reference/lambdaArgCrash.js @@ -35,11 +35,16 @@ class ItemSetEvent extends Event { //// [lambdaArgCrash.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Event = (function () { function Event() { // TODO: remove @@ -56,7 +61,7 @@ var Event = (function () { var ItemSetEvent = (function (_super) { __extends(ItemSetEvent, _super); function ItemSetEvent() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } ItemSetEvent.prototype.add = function (listener) { _super.prototype.add.call(this, listener); diff --git a/tests/baselines/reference/library-reference-11.trace.json b/tests/baselines/reference/library-reference-11.trace.json index 78ac53013f7..0393f04cc80 100644 --- a/tests/baselines/reference/library-reference-11.trace.json +++ b/tests/baselines/reference/library-reference-11.trace.json @@ -2,12 +2,7 @@ "======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory not set. ========", "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/a/b'", - "File '/a/b/node_modules/jquery.d.ts' does not exist.", - "File '/a/b/node_modules/jquery/package.json' does not exist.", - "File '/a/b/node_modules/jquery/index.d.ts' does not exist.", - "File '/a/b/node_modules/@types/jquery.d.ts' does not exist.", - "File '/a/b/node_modules/@types/jquery/package.json' does not exist.", - "File '/a/b/node_modules/@types/jquery/index.d.ts' does not exist.", + "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", "File '/a/node_modules/jquery.d.ts' does not exist.", "Found 'package.json' at '/a/node_modules/jquery/package.json'.", "'package.json' has 'typings' field 'jquery.d.ts' that references '/a/node_modules/jquery/jquery.d.ts'.", diff --git a/tests/baselines/reference/library-reference-12.trace.json b/tests/baselines/reference/library-reference-12.trace.json index 6e09c7a3f04..14e46647d6d 100644 --- a/tests/baselines/reference/library-reference-12.trace.json +++ b/tests/baselines/reference/library-reference-12.trace.json @@ -2,12 +2,7 @@ "======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory not set. ========", "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/a/b'", - "File '/a/b/node_modules/jquery.d.ts' does not exist.", - "File '/a/b/node_modules/jquery/package.json' does not exist.", - "File '/a/b/node_modules/jquery/index.d.ts' does not exist.", - "File '/a/b/node_modules/@types/jquery.d.ts' does not exist.", - "File '/a/b/node_modules/@types/jquery/package.json' does not exist.", - "File '/a/b/node_modules/@types/jquery/index.d.ts' does not exist.", + "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", "File '/a/node_modules/jquery.d.ts' does not exist.", "Found 'package.json' at '/a/node_modules/jquery/package.json'.", "'package.json' has 'types' field 'dist/jquery.d.ts' that references '/a/node_modules/jquery/dist/jquery.d.ts'.", diff --git a/tests/baselines/reference/library-reference-4.trace.json b/tests/baselines/reference/library-reference-4.trace.json index b47ba1065f5..b6b9e5e0af2 100644 --- a/tests/baselines/reference/library-reference-4.trace.json +++ b/tests/baselines/reference/library-reference-4.trace.json @@ -1,15 +1,8 @@ [ "======== Resolving type reference directive 'foo', containing file '/src/root.ts', root directory '/src'. ========", "Resolving with primary search path '/src'", - "File '/src/foo/package.json' does not exist.", - "File '/src/foo/index.d.ts' does not exist.", "Looking up in 'node_modules' folder, initial location '/src'", - "File '/src/node_modules/foo.d.ts' does not exist.", - "File '/src/node_modules/foo/package.json' does not exist.", - "File '/src/node_modules/foo/index.d.ts' does not exist.", - "File '/src/node_modules/@types/foo.d.ts' does not exist.", - "File '/src/node_modules/@types/foo/package.json' does not exist.", - "File '/src/node_modules/@types/foo/index.d.ts' does not exist.", + "Directory '/src/node_modules' does not exist, skipping all lookups in it.", "File '/node_modules/foo.d.ts' does not exist.", "File '/node_modules/foo/package.json' does not exist.", "File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.", @@ -17,15 +10,8 @@ "======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: false. ========", "======== Resolving type reference directive 'bar', containing file '/src/root.ts', root directory '/src'. ========", "Resolving with primary search path '/src'", - "File '/src/bar/package.json' does not exist.", - "File '/src/bar/index.d.ts' does not exist.", "Looking up in 'node_modules' folder, initial location '/src'", - "File '/src/node_modules/bar.d.ts' does not exist.", - "File '/src/node_modules/bar/package.json' does not exist.", - "File '/src/node_modules/bar/index.d.ts' does not exist.", - "File '/src/node_modules/@types/bar.d.ts' does not exist.", - "File '/src/node_modules/@types/bar/package.json' does not exist.", - "File '/src/node_modules/@types/bar/index.d.ts' does not exist.", + "Directory '/src/node_modules' does not exist, skipping all lookups in it.", "File '/node_modules/bar.d.ts' does not exist.", "File '/node_modules/bar/package.json' does not exist.", "File '/node_modules/bar/index.d.ts' exist - use it as a name resolution result.", @@ -33,8 +19,6 @@ "======== Type reference directive 'bar' was successfully resolved to '/node_modules/bar/index.d.ts', primary: false. ========", "======== Resolving type reference directive 'alpha', containing file '/node_modules/foo/index.d.ts', root directory '/src'. ========", "Resolving with primary search path '/src'", - "File '/src/alpha/package.json' does not exist.", - "File '/src/alpha/index.d.ts' does not exist.", "Looking up in 'node_modules' folder, initial location '/node_modules/foo'", "File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/foo/node_modules/alpha/package.json' does not exist.", @@ -43,8 +27,6 @@ "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/foo/node_modules/alpha/index.d.ts', primary: false. ========", "======== Resolving type reference directive 'alpha', containing file '/node_modules/bar/index.d.ts', root directory '/src'. ========", "Resolving with primary search path '/src'", - "File '/src/alpha/package.json' does not exist.", - "File '/src/alpha/index.d.ts' does not exist.", "Looking up in 'node_modules' folder, initial location '/node_modules/bar'", "File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/bar/node_modules/alpha/package.json' does not exist.", diff --git a/tests/baselines/reference/library-reference-5.trace.json b/tests/baselines/reference/library-reference-5.trace.json index 8f548e04d10..818fceb42cf 100644 --- a/tests/baselines/reference/library-reference-5.trace.json +++ b/tests/baselines/reference/library-reference-5.trace.json @@ -1,15 +1,9 @@ [ "======== Resolving type reference directive 'foo', containing file '/src/root.ts', root directory 'types'. ========", "Resolving with primary search path 'types'", - "File 'types/foo/package.json' does not exist.", - "File 'types/foo/index.d.ts' does not exist.", + "Directory 'types' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/src'", - "File '/src/node_modules/foo.d.ts' does not exist.", - "File '/src/node_modules/foo/package.json' does not exist.", - "File '/src/node_modules/foo/index.d.ts' does not exist.", - "File '/src/node_modules/@types/foo.d.ts' does not exist.", - "File '/src/node_modules/@types/foo/package.json' does not exist.", - "File '/src/node_modules/@types/foo/index.d.ts' does not exist.", + "Directory '/src/node_modules' does not exist, skipping all lookups in it.", "File '/node_modules/foo.d.ts' does not exist.", "File '/node_modules/foo/package.json' does not exist.", "File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.", @@ -17,15 +11,9 @@ "======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: false. ========", "======== Resolving type reference directive 'bar', containing file '/src/root.ts', root directory 'types'. ========", "Resolving with primary search path 'types'", - "File 'types/bar/package.json' does not exist.", - "File 'types/bar/index.d.ts' does not exist.", + "Directory 'types' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/src'", - "File '/src/node_modules/bar.d.ts' does not exist.", - "File '/src/node_modules/bar/package.json' does not exist.", - "File '/src/node_modules/bar/index.d.ts' does not exist.", - "File '/src/node_modules/@types/bar.d.ts' does not exist.", - "File '/src/node_modules/@types/bar/package.json' does not exist.", - "File '/src/node_modules/@types/bar/index.d.ts' does not exist.", + "Directory '/src/node_modules' does not exist, skipping all lookups in it.", "File '/node_modules/bar.d.ts' does not exist.", "File '/node_modules/bar/package.json' does not exist.", "File '/node_modules/bar/index.d.ts' exist - use it as a name resolution result.", @@ -33,8 +21,7 @@ "======== Type reference directive 'bar' was successfully resolved to '/node_modules/bar/index.d.ts', primary: false. ========", "======== Resolving type reference directive 'alpha', containing file '/node_modules/foo/index.d.ts', root directory 'types'. ========", "Resolving with primary search path 'types'", - "File 'types/alpha/package.json' does not exist.", - "File 'types/alpha/index.d.ts' does not exist.", + "Directory 'types' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/node_modules/foo'", "File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/foo/node_modules/alpha/package.json' does not exist.", @@ -43,8 +30,7 @@ "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/foo/node_modules/alpha/index.d.ts', primary: false. ========", "======== Resolving type reference directive 'alpha', containing file '/node_modules/bar/index.d.ts', root directory 'types'. ========", "Resolving with primary search path 'types'", - "File 'types/alpha/package.json' does not exist.", - "File 'types/alpha/index.d.ts' does not exist.", + "Directory 'types' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/node_modules/bar'", "File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/bar/node_modules/alpha/package.json' does not exist.", diff --git a/tests/baselines/reference/lift.js b/tests/baselines/reference/lift.js index 364d52d9385..80eebe9cb00 100644 --- a/tests/baselines/reference/lift.js +++ b/tests/baselines/reference/lift.js @@ -18,11 +18,16 @@ class C extends B { //// [lift.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B(y) { this.y = y; diff --git a/tests/baselines/reference/literals.errors.txt b/tests/baselines/reference/literals.errors.txt index 2920498bde4..ae058e0b530 100644 --- a/tests/baselines/reference/literals.errors.txt +++ b/tests/baselines/reference/literals.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/expressions/literals/literals.ts(9,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/literals/literals.ts(9,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/literals/literals.ts(10,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/literals/literals.ts(10,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/literals/literals.ts(9,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/literals/literals.ts(9,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/literals/literals.ts(10,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/literals/literals.ts(10,21): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/literals/literals.ts(20,9): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '0o1'. -tests/cases/conformance/expressions/literals/literals.ts(25,10): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '0o3'. +tests/cases/conformance/expressions/literals/literals.ts(25,9): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '-0o3'. ==== tests/cases/conformance/expressions/literals/literals.ts (6 errors) ==== @@ -17,14 +17,14 @@ tests/cases/conformance/expressions/literals/literals.ts(25,10): error TS1085: O var nu = null / null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var u = undefined / undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var b: boolean; var b = true; @@ -42,8 +42,8 @@ tests/cases/conformance/expressions/literals/literals.ts(25,10): error TS1085: O var n = -1.0; var n = -1e-4; var n = -003; // Error in ES5 - ~~~ -!!! error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '0o3'. + ~~~~ +!!! error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '-0o3'. var n = -0x1; var s: string; diff --git a/tests/baselines/reference/localTypes1.js b/tests/baselines/reference/localTypes1.js index 100452b7a96..d356bd58e20 100644 --- a/tests/baselines/reference/localTypes1.js +++ b/tests/baselines/reference/localTypes1.js @@ -142,11 +142,16 @@ function f6() { //// [localTypes1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function f1() { var E; (function (E) { @@ -300,7 +305,7 @@ function f6() { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -308,7 +313,7 @@ function f6() { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); diff --git a/tests/baselines/reference/logicalNotOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/logicalNotOperatorWithAnyOtherType.errors.txt index 02b4bf16fd2..0cb9869ca4c 100644 --- a/tests/baselines/reference/logicalNotOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/logicalNotOperatorWithAnyOtherType.errors.txt @@ -1,10 +1,13 @@ -tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(45,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(46,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(47,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(45,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(45,34): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(46,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(46,34): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(47,27): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(47,39): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(57,1): error TS2695: Left side of comma operator is unused and has no side effects. -==== tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts (4 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts (7 errors) ==== // ! operator on any type var ANY: any; @@ -50,14 +53,20 @@ tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNot var ResultIsBoolean15 = !A.foo(); var ResultIsBoolean16 = !(ANY + ANY1); var ResultIsBoolean17 = !(null + undefined); - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsBoolean18 = !(null + null); - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsBoolean19 = !(undefined + undefined); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // multiple ! operators var ResultIsBoolean20 = !!ANY; diff --git a/tests/baselines/reference/m7Bugs.js b/tests/baselines/reference/m7Bugs.js index e5a4d11f00c..d5fd319b993 100644 --- a/tests/baselines/reference/m7Bugs.js +++ b/tests/baselines/reference/m7Bugs.js @@ -27,11 +27,16 @@ var y3: C1 = {}; //// [m7Bugs.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var s = ({}); var x = {}; var C1 = (function () { @@ -42,7 +47,7 @@ var C1 = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(C1)); diff --git a/tests/baselines/reference/mappedTypeErrors.errors.txt b/tests/baselines/reference/mappedTypeErrors.errors.txt index 94644a96af9..c7571295521 100644 --- a/tests/baselines/reference/mappedTypeErrors.errors.txt +++ b/tests/baselines/reference/mappedTypeErrors.errors.txt @@ -45,7 +45,7 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(130,5): error TS2322: T tests/cases/conformance/types/mapped/mappedTypeErrors.ts(131,5): error TS2322: Type '{ a: string; }' is not assignable to type '{ [x: string]: any; a?: number | undefined; }'. Types of property 'a' are incompatible. Type 'string' is not assignable to type 'number | undefined'. -tests/cases/conformance/types/mapped/mappedTypeErrors.ts(137,16): error TS2322: Type '{}' is not assignable to type 'string'. +tests/cases/conformance/types/mapped/mappedTypeErrors.ts(137,16): error TS2322: Type 'T' is not assignable to type 'string'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(137,21): error TS2536: Type 'P' cannot be used to index type 'T'. @@ -259,7 +259,7 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(137,21): error TS2536: pf: {[P in F]?: T[P]}, pt: {[P in T]?: T[P]}, // note: should be in keyof T ~ -!!! error TS2322: Type '{}' is not assignable to type 'string'. +!!! error TS2322: Type 'T' is not assignable to type 'string'. ~~~~ !!! error TS2536: Type 'P' cannot be used to index type 'T'. }; diff --git a/tests/baselines/reference/mappedTypeNestedGenericInstantiation.js b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.js new file mode 100644 index 00000000000..f70130a84d5 --- /dev/null +++ b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.js @@ -0,0 +1,19 @@ +//// [mappedTypeNestedGenericInstantiation.ts] +// Repro from #13346 + +interface Chainable { + value(): T; + mapValues(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>; +} + +declare function chain(t: T): Chainable; + +const square = (x: number) => x * x; + +const v = chain({a: 1, b: 2}).mapValues(square).value(); + + +//// [mappedTypeNestedGenericInstantiation.js] +// Repro from #13346 +var square = function (x) { return x * x; }; +var v = chain({ a: 1, b: 2 }).mapValues(square).value(); diff --git a/tests/baselines/reference/mappedTypeNestedGenericInstantiation.symbols b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.symbols new file mode 100644 index 00000000000..0ec4f50bedc --- /dev/null +++ b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.symbols @@ -0,0 +1,50 @@ +=== tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts === +// Repro from #13346 + +interface Chainable { +>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20)) + + value(): T; +>value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20)) + + mapValues(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>; +>mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13)) +>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12)) +>func : Symbol(func, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 15)) +>v : Symbol(v, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 22)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20)) +>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12)) +>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0)) +>k : Symbol(k, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 56)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20)) +>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12)) +} + +declare function chain(t: T): Chainable; +>chain : Symbol(chain, Decl(mappedTypeNestedGenericInstantiation.ts, 5, 1)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23)) +>t : Symbol(t, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 26)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23)) +>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23)) + +const square = (x: number) => x * x; +>square : Symbol(square, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 5)) +>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16)) +>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16)) +>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16)) + +const v = chain({a: 1, b: 2}).mapValues(square).value(); +>v : Symbol(v, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 5)) +>chain({a: 1, b: 2}).mapValues(square).value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24)) +>chain({a: 1, b: 2}).mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13)) +>chain : Symbol(chain, Decl(mappedTypeNestedGenericInstantiation.ts, 5, 1)) +>a : Symbol(a, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 17)) +>b : Symbol(b, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 22)) +>mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13)) +>square : Symbol(square, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 5)) +>value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24)) + diff --git a/tests/baselines/reference/mappedTypeNestedGenericInstantiation.types b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.types new file mode 100644 index 00000000000..7501bdb19e8 --- /dev/null +++ b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.types @@ -0,0 +1,58 @@ +=== tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts === +// Repro from #13346 + +interface Chainable { +>Chainable : Chainable +>T : T + + value(): T; +>value : () => T +>T : T + + mapValues(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>; +>mapValues : (func: (v: T[keyof T]) => U) => Chainable<{ [k in keyof T]: U; }> +>U : U +>func : (v: T[keyof T]) => U +>v : T[keyof T] +>T : T +>T : T +>U : U +>Chainable : Chainable +>k : k +>T : T +>U : U +} + +declare function chain(t: T): Chainable; +>chain : (t: T) => Chainable +>T : T +>t : T +>T : T +>Chainable : Chainable +>T : T + +const square = (x: number) => x * x; +>square : (x: number) => number +>(x: number) => x * x : (x: number) => number +>x : number +>x * x : number +>x : number +>x : number + +const v = chain({a: 1, b: 2}).mapValues(square).value(); +>v : { a: number; b: number; } +>chain({a: 1, b: 2}).mapValues(square).value() : { a: number; b: number; } +>chain({a: 1, b: 2}).mapValues(square).value : () => { a: number; b: number; } +>chain({a: 1, b: 2}).mapValues(square) : Chainable<{ a: number; b: number; }> +>chain({a: 1, b: 2}).mapValues : (func: (v: number) => U) => Chainable<{ a: U; b: U; }> +>chain({a: 1, b: 2}) : Chainable<{ a: number; b: number; }> +>chain : (t: T) => Chainable +>{a: 1, b: 2} : { a: number; b: number; } +>a : number +>1 : 1 +>b : number +>2 : 2 +>mapValues : (func: (v: number) => U) => Chainable<{ a: U; b: U; }> +>square : (x: number) => number +>value : () => { a: number; b: number; } + diff --git a/tests/baselines/reference/mappedTypeRelationships.errors.txt b/tests/baselines/reference/mappedTypeRelationships.errors.txt index e8e0371ed9a..22f56dacaf6 100644 --- a/tests/baselines/reference/mappedTypeRelationships.errors.txt +++ b/tests/baselines/reference/mappedTypeRelationships.errors.txt @@ -3,8 +3,12 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(12,5): error TS2 tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(17,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(21,5): error TS2536: Type 'keyof U' cannot be used to index type 'T'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(22,5): error TS2322: Type 'T[keyof U]' is not assignable to type 'U[keyof U]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(22,12): error TS2536: Type 'keyof U' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(26,5): error TS2536: Type 'K' cannot be used to index type 'T'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(27,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(27,12): error TS2536: Type 'K' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(31,5): error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'. Type 'undefined' is not assignable to type 'T[keyof T]'. @@ -26,9 +30,24 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(62,5): error TS2 tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(67,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(71,5): error TS2322: Type 'Partial' is not assignable to type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2322: Type 'Partial' is not assignable to type 'T'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(126,5): error TS2322: Type 'Partial' is not assignable to type 'Identity'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(142,5): error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. + Type 'T[P]' is not assignable to type 'U[P]'. + Type 'T' is not assignable to type 'U'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(147,5): error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. + Type 'keyof U' is not assignable to type 'keyof T'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(152,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: T[P]; }'. + Type 'keyof T' is not assignable to type 'K'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(157,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. + Type 'keyof U' is not assignable to type 'K'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(162,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. + Type 'keyof T' is not assignable to type 'K'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in K]: U[P]; }'. + Type 'T[P]' is not assignable to type 'U[P]'. + Type 'T' is not assignable to type 'U'. -==== tests/cases/conformance/types/mapped/mappedTypeRelationships.ts (18 errors) ==== +==== tests/cases/conformance/types/mapped/mappedTypeRelationships.ts (27 errors) ==== function f1(x: T, k: keyof T) { return x[k]; @@ -59,6 +78,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2 ~~~~ !!! error TS2536: Type 'keyof U' cannot be used to index type 'T'. y[k] = x[k]; // Error + ~~~~ +!!! error TS2322: Type 'T[keyof U]' is not assignable to type 'U[keyof U]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. ~~~~ !!! error TS2536: Type 'keyof U' cannot be used to index type 'T'. } @@ -68,6 +90,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2 ~~~~ !!! error TS2536: Type 'K' cannot be used to index type 'T'. y[k] = x[k]; // Error + ~~~~ +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. ~~~~ !!! error TS2536: Type 'K' cannot be used to index type 'T'. } @@ -180,4 +205,89 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2 function f51(obj: T, key: K) { let item: Item = obj[key]; return obj[key].name; - } \ No newline at end of file + } + + type T1 = { + [P in keyof T]: T[P]; + } + + type T2 = { + [P in keyof T]: T[P]; + } + + function f60(x: T1, y: T2) { + x = y; + y = x; + } + + type Identity = { + [P in keyof T]: T[P]; + } + + function f61(x: Identity, y: Partial) { + x = y; // Error + ~ +!!! error TS2322: Type 'Partial' is not assignable to type 'Identity'. + y = x; + } + + function f62(x: Identity, y: Readonly) { + x = y; + y = x; + } + + function f70(x: { [P in keyof T]: T[P] }, y: { [P in keyof T]: T[P] }) { + x = y; + y = x; + } + + function f71(x: { [P in keyof T]: T[P] }, y: { [P in keyof T]: U[P] }) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. +!!! error TS2322: Type 'T[P]' is not assignable to type 'U[P]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. + } + + function f72(x: { [P in keyof T]: T[P] }, y: { [P in keyof U]: U[P] }) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. +!!! error TS2322: Type 'keyof U' is not assignable to type 'keyof T'. + } + + function f73(x: { [P in K]: T[P] }, y: { [P in keyof T]: T[P] }) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: T[P]; }'. +!!! error TS2322: Type 'keyof T' is not assignable to type 'K'. + } + + function f74(x: { [P in K]: T[P] }, y: { [P in keyof U]: U[P] }) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. +!!! error TS2322: Type 'keyof U' is not assignable to type 'K'. + } + + function f75(x: { [P in K]: T[P] }, y: { [P in keyof T]: U[P] }) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. +!!! error TS2322: Type 'keyof T' is not assignable to type 'K'. + } + + function f76(x: { [P in K]: T[P] }, y: { [P in K]: U[P] }) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in K]: U[P]; }'. +!!! error TS2322: Type 'T[P]' is not assignable to type 'U[P]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/mappedTypeRelationships.js b/tests/baselines/reference/mappedTypeRelationships.js index a81ff973da8..2476b72cef6 100644 --- a/tests/baselines/reference/mappedTypeRelationships.js +++ b/tests/baselines/reference/mappedTypeRelationships.js @@ -104,7 +104,70 @@ function f50(obj: T, key: keyof T) { function f51(obj: T, key: K) { let item: Item = obj[key]; return obj[key].name; -} +} + +type T1 = { + [P in keyof T]: T[P]; +} + +type T2 = { + [P in keyof T]: T[P]; +} + +function f60(x: T1, y: T2) { + x = y; + y = x; +} + +type Identity = { + [P in keyof T]: T[P]; +} + +function f61(x: Identity, y: Partial) { + x = y; // Error + y = x; +} + +function f62(x: Identity, y: Readonly) { + x = y; + y = x; +} + +function f70(x: { [P in keyof T]: T[P] }, y: { [P in keyof T]: T[P] }) { + x = y; + y = x; +} + +function f71(x: { [P in keyof T]: T[P] }, y: { [P in keyof T]: U[P] }) { + x = y; + y = x; // Error +} + +function f72(x: { [P in keyof T]: T[P] }, y: { [P in keyof U]: U[P] }) { + x = y; + y = x; // Error +} + +function f73(x: { [P in K]: T[P] }, y: { [P in keyof T]: T[P] }) { + x = y; + y = x; // Error +} + +function f74(x: { [P in K]: T[P] }, y: { [P in keyof U]: U[P] }) { + x = y; + y = x; // Error +} + +function f75(x: { [P in K]: T[P] }, y: { [P in keyof T]: U[P] }) { + x = y; + y = x; // Error +} + +function f76(x: { [P in K]: T[P] }, y: { [P in K]: U[P] }) { + x = y; + y = x; // Error +} + //// [mappedTypeRelationships.js] function f1(x, k) { @@ -185,6 +248,46 @@ function f51(obj, key) { var item = obj[key]; return obj[key].name; } +function f60(x, y) { + x = y; + y = x; +} +function f61(x, y) { + x = y; // Error + y = x; +} +function f62(x, y) { + x = y; + y = x; +} +function f70(x, y) { + x = y; + y = x; +} +function f71(x, y) { + x = y; + y = x; // Error +} +function f72(x, y) { + x = y; + y = x; // Error +} +function f73(x, y) { + x = y; + y = x; // Error +} +function f74(x, y) { + x = y; + y = x; // Error +} +function f75(x, y) { + x = y; + y = x; // Error +} +function f76(x, y) { + x = y; + y = x; // Error +} //// [mappedTypeRelationships.d.ts] @@ -214,3 +317,50 @@ declare type ItemMap = { }; declare function f50(obj: T, key: keyof T): string; declare function f51(obj: T, key: K): string; +declare type T1 = { + [P in keyof T]: T[P]; +}; +declare type T2 = { + [P in keyof T]: T[P]; +}; +declare function f60(x: T1, y: T2): void; +declare type Identity = { + [P in keyof T]: T[P]; +}; +declare function f61(x: Identity, y: Partial): void; +declare function f62(x: Identity, y: Readonly): void; +declare function f70(x: { + [P in keyof T]: T[P]; +}, y: { + [P in keyof T]: T[P]; +}): void; +declare function f71(x: { + [P in keyof T]: T[P]; +}, y: { + [P in keyof T]: U[P]; +}): void; +declare function f72(x: { + [P in keyof T]: T[P]; +}, y: { + [P in keyof U]: U[P]; +}): void; +declare function f73(x: { + [P in K]: T[P]; +}, y: { + [P in keyof T]: T[P]; +}): void; +declare function f74(x: { + [P in K]: T[P]; +}, y: { + [P in keyof U]: U[P]; +}): void; +declare function f75(x: { + [P in K]: T[P]; +}, y: { + [P in keyof T]: U[P]; +}): void; +declare function f76(x: { + [P in K]: T[P]; +}, y: { + [P in K]: U[P]; +}): void; diff --git a/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.errors.txt b/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.errors.txt new file mode 100644 index 00000000000..56837dd787e --- /dev/null +++ b/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/mappedTypeWithCombinedTypeMappers.ts(18,7): error TS2322: Type 'string' is not assignable to type '{ important: boolean; }'. + + +==== tests/cases/compiler/mappedTypeWithCombinedTypeMappers.ts (1 errors) ==== + // Repro from #13351 + + type Meta = { + readonly[P in keyof T]: { + value: T[P]; + also: A; + readonly children: Meta; + }; + } + + interface Input { + x: string; + y: number; + } + + declare const output: Meta; + + const shouldFail: { important: boolean } = output.x.children; + ~~~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type '{ important: boolean; }'. + \ No newline at end of file diff --git a/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.js b/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.js new file mode 100644 index 00000000000..a445f2eebc5 --- /dev/null +++ b/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.js @@ -0,0 +1,24 @@ +//// [mappedTypeWithCombinedTypeMappers.ts] +// Repro from #13351 + +type Meta = { + readonly[P in keyof T]: { + value: T[P]; + also: A; + readonly children: Meta; + }; +} + +interface Input { + x: string; + y: number; +} + +declare const output: Meta; + +const shouldFail: { important: boolean } = output.x.children; + + +//// [mappedTypeWithCombinedTypeMappers.js] +// Repro from #13351 +var shouldFail = output.x.children; diff --git a/tests/baselines/reference/mappedTypes4.js b/tests/baselines/reference/mappedTypes4.js index bb003b1a1ec..963538d2269 100644 --- a/tests/baselines/reference/mappedTypes4.js +++ b/tests/baselines/reference/mappedTypes4.js @@ -58,7 +58,19 @@ type DeepReadonlyFoo = { }; var x1: DeepReadonly; -var x1: DeepReadonlyFoo; +var x1: DeepReadonlyFoo; + +// Repro from #13232 + +type Z = { a: number }; +type Clone = { + [P in keyof (T & {})]: T[P]; +}; +type M = Clone; // M should be { a: number } + +var z1: Z; +var z1: Clone; + //// [mappedTypes4.js] function boxify(obj) { @@ -76,6 +88,8 @@ function f1(x) { } var x1; var x1; +var z1; +var z1; //// [mappedTypes4.d.ts] @@ -127,3 +141,12 @@ declare type DeepReadonlyFoo = { }; declare var x1: DeepReadonly; declare var x1: DeepReadonlyFoo; +declare type Z = { + a: number; +}; +declare type Clone = { + [P in keyof (T & {})]: T[P]; +}; +declare type M = Clone; +declare var z1: Z; +declare var z1: Clone; diff --git a/tests/baselines/reference/mappedTypes4.symbols b/tests/baselines/reference/mappedTypes4.symbols index b57adfe9954..ed108b47d78 100644 --- a/tests/baselines/reference/mappedTypes4.symbols +++ b/tests/baselines/reference/mappedTypes4.symbols @@ -196,3 +196,34 @@ var x1: DeepReadonlyFoo; >x1 : Symbol(x1, Decl(mappedTypes4.ts, 58, 3), Decl(mappedTypes4.ts, 59, 3)) >DeepReadonlyFoo : Symbol(DeepReadonlyFoo, Decl(mappedTypes4.ts, 50, 2)) +// Repro from #13232 + +type Z = { a: number }; +>Z : Symbol(Z, Decl(mappedTypes4.ts, 59, 24)) +>a : Symbol(a, Decl(mappedTypes4.ts, 63, 10)) + +type Clone = { +>Clone : Symbol(Clone, Decl(mappedTypes4.ts, 63, 23)) +>T : Symbol(T, Decl(mappedTypes4.ts, 64, 11)) + + [P in keyof (T & {})]: T[P]; +>P : Symbol(P, Decl(mappedTypes4.ts, 65, 3)) +>T : Symbol(T, Decl(mappedTypes4.ts, 64, 11)) +>T : Symbol(T, Decl(mappedTypes4.ts, 64, 11)) +>P : Symbol(P, Decl(mappedTypes4.ts, 65, 3)) + +}; +type M = Clone; // M should be { a: number } +>M : Symbol(M, Decl(mappedTypes4.ts, 66, 2)) +>Clone : Symbol(Clone, Decl(mappedTypes4.ts, 63, 23)) +>Z : Symbol(Z, Decl(mappedTypes4.ts, 59, 24)) + +var z1: Z; +>z1 : Symbol(z1, Decl(mappedTypes4.ts, 69, 3), Decl(mappedTypes4.ts, 70, 3)) +>Z : Symbol(Z, Decl(mappedTypes4.ts, 59, 24)) + +var z1: Clone; +>z1 : Symbol(z1, Decl(mappedTypes4.ts, 69, 3), Decl(mappedTypes4.ts, 70, 3)) +>Clone : Symbol(Clone, Decl(mappedTypes4.ts, 63, 23)) +>Z : Symbol(Z, Decl(mappedTypes4.ts, 59, 24)) + diff --git a/tests/baselines/reference/mappedTypes4.types b/tests/baselines/reference/mappedTypes4.types index cc492d82120..a2fec06ccec 100644 --- a/tests/baselines/reference/mappedTypes4.types +++ b/tests/baselines/reference/mappedTypes4.types @@ -211,3 +211,34 @@ var x1: DeepReadonlyFoo; >x1 : DeepReadonly >DeepReadonlyFoo : DeepReadonlyFoo +// Repro from #13232 + +type Z = { a: number }; +>Z : Z +>a : number + +type Clone = { +>Clone : Clone +>T : T + + [P in keyof (T & {})]: T[P]; +>P : P +>T : T +>T : T +>P : P + +}; +type M = Clone; // M should be { a: number } +>M : Clone +>Clone : Clone +>Z : Z + +var z1: Z; +>z1 : Z +>Z : Z + +var z1: Clone; +>z1 : Z +>Clone : Clone +>Z : Z + diff --git a/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt b/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt index 405fa4d2036..6cf1bbc5fa3 100644 --- a/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt +++ b/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/matchReturnTypeInAllBranches.ts(30,20): error TS2322: Type '12345' is not assignable to type 'boolean'. +tests/cases/compiler/matchReturnTypeInAllBranches.ts(30,13): error TS2322: Type '12345' is not assignable to type 'boolean'. ==== tests/cases/compiler/matchReturnTypeInAllBranches.ts (1 errors) ==== @@ -32,7 +32,7 @@ tests/cases/compiler/matchReturnTypeInAllBranches.ts(30,20): error TS2322: Type else { return 12345; - ~~~~~ + ~~~~~~~~~~~~~ !!! error TS2322: Type '12345' is not assignable to type 'boolean'. } } diff --git a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json index f6df1476088..eeff8b42ce6 100644 --- a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json +++ b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json @@ -1,7 +1,7 @@ [ "======== Resolving module 'shortid' from '/index.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module 'shortid' from 'node_modules' folder.", + "Loading module 'shortid' from 'node_modules' folder, target file type 'TypeScript'.", "File '/node_modules/shortid.ts' does not exist.", "File '/node_modules/shortid.tsx' does not exist.", "File '/node_modules/shortid.d.ts' does not exist.", @@ -9,10 +9,8 @@ "File '/node_modules/shortid/index.ts' does not exist.", "File '/node_modules/shortid/index.tsx' does not exist.", "File '/node_modules/shortid/index.d.ts' does not exist.", - "File '/node_modules/@types/shortid.d.ts' does not exist.", - "File '/node_modules/@types/shortid/package.json' does not exist.", - "File '/node_modules/@types/shortid/index.d.ts' does not exist.", - "Loading module 'shortid' from 'node_modules' folder.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Loading module 'shortid' from 'node_modules' folder, target file type 'JavaScript'.", "File '/node_modules/shortid.js' does not exist.", "File '/node_modules/shortid.jsx' does not exist.", "File '/node_modules/shortid/package.json' does not exist.", diff --git a/tests/baselines/reference/mergedDeclarations5.js b/tests/baselines/reference/mergedDeclarations5.js index b24e86eca58..a1e144fc223 100644 --- a/tests/baselines/reference/mergedDeclarations5.js +++ b/tests/baselines/reference/mergedDeclarations5.js @@ -19,15 +19,20 @@ var A = (function () { return A; }()); //// [b.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.foo = function () { }; return B; diff --git a/tests/baselines/reference/mergedDeclarations6.js b/tests/baselines/reference/mergedDeclarations6.js index d610e4ab46f..4452165c3e6 100644 --- a/tests/baselines/reference/mergedDeclarations6.js +++ b/tests/baselines/reference/mergedDeclarations6.js @@ -37,17 +37,22 @@ define(["require", "exports"], function (require, exports) { exports.A = A; }); //// [b.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); define(["require", "exports", "./a"], function (require, exports, a_1) { "use strict"; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.setProtected = function () { }; diff --git a/tests/baselines/reference/mergedInheritedClassInterface.js b/tests/baselines/reference/mergedInheritedClassInterface.js index 0f598f2cf78..25ad2b8be75 100644 --- a/tests/baselines/reference/mergedInheritedClassInterface.js +++ b/tests/baselines/reference/mergedInheritedClassInterface.js @@ -47,11 +47,16 @@ grandchild.method2(); //// [mergedInheritedClassInterface.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var BaseClass = (function () { function BaseClass() { } @@ -61,7 +66,7 @@ var BaseClass = (function () { var Child = (function (_super) { __extends(Child, _super); function Child() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Child.prototype.method = function () { }; return Child; @@ -75,7 +80,7 @@ var ChildNoBaseClass = (function () { var Grandchild = (function (_super) { __extends(Grandchild, _super); function Grandchild() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Grandchild; }(ChildNoBaseClass)); diff --git a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.js b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.js index 6dccf1dfdd9..4390bc251cd 100644 --- a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.js +++ b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.js @@ -32,11 +32,16 @@ var r = a.x; // error var r2 = a.w; // error //// [mergedInterfacesWithInheritedPrivates2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -50,14 +55,14 @@ var C2 = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(C2)); diff --git a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates3.js b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates3.js index a3ca796575c..8ad8a27dc8f 100644 --- a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates3.js +++ b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates3.js @@ -39,11 +39,16 @@ module M { } //// [mergedInterfacesWithInheritedPrivates3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -57,7 +62,7 @@ var C2 = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/metadataOfClassFromModule.js b/tests/baselines/reference/metadataOfClassFromModule.js new file mode 100644 index 00000000000..8ef120600df --- /dev/null +++ b/tests/baselines/reference/metadataOfClassFromModule.js @@ -0,0 +1,44 @@ +//// [metadataOfClassFromModule.ts] +module MyModule { + + export function inject(target: any, key: string): void { } + + export class Leg { } + + export class Person { + @inject leftLeg: Leg; + } + +} + +//// [metadataOfClassFromModule.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +var MyModule; +(function (MyModule) { + function inject(target, key) { } + MyModule.inject = inject; + var Leg = (function () { + function Leg() { + } + return Leg; + }()); + MyModule.Leg = Leg; + var Person = (function () { + function Person() { + } + return Person; + }()); + __decorate([ + inject, + __metadata("design:type", Leg) + ], Person.prototype, "leftLeg", void 0); + MyModule.Person = Person; +})(MyModule || (MyModule = {})); diff --git a/tests/baselines/reference/metadataOfClassFromModule.symbols b/tests/baselines/reference/metadataOfClassFromModule.symbols new file mode 100644 index 00000000000..f430677f0fa --- /dev/null +++ b/tests/baselines/reference/metadataOfClassFromModule.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/metadataOfClassFromModule.ts === +module MyModule { +>MyModule : Symbol(MyModule, Decl(metadataOfClassFromModule.ts, 0, 0)) + + export function inject(target: any, key: string): void { } +>inject : Symbol(inject, Decl(metadataOfClassFromModule.ts, 0, 17)) +>target : Symbol(target, Decl(metadataOfClassFromModule.ts, 2, 27)) +>key : Symbol(key, Decl(metadataOfClassFromModule.ts, 2, 39)) + + export class Leg { } +>Leg : Symbol(Leg, Decl(metadataOfClassFromModule.ts, 2, 62)) + + export class Person { +>Person : Symbol(Person, Decl(metadataOfClassFromModule.ts, 4, 24)) + + @inject leftLeg: Leg; +>inject : Symbol(inject, Decl(metadataOfClassFromModule.ts, 0, 17)) +>leftLeg : Symbol(Person.leftLeg, Decl(metadataOfClassFromModule.ts, 6, 25)) +>Leg : Symbol(Leg, Decl(metadataOfClassFromModule.ts, 2, 62)) + } + +} diff --git a/tests/baselines/reference/metadataOfClassFromModule.types b/tests/baselines/reference/metadataOfClassFromModule.types new file mode 100644 index 00000000000..eeb24bf82aa --- /dev/null +++ b/tests/baselines/reference/metadataOfClassFromModule.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/metadataOfClassFromModule.ts === +module MyModule { +>MyModule : typeof MyModule + + export function inject(target: any, key: string): void { } +>inject : (target: any, key: string) => void +>target : any +>key : string + + export class Leg { } +>Leg : Leg + + export class Person { +>Person : Person + + @inject leftLeg: Leg; +>inject : (target: any, key: string) => void +>leftLeg : Leg +>Leg : Leg + } + +} diff --git a/tests/baselines/reference/missingPropertiesOfClassExpression.js b/tests/baselines/reference/missingPropertiesOfClassExpression.js index c7b30882b14..7f468d14def 100644 --- a/tests/baselines/reference/missingPropertiesOfClassExpression.js +++ b/tests/baselines/reference/missingPropertiesOfClassExpression.js @@ -7,11 +7,16 @@ class George extends class { reset() { return this.y; } } { //// [missingPropertiesOfClassExpression.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var George = (function (_super) { __extends(George, _super); function George() { diff --git a/tests/baselines/reference/moduleAsBaseType.js b/tests/baselines/reference/moduleAsBaseType.js index fc0533a2470..2a3ee8f4585 100644 --- a/tests/baselines/reference/moduleAsBaseType.js +++ b/tests/baselines/reference/moduleAsBaseType.js @@ -5,15 +5,20 @@ interface I extends M { } class C2 implements M { } //// [moduleAsBaseType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(M)); diff --git a/tests/baselines/reference/moduleImportedForTypeArgumentPosition.js b/tests/baselines/reference/moduleImportedForTypeArgumentPosition.js index 51d9eb89b1d..26d262a76fe 100644 --- a/tests/baselines/reference/moduleImportedForTypeArgumentPosition.js +++ b/tests/baselines/reference/moduleImportedForTypeArgumentPosition.js @@ -16,11 +16,16 @@ define(["require", "exports"], function (require, exports) { "use strict"; }); //// [moduleImportedForTypeArgumentPosition_1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); define(["require", "exports"], function (require, exports) { "use strict"; var C1 = (function () { @@ -31,7 +36,7 @@ define(["require", "exports"], function (require, exports) { var Test1 = (function (_super) { __extends(Test1, _super); function Test1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Test1; }(C1)); diff --git a/tests/baselines/reference/modulePrologueUmd.js b/tests/baselines/reference/modulePrologueUmd.js index fb366945d66..18edf1ef4af 100644 --- a/tests/baselines/reference/modulePrologueUmd.js +++ b/tests/baselines/reference/modulePrologueUmd.js @@ -4,14 +4,15 @@ export class Foo {} //// [modulePrologueUmd.js] -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { "use strict"; var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/moduleResolutionWithExtensions.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions.trace.json index 6860c61bb17..50e3cccad9c 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions.trace.json @@ -1,12 +1,12 @@ [ "======== Resolving module './a' from '/src/b.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/src/a'.", + "Loading module as file / folder, candidate module location '/src/a', target file type 'TypeScript'.", "File '/src/a.ts' exist - use it as a name resolution result.", "======== Module name './a' was successfully resolved to '/src/a.ts'. ========", "======== Resolving module './a.js' from '/src/d.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/src/a.js'.", + "Loading module as file / folder, candidate module location '/src/a.js', target file type 'TypeScript'.", "File '/src/a.js.ts' does not exist.", "File '/src/a.js.tsx' does not exist.", "File '/src/a.js.d.ts' does not exist.", @@ -15,7 +15,7 @@ "======== Module name './a.js' was successfully resolved to '/src/a.ts'. ========", "======== Resolving module './jquery.js' from '/src/jquery_user_1.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/src/jquery.js'.", + "Loading module as file / folder, candidate module location '/src/jquery.js', target file type 'TypeScript'.", "File '/src/jquery.js.ts' does not exist.", "File '/src/jquery.js.tsx' does not exist.", "File '/src/jquery.js.d.ts' does not exist.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.trace.json index f2b0214602c..b57862c09e3 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.trace.json @@ -1,35 +1,29 @@ [ "======== Resolving module './tsx' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/tsx'.", + "Loading module as file / folder, candidate module location '/tsx', target file type 'TypeScript'.", "File '/tsx.ts' does not exist.", "File '/tsx.tsx' exist - use it as a name resolution result.", "======== Module name './tsx' was successfully resolved to '/tsx.tsx'. ========", "======== Resolving module './jsx' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/jsx'.", + "Loading module as file / folder, candidate module location '/jsx', target file type 'TypeScript'.", "File '/jsx.ts' does not exist.", "File '/jsx.tsx' does not exist.", "File '/jsx.d.ts' does not exist.", - "File '/jsx/package.json' does not exist.", - "File '/jsx/index.ts' does not exist.", - "File '/jsx/index.tsx' does not exist.", - "File '/jsx/index.d.ts' does not exist.", - "Loading module as file / folder, candidate module location '/jsx'.", + "Directory '/jsx' does not exist, skipping all lookups in it.", + "Loading module as file / folder, candidate module location '/jsx', target file type 'JavaScript'.", "File '/jsx.js' does not exist.", "File '/jsx.jsx' exist - use it as a name resolution result.", "======== Module name './jsx' was successfully resolved to '/jsx.jsx'. ========", "======== Resolving module './js' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/js'.", + "Loading module as file / folder, candidate module location '/js', target file type 'TypeScript'.", "File '/js.ts' does not exist.", "File '/js.tsx' does not exist.", "File '/js.d.ts' does not exist.", - "File '/js/package.json' does not exist.", - "File '/js/index.ts' does not exist.", - "File '/js/index.tsx' does not exist.", - "File '/js/index.d.ts' does not exist.", - "Loading module as file / folder, candidate module location '/js'.", + "Directory '/js' does not exist, skipping all lookups in it.", + "Loading module as file / folder, candidate module location '/js', target file type 'JavaScript'.", "File '/js.js' exist - use it as a name resolution result.", "======== Module name './js' was successfully resolved to '/js.js'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported2.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported2.trace.json index 89bd061301e..7474cccdb35 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported2.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported2.trace.json @@ -1,15 +1,12 @@ [ "======== Resolving module './jsx' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/jsx'.", + "Loading module as file / folder, candidate module location '/jsx', target file type 'TypeScript'.", "File '/jsx.ts' does not exist.", "File '/jsx.tsx' does not exist.", "File '/jsx.d.ts' does not exist.", - "File '/jsx/package.json' does not exist.", - "File '/jsx/index.ts' does not exist.", - "File '/jsx/index.tsx' does not exist.", - "File '/jsx/index.d.ts' does not exist.", - "Loading module as file / folder, candidate module location '/jsx'.", + "Directory '/jsx' does not exist, skipping all lookups in it.", + "Loading module as file / folder, candidate module location '/jsx', target file type 'JavaScript'.", "File '/jsx.js' does not exist.", "File '/jsx.jsx' exist - use it as a name resolution result.", "======== Module name './jsx' was successfully resolved to '/jsx.jsx'. ========" diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.trace.json index 89bd061301e..7474cccdb35 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.trace.json @@ -1,15 +1,12 @@ [ "======== Resolving module './jsx' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/jsx'.", + "Loading module as file / folder, candidate module location '/jsx', target file type 'TypeScript'.", "File '/jsx.ts' does not exist.", "File '/jsx.tsx' does not exist.", "File '/jsx.d.ts' does not exist.", - "File '/jsx/package.json' does not exist.", - "File '/jsx/index.ts' does not exist.", - "File '/jsx/index.tsx' does not exist.", - "File '/jsx/index.d.ts' does not exist.", - "Loading module as file / folder, candidate module location '/jsx'.", + "Directory '/jsx' does not exist, skipping all lookups in it.", + "Loading module as file / folder, candidate module location '/jsx', target file type 'JavaScript'.", "File '/jsx.js' does not exist.", "File '/jsx.jsx' exist - use it as a name resolution result.", "======== Module name './jsx' was successfully resolved to '/jsx.jsx'. ========" diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_preferTs.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_preferTs.trace.json index f6612b84cc3..0c56366809e 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_preferTs.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_preferTs.trace.json @@ -1,7 +1,7 @@ [ "======== Resolving module './b' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/b'.", + "Loading module as file / folder, candidate module location '/b', target file type 'TypeScript'.", "File '/b.ts' does not exist.", "File '/b.tsx' does not exist.", "File '/b.d.ts' does not exist.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json index 84532e8db7b..e1b1673b32a 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json @@ -1,7 +1,7 @@ [ "======== Resolving module 'normalize.css' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module 'normalize.css' from 'node_modules' folder.", + "Loading module 'normalize.css' from 'node_modules' folder, target file type 'TypeScript'.", "File '/node_modules/normalize.css.ts' does not exist.", "File '/node_modules/normalize.css.tsx' does not exist.", "File '/node_modules/normalize.css.d.ts' does not exist.", @@ -10,10 +10,8 @@ "File '/node_modules/normalize.css/index.ts' does not exist.", "File '/node_modules/normalize.css/index.tsx' does not exist.", "File '/node_modules/normalize.css/index.d.ts' does not exist.", - "File '/node_modules/@types/normalize.css.d.ts' does not exist.", - "File '/node_modules/@types/normalize.css/package.json' does not exist.", - "File '/node_modules/@types/normalize.css/index.d.ts' does not exist.", - "Loading module 'normalize.css' from 'node_modules' folder.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Loading module 'normalize.css' from 'node_modules' folder, target file type 'JavaScript'.", "File '/node_modules/normalize.css.js' does not exist.", "File '/node_modules/normalize.css.jsx' does not exist.", "Found 'package.json' at '/node_modules/normalize.css/package.json'.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json index 27c9d2243e5..11dd95ebe45 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json @@ -1,7 +1,7 @@ [ "======== Resolving module 'foo' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module 'foo' from 'node_modules' folder.", + "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", "File '/node_modules/foo.ts' does not exist.", "File '/node_modules/foo.tsx' does not exist.", "File '/node_modules/foo.d.ts' does not exist.", @@ -15,10 +15,8 @@ "File '/node_modules/foo/index.ts' does not exist.", "File '/node_modules/foo/index.tsx' does not exist.", "File '/node_modules/foo/index.d.ts' does not exist.", - "File '/node_modules/@types/foo.d.ts' does not exist.", - "File '/node_modules/@types/foo/package.json' does not exist.", - "File '/node_modules/@types/foo/index.d.ts' does not exist.", - "Loading module 'foo' from 'node_modules' folder.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", "Found 'package.json' at '/node_modules/foo/package.json'.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json index 8d4217a92bd..c01ba494886 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json @@ -1,7 +1,7 @@ [ "======== Resolving module 'js' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module 'js' from 'node_modules' folder.", + "Loading module 'js' from 'node_modules' folder, target file type 'TypeScript'.", "File '/node_modules/js.ts' does not exist.", "File '/node_modules/js.tsx' does not exist.", "File '/node_modules/js.d.ts' does not exist.", @@ -9,10 +9,8 @@ "File '/node_modules/js/index.ts' does not exist.", "File '/node_modules/js/index.tsx' does not exist.", "File '/node_modules/js/index.d.ts' does not exist.", - "File '/node_modules/@types/js.d.ts' does not exist.", - "File '/node_modules/@types/js/package.json' does not exist.", - "File '/node_modules/@types/js/index.d.ts' does not exist.", - "Loading module 'js' from 'node_modules' folder.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Loading module 'js' from 'node_modules' folder, target file type 'JavaScript'.", "File '/node_modules/js.js' does not exist.", "File '/node_modules/js.jsx' does not exist.", "File '/node_modules/js/package.json' does not exist.", diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks.trace.json b/tests/baselines/reference/moduleResolutionWithSymlinks.trace.json index bd23ccdb366..1b21293fc05 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSymlinks.trace.json @@ -1,7 +1,7 @@ [ "======== Resolving module './library-a' from '/src/app.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/src/library-a'.", + "Loading module as file / folder, candidate module location '/src/library-a', target file type 'TypeScript'.", "File '/src/library-a.ts' does not exist.", "File '/src/library-a.tsx' does not exist.", "File '/src/library-a.d.ts' does not exist.", @@ -10,7 +10,7 @@ "======== Module name './library-a' was successfully resolved to '/src/library-a/index.ts'. ========", "======== Resolving module './library-b' from '/src/app.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/src/library-b'.", + "Loading module as file / folder, candidate module location '/src/library-b', target file type 'TypeScript'.", "File '/src/library-b.ts' does not exist.", "File '/src/library-b.tsx' does not exist.", "File '/src/library-b.d.ts' does not exist.", @@ -19,7 +19,7 @@ "======== Module name './library-b' was successfully resolved to '/src/library-b/index.ts'. ========", "======== Resolving module 'library-a' from '/src/library-b/index.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module 'library-a' from 'node_modules' folder.", + "Loading module 'library-a' from 'node_modules' folder, target file type 'TypeScript'.", "File '/src/library-b/node_modules/library-a.ts' does not exist.", "File '/src/library-b/node_modules/library-a.tsx' does not exist.", "File '/src/library-b/node_modules/library-a.d.ts' does not exist.", diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks_notInNodeModules.trace.json b/tests/baselines/reference/moduleResolutionWithSymlinks_notInNodeModules.trace.json index c2f0c04d07f..477bae0b4e2 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks_notInNodeModules.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSymlinks_notInNodeModules.trace.json @@ -1,12 +1,12 @@ [ "======== Resolving module './shared/abc' from '/src/app.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/src/shared/abc'.", + "Loading module as file / folder, candidate module location '/src/shared/abc', target file type 'TypeScript'.", "File '/src/shared/abc.ts' exist - use it as a name resolution result.", "======== Module name './shared/abc' was successfully resolved to '/src/shared/abc.ts'. ========", "======== Resolving module './shared2/abc' from '/src/app.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/src/shared2/abc'.", + "Loading module as file / folder, candidate module location '/src/shared2/abc', target file type 'TypeScript'.", "File '/src/shared2/abc.ts' exist - use it as a name resolution result.", "======== Module name './shared2/abc' was successfully resolved to '/src/shared2/abc.ts'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks_referenceTypes.trace.json b/tests/baselines/reference/moduleResolutionWithSymlinks_referenceTypes.trace.json index 3e0609ee325..78d169457ee 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks_referenceTypes.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSymlinks_referenceTypes.trace.json @@ -3,8 +3,6 @@ "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/'", "File '/node_modules/library-a.d.ts' does not exist.", - "File '/node_modules/library-a/package.json' does not exist.", - "File '/node_modules/library-a/index.d.ts' does not exist.", "File '/node_modules/@types/library-a.d.ts' does not exist.", "File '/node_modules/@types/library-a/package.json' does not exist.", "File '/node_modules/@types/library-a/index.d.ts' exist - use it as a name resolution result.", @@ -14,8 +12,6 @@ "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/'", "File '/node_modules/library-b.d.ts' does not exist.", - "File '/node_modules/library-b/package.json' does not exist.", - "File '/node_modules/library-b/index.d.ts' does not exist.", "File '/node_modules/@types/library-b.d.ts' does not exist.", "File '/node_modules/@types/library-b/package.json' does not exist.", "File '/node_modules/@types/library-b/index.d.ts' exist - use it as a name resolution result.", @@ -25,8 +21,6 @@ "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/node_modules/@types/library-b'", "File '/node_modules/@types/library-b/node_modules/library-a.d.ts' does not exist.", - "File '/node_modules/@types/library-b/node_modules/library-a/package.json' does not exist.", - "File '/node_modules/@types/library-b/node_modules/library-a/index.d.ts' does not exist.", "File '/node_modules/@types/library-b/node_modules/@types/library-a.d.ts' does not exist.", "File '/node_modules/@types/library-b/node_modules/@types/library-a/package.json' does not exist.", "File '/node_modules/@types/library-b/node_modules/@types/library-a/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.trace.json b/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.trace.json index bd23ccdb366..1b21293fc05 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.trace.json @@ -1,7 +1,7 @@ [ "======== Resolving module './library-a' from '/src/app.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/src/library-a'.", + "Loading module as file / folder, candidate module location '/src/library-a', target file type 'TypeScript'.", "File '/src/library-a.ts' does not exist.", "File '/src/library-a.tsx' does not exist.", "File '/src/library-a.d.ts' does not exist.", @@ -10,7 +10,7 @@ "======== Module name './library-a' was successfully resolved to '/src/library-a/index.ts'. ========", "======== Resolving module './library-b' from '/src/app.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/src/library-b'.", + "Loading module as file / folder, candidate module location '/src/library-b', target file type 'TypeScript'.", "File '/src/library-b.ts' does not exist.", "File '/src/library-b.tsx' does not exist.", "File '/src/library-b.d.ts' does not exist.", @@ -19,7 +19,7 @@ "======== Module name './library-b' was successfully resolved to '/src/library-b/index.ts'. ========", "======== Resolving module 'library-a' from '/src/library-b/index.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module 'library-a' from 'node_modules' folder.", + "Loading module 'library-a' from 'node_modules' folder, target file type 'TypeScript'.", "File '/src/library-b/node_modules/library-a.ts' does not exist.", "File '/src/library-b/node_modules/library-a.tsx' does not exist.", "File '/src/library-b/node_modules/library-a.d.ts' does not exist.", diff --git a/tests/baselines/reference/moduleVariableArrayIndexer.errors.txt b/tests/baselines/reference/moduleVariableArrayIndexer.errors.txt new file mode 100644 index 00000000000..f0c070375f6 --- /dev/null +++ b/tests/baselines/reference/moduleVariableArrayIndexer.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/moduleVariableArrayIndexer.ts(3,13): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/compiler/moduleVariableArrayIndexer.ts (1 errors) ==== + module Bar { + export var a = 1; + var t = undefined[a][a]; // CG: var t = undefined[Bar.a][a]; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/moduleWithStatementsOfEveryKind.js b/tests/baselines/reference/moduleWithStatementsOfEveryKind.js index 4243c9849cf..00838f25beb 100644 --- a/tests/baselines/reference/moduleWithStatementsOfEveryKind.js +++ b/tests/baselines/reference/moduleWithStatementsOfEveryKind.js @@ -59,11 +59,16 @@ module Y { //// [moduleWithStatementsOfEveryKind.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A; (function (A_1) { var A = (function () { @@ -79,14 +84,14 @@ var A; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(AA)); var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return BB; }(A)); @@ -130,7 +135,7 @@ var Y; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(AA)); @@ -138,7 +143,7 @@ var Y; var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return BB; }(A)); diff --git a/tests/baselines/reference/multipleInheritance.js b/tests/baselines/reference/multipleInheritance.js index 9c0e865cdb7..59abc8cd469 100644 --- a/tests/baselines/reference/multipleInheritance.js +++ b/tests/baselines/reference/multipleInheritance.js @@ -39,11 +39,16 @@ class Baad extends Good { //// [multipleInheritance.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B1 = (function () { function B1() { } @@ -57,28 +62,28 @@ var B2 = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B1)); var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(B1)); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(B2)); var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(D1)); @@ -90,7 +95,7 @@ var N = (function () { var ND = (function (_super) { __extends(ND, _super); function ND() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ND; }(N)); @@ -104,7 +109,7 @@ var Good = (function () { var Baad = (function (_super) { __extends(Baad, _super); function Baad() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Baad.prototype.f = function () { return 0; }; Baad.prototype.g = function (n) { return 0; }; diff --git a/tests/baselines/reference/mutuallyRecursiveGenericBaseTypes2.js b/tests/baselines/reference/mutuallyRecursiveGenericBaseTypes2.js index 8b59564d465..7977134b2ed 100644 --- a/tests/baselines/reference/mutuallyRecursiveGenericBaseTypes2.js +++ b/tests/baselines/reference/mutuallyRecursiveGenericBaseTypes2.js @@ -11,11 +11,16 @@ var test = new foo(); //// [mutuallyRecursiveGenericBaseTypes2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var foo = (function () { function foo() { } @@ -25,7 +30,7 @@ var foo = (function () { var foo2 = (function (_super) { __extends(foo2, _super); function foo2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return foo2; }(foo)); diff --git a/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.errors.txt b/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.errors.txt new file mode 100644 index 00000000000..c686cd7a7cf --- /dev/null +++ b/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.errors.txt @@ -0,0 +1,37 @@ +tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts(13,17): error TS2345: Argument of type 'A | B' is not assignable to parameter of type 'A'. + Type 'B' is not assignable to type 'A'. + Property 'a' is missing in type 'B'. + + +==== tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts (1 errors) ==== + class A { + constructor(private a: string) { } + } + + class B { + } + + function acceptA(a: A) { } + function acceptB(b: B) { } + + function test(x: A | B) { + if (x instanceof B) { + acceptA(x); + ~ +!!! error TS2345: Argument of type 'A | B' is not assignable to parameter of type 'A'. +!!! error TS2345: Type 'B' is not assignable to type 'A'. +!!! error TS2345: Property 'a' is missing in type 'B'. + } + + if (x instanceof A) { + acceptA(x); + } + + if (x instanceof B) { + acceptB(x); + } + + if (x instanceof B) { + acceptB(x); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.js b/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.js new file mode 100644 index 00000000000..96fa20359ca --- /dev/null +++ b/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.js @@ -0,0 +1,57 @@ +//// [narrowingGenericTypeFromInstanceof01.ts] +class A { + constructor(private a: string) { } +} + +class B { +} + +function acceptA(a: A) { } +function acceptB(b: B) { } + +function test(x: A | B) { + if (x instanceof B) { + acceptA(x); + } + + if (x instanceof A) { + acceptA(x); + } + + if (x instanceof B) { + acceptB(x); + } + + if (x instanceof B) { + acceptB(x); + } +} + +//// [narrowingGenericTypeFromInstanceof01.js] +var A = (function () { + function A(a) { + this.a = a; + } + return A; +}()); +var B = (function () { + function B() { + } + return B; +}()); +function acceptA(a) { } +function acceptB(b) { } +function test(x) { + if (x instanceof B) { + acceptA(x); + } + if (x instanceof A) { + acceptA(x); + } + if (x instanceof B) { + acceptB(x); + } + if (x instanceof B) { + acceptB(x); + } +} diff --git a/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.symbols b/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.symbols new file mode 100644 index 00000000000..2130d68cb24 --- /dev/null +++ b/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.symbols @@ -0,0 +1,73 @@ +=== tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts === +class A { +>A : Symbol(A, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 0)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 8)) + + constructor(private a: string) { } +>a : Symbol(A.a, Decl(narrowingGenericTypeFromInstanceof01.ts, 1, 16)) +} + +class B { +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 4, 8)) +} + +function acceptA(a: A) { } +>acceptA : Symbol(acceptA, Decl(narrowingGenericTypeFromInstanceof01.ts, 5, 1)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 17)) +>a : Symbol(a, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 20)) +>A : Symbol(A, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 0)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 17)) + +function acceptB(b: B) { } +>acceptB : Symbol(acceptB, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 32)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 8, 17)) +>b : Symbol(b, Decl(narrowingGenericTypeFromInstanceof01.ts, 8, 20)) +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 8, 17)) + +function test(x: A | B) { +>test : Symbol(test, Decl(narrowingGenericTypeFromInstanceof01.ts, 8, 32)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 14)) +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) +>A : Symbol(A, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 0)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 14)) +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 14)) + + if (x instanceof B) { +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) + + acceptA(x); +>acceptA : Symbol(acceptA, Decl(narrowingGenericTypeFromInstanceof01.ts, 5, 1)) +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) + } + + if (x instanceof A) { +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) +>A : Symbol(A, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 0)) + + acceptA(x); +>acceptA : Symbol(acceptA, Decl(narrowingGenericTypeFromInstanceof01.ts, 5, 1)) +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) + } + + if (x instanceof B) { +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) + + acceptB(x); +>acceptB : Symbol(acceptB, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 32)) +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) + } + + if (x instanceof B) { +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) + + acceptB(x); +>acceptB : Symbol(acceptB, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 32)) +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) + } +} diff --git a/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.types b/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.types new file mode 100644 index 00000000000..a5b7c637c6c --- /dev/null +++ b/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.types @@ -0,0 +1,81 @@ +=== tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts === +class A { +>A : A +>T : T + + constructor(private a: string) { } +>a : string +} + +class B { +>B : B +>T : T +} + +function acceptA(a: A) { } +>acceptA : (a: A) => void +>T : T +>a : A +>A : A +>T : T + +function acceptB(b: B) { } +>acceptB : (b: B) => void +>T : T +>b : B +>B : B +>T : T + +function test(x: A | B) { +>test : (x: A | B) => void +>T : T +>x : A | B +>A : A +>T : T +>B : B +>T : T + + if (x instanceof B) { +>x instanceof B : boolean +>x : A | B +>B : typeof B + + acceptA(x); +>acceptA(x) : void +>acceptA : (a: A) => void +>x : A + } + + if (x instanceof A) { +>x instanceof A : boolean +>x : A | B +>A : typeof A + + acceptA(x); +>acceptA(x) : void +>acceptA : (a: A) => void +>x : A + } + + if (x instanceof B) { +>x instanceof B : boolean +>x : A | B +>B : typeof B + + acceptB(x); +>acceptB(x) : void +>acceptB : (b: B) => void +>x : A + } + + if (x instanceof B) { +>x instanceof B : boolean +>x : A | B +>B : typeof B + + acceptB(x); +>acceptB(x) : void +>acceptB : (b: B) => void +>x : A + } +} diff --git a/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt b/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt index 3bc5689d170..e0f818ba9c1 100644 --- a/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt +++ b/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt @@ -1,12 +1,12 @@ tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(4,15): error TS1109: Expression expected. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(4,25): error TS1005: '=' expected. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(4,26): error TS1109: Expression expected. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(7,17): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(7,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(8,17): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(8,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(9,17): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(9,29): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(7,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(7,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(8,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(8,24): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(9,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(9,29): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(12,14): error TS1109: Expression expected. @@ -25,19 +25,19 @@ tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperator // invalid expressions var NUMBER2 = -(null - undefined); ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var NUMBER3 = -(null - null); ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var NUMBER4 = -(undefined - undefined); ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // miss operand var NUMBER =-; diff --git a/tests/baselines/reference/negateOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/negateOperatorWithAnyOtherType.errors.txt index 03e596aca41..0fbf89fb7ec 100644 --- a/tests/baselines/reference/negateOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/negateOperatorWithAnyOtherType.errors.txt @@ -1,7 +1,9 @@ +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorWithAnyOtherType.ts(34,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorWithAnyOtherType.ts(35,23): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorWithAnyOtherType.ts(51,1): error TS2695: Left side of comma operator is unused and has no side effects. -==== tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorWithAnyOtherType.ts (1 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorWithAnyOtherType.ts (3 errors) ==== // - operator on any type var ANY: any; @@ -36,7 +38,11 @@ tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperator // any type literal var ResultIsNumber7 = -undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber = -null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. // any type expressions var ResultIsNumber8 = -ANY2[0]; diff --git a/tests/baselines/reference/neverTypeErrors1.errors.txt b/tests/baselines/reference/neverTypeErrors1.errors.txt index cb79c0c19fb..a27c6fba065 100644 --- a/tests/baselines/reference/neverTypeErrors1.errors.txt +++ b/tests/baselines/reference/neverTypeErrors1.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/types/never/neverTypeErrors1.ts(6,5): error TS2322: Type tests/cases/conformance/types/never/neverTypeErrors1.ts(7,5): error TS2322: Type 'null' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors1.ts(8,5): error TS2322: Type '{}' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors1.ts(12,5): error TS2322: Type 'undefined' is not assignable to type 'never'. -tests/cases/conformance/types/never/neverTypeErrors1.ts(16,12): error TS2322: Type '1' is not assignable to type 'never'. +tests/cases/conformance/types/never/neverTypeErrors1.ts(16,5): error TS2322: Type '1' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors1.ts(19,16): error TS2534: A function returning 'never' cannot have a reachable end point. @@ -40,7 +40,7 @@ tests/cases/conformance/types/never/neverTypeErrors1.ts(19,16): error TS2534: A function f3(): never { return 1; - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'never'. } diff --git a/tests/baselines/reference/neverTypeErrors2.errors.txt b/tests/baselines/reference/neverTypeErrors2.errors.txt index ed27e615ea1..60e6947f44a 100644 --- a/tests/baselines/reference/neverTypeErrors2.errors.txt +++ b/tests/baselines/reference/neverTypeErrors2.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/types/never/neverTypeErrors2.ts(7,5): error TS2322: Type tests/cases/conformance/types/never/neverTypeErrors2.ts(8,5): error TS2322: Type 'null' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors2.ts(9,5): error TS2322: Type '{}' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors2.ts(13,5): error TS2322: Type 'undefined' is not assignable to type 'never'. -tests/cases/conformance/types/never/neverTypeErrors2.ts(17,12): error TS2322: Type '1' is not assignable to type 'never'. +tests/cases/conformance/types/never/neverTypeErrors2.ts(17,5): error TS2322: Type '1' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors2.ts(20,16): error TS2534: A function returning 'never' cannot have a reachable end point. @@ -41,7 +41,7 @@ tests/cases/conformance/types/never/neverTypeErrors2.ts(20,16): error TS2534: A function f3(): never { return 1; - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'never'. } diff --git a/tests/baselines/reference/newTarget.es5.js b/tests/baselines/reference/newTarget.es5.js new file mode 100644 index 00000000000..2ebe4bfcadc --- /dev/null +++ b/tests/baselines/reference/newTarget.es5.js @@ -0,0 +1,79 @@ +//// [newTarget.es5.ts] +class A { + constructor() { + const a = new.target; + const b = () => new.target; + } + static c = function () { return new.target; } + d = function () { return new.target; } +} + +class B extends A { + constructor() { + super(); + const e = new.target; + const f = () => new.target; + } +} + +function f1() { + const g = new.target; + const h = () => new.target; +} + +const f2 = function () { + const i = new.target; + const j = () => new.target; +} + +const O = { + k: function () { return new.target; } +}; + + + +//// [newTarget.es5.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var A = (function () { + function A() { + var _newTarget = this.constructor; + this.d = function _a() { var _newTarget = this && this instanceof _a ? this.constructor : void 0; return _newTarget; }; + var a = _newTarget; + var b = function () { return _newTarget; }; + } + return A; +}()); +A.c = function _a() { var _newTarget = this && this instanceof _a ? this.constructor : void 0; return _newTarget; }; +var B = (function (_super) { + __extends(B, _super); + function B() { + var _newTarget = this.constructor; + var _this = _super.call(this) || this; + var e = _newTarget; + var f = function () { return _newTarget; }; + return _this; + } + return B; +}(A)); +function f1() { + var _newTarget = this && this instanceof f1 ? this.constructor : void 0; + var g = _newTarget; + var h = function () { return _newTarget; }; +} +var f2 = function _b() { + var _newTarget = this && this instanceof _b ? this.constructor : void 0; + var i = _newTarget; + var j = function () { return _newTarget; }; +}; +var O = { + k: function _c() { var _newTarget = this && this instanceof _c ? this.constructor : void 0; return _newTarget; } +}; diff --git a/tests/baselines/reference/newTarget.es5.symbols b/tests/baselines/reference/newTarget.es5.symbols new file mode 100644 index 00000000000..34cdb3f34c3 --- /dev/null +++ b/tests/baselines/reference/newTarget.es5.symbols @@ -0,0 +1,63 @@ +=== tests/cases/conformance/es6/newTarget/newTarget.es5.ts === +class A { +>A : Symbol(A, Decl(newTarget.es5.ts, 0, 0)) + + constructor() { + const a = new.target; +>a : Symbol(a, Decl(newTarget.es5.ts, 2, 13)) + + const b = () => new.target; +>b : Symbol(b, Decl(newTarget.es5.ts, 3, 13)) + } + static c = function () { return new.target; } +>c : Symbol(A.c, Decl(newTarget.es5.ts, 4, 5)) + + d = function () { return new.target; } +>d : Symbol(A.d, Decl(newTarget.es5.ts, 5, 49)) +} + +class B extends A { +>B : Symbol(B, Decl(newTarget.es5.ts, 7, 1)) +>A : Symbol(A, Decl(newTarget.es5.ts, 0, 0)) + + constructor() { + super(); +>super : Symbol(A, Decl(newTarget.es5.ts, 0, 0)) + + const e = new.target; +>e : Symbol(e, Decl(newTarget.es5.ts, 12, 13)) + + const f = () => new.target; +>f : Symbol(f, Decl(newTarget.es5.ts, 13, 13)) + } +} + +function f1() { +>f1 : Symbol(f1, Decl(newTarget.es5.ts, 15, 1)) + + const g = new.target; +>g : Symbol(g, Decl(newTarget.es5.ts, 18, 9)) + + const h = () => new.target; +>h : Symbol(h, Decl(newTarget.es5.ts, 19, 9)) +} + +const f2 = function () { +>f2 : Symbol(f2, Decl(newTarget.es5.ts, 22, 5)) + + const i = new.target; +>i : Symbol(i, Decl(newTarget.es5.ts, 23, 9)) + + const j = () => new.target; +>j : Symbol(j, Decl(newTarget.es5.ts, 24, 9)) +} + +const O = { +>O : Symbol(O, Decl(newTarget.es5.ts, 27, 5)) + + k: function () { return new.target; } +>k : Symbol(k, Decl(newTarget.es5.ts, 27, 11)) + +}; + + diff --git a/tests/baselines/reference/newTarget.es5.types b/tests/baselines/reference/newTarget.es5.types new file mode 100644 index 00000000000..ddbe78537b2 --- /dev/null +++ b/tests/baselines/reference/newTarget.es5.types @@ -0,0 +1,95 @@ +=== tests/cases/conformance/es6/newTarget/newTarget.es5.ts === +class A { +>A : A + + constructor() { + const a = new.target; +>a : typeof A +>new.target : typeof A +>target : any + + const b = () => new.target; +>b : () => typeof A +>() => new.target : () => typeof A +>new.target : typeof A +>target : any + } + static c = function () { return new.target; } +>c : () => any +>function () { return new.target; } : () => any +>new.target : () => any +>target : any + + d = function () { return new.target; } +>d : () => any +>function () { return new.target; } : () => any +>new.target : () => any +>target : any +} + +class B extends A { +>B : B +>A : A + + constructor() { + super(); +>super() : void +>super : typeof A + + const e = new.target; +>e : typeof B +>new.target : typeof B +>target : any + + const f = () => new.target; +>f : () => typeof B +>() => new.target : () => typeof B +>new.target : typeof B +>target : any + } +} + +function f1() { +>f1 : () => void + + const g = new.target; +>g : () => void +>new.target : () => void +>target : any + + const h = () => new.target; +>h : () => () => void +>() => new.target : () => () => void +>new.target : () => void +>target : any +} + +const f2 = function () { +>f2 : () => void +>function () { const i = new.target; const j = () => new.target;} : () => void + + const i = new.target; +>i : () => void +>new.target : () => void +>target : any + + const j = () => new.target; +>j : () => () => void +>() => new.target : () => () => void +>new.target : () => void +>target : any +} + +const O = { +>O : { k: () => any; } +>{ k: function () { return new.target; }} : { k: () => any; } + + k: function () { return new.target; } +>k : () => any +>function () { return new.target; } : () => any +>new.target : () => any +>target : any + +}; + + diff --git a/tests/baselines/reference/newTarget.es6.js b/tests/baselines/reference/newTarget.es6.js new file mode 100644 index 00000000000..2bd95ff9f98 --- /dev/null +++ b/tests/baselines/reference/newTarget.es6.js @@ -0,0 +1,61 @@ +//// [newTarget.es6.ts] +class A { + constructor() { + const a = new.target; + const b = () => new.target; + } + static c = function () { return new.target; } + d = function () { return new.target; } +} + +class B extends A { + constructor() { + super(); + const e = new.target; + const f = () => new.target; + } +} + +function f1() { + const g = new.target; + const h = () => new.target; +} + +const f2 = function () { + const i = new.target; + const j = () => new.target; +} + +const O = { + k: function () { return new.target; } +}; + + + +//// [newTarget.es6.js] +class A { + constructor() { + this.d = function () { return new.target; }; + const a = new.target; + const b = () => new.target; + } +} +A.c = function () { return new.target; }; +class B extends A { + constructor() { + super(); + const e = new.target; + const f = () => new.target; + } +} +function f1() { + const g = new.target; + const h = () => new.target; +} +const f2 = function () { + const i = new.target; + const j = () => new.target; +}; +const O = { + k: function () { return new.target; } +}; diff --git a/tests/baselines/reference/newTarget.es6.symbols b/tests/baselines/reference/newTarget.es6.symbols new file mode 100644 index 00000000000..b20ea3dba93 --- /dev/null +++ b/tests/baselines/reference/newTarget.es6.symbols @@ -0,0 +1,63 @@ +=== tests/cases/conformance/es6/newTarget/newTarget.es6.ts === +class A { +>A : Symbol(A, Decl(newTarget.es6.ts, 0, 0)) + + constructor() { + const a = new.target; +>a : Symbol(a, Decl(newTarget.es6.ts, 2, 13)) + + const b = () => new.target; +>b : Symbol(b, Decl(newTarget.es6.ts, 3, 13)) + } + static c = function () { return new.target; } +>c : Symbol(A.c, Decl(newTarget.es6.ts, 4, 5)) + + d = function () { return new.target; } +>d : Symbol(A.d, Decl(newTarget.es6.ts, 5, 49)) +} + +class B extends A { +>B : Symbol(B, Decl(newTarget.es6.ts, 7, 1)) +>A : Symbol(A, Decl(newTarget.es6.ts, 0, 0)) + + constructor() { + super(); +>super : Symbol(A, Decl(newTarget.es6.ts, 0, 0)) + + const e = new.target; +>e : Symbol(e, Decl(newTarget.es6.ts, 12, 13)) + + const f = () => new.target; +>f : Symbol(f, Decl(newTarget.es6.ts, 13, 13)) + } +} + +function f1() { +>f1 : Symbol(f1, Decl(newTarget.es6.ts, 15, 1)) + + const g = new.target; +>g : Symbol(g, Decl(newTarget.es6.ts, 18, 9)) + + const h = () => new.target; +>h : Symbol(h, Decl(newTarget.es6.ts, 19, 9)) +} + +const f2 = function () { +>f2 : Symbol(f2, Decl(newTarget.es6.ts, 22, 5)) + + const i = new.target; +>i : Symbol(i, Decl(newTarget.es6.ts, 23, 9)) + + const j = () => new.target; +>j : Symbol(j, Decl(newTarget.es6.ts, 24, 9)) +} + +const O = { +>O : Symbol(O, Decl(newTarget.es6.ts, 27, 5)) + + k: function () { return new.target; } +>k : Symbol(k, Decl(newTarget.es6.ts, 27, 11)) + +}; + + diff --git a/tests/baselines/reference/newTarget.es6.types b/tests/baselines/reference/newTarget.es6.types new file mode 100644 index 00000000000..08ef8429b3c --- /dev/null +++ b/tests/baselines/reference/newTarget.es6.types @@ -0,0 +1,95 @@ +=== tests/cases/conformance/es6/newTarget/newTarget.es6.ts === +class A { +>A : A + + constructor() { + const a = new.target; +>a : typeof A +>new.target : typeof A +>target : any + + const b = () => new.target; +>b : () => typeof A +>() => new.target : () => typeof A +>new.target : typeof A +>target : any + } + static c = function () { return new.target; } +>c : () => any +>function () { return new.target; } : () => any +>new.target : () => any +>target : any + + d = function () { return new.target; } +>d : () => any +>function () { return new.target; } : () => any +>new.target : () => any +>target : any +} + +class B extends A { +>B : B +>A : A + + constructor() { + super(); +>super() : void +>super : typeof A + + const e = new.target; +>e : typeof B +>new.target : typeof B +>target : any + + const f = () => new.target; +>f : () => typeof B +>() => new.target : () => typeof B +>new.target : typeof B +>target : any + } +} + +function f1() { +>f1 : () => void + + const g = new.target; +>g : () => void +>new.target : () => void +>target : any + + const h = () => new.target; +>h : () => () => void +>() => new.target : () => () => void +>new.target : () => void +>target : any +} + +const f2 = function () { +>f2 : () => void +>function () { const i = new.target; const j = () => new.target;} : () => void + + const i = new.target; +>i : () => void +>new.target : () => void +>target : any + + const j = () => new.target; +>j : () => () => void +>() => new.target : () => () => void +>new.target : () => void +>target : any +} + +const O = { +>O : { k: () => any; } +>{ k: function () { return new.target; }} : { k: () => any; } + + k: function () { return new.target; } +>k : () => any +>function () { return new.target; } : () => any +>new.target : () => any +>target : any + +}; + + diff --git a/tests/baselines/reference/noEmitHelpers.js b/tests/baselines/reference/noEmitHelpers.js index fdb7cbab7d4..1a9ad2579b9 100644 --- a/tests/baselines/reference/noEmitHelpers.js +++ b/tests/baselines/reference/noEmitHelpers.js @@ -13,7 +13,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/noImplicitAnyMissingGetAccessor.js b/tests/baselines/reference/noImplicitAnyMissingGetAccessor.js index cc4c9422373..7dc7e4dafb3 100644 --- a/tests/baselines/reference/noImplicitAnyMissingGetAccessor.js +++ b/tests/baselines/reference/noImplicitAnyMissingGetAccessor.js @@ -13,11 +13,16 @@ class Child extends Parent { } //// [noImplicitAnyMissingGetAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Parent = (function () { function Parent() { } @@ -26,7 +31,7 @@ var Parent = (function () { var Child = (function (_super) { __extends(Child, _super); function Child() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Child.prototype, "message", { set: function (str) { diff --git a/tests/baselines/reference/noImplicitAnyMissingSetAccessor.js b/tests/baselines/reference/noImplicitAnyMissingSetAccessor.js index 1323955c05e..31d7e65ed9b 100644 --- a/tests/baselines/reference/noImplicitAnyMissingSetAccessor.js +++ b/tests/baselines/reference/noImplicitAnyMissingSetAccessor.js @@ -12,11 +12,16 @@ class Child extends Parent { } //// [noImplicitAnyMissingSetAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Parent = (function () { function Parent() { } @@ -25,7 +30,7 @@ var Parent = (function () { var Child = (function (_super) { __extends(Child, _super); function Child() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Child.prototype, "message", { get: function () { diff --git a/tests/baselines/reference/noImplicitUseStrict_umd.js b/tests/baselines/reference/noImplicitUseStrict_umd.js index 566c3bbe0b6..eafb8246bf7 100644 --- a/tests/baselines/reference/noImplicitUseStrict_umd.js +++ b/tests/baselines/reference/noImplicitUseStrict_umd.js @@ -3,13 +3,14 @@ export var x = 0; //// [noImplicitUseStrict_umd.js] -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { exports.x = 0; }); diff --git a/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.js b/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.js index b0a3365193d..c088787717c 100644 --- a/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.js +++ b/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.js @@ -6,11 +6,16 @@ class Foo { class Bar extends Foo { } // Valid //// [nonGenericClassExtendingGenericClassWithAny.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -19,7 +24,7 @@ var Foo = (function () { var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar; }(Foo)); // Valid diff --git a/tests/baselines/reference/nonPrimitiveAccessProperty.errors.txt b/tests/baselines/reference/nonPrimitiveAccessProperty.errors.txt new file mode 100644 index 00000000000..8ef94c64448 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAccessProperty.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts(3,3): error TS2339: Property 'nonExist' does not exist on type 'object'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts (1 errors) ==== + var a: object; + a.toString(); + a.nonExist(); // error + ~~~~~~~~ +!!! error TS2339: Property 'nonExist' does not exist on type 'object'. + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveAccessProperty.js b/tests/baselines/reference/nonPrimitiveAccessProperty.js new file mode 100644 index 00000000000..a71b2aba865 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAccessProperty.js @@ -0,0 +1,10 @@ +//// [nonPrimitiveAccessProperty.ts] +var a: object; +a.toString(); +a.nonExist(); // error + + +//// [nonPrimitiveAccessProperty.js] +var a; +a.toString(); +a.nonExist(); // error diff --git a/tests/baselines/reference/nonPrimitiveAsProperty.errors.txt b/tests/baselines/reference/nonPrimitiveAsProperty.errors.txt new file mode 100644 index 00000000000..8d4042c92f0 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAsProperty.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAsProperty.ts(7,5): error TS2322: Type '{ foo: string; }' is not assignable to type 'WithNonPrimitive'. + Types of property 'foo' are incompatible. + Type 'string' is not assignable to type 'object'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAsProperty.ts (1 errors) ==== + interface WithNonPrimitive { + foo: object + } + + var a: WithNonPrimitive = { foo: {bar: "bar"} }; + + var b: WithNonPrimitive = {foo: "bar"}; // expect error + ~ +!!! error TS2322: Type '{ foo: string; }' is not assignable to type 'WithNonPrimitive'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'object'. + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveAsProperty.js b/tests/baselines/reference/nonPrimitiveAsProperty.js new file mode 100644 index 00000000000..d3e1b072a06 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAsProperty.js @@ -0,0 +1,21 @@ +//// [nonPrimitiveAsProperty.ts] +interface WithNonPrimitive { + foo: object +} + +var a: WithNonPrimitive = { foo: {bar: "bar"} }; + +var b: WithNonPrimitive = {foo: "bar"}; // expect error + + +//// [nonPrimitiveAsProperty.js] +var a = { foo: { bar: "bar" } }; +var b = { foo: "bar" }; // expect error + + +//// [nonPrimitiveAsProperty.d.ts] +interface WithNonPrimitive { + foo: object; +} +declare var a: WithNonPrimitive; +declare var b: WithNonPrimitive; diff --git a/tests/baselines/reference/nonPrimitiveAssignError.errors.txt b/tests/baselines/reference/nonPrimitiveAssignError.errors.txt new file mode 100644 index 00000000000..a9bfaaa4a8a --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAssignError.errors.txt @@ -0,0 +1,54 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(5,1): error TS2322: Type 'object' is not assignable to type '{ foo: string; }'. + Property 'foo' is missing in type 'Object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(13,1): error TS2322: Type 'number' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(14,1): error TS2322: Type 'true' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(15,1): error TS2322: Type 'string' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(17,1): error TS2322: Type 'object' is not assignable to type 'number'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(18,1): error TS2322: Type 'object' is not assignable to type 'boolean'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(19,1): error TS2322: Type 'object' is not assignable to type 'string'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts (7 errors) ==== + var x = {}; + var y = {foo: "bar"}; + var a: object; + x = a; + y = a; // expect error + ~ +!!! error TS2322: Type 'object' is not assignable to type '{ foo: string; }'. +!!! error TS2322: Property 'foo' is missing in type 'Object'. + a = x; + a = y; + + var n = 123; + var b = true; + var s = "fooo"; + + a = n; // expect error + ~ +!!! error TS2322: Type 'number' is not assignable to type 'object'. + a = b; // expect error + ~ +!!! error TS2322: Type 'true' is not assignable to type 'object'. + a = s; // expect error + ~ +!!! error TS2322: Type 'string' is not assignable to type 'object'. + + n = a; // expect error + ~ +!!! error TS2322: Type 'object' is not assignable to type 'number'. + b = a; // expect error + ~ +!!! error TS2322: Type 'object' is not assignable to type 'boolean'. + s = a; // expect error + ~ +!!! error TS2322: Type 'object' is not assignable to type 'string'. + + var numObj: Number = 123; + var boolObj: Boolean = true; + var strObj: String = "string"; + + a = numObj; // ok + a = boolObj; // ok + a = strObj; // ok + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveAssignError.js b/tests/baselines/reference/nonPrimitiveAssignError.js new file mode 100644 index 00000000000..c37836a91c6 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAssignError.js @@ -0,0 +1,53 @@ +//// [nonPrimitiveAssignError.ts] +var x = {}; +var y = {foo: "bar"}; +var a: object; +x = a; +y = a; // expect error +a = x; +a = y; + +var n = 123; +var b = true; +var s = "fooo"; + +a = n; // expect error +a = b; // expect error +a = s; // expect error + +n = a; // expect error +b = a; // expect error +s = a; // expect error + +var numObj: Number = 123; +var boolObj: Boolean = true; +var strObj: String = "string"; + +a = numObj; // ok +a = boolObj; // ok +a = strObj; // ok + + +//// [nonPrimitiveAssignError.js] +var x = {}; +var y = { foo: "bar" }; +var a; +x = a; +y = a; // expect error +a = x; +a = y; +var n = 123; +var b = true; +var s = "fooo"; +a = n; // expect error +a = b; // expect error +a = s; // expect error +n = a; // expect error +b = a; // expect error +s = a; // expect error +var numObj = 123; +var boolObj = true; +var strObj = "string"; +a = numObj; // ok +a = boolObj; // ok +a = strObj; // ok diff --git a/tests/baselines/reference/nonPrimitiveInFunction.errors.txt b/tests/baselines/reference/nonPrimitiveInFunction.errors.txt new file mode 100644 index 00000000000..c7f89fbdd06 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveInFunction.errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts(12,12): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts(13,1): error TS2322: Type 'object' is not assignable to type 'boolean'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts(17,5): error TS2322: Type 'number' is not assignable to type 'object'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts (3 errors) ==== + function takeObject(o: object) {} + function returnObject(): object { + return {}; + } + + var nonPrimitive: object; + var primitive: boolean; + + takeObject(nonPrimitive); + nonPrimitive = returnObject(); + + takeObject(primitive); // expect error + ~~~~~~~~~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'object'. + primitive = returnObject(); // expect error + ~~~~~~~~~ +!!! error TS2322: Type 'object' is not assignable to type 'boolean'. + + function returnError(): object { + var ret = 123; + return ret; // expect error + ~~~~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'object'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveInFunction.js b/tests/baselines/reference/nonPrimitiveInFunction.js new file mode 100644 index 00000000000..1d2a2462502 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveInFunction.js @@ -0,0 +1,44 @@ +//// [nonPrimitiveInFunction.ts] +function takeObject(o: object) {} +function returnObject(): object { + return {}; +} + +var nonPrimitive: object; +var primitive: boolean; + +takeObject(nonPrimitive); +nonPrimitive = returnObject(); + +takeObject(primitive); // expect error +primitive = returnObject(); // expect error + +function returnError(): object { + var ret = 123; + return ret; // expect error +} + + +//// [nonPrimitiveInFunction.js] +function takeObject(o) { } +function returnObject() { + return {}; +} +var nonPrimitive; +var primitive; +takeObject(nonPrimitive); +nonPrimitive = returnObject(); +takeObject(primitive); // expect error +primitive = returnObject(); // expect error +function returnError() { + var ret = 123; + return ret; // expect error +} + + +//// [nonPrimitiveInFunction.d.ts] +declare function takeObject(o: object): void; +declare function returnObject(): object; +declare var nonPrimitive: object; +declare var primitive: boolean; +declare function returnError(): object; diff --git a/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt b/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt new file mode 100644 index 00000000000..ce257c87680 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt @@ -0,0 +1,71 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(2,9): error TS2322: Type 'T' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(9,17): error TS2345: Argument of type '123' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(10,17): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(18,7): error TS2345: Argument of type '123' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(19,7): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(25,8): error TS2344: Type 'number' does not satisfy the constraint 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(26,8): error TS2344: Type 'string' does not satisfy the constraint 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(34,14): error TS2344: Type 'number' does not satisfy the constraint 'object'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts (8 errors) ==== + function generic(t: T) { + var o: object = t; // expect error + ~ +!!! error TS2322: Type 'T' is not assignable to type 'object'. + } + var a = {}; + var b = "42"; + + generic({}); + generic(a); + generic(123); // expect error + ~~~ +!!! error TS2345: Argument of type '123' is not assignable to parameter of type 'object'. + generic(b); // expect error + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. + + function bound(t: T) { + var o: object = t; // ok + } + + bound({}); + bound(a); + bound(123); // expect error + ~~~ +!!! error TS2345: Argument of type '123' is not assignable to parameter of type 'object'. + bound(b); // expect error + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. + + function bound2() {} + + bound2<{}>(); + bound2(); + bound2(); // expect error + ~~~~~~ +!!! error TS2344: Type 'number' does not satisfy the constraint 'object'. + bound2(); // expect error + ~~~~~~ +!!! error TS2344: Type 'string' does not satisfy the constraint 'object'. + + function bound3(t: T) { + var o: object = t; // ok + } + + interface Proxy {} + + var x: Proxy; // error + ~~~~~~ +!!! error TS2344: Type 'number' does not satisfy the constraint 'object'. + var y: Proxy; // ok + var z: Proxy ; // ok + + + interface Blah { + foo: number; + } + + var u: Proxy; // ok + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveInGeneric.js b/tests/baselines/reference/nonPrimitiveInGeneric.js new file mode 100644 index 00000000000..d7e013c71f1 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveInGeneric.js @@ -0,0 +1,93 @@ +//// [nonPrimitiveInGeneric.ts] +function generic(t: T) { + var o: object = t; // expect error +} +var a = {}; +var b = "42"; + +generic({}); +generic(a); +generic(123); // expect error +generic(b); // expect error + +function bound(t: T) { + var o: object = t; // ok +} + +bound({}); +bound(a); +bound(123); // expect error +bound(b); // expect error + +function bound2() {} + +bound2<{}>(); +bound2(); +bound2(); // expect error +bound2(); // expect error + +function bound3(t: T) { + var o: object = t; // ok +} + +interface Proxy {} + +var x: Proxy; // error +var y: Proxy; // ok +var z: Proxy ; // ok + + +interface Blah { + foo: number; +} + +var u: Proxy; // ok + + +//// [nonPrimitiveInGeneric.js] +function generic(t) { + var o = t; // expect error +} +var a = {}; +var b = "42"; +generic({}); +generic(a); +generic(123); // expect error +generic(b); // expect error +function bound(t) { + var o = t; // ok +} +bound({}); +bound(a); +bound(123); // expect error +bound(b); // expect error +function bound2() { } +bound2(); +bound2(); +bound2(); // expect error +bound2(); // expect error +function bound3(t) { + var o = t; // ok +} +var x; // error +var y; // ok +var z; // ok +var u; // ok + + +//// [nonPrimitiveInGeneric.d.ts] +declare function generic(t: T): void; +declare var a: {}; +declare var b: string; +declare function bound(t: T): void; +declare function bound2(): void; +declare function bound3(t: T): void; +interface Proxy { +} +declare var x: Proxy; +declare var y: Proxy; +declare var z: Proxy; +interface Blah { + foo: number; +} +declare var u: Proxy; diff --git a/tests/baselines/reference/nonPrimitiveNarrow.errors.txt b/tests/baselines/reference/nonPrimitiveNarrow.errors.txt new file mode 100644 index 00000000000..1b3cf55b4b2 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveNarrow.errors.txt @@ -0,0 +1,35 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts(9,5): error TS2322: Type '123' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts(13,7): error TS2339: Property 'toFixed' does not exist on type 'never'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts(21,6): error TS2339: Property 'toString' does not exist on type 'never'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts (3 errors) ==== + class Narrow { + narrowed: boolean + } + + var a: object + + if (a instanceof Narrow) { + a.narrowed; // ok + a = 123; // error + ~ +!!! error TS2322: Type '123' is not assignable to type 'object'. + } + + if (typeof a === 'number') { + a.toFixed(); // error, never + ~~~~~~~ +!!! error TS2339: Property 'toFixed' does not exist on type 'never'. + } + + var b: object | null + + if (typeof b === 'object') { + b.toString(); // ok, object | null + } else { + b.toString(); // error, never + ~~~~~~~~ +!!! error TS2339: Property 'toString' does not exist on type 'never'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveNarrow.js b/tests/baselines/reference/nonPrimitiveNarrow.js new file mode 100644 index 00000000000..607206eecfc --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveNarrow.js @@ -0,0 +1,46 @@ +//// [nonPrimitiveNarrow.ts] +class Narrow { + narrowed: boolean +} + +var a: object + +if (a instanceof Narrow) { + a.narrowed; // ok + a = 123; // error +} + +if (typeof a === 'number') { + a.toFixed(); // error, never +} + +var b: object | null + +if (typeof b === 'object') { + b.toString(); // ok, object | null +} else { + b.toString(); // error, never +} + + +//// [nonPrimitiveNarrow.js] +var Narrow = (function () { + function Narrow() { + } + return Narrow; +}()); +var a; +if (a instanceof Narrow) { + a.narrowed; // ok + a = 123; // error +} +if (typeof a === 'number') { + a.toFixed(); // error, never +} +var b; +if (typeof b === 'object') { + b.toString(); // ok, object | null +} +else { + b.toString(); // error, never +} diff --git a/tests/baselines/reference/nonPrimitiveStrictNull.errors.txt b/tests/baselines/reference/nonPrimitiveStrictNull.errors.txt new file mode 100644 index 00000000000..473011aaa7f --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveStrictNull.errors.txt @@ -0,0 +1,126 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(7,1): error TS2454: Variable 'a' is used before being assigned. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(8,1): error TS2322: Type 'undefined' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(9,1): error TS2322: Type 'null' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(10,1): error TS2322: Type 'object | null' is not assignable to type 'object'. + Type 'null' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(11,1): error TS2322: Type 'object | undefined' is not assignable to type 'object'. + Type 'undefined' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(12,1): error TS2322: Type 'object | null | undefined' is not assignable to type 'object'. + Type 'undefined' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(18,7): error TS2339: Property 'toString' does not exist on type 'never'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(22,5): error TS2322: Type 'object | null' is not assignable to type 'object'. + Type 'null' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(27,5): error TS2531: Object is possibly 'null'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(29,5): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(33,5): error TS2533: Object is possibly 'null' or 'undefined'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(39,5): error TS2531: Object is possibly 'null'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(41,5): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(45,5): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(47,5): error TS2531: Object is possibly 'null'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(52,14): error TS2344: Type 'number' does not satisfy the constraint 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(53,14): error TS2344: Type 'null' does not satisfy the constraint 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(54,14): error TS2344: Type 'undefined' does not satisfy the constraint 'object'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts (18 errors) ==== + + var a: object + declare var b: object | null + declare var c: object | undefined + declare var d: object | null | undefined + var e: object | null + a.toString; // error + ~ +!!! error TS2454: Variable 'a' is used before being assigned. + a = undefined; // error + ~ +!!! error TS2322: Type 'undefined' is not assignable to type 'object'. + a = null; // error + ~ +!!! error TS2322: Type 'null' is not assignable to type 'object'. + a = b; // error + ~ +!!! error TS2322: Type 'object | null' is not assignable to type 'object'. +!!! error TS2322: Type 'null' is not assignable to type 'object'. + a = c; // error + ~ +!!! error TS2322: Type 'object | undefined' is not assignable to type 'object'. +!!! error TS2322: Type 'undefined' is not assignable to type 'object'. + a = d; // error + ~ +!!! error TS2322: Type 'object | null | undefined' is not assignable to type 'object'. +!!! error TS2322: Type 'undefined' is not assignable to type 'object'. + + e = a; // ok + a = e; // ok + + if (typeof b !== 'object') { + b.toString(); // error, never + ~~~~~~~~ +!!! error TS2339: Property 'toString' does not exist on type 'never'. + } + + if (typeof b === 'object') { + a = b; // error, b is not narrowed + ~ +!!! error TS2322: Type 'object | null' is not assignable to type 'object'. +!!! error TS2322: Type 'null' is not assignable to type 'object'. + } + + if (typeof d === 'object') { + b = d; // ok + d.toString(); // error, object | null + ~ +!!! error TS2531: Object is possibly 'null'. + } else { + d.toString(); // error, undefined + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + + if (d == null) { + d.toString(); // error, undefined | null + ~ +!!! error TS2533: Object is possibly 'null' or 'undefined'. + } else { + d.toString(); // object + } + + if (d === null) { + d.toString(); // error, null + ~ +!!! error TS2531: Object is possibly 'null'. + } else { + d.toString(); // error, object | undefined + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + + if (typeof d === 'undefined') { + d.toString(); // error, undefined + ~ +!!! error TS2532: Object is possibly 'undefined'. + } else { + d.toString(); // error, object | null + ~ +!!! error TS2531: Object is possibly 'null'. + } + + interface Proxy {} + + var x: Proxy; // error + ~~~~~~ +!!! error TS2344: Type 'number' does not satisfy the constraint 'object'. + var y: Proxy; // error + ~~~~ +!!! error TS2344: Type 'null' does not satisfy the constraint 'object'. + var z: Proxy; // error + ~~~~~~~~~ +!!! error TS2344: Type 'undefined' does not satisfy the constraint 'object'. + + interface Blah { + foo: number; + } + + var u: Proxy; // ok + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveStrictNull.js b/tests/baselines/reference/nonPrimitiveStrictNull.js new file mode 100644 index 00000000000..754ca8cac7d --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveStrictNull.js @@ -0,0 +1,109 @@ +//// [nonPrimitiveStrictNull.ts] + +var a: object +declare var b: object | null +declare var c: object | undefined +declare var d: object | null | undefined +var e: object | null +a.toString; // error +a = undefined; // error +a = null; // error +a = b; // error +a = c; // error +a = d; // error + +e = a; // ok +a = e; // ok + +if (typeof b !== 'object') { + b.toString(); // error, never +} + +if (typeof b === 'object') { + a = b; // error, b is not narrowed +} + +if (typeof d === 'object') { + b = d; // ok + d.toString(); // error, object | null +} else { + d.toString(); // error, undefined +} + +if (d == null) { + d.toString(); // error, undefined | null +} else { + d.toString(); // object +} + +if (d === null) { + d.toString(); // error, null +} else { + d.toString(); // error, object | undefined +} + +if (typeof d === 'undefined') { + d.toString(); // error, undefined +} else { + d.toString(); // error, object | null +} + +interface Proxy {} + +var x: Proxy; // error +var y: Proxy; // error +var z: Proxy; // error + +interface Blah { + foo: number; +} + +var u: Proxy; // ok + + +//// [nonPrimitiveStrictNull.js] +var a; +var e; +a.toString; // error +a = undefined; // error +a = null; // error +a = b; // error +a = c; // error +a = d; // error +e = a; // ok +a = e; // ok +if (typeof b !== 'object') { + b.toString(); // error, never +} +if (typeof b === 'object') { + a = b; // error, b is not narrowed +} +if (typeof d === 'object') { + b = d; // ok + d.toString(); // error, object | null +} +else { + d.toString(); // error, undefined +} +if (d == null) { + d.toString(); // error, undefined | null +} +else { + d.toString(); // object +} +if (d === null) { + d.toString(); // error, null +} +else { + d.toString(); // error, object | undefined +} +if (typeof d === 'undefined') { + d.toString(); // error, undefined +} +else { + d.toString(); // error, object | null +} +var x; // error +var y; // error +var z; // error +var u; // ok diff --git a/tests/baselines/reference/nonPrimitiveUnionIntersection.errors.txt b/tests/baselines/reference/nonPrimitiveUnionIntersection.errors.txt new file mode 100644 index 00000000000..5fb1e89c2e3 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveUnionIntersection.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts(1,5): error TS2322: Type '""' is not assignable to type 'object & string'. + Type '""' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts(3,1): error TS2322: Type 'string' is not assignable to type 'object & string'. + Type 'string' is not assignable to type 'object'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts (2 errors) ==== + var a: object & string = ""; // error + ~ +!!! error TS2322: Type '""' is not assignable to type 'object & string'. +!!! error TS2322: Type '""' is not assignable to type 'object'. + var b: object | string = ""; // ok + a = b; // error + ~ +!!! error TS2322: Type 'string' is not assignable to type 'object & string'. +!!! error TS2322: Type 'string' is not assignable to type 'object'. + b = a; // ok + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveUnionIntersection.js b/tests/baselines/reference/nonPrimitiveUnionIntersection.js new file mode 100644 index 00000000000..7f4b46c42ed --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveUnionIntersection.js @@ -0,0 +1,17 @@ +//// [nonPrimitiveUnionIntersection.ts] +var a: object & string = ""; // error +var b: object | string = ""; // ok +a = b; // error +b = a; // ok + + +//// [nonPrimitiveUnionIntersection.js] +var a = ""; // error +var b = ""; // ok +a = b; // error +b = a; // ok + + +//// [nonPrimitiveUnionIntersection.d.ts] +declare var a: object & string; +declare var b: object | string; diff --git a/tests/baselines/reference/null.errors.txt b/tests/baselines/reference/null.errors.txt new file mode 100644 index 00000000000..f957507438c --- /dev/null +++ b/tests/baselines/reference/null.errors.txt @@ -0,0 +1,28 @@ +tests/cases/compiler/null.ts(4,9): error TS2531: Object is possibly 'null'. + + +==== tests/cases/compiler/null.ts (1 errors) ==== + + var x=null; + var y=3+x; + var z=3+null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + class C { + } + function f() { + return null; + return new C(); + } + function g() { + return null; + return 3; + } + interface I { + x:any; + y:number; + } + var w:I={x:null,y:3}; + + + \ No newline at end of file diff --git a/tests/baselines/reference/nullKeyword.errors.txt b/tests/baselines/reference/nullKeyword.errors.txt index a140fce0b0f..b815b61b676 100644 --- a/tests/baselines/reference/nullKeyword.errors.txt +++ b/tests/baselines/reference/nullKeyword.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/nullKeyword.ts(1,6): error TS2339: Property 'foo' does not exist on type 'null'. +tests/cases/compiler/nullKeyword.ts(1,1): error TS2531: Object is possibly 'null'. ==== tests/cases/compiler/nullKeyword.ts (1 errors) ==== null.foo; - ~~~ -!!! error TS2339: Property 'foo' does not exist on type 'null'. \ No newline at end of file + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/numberToString.errors.txt b/tests/baselines/reference/numberToString.errors.txt index 60a382e47c3..bbd9178862a 100644 --- a/tests/baselines/reference/numberToString.errors.txt +++ b/tests/baselines/reference/numberToString.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/numberToString.ts(2,12): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/numberToString.ts(2,5): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/compiler/numberToString.ts(9,4): error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/numberToString.ts (2 errors) ==== function f1(n:number):string { return n; // error return type mismatch - ~ + ~~~~~~~~~ !!! error TS2322: Type 'number' is not assignable to type 'string'. } diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt index ec0f330f1a3..f532bd23755 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(36,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(50,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(68,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(79,5): error TS2322: Type '{ 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(79,5): error TS2322: Type '{ a: string; b: number; c: () => void; "d": string; "e": number; 1.0: string; 2.0: number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'. Object literal may only specify known properties, and 'a' does not exist in type '{ [x: number]: string; }'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(88,9): error TS2304: Cannot find name 'Myn'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -107,7 +107,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo var b: { [x: number]: string; } = { a: '', ~~~~~ -!!! error TS2322: Type '{ 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'. +!!! error TS2322: Type '{ a: string; b: number; c: () => void; "d": string; "e": number; 1.0: string; 2.0: number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'. !!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ [x: number]: string; }'. b: 1, c: () => { }, diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt index e6d22ff0712..74cd032c40e 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(16,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(25,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(34,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(44,5): error TS2322: Type '{ 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(44,5): error TS2322: Type '{ 1.0: A; 2.0: B; "2.5": B; 3.0: number; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. Object literal may only specify known properties, and '"4.0"' does not exist in type '{ [x: number]: A; }'. @@ -57,6 +57,6 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo 3.0: 1, "4.0": '' ~~~~~~~~~ -!!! error TS2322: Type '{ 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. +!!! error TS2322: Type '{ 1.0: A; 2.0: B; "2.5": B; 3.0: number; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. !!! error TS2322: Object literal may only specify known properties, and '"4.0"' does not exist in type '{ [x: number]: A; }'. } \ No newline at end of file diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.js b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.js index 92c8b380e00..9e501b5d92c 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.js +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.js @@ -47,11 +47,16 @@ var b: { [x: number]: A } = { //// [numericIndexerConstrainsPropertyDeclarations2.js] // String indexer providing a constraint of a user defined 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -61,7 +66,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { return ''; }; return B; diff --git a/tests/baselines/reference/numericIndexerConstraint3.js b/tests/baselines/reference/numericIndexerConstraint3.js index 29cb75b4234..9e733e593fd 100644 --- a/tests/baselines/reference/numericIndexerConstraint3.js +++ b/tests/baselines/reference/numericIndexerConstraint3.js @@ -13,11 +13,16 @@ class C { } //// [numericIndexerConstraint3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -26,7 +31,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/numericIndexerConstraint4.js b/tests/baselines/reference/numericIndexerConstraint4.js index 135e169c4a9..4546db0b8a4 100644 --- a/tests/baselines/reference/numericIndexerConstraint4.js +++ b/tests/baselines/reference/numericIndexerConstraint4.js @@ -13,11 +13,16 @@ var x: { //// [numericIndexerConstraint4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -26,7 +31,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/numericIndexerConstraint5.errors.txt b/tests/baselines/reference/numericIndexerConstraint5.errors.txt index cb888de08c4..04b7e0dc337 100644 --- a/tests/baselines/reference/numericIndexerConstraint5.errors.txt +++ b/tests/baselines/reference/numericIndexerConstraint5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/numericIndexerConstraint5.ts(2,5): error TS2322: Type '{ 0: Date; name: string; }' is not assignable to type '{ [name: number]: string; }'. +tests/cases/compiler/numericIndexerConstraint5.ts(2,5): error TS2322: Type '{ name: string; 0: Date; }' is not assignable to type '{ [name: number]: string; }'. Property '0' is incompatible with index signature. Type 'Date' is not assignable to type 'string'. @@ -7,6 +7,6 @@ tests/cases/compiler/numericIndexerConstraint5.ts(2,5): error TS2322: Type '{ 0: var x = { name: "x", 0: new Date() }; var z: { [name: number]: string } = x; ~ -!!! error TS2322: Type '{ 0: Date; name: string; }' is not assignable to type '{ [name: number]: string; }'. +!!! error TS2322: Type '{ name: string; 0: Date; }' is not assignable to type '{ [name: number]: string; }'. !!! error TS2322: Property '0' is incompatible with index signature. !!! error TS2322: Type 'Date' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/numericIndexerTyping2.js b/tests/baselines/reference/numericIndexerTyping2.js index 5b9e797bdec..8bcc5ac61c4 100644 --- a/tests/baselines/reference/numericIndexerTyping2.js +++ b/tests/baselines/reference/numericIndexerTyping2.js @@ -13,11 +13,16 @@ var i2: I2; var r2: string = i2[1]; // error: numeric indexer returns the type of the string indexere //// [numericIndexerTyping2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var I = (function () { function I() { } @@ -26,7 +31,7 @@ var I = (function () { var I2 = (function (_super) { __extends(I2, _super); function I2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return I2; }(I)); diff --git a/tests/baselines/reference/objectCreationOfElementAccessExpression.js b/tests/baselines/reference/objectCreationOfElementAccessExpression.js index a1739ce0d8e..72645662e01 100644 --- a/tests/baselines/reference/objectCreationOfElementAccessExpression.js +++ b/tests/baselines/reference/objectCreationOfElementAccessExpression.js @@ -56,11 +56,16 @@ var foods2: MonsterFood[] = new PetFood[new IceCream('Mint chocolate chip') , Co //// [objectCreationOfElementAccessExpression.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Food = (function () { function Food(name) { this.name = name; diff --git a/tests/baselines/reference/objectLiteralErrors.errors.txt b/tests/baselines/reference/objectLiteralErrors.errors.txt index 03b4b74eacd..0e0db0b414f 100644 --- a/tests/baselines/reference/objectLiteralErrors.errors.txt +++ b/tests/baselines/reference/objectLiteralErrors.errors.txt @@ -73,7 +73,7 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(40,46) tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(40,46): error TS2300: Duplicate identifier 'a'. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(43,16): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(43,47): error TS2380: 'get' and 'set' accessor must have the same type. -tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(44,29): error TS2322: Type '4' is not assignable to type 'string'. +tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(44,22): error TS2322: Type '4' is not assignable to type 'string'. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,16): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,55): error TS2380: 'get' and 'set' accessor must have the same type. @@ -273,7 +273,7 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,55) ~ !!! error TS2380: 'get' and 'set' accessor must have the same type. var g2 = { get a() { return 4; }, set a(n: string) { } }; - ~ + ~~~~~~~~~ !!! error TS2322: Type '4' is not assignable to type 'string'. var g3 = { get a(): number { return undefined; }, set a(n: string) { } }; ~ diff --git a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt index 9d5ff7ea0a2..53abb5b7658 100644 --- a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt +++ b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ x: B; 0: A; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. Property '0' is incompatible with index signature. Type 'A' is not assignable to type 'B'. Property 'y' is missing in type 'A'. -tests/cases/compiler/objectLiteralIndexerErrors.ts(14,1): error TS2322: Type '{ 0: A; x: any; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +tests/cases/compiler/objectLiteralIndexerErrors.ts(14,1): error TS2322: Type '{ x: any; 0: A; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. Property '0' is incompatible with index signature. Type 'A' is not assignable to type 'B'. @@ -22,12 +22,12 @@ tests/cases/compiler/objectLiteralIndexerErrors.ts(14,1): error TS2322: Type '{ var o1: { [s: string]: A;[n: number]: B; } = { x: b, 0: a }; // both indexers are A ~~ -!!! error TS2322: Type '{ 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +!!! error TS2322: Type '{ x: B; 0: A; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. !!! error TS2322: Property '0' is incompatible with index signature. !!! error TS2322: Type 'A' is not assignable to type 'B'. !!! error TS2322: Property 'y' is missing in type 'A'. o1 = { x: c, 0: a }; // string indexer is any, number indexer is A ~~ -!!! error TS2322: Type '{ 0: A; x: any; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +!!! error TS2322: Type '{ x: any; 0: A; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. !!! error TS2322: Property '0' is incompatible with index signature. !!! error TS2322: Type 'A' is not assignable to type 'B'. \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralIndexers.types b/tests/baselines/reference/objectLiteralIndexers.types index 9e3aa4bac49..ef242fd1fe3 100644 --- a/tests/baselines/reference/objectLiteralIndexers.types +++ b/tests/baselines/reference/objectLiteralIndexers.types @@ -31,23 +31,23 @@ var o1: { [s: string]: A;[n: number]: B; } = { x: a, 0: b }; // string indexer i >A : A >n : number >B : B ->{ x: a, 0: b } : { 0: B; x: A; } +>{ x: a, 0: b } : { x: A; 0: B; } >x : A >a : A >b : B o1 = { x: b, 0: c }; // both indexers are any ->o1 = { x: b, 0: c } : { 0: any; x: B; } +>o1 = { x: b, 0: c } : { x: B; 0: any; } >o1 : { [s: string]: A; [n: number]: B; } ->{ x: b, 0: c } : { 0: any; x: B; } +>{ x: b, 0: c } : { x: B; 0: any; } >x : B >b : B >c : any o1 = { x: c, 0: b }; // string indexer is any, number indexer is B ->o1 = { x: c, 0: b } : { 0: B; x: any; } +>o1 = { x: c, 0: b } : { x: any; 0: B; } >o1 : { [s: string]: A; [n: number]: B; } ->{ x: c, 0: b } : { 0: B; x: any; } +>{ x: c, 0: b } : { x: any; 0: B; } >x : any >c : any >b : B diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt index 6f405facceb..c0e6e10d8de 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(4,43): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,72): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'. Types of property 'id' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(8,5): error TS2345: Argument of type '{ name: string; id: number; }' is not assignable to parameter of type '{ name: string; id: boolean; }'. @@ -18,7 +18,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. var person1: { name, id }; // ok function foo(name: string, id: number): { id: string, name: number } { return { name, id }; } // error - ~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'. !!! error TS2322: Types of property 'id' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt index 92750fd29a0..6b227fce710 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(4,43): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(5,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(5,72): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'. Types of property 'name' are incompatible. Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(8,5): error TS2322: Type '{ name: number; id: string; }' is not assignable to type '{ name: string; id: number; }'. @@ -17,7 +17,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. function bar(name: string, id: number): { name: number, id: string } { return { name, id }; } // error - ~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'. !!! error TS2322: Types of property 'name' are incompatible. !!! error TS2322: Type 'string' is not assignable to type 'number'. diff --git a/tests/baselines/reference/objectRest.js b/tests/baselines/reference/objectRest.js index 48a1bf8daf8..59eb11542c0 100644 --- a/tests/baselines/reference/objectRest.js +++ b/tests/baselines/reference/objectRest.js @@ -29,8 +29,15 @@ class Removable { removed: string; remainder: string; } +interface I { + m(): void; + removed: string; + remainder: string; +} var removable = new Removable(); var { removed, ...removableRest } = removable; +var i: I = removable; +var { removed, ...removableRest2 } = i; let computed = 'b'; let computed2 = 'a'; @@ -74,6 +81,8 @@ class Removable { } var removable = new Removable(); var { removed } = removable, removableRest = __rest(removable, ["removed"]); +var i = removable; +var { removed } = i, removableRest2 = __rest(i, ["removed"]); let computed = 'b'; let computed2 = 'a'; var _g = computed, stillNotGreat = o[_g], _h = computed2, soSo = o[_h], o = __rest(o, [typeof _g === "symbol" ? _g : _g + "", typeof _h === "symbol" ? _h : _h + ""]); diff --git a/tests/baselines/reference/objectRest.symbols b/tests/baselines/reference/objectRest.symbols index 46309392135..2992220d8b2 100644 --- a/tests/baselines/reference/objectRest.symbols +++ b/tests/baselines/reference/objectRest.symbols @@ -1,42 +1,42 @@ === tests/cases/conformance/types/rest/objectRest.ts === var o = { a: 1, b: 'no' } ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) >a : Symbol(a, Decl(objectRest.ts, 0, 9)) >b : Symbol(b, Decl(objectRest.ts, 0, 15)) var { ...clone } = o; >clone : Symbol(clone, Decl(objectRest.ts, 1, 5)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) var { a, ...justB } = o; >a : Symbol(a, Decl(objectRest.ts, 2, 5), Decl(objectRest.ts, 3, 5)) >justB : Symbol(justB, Decl(objectRest.ts, 2, 8)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) var { a, b: renamed, ...empty } = o; >a : Symbol(a, Decl(objectRest.ts, 2, 5), Decl(objectRest.ts, 3, 5)) >b : Symbol(b, Decl(objectRest.ts, 0, 15)) >renamed : Symbol(renamed, Decl(objectRest.ts, 3, 8), Decl(objectRest.ts, 4, 5), Decl(objectRest.ts, 5, 5), Decl(objectRest.ts, 9, 5)) >empty : Symbol(empty, Decl(objectRest.ts, 3, 20)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) var { ['b']: renamed, ...justA } = o; >'b' : Symbol(renamed, Decl(objectRest.ts, 3, 8), Decl(objectRest.ts, 4, 5), Decl(objectRest.ts, 5, 5), Decl(objectRest.ts, 9, 5)) >renamed : Symbol(renamed, Decl(objectRest.ts, 3, 8), Decl(objectRest.ts, 4, 5), Decl(objectRest.ts, 5, 5), Decl(objectRest.ts, 9, 5)) >justA : Symbol(justA, Decl(objectRest.ts, 4, 21), Decl(objectRest.ts, 5, 19), Decl(objectRest.ts, 6, 31)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) var { 'b': renamed, ...justA } = o; >renamed : Symbol(renamed, Decl(objectRest.ts, 3, 8), Decl(objectRest.ts, 4, 5), Decl(objectRest.ts, 5, 5), Decl(objectRest.ts, 9, 5)) >justA : Symbol(justA, Decl(objectRest.ts, 4, 21), Decl(objectRest.ts, 5, 19), Decl(objectRest.ts, 6, 31)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) var { b: { '0': n, '1': oooo }, ...justA } = o; >b : Symbol(b, Decl(objectRest.ts, 0, 15)) >n : Symbol(n, Decl(objectRest.ts, 6, 10)) >oooo : Symbol(oooo, Decl(objectRest.ts, 6, 18)) >justA : Symbol(justA, Decl(objectRest.ts, 4, 21), Decl(objectRest.ts, 5, 19), Decl(objectRest.ts, 6, 31)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) let o2 = { c: 'terrible idea?', d: 'yes' }; >o2 : Symbol(o2, Decl(objectRest.ts, 8, 3)) @@ -138,41 +138,63 @@ class Removable { remainder: string; >remainder : Symbol(Removable.remainder, Decl(objectRest.ts, 27, 20)) } +interface I { +>I : Symbol(I, Decl(objectRest.ts, 29, 1)) + + m(): void; +>m : Symbol(I.m, Decl(objectRest.ts, 30, 13)) + + removed: string; +>removed : Symbol(I.removed, Decl(objectRest.ts, 31, 14)) + + remainder: string; +>remainder : Symbol(I.remainder, Decl(objectRest.ts, 32, 20)) +} var removable = new Removable(); ->removable : Symbol(removable, Decl(objectRest.ts, 30, 3)) +>removable : Symbol(removable, Decl(objectRest.ts, 35, 3)) >Removable : Symbol(Removable, Decl(objectRest.ts, 18, 35)) var { removed, ...removableRest } = removable; ->removed : Symbol(removed, Decl(objectRest.ts, 31, 5)) ->removableRest : Symbol(removableRest, Decl(objectRest.ts, 31, 14)) ->removable : Symbol(removable, Decl(objectRest.ts, 30, 3)) +>removed : Symbol(removed, Decl(objectRest.ts, 36, 5), Decl(objectRest.ts, 38, 5)) +>removableRest : Symbol(removableRest, Decl(objectRest.ts, 36, 14)) +>removable : Symbol(removable, Decl(objectRest.ts, 35, 3)) + +var i: I = removable; +>i : Symbol(i, Decl(objectRest.ts, 37, 3)) +>I : Symbol(I, Decl(objectRest.ts, 29, 1)) +>removable : Symbol(removable, Decl(objectRest.ts, 35, 3)) + +var { removed, ...removableRest2 } = i; +>removed : Symbol(removed, Decl(objectRest.ts, 36, 5), Decl(objectRest.ts, 38, 5)) +>removableRest2 : Symbol(removableRest2, Decl(objectRest.ts, 38, 14)) +>i : Symbol(i, Decl(objectRest.ts, 37, 3)) let computed = 'b'; ->computed : Symbol(computed, Decl(objectRest.ts, 33, 3)) +>computed : Symbol(computed, Decl(objectRest.ts, 40, 3)) let computed2 = 'a'; ->computed2 : Symbol(computed2, Decl(objectRest.ts, 34, 3)) +>computed2 : Symbol(computed2, Decl(objectRest.ts, 41, 3)) var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o; ->computed : Symbol(computed, Decl(objectRest.ts, 33, 3)) ->stillNotGreat : Symbol(stillNotGreat, Decl(objectRest.ts, 35, 5)) ->computed2 : Symbol(computed2, Decl(objectRest.ts, 34, 3)) ->soSo : Symbol(soSo, Decl(objectRest.ts, 35, 32)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>computed : Symbol(computed, Decl(objectRest.ts, 40, 3)) +>stillNotGreat : Symbol(stillNotGreat, Decl(objectRest.ts, 42, 5)) +>computed2 : Symbol(computed2, Decl(objectRest.ts, 41, 3)) +>soSo : Symbol(soSo, Decl(objectRest.ts, 42, 32)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) ({ [computed]: stillNotGreat, [computed2]: soSo, ...o } = o); ->computed : Symbol(computed, Decl(objectRest.ts, 33, 3)) ->stillNotGreat : Symbol(stillNotGreat, Decl(objectRest.ts, 35, 5)) ->computed2 : Symbol(computed2, Decl(objectRest.ts, 34, 3)) ->soSo : Symbol(soSo, Decl(objectRest.ts, 35, 32)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>computed : Symbol(computed, Decl(objectRest.ts, 40, 3)) +>stillNotGreat : Symbol(stillNotGreat, Decl(objectRest.ts, 42, 5)) +>computed2 : Symbol(computed2, Decl(objectRest.ts, 41, 3)) +>soSo : Symbol(soSo, Decl(objectRest.ts, 42, 32)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject['anythingGoes']; ->noContextualType : Symbol(noContextualType, Decl(objectRest.ts, 38, 3)) ->aNumber : Symbol(aNumber, Decl(objectRest.ts, 38, 25)) ->notEmptyObject : Symbol(notEmptyObject, Decl(objectRest.ts, 38, 39)) ->aNumber : Symbol(aNumber, Decl(objectRest.ts, 38, 25)) ->notEmptyObject : Symbol(notEmptyObject, Decl(objectRest.ts, 38, 39)) +>noContextualType : Symbol(noContextualType, Decl(objectRest.ts, 45, 3)) +>aNumber : Symbol(aNumber, Decl(objectRest.ts, 45, 25)) +>notEmptyObject : Symbol(notEmptyObject, Decl(objectRest.ts, 45, 39)) +>aNumber : Symbol(aNumber, Decl(objectRest.ts, 45, 25)) +>notEmptyObject : Symbol(notEmptyObject, Decl(objectRest.ts, 45, 39)) diff --git a/tests/baselines/reference/objectRest.types b/tests/baselines/reference/objectRest.types index 1dc05741713..5347f09f5a3 100644 --- a/tests/baselines/reference/objectRest.types +++ b/tests/baselines/reference/objectRest.types @@ -158,6 +158,18 @@ class Removable { remainder: string; >remainder : string } +interface I { +>I : I + + m(): void; +>m : () => void + + removed: string; +>removed : string + + remainder: string; +>remainder : string +} var removable = new Removable(); >removable : Removable >new Removable() : Removable @@ -168,6 +180,16 @@ var { removed, ...removableRest } = removable; >removableRest : { both: number; remainder: string; } >removable : Removable +var i: I = removable; +>i : I +>I : I +>removable : Removable + +var { removed, ...removableRest2 } = i; +>removed : string +>removableRest2 : { m(): void; remainder: string; } +>i : I + let computed = 'b'; >computed : string >'b' : "b" diff --git a/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.js b/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.js index 17045d65af0..22a852e156c 100644 --- a/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.js +++ b/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.js @@ -55,11 +55,16 @@ var b: { var r4: void = b.valueOf(); //// [objectTypeHidingMembersOfExtendedObject.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -68,7 +73,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types b/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types index e050d33024c..1f34c4fafac 100644 --- a/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types +++ b/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types @@ -267,7 +267,7 @@ var r13 = i[-01] >01 : 1 var a: { ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } "0.1": void; ".1": Object; @@ -289,19 +289,19 @@ var a: { var r1 = a['0.1']; >r1 : void >a['0.1'] : void ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'0.1' : "0.1" var r2 = a['.1']; >r2 : Object >a['.1'] : Object ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'.1' : ".1" var r3 = a['1']; >r3 : number >a['1'] : number ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'1' : "1" var r3 = c[1]; @@ -313,7 +313,7 @@ var r3 = c[1]; var r4 = a['1.']; >r4 : string >a['1.'] : string ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'1.' : "1." var r3 = c[1.]; // same as indexing by 1 when done numerically @@ -325,13 +325,13 @@ var r3 = c[1.]; // same as indexing by 1 when done numerically var r5 = a['1..']; >r5 : boolean >a['1..'] : boolean ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'1..' : "1.." var r6 = a['1.0']; >r6 : Date >a['1.0'] : Date ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'1.0' : "1.0" var r3 = c[1.0]; // same as indexing by 1 when done numerically @@ -394,8 +394,8 @@ var r13 = i[-01] >01 : 1 var b = { ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } ->{ "0.1": null, ".1": new Object(), "1": 1, "1.": "", "1..": true, "1.0": new Date(), "-1.0": /123/, "-1": Date} : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>{ "0.1": null, ".1": new Object(), "1": 1, "1.": "", "1..": true, "1.0": new Date(), "-1.0": /123/, "-1": Date} : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } "0.1": null, >null : void @@ -429,19 +429,19 @@ var b = { var r1 = b['0.1']; >r1 : void >b['0.1'] : void ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'0.1' : "0.1" var r2 = b['.1']; >r2 : Object >b['.1'] : Object ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'.1' : ".1" var r3 = b['1']; >r3 : number >b['1'] : number ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'1' : "1" var r3 = c[1]; @@ -453,7 +453,7 @@ var r3 = c[1]; var r4 = b['1.']; >r4 : string >b['1.'] : string ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'1.' : "1." var r3 = c[1.]; // same as indexing by 1 when done numerically @@ -465,13 +465,13 @@ var r3 = c[1.]; // same as indexing by 1 when done numerically var r5 = b['1..']; >r5 : boolean >b['1..'] : boolean ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'1..' : "1.." var r6 = b['1.0']; >r6 : Date >b['1.0'] : Date ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'1.0' : "1.0" var r3 = c[1.0]; // same as indexing by 1 when done numerically diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.js b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.js index e82cef9bdd6..d7db8d271bd 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.js +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.js @@ -124,11 +124,16 @@ function foo16(x: any) { } //// [objectTypesIdentityWithNumericIndexers1.js] // object types are identical structurally -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -147,14 +152,14 @@ var C = (function () { var PA = (function (_super) { __extends(PA, _super); function PA() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PA; }(A)); var PB = (function (_super) { __extends(PB, _super); function PB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PB; }(B)); diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.js b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.js index abcea113670..6af5cb75146 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.js +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.js @@ -127,11 +127,16 @@ function foo16(x: any) { } //// [objectTypesIdentityWithNumericIndexers2.js] // object types are identical structurally -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -140,7 +145,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -162,14 +167,14 @@ var C = (function () { var PA = (function (_super) { __extends(PA, _super); function PA() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PA; }(A)); var PB = (function (_super) { __extends(PB, _super); function PB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PB; }(B)); diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.js b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.js index f5aeb177472..0441cc85dcf 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.js +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.js @@ -124,11 +124,16 @@ function foo16(x: any) { } //// [objectTypesIdentityWithNumericIndexers3.js] // object types are identical structurally -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -147,14 +152,14 @@ var C = (function () { var PA = (function (_super) { __extends(PA, _super); function PA() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PA; }(A)); var PB = (function (_super) { __extends(PB, _super); function PB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PB; }(B)); diff --git a/tests/baselines/reference/objectTypesIdentityWithPrivates.js b/tests/baselines/reference/objectTypesIdentityWithPrivates.js index 3946027063f..294d879ce24 100644 --- a/tests/baselines/reference/objectTypesIdentityWithPrivates.js +++ b/tests/baselines/reference/objectTypesIdentityWithPrivates.js @@ -122,11 +122,16 @@ function foo16(x: any) { } //// [objectTypesIdentityWithPrivates.js] // object types are identical structurally -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -145,14 +150,14 @@ var C = (function () { var PA = (function (_super) { __extends(PA, _super); function PA() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PA; }(A)); var PB = (function (_super) { __extends(PB, _super); function PB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PB; }(B)); diff --git a/tests/baselines/reference/objectTypesIdentityWithPrivates2.js b/tests/baselines/reference/objectTypesIdentityWithPrivates2.js index 9cae6960a2e..d151af230f6 100644 --- a/tests/baselines/reference/objectTypesIdentityWithPrivates2.js +++ b/tests/baselines/reference/objectTypesIdentityWithPrivates2.js @@ -40,11 +40,16 @@ function foo6(x: any): any { } //// [objectTypesIdentityWithPrivates2.js] // object types are identical structurally -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -53,7 +58,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/objectTypesIdentityWithPrivates3.js b/tests/baselines/reference/objectTypesIdentityWithPrivates3.js index 68754a583aa..7fc23f7255c 100644 --- a/tests/baselines/reference/objectTypesIdentityWithPrivates3.js +++ b/tests/baselines/reference/objectTypesIdentityWithPrivates3.js @@ -26,11 +26,16 @@ var c3: C3; c3; // Should fail (private x originates in the same declaration, but different types) //// [objectTypesIdentityWithPrivates3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1() { } @@ -39,7 +44,7 @@ var C1 = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(C1)); @@ -53,7 +58,7 @@ var C3 = (function () { var C4 = (function (_super) { __extends(C4, _super); function C4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C4; }(C3)); diff --git a/tests/baselines/reference/objectTypesIdentityWithStringIndexers.js b/tests/baselines/reference/objectTypesIdentityWithStringIndexers.js index b0211bbbba7..9bf7aca342b 100644 --- a/tests/baselines/reference/objectTypesIdentityWithStringIndexers.js +++ b/tests/baselines/reference/objectTypesIdentityWithStringIndexers.js @@ -124,11 +124,16 @@ function foo16(x: any) { } //// [objectTypesIdentityWithStringIndexers.js] // object types are identical structurally -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -147,14 +152,14 @@ var C = (function () { var PA = (function (_super) { __extends(PA, _super); function PA() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PA; }(A)); var PB = (function (_super) { __extends(PB, _super); function PB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PB; }(B)); diff --git a/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.js b/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.js index 00d7d1e81d8..f8aa1127e4e 100644 --- a/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.js +++ b/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.js @@ -127,11 +127,16 @@ function foo16(x: any) { } //// [objectTypesIdentityWithStringIndexers2.js] // object types are identical structurally -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -140,7 +145,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -162,14 +167,14 @@ var C = (function () { var PA = (function (_super) { __extends(PA, _super); function PA() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PA; }(A)); var PB = (function (_super) { __extends(PB, _super); function PB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PB; }(B)); diff --git a/tests/baselines/reference/oldStyleOctalLiteralTypes.errors.txt b/tests/baselines/reference/oldStyleOctalLiteralTypes.errors.txt index 4dc81f370a4..7d42963b05d 100644 --- a/tests/baselines/reference/oldStyleOctalLiteralTypes.errors.txt +++ b/tests/baselines/reference/oldStyleOctalLiteralTypes.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/oldStyleOctalLiteralTypes.ts(1,8): error TS8017: Octal literal types must use ES2015 syntax. Use the syntax '0o10'. -tests/cases/compiler/oldStyleOctalLiteralTypes.ts(2,9): error TS8017: Octal literal types must use ES2015 syntax. Use the syntax '0o20'. +tests/cases/compiler/oldStyleOctalLiteralTypes.ts(2,8): error TS8017: Octal literal types must use ES2015 syntax. Use the syntax '-0o20'. ==== tests/cases/compiler/oldStyleOctalLiteralTypes.ts (2 errors) ==== @@ -7,6 +7,6 @@ tests/cases/compiler/oldStyleOctalLiteralTypes.ts(2,9): error TS8017: Octal lite ~~~ !!! error TS8017: Octal literal types must use ES2015 syntax. Use the syntax '0o10'. let y: -020; - ~~~ -!!! error TS8017: Octal literal types must use ES2015 syntax. Use the syntax '0o20'. + ~~~~ +!!! error TS8017: Octal literal types must use ES2015 syntax. Use the syntax '-0o20'. \ No newline at end of file diff --git a/tests/baselines/reference/operatorAddNullUndefined.errors.txt b/tests/baselines/reference/operatorAddNullUndefined.errors.txt index 269ee0a5166..871ef3fc98f 100644 --- a/tests/baselines/reference/operatorAddNullUndefined.errors.txt +++ b/tests/baselines/reference/operatorAddNullUndefined.errors.txt @@ -1,32 +1,68 @@ -tests/cases/compiler/operatorAddNullUndefined.ts(2,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/compiler/operatorAddNullUndefined.ts(3,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/compiler/operatorAddNullUndefined.ts(4,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/compiler/operatorAddNullUndefined.ts(5,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(2,10): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(2,17): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(3,10): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(3,17): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(4,10): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(4,22): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(5,10): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(5,22): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(6,14): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(7,14): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(8,10): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(9,10): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(14,11): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(15,11): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(16,17): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(17,17): error TS2532: Object is possibly 'undefined'. -==== tests/cases/compiler/operatorAddNullUndefined.ts (4 errors) ==== +==== tests/cases/compiler/operatorAddNullUndefined.ts (16 errors) ==== enum E { x } var x1 = null + null; - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var x2 = null + undefined; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x3 = undefined + null; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var x4 = undefined + undefined; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x5 = 1 + null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. var x6 = 1 + undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x7 = null + 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. var x8 = undefined + 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x9 = "test" + null; var x10 = "test" + undefined; var x11 = null + "test"; var x12 = undefined + "test"; var x13 = null + E.x + ~~~~ +!!! error TS2531: Object is possibly 'null'. var x14 = undefined + E.x + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x15 = E.x + null - var x16 = E.x + undefined \ No newline at end of file + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var x16 = E.x + undefined + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalConstructorArgInSuper.js b/tests/baselines/reference/optionalConstructorArgInSuper.js index e460ab3fb15..2412ce67ffe 100644 --- a/tests/baselines/reference/optionalConstructorArgInSuper.js +++ b/tests/baselines/reference/optionalConstructorArgInSuper.js @@ -11,11 +11,16 @@ d2.foo(); //// [optionalConstructorArgInSuper.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(opt) { } @@ -25,7 +30,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/optionalMethods.js b/tests/baselines/reference/optionalMethods.js index 28ed0bcd76e..a3685175f66 100644 --- a/tests/baselines/reference/optionalMethods.js +++ b/tests/baselines/reference/optionalMethods.js @@ -58,11 +58,16 @@ class Derived extends Base { //// [optionalMethods.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function test1(x) { x.a; x.b; @@ -109,7 +114,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.a = 1; return _this; } diff --git a/tests/baselines/reference/optionalParamArgsTest.js b/tests/baselines/reference/optionalParamArgsTest.js index 1b603898aa6..5c8503a9bef 100644 --- a/tests/baselines/reference/optionalParamArgsTest.js +++ b/tests/baselines/reference/optionalParamArgsTest.js @@ -125,11 +125,16 @@ fnOpt2(1, [2, 3], [1], true); //// [optionalParamArgsTest.js] // Optional parameter and default argument tests -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // test basic configurations var C1 = (function () { function C1(v, p) { diff --git a/tests/baselines/reference/optionalParamInOverride.js b/tests/baselines/reference/optionalParamInOverride.js index 1312a89502a..601cb4d6f1e 100644 --- a/tests/baselines/reference/optionalParamInOverride.js +++ b/tests/baselines/reference/optionalParamInOverride.js @@ -8,11 +8,16 @@ class Y extends Z { //// [optionalParamInOverride.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Z = (function () { function Z() { } @@ -22,7 +27,7 @@ var Z = (function () { var Y = (function (_super) { __extends(Y, _super); function Y() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Y.prototype.func = function (value) { }; return Y; diff --git a/tests/baselines/reference/optionalParameterProperty.js b/tests/baselines/reference/optionalParameterProperty.js index f9b9ecaf990..fc288d09767 100644 --- a/tests/baselines/reference/optionalParameterProperty.js +++ b/tests/baselines/reference/optionalParameterProperty.js @@ -12,11 +12,16 @@ class D extends C { //// [optionalParameterProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } diff --git a/tests/baselines/reference/outModuleConcatAmd.js b/tests/baselines/reference/outModuleConcatAmd.js index 5054c2a3c33..b30cf93786c 100644 --- a/tests/baselines/reference/outModuleConcatAmd.js +++ b/tests/baselines/reference/outModuleConcatAmd.js @@ -9,11 +9,16 @@ import {A} from "./ref/a"; export class B extends A { } //// [all.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); define("ref/a", ["require", "exports"], function (require, exports) { "use strict"; var A = (function () { @@ -28,7 +33,7 @@ define("b", ["require", "exports", "ref/a"], function (require, exports, a_1) { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(a_1.A)); diff --git a/tests/baselines/reference/outModuleConcatAmd.js.map b/tests/baselines/reference/outModuleConcatAmd.js.map index 9187aca0646..a95ca740a61 100644 --- a/tests/baselines/reference/outModuleConcatAmd.js.map +++ b/tests/baselines/reference/outModuleConcatAmd.js.map @@ -1,2 +1,2 @@ //// [all.js.map] -{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;;;IACA;QAAA;QAAiB,CAAC;QAAD,QAAC;IAAD,CAAC,AAAlB,IAAkB;IAAL,cAAC;;;;ICAd;QAAuB,qBAAC;QAAxB;;QAA2B,CAAC;QAAD,QAAC;IAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;IAAf,cAAC"} \ No newline at end of file +{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;;;;;;;;IACA;QAAA;QAAiB,CAAC;QAAD,QAAC;IAAD,CAAC,AAAlB,IAAkB;IAAL,cAAC;;;;ICAd;QAAuB,qBAAC;QAAxB;;QAA2B,CAAC;QAAD,QAAC;IAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;IAAf,cAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatAmd.sourcemap.txt b/tests/baselines/reference/outModuleConcatAmd.sourcemap.txt index 34ab74816ad..a8a11fcadc0 100644 --- a/tests/baselines/reference/outModuleConcatAmd.sourcemap.txt +++ b/tests/baselines/reference/outModuleConcatAmd.sourcemap.txt @@ -8,11 +8,16 @@ sources: tests/cases/compiler/ref/a.ts,tests/cases/compiler/b.ts emittedFile:all.js sourceFile:tests/cases/compiler/ref/a.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; } ->>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); ->>>}; +>>>var __extends = (this && this.__extends) || (function () { +>>> var extendStatics = Object.setPrototypeOf || +>>> ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || +>>> function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; +>>> return function (d, b) { +>>> extendStatics(d, b); +>>> function __() { this.constructor = d; } +>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +>>> }; +>>>})(); >>>define("ref/a", ["require", "exports"], function (require, exports) { >>> "use strict"; >>> var A = (function () { @@ -20,13 +25,13 @@ sourceFile:tests/cases/compiler/ref/a.ts 2 > ^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(8, 5) Source(2, 1) + SourceIndex(0) +1 >Emitted(13, 5) Source(2, 1) + SourceIndex(0) --- >>> function A() { 1->^^^^^^^^ 2 > ^^-> 1-> -1->Emitted(9, 9) Source(2, 1) + SourceIndex(0) +1->Emitted(14, 9) Source(2, 1) + SourceIndex(0) --- >>> } 1->^^^^^^^^ @@ -34,16 +39,16 @@ sourceFile:tests/cases/compiler/ref/a.ts 3 > ^^^^^^^^^-> 1->export class A { 2 > } -1->Emitted(10, 9) Source(2, 18) + SourceIndex(0) -2 >Emitted(10, 10) Source(2, 19) + SourceIndex(0) +1->Emitted(15, 9) Source(2, 18) + SourceIndex(0) +2 >Emitted(15, 10) Source(2, 19) + SourceIndex(0) --- >>> return A; 1->^^^^^^^^ 2 > ^^^^^^^^ 1-> 2 > } -1->Emitted(11, 9) Source(2, 18) + SourceIndex(0) -2 >Emitted(11, 17) Source(2, 19) + SourceIndex(0) +1->Emitted(16, 9) Source(2, 18) + SourceIndex(0) +2 >Emitted(16, 17) Source(2, 19) + SourceIndex(0) --- >>> }()); 1 >^^^^ @@ -55,18 +60,18 @@ sourceFile:tests/cases/compiler/ref/a.ts 2 > } 3 > 4 > export class A { } -1 >Emitted(12, 5) Source(2, 18) + SourceIndex(0) -2 >Emitted(12, 6) Source(2, 19) + SourceIndex(0) -3 >Emitted(12, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(12, 10) Source(2, 19) + SourceIndex(0) +1 >Emitted(17, 5) Source(2, 18) + SourceIndex(0) +2 >Emitted(17, 6) Source(2, 19) + SourceIndex(0) +3 >Emitted(17, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(17, 10) Source(2, 19) + SourceIndex(0) --- >>> exports.A = A; 1->^^^^ 2 > ^^^^^^^^^^^^^^ 1-> 2 > A -1->Emitted(13, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(13, 19) Source(2, 15) + SourceIndex(0) +1->Emitted(18, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(18, 19) Source(2, 15) + SourceIndex(0) --- ------------------------------------------------------------------- emittedFile:all.js @@ -80,39 +85,39 @@ sourceFile:tests/cases/compiler/b.ts 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >import {A} from "./ref/a"; > -1 >Emitted(17, 5) Source(2, 1) + SourceIndex(1) +1 >Emitted(22, 5) Source(2, 1) + SourceIndex(1) --- >>> __extends(B, _super); 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^ 1->export class B extends 2 > A -1->Emitted(18, 9) Source(2, 24) + SourceIndex(1) -2 >Emitted(18, 30) Source(2, 25) + SourceIndex(1) +1->Emitted(23, 9) Source(2, 24) + SourceIndex(1) +2 >Emitted(23, 30) Source(2, 25) + SourceIndex(1) --- >>> function B() { 1 >^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(19, 9) Source(2, 1) + SourceIndex(1) +1 >Emitted(24, 9) Source(2, 1) + SourceIndex(1) --- ->>> return _super.apply(this, arguments) || this; +>>> return _super !== null && _super.apply(this, arguments) || this; >>> } 1->^^^^^^^^ 2 > ^ 3 > ^^^^^^^^^-> 1->export class B extends A { 2 > } -1->Emitted(21, 9) Source(2, 28) + SourceIndex(1) -2 >Emitted(21, 10) Source(2, 29) + SourceIndex(1) +1->Emitted(26, 9) Source(2, 28) + SourceIndex(1) +2 >Emitted(26, 10) Source(2, 29) + SourceIndex(1) --- >>> return B; 1->^^^^^^^^ 2 > ^^^^^^^^ 1-> 2 > } -1->Emitted(22, 9) Source(2, 28) + SourceIndex(1) -2 >Emitted(22, 17) Source(2, 29) + SourceIndex(1) +1->Emitted(27, 9) Source(2, 28) + SourceIndex(1) +2 >Emitted(27, 17) Source(2, 29) + SourceIndex(1) --- >>> }(a_1.A)); 1 >^^^^ @@ -128,20 +133,20 @@ sourceFile:tests/cases/compiler/b.ts 4 > export class B extends 5 > A 6 > { } -1 >Emitted(23, 5) Source(2, 28) + SourceIndex(1) -2 >Emitted(23, 6) Source(2, 29) + SourceIndex(1) -3 >Emitted(23, 6) Source(2, 1) + SourceIndex(1) -4 >Emitted(23, 7) Source(2, 24) + SourceIndex(1) -5 >Emitted(23, 12) Source(2, 25) + SourceIndex(1) -6 >Emitted(23, 15) Source(2, 29) + SourceIndex(1) +1 >Emitted(28, 5) Source(2, 28) + SourceIndex(1) +2 >Emitted(28, 6) Source(2, 29) + SourceIndex(1) +3 >Emitted(28, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(28, 7) Source(2, 24) + SourceIndex(1) +5 >Emitted(28, 12) Source(2, 25) + SourceIndex(1) +6 >Emitted(28, 15) Source(2, 29) + SourceIndex(1) --- >>> exports.B = B; 1->^^^^ 2 > ^^^^^^^^^^^^^^ 1-> 2 > B -1->Emitted(24, 5) Source(2, 14) + SourceIndex(1) -2 >Emitted(24, 19) Source(2, 15) + SourceIndex(1) +1->Emitted(29, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(29, 19) Source(2, 15) + SourceIndex(1) --- >>>}); >>>//# sourceMappingURL=all.js.map \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatSystem.js b/tests/baselines/reference/outModuleConcatSystem.js index a615090f33a..1648748a168 100644 --- a/tests/baselines/reference/outModuleConcatSystem.js +++ b/tests/baselines/reference/outModuleConcatSystem.js @@ -9,11 +9,16 @@ import {A} from "./ref/a"; export class B extends A { } //// [all.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); System.register("ref/a", [], function (exports_1, context_1) { "use strict"; var __moduleName = context_1 && context_1.id; @@ -44,7 +49,7 @@ System.register("b", ["ref/a"], function (exports_2, context_2) { B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(a_1.A)); diff --git a/tests/baselines/reference/outModuleConcatSystem.js.map b/tests/baselines/reference/outModuleConcatSystem.js.map index ac8fb23d87c..25b706844e2 100644 --- a/tests/baselines/reference/outModuleConcatSystem.js.map +++ b/tests/baselines/reference/outModuleConcatSystem.js.map @@ -1,2 +1,2 @@ //// [all.js.map] -{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;;;;;;;;YACA;gBAAA;gBAAiB,CAAC;gBAAD,QAAC;YAAD,CAAC,AAAlB,IAAkB;;QAClB,CAAC;;;;;;;;;;;;;;YCDD;gBAAuB,qBAAC;gBAAxB;;gBAA2B,CAAC;gBAAD,QAAC;YAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;;QAAA,CAAC"} \ No newline at end of file +{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;YACA;gBAAA;gBAAiB,CAAC;gBAAD,QAAC;YAAD,CAAC,AAAlB,IAAkB;;QAClB,CAAC;;;;;;;;;;;;;;YCDD;gBAAuB,qBAAC;gBAAxB;;gBAA2B,CAAC;gBAAD,QAAC;YAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;;QAAA,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatSystem.sourcemap.txt b/tests/baselines/reference/outModuleConcatSystem.sourcemap.txt index 732214237fa..a8dd4bb55e7 100644 --- a/tests/baselines/reference/outModuleConcatSystem.sourcemap.txt +++ b/tests/baselines/reference/outModuleConcatSystem.sourcemap.txt @@ -8,11 +8,16 @@ sources: tests/cases/compiler/ref/a.ts,tests/cases/compiler/b.ts emittedFile:all.js sourceFile:tests/cases/compiler/ref/a.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; } ->>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); ->>>}; +>>>var __extends = (this && this.__extends) || (function () { +>>> var extendStatics = Object.setPrototypeOf || +>>> ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || +>>> function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; +>>> return function (d, b) { +>>> extendStatics(d, b); +>>> function __() { this.constructor = d; } +>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +>>> }; +>>>})(); >>>System.register("ref/a", [], function (exports_1, context_1) { >>> "use strict"; >>> var __moduleName = context_1 && context_1.id; @@ -25,13 +30,13 @@ sourceFile:tests/cases/compiler/ref/a.ts 2 > ^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(13, 13) Source(2, 1) + SourceIndex(0) +1 >Emitted(18, 13) Source(2, 1) + SourceIndex(0) --- >>> function A() { 1->^^^^^^^^^^^^^^^^ 2 > ^^-> 1-> -1->Emitted(14, 17) Source(2, 1) + SourceIndex(0) +1->Emitted(19, 17) Source(2, 1) + SourceIndex(0) --- >>> } 1->^^^^^^^^^^^^^^^^ @@ -39,16 +44,16 @@ sourceFile:tests/cases/compiler/ref/a.ts 3 > ^^^^^^^^^-> 1->export class A { 2 > } -1->Emitted(15, 17) Source(2, 18) + SourceIndex(0) -2 >Emitted(15, 18) Source(2, 19) + SourceIndex(0) +1->Emitted(20, 17) Source(2, 18) + SourceIndex(0) +2 >Emitted(20, 18) Source(2, 19) + SourceIndex(0) --- >>> return A; 1->^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^ 1-> 2 > } -1->Emitted(16, 17) Source(2, 18) + SourceIndex(0) -2 >Emitted(16, 25) Source(2, 19) + SourceIndex(0) +1->Emitted(21, 17) Source(2, 18) + SourceIndex(0) +2 >Emitted(21, 25) Source(2, 19) + SourceIndex(0) --- >>> }()); 1 >^^^^^^^^^^^^ @@ -60,10 +65,10 @@ sourceFile:tests/cases/compiler/ref/a.ts 2 > } 3 > 4 > export class A { } -1 >Emitted(17, 13) Source(2, 18) + SourceIndex(0) -2 >Emitted(17, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(17, 14) Source(2, 1) + SourceIndex(0) -4 >Emitted(17, 18) Source(2, 19) + SourceIndex(0) +1 >Emitted(22, 13) Source(2, 18) + SourceIndex(0) +2 >Emitted(22, 14) Source(2, 19) + SourceIndex(0) +3 >Emitted(22, 14) Source(2, 1) + SourceIndex(0) +4 >Emitted(22, 18) Source(2, 19) + SourceIndex(0) --- >>> exports_1("A", A); >>> } @@ -72,8 +77,8 @@ sourceFile:tests/cases/compiler/ref/a.ts 1-> > 2 > -1->Emitted(19, 9) Source(3, 1) + SourceIndex(0) -2 >Emitted(19, 10) Source(3, 2) + SourceIndex(0) +1->Emitted(24, 9) Source(3, 1) + SourceIndex(0) +2 >Emitted(24, 10) Source(3, 2) + SourceIndex(0) --- ------------------------------------------------------------------- emittedFile:all.js @@ -97,39 +102,39 @@ sourceFile:tests/cases/compiler/b.ts 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >import {A} from "./ref/a"; > -1 >Emitted(33, 13) Source(2, 1) + SourceIndex(1) +1 >Emitted(38, 13) Source(2, 1) + SourceIndex(1) --- >>> __extends(B, _super); 1->^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^ 1->export class B extends 2 > A -1->Emitted(34, 17) Source(2, 24) + SourceIndex(1) -2 >Emitted(34, 38) Source(2, 25) + SourceIndex(1) +1->Emitted(39, 17) Source(2, 24) + SourceIndex(1) +2 >Emitted(39, 38) Source(2, 25) + SourceIndex(1) --- >>> function B() { 1 >^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(35, 17) Source(2, 1) + SourceIndex(1) +1 >Emitted(40, 17) Source(2, 1) + SourceIndex(1) --- ->>> return _super.apply(this, arguments) || this; +>>> return _super !== null && _super.apply(this, arguments) || this; >>> } 1->^^^^^^^^^^^^^^^^ 2 > ^ 3 > ^^^^^^^^^-> 1->export class B extends A { 2 > } -1->Emitted(37, 17) Source(2, 28) + SourceIndex(1) -2 >Emitted(37, 18) Source(2, 29) + SourceIndex(1) +1->Emitted(42, 17) Source(2, 28) + SourceIndex(1) +2 >Emitted(42, 18) Source(2, 29) + SourceIndex(1) --- >>> return B; 1->^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^ 1-> 2 > } -1->Emitted(38, 17) Source(2, 28) + SourceIndex(1) -2 >Emitted(38, 25) Source(2, 29) + SourceIndex(1) +1->Emitted(43, 17) Source(2, 28) + SourceIndex(1) +2 >Emitted(43, 25) Source(2, 29) + SourceIndex(1) --- >>> }(a_1.A)); 1 >^^^^^^^^^^^^ @@ -145,12 +150,12 @@ sourceFile:tests/cases/compiler/b.ts 4 > export class B extends 5 > A 6 > { } -1 >Emitted(39, 13) Source(2, 28) + SourceIndex(1) -2 >Emitted(39, 14) Source(2, 29) + SourceIndex(1) -3 >Emitted(39, 14) Source(2, 1) + SourceIndex(1) -4 >Emitted(39, 15) Source(2, 24) + SourceIndex(1) -5 >Emitted(39, 20) Source(2, 25) + SourceIndex(1) -6 >Emitted(39, 23) Source(2, 29) + SourceIndex(1) +1 >Emitted(44, 13) Source(2, 28) + SourceIndex(1) +2 >Emitted(44, 14) Source(2, 29) + SourceIndex(1) +3 >Emitted(44, 14) Source(2, 1) + SourceIndex(1) +4 >Emitted(44, 15) Source(2, 24) + SourceIndex(1) +5 >Emitted(44, 20) Source(2, 25) + SourceIndex(1) +6 >Emitted(44, 23) Source(2, 29) + SourceIndex(1) --- >>> exports_2("B", B); >>> } @@ -158,8 +163,8 @@ sourceFile:tests/cases/compiler/b.ts 2 > ^ 1-> 2 > -1->Emitted(41, 9) Source(2, 29) + SourceIndex(1) -2 >Emitted(41, 10) Source(2, 30) + SourceIndex(1) +1->Emitted(46, 9) Source(2, 29) + SourceIndex(1) +2 >Emitted(46, 10) Source(2, 30) + SourceIndex(1) --- >>> }; >>>}); diff --git a/tests/baselines/reference/outModuleTripleSlashRefs.js b/tests/baselines/reference/outModuleTripleSlashRefs.js index b9ff7c15b61..33e970af54b 100644 --- a/tests/baselines/reference/outModuleTripleSlashRefs.js +++ b/tests/baselines/reference/outModuleTripleSlashRefs.js @@ -31,11 +31,16 @@ export class B extends A { } //// [all.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); /// var Foo = (function () { function Foo() { @@ -57,7 +62,7 @@ define("b", ["require", "exports", "ref/a"], function (require, exports, a_1) { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(a_1.A)); diff --git a/tests/baselines/reference/outModuleTripleSlashRefs.js.map b/tests/baselines/reference/outModuleTripleSlashRefs.js.map index 5ccc59aeabf..e91088c249c 100644 --- a/tests/baselines/reference/outModuleTripleSlashRefs.js.map +++ b/tests/baselines/reference/outModuleTripleSlashRefs.js.map @@ -1,2 +1,2 @@ //// [all.js.map] -{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/b.ts","tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;AAAA,iCAAiC;AACjC;IAAA;IAEA,CAAC;IAAD,UAAC;AAAD,CAAC,AAFD,IAEC;;;ICFD,+BAA+B;IAC/B;QAAA;QAEA,CAAC;QAAD,QAAC;IAAD,CAAC,AAFD,IAEC;IAFY,cAAC;;;;ICDd;QAAuB,qBAAC;QAAxB;;QAA2B,CAAC;QAAD,QAAC;IAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;IAAf,cAAC"} \ No newline at end of file +{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/b.ts","tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,iCAAiC;AACjC;IAAA;IAEA,CAAC;IAAD,UAAC;AAAD,CAAC,AAFD,IAEC;;;ICFD,+BAA+B;IAC/B;QAAA;QAEA,CAAC;QAAD,QAAC;IAAD,CAAC,AAFD,IAEC;IAFY,cAAC;;;;ICDd;QAAuB,qBAAC;QAAxB;;QAA2B,CAAC;QAAD,QAAC;IAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;IAAf,cAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleTripleSlashRefs.sourcemap.txt b/tests/baselines/reference/outModuleTripleSlashRefs.sourcemap.txt index ce41bae6de3..f2076c34482 100644 --- a/tests/baselines/reference/outModuleTripleSlashRefs.sourcemap.txt +++ b/tests/baselines/reference/outModuleTripleSlashRefs.sourcemap.txt @@ -8,31 +8,36 @@ sources: tests/cases/compiler/ref/b.ts,tests/cases/compiler/ref/a.ts,tests/cases emittedFile:all.js sourceFile:tests/cases/compiler/ref/b.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; } ->>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); ->>>}; +>>>var __extends = (this && this.__extends) || (function () { +>>> var extendStatics = Object.setPrototypeOf || +>>> ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || +>>> function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; +>>> return function (d, b) { +>>> extendStatics(d, b); +>>> function __() { this.constructor = d; } +>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +>>> }; +>>>})(); >>>/// 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > 2 >/// -1 >Emitted(6, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(6, 34) Source(1, 34) + SourceIndex(0) +1 >Emitted(11, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(0) --- >>>var Foo = (function () { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(7, 1) Source(2, 1) + SourceIndex(0) +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(0) --- >>> function Foo() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(8, 5) Source(2, 1) + SourceIndex(0) +1->Emitted(13, 5) Source(2, 1) + SourceIndex(0) --- >>> } 1->^^^^ @@ -42,16 +47,16 @@ sourceFile:tests/cases/compiler/ref/b.ts > member: Bar; > 2 > } -1->Emitted(9, 5) Source(4, 1) + SourceIndex(0) -2 >Emitted(9, 6) Source(4, 2) + SourceIndex(0) +1->Emitted(14, 5) Source(4, 1) + SourceIndex(0) +2 >Emitted(14, 6) Source(4, 2) + SourceIndex(0) --- >>> return Foo; 1->^^^^ 2 > ^^^^^^^^^^ 1-> 2 > } -1->Emitted(10, 5) Source(4, 1) + SourceIndex(0) -2 >Emitted(10, 15) Source(4, 2) + SourceIndex(0) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(0) +2 >Emitted(15, 15) Source(4, 2) + SourceIndex(0) --- >>>}()); 1 > @@ -65,10 +70,10 @@ sourceFile:tests/cases/compiler/ref/b.ts 4 > class Foo { > member: Bar; > } -1 >Emitted(11, 1) Source(4, 1) + SourceIndex(0) -2 >Emitted(11, 2) Source(4, 2) + SourceIndex(0) -3 >Emitted(11, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(11, 6) Source(4, 2) + SourceIndex(0) +1 >Emitted(16, 1) Source(4, 1) + SourceIndex(0) +2 >Emitted(16, 2) Source(4, 2) + SourceIndex(0) +3 >Emitted(16, 2) Source(2, 1) + SourceIndex(0) +4 >Emitted(16, 6) Source(4, 2) + SourceIndex(0) --- ------------------------------------------------------------------- emittedFile:all.js @@ -82,21 +87,21 @@ sourceFile:tests/cases/compiler/ref/a.ts 1-> > 2 > /// -1->Emitted(14, 5) Source(2, 1) + SourceIndex(1) -2 >Emitted(14, 36) Source(2, 32) + SourceIndex(1) +1->Emitted(19, 5) Source(2, 1) + SourceIndex(1) +2 >Emitted(19, 36) Source(2, 32) + SourceIndex(1) --- >>> var A = (function () { 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(15, 5) Source(3, 1) + SourceIndex(1) +1 >Emitted(20, 5) Source(3, 1) + SourceIndex(1) --- >>> function A() { 1->^^^^^^^^ 2 > ^^-> 1-> -1->Emitted(16, 9) Source(3, 1) + SourceIndex(1) +1->Emitted(21, 9) Source(3, 1) + SourceIndex(1) --- >>> } 1->^^^^^^^^ @@ -106,16 +111,16 @@ sourceFile:tests/cases/compiler/ref/a.ts > member: typeof GlobalFoo; > 2 > } -1->Emitted(17, 9) Source(5, 1) + SourceIndex(1) -2 >Emitted(17, 10) Source(5, 2) + SourceIndex(1) +1->Emitted(22, 9) Source(5, 1) + SourceIndex(1) +2 >Emitted(22, 10) Source(5, 2) + SourceIndex(1) --- >>> return A; 1->^^^^^^^^ 2 > ^^^^^^^^ 1-> 2 > } -1->Emitted(18, 9) Source(5, 1) + SourceIndex(1) -2 >Emitted(18, 17) Source(5, 2) + SourceIndex(1) +1->Emitted(23, 9) Source(5, 1) + SourceIndex(1) +2 >Emitted(23, 17) Source(5, 2) + SourceIndex(1) --- >>> }()); 1 >^^^^ @@ -129,18 +134,18 @@ sourceFile:tests/cases/compiler/ref/a.ts 4 > export class A { > member: typeof GlobalFoo; > } -1 >Emitted(19, 5) Source(5, 1) + SourceIndex(1) -2 >Emitted(19, 6) Source(5, 2) + SourceIndex(1) -3 >Emitted(19, 6) Source(3, 1) + SourceIndex(1) -4 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) +1 >Emitted(24, 5) Source(5, 1) + SourceIndex(1) +2 >Emitted(24, 6) Source(5, 2) + SourceIndex(1) +3 >Emitted(24, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(24, 10) Source(5, 2) + SourceIndex(1) --- >>> exports.A = A; 1->^^^^ 2 > ^^^^^^^^^^^^^^ 1-> 2 > A -1->Emitted(20, 5) Source(3, 14) + SourceIndex(1) -2 >Emitted(20, 19) Source(3, 15) + SourceIndex(1) +1->Emitted(25, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(25, 19) Source(3, 15) + SourceIndex(1) --- ------------------------------------------------------------------- emittedFile:all.js @@ -154,39 +159,39 @@ sourceFile:tests/cases/compiler/b.ts 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >import {A} from "./ref/a"; > -1 >Emitted(24, 5) Source(2, 1) + SourceIndex(2) +1 >Emitted(29, 5) Source(2, 1) + SourceIndex(2) --- >>> __extends(B, _super); 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^ 1->export class B extends 2 > A -1->Emitted(25, 9) Source(2, 24) + SourceIndex(2) -2 >Emitted(25, 30) Source(2, 25) + SourceIndex(2) +1->Emitted(30, 9) Source(2, 24) + SourceIndex(2) +2 >Emitted(30, 30) Source(2, 25) + SourceIndex(2) --- >>> function B() { 1 >^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(26, 9) Source(2, 1) + SourceIndex(2) +1 >Emitted(31, 9) Source(2, 1) + SourceIndex(2) --- ->>> return _super.apply(this, arguments) || this; +>>> return _super !== null && _super.apply(this, arguments) || this; >>> } 1->^^^^^^^^ 2 > ^ 3 > ^^^^^^^^^-> 1->export class B extends A { 2 > } -1->Emitted(28, 9) Source(2, 28) + SourceIndex(2) -2 >Emitted(28, 10) Source(2, 29) + SourceIndex(2) +1->Emitted(33, 9) Source(2, 28) + SourceIndex(2) +2 >Emitted(33, 10) Source(2, 29) + SourceIndex(2) --- >>> return B; 1->^^^^^^^^ 2 > ^^^^^^^^ 1-> 2 > } -1->Emitted(29, 9) Source(2, 28) + SourceIndex(2) -2 >Emitted(29, 17) Source(2, 29) + SourceIndex(2) +1->Emitted(34, 9) Source(2, 28) + SourceIndex(2) +2 >Emitted(34, 17) Source(2, 29) + SourceIndex(2) --- >>> }(a_1.A)); 1 >^^^^ @@ -202,20 +207,20 @@ sourceFile:tests/cases/compiler/b.ts 4 > export class B extends 5 > A 6 > { } -1 >Emitted(30, 5) Source(2, 28) + SourceIndex(2) -2 >Emitted(30, 6) Source(2, 29) + SourceIndex(2) -3 >Emitted(30, 6) Source(2, 1) + SourceIndex(2) -4 >Emitted(30, 7) Source(2, 24) + SourceIndex(2) -5 >Emitted(30, 12) Source(2, 25) + SourceIndex(2) -6 >Emitted(30, 15) Source(2, 29) + SourceIndex(2) +1 >Emitted(35, 5) Source(2, 28) + SourceIndex(2) +2 >Emitted(35, 6) Source(2, 29) + SourceIndex(2) +3 >Emitted(35, 6) Source(2, 1) + SourceIndex(2) +4 >Emitted(35, 7) Source(2, 24) + SourceIndex(2) +5 >Emitted(35, 12) Source(2, 25) + SourceIndex(2) +6 >Emitted(35, 15) Source(2, 29) + SourceIndex(2) --- >>> exports.B = B; 1->^^^^ 2 > ^^^^^^^^^^^^^^ 1-> 2 > B -1->Emitted(31, 5) Source(2, 14) + SourceIndex(2) -2 >Emitted(31, 19) Source(2, 15) + SourceIndex(2) +1->Emitted(36, 5) Source(2, 14) + SourceIndex(2) +2 >Emitted(36, 19) Source(2, 15) + SourceIndex(2) --- >>>}); >>>//# sourceMappingURL=all.js.map \ No newline at end of file diff --git a/tests/baselines/reference/overload1.js b/tests/baselines/reference/overload1.js index 41aafdfb29c..fc898b4e870 100644 --- a/tests/baselines/reference/overload1.js +++ b/tests/baselines/reference/overload1.js @@ -40,11 +40,16 @@ var v=x.g; //// [overload1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var O; (function (O) { var A = (function () { @@ -56,7 +61,7 @@ var O; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -64,7 +69,7 @@ var O; var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks1.js b/tests/baselines/reference/overloadOnConstConstraintChecks1.js index f9d1c81b06b..6a4cc01bf85 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks1.js +++ b/tests/baselines/reference/overloadOnConstConstraintChecks1.js @@ -23,11 +23,16 @@ class D implements MyDoc { } //// [overloadOnConstConstraintChecks1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -37,7 +42,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.prototype.bar = function () { }; return Derived1; @@ -45,7 +50,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.prototype.baz = function () { }; return Derived2; @@ -53,7 +58,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived3.prototype.biz = function () { }; return Derived3; diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks2.js b/tests/baselines/reference/overloadOnConstConstraintChecks2.js index a680a62ddfe..379de55da88 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks2.js +++ b/tests/baselines/reference/overloadOnConstConstraintChecks2.js @@ -12,11 +12,16 @@ function foo(name: any): A { } //// [overloadOnConstConstraintChecks2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -25,14 +30,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.foo = function () { }; return C; diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks3.js b/tests/baselines/reference/overloadOnConstConstraintChecks3.js index 025e449fd6f..de843b9f44c 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks3.js +++ b/tests/baselines/reference/overloadOnConstConstraintChecks3.js @@ -13,11 +13,16 @@ function foo(name: any): A { //// [overloadOnConstConstraintChecks3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { this.x = 1; @@ -27,14 +32,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.foo = function () { }; return C; diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks4.js b/tests/baselines/reference/overloadOnConstConstraintChecks4.js index 0f436a5f0b2..3f7664ff6c8 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks4.js +++ b/tests/baselines/reference/overloadOnConstConstraintChecks4.js @@ -14,11 +14,16 @@ function foo(name: any): Z { //// [overloadOnConstConstraintChecks4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Z = (function () { function Z() { } @@ -27,7 +32,7 @@ var Z = (function () { var A = (function (_super) { __extends(A, _super); function A() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = 1; return _this; } @@ -36,14 +41,14 @@ var A = (function (_super) { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.foo = function () { }; return C; diff --git a/tests/baselines/reference/overloadOnConstantsInvalidOverload1.js b/tests/baselines/reference/overloadOnConstantsInvalidOverload1.js index e3f58c0f7d0..5488ea03ee8 100644 --- a/tests/baselines/reference/overloadOnConstantsInvalidOverload1.js +++ b/tests/baselines/reference/overloadOnConstantsInvalidOverload1.js @@ -12,11 +12,16 @@ function foo(name: "DIV"): Derived2 { foo("HI"); //// [overloadOnConstantsInvalidOverload1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -26,7 +31,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.prototype.bar = function () { }; return Derived1; @@ -34,7 +39,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.prototype.baz = function () { }; return Derived2; @@ -42,7 +47,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived3.prototype.biz = function () { }; return Derived3; diff --git a/tests/baselines/reference/overloadResolution.js b/tests/baselines/reference/overloadResolution.js index e5cc35c39c4..32040c082ee 100644 --- a/tests/baselines/reference/overloadResolution.js +++ b/tests/baselines/reference/overloadResolution.js @@ -95,11 +95,16 @@ var s = fn5((n) => n.substr(0)); //// [overloadResolution.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var SomeBase = (function () { function SomeBase() { } @@ -108,21 +113,21 @@ var SomeBase = (function () { var SomeDerived1 = (function (_super) { __extends(SomeDerived1, _super); function SomeDerived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived1; }(SomeBase)); var SomeDerived2 = (function (_super) { __extends(SomeDerived2, _super); function SomeDerived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived2; }(SomeBase)); var SomeDerived3 = (function (_super) { __extends(SomeDerived3, _super); function SomeDerived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived3; }(SomeBase)); diff --git a/tests/baselines/reference/overloadResolutionClassConstructors.js b/tests/baselines/reference/overloadResolutionClassConstructors.js index 7c8b2e2ccb6..5a8c7c0838b 100644 --- a/tests/baselines/reference/overloadResolutionClassConstructors.js +++ b/tests/baselines/reference/overloadResolutionClassConstructors.js @@ -102,11 +102,16 @@ new fn5((n) => n.blah); // Error //// [overloadResolutionClassConstructors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var SomeBase = (function () { function SomeBase() { } @@ -115,21 +120,21 @@ var SomeBase = (function () { var SomeDerived1 = (function (_super) { __extends(SomeDerived1, _super); function SomeDerived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived1; }(SomeBase)); var SomeDerived2 = (function (_super) { __extends(SomeDerived2, _super); function SomeDerived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived2; }(SomeBase)); var SomeDerived3 = (function (_super) { __extends(SomeDerived3, _super); function SomeDerived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived3; }(SomeBase)); diff --git a/tests/baselines/reference/overloadResolutionConstructors.js b/tests/baselines/reference/overloadResolutionConstructors.js index 44bbfbcec2b..32f350bdc2e 100644 --- a/tests/baselines/reference/overloadResolutionConstructors.js +++ b/tests/baselines/reference/overloadResolutionConstructors.js @@ -103,11 +103,16 @@ var s = new fn5((n) => n.substr(0)); //// [overloadResolutionConstructors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var SomeBase = (function () { function SomeBase() { } @@ -116,21 +121,21 @@ var SomeBase = (function () { var SomeDerived1 = (function (_super) { __extends(SomeDerived1, _super); function SomeDerived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived1; }(SomeBase)); var SomeDerived2 = (function (_super) { __extends(SomeDerived2, _super); function SomeDerived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived2; }(SomeBase)); var SomeDerived3 = (function (_super) { __extends(SomeDerived3, _super); function SomeDerived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived3; }(SomeBase)); diff --git a/tests/baselines/reference/overloadingOnConstants1.js b/tests/baselines/reference/overloadingOnConstants1.js index 96f4f7baf24..c741abade66 100644 --- a/tests/baselines/reference/overloadingOnConstants1.js +++ b/tests/baselines/reference/overloadingOnConstants1.js @@ -26,11 +26,16 @@ var htmlDivElement2: Derived1 = d2.createElement("div"); var htmlSpanElement2: Derived1 = d2.createElement("span"); //// [overloadingOnConstants1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -40,7 +45,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.prototype.bar = function () { }; return Derived1; @@ -48,7 +53,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.prototype.baz = function () { }; return Derived2; @@ -56,7 +61,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived3.prototype.biz = function () { }; return Derived3; diff --git a/tests/baselines/reference/overloadingOnConstants2.js b/tests/baselines/reference/overloadingOnConstants2.js index 0c34d0f4b76..f415df84a47 100644 --- a/tests/baselines/reference/overloadingOnConstants2.js +++ b/tests/baselines/reference/overloadingOnConstants2.js @@ -28,11 +28,16 @@ var e: E = bar("bye", []); // E var f: C = bar("um", []); // C //// [overloadingOnConstants2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { this.x = 1; @@ -42,7 +47,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/overridingPrivateStaticMembers.js b/tests/baselines/reference/overridingPrivateStaticMembers.js index ca5616450ba..0b4e5672b5e 100644 --- a/tests/baselines/reference/overridingPrivateStaticMembers.js +++ b/tests/baselines/reference/overridingPrivateStaticMembers.js @@ -8,11 +8,16 @@ class Derived2 extends Base2 { } //// [overridingPrivateStaticMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base2 = (function () { function Base2() { } @@ -21,7 +26,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/parseErrorInHeritageClause1.js b/tests/baselines/reference/parseErrorInHeritageClause1.js index a9ca0a6db73..735c756fd1f 100644 --- a/tests/baselines/reference/parseErrorInHeritageClause1.js +++ b/tests/baselines/reference/parseErrorInHeritageClause1.js @@ -3,15 +3,20 @@ class C extends A # { } //// [parseErrorInHeritageClause1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parser509630.js b/tests/baselines/reference/parser509630.js index d3648dc5b64..8b963bf0674 100644 --- a/tests/baselines/reference/parser509630.js +++ b/tests/baselines/reference/parser509630.js @@ -7,11 +7,16 @@ class Any extends Type { //// [parser509630.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Type = (function () { function Type() { this.examples = []; // typing here @@ -21,7 +26,7 @@ var Type = (function () { var Any = (function (_super) { __extends(Any, _super); function Any() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Any; }(Type)); diff --git a/tests/baselines/reference/parserAstSpans1.js b/tests/baselines/reference/parserAstSpans1.js index 6b86353b959..ed4943046fa 100644 --- a/tests/baselines/reference/parserAstSpans1.js +++ b/tests/baselines/reference/parserAstSpans1.js @@ -220,11 +220,16 @@ class c6 extends c5 { } //// [parserAstSpans1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var c1 = (function () { function c1() { } @@ -363,7 +368,7 @@ c2_i.nc_f1(); var c4 = (function (_super) { __extends(c4, _super); function c4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return c4; }(c2)); diff --git a/tests/baselines/reference/parserClassDeclaration1.js b/tests/baselines/reference/parserClassDeclaration1.js index a61b492b7a9..85fe94e04cc 100644 --- a/tests/baselines/reference/parserClassDeclaration1.js +++ b/tests/baselines/reference/parserClassDeclaration1.js @@ -3,15 +3,20 @@ class C extends A extends B { } //// [parserClassDeclaration1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserClassDeclaration3.js b/tests/baselines/reference/parserClassDeclaration3.js index f58f0ab00cb..d627784985d 100644 --- a/tests/baselines/reference/parserClassDeclaration3.js +++ b/tests/baselines/reference/parserClassDeclaration3.js @@ -3,15 +3,20 @@ class C implements A extends B { } //// [parserClassDeclaration3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); diff --git a/tests/baselines/reference/parserClassDeclaration4.js b/tests/baselines/reference/parserClassDeclaration4.js index 912aa8c6581..318833c5e91 100644 --- a/tests/baselines/reference/parserClassDeclaration4.js +++ b/tests/baselines/reference/parserClassDeclaration4.js @@ -3,15 +3,20 @@ class C extends A implements B extends C { } //// [parserClassDeclaration4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserClassDeclaration5.js b/tests/baselines/reference/parserClassDeclaration5.js index 054aaf0eb7a..e5b2c337214 100644 --- a/tests/baselines/reference/parserClassDeclaration5.js +++ b/tests/baselines/reference/parserClassDeclaration5.js @@ -3,15 +3,20 @@ class C extends A implements B implements C { } //// [parserClassDeclaration5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserClassDeclaration6.js b/tests/baselines/reference/parserClassDeclaration6.js index 1423edfe037..0d6049c9ba9 100644 --- a/tests/baselines/reference/parserClassDeclaration6.js +++ b/tests/baselines/reference/parserClassDeclaration6.js @@ -3,15 +3,20 @@ class C extends A, B { } //// [parserClassDeclaration6.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js index aa0679bb8f5..30f2e7f5698 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js @@ -3,15 +3,20 @@ class C extends A, { } //// [parserErrorRecovery_ExtendsOrImplementsClause2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js index 1308c7c194b..42947c5fcb8 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js @@ -3,15 +3,20 @@ class C extends A implements { } //// [parserErrorRecovery_ExtendsOrImplementsClause4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js index b1471628fbd..1e62709949d 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js @@ -3,15 +3,20 @@ class C extends A, implements B, { } //// [parserErrorRecovery_ExtendsOrImplementsClause5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserExportAssignment9.errors.txt b/tests/baselines/reference/parserExportAssignment9.errors.txt new file mode 100644 index 00000000000..818b60cfc98 --- /dev/null +++ b/tests/baselines/reference/parserExportAssignment9.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment9.ts(2,3): error TS1319: A default export can only be used in an ECMAScript-style module. +tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment9.ts(6,3): error TS1319: A default export can only be used in an ECMAScript-style module. + + +==== tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment9.ts (2 errors) ==== + namespace Foo { + export default foo; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1319: A default export can only be used in an ECMAScript-style module. + } + + module Bar { + export default bar; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1319: A default export can only be used in an ECMAScript-style module. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserExportAssignment9.js b/tests/baselines/reference/parserExportAssignment9.js new file mode 100644 index 00000000000..2600ae629e9 --- /dev/null +++ b/tests/baselines/reference/parserExportAssignment9.js @@ -0,0 +1,18 @@ +//// [parserExportAssignment9.ts] +namespace Foo { + export default foo; +} + +module Bar { + export default bar; +} + +//// [parserExportAssignment9.js] +var Foo; +(function (Foo) { + export default foo; +})(Foo || (Foo = {})); +var Bar; +(function (Bar) { + export default bar; +})(Bar || (Bar = {})); diff --git a/tests/baselines/reference/parserGenericsInTypeContexts1.js b/tests/baselines/reference/parserGenericsInTypeContexts1.js index 641d296dc43..ef5452a1638 100644 --- a/tests/baselines/reference/parserGenericsInTypeContexts1.js +++ b/tests/baselines/reference/parserGenericsInTypeContexts1.js @@ -18,15 +18,20 @@ function f2(): F { //// [parserGenericsInTypeContexts1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserGenericsInTypeContexts2.js b/tests/baselines/reference/parserGenericsInTypeContexts2.js index b0f14a090ae..9302db655bf 100644 --- a/tests/baselines/reference/parserGenericsInTypeContexts2.js +++ b/tests/baselines/reference/parserGenericsInTypeContexts2.js @@ -18,15 +18,20 @@ function f2(): F, Y>> { //// [parserGenericsInTypeContexts2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserRealSource10.js b/tests/baselines/reference/parserRealSource10.js index 11cfbdfa1f2..0d42dc5f47b 100644 --- a/tests/baselines/reference/parserRealSource10.js +++ b/tests/baselines/reference/parserRealSource10.js @@ -458,11 +458,16 @@ module TypeScript { //// [parserRealSource10.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); /// var TypeScript; (function (TypeScript) { diff --git a/tests/baselines/reference/parserRealSource11.js b/tests/baselines/reference/parserRealSource11.js index eb05d13f4ed..0d942cb1c68 100644 --- a/tests/baselines/reference/parserRealSource11.js +++ b/tests/baselines/reference/parserRealSource11.js @@ -2367,11 +2367,16 @@ module TypeScript { //// [parserRealSource11.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); /// var TypeScript; (function (TypeScript) { diff --git a/tests/baselines/reference/parserStrictMode15.errors.txt b/tests/baselines/reference/parserStrictMode15.errors.txt index 0bcaaf33786..831d214c9fb 100644 --- a/tests/baselines/reference/parserStrictMode15.errors.txt +++ b/tests/baselines/reference/parserStrictMode15.errors.txt @@ -1,11 +1,14 @@ tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode15.ts(2,8): error TS1102: 'delete' cannot be called on an identifier in strict mode. tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode15.ts(2,8): error TS2304: Cannot find name 'a'. +tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode15.ts(2,8): error TS2703: The operand of a delete operator must be a property reference -==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode15.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode15.ts (3 errors) ==== "use strict"; delete a; ~ !!! error TS1102: 'delete' cannot be called on an identifier in strict mode. ~ -!!! error TS2304: Cannot find name 'a'. \ No newline at end of file +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS2703: The operand of a delete operator must be a property reference \ No newline at end of file diff --git a/tests/baselines/reference/parserStrictMode16.errors.txt b/tests/baselines/reference/parserStrictMode16.errors.txt new file mode 100644 index 00000000000..fe99c337232 --- /dev/null +++ b/tests/baselines/reference/parserStrictMode16.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts(2,8): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts(3,8): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts(4,8): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts(5,8): error TS2703: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts (4 errors) ==== + "use strict"; + delete this; + ~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + delete 1; + ~ +!!! error TS2703: The operand of a delete operator must be a property reference + delete null; + ~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference + delete "a"; + ~~~ +!!! error TS2703: The operand of a delete operator must be a property reference \ No newline at end of file diff --git a/tests/baselines/reference/parserharness.js b/tests/baselines/reference/parserharness.js index 14ce4338176..5090c33bdc8 100644 --- a/tests/baselines/reference/parserharness.js +++ b/tests/baselines/reference/parserharness.js @@ -2096,11 +2096,16 @@ module Harness { // See the License for the specific language governing permissions and // limitations under the License. // -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); /// /// /// diff --git a/tests/baselines/reference/partiallyAnnotatedFunctionInferenceError.js b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceError.js index 9702595fffb..88439493a50 100644 --- a/tests/baselines/reference/partiallyAnnotatedFunctionInferenceError.js +++ b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceError.js @@ -16,11 +16,16 @@ testError((t1, t2, t3: D) => {}) //// [partiallyAnnotatedFunctionInferenceError.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -29,7 +34,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.js b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.js index d20b35625e9..6a46935b224 100644 --- a/tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.js +++ b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.js @@ -35,11 +35,16 @@ testRest((t2, ...t3: D[]) => {}) //// [partiallyAnnotatedFunctionInferenceWithTypeParameter.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -48,7 +53,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution3_node.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution3_node.trace.json index 5c7c143f604..c61871b34c0 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution3_node.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution3_node.trace.json @@ -3,47 +3,26 @@ "Explicitly specified module resolution kind: 'NodeJs'.", "'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'folder2/file2'", "Resolving module name 'folder2/file2' relative to base url 'c:/root' - 'c:/root/folder2/file2'.", - "Loading module as file / folder, candidate module location 'c:/root/folder2/file2'.", + "Loading module as file / folder, candidate module location 'c:/root/folder2/file2', target file type 'TypeScript'.", "File 'c:/root/folder2/file2.ts' exist - use it as a name resolution result.", "======== Module name 'folder2/file2' was successfully resolved to 'c:/root/folder2/file2.ts'. ========", "======== Resolving module './file3' from 'c:/root/folder2/file2.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module as file / folder, candidate module location 'c:/root/folder2/file3'.", + "Loading module as file / folder, candidate module location 'c:/root/folder2/file3', target file type 'TypeScript'.", "File 'c:/root/folder2/file3.ts' exist - use it as a name resolution result.", "======== Module name './file3' was successfully resolved to 'c:/root/folder2/file3.ts'. ========", "======== Resolving module 'file4' from 'c:/root/folder2/file2.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'file4'", "Resolving module name 'file4' relative to base url 'c:/root' - 'c:/root/file4'.", - "Loading module as file / folder, candidate module location 'c:/root/file4'.", + "Loading module as file / folder, candidate module location 'c:/root/file4', target file type 'TypeScript'.", "File 'c:/root/file4.ts' does not exist.", "File 'c:/root/file4.tsx' does not exist.", "File 'c:/root/file4.d.ts' does not exist.", - "File 'c:/root/file4/package.json' does not exist.", - "File 'c:/root/file4/index.ts' does not exist.", - "File 'c:/root/file4/index.tsx' does not exist.", - "File 'c:/root/file4/index.d.ts' does not exist.", - "Loading module 'file4' from 'node_modules' folder.", - "File 'c:/root/folder2/node_modules/file4.ts' does not exist.", - "File 'c:/root/folder2/node_modules/file4.tsx' does not exist.", - "File 'c:/root/folder2/node_modules/file4.d.ts' does not exist.", - "File 'c:/root/folder2/node_modules/file4/package.json' does not exist.", - "File 'c:/root/folder2/node_modules/file4/index.ts' does not exist.", - "File 'c:/root/folder2/node_modules/file4/index.tsx' does not exist.", - "File 'c:/root/folder2/node_modules/file4/index.d.ts' does not exist.", - "File 'c:/root/folder2/node_modules/@types/file4.d.ts' does not exist.", - "File 'c:/root/folder2/node_modules/@types/file4/package.json' does not exist.", - "File 'c:/root/folder2/node_modules/@types/file4/index.d.ts' does not exist.", - "File 'c:/root/node_modules/file4.ts' does not exist.", - "File 'c:/root/node_modules/file4.tsx' does not exist.", - "File 'c:/root/node_modules/file4.d.ts' does not exist.", - "File 'c:/root/node_modules/file4/package.json' does not exist.", - "File 'c:/root/node_modules/file4/index.ts' does not exist.", - "File 'c:/root/node_modules/file4/index.tsx' does not exist.", - "File 'c:/root/node_modules/file4/index.d.ts' does not exist.", - "File 'c:/root/node_modules/@types/file4.d.ts' does not exist.", - "File 'c:/root/node_modules/@types/file4/package.json' does not exist.", - "File 'c:/root/node_modules/@types/file4/index.d.ts' does not exist.", + "Directory 'c:/root/file4' does not exist, skipping all lookups in it.", + "Loading module 'file4' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory 'c:/root/folder2/node_modules' does not exist, skipping all lookups in it.", + "Directory 'c:/root/node_modules' does not exist, skipping all lookups in it.", "File 'c:/node_modules/file4.ts' does not exist.", "File 'c:/node_modules/file4.tsx' does not exist.", "File 'c:/node_modules/file4.d.ts' does not exist.", diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution4_node.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution4_node.trace.json index 5c7c143f604..c61871b34c0 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution4_node.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution4_node.trace.json @@ -3,47 +3,26 @@ "Explicitly specified module resolution kind: 'NodeJs'.", "'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'folder2/file2'", "Resolving module name 'folder2/file2' relative to base url 'c:/root' - 'c:/root/folder2/file2'.", - "Loading module as file / folder, candidate module location 'c:/root/folder2/file2'.", + "Loading module as file / folder, candidate module location 'c:/root/folder2/file2', target file type 'TypeScript'.", "File 'c:/root/folder2/file2.ts' exist - use it as a name resolution result.", "======== Module name 'folder2/file2' was successfully resolved to 'c:/root/folder2/file2.ts'. ========", "======== Resolving module './file3' from 'c:/root/folder2/file2.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module as file / folder, candidate module location 'c:/root/folder2/file3'.", + "Loading module as file / folder, candidate module location 'c:/root/folder2/file3', target file type 'TypeScript'.", "File 'c:/root/folder2/file3.ts' exist - use it as a name resolution result.", "======== Module name './file3' was successfully resolved to 'c:/root/folder2/file3.ts'. ========", "======== Resolving module 'file4' from 'c:/root/folder2/file2.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'file4'", "Resolving module name 'file4' relative to base url 'c:/root' - 'c:/root/file4'.", - "Loading module as file / folder, candidate module location 'c:/root/file4'.", + "Loading module as file / folder, candidate module location 'c:/root/file4', target file type 'TypeScript'.", "File 'c:/root/file4.ts' does not exist.", "File 'c:/root/file4.tsx' does not exist.", "File 'c:/root/file4.d.ts' does not exist.", - "File 'c:/root/file4/package.json' does not exist.", - "File 'c:/root/file4/index.ts' does not exist.", - "File 'c:/root/file4/index.tsx' does not exist.", - "File 'c:/root/file4/index.d.ts' does not exist.", - "Loading module 'file4' from 'node_modules' folder.", - "File 'c:/root/folder2/node_modules/file4.ts' does not exist.", - "File 'c:/root/folder2/node_modules/file4.tsx' does not exist.", - "File 'c:/root/folder2/node_modules/file4.d.ts' does not exist.", - "File 'c:/root/folder2/node_modules/file4/package.json' does not exist.", - "File 'c:/root/folder2/node_modules/file4/index.ts' does not exist.", - "File 'c:/root/folder2/node_modules/file4/index.tsx' does not exist.", - "File 'c:/root/folder2/node_modules/file4/index.d.ts' does not exist.", - "File 'c:/root/folder2/node_modules/@types/file4.d.ts' does not exist.", - "File 'c:/root/folder2/node_modules/@types/file4/package.json' does not exist.", - "File 'c:/root/folder2/node_modules/@types/file4/index.d.ts' does not exist.", - "File 'c:/root/node_modules/file4.ts' does not exist.", - "File 'c:/root/node_modules/file4.tsx' does not exist.", - "File 'c:/root/node_modules/file4.d.ts' does not exist.", - "File 'c:/root/node_modules/file4/package.json' does not exist.", - "File 'c:/root/node_modules/file4/index.ts' does not exist.", - "File 'c:/root/node_modules/file4/index.tsx' does not exist.", - "File 'c:/root/node_modules/file4/index.d.ts' does not exist.", - "File 'c:/root/node_modules/@types/file4.d.ts' does not exist.", - "File 'c:/root/node_modules/@types/file4/package.json' does not exist.", - "File 'c:/root/node_modules/@types/file4/index.d.ts' does not exist.", + "Directory 'c:/root/file4' does not exist, skipping all lookups in it.", + "Loading module 'file4' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory 'c:/root/folder2/node_modules' does not exist, skipping all lookups in it.", + "Directory 'c:/root/node_modules' does not exist, skipping all lookups in it.", "File 'c:/node_modules/file4.ts' does not exist.", "File 'c:/node_modules/file4.tsx' does not exist.", "File 'c:/node_modules/file4.d.ts' does not exist.", diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution5_classic.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution5_classic.trace.json index 6c899bf028e..9108b25e88c 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution5_classic.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution5_classic.trace.json @@ -13,9 +13,6 @@ "'paths' option is specified, looking for a pattern to match module name 'folder3/file2'.", "Module name 'folder3/file2', matched pattern '*'.", "Trying substitution '*', candidate module location: 'folder3/file2'.", - "File 'c:/root/folder3/file2.ts' does not exist.", - "File 'c:/root/folder3/file2.tsx' does not exist.", - "File 'c:/root/folder3/file2.d.ts' does not exist.", "Trying substitution 'generated/*', candidate module location: 'generated/folder3/file2'.", "File 'c:/root/generated/folder3/file2.ts' exist - use it as a name resolution result.", "======== Module name 'folder3/file2' was successfully resolved to 'c:/root/generated/folder3/file2.ts'. ========", diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution5_node.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution5_node.trace.json index ebef311d2a6..d70942a4b47 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution5_node.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution5_node.trace.json @@ -5,7 +5,7 @@ "'paths' option is specified, looking for a pattern to match module name 'folder2/file1'.", "Module name 'folder2/file1', matched pattern '*'.", "Trying substitution '*', candidate module location: 'folder2/file1'.", - "Loading module as file / folder, candidate module location 'c:/root/folder2/file1'.", + "Loading module as file / folder, candidate module location 'c:/root/folder2/file1', target file type 'TypeScript'.", "File 'c:/root/folder2/file1.ts' exist - use it as a name resolution result.", "======== Module name 'folder2/file1' was successfully resolved to 'c:/root/folder2/file1.ts'. ========", "======== Resolving module 'folder3/file2' from 'c:/root/folder1/file1.ts'. ========", @@ -14,16 +14,9 @@ "'paths' option is specified, looking for a pattern to match module name 'folder3/file2'.", "Module name 'folder3/file2', matched pattern '*'.", "Trying substitution '*', candidate module location: 'folder3/file2'.", - "Loading module as file / folder, candidate module location 'c:/root/folder3/file2'.", - "File 'c:/root/folder3/file2.ts' does not exist.", - "File 'c:/root/folder3/file2.tsx' does not exist.", - "File 'c:/root/folder3/file2.d.ts' does not exist.", - "File 'c:/root/folder3/file2/package.json' does not exist.", - "File 'c:/root/folder3/file2/index.ts' does not exist.", - "File 'c:/root/folder3/file2/index.tsx' does not exist.", - "File 'c:/root/folder3/file2/index.d.ts' does not exist.", + "Loading module as file / folder, candidate module location 'c:/root/folder3/file2', target file type 'TypeScript'.", "Trying substitution 'generated/*', candidate module location: 'generated/folder3/file2'.", - "Loading module as file / folder, candidate module location 'c:/root/generated/folder3/file2'.", + "Loading module as file / folder, candidate module location 'c:/root/generated/folder3/file2', target file type 'TypeScript'.", "File 'c:/root/generated/folder3/file2.ts' exist - use it as a name resolution result.", "======== Module name 'folder3/file2' was successfully resolved to 'c:/root/generated/folder3/file2.ts'. ========", "======== Resolving module 'components/file3' from 'c:/root/folder1/file1.ts'. ========", @@ -32,7 +25,7 @@ "'paths' option is specified, looking for a pattern to match module name 'components/file3'.", "Module name 'components/file3', matched pattern 'components/*'.", "Trying substitution 'shared/components/*', candidate module location: 'shared/components/file3'.", - "Loading module as file / folder, candidate module location 'c:/root/shared/components/file3'.", + "Loading module as file / folder, candidate module location 'c:/root/shared/components/file3', target file type 'TypeScript'.", "File 'c:/root/shared/components/file3.ts' does not exist.", "File 'c:/root/shared/components/file3.tsx' does not exist.", "File 'c:/root/shared/components/file3.d.ts' does not exist.", @@ -47,44 +40,20 @@ "'paths' option is specified, looking for a pattern to match module name 'file4'.", "Module name 'file4', matched pattern '*'.", "Trying substitution '*', candidate module location: 'file4'.", - "Loading module as file / folder, candidate module location 'c:/root/file4'.", + "Loading module as file / folder, candidate module location 'c:/root/file4', target file type 'TypeScript'.", "File 'c:/root/file4.ts' does not exist.", "File 'c:/root/file4.tsx' does not exist.", "File 'c:/root/file4.d.ts' does not exist.", - "File 'c:/root/file4/package.json' does not exist.", - "File 'c:/root/file4/index.ts' does not exist.", - "File 'c:/root/file4/index.tsx' does not exist.", - "File 'c:/root/file4/index.d.ts' does not exist.", + "Directory 'c:/root/file4' does not exist, skipping all lookups in it.", "Trying substitution 'generated/*', candidate module location: 'generated/file4'.", - "Loading module as file / folder, candidate module location 'c:/root/generated/file4'.", + "Loading module as file / folder, candidate module location 'c:/root/generated/file4', target file type 'TypeScript'.", "File 'c:/root/generated/file4.ts' does not exist.", "File 'c:/root/generated/file4.tsx' does not exist.", "File 'c:/root/generated/file4.d.ts' does not exist.", - "File 'c:/root/generated/file4/package.json' does not exist.", - "File 'c:/root/generated/file4/index.ts' does not exist.", - "File 'c:/root/generated/file4/index.tsx' does not exist.", - "File 'c:/root/generated/file4/index.d.ts' does not exist.", - "Loading module 'file4' from 'node_modules' folder.", - "File 'c:/root/folder1/node_modules/file4.ts' does not exist.", - "File 'c:/root/folder1/node_modules/file4.tsx' does not exist.", - "File 'c:/root/folder1/node_modules/file4.d.ts' does not exist.", - "File 'c:/root/folder1/node_modules/file4/package.json' does not exist.", - "File 'c:/root/folder1/node_modules/file4/index.ts' does not exist.", - "File 'c:/root/folder1/node_modules/file4/index.tsx' does not exist.", - "File 'c:/root/folder1/node_modules/file4/index.d.ts' does not exist.", - "File 'c:/root/folder1/node_modules/@types/file4.d.ts' does not exist.", - "File 'c:/root/folder1/node_modules/@types/file4/package.json' does not exist.", - "File 'c:/root/folder1/node_modules/@types/file4/index.d.ts' does not exist.", - "File 'c:/root/node_modules/file4.ts' does not exist.", - "File 'c:/root/node_modules/file4.tsx' does not exist.", - "File 'c:/root/node_modules/file4.d.ts' does not exist.", - "File 'c:/root/node_modules/file4/package.json' does not exist.", - "File 'c:/root/node_modules/file4/index.ts' does not exist.", - "File 'c:/root/node_modules/file4/index.tsx' does not exist.", - "File 'c:/root/node_modules/file4/index.d.ts' does not exist.", - "File 'c:/root/node_modules/@types/file4.d.ts' does not exist.", - "File 'c:/root/node_modules/@types/file4/package.json' does not exist.", - "File 'c:/root/node_modules/@types/file4/index.d.ts' does not exist.", + "Directory 'c:/root/generated/file4' does not exist, skipping all lookups in it.", + "Loading module 'file4' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory 'c:/root/folder1/node_modules' does not exist, skipping all lookups in it.", + "Directory 'c:/root/node_modules' does not exist, skipping all lookups in it.", "File 'c:/node_modules/file4.ts' exist - use it as a name resolution result.", "Resolving real path for 'c:/node_modules/file4.ts', result 'c:/node_modules/file4.ts'", "======== Module name 'file4' was successfully resolved to 'c:/node_modules/file4.ts'. ========" diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution6_classic.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution6_classic.trace.json index d50a6c78ed7..ec865b7ac66 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution6_classic.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution6_classic.trace.json @@ -6,9 +6,6 @@ "Checking if 'c:/root/generated/src/' is the longest matching prefix for 'c:/root/src/project/file3' - 'false'.", "Longest matching prefix for 'c:/root/src/project/file3' is 'c:/root/src/'", "Loading 'project/file3' from the root dir 'c:/root/src/', candidate location 'c:/root/src/project/file3'", - "File 'c:/root/src/project/file3.ts' does not exist.", - "File 'c:/root/src/project/file3.tsx' does not exist.", - "File 'c:/root/src/project/file3.d.ts' does not exist.", "Trying other entries in 'rootDirs'", "Loading 'project/file3' from the root dir 'c:/root/generated/src', candidate location 'c:/root/generated/src/project/file3'", "File 'c:/root/generated/src/project/file3.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution6_node.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution6_node.trace.json index 7c5e76a2847..d623e166ef0 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution6_node.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution6_node.trace.json @@ -6,17 +6,11 @@ "Checking if 'c:/root/generated/src/' is the longest matching prefix for 'c:/root/src/project/file3' - 'false'.", "Longest matching prefix for 'c:/root/src/project/file3' is 'c:/root/src/'", "Loading 'project/file3' from the root dir 'c:/root/src/', candidate location 'c:/root/src/project/file3'", - "Loading module as file / folder, candidate module location 'c:/root/src/project/file3'.", - "File 'c:/root/src/project/file3.ts' does not exist.", - "File 'c:/root/src/project/file3.tsx' does not exist.", - "File 'c:/root/src/project/file3.d.ts' does not exist.", - "File 'c:/root/src/project/file3/package.json' does not exist.", - "File 'c:/root/src/project/file3/index.ts' does not exist.", - "File 'c:/root/src/project/file3/index.tsx' does not exist.", - "File 'c:/root/src/project/file3/index.d.ts' does not exist.", + "Loading module as file / folder, candidate module location 'c:/root/src/project/file3', target file type 'TypeScript'.", + "Directory 'c:/root/src/project' does not exist, skipping all lookups in it.", "Trying other entries in 'rootDirs'", "Loading 'project/file3' from the root dir 'c:/root/generated/src', candidate location 'c:/root/generated/src/project/file3'", - "Loading module as file / folder, candidate module location 'c:/root/generated/src/project/file3'.", + "Loading module as file / folder, candidate module location 'c:/root/generated/src/project/file3', target file type 'TypeScript'.", "File 'c:/root/generated/src/project/file3.ts' exist - use it as a name resolution result.", "======== Module name './project/file3' was successfully resolved to 'c:/root/generated/src/project/file3.ts'. ========", "======== Resolving module '../file2' from 'c:/root/generated/src/project/file3.ts'. ========", @@ -26,17 +20,14 @@ "Checking if 'c:/root/generated/src/' is the longest matching prefix for 'c:/root/generated/src/file2' - 'true'.", "Longest matching prefix for 'c:/root/generated/src/file2' is 'c:/root/generated/src/'", "Loading 'file2' from the root dir 'c:/root/generated/src/', candidate location 'c:/root/generated/src/file2'", - "Loading module as file / folder, candidate module location 'c:/root/generated/src/file2'.", + "Loading module as file / folder, candidate module location 'c:/root/generated/src/file2', target file type 'TypeScript'.", "File 'c:/root/generated/src/file2.ts' does not exist.", "File 'c:/root/generated/src/file2.tsx' does not exist.", "File 'c:/root/generated/src/file2.d.ts' does not exist.", - "File 'c:/root/generated/src/file2/package.json' does not exist.", - "File 'c:/root/generated/src/file2/index.ts' does not exist.", - "File 'c:/root/generated/src/file2/index.tsx' does not exist.", - "File 'c:/root/generated/src/file2/index.d.ts' does not exist.", + "Directory 'c:/root/generated/src/file2' does not exist, skipping all lookups in it.", "Trying other entries in 'rootDirs'", "Loading 'file2' from the root dir 'c:/root/src', candidate location 'c:/root/src/file2'", - "Loading module as file / folder, candidate module location 'c:/root/src/file2'.", + "Loading module as file / folder, candidate module location 'c:/root/src/file2', target file type 'TypeScript'.", "File 'c:/root/src/file2.ts' does not exist.", "File 'c:/root/src/file2.tsx' does not exist.", "File 'c:/root/src/file2.d.ts' does not exist.", diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution7_classic.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution7_classic.trace.json index 85373855eb5..61056ea8502 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution7_classic.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution7_classic.trace.json @@ -6,9 +6,6 @@ "Checking if 'c:/root/generated/src/' is the longest matching prefix for 'c:/root/src/project/file2' - 'false'.", "Longest matching prefix for 'c:/root/src/project/file2' is 'c:/root/src/'", "Loading 'project/file2' from the root dir 'c:/root/src/', candidate location 'c:/root/src/project/file2'", - "File 'c:/root/src/project/file2.ts' does not exist.", - "File 'c:/root/src/project/file2.tsx' does not exist.", - "File 'c:/root/src/project/file2.d.ts' does not exist.", "Trying other entries in 'rootDirs'", "Loading 'project/file2' from the root dir 'c:/root/generated/src', candidate location 'c:/root/generated/src/project/file2'", "File 'c:/root/generated/src/project/file2.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution7_node.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution7_node.trace.json index 31440cca28e..4cc7dbae1c1 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution7_node.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution7_node.trace.json @@ -6,17 +6,11 @@ "Checking if 'c:/root/generated/src/' is the longest matching prefix for 'c:/root/src/project/file2' - 'false'.", "Longest matching prefix for 'c:/root/src/project/file2' is 'c:/root/src/'", "Loading 'project/file2' from the root dir 'c:/root/src/', candidate location 'c:/root/src/project/file2'", - "Loading module as file / folder, candidate module location 'c:/root/src/project/file2'.", - "File 'c:/root/src/project/file2.ts' does not exist.", - "File 'c:/root/src/project/file2.tsx' does not exist.", - "File 'c:/root/src/project/file2.d.ts' does not exist.", - "File 'c:/root/src/project/file2/package.json' does not exist.", - "File 'c:/root/src/project/file2/index.ts' does not exist.", - "File 'c:/root/src/project/file2/index.tsx' does not exist.", - "File 'c:/root/src/project/file2/index.d.ts' does not exist.", + "Loading module as file / folder, candidate module location 'c:/root/src/project/file2', target file type 'TypeScript'.", + "Directory 'c:/root/src/project' does not exist, skipping all lookups in it.", "Trying other entries in 'rootDirs'", "Loading 'project/file2' from the root dir 'c:/root/generated/src', candidate location 'c:/root/generated/src/project/file2'", - "Loading module as file / folder, candidate module location 'c:/root/generated/src/project/file2'.", + "Loading module as file / folder, candidate module location 'c:/root/generated/src/project/file2', target file type 'TypeScript'.", "File 'c:/root/generated/src/project/file2.ts' exist - use it as a name resolution result.", "======== Module name './project/file2' was successfully resolved to 'c:/root/generated/src/project/file2.ts'. ========", "======== Resolving module 'module3' from 'c:/root/src/file1.ts'. ========", @@ -25,44 +19,20 @@ "'paths' option is specified, looking for a pattern to match module name 'module3'.", "Module name 'module3', matched pattern '*'.", "Trying substitution '*', candidate module location: 'module3'.", - "Loading module as file / folder, candidate module location 'c:/root/module3'.", + "Loading module as file / folder, candidate module location 'c:/root/module3', target file type 'TypeScript'.", "File 'c:/root/module3.ts' does not exist.", "File 'c:/root/module3.tsx' does not exist.", "File 'c:/root/module3.d.ts' does not exist.", - "File 'c:/root/module3/package.json' does not exist.", - "File 'c:/root/module3/index.ts' does not exist.", - "File 'c:/root/module3/index.tsx' does not exist.", - "File 'c:/root/module3/index.d.ts' does not exist.", + "Directory 'c:/root/module3' does not exist, skipping all lookups in it.", "Trying substitution 'c:/shared/*', candidate module location: 'c:/shared/module3'.", - "Loading module as file / folder, candidate module location 'c:/shared/module3'.", + "Loading module as file / folder, candidate module location 'c:/shared/module3', target file type 'TypeScript'.", "File 'c:/shared/module3.ts' does not exist.", "File 'c:/shared/module3.tsx' does not exist.", "File 'c:/shared/module3.d.ts' does not exist.", - "File 'c:/shared/module3/package.json' does not exist.", - "File 'c:/shared/module3/index.ts' does not exist.", - "File 'c:/shared/module3/index.tsx' does not exist.", - "File 'c:/shared/module3/index.d.ts' does not exist.", - "Loading module 'module3' from 'node_modules' folder.", - "File 'c:/root/src/node_modules/module3.ts' does not exist.", - "File 'c:/root/src/node_modules/module3.tsx' does not exist.", - "File 'c:/root/src/node_modules/module3.d.ts' does not exist.", - "File 'c:/root/src/node_modules/module3/package.json' does not exist.", - "File 'c:/root/src/node_modules/module3/index.ts' does not exist.", - "File 'c:/root/src/node_modules/module3/index.tsx' does not exist.", - "File 'c:/root/src/node_modules/module3/index.d.ts' does not exist.", - "File 'c:/root/src/node_modules/@types/module3.d.ts' does not exist.", - "File 'c:/root/src/node_modules/@types/module3/package.json' does not exist.", - "File 'c:/root/src/node_modules/@types/module3/index.d.ts' does not exist.", - "File 'c:/root/node_modules/module3.ts' does not exist.", - "File 'c:/root/node_modules/module3.tsx' does not exist.", - "File 'c:/root/node_modules/module3.d.ts' does not exist.", - "File 'c:/root/node_modules/module3/package.json' does not exist.", - "File 'c:/root/node_modules/module3/index.ts' does not exist.", - "File 'c:/root/node_modules/module3/index.tsx' does not exist.", - "File 'c:/root/node_modules/module3/index.d.ts' does not exist.", - "File 'c:/root/node_modules/@types/module3.d.ts' does not exist.", - "File 'c:/root/node_modules/@types/module3/package.json' does not exist.", - "File 'c:/root/node_modules/@types/module3/index.d.ts' does not exist.", + "Directory 'c:/shared/module3' does not exist, skipping all lookups in it.", + "Loading module 'module3' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory 'c:/root/src/node_modules' does not exist, skipping all lookups in it.", + "Directory 'c:/root/node_modules' does not exist, skipping all lookups in it.", "File 'c:/node_modules/module3.ts' does not exist.", "File 'c:/node_modules/module3.tsx' does not exist.", "File 'c:/node_modules/module3.d.ts' exist - use it as a name resolution result.", @@ -74,16 +44,13 @@ "'paths' option is specified, looking for a pattern to match module name 'module1'.", "Module name 'module1', matched pattern '*'.", "Trying substitution '*', candidate module location: 'module1'.", - "Loading module as file / folder, candidate module location 'c:/root/module1'.", + "Loading module as file / folder, candidate module location 'c:/root/module1', target file type 'TypeScript'.", "File 'c:/root/module1.ts' does not exist.", "File 'c:/root/module1.tsx' does not exist.", "File 'c:/root/module1.d.ts' does not exist.", - "File 'c:/root/module1/package.json' does not exist.", - "File 'c:/root/module1/index.ts' does not exist.", - "File 'c:/root/module1/index.tsx' does not exist.", - "File 'c:/root/module1/index.d.ts' does not exist.", + "Directory 'c:/root/module1' does not exist, skipping all lookups in it.", "Trying substitution 'c:/shared/*', candidate module location: 'c:/shared/module1'.", - "Loading module as file / folder, candidate module location 'c:/shared/module1'.", + "Loading module as file / folder, candidate module location 'c:/shared/module1', target file type 'TypeScript'.", "File 'c:/shared/module1.ts' does not exist.", "File 'c:/shared/module1.tsx' does not exist.", "File 'c:/shared/module1.d.ts' does not exist.", @@ -98,7 +65,7 @@ "'paths' option is specified, looking for a pattern to match module name 'templates/module2'.", "Module name 'templates/module2', matched pattern 'templates/*'.", "Trying substitution 'generated/src/templates/*', candidate module location: 'generated/src/templates/module2'.", - "Loading module as file / folder, candidate module location 'c:/root/generated/src/templates/module2'.", + "Loading module as file / folder, candidate module location 'c:/root/generated/src/templates/module2', target file type 'TypeScript'.", "File 'c:/root/generated/src/templates/module2.ts' exist - use it as a name resolution result.", "======== Module name 'templates/module2' was successfully resolved to 'c:/root/generated/src/templates/module2.ts'. ========", "======== Resolving module '../file3' from 'c:/root/generated/src/project/file2.ts'. ========", @@ -108,17 +75,14 @@ "Checking if 'c:/root/generated/src/' is the longest matching prefix for 'c:/root/generated/src/file3' - 'true'.", "Longest matching prefix for 'c:/root/generated/src/file3' is 'c:/root/generated/src/'", "Loading 'file3' from the root dir 'c:/root/generated/src/', candidate location 'c:/root/generated/src/file3'", - "Loading module as file / folder, candidate module location 'c:/root/generated/src/file3'.", + "Loading module as file / folder, candidate module location 'c:/root/generated/src/file3', target file type 'TypeScript'.", "File 'c:/root/generated/src/file3.ts' does not exist.", "File 'c:/root/generated/src/file3.tsx' does not exist.", "File 'c:/root/generated/src/file3.d.ts' does not exist.", - "File 'c:/root/generated/src/file3/package.json' does not exist.", - "File 'c:/root/generated/src/file3/index.ts' does not exist.", - "File 'c:/root/generated/src/file3/index.tsx' does not exist.", - "File 'c:/root/generated/src/file3/index.d.ts' does not exist.", + "Directory 'c:/root/generated/src/file3' does not exist, skipping all lookups in it.", "Trying other entries in 'rootDirs'", "Loading 'file3' from the root dir 'c:/root/src', candidate location 'c:/root/src/file3'", - "Loading module as file / folder, candidate module location 'c:/root/src/file3'.", + "Loading module as file / folder, candidate module location 'c:/root/src/file3', target file type 'TypeScript'.", "File 'c:/root/src/file3.ts' does not exist.", "File 'c:/root/src/file3.tsx' does not exist.", "File 'c:/root/src/file3.d.ts' does not exist.", diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_failedLookup.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_failedLookup.trace.json index face88d225e..197b7f5c249 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_failedLookup.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_failedLookup.trace.json @@ -6,27 +6,14 @@ "Module name 'foo', matched pattern 'foo'.", "Trying substitution 'foo/foo.ts', candidate module location: 'foo/foo.ts'.", "File '/foo/foo.ts' does not exist.", - "Loading module 'foo' from 'node_modules' folder.", - "File '/node_modules/foo.ts' does not exist.", - "File '/node_modules/foo.tsx' does not exist.", - "File '/node_modules/foo.d.ts' does not exist.", - "File '/node_modules/foo/package.json' does not exist.", - "File '/node_modules/foo/index.ts' does not exist.", - "File '/node_modules/foo/index.tsx' does not exist.", - "File '/node_modules/foo/index.d.ts' does not exist.", - "File '/node_modules/@types/foo.d.ts' does not exist.", - "File '/node_modules/@types/foo/package.json' does not exist.", - "File '/node_modules/@types/foo/index.d.ts' does not exist.", + "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'foo'", "'paths' option is specified, looking for a pattern to match module name 'foo'.", "Module name 'foo', matched pattern 'foo'.", "Trying substitution 'foo/foo.ts', candidate module location: 'foo/foo.ts'.", "File '/foo/foo.ts' does not exist.", - "Loading module 'foo' from 'node_modules' folder.", - "File '/node_modules/foo.js' does not exist.", - "File '/node_modules/foo.jsx' does not exist.", - "File '/node_modules/foo/package.json' does not exist.", - "File '/node_modules/foo/index.js' does not exist.", - "File '/node_modules/foo/index.jsx' does not exist.", + "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name 'foo' was not resolved. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/plusOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/plusOperatorWithAnyOtherType.errors.txt index 6c0f113b17b..d693aaa17d9 100644 --- a/tests/baselines/reference/plusOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/plusOperatorWithAnyOtherType.errors.txt @@ -1,10 +1,15 @@ -tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(46,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(47,26): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(48,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(34,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(35,24): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(46,26): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(46,33): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(47,26): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(47,33): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(48,26): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(48,38): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(54,1): error TS2695: Left side of comma operator is unused and has no side effects. -==== tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts (4 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts (9 errors) ==== // + operator on any type var ANY: any; @@ -39,7 +44,11 @@ tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWith // any type literal var ResultIsNumber7 = +undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber8 = +null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. // any type expressions var ResultIsNumber9 = +ANY2[0]; @@ -51,14 +60,20 @@ tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWith var ResultIsNumber15 = +A.foo(); var ResultIsNumber16 = +(ANY + ANY1); var ResultIsNumber17 = +(null + undefined); - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber18 = +(null + null); - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber19 = +(undefined + undefined); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // miss assignment operators +ANY; diff --git a/tests/baselines/reference/primitiveMembers.js b/tests/baselines/reference/primitiveMembers.js index 7b94b555eb1..163c5c8873d 100644 --- a/tests/baselines/reference/primitiveMembers.js +++ b/tests/baselines/reference/primitiveMembers.js @@ -32,11 +32,16 @@ class foo extends baz { public bar(){ return undefined}; } //// [primitiveMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x = 5; var r = /yo/; r.source; @@ -63,7 +68,7 @@ var baz = (function () { var foo = (function (_super) { __extends(foo, _super); function foo() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } foo.prototype.bar = function () { return undefined; }; ; diff --git a/tests/baselines/reference/privacyClass.js b/tests/baselines/reference/privacyClass.js index 7e56edf2cf1..4e79f019e5d 100644 --- a/tests/baselines/reference/privacyClass.js +++ b/tests/baselines/reference/privacyClass.js @@ -129,11 +129,16 @@ export class glo_C12_public extends glo_c_private implements glo_i_private, glo //// [privacyClass.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var m1; (function (m1) { var m1_c_public = (function () { @@ -152,21 +157,21 @@ var m1; var m1_C1_private = (function (_super) { __extends(m1_C1_private, _super); function m1_C1_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C1_private; }(m1_c_public)); var m1_C2_private = (function (_super) { __extends(m1_C2_private, _super); function m1_C2_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C2_private; }(m1_c_private)); var m1_C3_public = (function (_super) { __extends(m1_C3_public, _super); function m1_C3_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C3_public; }(m1_c_public)); @@ -174,7 +179,7 @@ var m1; var m1_C4_public = (function (_super) { __extends(m1_C4_public, _super); function m1_C4_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C4_public; }(m1_c_private)); @@ -204,21 +209,21 @@ var m1; var m1_C9_private = (function (_super) { __extends(m1_C9_private, _super); function m1_C9_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C9_private; }(m1_c_public)); var m1_C10_private = (function (_super) { __extends(m1_C10_private, _super); function m1_C10_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C10_private; }(m1_c_private)); var m1_C11_public = (function (_super) { __extends(m1_C11_public, _super); function m1_C11_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C11_public; }(m1_c_public)); @@ -226,7 +231,7 @@ var m1; var m1_C12_public = (function (_super) { __extends(m1_C12_public, _super); function m1_C12_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C12_public; }(m1_c_private)); @@ -250,21 +255,21 @@ var m2; var m2_C1_private = (function (_super) { __extends(m2_C1_private, _super); function m2_C1_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m2_C1_private; }(m2_c_public)); var m2_C2_private = (function (_super) { __extends(m2_C2_private, _super); function m2_C2_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m2_C2_private; }(m2_c_private)); var m2_C3_public = (function (_super) { __extends(m2_C3_public, _super); function m2_C3_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m2_C3_public; }(m2_c_public)); @@ -272,7 +277,7 @@ var m2; var m2_C4_public = (function (_super) { __extends(m2_C4_public, _super); function m2_C4_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m2_C4_public; }(m2_c_private)); @@ -302,21 +307,21 @@ var m2; var m2_C9_private = (function (_super) { __extends(m2_C9_private, _super); function m2_C9_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m2_C9_private; }(m2_c_public)); var m2_C10_private = (function (_super) { __extends(m2_C10_private, _super); function m2_C10_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m2_C10_private; }(m2_c_private)); var m2_C11_public = (function (_super) { __extends(m2_C11_public, _super); function m2_C11_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m2_C11_public; }(m2_c_public)); @@ -324,7 +329,7 @@ var m2; var m2_C12_public = (function (_super) { __extends(m2_C12_public, _super); function m2_C12_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m2_C12_public; }(m2_c_private)); @@ -346,21 +351,21 @@ var glo_c_private = (function () { var glo_C1_private = (function (_super) { __extends(glo_C1_private, _super); function glo_C1_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C1_private; }(glo_c_public)); var glo_C2_private = (function (_super) { __extends(glo_C2_private, _super); function glo_C2_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C2_private; }(glo_c_private)); var glo_C3_public = (function (_super) { __extends(glo_C3_public, _super); function glo_C3_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C3_public; }(glo_c_public)); @@ -368,7 +373,7 @@ exports.glo_C3_public = glo_C3_public; var glo_C4_public = (function (_super) { __extends(glo_C4_public, _super); function glo_C4_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C4_public; }(glo_c_private)); @@ -398,21 +403,21 @@ exports.glo_C8_public = glo_C8_public; var glo_C9_private = (function (_super) { __extends(glo_C9_private, _super); function glo_C9_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C9_private; }(glo_c_public)); var glo_C10_private = (function (_super) { __extends(glo_C10_private, _super); function glo_C10_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C10_private; }(glo_c_private)); var glo_C11_public = (function (_super) { __extends(glo_C11_public, _super); function glo_C11_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C11_public; }(glo_c_public)); @@ -420,7 +425,7 @@ exports.glo_C11_public = glo_C11_public; var glo_C12_public = (function (_super) { __extends(glo_C12_public, _super); function glo_C12_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C12_public; }(glo_c_private)); diff --git a/tests/baselines/reference/privacyClassExtendsClauseDeclFile.js b/tests/baselines/reference/privacyClassExtendsClauseDeclFile.js index e0828809416..3e5b20923df 100644 --- a/tests/baselines/reference/privacyClassExtendsClauseDeclFile.js +++ b/tests/baselines/reference/privacyClassExtendsClauseDeclFile.js @@ -99,11 +99,16 @@ class publicClassExtendingPublicClassInGlobal extends publicClassInGlobal { //// [privacyClassExtendsClauseDeclFile_externalModule.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var publicModule; (function (publicModule) { var publicClassInPublicModule = (function () { @@ -122,21 +127,21 @@ var publicModule; var privateClassExtendingPublicClassInModule = (function (_super) { __extends(privateClassExtendingPublicClassInModule, _super); function privateClassExtendingPublicClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingPublicClassInModule; }(publicClassInPublicModule)); var privateClassExtendingPrivateClassInModule = (function (_super) { __extends(privateClassExtendingPrivateClassInModule, _super); function privateClassExtendingPrivateClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingPrivateClassInModule; }(privateClassInPublicModule)); var publicClassExtendingPublicClassInModule = (function (_super) { __extends(publicClassExtendingPublicClassInModule, _super); function publicClassExtendingPublicClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPublicClassInModule; }(publicClassInPublicModule)); @@ -144,7 +149,7 @@ var publicModule; var publicClassExtendingPrivateClassInModule = (function (_super) { __extends(publicClassExtendingPrivateClassInModule, _super); function publicClassExtendingPrivateClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPrivateClassInModule; }(privateClassInPublicModule)); @@ -152,14 +157,14 @@ var publicModule; var privateClassExtendingFromPrivateModuleClass = (function (_super) { __extends(privateClassExtendingFromPrivateModuleClass, _super); function privateClassExtendingFromPrivateModuleClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingFromPrivateModuleClass; }(privateModule.publicClassInPrivateModule)); var publicClassExtendingFromPrivateModuleClass = (function (_super) { __extends(publicClassExtendingFromPrivateModuleClass, _super); function publicClassExtendingFromPrivateModuleClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingFromPrivateModuleClass; }(privateModule.publicClassInPrivateModule)); @@ -183,21 +188,21 @@ var privateModule; var privateClassExtendingPublicClassInModule = (function (_super) { __extends(privateClassExtendingPublicClassInModule, _super); function privateClassExtendingPublicClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingPublicClassInModule; }(publicClassInPrivateModule)); var privateClassExtendingPrivateClassInModule = (function (_super) { __extends(privateClassExtendingPrivateClassInModule, _super); function privateClassExtendingPrivateClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingPrivateClassInModule; }(privateClassInPrivateModule)); var publicClassExtendingPublicClassInModule = (function (_super) { __extends(publicClassExtendingPublicClassInModule, _super); function publicClassExtendingPublicClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPublicClassInModule; }(publicClassInPrivateModule)); @@ -205,7 +210,7 @@ var privateModule; var publicClassExtendingPrivateClassInModule = (function (_super) { __extends(publicClassExtendingPrivateClassInModule, _super); function publicClassExtendingPrivateClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPrivateClassInModule; }(privateClassInPrivateModule)); @@ -213,14 +218,14 @@ var privateModule; var privateClassExtendingFromPrivateModuleClass = (function (_super) { __extends(privateClassExtendingFromPrivateModuleClass, _super); function privateClassExtendingFromPrivateModuleClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingFromPrivateModuleClass; }(privateModule.publicClassInPrivateModule)); var publicClassExtendingFromPrivateModuleClass = (function (_super) { __extends(publicClassExtendingFromPrivateModuleClass, _super); function publicClassExtendingFromPrivateModuleClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingFromPrivateModuleClass; }(privateModule.publicClassInPrivateModule)); @@ -242,21 +247,21 @@ var privateClass = (function () { var privateClassExtendingPublicClass = (function (_super) { __extends(privateClassExtendingPublicClass, _super); function privateClassExtendingPublicClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingPublicClass; }(publicClass)); var privateClassExtendingPrivateClassInModule = (function (_super) { __extends(privateClassExtendingPrivateClassInModule, _super); function privateClassExtendingPrivateClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingPrivateClassInModule; }(privateClass)); var publicClassExtendingPublicClass = (function (_super) { __extends(publicClassExtendingPublicClass, _super); function publicClassExtendingPublicClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPublicClass; }(publicClass)); @@ -264,7 +269,7 @@ exports.publicClassExtendingPublicClass = publicClassExtendingPublicClass; var publicClassExtendingPrivateClass = (function (_super) { __extends(publicClassExtendingPrivateClass, _super); function publicClassExtendingPrivateClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPrivateClass; }(privateClass)); @@ -272,24 +277,29 @@ exports.publicClassExtendingPrivateClass = publicClassExtendingPrivateClass; var privateClassExtendingFromPrivateModuleClass = (function (_super) { __extends(privateClassExtendingFromPrivateModuleClass, _super); function privateClassExtendingFromPrivateModuleClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingFromPrivateModuleClass; }(privateModule.publicClassInPrivateModule)); var publicClassExtendingFromPrivateModuleClass = (function (_super) { __extends(publicClassExtendingFromPrivateModuleClass, _super); function publicClassExtendingFromPrivateModuleClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingFromPrivateModuleClass; }(privateModule.publicClassInPrivateModule)); exports.publicClassExtendingFromPrivateModuleClass = publicClassExtendingFromPrivateModuleClass; //// [privacyClassExtendsClauseDeclFile_GlobalFile.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var publicModuleInGlobal; (function (publicModuleInGlobal) { var publicClassInPublicModule = (function () { @@ -308,21 +318,21 @@ var publicModuleInGlobal; var privateClassExtendingPublicClassInModule = (function (_super) { __extends(privateClassExtendingPublicClassInModule, _super); function privateClassExtendingPublicClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingPublicClassInModule; }(publicClassInPublicModule)); var privateClassExtendingPrivateClassInModule = (function (_super) { __extends(privateClassExtendingPrivateClassInModule, _super); function privateClassExtendingPrivateClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingPrivateClassInModule; }(privateClassInPublicModule)); var publicClassExtendingPublicClassInModule = (function (_super) { __extends(publicClassExtendingPublicClassInModule, _super); function publicClassExtendingPublicClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPublicClassInModule; }(publicClassInPublicModule)); @@ -330,7 +340,7 @@ var publicModuleInGlobal; var publicClassExtendingPrivateClassInModule = (function (_super) { __extends(publicClassExtendingPrivateClassInModule, _super); function publicClassExtendingPrivateClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPrivateClassInModule; }(privateClassInPublicModule)); @@ -344,7 +354,7 @@ var publicClassInGlobal = (function () { var publicClassExtendingPublicClassInGlobal = (function (_super) { __extends(publicClassExtendingPublicClassInGlobal, _super); function publicClassExtendingPublicClassInGlobal() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPublicClassInGlobal; }(publicClassInGlobal)); diff --git a/tests/baselines/reference/privacyGloClass.js b/tests/baselines/reference/privacyGloClass.js index fa769a606ae..85acba1148b 100644 --- a/tests/baselines/reference/privacyGloClass.js +++ b/tests/baselines/reference/privacyGloClass.js @@ -61,11 +61,16 @@ class glo_C11_public extends glo_c_public implements glo_i_public { //// [privacyGloClass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var m1; (function (m1) { var m1_c_public = (function () { @@ -84,21 +89,21 @@ var m1; var m1_C1_private = (function (_super) { __extends(m1_C1_private, _super); function m1_C1_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C1_private; }(m1_c_public)); var m1_C2_private = (function (_super) { __extends(m1_C2_private, _super); function m1_C2_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C2_private; }(m1_c_private)); var m1_C3_public = (function (_super) { __extends(m1_C3_public, _super); function m1_C3_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C3_public; }(m1_c_public)); @@ -106,7 +111,7 @@ var m1; var m1_C4_public = (function (_super) { __extends(m1_C4_public, _super); function m1_C4_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C4_public; }(m1_c_private)); @@ -136,21 +141,21 @@ var m1; var m1_C9_private = (function (_super) { __extends(m1_C9_private, _super); function m1_C9_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C9_private; }(m1_c_public)); var m1_C10_private = (function (_super) { __extends(m1_C10_private, _super); function m1_C10_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C10_private; }(m1_c_private)); var m1_C11_public = (function (_super) { __extends(m1_C11_public, _super); function m1_C11_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C11_public; }(m1_c_public)); @@ -158,7 +163,7 @@ var m1; var m1_C12_public = (function (_super) { __extends(m1_C12_public, _super); function m1_C12_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C12_public; }(m1_c_private)); @@ -174,7 +179,7 @@ var glo_c_public = (function () { var glo_C3_public = (function (_super) { __extends(glo_C3_public, _super); function glo_C3_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C3_public; }(glo_c_public)); @@ -186,7 +191,7 @@ var glo_C7_public = (function () { var glo_C11_public = (function (_super) { __extends(glo_C11_public, _super); function glo_C11_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C11_public; }(glo_c_public)); diff --git a/tests/baselines/reference/privateAccessInSubclass1.js b/tests/baselines/reference/privateAccessInSubclass1.js index 21ff4793fb3..bab68b8d67e 100644 --- a/tests/baselines/reference/privateAccessInSubclass1.js +++ b/tests/baselines/reference/privateAccessInSubclass1.js @@ -10,11 +10,16 @@ class D extends Base { } //// [privateAccessInSubclass1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -23,7 +28,7 @@ var Base = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.myMethod = function () { this.options; diff --git a/tests/baselines/reference/privateInstanceMemberAccessibility.js b/tests/baselines/reference/privateInstanceMemberAccessibility.js index 6fa05178f91..8448f142bbb 100644 --- a/tests/baselines/reference/privateInstanceMemberAccessibility.js +++ b/tests/baselines/reference/privateInstanceMemberAccessibility.js @@ -14,11 +14,16 @@ class Derived extends Base { } //// [privateInstanceMemberAccessibility.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -27,7 +32,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = _super.prototype.foo; // error _this.z = _super.prototype.foo; // error return _this; diff --git a/tests/baselines/reference/privateProtectedMembersAreNotAccessibleDestructuring.js b/tests/baselines/reference/privateProtectedMembersAreNotAccessibleDestructuring.js index b732661edfc..be01293a2cd 100644 --- a/tests/baselines/reference/privateProtectedMembersAreNotAccessibleDestructuring.js +++ b/tests/baselines/reference/privateProtectedMembersAreNotAccessibleDestructuring.js @@ -22,11 +22,16 @@ let { priv: a, prot: b, privateMethod: f } = k; // error //// [privateProtectedMembersAreNotAccessibleDestructuring.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var K = (function () { function K() { } @@ -40,7 +45,7 @@ var K = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.m2 = function () { var a = this.priv; // error diff --git a/tests/baselines/reference/privateStaticMemberAccessibility.js b/tests/baselines/reference/privateStaticMemberAccessibility.js index c1897e8503a..92a8713ef8f 100644 --- a/tests/baselines/reference/privateStaticMemberAccessibility.js +++ b/tests/baselines/reference/privateStaticMemberAccessibility.js @@ -9,11 +9,16 @@ class Derived extends Base { } //// [privateStaticMemberAccessibility.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -22,7 +27,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.bing = function () { return Base.foo; }; // error return _this; } diff --git a/tests/baselines/reference/privateStaticNotAccessibleInClodule2.js b/tests/baselines/reference/privateStaticNotAccessibleInClodule2.js index a93823654d4..c4af30f1456 100644 --- a/tests/baselines/reference/privateStaticNotAccessibleInClodule2.js +++ b/tests/baselines/reference/privateStaticNotAccessibleInClodule2.js @@ -16,11 +16,16 @@ module D { //// [privateStaticNotAccessibleInClodule2.js] // Any attempt to access a private property member outside the class body that contains its declaration results in a compile-time 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -29,7 +34,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js index 99a4842f636..1c181a2feae 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js @@ -1,8 +1,13 @@ -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var m2; (function (m2) { m2.c1 = new m2.mExported.me.class1; @@ -14,7 +19,7 @@ var m2; var class1 = (function (_super) { __extends(class1, _super); function class1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class1; }(m2.mExported.me.class1)); @@ -27,7 +32,7 @@ var m2; var class2 = (function (_super) { __extends(class2, _super); function class2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class2; }(m2.mExported.me.class1)); @@ -40,7 +45,7 @@ var m2; var class3 = (function (_super) { __extends(class3, _super); function class3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class3; }(mNonExported.mne.class1)); @@ -53,7 +58,7 @@ var m2; var class4 = (function (_super) { __extends(class4, _super); function class4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class4; }(mNonExported.mne.class1)); diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js index 99a4842f636..1c181a2feae 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js @@ -1,8 +1,13 @@ -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var m2; (function (m2) { m2.c1 = new m2.mExported.me.class1; @@ -14,7 +19,7 @@ var m2; var class1 = (function (_super) { __extends(class1, _super); function class1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class1; }(m2.mExported.me.class1)); @@ -27,7 +32,7 @@ var m2; var class2 = (function (_super) { __extends(class2, _super); function class2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class2; }(m2.mExported.me.class1)); @@ -40,7 +45,7 @@ var m2; var class3 = (function (_super) { __extends(class3, _super); function class3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class3; }(mNonExported.mne.class1)); @@ -53,7 +58,7 @@ var m2; var class4 = (function (_super) { __extends(class4, _super); function class4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class4; }(mNonExported.mne.class1)); diff --git a/tests/baselines/reference/project/prologueEmit/amd/out.js b/tests/baselines/reference/project/prologueEmit/amd/out.js index 7ee160b82ef..45dfb93c458 100644 --- a/tests/baselines/reference/project/prologueEmit/amd/out.js +++ b/tests/baselines/reference/project/prologueEmit/amd/out.js @@ -1,8 +1,13 @@ -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _this = this; // Add a lambda to ensure global 'this' capture is triggered (function () { return _this.window; }); @@ -18,7 +23,7 @@ var m; var child = (function (_super) { __extends(child, _super); function child() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return child; }(base)); diff --git a/tests/baselines/reference/project/prologueEmit/node/out.js b/tests/baselines/reference/project/prologueEmit/node/out.js index 7ee160b82ef..45dfb93c458 100644 --- a/tests/baselines/reference/project/prologueEmit/node/out.js +++ b/tests/baselines/reference/project/prologueEmit/node/out.js @@ -1,8 +1,13 @@ -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _this = this; // Add a lambda to ensure global 'this' capture is triggered (function () { return _this.window; }); @@ -18,7 +23,7 @@ var m; var child = (function (_super) { __extends(child, _super); function child() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return child; }(base)); diff --git a/tests/baselines/reference/project/quotesInFileAndDirectoryNames/amd/m'ain.js b/tests/baselines/reference/project/quotesInFileAndDirectoryNames/amd/m'ain.js index b793b07534c..ce5681ae1c9 100644 --- a/tests/baselines/reference/project/quotesInFileAndDirectoryNames/amd/m'ain.js +++ b/tests/baselines/reference/project/quotesInFileAndDirectoryNames/amd/m'ain.js @@ -1,13 +1,18 @@ /// -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ClassC = (function (_super) { __extends(ClassC, _super); function ClassC() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ClassC; }(test.ClassA)); diff --git a/tests/baselines/reference/project/quotesInFileAndDirectoryNames/node/m'ain.js b/tests/baselines/reference/project/quotesInFileAndDirectoryNames/node/m'ain.js index b793b07534c..ce5681ae1c9 100644 --- a/tests/baselines/reference/project/quotesInFileAndDirectoryNames/node/m'ain.js +++ b/tests/baselines/reference/project/quotesInFileAndDirectoryNames/node/m'ain.js @@ -1,13 +1,18 @@ /// -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ClassC = (function (_super) { __extends(ClassC, _super); function ClassC() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ClassC; }(test.ClassA)); diff --git a/tests/baselines/reference/propertiesAndIndexers.js b/tests/baselines/reference/propertiesAndIndexers.js index dff86f3954e..2c678ba258f 100644 --- a/tests/baselines/reference/propertiesAndIndexers.js +++ b/tests/baselines/reference/propertiesAndIndexers.js @@ -52,11 +52,16 @@ var c: { }; //// [propertiesAndIndexers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var P = (function () { function P() { } @@ -65,7 +70,7 @@ var P = (function () { var Q = (function (_super) { __extends(Q, _super); function Q() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Q; }(P)); diff --git a/tests/baselines/reference/propertyAccess.js b/tests/baselines/reference/propertyAccess.js index 0a4c9082a21..5904d66c372 100644 --- a/tests/baselines/reference/propertyAccess.js +++ b/tests/baselines/reference/propertyAccess.js @@ -151,11 +151,16 @@ var x3: A; //// [propertyAccess.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -164,7 +169,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/propertyAccess4.errors.txt b/tests/baselines/reference/propertyAccess4.errors.txt index cdc772ba528..fc491d8c7a9 100644 --- a/tests/baselines/reference/propertyAccess4.errors.txt +++ b/tests/baselines/reference/propertyAccess4.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/propertyAccess4.ts(1,6): error TS2339: Property 'toBAZ' does not exist on type 'null'. +tests/cases/compiler/propertyAccess4.ts(1,1): error TS2531: Object is possibly 'null'. ==== tests/cases/compiler/propertyAccess4.ts (1 errors) ==== null.toBAZ(); - ~~~~~ -!!! error TS2339: Property 'toBAZ' does not exist on type 'null'. \ No newline at end of file + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/propertyAccess5.errors.txt b/tests/baselines/reference/propertyAccess5.errors.txt index 81c05c5342b..4f7e7f4bcd6 100644 --- a/tests/baselines/reference/propertyAccess5.errors.txt +++ b/tests/baselines/reference/propertyAccess5.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/propertyAccess5.ts(1,11): error TS2339: Property 'toBAZ' does not exist on type 'undefined'. +tests/cases/compiler/propertyAccess5.ts(1,1): error TS2532: Object is possibly 'undefined'. ==== tests/cases/compiler/propertyAccess5.ts (1 errors) ==== undefined.toBAZ(); - ~~~~~ -!!! error TS2339: Property 'toBAZ' does not exist on type 'undefined'. \ No newline at end of file + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.js b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.js index d36d7e27efe..08e1a9ceb11 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.js +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.js @@ -83,11 +83,16 @@ var r4 = b.foo(aB, aB); // no inferences for T so constraint isn't satisfied, er //// [propertyAccessOnTypeParameterWithConstraints2.js] // generic types should behave as if they have properties of their constraint 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -97,7 +102,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { return ''; diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.js b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.js index 4aedfe12b04..0d945197957 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.js +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.js @@ -58,11 +58,16 @@ var r4 = b.foo(new B()); // valid call to an invalid function //// [propertyAccessOnTypeParameterWithConstraints3.js] // generic types should behave as if they have properties of their constraint 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -72,7 +77,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { return ''; diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.errors.txt b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.errors.txt index fd012d0e5a5..c1052dff554 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.errors.txt +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(15,32): error TS2339: Property 'notHere' does not exist on type 'U'. tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(25,16): error TS2339: Property 'notHere' does not exist on type 'B'. tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(32,22): error TS2339: Property 'notHere' does not exist on type 'A'. -tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(38,16): error TS2322: Type 'string' is not assignable to type 'U'. +tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(38,9): error TS2322: Type 'string' is not assignable to type 'U'. tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(38,22): error TS2339: Property 'notHere' does not exist on type 'U'. @@ -50,7 +50,7 @@ tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOn foo: (x: U): U => { var a = x['foo'](); // should be string return a + x.notHere(); - ~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'U'. ~~~~~~~ !!! error TS2339: Property 'notHere' does not exist on type 'U'. diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.js b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.js index 3cb14438141..a7cc39b7f05 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.js +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.js @@ -45,11 +45,16 @@ var b = { var r4 = b.foo(new B()); // error after constraints above made illegal, doesn't matter //// [propertyAccessOnTypeParameterWithConstraints5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -59,7 +64,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { return ''; diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass.js index 429dfdf6b14..47d329909fd 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass.js +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass.js @@ -39,11 +39,16 @@ class E extends C { } //// [protectedClassPropertyAccessibleWithinNestedSubclass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { } @@ -52,7 +57,7 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(C.prototype, "y", { get: function () { return this.x; }, @@ -93,7 +98,7 @@ var C = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(C)); diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass1.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass1.js index 0571b85ea9e..8273b7e31bd 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass1.js +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass1.js @@ -115,11 +115,16 @@ d3.x; // Error, neither within their declaring class nor class d4.x; // Error, neither within their declaring class nor classes derived from their declaring class //// [protectedClassPropertyAccessibleWithinNestedSubclass1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -147,7 +152,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.prototype.method1 = function () { var B = (function () { @@ -173,7 +178,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.prototype.method2 = function () { var C = (function () { @@ -199,7 +204,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived3.prototype.method3 = function () { var D = (function () { @@ -225,7 +230,7 @@ var Derived3 = (function (_super) { var Derived4 = (function (_super) { __extends(Derived4, _super); function Derived4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived4.prototype.method4 = function () { var E = (function () { diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js index a10b39b402e..a2d35914cbe 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js @@ -21,11 +21,16 @@ class C extends B { //// [protectedClassPropertyAccessibleWithinSubclass.js] // no 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { } @@ -34,7 +39,7 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(C.prototype, "y", { get: function () { return this.x; }, diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.js index a404b8049bc..7a9ee9f2268 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.js +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.js @@ -95,11 +95,16 @@ d3.x; // Error, neither within their declaring class nor class d4.x; // Error, neither within their declaring class nor classes derived from their declaring class //// [protectedClassPropertyAccessibleWithinSubclass2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -120,7 +125,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.prototype.method1 = function () { var b; @@ -139,7 +144,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.prototype.method2 = function () { var b; @@ -158,7 +163,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived3.prototype.method3 = function () { var b; @@ -177,7 +182,7 @@ var Derived3 = (function (_super) { var Derived4 = (function (_super) { __extends(Derived4, _super); function Derived4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived4.prototype.method4 = function () { var b; diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.js index 7d449bdcbd4..2b9faf6282c 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.js +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.js @@ -14,11 +14,16 @@ class Derived extends Base { } //// [protectedClassPropertyAccessibleWithinSubclass3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -30,7 +35,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.prototype.method1 = function () { this.x; // OK, accessed within a subclass of the declaring class diff --git a/tests/baselines/reference/protectedInstanceMemberAccessibility.js b/tests/baselines/reference/protectedInstanceMemberAccessibility.js index 3259d401270..6617636aa45 100644 --- a/tests/baselines/reference/protectedInstanceMemberAccessibility.js +++ b/tests/baselines/reference/protectedInstanceMemberAccessibility.js @@ -45,11 +45,16 @@ class C extends A { //// [protectedInstanceMemberAccessibility.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -61,7 +66,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.g = function () { var t1 = this.x; @@ -93,7 +98,7 @@ var B = (function (_super) { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/protectedMembers.js b/tests/baselines/reference/protectedMembers.js index 46b4691dff7..7684ff8e658 100644 --- a/tests/baselines/reference/protectedMembers.js +++ b/tests/baselines/reference/protectedMembers.js @@ -116,11 +116,16 @@ class B3 extends A3 { //// [protectedMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // Class with protected members var C1 = (function () { function C1() { @@ -137,7 +142,7 @@ var C1 = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C2.prototype.f = function () { return _super.prototype.f.call(this) + this.x; @@ -151,7 +156,7 @@ var C2 = (function (_super) { var C3 = (function (_super) { __extends(C3, _super); function C3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C3.prototype.f = function () { return _super.prototype.f.call(this); @@ -187,14 +192,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.foo = function (a, b, c, d, e) { a.x = 1; // Error, access must be through C or type derived from C @@ -208,7 +213,7 @@ var C = (function (_super) { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); @@ -239,7 +244,7 @@ var A2 = (function () { var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A2)); @@ -252,7 +257,7 @@ var A3 = (function () { var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A3)); diff --git a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass.js b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass.js index ad1b1682aa7..238c0dc2384 100644 --- a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass.js +++ b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass.js @@ -44,11 +44,16 @@ Derived2.x; // Error, neither within their declaring class nor classes deriv Derived3.x; // Error, neither within their declaring class nor classes derived from their declaring class //// [protectedStaticClassPropertyAccessibleWithinSubclass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -63,7 +68,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.staticMethod1 = function () { Base.x; // OK, accessed within a class derived from their declaring class @@ -76,7 +81,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.staticMethod2 = function () { Base.x; // OK, accessed within a class derived from their declaring class @@ -89,7 +94,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived3.staticMethod3 = function () { Base.x; // OK, accessed within a class derived from their declaring class diff --git a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.js b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.js index a2346b8be40..969b7ebd7dc 100644 --- a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.js +++ b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.js @@ -22,11 +22,16 @@ class Derived2 extends Derived1 { } //// [protectedStaticClassPropertyAccessibleWithinSubclass2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -38,7 +43,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.staticMethod1 = function () { this.x; // OK, accessed within a class derived from their declaring class @@ -49,7 +54,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.staticMethod3 = function () { this.x; // OK, accessed within a class derived from their declaring class 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 a881eb55a18..f7b49b4219a 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 @@ -7,11 +7,16 @@ class Beta extends Alpha.x { } //// [qualifiedName_entity-name-resolution-does-not-affect-class-heritage.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Alpha; (function (Alpha) { Alpha.x = 100; @@ -19,7 +24,7 @@ var Alpha; var Beta = (function (_super) { __extends(Beta, _super); function Beta() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Beta; }(Alpha.x)); diff --git a/tests/baselines/reference/readonlyConstructorAssignment.js b/tests/baselines/reference/readonlyConstructorAssignment.js index 872c00486c0..bb4ddec93a8 100644 --- a/tests/baselines/reference/readonlyConstructorAssignment.js +++ b/tests/baselines/reference/readonlyConstructorAssignment.js @@ -41,11 +41,16 @@ class E extends D { //// [readonlyConstructorAssignment.js] // Tests that readonly parameter properties behave like regular readonly properties -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(x) { this.x = x; diff --git a/tests/baselines/reference/recursiveBaseCheck3.js b/tests/baselines/reference/recursiveBaseCheck3.js index 250a9e0b618..a9ea849cea0 100644 --- a/tests/baselines/reference/recursiveBaseCheck3.js +++ b/tests/baselines/reference/recursiveBaseCheck3.js @@ -5,22 +5,27 @@ class C extends A { } (new C).blah; //// [recursiveBaseCheck3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function (_super) { __extends(A, _super); function A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A; }(C)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/recursiveBaseCheck4.js b/tests/baselines/reference/recursiveBaseCheck4.js index 7f0c6b5f95d..7b0be057441 100644 --- a/tests/baselines/reference/recursiveBaseCheck4.js +++ b/tests/baselines/reference/recursiveBaseCheck4.js @@ -3,15 +3,20 @@ class M extends M { } (new M).blah; //// [recursiveBaseCheck4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M = (function (_super) { __extends(M, _super); function M() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return M; }(M)); diff --git a/tests/baselines/reference/recursiveBaseCheck6.js b/tests/baselines/reference/recursiveBaseCheck6.js index 53a608baeca..6e639130839 100644 --- a/tests/baselines/reference/recursiveBaseCheck6.js +++ b/tests/baselines/reference/recursiveBaseCheck6.js @@ -3,15 +3,20 @@ class S18 extends S18<{ S19: A; }>{ } (new S18()).blah; //// [recursiveBaseCheck6.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var S18 = (function (_super) { __extends(S18, _super); function S18() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return S18; }(S18)); diff --git a/tests/baselines/reference/recursiveBaseConstructorCreation1.js b/tests/baselines/reference/recursiveBaseConstructorCreation1.js index 344750974cb..c8507944ed7 100644 --- a/tests/baselines/reference/recursiveBaseConstructorCreation1.js +++ b/tests/baselines/reference/recursiveBaseConstructorCreation1.js @@ -7,11 +7,16 @@ var x = new C2(); // Valid //// [recursiveBaseConstructorCreation1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1() { } @@ -21,7 +26,7 @@ var C1 = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(C1)); diff --git a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js index 34aa110b7ee..704c39891e6 100644 --- a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js +++ b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js @@ -10,11 +10,16 @@ export class MemberNameArray extends MemberName { //// [recursiveClassInstantiationsWithDefaultConstructors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = new TypeScript2.MemberNameArray(); var TypeScript2; (function (TypeScript2) { @@ -28,7 +33,7 @@ var TypeScript2; var MemberNameArray = (function (_super) { __extends(MemberNameArray, _super); function MemberNameArray() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return MemberNameArray; }(MemberName)); diff --git a/tests/baselines/reference/recursiveClassReferenceTest.js b/tests/baselines/reference/recursiveClassReferenceTest.js index a2cf3319474..2d44740ac73 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.js +++ b/tests/baselines/reference/recursiveClassReferenceTest.js @@ -105,11 +105,16 @@ module Sample.Thing.Languages.PlainText { //// [recursiveClassReferenceTest.js] // Scenario 1: Test reqursive function call with "this" parameter // Scenario 2: Test recursive function call with cast and "this" parameter -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Sample; (function (Sample) { var Actions; @@ -188,7 +193,7 @@ var AbstractMode = (function () { var Mode = (function (_super) { __extends(Mode, _super); function Mode() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } // scenario 2 Mode.prototype.getInitialState = function () { diff --git a/tests/baselines/reference/recursiveClassReferenceTest.js.map b/tests/baselines/reference/recursiveClassReferenceTest.js.map index 0b9bb8281bc..b27f18ddffa 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":[],"mappings":"AAAA,iEAAiE;AACjE,0EAA0E;;;;;;AA8B1E,IAAO,MAAM,CAUZ;AAVD,WAAO,MAAM;IAAC,IAAA,OAAO,CAUpB;IAVa,WAAA,OAAO;QAAC,IAAA,KAAK,CAU1B;QAVqB,WAAA,OAAK;YAAC,IAAA,IAAI,CAU/B;YAV2B,WAAA,IAAI;gBAC/B;oBAAA;oBAQA,CAAC;oBANO,+BAAK,GAAZ,cAAiB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;oBAExB,6BAAG,GAAV,UAAW,KAA6B;wBAEvC,MAAM,CAAC,IAAI,CAAC;oBACb,CAAC;oBACF,sBAAC;gBAAD,CAAC,AARD,IAQC;gBARY,oBAAe,kBAQ3B,CAAA;YACF,CAAC,EAV2B,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAU/B;QAAD,CAAC,EAVqB,KAAK,GAAL,aAAK,KAAL,aAAK,QAU1B;IAAD,CAAC,EAVa,OAAO,GAAP,cAAO,KAAP,cAAO,QAUpB;AAAD,CAAC,EAVM,MAAM,KAAN,MAAM,QAUZ;AAED,WAAO,MAAM;IAAC,IAAA,KAAK,CAoBlB;IApBa,WAAA,KAAK;QAAC,IAAA,OAAO,CAoB1B;QApBmB,WAAA,OAAO;YAC1B;gBAKC,oBAAoB,SAAkC;oBAAlC,cAAS,GAAT,SAAS,CAAyB;oBAD9C,YAAO,GAAO,IAAI,CAAC;oBAEvB,aAAa;oBACb,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBAC3C,CAAC;gBANM,wBAAG,GAAV,UAAW,MAAyC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;oBAAA,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAAA,CAAC,CAAA,CAAC;gBAQlF,+BAAU,GAAjB;oBACC,MAAM,CAAC,OAAO,CAAC;gBAChB,CAAC;gBAEM,4BAAO,GAAd;gBAEA,CAAC;gBAEF,iBAAC;YAAD,CAAC,AAlBD,IAkBC;YAlBY,kBAAU,aAkBtB,CAAA;QACF,CAAC,EApBmB,OAAO,GAAP,aAAO,KAAP,aAAO,QAoB1B;IAAD,CAAC,EApBa,KAAK,GAAL,YAAK,KAAL,YAAK,QAoBlB;AAAD,CAAC,EApBM,MAAM,KAAN,MAAM,QAoBZ;AAGD;IAAA;IAAuF,CAAC;IAA3C,sCAAe,GAAtB,cAAmC,MAAM,CAAC,IAAI,CAAC,CAAA,CAAC;IAAC,mBAAC;AAAD,CAAC,AAAxF,IAAwF;AASxF,WAAO,MAAM;IAAC,IAAA,KAAK,CAwBlB;IAxBa,WAAA,KAAK;QAAC,IAAA,SAAS,CAwB5B;QAxBmB,WAAA,SAAS;YAAC,IAAA,SAAS,CAwBtC;YAxB6B,WAAA,SAAS;gBAEtC;oBACO,eAAoB,IAAW;wBAAX,SAAI,GAAJ,IAAI,CAAO;oBAAI,CAAC;oBACnC,qBAAK,GAAZ;wBACC,MAAM,CAAC,IAAI,CAAC;oBACb,CAAC;oBAEM,sBAAM,GAAb,UAAc,KAAY;wBACzB,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC;oBACvB,CAAC;oBAEM,uBAAO,GAAd,cAA0B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;oBACzC,YAAC;gBAAD,CAAC,AAXD,IAWC;gBAXY,eAAK,QAWjB,CAAA;gBAED;oBAA0B,wBAAY;oBAAtC;;oBAQA,CAAC;oBANA,aAAa;oBACN,8BAAe,GAAtB;wBACC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;oBACxB,CAAC;oBAGF,WAAC;gBAAD,CAAC,AARD,CAA0B,YAAY,GAQrC;gBARY,cAAI,OAQhB,CAAA;YACF,CAAC,EAxB6B,SAAS,GAAT,mBAAS,KAAT,mBAAS,QAwBtC;QAAD,CAAC,EAxBmB,SAAS,GAAT,eAAS,KAAT,eAAS,QAwB5B;IAAD,CAAC,EAxBa,KAAK,GAAL,YAAK,KAAL,YAAK,QAwBlB;AAAD,CAAC,EAxBM,MAAM,KAAN,MAAM,QAwBZ"} \ No newline at end of file +{"version":3,"file":"recursiveClassReferenceTest.js","sourceRoot":"","sources":["recursiveClassReferenceTest.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,0EAA0E;;;;;;;;;;;AA8B1E,IAAO,MAAM,CAUZ;AAVD,WAAO,MAAM;IAAC,IAAA,OAAO,CAUpB;IAVa,WAAA,OAAO;QAAC,IAAA,KAAK,CAU1B;QAVqB,WAAA,OAAK;YAAC,IAAA,IAAI,CAU/B;YAV2B,WAAA,IAAI;gBAC/B;oBAAA;oBAQA,CAAC;oBANO,+BAAK,GAAZ,cAAiB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;oBAExB,6BAAG,GAAV,UAAW,KAA6B;wBAEvC,MAAM,CAAC,IAAI,CAAC;oBACb,CAAC;oBACF,sBAAC;gBAAD,CAAC,AARD,IAQC;gBARY,oBAAe,kBAQ3B,CAAA;YACF,CAAC,EAV2B,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAU/B;QAAD,CAAC,EAVqB,KAAK,GAAL,aAAK,KAAL,aAAK,QAU1B;IAAD,CAAC,EAVa,OAAO,GAAP,cAAO,KAAP,cAAO,QAUpB;AAAD,CAAC,EAVM,MAAM,KAAN,MAAM,QAUZ;AAED,WAAO,MAAM;IAAC,IAAA,KAAK,CAoBlB;IApBa,WAAA,KAAK;QAAC,IAAA,OAAO,CAoB1B;QApBmB,WAAA,OAAO;YAC1B;gBAKC,oBAAoB,SAAkC;oBAAlC,cAAS,GAAT,SAAS,CAAyB;oBAD9C,YAAO,GAAO,IAAI,CAAC;oBAEvB,aAAa;oBACb,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBAC3C,CAAC;gBANM,wBAAG,GAAV,UAAW,MAAyC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;oBAAA,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAAA,CAAC,CAAA,CAAC;gBAQlF,+BAAU,GAAjB;oBACC,MAAM,CAAC,OAAO,CAAC;gBAChB,CAAC;gBAEM,4BAAO,GAAd;gBAEA,CAAC;gBAEF,iBAAC;YAAD,CAAC,AAlBD,IAkBC;YAlBY,kBAAU,aAkBtB,CAAA;QACF,CAAC,EApBmB,OAAO,GAAP,aAAO,KAAP,aAAO,QAoB1B;IAAD,CAAC,EApBa,KAAK,GAAL,YAAK,KAAL,YAAK,QAoBlB;AAAD,CAAC,EApBM,MAAM,KAAN,MAAM,QAoBZ;AAGD;IAAA;IAAuF,CAAC;IAA3C,sCAAe,GAAtB,cAAmC,MAAM,CAAC,IAAI,CAAC,CAAA,CAAC;IAAC,mBAAC;AAAD,CAAC,AAAxF,IAAwF;AASxF,WAAO,MAAM;IAAC,IAAA,KAAK,CAwBlB;IAxBa,WAAA,KAAK;QAAC,IAAA,SAAS,CAwB5B;QAxBmB,WAAA,SAAS;YAAC,IAAA,SAAS,CAwBtC;YAxB6B,WAAA,SAAS;gBAEtC;oBACO,eAAoB,IAAW;wBAAX,SAAI,GAAJ,IAAI,CAAO;oBAAI,CAAC;oBACnC,qBAAK,GAAZ;wBACC,MAAM,CAAC,IAAI,CAAC;oBACb,CAAC;oBAEM,sBAAM,GAAb,UAAc,KAAY;wBACzB,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC;oBACvB,CAAC;oBAEM,uBAAO,GAAd,cAA0B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;oBACzC,YAAC;gBAAD,CAAC,AAXD,IAWC;gBAXY,eAAK,QAWjB,CAAA;gBAED;oBAA0B,wBAAY;oBAAtC;;oBAQA,CAAC;oBANA,aAAa;oBACN,8BAAe,GAAtB;wBACC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;oBACxB,CAAC;oBAGF,WAAC;gBAAD,CAAC,AARD,CAA0B,YAAY,GAQrC;gBARY,cAAI,OAQhB,CAAA;YACF,CAAC,EAxB6B,SAAS,GAAT,mBAAS,KAAT,mBAAS,QAwBtC;QAAD,CAAC,EAxBmB,SAAS,GAAT,eAAS,KAAT,eAAS,QAwB5B;IAAD,CAAC,EAxBa,KAAK,GAAL,YAAK,KAAL,YAAK,QAwBlB;AAAD,CAAC,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 f99a062e2c6..4196b08c609 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt +++ b/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt @@ -26,11 +26,16 @@ sourceFile:recursiveClassReferenceTest.ts 1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) 2 >Emitted(2, 75) Source(2, 75) + SourceIndex(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; } ->>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); ->>>}; +>>>var __extends = (this && this.__extends) || (function () { +>>> var extendStatics = Object.setPrototypeOf || +>>> ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || +>>> function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; +>>> return function (d, b) { +>>> extendStatics(d, b); +>>> function __() { this.constructor = d; } +>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +>>> }; +>>>})(); >>>var Sample; 1 > 2 >^^^^ @@ -81,10 +86,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -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) +1 >Emitted(13, 1) Source(32, 1) + SourceIndex(0) +2 >Emitted(13, 5) Source(32, 8) + SourceIndex(0) +3 >Emitted(13, 11) Source(32, 14) + SourceIndex(0) +4 >Emitted(13, 12) Source(42, 2) + SourceIndex(0) --- >>>(function (Sample) { 1-> @@ -93,9 +98,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 >module 3 > Sample -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) +1->Emitted(14, 1) Source(32, 1) + SourceIndex(0) +2 >Emitted(14, 12) Source(32, 8) + SourceIndex(0) +3 >Emitted(14, 18) Source(32, 14) + SourceIndex(0) --- >>> var Actions; 1 >^^^^ @@ -117,10 +122,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(10, 5) Source(32, 15) + SourceIndex(0) -2 >Emitted(10, 9) Source(32, 15) + SourceIndex(0) -3 >Emitted(10, 16) Source(32, 22) + SourceIndex(0) -4 >Emitted(10, 17) Source(42, 2) + SourceIndex(0) +1 >Emitted(15, 5) Source(32, 15) + SourceIndex(0) +2 >Emitted(15, 9) Source(32, 15) + SourceIndex(0) +3 >Emitted(15, 16) Source(32, 22) + SourceIndex(0) +4 >Emitted(15, 17) Source(42, 2) + SourceIndex(0) --- >>> (function (Actions) { 1->^^^^ @@ -129,9 +134,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Actions -1->Emitted(11, 5) Source(32, 15) + SourceIndex(0) -2 >Emitted(11, 16) Source(32, 15) + SourceIndex(0) -3 >Emitted(11, 23) Source(32, 22) + SourceIndex(0) +1->Emitted(16, 5) Source(32, 15) + SourceIndex(0) +2 >Emitted(16, 16) Source(32, 15) + SourceIndex(0) +3 >Emitted(16, 23) Source(32, 22) + SourceIndex(0) --- >>> var Thing; 1 >^^^^^^^^ @@ -153,10 +158,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(12, 9) Source(32, 23) + SourceIndex(0) -2 >Emitted(12, 13) Source(32, 23) + SourceIndex(0) -3 >Emitted(12, 18) Source(32, 28) + SourceIndex(0) -4 >Emitted(12, 19) Source(42, 2) + SourceIndex(0) +1 >Emitted(17, 9) Source(32, 23) + SourceIndex(0) +2 >Emitted(17, 13) Source(32, 23) + SourceIndex(0) +3 >Emitted(17, 18) Source(32, 28) + SourceIndex(0) +4 >Emitted(17, 19) Source(42, 2) + SourceIndex(0) --- >>> (function (Thing_1) { 1->^^^^^^^^ @@ -165,9 +170,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Thing -1->Emitted(13, 9) Source(32, 23) + SourceIndex(0) -2 >Emitted(13, 20) Source(32, 23) + SourceIndex(0) -3 >Emitted(13, 27) Source(32, 28) + SourceIndex(0) +1->Emitted(18, 9) Source(32, 23) + SourceIndex(0) +2 >Emitted(18, 20) Source(32, 23) + SourceIndex(0) +3 >Emitted(18, 27) Source(32, 28) + SourceIndex(0) --- >>> var Find; 1 >^^^^^^^^^^^^ @@ -189,10 +194,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(14, 13) Source(32, 29) + SourceIndex(0) -2 >Emitted(14, 17) Source(32, 29) + SourceIndex(0) -3 >Emitted(14, 21) Source(32, 33) + SourceIndex(0) -4 >Emitted(14, 22) Source(42, 2) + SourceIndex(0) +1 >Emitted(19, 13) Source(32, 29) + SourceIndex(0) +2 >Emitted(19, 17) Source(32, 29) + SourceIndex(0) +3 >Emitted(19, 21) Source(32, 33) + SourceIndex(0) +4 >Emitted(19, 22) Source(42, 2) + SourceIndex(0) --- >>> (function (Find) { 1->^^^^^^^^^^^^ @@ -202,22 +207,22 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Find -1->Emitted(15, 13) Source(32, 29) + SourceIndex(0) -2 >Emitted(15, 24) Source(32, 29) + SourceIndex(0) -3 >Emitted(15, 28) Source(32, 33) + SourceIndex(0) +1->Emitted(20, 13) Source(32, 29) + SourceIndex(0) +2 >Emitted(20, 24) Source(32, 29) + SourceIndex(0) +3 >Emitted(20, 28) Source(32, 33) + SourceIndex(0) --- >>> var StartFindAction = (function () { 1->^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> { > -1->Emitted(16, 17) Source(33, 2) + SourceIndex(0) +1->Emitted(21, 17) Source(33, 2) + SourceIndex(0) --- >>> function StartFindAction() { 1->^^^^^^^^^^^^^^^^^^^^ 2 > ^^-> 1-> -1->Emitted(17, 21) Source(33, 2) + SourceIndex(0) +1->Emitted(22, 21) Source(33, 2) + SourceIndex(0) --- >>> } 1->^^^^^^^^^^^^^^^^^^^^ @@ -233,8 +238,8 @@ sourceFile:recursiveClassReferenceTest.ts > } > 2 > } -1->Emitted(18, 21) Source(41, 2) + SourceIndex(0) -2 >Emitted(18, 22) Source(41, 3) + SourceIndex(0) +1->Emitted(23, 21) Source(41, 2) + SourceIndex(0) +2 >Emitted(23, 22) Source(41, 3) + SourceIndex(0) --- >>> StartFindAction.prototype.getId = function () { return "yo"; }; 1->^^^^^^^^^^^^^^^^^^^^ @@ -257,16 +262,16 @@ sourceFile:recursiveClassReferenceTest.ts 8 > ; 9 > 10> } -1->Emitted(19, 21) Source(35, 10) + SourceIndex(0) -2 >Emitted(19, 52) Source(35, 15) + SourceIndex(0) -3 >Emitted(19, 55) Source(35, 3) + SourceIndex(0) -4 >Emitted(19, 69) Source(35, 20) + SourceIndex(0) -5 >Emitted(19, 75) Source(35, 26) + SourceIndex(0) -6 >Emitted(19, 76) Source(35, 27) + SourceIndex(0) -7 >Emitted(19, 80) Source(35, 31) + SourceIndex(0) -8 >Emitted(19, 81) Source(35, 32) + SourceIndex(0) -9 >Emitted(19, 82) Source(35, 33) + SourceIndex(0) -10>Emitted(19, 83) Source(35, 34) + SourceIndex(0) +1->Emitted(24, 21) Source(35, 10) + SourceIndex(0) +2 >Emitted(24, 52) Source(35, 15) + SourceIndex(0) +3 >Emitted(24, 55) Source(35, 3) + SourceIndex(0) +4 >Emitted(24, 69) Source(35, 20) + SourceIndex(0) +5 >Emitted(24, 75) Source(35, 26) + SourceIndex(0) +6 >Emitted(24, 76) Source(35, 27) + SourceIndex(0) +7 >Emitted(24, 80) Source(35, 31) + SourceIndex(0) +8 >Emitted(24, 81) Source(35, 32) + SourceIndex(0) +9 >Emitted(24, 82) Source(35, 33) + SourceIndex(0) +10>Emitted(24, 83) Source(35, 34) + SourceIndex(0) --- >>> StartFindAction.prototype.run = function (Thing) { 1 >^^^^^^^^^^^^^^^^^^^^ @@ -281,11 +286,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > public run( 5 > Thing:Sample.Thing.ICodeThing -1 >Emitted(20, 21) Source(37, 10) + SourceIndex(0) -2 >Emitted(20, 50) Source(37, 13) + SourceIndex(0) -3 >Emitted(20, 53) Source(37, 3) + SourceIndex(0) -4 >Emitted(20, 63) Source(37, 14) + SourceIndex(0) -5 >Emitted(20, 68) Source(37, 43) + SourceIndex(0) +1 >Emitted(25, 21) Source(37, 10) + SourceIndex(0) +2 >Emitted(25, 50) Source(37, 13) + SourceIndex(0) +3 >Emitted(25, 53) Source(37, 3) + SourceIndex(0) +4 >Emitted(25, 63) Source(37, 14) + SourceIndex(0) +5 >Emitted(25, 68) Source(37, 43) + SourceIndex(0) --- >>> return true; 1 >^^^^^^^^^^^^^^^^^^^^^^^^ @@ -300,11 +305,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > true 5 > ; -1 >Emitted(21, 25) Source(39, 4) + SourceIndex(0) -2 >Emitted(21, 31) Source(39, 10) + SourceIndex(0) -3 >Emitted(21, 32) Source(39, 11) + SourceIndex(0) -4 >Emitted(21, 36) Source(39, 15) + SourceIndex(0) -5 >Emitted(21, 37) Source(39, 16) + SourceIndex(0) +1 >Emitted(26, 25) Source(39, 4) + SourceIndex(0) +2 >Emitted(26, 31) Source(39, 10) + SourceIndex(0) +3 >Emitted(26, 32) Source(39, 11) + SourceIndex(0) +4 >Emitted(26, 36) Source(39, 15) + SourceIndex(0) +5 >Emitted(26, 37) Source(39, 16) + SourceIndex(0) --- >>> }; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -313,8 +318,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(22, 21) Source(40, 3) + SourceIndex(0) -2 >Emitted(22, 22) Source(40, 4) + SourceIndex(0) +1 >Emitted(27, 21) Source(40, 3) + SourceIndex(0) +2 >Emitted(27, 22) Source(40, 4) + SourceIndex(0) --- >>> return StartFindAction; 1->^^^^^^^^^^^^^^^^^^^^ @@ -322,8 +327,8 @@ sourceFile:recursiveClassReferenceTest.ts 1-> > 2 > } -1->Emitted(23, 21) Source(41, 2) + SourceIndex(0) -2 >Emitted(23, 43) Source(41, 3) + SourceIndex(0) +1->Emitted(28, 21) Source(41, 2) + SourceIndex(0) +2 >Emitted(28, 43) Source(41, 3) + SourceIndex(0) --- >>> }()); 1 >^^^^^^^^^^^^^^^^ @@ -343,10 +348,10 @@ sourceFile:recursiveClassReferenceTest.ts > return true; > } > } -1 >Emitted(24, 17) Source(41, 2) + SourceIndex(0) -2 >Emitted(24, 18) Source(41, 3) + SourceIndex(0) -3 >Emitted(24, 18) Source(33, 2) + SourceIndex(0) -4 >Emitted(24, 22) Source(41, 3) + SourceIndex(0) +1 >Emitted(29, 17) Source(41, 2) + SourceIndex(0) +2 >Emitted(29, 18) Source(41, 3) + SourceIndex(0) +3 >Emitted(29, 18) Source(33, 2) + SourceIndex(0) +4 >Emitted(29, 22) Source(41, 3) + SourceIndex(0) --- >>> Find.StartFindAction = StartFindAction; 1->^^^^^^^^^^^^^^^^ @@ -366,10 +371,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > } 4 > -1->Emitted(25, 17) Source(33, 15) + SourceIndex(0) -2 >Emitted(25, 37) Source(33, 30) + SourceIndex(0) -3 >Emitted(25, 55) Source(41, 3) + SourceIndex(0) -4 >Emitted(25, 56) Source(41, 3) + SourceIndex(0) +1->Emitted(30, 17) Source(33, 15) + SourceIndex(0) +2 >Emitted(30, 37) Source(33, 30) + SourceIndex(0) +3 >Emitted(30, 55) Source(41, 3) + SourceIndex(0) +4 >Emitted(30, 56) Source(41, 3) + SourceIndex(0) --- >>> })(Find = Thing_1.Find || (Thing_1.Find = {})); 1->^^^^^^^^^^^^ @@ -401,15 +406,15 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1->Emitted(26, 13) Source(42, 1) + SourceIndex(0) -2 >Emitted(26, 14) Source(42, 2) + SourceIndex(0) -3 >Emitted(26, 16) Source(32, 29) + SourceIndex(0) -4 >Emitted(26, 20) Source(32, 33) + SourceIndex(0) -5 >Emitted(26, 23) Source(32, 29) + SourceIndex(0) -6 >Emitted(26, 35) Source(32, 33) + SourceIndex(0) -7 >Emitted(26, 40) Source(32, 29) + SourceIndex(0) -8 >Emitted(26, 52) Source(32, 33) + SourceIndex(0) -9 >Emitted(26, 60) Source(42, 2) + SourceIndex(0) +1->Emitted(31, 13) Source(42, 1) + SourceIndex(0) +2 >Emitted(31, 14) Source(42, 2) + SourceIndex(0) +3 >Emitted(31, 16) Source(32, 29) + SourceIndex(0) +4 >Emitted(31, 20) Source(32, 33) + SourceIndex(0) +5 >Emitted(31, 23) Source(32, 29) + SourceIndex(0) +6 >Emitted(31, 35) Source(32, 33) + SourceIndex(0) +7 >Emitted(31, 40) Source(32, 29) + SourceIndex(0) +8 >Emitted(31, 52) Source(32, 33) + SourceIndex(0) +9 >Emitted(31, 60) Source(42, 2) + SourceIndex(0) --- >>> })(Thing = Actions.Thing || (Actions.Thing = {})); 1 >^^^^^^^^ @@ -441,15 +446,15 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(27, 9) Source(42, 1) + SourceIndex(0) -2 >Emitted(27, 10) Source(42, 2) + SourceIndex(0) -3 >Emitted(27, 12) Source(32, 23) + SourceIndex(0) -4 >Emitted(27, 17) Source(32, 28) + SourceIndex(0) -5 >Emitted(27, 20) Source(32, 23) + SourceIndex(0) -6 >Emitted(27, 33) Source(32, 28) + SourceIndex(0) -7 >Emitted(27, 38) Source(32, 23) + SourceIndex(0) -8 >Emitted(27, 51) Source(32, 28) + SourceIndex(0) -9 >Emitted(27, 59) Source(42, 2) + SourceIndex(0) +1 >Emitted(32, 9) Source(42, 1) + SourceIndex(0) +2 >Emitted(32, 10) Source(42, 2) + SourceIndex(0) +3 >Emitted(32, 12) Source(32, 23) + SourceIndex(0) +4 >Emitted(32, 17) Source(32, 28) + SourceIndex(0) +5 >Emitted(32, 20) Source(32, 23) + SourceIndex(0) +6 >Emitted(32, 33) Source(32, 28) + SourceIndex(0) +7 >Emitted(32, 38) Source(32, 23) + SourceIndex(0) +8 >Emitted(32, 51) Source(32, 28) + SourceIndex(0) +9 >Emitted(32, 59) Source(42, 2) + SourceIndex(0) --- >>> })(Actions = Sample.Actions || (Sample.Actions = {})); 1->^^^^ @@ -480,15 +485,15 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1->Emitted(28, 5) Source(42, 1) + SourceIndex(0) -2 >Emitted(28, 6) Source(42, 2) + SourceIndex(0) -3 >Emitted(28, 8) Source(32, 15) + SourceIndex(0) -4 >Emitted(28, 15) Source(32, 22) + SourceIndex(0) -5 >Emitted(28, 18) Source(32, 15) + SourceIndex(0) -6 >Emitted(28, 32) Source(32, 22) + SourceIndex(0) -7 >Emitted(28, 37) Source(32, 15) + SourceIndex(0) -8 >Emitted(28, 51) Source(32, 22) + SourceIndex(0) -9 >Emitted(28, 59) Source(42, 2) + SourceIndex(0) +1->Emitted(33, 5) Source(42, 1) + SourceIndex(0) +2 >Emitted(33, 6) Source(42, 2) + SourceIndex(0) +3 >Emitted(33, 8) Source(32, 15) + SourceIndex(0) +4 >Emitted(33, 15) Source(32, 22) + SourceIndex(0) +5 >Emitted(33, 18) Source(32, 15) + SourceIndex(0) +6 >Emitted(33, 32) Source(32, 22) + SourceIndex(0) +7 >Emitted(33, 37) Source(32, 15) + SourceIndex(0) +8 >Emitted(33, 51) Source(32, 22) + SourceIndex(0) +9 >Emitted(33, 59) Source(42, 2) + SourceIndex(0) --- >>>})(Sample || (Sample = {})); 1 > @@ -515,13 +520,13 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(29, 1) Source(42, 1) + SourceIndex(0) -2 >Emitted(29, 2) Source(42, 2) + SourceIndex(0) -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) +1 >Emitted(34, 1) Source(42, 1) + SourceIndex(0) +2 >Emitted(34, 2) Source(42, 2) + SourceIndex(0) +3 >Emitted(34, 4) Source(32, 8) + SourceIndex(0) +4 >Emitted(34, 10) Source(32, 14) + SourceIndex(0) +5 >Emitted(34, 15) Source(32, 8) + SourceIndex(0) +6 >Emitted(34, 21) Source(32, 14) + SourceIndex(0) +7 >Emitted(34, 29) Source(42, 2) + SourceIndex(0) --- >>>(function (Sample) { 1 > @@ -532,9 +537,9 @@ sourceFile:recursiveClassReferenceTest.ts > 2 >module 3 > Sample -1 >Emitted(30, 1) Source(44, 1) + SourceIndex(0) -2 >Emitted(30, 12) Source(44, 8) + SourceIndex(0) -3 >Emitted(30, 18) Source(44, 14) + SourceIndex(0) +1 >Emitted(35, 1) Source(44, 1) + SourceIndex(0) +2 >Emitted(35, 12) Source(44, 8) + SourceIndex(0) +3 >Emitted(35, 18) Source(44, 14) + SourceIndex(0) --- >>> var Thing; 1 >^^^^ @@ -566,10 +571,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(31, 5) Source(44, 15) + SourceIndex(0) -2 >Emitted(31, 9) Source(44, 15) + SourceIndex(0) -3 >Emitted(31, 14) Source(44, 20) + SourceIndex(0) -4 >Emitted(31, 15) Source(64, 2) + SourceIndex(0) +1 >Emitted(36, 5) Source(44, 15) + SourceIndex(0) +2 >Emitted(36, 9) Source(44, 15) + SourceIndex(0) +3 >Emitted(36, 14) Source(44, 20) + SourceIndex(0) +4 >Emitted(36, 15) Source(64, 2) + SourceIndex(0) --- >>> (function (Thing) { 1->^^^^ @@ -579,9 +584,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Thing -1->Emitted(32, 5) Source(44, 15) + SourceIndex(0) -2 >Emitted(32, 16) Source(44, 15) + SourceIndex(0) -3 >Emitted(32, 21) Source(44, 20) + SourceIndex(0) +1->Emitted(37, 5) Source(44, 15) + SourceIndex(0) +2 >Emitted(37, 16) Source(44, 15) + SourceIndex(0) +3 >Emitted(37, 21) Source(44, 20) + SourceIndex(0) --- >>> var Widgets; 1->^^^^^^^^ @@ -613,10 +618,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1->Emitted(33, 9) Source(44, 21) + SourceIndex(0) -2 >Emitted(33, 13) Source(44, 21) + SourceIndex(0) -3 >Emitted(33, 20) Source(44, 28) + SourceIndex(0) -4 >Emitted(33, 21) Source(64, 2) + SourceIndex(0) +1->Emitted(38, 9) Source(44, 21) + SourceIndex(0) +2 >Emitted(38, 13) Source(44, 21) + SourceIndex(0) +3 >Emitted(38, 20) Source(44, 28) + SourceIndex(0) +4 >Emitted(38, 21) Source(64, 2) + SourceIndex(0) --- >>> (function (Widgets) { 1->^^^^^^^^ @@ -626,16 +631,16 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Widgets -1->Emitted(34, 9) Source(44, 21) + SourceIndex(0) -2 >Emitted(34, 20) Source(44, 21) + SourceIndex(0) -3 >Emitted(34, 27) Source(44, 28) + SourceIndex(0) +1->Emitted(39, 9) Source(44, 21) + SourceIndex(0) +2 >Emitted(39, 20) Source(44, 21) + SourceIndex(0) +3 >Emitted(39, 27) Source(44, 28) + SourceIndex(0) --- >>> var FindWidget = (function () { 1->^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> { > -1->Emitted(35, 13) Source(45, 2) + SourceIndex(0) +1->Emitted(40, 13) Source(45, 2) + SourceIndex(0) --- >>> function FindWidget(codeThing) { 1->^^^^^^^^^^^^^^^^ @@ -650,9 +655,9 @@ sourceFile:recursiveClassReferenceTest.ts > 2 > constructor(private 3 > codeThing: Sample.Thing.ICodeThing -1->Emitted(36, 17) Source(50, 3) + SourceIndex(0) -2 >Emitted(36, 37) Source(50, 23) + SourceIndex(0) -3 >Emitted(36, 46) Source(50, 57) + SourceIndex(0) +1->Emitted(41, 17) Source(50, 3) + SourceIndex(0) +2 >Emitted(41, 37) Source(50, 23) + SourceIndex(0) +3 >Emitted(41, 46) Source(50, 57) + SourceIndex(0) --- >>> this.codeThing = codeThing; 1->^^^^^^^^^^^^^^^^^^^^ @@ -665,11 +670,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > codeThing 5 > : Sample.Thing.ICodeThing -1->Emitted(37, 21) Source(50, 23) + SourceIndex(0) -2 >Emitted(37, 35) Source(50, 32) + SourceIndex(0) -3 >Emitted(37, 38) Source(50, 23) + SourceIndex(0) -4 >Emitted(37, 47) Source(50, 32) + SourceIndex(0) -5 >Emitted(37, 48) Source(50, 57) + SourceIndex(0) +1->Emitted(42, 21) Source(50, 23) + SourceIndex(0) +2 >Emitted(42, 35) Source(50, 32) + SourceIndex(0) +3 >Emitted(42, 38) Source(50, 23) + SourceIndex(0) +4 >Emitted(42, 47) Source(50, 32) + SourceIndex(0) +5 >Emitted(42, 48) Source(50, 57) + SourceIndex(0) --- >>> this.domNode = null; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -682,11 +687,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > :any = 4 > null 5 > ; -1 >Emitted(38, 21) Source(49, 11) + SourceIndex(0) -2 >Emitted(38, 33) Source(49, 18) + SourceIndex(0) -3 >Emitted(38, 36) Source(49, 25) + SourceIndex(0) -4 >Emitted(38, 40) Source(49, 29) + SourceIndex(0) -5 >Emitted(38, 41) Source(49, 30) + SourceIndex(0) +1 >Emitted(43, 21) Source(49, 11) + SourceIndex(0) +2 >Emitted(43, 33) Source(49, 18) + SourceIndex(0) +3 >Emitted(43, 36) Source(49, 25) + SourceIndex(0) +4 >Emitted(43, 40) Source(49, 29) + SourceIndex(0) +5 >Emitted(43, 41) Source(49, 30) + SourceIndex(0) --- >>> // scenario 1 1 >^^^^^^^^^^^^^^^^^^^^ @@ -696,8 +701,8 @@ sourceFile:recursiveClassReferenceTest.ts > constructor(private codeThing: Sample.Thing.ICodeThing) { > 2 > // scenario 1 -1 >Emitted(39, 21) Source(51, 7) + SourceIndex(0) -2 >Emitted(39, 34) Source(51, 20) + SourceIndex(0) +1 >Emitted(44, 21) Source(51, 7) + SourceIndex(0) +2 >Emitted(44, 34) Source(51, 20) + SourceIndex(0) --- >>> codeThing.addWidget("addWidget", this); 1->^^^^^^^^^^^^^^^^^^^^ @@ -721,16 +726,16 @@ sourceFile:recursiveClassReferenceTest.ts 8 > this 9 > ) 10> ; -1->Emitted(40, 21) Source(52, 7) + SourceIndex(0) -2 >Emitted(40, 30) Source(52, 16) + SourceIndex(0) -3 >Emitted(40, 31) Source(52, 17) + SourceIndex(0) -4 >Emitted(40, 40) Source(52, 26) + SourceIndex(0) -5 >Emitted(40, 41) Source(52, 27) + SourceIndex(0) -6 >Emitted(40, 52) Source(52, 38) + SourceIndex(0) -7 >Emitted(40, 54) Source(52, 40) + SourceIndex(0) -8 >Emitted(40, 58) Source(52, 44) + SourceIndex(0) -9 >Emitted(40, 59) Source(52, 45) + SourceIndex(0) -10>Emitted(40, 60) Source(52, 46) + SourceIndex(0) +1->Emitted(45, 21) Source(52, 7) + SourceIndex(0) +2 >Emitted(45, 30) Source(52, 16) + SourceIndex(0) +3 >Emitted(45, 31) Source(52, 17) + SourceIndex(0) +4 >Emitted(45, 40) Source(52, 26) + SourceIndex(0) +5 >Emitted(45, 41) Source(52, 27) + SourceIndex(0) +6 >Emitted(45, 52) Source(52, 38) + SourceIndex(0) +7 >Emitted(45, 54) Source(52, 40) + SourceIndex(0) +8 >Emitted(45, 58) Source(52, 44) + SourceIndex(0) +9 >Emitted(45, 59) Source(52, 45) + SourceIndex(0) +10>Emitted(45, 60) Source(52, 46) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^ @@ -739,8 +744,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(41, 17) Source(53, 3) + SourceIndex(0) -2 >Emitted(41, 18) Source(53, 4) + SourceIndex(0) +1 >Emitted(46, 17) Source(53, 3) + SourceIndex(0) +2 >Emitted(46, 18) Source(53, 4) + SourceIndex(0) --- >>> FindWidget.prototype.gar = function (runner) { if (true) { 1->^^^^^^^^^^^^^^^^ @@ -769,19 +774,19 @@ sourceFile:recursiveClassReferenceTest.ts 11> ) 12> 13> { -1->Emitted(42, 17) Source(47, 10) + SourceIndex(0) -2 >Emitted(42, 41) Source(47, 13) + SourceIndex(0) -3 >Emitted(42, 44) Source(47, 3) + SourceIndex(0) -4 >Emitted(42, 54) Source(47, 14) + SourceIndex(0) -5 >Emitted(42, 60) Source(47, 55) + SourceIndex(0) -6 >Emitted(42, 64) Source(47, 59) + SourceIndex(0) -7 >Emitted(42, 66) Source(47, 61) + SourceIndex(0) -8 >Emitted(42, 67) Source(47, 62) + SourceIndex(0) -9 >Emitted(42, 68) Source(47, 63) + SourceIndex(0) -10>Emitted(42, 72) Source(47, 67) + SourceIndex(0) -11>Emitted(42, 73) Source(47, 68) + SourceIndex(0) -12>Emitted(42, 74) Source(47, 69) + SourceIndex(0) -13>Emitted(42, 75) Source(47, 70) + SourceIndex(0) +1->Emitted(47, 17) Source(47, 10) + SourceIndex(0) +2 >Emitted(47, 41) Source(47, 13) + SourceIndex(0) +3 >Emitted(47, 44) Source(47, 3) + SourceIndex(0) +4 >Emitted(47, 54) Source(47, 14) + SourceIndex(0) +5 >Emitted(47, 60) Source(47, 55) + SourceIndex(0) +6 >Emitted(47, 64) Source(47, 59) + SourceIndex(0) +7 >Emitted(47, 66) Source(47, 61) + SourceIndex(0) +8 >Emitted(47, 67) Source(47, 62) + SourceIndex(0) +9 >Emitted(47, 68) Source(47, 63) + SourceIndex(0) +10>Emitted(47, 72) Source(47, 67) + SourceIndex(0) +11>Emitted(47, 73) Source(47, 68) + SourceIndex(0) +12>Emitted(47, 74) Source(47, 69) + SourceIndex(0) +13>Emitted(47, 75) Source(47, 70) + SourceIndex(0) --- >>> return runner(this); 1 >^^^^^^^^^^^^^^^^^^^^ @@ -800,14 +805,14 @@ sourceFile:recursiveClassReferenceTest.ts 6 > this 7 > ) 8 > ; -1 >Emitted(43, 21) Source(47, 70) + SourceIndex(0) -2 >Emitted(43, 27) Source(47, 76) + SourceIndex(0) -3 >Emitted(43, 28) Source(47, 77) + SourceIndex(0) -4 >Emitted(43, 34) Source(47, 83) + SourceIndex(0) -5 >Emitted(43, 35) Source(47, 84) + SourceIndex(0) -6 >Emitted(43, 39) Source(47, 88) + SourceIndex(0) -7 >Emitted(43, 40) Source(47, 89) + SourceIndex(0) -8 >Emitted(43, 41) Source(47, 90) + SourceIndex(0) +1 >Emitted(48, 21) Source(47, 70) + SourceIndex(0) +2 >Emitted(48, 27) Source(47, 76) + SourceIndex(0) +3 >Emitted(48, 28) Source(47, 77) + SourceIndex(0) +4 >Emitted(48, 34) Source(47, 83) + SourceIndex(0) +5 >Emitted(48, 35) Source(47, 84) + SourceIndex(0) +6 >Emitted(48, 39) Source(47, 88) + SourceIndex(0) +7 >Emitted(48, 40) Source(47, 89) + SourceIndex(0) +8 >Emitted(48, 41) Source(47, 90) + SourceIndex(0) --- >>> } }; 1 >^^^^^^^^^^^^^^^^ @@ -819,10 +824,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 > } 3 > 4 > } -1 >Emitted(44, 17) Source(47, 90) + SourceIndex(0) -2 >Emitted(44, 18) Source(47, 91) + SourceIndex(0) -3 >Emitted(44, 19) Source(47, 91) + SourceIndex(0) -4 >Emitted(44, 20) Source(47, 92) + SourceIndex(0) +1 >Emitted(49, 17) Source(47, 90) + SourceIndex(0) +2 >Emitted(49, 18) Source(47, 91) + SourceIndex(0) +3 >Emitted(49, 19) Source(47, 91) + SourceIndex(0) +4 >Emitted(49, 20) Source(47, 92) + SourceIndex(0) --- >>> FindWidget.prototype.getDomNode = function () { 1->^^^^^^^^^^^^^^^^ @@ -839,9 +844,9 @@ sourceFile:recursiveClassReferenceTest.ts > public 2 > getDomNode 3 > -1->Emitted(45, 17) Source(55, 10) + SourceIndex(0) -2 >Emitted(45, 48) Source(55, 20) + SourceIndex(0) -3 >Emitted(45, 51) Source(55, 3) + SourceIndex(0) +1->Emitted(50, 17) Source(55, 10) + SourceIndex(0) +2 >Emitted(50, 48) Source(55, 20) + SourceIndex(0) +3 >Emitted(50, 51) Source(55, 3) + SourceIndex(0) --- >>> return domNode; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -855,11 +860,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > domNode 5 > ; -1 >Emitted(46, 21) Source(56, 4) + SourceIndex(0) -2 >Emitted(46, 27) Source(56, 10) + SourceIndex(0) -3 >Emitted(46, 28) Source(56, 11) + SourceIndex(0) -4 >Emitted(46, 35) Source(56, 18) + SourceIndex(0) -5 >Emitted(46, 36) Source(56, 19) + SourceIndex(0) +1 >Emitted(51, 21) Source(56, 4) + SourceIndex(0) +2 >Emitted(51, 27) Source(56, 10) + SourceIndex(0) +3 >Emitted(51, 28) Source(56, 11) + SourceIndex(0) +4 >Emitted(51, 35) Source(56, 18) + SourceIndex(0) +5 >Emitted(51, 36) Source(56, 19) + SourceIndex(0) --- >>> }; 1 >^^^^^^^^^^^^^^^^ @@ -868,8 +873,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(47, 17) Source(57, 3) + SourceIndex(0) -2 >Emitted(47, 18) Source(57, 4) + SourceIndex(0) +1 >Emitted(52, 17) Source(57, 3) + SourceIndex(0) +2 >Emitted(52, 18) Source(57, 4) + SourceIndex(0) --- >>> FindWidget.prototype.destroy = function () { 1->^^^^^^^^^^^^^^^^ @@ -880,9 +885,9 @@ sourceFile:recursiveClassReferenceTest.ts > public 2 > destroy 3 > -1->Emitted(48, 17) Source(59, 10) + SourceIndex(0) -2 >Emitted(48, 45) Source(59, 17) + SourceIndex(0) -3 >Emitted(48, 48) Source(59, 3) + SourceIndex(0) +1->Emitted(53, 17) Source(59, 10) + SourceIndex(0) +2 >Emitted(53, 45) Source(59, 17) + SourceIndex(0) +3 >Emitted(53, 48) Source(59, 3) + SourceIndex(0) --- >>> }; 1 >^^^^^^^^^^^^^^^^ @@ -892,8 +897,8 @@ sourceFile:recursiveClassReferenceTest.ts > > 2 > } -1 >Emitted(49, 17) Source(61, 3) + SourceIndex(0) -2 >Emitted(49, 18) Source(61, 4) + SourceIndex(0) +1 >Emitted(54, 17) Source(61, 3) + SourceIndex(0) +2 >Emitted(54, 18) Source(61, 4) + SourceIndex(0) --- >>> return FindWidget; 1->^^^^^^^^^^^^^^^^ @@ -902,8 +907,8 @@ sourceFile:recursiveClassReferenceTest.ts > > 2 > } -1->Emitted(50, 17) Source(63, 2) + SourceIndex(0) -2 >Emitted(50, 34) Source(63, 3) + SourceIndex(0) +1->Emitted(55, 17) Source(63, 2) + SourceIndex(0) +2 >Emitted(55, 34) Source(63, 3) + SourceIndex(0) --- >>> }()); 1 >^^^^^^^^^^^^ @@ -933,10 +938,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > > } -1 >Emitted(51, 13) Source(63, 2) + SourceIndex(0) -2 >Emitted(51, 14) Source(63, 3) + SourceIndex(0) -3 >Emitted(51, 14) Source(45, 2) + SourceIndex(0) -4 >Emitted(51, 18) Source(63, 3) + SourceIndex(0) +1 >Emitted(56, 13) Source(63, 2) + SourceIndex(0) +2 >Emitted(56, 14) Source(63, 3) + SourceIndex(0) +3 >Emitted(56, 14) Source(45, 2) + SourceIndex(0) +4 >Emitted(56, 18) Source(63, 3) + SourceIndex(0) --- >>> Widgets.FindWidget = FindWidget; 1->^^^^^^^^^^^^ @@ -966,10 +971,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } 4 > -1->Emitted(52, 13) Source(45, 15) + SourceIndex(0) -2 >Emitted(52, 31) Source(45, 25) + SourceIndex(0) -3 >Emitted(52, 44) Source(63, 3) + SourceIndex(0) -4 >Emitted(52, 45) Source(63, 3) + SourceIndex(0) +1->Emitted(57, 13) Source(45, 15) + SourceIndex(0) +2 >Emitted(57, 31) Source(45, 25) + SourceIndex(0) +3 >Emitted(57, 44) Source(63, 3) + SourceIndex(0) +4 >Emitted(57, 45) Source(63, 3) + SourceIndex(0) --- >>> })(Widgets = Thing.Widgets || (Thing.Widgets = {})); 1->^^^^^^^^ @@ -1011,15 +1016,15 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1->Emitted(53, 9) Source(64, 1) + SourceIndex(0) -2 >Emitted(53, 10) Source(64, 2) + SourceIndex(0) -3 >Emitted(53, 12) Source(44, 21) + SourceIndex(0) -4 >Emitted(53, 19) Source(44, 28) + SourceIndex(0) -5 >Emitted(53, 22) Source(44, 21) + SourceIndex(0) -6 >Emitted(53, 35) Source(44, 28) + SourceIndex(0) -7 >Emitted(53, 40) Source(44, 21) + SourceIndex(0) -8 >Emitted(53, 53) Source(44, 28) + SourceIndex(0) -9 >Emitted(53, 61) Source(64, 2) + SourceIndex(0) +1->Emitted(58, 9) Source(64, 1) + SourceIndex(0) +2 >Emitted(58, 10) Source(64, 2) + SourceIndex(0) +3 >Emitted(58, 12) Source(44, 21) + SourceIndex(0) +4 >Emitted(58, 19) Source(44, 28) + SourceIndex(0) +5 >Emitted(58, 22) Source(44, 21) + SourceIndex(0) +6 >Emitted(58, 35) Source(44, 28) + SourceIndex(0) +7 >Emitted(58, 40) Source(44, 21) + SourceIndex(0) +8 >Emitted(58, 53) Source(44, 28) + SourceIndex(0) +9 >Emitted(58, 61) Source(64, 2) + SourceIndex(0) --- >>> })(Thing = Sample.Thing || (Sample.Thing = {})); 1 >^^^^ @@ -1060,15 +1065,15 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(54, 5) Source(64, 1) + SourceIndex(0) -2 >Emitted(54, 6) Source(64, 2) + SourceIndex(0) -3 >Emitted(54, 8) Source(44, 15) + SourceIndex(0) -4 >Emitted(54, 13) Source(44, 20) + SourceIndex(0) -5 >Emitted(54, 16) Source(44, 15) + SourceIndex(0) -6 >Emitted(54, 28) Source(44, 20) + SourceIndex(0) -7 >Emitted(54, 33) Source(44, 15) + SourceIndex(0) -8 >Emitted(54, 45) Source(44, 20) + SourceIndex(0) -9 >Emitted(54, 53) Source(64, 2) + SourceIndex(0) +1 >Emitted(59, 5) Source(64, 1) + SourceIndex(0) +2 >Emitted(59, 6) Source(64, 2) + SourceIndex(0) +3 >Emitted(59, 8) Source(44, 15) + SourceIndex(0) +4 >Emitted(59, 13) Source(44, 20) + SourceIndex(0) +5 >Emitted(59, 16) Source(44, 15) + SourceIndex(0) +6 >Emitted(59, 28) Source(44, 20) + SourceIndex(0) +7 >Emitted(59, 33) Source(44, 15) + SourceIndex(0) +8 >Emitted(59, 45) Source(44, 20) + SourceIndex(0) +9 >Emitted(59, 53) Source(64, 2) + SourceIndex(0) --- >>>})(Sample || (Sample = {})); 1 > @@ -1106,13 +1111,13 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(55, 1) Source(64, 1) + SourceIndex(0) -2 >Emitted(55, 2) Source(64, 2) + SourceIndex(0) -3 >Emitted(55, 4) Source(44, 8) + SourceIndex(0) -4 >Emitted(55, 10) Source(44, 14) + SourceIndex(0) -5 >Emitted(55, 15) Source(44, 8) + SourceIndex(0) -6 >Emitted(55, 21) Source(44, 14) + SourceIndex(0) -7 >Emitted(55, 29) Source(64, 2) + SourceIndex(0) +1 >Emitted(60, 1) Source(64, 1) + SourceIndex(0) +2 >Emitted(60, 2) Source(64, 2) + SourceIndex(0) +3 >Emitted(60, 4) Source(44, 8) + SourceIndex(0) +4 >Emitted(60, 10) Source(44, 14) + SourceIndex(0) +5 >Emitted(60, 15) Source(44, 8) + SourceIndex(0) +6 >Emitted(60, 21) Source(44, 14) + SourceIndex(0) +7 >Emitted(60, 29) Source(64, 2) + SourceIndex(0) --- >>>var AbstractMode = (function () { 1-> @@ -1121,13 +1126,13 @@ sourceFile:recursiveClassReferenceTest.ts > >interface IMode { getInitialState(): IState;} > -1->Emitted(56, 1) Source(67, 1) + SourceIndex(0) +1->Emitted(61, 1) Source(67, 1) + SourceIndex(0) --- >>> function AbstractMode() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(57, 5) Source(67, 1) + SourceIndex(0) +1->Emitted(62, 5) Source(67, 1) + SourceIndex(0) --- >>> } 1->^^^^ @@ -1135,8 +1140,8 @@ sourceFile:recursiveClassReferenceTest.ts 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1->class AbstractMode implements IMode { public getInitialState(): IState { return null;} 2 > } -1->Emitted(58, 5) Source(67, 88) + SourceIndex(0) -2 >Emitted(58, 6) Source(67, 89) + SourceIndex(0) +1->Emitted(63, 5) Source(67, 88) + SourceIndex(0) +2 >Emitted(63, 6) Source(67, 89) + SourceIndex(0) --- >>> AbstractMode.prototype.getInitialState = function () { return null; }; 1->^^^^ @@ -1159,24 +1164,24 @@ sourceFile:recursiveClassReferenceTest.ts 8 > ; 9 > 10> } -1->Emitted(59, 5) Source(67, 46) + SourceIndex(0) -2 >Emitted(59, 43) Source(67, 61) + SourceIndex(0) -3 >Emitted(59, 46) Source(67, 39) + SourceIndex(0) -4 >Emitted(59, 60) Source(67, 74) + SourceIndex(0) -5 >Emitted(59, 66) Source(67, 80) + SourceIndex(0) -6 >Emitted(59, 67) Source(67, 81) + SourceIndex(0) -7 >Emitted(59, 71) Source(67, 85) + SourceIndex(0) -8 >Emitted(59, 72) Source(67, 86) + SourceIndex(0) -9 >Emitted(59, 73) Source(67, 86) + SourceIndex(0) -10>Emitted(59, 74) Source(67, 87) + SourceIndex(0) +1->Emitted(64, 5) Source(67, 46) + SourceIndex(0) +2 >Emitted(64, 43) Source(67, 61) + SourceIndex(0) +3 >Emitted(64, 46) Source(67, 39) + SourceIndex(0) +4 >Emitted(64, 60) Source(67, 74) + SourceIndex(0) +5 >Emitted(64, 66) Source(67, 80) + SourceIndex(0) +6 >Emitted(64, 67) Source(67, 81) + SourceIndex(0) +7 >Emitted(64, 71) Source(67, 85) + SourceIndex(0) +8 >Emitted(64, 72) Source(67, 86) + SourceIndex(0) +9 >Emitted(64, 73) Source(67, 86) + SourceIndex(0) +10>Emitted(64, 74) Source(67, 87) + SourceIndex(0) --- >>> return AbstractMode; 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^ 1 > 2 > } -1 >Emitted(60, 5) Source(67, 88) + SourceIndex(0) -2 >Emitted(60, 24) Source(67, 89) + SourceIndex(0) +1 >Emitted(65, 5) Source(67, 88) + SourceIndex(0) +2 >Emitted(65, 24) Source(67, 89) + SourceIndex(0) --- >>>}()); 1 > @@ -1188,10 +1193,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 >} 3 > 4 > class AbstractMode implements IMode { public getInitialState(): IState { return null;} } -1 >Emitted(61, 1) Source(67, 88) + SourceIndex(0) -2 >Emitted(61, 2) Source(67, 89) + SourceIndex(0) -3 >Emitted(61, 2) Source(67, 1) + SourceIndex(0) -4 >Emitted(61, 6) Source(67, 89) + SourceIndex(0) +1 >Emitted(66, 1) Source(67, 88) + SourceIndex(0) +2 >Emitted(66, 2) Source(67, 89) + SourceIndex(0) +3 >Emitted(66, 2) Source(67, 1) + SourceIndex(0) +4 >Emitted(66, 6) Source(67, 89) + SourceIndex(0) --- >>>(function (Sample) { 1-> @@ -1209,9 +1214,9 @@ sourceFile:recursiveClassReferenceTest.ts > 2 >module 3 > Sample -1->Emitted(62, 1) Source(76, 1) + SourceIndex(0) -2 >Emitted(62, 12) Source(76, 8) + SourceIndex(0) -3 >Emitted(62, 18) Source(76, 14) + SourceIndex(0) +1->Emitted(67, 1) Source(76, 1) + SourceIndex(0) +2 >Emitted(67, 12) Source(76, 8) + SourceIndex(0) +3 >Emitted(67, 18) Source(76, 14) + SourceIndex(0) --- >>> var Thing; 1 >^^^^ @@ -1247,10 +1252,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(63, 5) Source(76, 15) + SourceIndex(0) -2 >Emitted(63, 9) Source(76, 15) + SourceIndex(0) -3 >Emitted(63, 14) Source(76, 20) + SourceIndex(0) -4 >Emitted(63, 15) Source(100, 2) + SourceIndex(0) +1 >Emitted(68, 5) Source(76, 15) + SourceIndex(0) +2 >Emitted(68, 9) Source(76, 15) + SourceIndex(0) +3 >Emitted(68, 14) Source(76, 20) + SourceIndex(0) +4 >Emitted(68, 15) Source(100, 2) + SourceIndex(0) --- >>> (function (Thing) { 1->^^^^ @@ -1260,9 +1265,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Thing -1->Emitted(64, 5) Source(76, 15) + SourceIndex(0) -2 >Emitted(64, 16) Source(76, 15) + SourceIndex(0) -3 >Emitted(64, 21) Source(76, 20) + SourceIndex(0) +1->Emitted(69, 5) Source(76, 15) + SourceIndex(0) +2 >Emitted(69, 16) Source(76, 15) + SourceIndex(0) +3 >Emitted(69, 21) Source(76, 20) + SourceIndex(0) --- >>> var Languages; 1->^^^^^^^^ @@ -1298,10 +1303,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1->Emitted(65, 9) Source(76, 21) + SourceIndex(0) -2 >Emitted(65, 13) Source(76, 21) + SourceIndex(0) -3 >Emitted(65, 22) Source(76, 30) + SourceIndex(0) -4 >Emitted(65, 23) Source(100, 2) + SourceIndex(0) +1->Emitted(70, 9) Source(76, 21) + SourceIndex(0) +2 >Emitted(70, 13) Source(76, 21) + SourceIndex(0) +3 >Emitted(70, 22) Source(76, 30) + SourceIndex(0) +4 >Emitted(70, 23) Source(100, 2) + SourceIndex(0) --- >>> (function (Languages) { 1->^^^^^^^^ @@ -1310,9 +1315,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Languages -1->Emitted(66, 9) Source(76, 21) + SourceIndex(0) -2 >Emitted(66, 20) Source(76, 21) + SourceIndex(0) -3 >Emitted(66, 29) Source(76, 30) + SourceIndex(0) +1->Emitted(71, 9) Source(76, 21) + SourceIndex(0) +2 >Emitted(71, 20) Source(76, 21) + SourceIndex(0) +3 >Emitted(71, 29) Source(76, 30) + SourceIndex(0) --- >>> var PlainText; 1 >^^^^^^^^^^^^ @@ -1348,10 +1353,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(67, 13) Source(76, 31) + SourceIndex(0) -2 >Emitted(67, 17) Source(76, 31) + SourceIndex(0) -3 >Emitted(67, 26) Source(76, 40) + SourceIndex(0) -4 >Emitted(67, 27) Source(100, 2) + SourceIndex(0) +1 >Emitted(72, 13) Source(76, 31) + SourceIndex(0) +2 >Emitted(72, 17) Source(76, 31) + SourceIndex(0) +3 >Emitted(72, 26) Source(76, 40) + SourceIndex(0) +4 >Emitted(72, 27) Source(100, 2) + SourceIndex(0) --- >>> (function (PlainText) { 1->^^^^^^^^^^^^ @@ -1361,9 +1366,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > PlainText -1->Emitted(68, 13) Source(76, 31) + SourceIndex(0) -2 >Emitted(68, 24) Source(76, 31) + SourceIndex(0) -3 >Emitted(68, 33) Source(76, 40) + SourceIndex(0) +1->Emitted(73, 13) Source(76, 31) + SourceIndex(0) +2 >Emitted(73, 24) Source(76, 31) + SourceIndex(0) +3 >Emitted(73, 33) Source(76, 40) + SourceIndex(0) --- >>> var State = (function () { 1->^^^^^^^^^^^^^^^^ @@ -1371,7 +1376,7 @@ sourceFile:recursiveClassReferenceTest.ts 1-> { > > -1->Emitted(69, 17) Source(78, 2) + SourceIndex(0) +1->Emitted(74, 17) Source(78, 2) + SourceIndex(0) --- >>> function State(mode) { 1->^^^^^^^^^^^^^^^^^^^^ @@ -1382,9 +1387,9 @@ sourceFile:recursiveClassReferenceTest.ts > 2 > constructor(private 3 > mode: IMode -1->Emitted(70, 21) Source(79, 9) + SourceIndex(0) -2 >Emitted(70, 36) Source(79, 29) + SourceIndex(0) -3 >Emitted(70, 40) Source(79, 40) + SourceIndex(0) +1->Emitted(75, 21) Source(79, 9) + SourceIndex(0) +2 >Emitted(75, 36) Source(79, 29) + SourceIndex(0) +3 >Emitted(75, 40) Source(79, 40) + SourceIndex(0) --- >>> this.mode = mode; 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1397,11 +1402,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > mode 5 > : IMode -1->Emitted(71, 25) Source(79, 29) + SourceIndex(0) -2 >Emitted(71, 34) Source(79, 33) + SourceIndex(0) -3 >Emitted(71, 37) Source(79, 29) + SourceIndex(0) -4 >Emitted(71, 41) Source(79, 33) + SourceIndex(0) -5 >Emitted(71, 42) Source(79, 40) + SourceIndex(0) +1->Emitted(76, 25) Source(79, 29) + SourceIndex(0) +2 >Emitted(76, 34) Source(79, 33) + SourceIndex(0) +3 >Emitted(76, 37) Source(79, 29) + SourceIndex(0) +4 >Emitted(76, 41) Source(79, 33) + SourceIndex(0) +5 >Emitted(76, 42) Source(79, 40) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1409,8 +1414,8 @@ sourceFile:recursiveClassReferenceTest.ts 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >) { 2 > } -1 >Emitted(72, 21) Source(79, 44) + SourceIndex(0) -2 >Emitted(72, 22) Source(79, 45) + SourceIndex(0) +1 >Emitted(77, 21) Source(79, 44) + SourceIndex(0) +2 >Emitted(77, 22) Source(79, 45) + SourceIndex(0) --- >>> State.prototype.clone = function () { 1->^^^^^^^^^^^^^^^^^^^^ @@ -1420,9 +1425,9 @@ sourceFile:recursiveClassReferenceTest.ts > public 2 > clone 3 > -1->Emitted(73, 21) Source(80, 10) + SourceIndex(0) -2 >Emitted(73, 42) Source(80, 15) + SourceIndex(0) -3 >Emitted(73, 45) Source(80, 3) + SourceIndex(0) +1->Emitted(78, 21) Source(80, 10) + SourceIndex(0) +2 >Emitted(78, 42) Source(80, 15) + SourceIndex(0) +3 >Emitted(78, 45) Source(80, 3) + SourceIndex(0) --- >>> return this; 1 >^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1436,11 +1441,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > this 5 > ; -1 >Emitted(74, 25) Source(81, 4) + SourceIndex(0) -2 >Emitted(74, 31) Source(81, 10) + SourceIndex(0) -3 >Emitted(74, 32) Source(81, 11) + SourceIndex(0) -4 >Emitted(74, 36) Source(81, 15) + SourceIndex(0) -5 >Emitted(74, 37) Source(81, 16) + SourceIndex(0) +1 >Emitted(79, 25) Source(81, 4) + SourceIndex(0) +2 >Emitted(79, 31) Source(81, 10) + SourceIndex(0) +3 >Emitted(79, 32) Source(81, 11) + SourceIndex(0) +4 >Emitted(79, 36) Source(81, 15) + SourceIndex(0) +5 >Emitted(79, 37) Source(81, 16) + SourceIndex(0) --- >>> }; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1449,8 +1454,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(75, 21) Source(82, 3) + SourceIndex(0) -2 >Emitted(75, 22) Source(82, 4) + SourceIndex(0) +1 >Emitted(80, 21) Source(82, 3) + SourceIndex(0) +2 >Emitted(80, 22) Source(82, 4) + SourceIndex(0) --- >>> State.prototype.equals = function (other) { 1->^^^^^^^^^^^^^^^^^^^^ @@ -1465,11 +1470,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > public equals( 5 > other:IState -1->Emitted(76, 21) Source(84, 10) + SourceIndex(0) -2 >Emitted(76, 43) Source(84, 16) + SourceIndex(0) -3 >Emitted(76, 46) Source(84, 3) + SourceIndex(0) -4 >Emitted(76, 56) Source(84, 17) + SourceIndex(0) -5 >Emitted(76, 61) Source(84, 29) + SourceIndex(0) +1->Emitted(81, 21) Source(84, 10) + SourceIndex(0) +2 >Emitted(81, 43) Source(84, 16) + SourceIndex(0) +3 >Emitted(81, 46) Source(84, 3) + SourceIndex(0) +4 >Emitted(81, 56) Source(84, 17) + SourceIndex(0) +5 >Emitted(81, 61) Source(84, 29) + SourceIndex(0) --- >>> return this === other; 1 >^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1487,13 +1492,13 @@ sourceFile:recursiveClassReferenceTest.ts 5 > === 6 > other 7 > ; -1 >Emitted(77, 25) Source(85, 4) + SourceIndex(0) -2 >Emitted(77, 31) Source(85, 10) + SourceIndex(0) -3 >Emitted(77, 32) Source(85, 11) + SourceIndex(0) -4 >Emitted(77, 36) Source(85, 15) + SourceIndex(0) -5 >Emitted(77, 41) Source(85, 20) + SourceIndex(0) -6 >Emitted(77, 46) Source(85, 25) + SourceIndex(0) -7 >Emitted(77, 47) Source(85, 26) + SourceIndex(0) +1 >Emitted(82, 25) Source(85, 4) + SourceIndex(0) +2 >Emitted(82, 31) Source(85, 10) + SourceIndex(0) +3 >Emitted(82, 32) Source(85, 11) + SourceIndex(0) +4 >Emitted(82, 36) Source(85, 15) + SourceIndex(0) +5 >Emitted(82, 41) Source(85, 20) + SourceIndex(0) +6 >Emitted(82, 46) Source(85, 25) + SourceIndex(0) +7 >Emitted(82, 47) Source(85, 26) + SourceIndex(0) --- >>> }; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1502,8 +1507,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(78, 21) Source(86, 3) + SourceIndex(0) -2 >Emitted(78, 22) Source(86, 4) + SourceIndex(0) +1 >Emitted(83, 21) Source(86, 3) + SourceIndex(0) +2 >Emitted(83, 22) Source(86, 4) + SourceIndex(0) --- >>> State.prototype.getMode = function () { return mode; }; 1->^^^^^^^^^^^^^^^^^^^^ @@ -1528,16 +1533,16 @@ sourceFile:recursiveClassReferenceTest.ts 8 > ; 9 > 10> } -1->Emitted(79, 21) Source(88, 10) + SourceIndex(0) -2 >Emitted(79, 44) Source(88, 17) + SourceIndex(0) -3 >Emitted(79, 47) Source(88, 3) + SourceIndex(0) -4 >Emitted(79, 61) Source(88, 29) + SourceIndex(0) -5 >Emitted(79, 67) Source(88, 35) + SourceIndex(0) -6 >Emitted(79, 68) Source(88, 36) + SourceIndex(0) -7 >Emitted(79, 72) Source(88, 40) + SourceIndex(0) -8 >Emitted(79, 73) Source(88, 41) + SourceIndex(0) -9 >Emitted(79, 74) Source(88, 42) + SourceIndex(0) -10>Emitted(79, 75) Source(88, 43) + SourceIndex(0) +1->Emitted(84, 21) Source(88, 10) + SourceIndex(0) +2 >Emitted(84, 44) Source(88, 17) + SourceIndex(0) +3 >Emitted(84, 47) Source(88, 3) + SourceIndex(0) +4 >Emitted(84, 61) Source(88, 29) + SourceIndex(0) +5 >Emitted(84, 67) Source(88, 35) + SourceIndex(0) +6 >Emitted(84, 68) Source(88, 36) + SourceIndex(0) +7 >Emitted(84, 72) Source(88, 40) + SourceIndex(0) +8 >Emitted(84, 73) Source(88, 41) + SourceIndex(0) +9 >Emitted(84, 74) Source(88, 42) + SourceIndex(0) +10>Emitted(84, 75) Source(88, 43) + SourceIndex(0) --- >>> return State; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1545,8 +1550,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(80, 21) Source(89, 2) + SourceIndex(0) -2 >Emitted(80, 33) Source(89, 3) + SourceIndex(0) +1 >Emitted(85, 21) Source(89, 2) + SourceIndex(0) +2 >Emitted(85, 33) Source(89, 3) + SourceIndex(0) --- >>> }()); 1 >^^^^^^^^^^^^^^^^ @@ -1569,10 +1574,10 @@ sourceFile:recursiveClassReferenceTest.ts > > public getMode(): IMode { return mode; } > } -1 >Emitted(81, 17) Source(89, 2) + SourceIndex(0) -2 >Emitted(81, 18) Source(89, 3) + SourceIndex(0) -3 >Emitted(81, 18) Source(78, 2) + SourceIndex(0) -4 >Emitted(81, 22) Source(89, 3) + SourceIndex(0) +1 >Emitted(86, 17) Source(89, 2) + SourceIndex(0) +2 >Emitted(86, 18) Source(89, 3) + SourceIndex(0) +3 >Emitted(86, 18) Source(78, 2) + SourceIndex(0) +4 >Emitted(86, 22) Source(89, 3) + SourceIndex(0) --- >>> PlainText.State = State; 1->^^^^^^^^^^^^^^^^ @@ -1595,10 +1600,10 @@ sourceFile:recursiveClassReferenceTest.ts > public getMode(): IMode { return mode; } > } 4 > -1->Emitted(82, 17) Source(78, 15) + SourceIndex(0) -2 >Emitted(82, 32) Source(78, 20) + SourceIndex(0) -3 >Emitted(82, 40) Source(89, 3) + SourceIndex(0) -4 >Emitted(82, 41) Source(89, 3) + SourceIndex(0) +1->Emitted(87, 17) Source(78, 15) + SourceIndex(0) +2 >Emitted(87, 32) Source(78, 20) + SourceIndex(0) +3 >Emitted(87, 40) Source(89, 3) + SourceIndex(0) +4 >Emitted(87, 41) Source(89, 3) + SourceIndex(0) --- >>> var Mode = (function (_super) { 1->^^^^^^^^^^^^^^^^ @@ -1606,23 +1611,23 @@ sourceFile:recursiveClassReferenceTest.ts 1-> > > -1->Emitted(83, 17) Source(91, 2) + SourceIndex(0) +1->Emitted(88, 17) Source(91, 2) + SourceIndex(0) --- >>> __extends(Mode, _super); 1->^^^^^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^ 1->export class Mode extends 2 > AbstractMode -1->Emitted(84, 21) Source(91, 28) + SourceIndex(0) -2 >Emitted(84, 45) Source(91, 40) + SourceIndex(0) +1->Emitted(89, 21) Source(91, 28) + SourceIndex(0) +2 >Emitted(89, 45) Source(91, 40) + SourceIndex(0) --- >>> function Mode() { 1 >^^^^^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(85, 21) Source(91, 2) + SourceIndex(0) +1 >Emitted(90, 21) Source(91, 2) + SourceIndex(0) --- ->>> return _super.apply(this, arguments) || this; +>>> return _super !== null && _super.apply(this, arguments) || this; >>> } 1->^^^^^^^^^^^^^^^^^^^^ 2 > ^ @@ -1637,8 +1642,8 @@ sourceFile:recursiveClassReferenceTest.ts > > 2 > } -1->Emitted(87, 21) Source(99, 2) + SourceIndex(0) -2 >Emitted(87, 22) Source(99, 3) + SourceIndex(0) +1->Emitted(92, 21) Source(99, 2) + SourceIndex(0) +2 >Emitted(92, 22) Source(99, 3) + SourceIndex(0) --- >>> // scenario 2 1->^^^^^^^^^^^^^^^^^^^^ @@ -1646,8 +1651,8 @@ sourceFile:recursiveClassReferenceTest.ts 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> 2 > // scenario 2 -1->Emitted(88, 21) Source(93, 3) + SourceIndex(0) -2 >Emitted(88, 34) Source(93, 16) + SourceIndex(0) +1->Emitted(93, 21) Source(93, 3) + SourceIndex(0) +2 >Emitted(93, 34) Source(93, 16) + SourceIndex(0) --- >>> Mode.prototype.getInitialState = function () { 1->^^^^^^^^^^^^^^^^^^^^ @@ -1657,9 +1662,9 @@ sourceFile:recursiveClassReferenceTest.ts > public 2 > getInitialState 3 > -1->Emitted(89, 21) Source(94, 10) + SourceIndex(0) -2 >Emitted(89, 51) Source(94, 25) + SourceIndex(0) -3 >Emitted(89, 54) Source(94, 3) + SourceIndex(0) +1->Emitted(94, 21) Source(94, 10) + SourceIndex(0) +2 >Emitted(94, 51) Source(94, 25) + SourceIndex(0) +3 >Emitted(94, 54) Source(94, 3) + SourceIndex(0) --- >>> return new State(self); 1 >^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1681,15 +1686,15 @@ sourceFile:recursiveClassReferenceTest.ts 7 > self 8 > ) 9 > ; -1 >Emitted(90, 25) Source(95, 4) + SourceIndex(0) -2 >Emitted(90, 31) Source(95, 10) + SourceIndex(0) -3 >Emitted(90, 32) Source(95, 11) + SourceIndex(0) -4 >Emitted(90, 36) Source(95, 15) + SourceIndex(0) -5 >Emitted(90, 41) Source(95, 20) + SourceIndex(0) -6 >Emitted(90, 42) Source(95, 21) + SourceIndex(0) -7 >Emitted(90, 46) Source(95, 25) + SourceIndex(0) -8 >Emitted(90, 47) Source(95, 26) + SourceIndex(0) -9 >Emitted(90, 48) Source(95, 27) + SourceIndex(0) +1 >Emitted(95, 25) Source(95, 4) + SourceIndex(0) +2 >Emitted(95, 31) Source(95, 10) + SourceIndex(0) +3 >Emitted(95, 32) Source(95, 11) + SourceIndex(0) +4 >Emitted(95, 36) Source(95, 15) + SourceIndex(0) +5 >Emitted(95, 41) Source(95, 20) + SourceIndex(0) +6 >Emitted(95, 42) Source(95, 21) + SourceIndex(0) +7 >Emitted(95, 46) Source(95, 25) + SourceIndex(0) +8 >Emitted(95, 47) Source(95, 26) + SourceIndex(0) +9 >Emitted(95, 48) Source(95, 27) + SourceIndex(0) --- >>> }; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1698,8 +1703,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(91, 21) Source(96, 3) + SourceIndex(0) -2 >Emitted(91, 22) Source(96, 4) + SourceIndex(0) +1 >Emitted(96, 21) Source(96, 3) + SourceIndex(0) +2 >Emitted(96, 22) Source(96, 4) + SourceIndex(0) --- >>> return Mode; 1->^^^^^^^^^^^^^^^^^^^^ @@ -1710,8 +1715,8 @@ sourceFile:recursiveClassReferenceTest.ts > > 2 > } -1->Emitted(92, 21) Source(99, 2) + SourceIndex(0) -2 >Emitted(92, 32) Source(99, 3) + SourceIndex(0) +1->Emitted(97, 21) Source(99, 2) + SourceIndex(0) +2 >Emitted(97, 32) Source(99, 3) + SourceIndex(0) --- >>> }(AbstractMode)); 1->^^^^^^^^^^^^^^^^ @@ -1735,12 +1740,12 @@ sourceFile:recursiveClassReferenceTest.ts > > > } -1->Emitted(93, 17) Source(99, 2) + SourceIndex(0) -2 >Emitted(93, 18) Source(99, 3) + SourceIndex(0) -3 >Emitted(93, 18) Source(91, 2) + SourceIndex(0) -4 >Emitted(93, 19) Source(91, 28) + SourceIndex(0) -5 >Emitted(93, 31) Source(91, 40) + SourceIndex(0) -6 >Emitted(93, 34) Source(99, 3) + SourceIndex(0) +1->Emitted(98, 17) Source(99, 2) + SourceIndex(0) +2 >Emitted(98, 18) Source(99, 3) + SourceIndex(0) +3 >Emitted(98, 18) Source(91, 2) + SourceIndex(0) +4 >Emitted(98, 19) Source(91, 28) + SourceIndex(0) +5 >Emitted(98, 31) Source(91, 40) + SourceIndex(0) +6 >Emitted(98, 34) Source(99, 3) + SourceIndex(0) --- >>> PlainText.Mode = Mode; 1->^^^^^^^^^^^^^^^^ @@ -1760,10 +1765,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } 4 > -1->Emitted(94, 17) Source(91, 15) + SourceIndex(0) -2 >Emitted(94, 31) Source(91, 19) + SourceIndex(0) -3 >Emitted(94, 38) Source(99, 3) + SourceIndex(0) -4 >Emitted(94, 39) Source(99, 3) + SourceIndex(0) +1->Emitted(99, 17) Source(91, 15) + SourceIndex(0) +2 >Emitted(99, 31) Source(91, 19) + SourceIndex(0) +3 >Emitted(99, 38) Source(99, 3) + SourceIndex(0) +4 >Emitted(99, 39) Source(99, 3) + SourceIndex(0) --- >>> })(PlainText = Languages.PlainText || (Languages.PlainText = {})); 1->^^^^^^^^^^^^ @@ -1809,15 +1814,15 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1->Emitted(95, 13) Source(100, 1) + SourceIndex(0) -2 >Emitted(95, 14) Source(100, 2) + SourceIndex(0) -3 >Emitted(95, 16) Source(76, 31) + SourceIndex(0) -4 >Emitted(95, 25) Source(76, 40) + SourceIndex(0) -5 >Emitted(95, 28) Source(76, 31) + SourceIndex(0) -6 >Emitted(95, 47) Source(76, 40) + SourceIndex(0) -7 >Emitted(95, 52) Source(76, 31) + SourceIndex(0) -8 >Emitted(95, 71) Source(76, 40) + SourceIndex(0) -9 >Emitted(95, 79) Source(100, 2) + SourceIndex(0) +1->Emitted(100, 13) Source(100, 1) + SourceIndex(0) +2 >Emitted(100, 14) Source(100, 2) + SourceIndex(0) +3 >Emitted(100, 16) Source(76, 31) + SourceIndex(0) +4 >Emitted(100, 25) Source(76, 40) + SourceIndex(0) +5 >Emitted(100, 28) Source(76, 31) + SourceIndex(0) +6 >Emitted(100, 47) Source(76, 40) + SourceIndex(0) +7 >Emitted(100, 52) Source(76, 31) + SourceIndex(0) +8 >Emitted(100, 71) Source(76, 40) + SourceIndex(0) +9 >Emitted(100, 79) Source(100, 2) + SourceIndex(0) --- >>> })(Languages = Thing.Languages || (Thing.Languages = {})); 1 >^^^^^^^^ @@ -1862,15 +1867,15 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(96, 9) Source(100, 1) + SourceIndex(0) -2 >Emitted(96, 10) Source(100, 2) + SourceIndex(0) -3 >Emitted(96, 12) Source(76, 21) + SourceIndex(0) -4 >Emitted(96, 21) Source(76, 30) + SourceIndex(0) -5 >Emitted(96, 24) Source(76, 21) + SourceIndex(0) -6 >Emitted(96, 39) Source(76, 30) + SourceIndex(0) -7 >Emitted(96, 44) Source(76, 21) + SourceIndex(0) -8 >Emitted(96, 59) Source(76, 30) + SourceIndex(0) -9 >Emitted(96, 67) Source(100, 2) + SourceIndex(0) +1 >Emitted(101, 9) Source(100, 1) + SourceIndex(0) +2 >Emitted(101, 10) Source(100, 2) + SourceIndex(0) +3 >Emitted(101, 12) Source(76, 21) + SourceIndex(0) +4 >Emitted(101, 21) Source(76, 30) + SourceIndex(0) +5 >Emitted(101, 24) Source(76, 21) + SourceIndex(0) +6 >Emitted(101, 39) Source(76, 30) + SourceIndex(0) +7 >Emitted(101, 44) Source(76, 21) + SourceIndex(0) +8 >Emitted(101, 59) Source(76, 30) + SourceIndex(0) +9 >Emitted(101, 67) Source(100, 2) + SourceIndex(0) --- >>> })(Thing = Sample.Thing || (Sample.Thing = {})); 1 >^^^^ @@ -1915,15 +1920,15 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(97, 5) Source(100, 1) + SourceIndex(0) -2 >Emitted(97, 6) Source(100, 2) + SourceIndex(0) -3 >Emitted(97, 8) Source(76, 15) + SourceIndex(0) -4 >Emitted(97, 13) Source(76, 20) + SourceIndex(0) -5 >Emitted(97, 16) Source(76, 15) + SourceIndex(0) -6 >Emitted(97, 28) Source(76, 20) + SourceIndex(0) -7 >Emitted(97, 33) Source(76, 15) + SourceIndex(0) -8 >Emitted(97, 45) Source(76, 20) + SourceIndex(0) -9 >Emitted(97, 53) Source(100, 2) + SourceIndex(0) +1 >Emitted(102, 5) Source(100, 1) + SourceIndex(0) +2 >Emitted(102, 6) Source(100, 2) + SourceIndex(0) +3 >Emitted(102, 8) Source(76, 15) + SourceIndex(0) +4 >Emitted(102, 13) Source(76, 20) + SourceIndex(0) +5 >Emitted(102, 16) Source(76, 15) + SourceIndex(0) +6 >Emitted(102, 28) Source(76, 20) + SourceIndex(0) +7 >Emitted(102, 33) Source(76, 15) + SourceIndex(0) +8 >Emitted(102, 45) Source(76, 20) + SourceIndex(0) +9 >Emitted(102, 53) Source(100, 2) + SourceIndex(0) --- >>>})(Sample || (Sample = {})); 1 > @@ -1965,12 +1970,12 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(98, 1) Source(100, 1) + SourceIndex(0) -2 >Emitted(98, 2) Source(100, 2) + SourceIndex(0) -3 >Emitted(98, 4) Source(76, 8) + SourceIndex(0) -4 >Emitted(98, 10) Source(76, 14) + SourceIndex(0) -5 >Emitted(98, 15) Source(76, 8) + SourceIndex(0) -6 >Emitted(98, 21) Source(76, 14) + SourceIndex(0) -7 >Emitted(98, 29) Source(100, 2) + SourceIndex(0) +1 >Emitted(103, 1) Source(100, 1) + SourceIndex(0) +2 >Emitted(103, 2) Source(100, 2) + SourceIndex(0) +3 >Emitted(103, 4) Source(76, 8) + SourceIndex(0) +4 >Emitted(103, 10) Source(76, 14) + SourceIndex(0) +5 >Emitted(103, 15) Source(76, 8) + SourceIndex(0) +6 >Emitted(103, 21) Source(76, 14) + SourceIndex(0) +7 >Emitted(103, 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 8441ff9e15a..cb46865c46f 100644 --- a/tests/baselines/reference/recursiveComplicatedClasses.js +++ b/tests/baselines/reference/recursiveComplicatedClasses.js @@ -25,11 +25,16 @@ class TypeSymbol extends InferenceSymbol { } //// [recursiveComplicatedClasses.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Signature = (function () { function Signature() { this.parameters = null; @@ -51,21 +56,21 @@ var Symbol = (function () { var InferenceSymbol = (function (_super) { __extends(InferenceSymbol, _super); function InferenceSymbol() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return InferenceSymbol; }(Symbol)); var ParameterSymbol = (function (_super) { __extends(ParameterSymbol, _super); function ParameterSymbol() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ParameterSymbol; }(InferenceSymbol)); var TypeSymbol = (function (_super) { __extends(TypeSymbol, _super); function TypeSymbol() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return TypeSymbol; }(InferenceSymbol)); diff --git a/tests/baselines/reference/recursiveFunctionTypes.errors.txt b/tests/baselines/reference/recursiveFunctionTypes.errors.txt index 8614f747016..8a454133a82 100644 --- a/tests/baselines/reference/recursiveFunctionTypes.errors.txt +++ b/tests/baselines/reference/recursiveFunctionTypes.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/recursiveFunctionTypes.ts(1,35): error TS2322: Type '1' is not assignable to type '() => typeof fn'. +tests/cases/compiler/recursiveFunctionTypes.ts(1,28): error TS2322: Type '1' is not assignable to type '() => typeof fn'. tests/cases/compiler/recursiveFunctionTypes.ts(3,5): error TS2322: Type '() => typeof fn' is not assignable to type 'number'. tests/cases/compiler/recursiveFunctionTypes.ts(4,5): error TS2322: Type '() => typeof fn' is not assignable to type '() => number'. Type '() => typeof fn' is not assignable to type 'number'. @@ -16,7 +16,7 @@ tests/cases/compiler/recursiveFunctionTypes.ts(43,4): error TS2345: Argument of ==== tests/cases/compiler/recursiveFunctionTypes.ts (13 errors) ==== function fn(): typeof fn { return 1; } - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type '() => typeof fn'. var x: number = fn; // error diff --git a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js index 76224741e60..ee976ff3da1 100644 --- a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js +++ b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js @@ -30,11 +30,16 @@ declare module MsPortal.Controls.Base.ItemList { */ //// [recursivelySpecializedConstructorDeclaration.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var MsPortal; (function (MsPortal) { var Controls; @@ -52,7 +57,7 @@ var MsPortal; var ViewModel = (function (_super) { __extends(ViewModel, _super); function ViewModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ViewModel; }(ItemValue)); diff --git a/tests/baselines/reference/reexportClassDefinition.js b/tests/baselines/reference/reexportClassDefinition.js index a75a90d4d86..0242a57d4f5 100644 --- a/tests/baselines/reference/reexportClassDefinition.js +++ b/tests/baselines/reference/reexportClassDefinition.js @@ -33,16 +33,21 @@ module.exports = { }; //// [foo3.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var foo2 = require("./foo2"); var x = (function (_super) { __extends(x, _super); function x() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return x; }(foo2.x)); diff --git a/tests/baselines/reference/reservedNamesInAliases.errors.txt b/tests/baselines/reference/reservedNamesInAliases.errors.txt index b6565427395..22894f8f6a6 100644 --- a/tests/baselines/reference/reservedNamesInAliases.errors.txt +++ b/tests/baselines/reference/reservedNamesInAliases.errors.txt @@ -6,9 +6,10 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,1): error tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,6): error TS1005: ';' expected. tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,11): error TS1109: Expression expected. tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error TS2693: 'I' only refers to a type, but is being used as a value here. +tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(7,6): error TS2457: Type alias name cannot be 'object' -==== tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts (8 errors) ==== +==== tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts (9 errors) ==== interface I {} type any = I; ~~~ @@ -30,4 +31,8 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error ~ !!! error TS1109: Expression expected. ~ -!!! error TS2693: 'I' only refers to a type, but is being used as a value here. \ No newline at end of file +!!! error TS2693: 'I' only refers to a type, but is being used as a value here. + type object = I; + ~~~~~~ +!!! error TS2457: Type alias name cannot be 'object' + \ No newline at end of file diff --git a/tests/baselines/reference/reservedNamesInAliases.js b/tests/baselines/reference/reservedNamesInAliases.js index 4ebc3bdb95f..368331d3114 100644 --- a/tests/baselines/reference/reservedNamesInAliases.js +++ b/tests/baselines/reference/reservedNamesInAliases.js @@ -4,7 +4,9 @@ type any = I; type number = I; type boolean = I; type string = I; -type void = I; +type void = I; +type object = I; + //// [reservedNamesInAliases.js] type; diff --git a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.js b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.js index 94dc537298a..1a9a3dacbba 100644 --- a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.js +++ b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.js @@ -1020,17 +1020,22 @@ module caurinus { //// [resolvingClassDeclarationWhenInBaseTypeResolution.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var rionegrensis; (function (rionegrensis) { var caniventer = (function (_super) { __extends(caniventer, _super); function caniventer() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } caniventer.prototype.salomonseni = function () { var _this = this; @@ -1068,7 +1073,7 @@ var rionegrensis; var veraecrucis = (function (_super) { __extends(veraecrucis, _super); function veraecrucis() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } veraecrucis.prototype.naso = function () { var _this = this; @@ -1247,7 +1252,7 @@ var julianae; var oralis = (function (_super) { __extends(oralis, _super); function oralis() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } oralis.prototype.cepapi = function () { var _this = this; @@ -1333,7 +1338,7 @@ var julianae; var sumatrana = (function (_super) { __extends(sumatrana, _super); function sumatrana() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } sumatrana.prototype.wolffsohni = function () { var _this = this; @@ -1533,7 +1538,7 @@ var julianae; var durangae = (function (_super) { __extends(durangae, _super); function durangae() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } durangae.prototype.Californium = function () { var _this = this; @@ -1607,7 +1612,7 @@ var Lanthanum; var nitidus = (function (_super) { __extends(nitidus, _super); function nitidus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } nitidus.prototype.granatensis = function () { var _this = this; @@ -1675,7 +1680,7 @@ var Lanthanum; var megalonyx = (function (_super) { __extends(megalonyx, _super); function megalonyx() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } megalonyx.prototype.phillipsii = function () { var _this = this; @@ -1824,7 +1829,7 @@ var rendalli; var zuluensis = (function (_super) { __extends(zuluensis, _super); function zuluensis() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } zuluensis.prototype.telfairi = function () { var _this = this; @@ -1982,7 +1987,7 @@ var rendalli; var crenulata = (function (_super) { __extends(crenulata, _super); function crenulata() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } crenulata.prototype.salvanius = function () { var _this = this; @@ -2065,7 +2070,7 @@ var trivirgatus; var mixtus = (function (_super) { __extends(mixtus, _super); function mixtus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } mixtus.prototype.ochrogaster = function () { var _this = this; @@ -2306,7 +2311,7 @@ var quasiater; var americanus = (function (_super) { __extends(americanus, _super); function americanus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } americanus.prototype.nasoloi = function () { var _this = this; @@ -2341,7 +2346,7 @@ var lavali; var wilsoni = (function (_super) { __extends(wilsoni, _super); function wilsoni() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } wilsoni.prototype.setiger = function () { var _this = this; @@ -2433,7 +2438,7 @@ var lavali; var otion = (function (_super) { __extends(otion, _super); function otion() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } otion.prototype.bonaerensis = function () { var _this = this; @@ -2597,7 +2602,7 @@ var lavali; var thaeleri = (function (_super) { __extends(thaeleri, _super); function thaeleri() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } thaeleri.prototype.coromandra = function () { var _this = this; @@ -2653,7 +2658,7 @@ var lavali; var lepturus = (function (_super) { __extends(lepturus, _super); function lepturus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } lepturus.prototype.ferrumequinum = function () { var _this = this; @@ -2676,7 +2681,7 @@ var dogramacii; var robustulus = (function (_super) { __extends(robustulus, _super); function robustulus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } robustulus.prototype.fossor = function () { var _this = this; @@ -2891,7 +2896,7 @@ var lutreolus; var schlegeli = (function (_super) { __extends(schlegeli, _super); function schlegeli() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } schlegeli.prototype.mittendorfi = function () { var _this = this; @@ -3118,7 +3123,7 @@ var panglima; var amphibius = (function (_super) { __extends(amphibius, _super); function amphibius() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } amphibius.prototype.bottegi = function () { var _this = this; @@ -3162,7 +3167,7 @@ var panglima; var fundatus = (function (_super) { __extends(fundatus, _super); function fundatus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } fundatus.prototype.crassulus = function () { var _this = this; @@ -3188,7 +3193,7 @@ var panglima; var abidi = (function (_super) { __extends(abidi, _super); function abidi() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } abidi.prototype.greyii = function () { var _this = this; @@ -3279,7 +3284,7 @@ var minutus; var himalayana = (function (_super) { __extends(himalayana, _super); function himalayana() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } himalayana.prototype.simoni = function () { var _this = this; @@ -3362,7 +3367,7 @@ var caurinus; var mahaganus = (function (_super) { __extends(mahaganus, _super); function mahaganus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } mahaganus.prototype.martiniquensis = function () { var _this = this; @@ -3436,7 +3441,7 @@ var howi; var angulatus = (function (_super) { __extends(angulatus, _super); function angulatus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } angulatus.prototype.pennatus = function () { var _this = this; @@ -3518,7 +3523,7 @@ var sagitta; var walkeri = (function (_super) { __extends(walkeri, _super); function walkeri() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } walkeri.prototype.maracajuensis = function () { var _this = this; @@ -3534,7 +3539,7 @@ var sagitta; var inez = (function (_super) { __extends(inez, _super); function inez() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } inez.prototype.vexillaris = function () { var _this = this; @@ -3550,7 +3555,7 @@ var sagitta; var konganensis = (function (_super) { __extends(konganensis, _super); function konganensis() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return konganensis; }(imperfecta.lasiurus)); @@ -3561,7 +3566,7 @@ var panamensis; var linulus = (function (_super) { __extends(linulus, _super); function linulus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } linulus.prototype.goslingi = function () { var _this = this; @@ -3712,7 +3717,7 @@ var samarensis; var pelurus = (function (_super) { __extends(pelurus, _super); function pelurus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } pelurus.prototype.Palladium = function () { var _this = this; @@ -3798,7 +3803,7 @@ var samarensis; var fuscus = (function (_super) { __extends(fuscus, _super); function fuscus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } fuscus.prototype.planifrons = function () { var _this = this; @@ -3958,7 +3963,7 @@ var samarensis; var leptoceros = (function (_super) { __extends(leptoceros, _super); function leptoceros() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } leptoceros.prototype.victus = function () { var _this = this; @@ -3998,7 +4003,7 @@ var samarensis; var nigricans = (function (_super) { __extends(nigricans, _super); function nigricans() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } nigricans.prototype.woosnami = function () { var _this = this; @@ -4023,7 +4028,7 @@ var dammermani; var pygmaea = (function (_super) { __extends(pygmaea, _super); function pygmaea() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } pygmaea.prototype.pajeros = function () { var _this = this; @@ -4052,7 +4057,7 @@ var chrysaeolus; var sarasinorum = (function (_super) { __extends(sarasinorum, _super); function sarasinorum() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } sarasinorum.prototype.belzebul = function () { var _this = this; @@ -4154,7 +4159,7 @@ var chrysaeolus; var oreas = (function (_super) { __extends(oreas, _super); function oreas() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } oreas.prototype.salamonis = function () { var _this = this; @@ -4380,7 +4385,7 @@ var provocax; var melanoleuca = (function (_super) { __extends(melanoleuca, _super); function melanoleuca() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } melanoleuca.prototype.Neodymium = function () { var _this = this; @@ -4422,7 +4427,7 @@ var provocax; var marcanoi = (function (_super) { __extends(marcanoi, _super); function marcanoi() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } marcanoi.prototype.formosae = function () { var _this = this; @@ -4824,7 +4829,7 @@ var gabriellae; var klossii = (function (_super) { __extends(klossii, _super); function klossii() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return klossii; }(imperfecta.lasiurus)); @@ -5027,7 +5032,7 @@ var imperfecta; var ciliolabrum = (function (_super) { __extends(ciliolabrum, _super); function ciliolabrum() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } ciliolabrum.prototype.leschenaultii = function () { var _this = this; @@ -5087,7 +5092,7 @@ var imperfecta; var sodyi = (function (_super) { __extends(sodyi, _super); function sodyi() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } sodyi.prototype.saundersiae = function () { var _this = this; @@ -5151,7 +5156,7 @@ var imperfecta; var megaphyllus = (function (_super) { __extends(megaphyllus, _super); function megaphyllus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } megaphyllus.prototype.montana = function () { var _this = this; @@ -5321,7 +5326,7 @@ var imperfecta; var cor = (function (_super) { __extends(cor, _super); function cor() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } cor.prototype.antinorii = function () { var _this = this; @@ -5411,7 +5416,7 @@ var imperfecta; var germaini = (function (_super) { __extends(germaini, _super); function germaini() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } germaini.prototype.sharpei = function () { var _this = this; @@ -5507,7 +5512,7 @@ var imperfecta; var melanops = (function (_super) { __extends(melanops, _super); function melanops() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } melanops.prototype.blarina = function () { var _this = this; @@ -5595,7 +5600,7 @@ var imperfecta; var peninsulae = (function (_super) { __extends(peninsulae, _super); function peninsulae() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } peninsulae.prototype.aitkeni = function () { var _this = this; @@ -5739,7 +5744,7 @@ var imperfecta; var Praseodymium = (function (_super) { __extends(Praseodymium, _super); function Praseodymium() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Praseodymium.prototype.clara = function () { var _this = this; @@ -5827,7 +5832,7 @@ var imperfecta; var johorensis = (function (_super) { __extends(johorensis, _super); function johorensis() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } johorensis.prototype.maini = function () { var _this = this; @@ -5951,7 +5956,7 @@ var imperfecta; var psilurus = (function (_super) { __extends(psilurus, _super); function psilurus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } psilurus.prototype.socialis = function () { var _this = this; diff --git a/tests/baselines/reference/returnInConstructor1.errors.txt b/tests/baselines/reference/returnInConstructor1.errors.txt index a7d3fd05204..939d303ec65 100644 --- a/tests/baselines/reference/returnInConstructor1.errors.txt +++ b/tests/baselines/reference/returnInConstructor1.errors.txt @@ -1,15 +1,15 @@ -tests/cases/compiler/returnInConstructor1.ts(11,16): error TS2322: Type '1' is not assignable to type 'B'. -tests/cases/compiler/returnInConstructor1.ts(11,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class -tests/cases/compiler/returnInConstructor1.ts(25,16): error TS2322: Type '"test"' is not assignable to type 'D'. -tests/cases/compiler/returnInConstructor1.ts(25,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class -tests/cases/compiler/returnInConstructor1.ts(39,16): error TS2322: Type '{ foo: number; }' is not assignable to type 'F'. +tests/cases/compiler/returnInConstructor1.ts(11,9): error TS2322: Type '1' is not assignable to type 'B'. +tests/cases/compiler/returnInConstructor1.ts(11,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/compiler/returnInConstructor1.ts(25,9): error TS2322: Type '"test"' is not assignable to type 'D'. +tests/cases/compiler/returnInConstructor1.ts(25,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/compiler/returnInConstructor1.ts(39,9): error TS2322: Type '{ foo: number; }' is not assignable to type 'F'. Types of property 'foo' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/compiler/returnInConstructor1.ts(39,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class -tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2322: Type 'G' is not assignable to type 'H'. +tests/cases/compiler/returnInConstructor1.ts(39,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/compiler/returnInConstructor1.ts(55,9): error TS2322: Type 'G' is not assignable to type 'H'. Types of property 'foo' are incompatible. Type '() => void' is not assignable to type 'string'. -tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/compiler/returnInConstructor1.ts(55,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class ==== tests/cases/compiler/returnInConstructor1.ts (8 errors) ==== @@ -24,9 +24,9 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o foo() { } constructor() { return 1; // error - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'B'. - ~ + ~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } @@ -42,9 +42,9 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o foo() { } constructor() { return "test"; // error - ~~~~~~ + ~~~~~~~~~~~~~~ !!! error TS2322: Type '"test"' is not assignable to type 'D'. - ~~~~~~ + ~~~~~~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } @@ -60,11 +60,11 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o public foo: string; constructor() { return { foo: 1 }; //error - ~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ foo: number; }' is not assignable to type 'F'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. - ~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } @@ -82,11 +82,11 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o constructor() { super(); return new G(); //error - ~~~~~~~ + ~~~~~~~~~~~~~~~ !!! error TS2322: Type 'G' is not assignable to type 'H'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type '() => void' is not assignable to type 'string'. - ~~~~~~~ + ~~~~~~~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } diff --git a/tests/baselines/reference/returnInConstructor1.js b/tests/baselines/reference/returnInConstructor1.js index a47fa7ed513..6bdcc0cb6a2 100644 --- a/tests/baselines/reference/returnInConstructor1.js +++ b/tests/baselines/reference/returnInConstructor1.js @@ -67,11 +67,16 @@ class I extends G { //// [returnInConstructor1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { return; diff --git a/tests/baselines/reference/returnStatements.js b/tests/baselines/reference/returnStatements.js index f786e994963..617911be759 100644 --- a/tests/baselines/reference/returnStatements.js +++ b/tests/baselines/reference/returnStatements.js @@ -25,11 +25,16 @@ function fn13(): C { return null; } //// [returnStatements.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // all the following should be valid function fn1() { return 1; } function fn2() { return ''; } @@ -48,7 +53,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/returnValueInSetter.errors.txt b/tests/baselines/reference/returnValueInSetter.errors.txt index f9dffa1bc36..4d7b0d185f9 100644 --- a/tests/baselines/reference/returnValueInSetter.errors.txt +++ b/tests/baselines/reference/returnValueInSetter.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/returnValueInSetter.ts(2,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/returnValueInSetter.ts(3,16): error TS2408: Setters cannot return a value. +tests/cases/compiler/returnValueInSetter.ts(3,9): error TS2408: Setters cannot return a value. ==== tests/cases/compiler/returnValueInSetter.ts (2 errors) ==== @@ -8,7 +8,7 @@ tests/cases/compiler/returnValueInSetter.ts(3,16): error TS2408: Setters cannot ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. return null; // Should be an error - ~~~~ + ~~~~~~~~~~~~ !!! error TS2408: Setters cannot return a value. } } diff --git a/tests/baselines/reference/scannerNumericLiteral8.errors.txt b/tests/baselines/reference/scannerNumericLiteral8.errors.txt index 5aad01449f2..6545050afc2 100644 --- a/tests/baselines/reference/scannerNumericLiteral8.errors.txt +++ b/tests/baselines/reference/scannerNumericLiteral8.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/scanner/ecmascript5/scannerNumericLiteral8.ts(1,2): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '0o3'. +tests/cases/conformance/scanner/ecmascript5/scannerNumericLiteral8.ts(1,1): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '-0o3'. ==== tests/cases/conformance/scanner/ecmascript5/scannerNumericLiteral8.ts (1 errors) ==== -03 - ~~ -!!! error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '0o3'. \ No newline at end of file + ~~~ +!!! error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '-0o3'. \ No newline at end of file diff --git a/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.js b/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.js index 1474f8ab29a..c72fe6dde7d 100644 --- a/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.js +++ b/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.js @@ -9,11 +9,16 @@ class D extends C { } //// [scopeCheckExtendedClassInsidePublicMethod2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -22,7 +27,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.c = function () { v = 1; diff --git a/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.js b/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.js index 0baf0187009..34c1698a3ea 100644 --- a/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.js +++ b/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.js @@ -9,11 +9,16 @@ class D extends C { } //// [scopeCheckExtendedClassInsideStaticMethod1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -22,7 +27,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.c = function () { v = 1; diff --git a/tests/baselines/reference/scopeTests.js b/tests/baselines/reference/scopeTests.js index 48863404a8e..b60242c0714 100644 --- a/tests/baselines/reference/scopeTests.js +++ b/tests/baselines/reference/scopeTests.js @@ -12,11 +12,16 @@ class D extends C { } //// [scopeTests.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } diff --git a/tests/baselines/reference/setterWithReturn.errors.txt b/tests/baselines/reference/setterWithReturn.errors.txt index 6aed49105b8..a0f04506a71 100644 --- a/tests/baselines/reference/setterWithReturn.errors.txt +++ b/tests/baselines/reference/setterWithReturn.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/setterWithReturn.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/setterWithReturn.ts(4,20): error TS2408: Setters cannot return a value. +tests/cases/compiler/setterWithReturn.ts(4,13): error TS2408: Setters cannot return a value. tests/cases/compiler/setterWithReturn.ts(7,13): error TS7027: Unreachable code detected. -tests/cases/compiler/setterWithReturn.ts(7,20): error TS2408: Setters cannot return a value. +tests/cases/compiler/setterWithReturn.ts(7,13): error TS2408: Setters cannot return a value. ==== tests/cases/compiler/setterWithReturn.ts (4 errors) ==== @@ -11,14 +11,14 @@ tests/cases/compiler/setterWithReturn.ts(7,20): error TS2408: Setters cannot ret !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. if (true) { return arg1; - ~~~~ + ~~~~~~~~~~~~ !!! error TS2408: Setters cannot return a value. } else { return 0; ~~~~~~ !!! error TS7027: Unreachable code detected. - ~ + ~~~~~~~~~ !!! error TS2408: Setters cannot return a value. } } diff --git a/tests/baselines/reference/shadowPrivateMembers.js b/tests/baselines/reference/shadowPrivateMembers.js index 4906814f7eb..ce0fd333b91 100644 --- a/tests/baselines/reference/shadowPrivateMembers.js +++ b/tests/baselines/reference/shadowPrivateMembers.js @@ -4,11 +4,16 @@ class derived extends base { private n() {} } //// [shadowPrivateMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var base = (function () { function base() { } @@ -18,7 +23,7 @@ var base = (function () { var derived = (function (_super) { __extends(derived, _super); function derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } derived.prototype.n = function () { }; return derived; diff --git a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js index 4bac0210c85..44638fa007e 100644 --- a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js +++ b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js @@ -8,11 +8,16 @@ class Greeter extends AbstractGreeter { } //// [sourceMapValidationClassWithDefaultConstructorAndExtendsClause.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var AbstractGreeter = (function () { function AbstractGreeter() { } @@ -21,7 +26,7 @@ var AbstractGreeter = (function () { var Greeter = (function (_super) { __extends(Greeter, _super); function Greeter() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.a = 10; _this.nameA = "Ten"; return _this; diff --git a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js.map b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js.map index 6b18a783dfa..60e19fc95d2 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":[],"mappings":";;;;;AAAA;IAAA;IACA,CAAC;IAAD,sBAAC;AAAD,CAAC,AADD,IACC;AAED;IAAsB,2BAAe;IAArC;QAAA,kDAGC;QAFU,OAAC,GAAG,EAAE,CAAC;QACP,WAAK,GAAG,KAAK,CAAC;;IACzB,CAAC;IAAD,cAAC;AAAD,CAAC,AAHD,CAAsB,eAAe,GAGpC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js","sourceRoot":"","sources":["sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts"],"names":[],"mappings":";;;;;;;;;;AAAA;IAAA;IACA,CAAC;IAAD,sBAAC;AAAD,CAAC,AADD,IACC;AAED;IAAsB,2BAAe;IAArC;QAAA,qEAGC;QAFU,OAAC,GAAG,EAAE,CAAC;QACP,WAAK,GAAG,KAAK,CAAC;;IACzB,CAAC;IAAD,cAAC;AAAD,CAAC,AAHD,CAAsB,eAAe,GAGpC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.sourcemap.txt b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.sourcemap.txt index 91e284fd063..9fa37bcff06 100644 --- a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.sourcemap.txt @@ -8,22 +8,27 @@ sources: sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts emittedFile:tests/cases/compiler/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js 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; } ->>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); ->>>}; +>>>var __extends = (this && this.__extends) || (function () { +>>> var extendStatics = Object.setPrototypeOf || +>>> ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || +>>> function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; +>>> return function (d, b) { +>>> extendStatics(d, b); +>>> function __() { this.constructor = d; } +>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +>>> }; +>>>})(); >>>var AbstractGreeter = (function () { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(6, 1) Source(1, 1) + SourceIndex(0) +1 >Emitted(11, 1) Source(1, 1) + SourceIndex(0) --- >>> function AbstractGreeter() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(7, 5) Source(1, 1) + SourceIndex(0) +1->Emitted(12, 5) Source(1, 1) + SourceIndex(0) --- >>> } 1->^^^^ @@ -32,16 +37,16 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 1->class AbstractGreeter { > 2 > } -1->Emitted(8, 5) Source(2, 1) + SourceIndex(0) -2 >Emitted(8, 6) Source(2, 2) + SourceIndex(0) +1->Emitted(13, 5) Source(2, 1) + SourceIndex(0) +2 >Emitted(13, 6) Source(2, 2) + SourceIndex(0) --- >>> return AbstractGreeter; 1->^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^ 1-> 2 > } -1->Emitted(9, 5) Source(2, 1) + SourceIndex(0) -2 >Emitted(9, 27) Source(2, 2) + SourceIndex(0) +1->Emitted(14, 5) Source(2, 1) + SourceIndex(0) +2 >Emitted(14, 27) Source(2, 2) + SourceIndex(0) --- >>>}()); 1 > @@ -54,10 +59,10 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 3 > 4 > class AbstractGreeter { > } -1 >Emitted(10, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(10, 2) Source(2, 2) + SourceIndex(0) -3 >Emitted(10, 2) Source(1, 1) + SourceIndex(0) -4 >Emitted(10, 6) Source(2, 2) + SourceIndex(0) +1 >Emitted(15, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(15, 2) Source(2, 2) + SourceIndex(0) +3 >Emitted(15, 2) Source(1, 1) + SourceIndex(0) +4 >Emitted(15, 6) Source(2, 2) + SourceIndex(0) --- >>>var Greeter = (function (_super) { 1-> @@ -65,32 +70,32 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 1-> > > -1->Emitted(11, 1) Source(4, 1) + SourceIndex(0) +1->Emitted(16, 1) Source(4, 1) + SourceIndex(0) --- >>> __extends(Greeter, _super); 1->^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1->class Greeter extends 2 > AbstractGreeter -1->Emitted(12, 5) Source(4, 23) + SourceIndex(0) -2 >Emitted(12, 32) Source(4, 38) + SourceIndex(0) +1->Emitted(17, 5) Source(4, 23) + SourceIndex(0) +2 >Emitted(17, 32) Source(4, 38) + SourceIndex(0) --- >>> function Greeter() { 1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(13, 5) Source(4, 1) + SourceIndex(0) +1 >Emitted(18, 5) Source(4, 1) + SourceIndex(0) --- ->>> var _this = _super.apply(this, arguments) || this; +>>> var _this = _super !== null && _super.apply(this, arguments) || this; 1->^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> 2 > class Greeter extends AbstractGreeter { > public a = 10; > public nameA = "Ten"; > } -1->Emitted(14, 9) Source(4, 1) + SourceIndex(0) -2 >Emitted(14, 59) Source(7, 2) + SourceIndex(0) +1->Emitted(19, 9) Source(4, 1) + SourceIndex(0) +2 >Emitted(19, 78) Source(7, 2) + SourceIndex(0) --- >>> _this.a = 10; 1 >^^^^^^^^ @@ -104,11 +109,11 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 3 > = 4 > 10 5 > ; -1 >Emitted(15, 9) Source(5, 12) + SourceIndex(0) -2 >Emitted(15, 16) Source(5, 13) + SourceIndex(0) -3 >Emitted(15, 19) Source(5, 16) + SourceIndex(0) -4 >Emitted(15, 21) Source(5, 18) + SourceIndex(0) -5 >Emitted(15, 22) Source(5, 19) + SourceIndex(0) +1 >Emitted(20, 9) Source(5, 12) + SourceIndex(0) +2 >Emitted(20, 16) Source(5, 13) + SourceIndex(0) +3 >Emitted(20, 19) Source(5, 16) + SourceIndex(0) +4 >Emitted(20, 21) Source(5, 18) + SourceIndex(0) +5 >Emitted(20, 22) Source(5, 19) + SourceIndex(0) --- >>> _this.nameA = "Ten"; 1->^^^^^^^^ @@ -122,11 +127,11 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 3 > = 4 > "Ten" 5 > ; -1->Emitted(16, 9) Source(6, 12) + SourceIndex(0) -2 >Emitted(16, 20) Source(6, 17) + SourceIndex(0) -3 >Emitted(16, 23) Source(6, 20) + SourceIndex(0) -4 >Emitted(16, 28) Source(6, 25) + SourceIndex(0) -5 >Emitted(16, 29) Source(6, 26) + SourceIndex(0) +1->Emitted(21, 9) Source(6, 12) + SourceIndex(0) +2 >Emitted(21, 20) Source(6, 17) + SourceIndex(0) +3 >Emitted(21, 23) Source(6, 20) + SourceIndex(0) +4 >Emitted(21, 28) Source(6, 25) + SourceIndex(0) +5 >Emitted(21, 29) Source(6, 26) + SourceIndex(0) --- >>> return _this; >>> } @@ -136,8 +141,8 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 1 > > 2 > } -1 >Emitted(18, 5) Source(7, 1) + SourceIndex(0) -2 >Emitted(18, 6) Source(7, 2) + SourceIndex(0) +1 >Emitted(23, 5) Source(7, 1) + SourceIndex(0) +2 >Emitted(23, 6) Source(7, 2) + SourceIndex(0) --- >>> return Greeter; 1->^^^^ @@ -145,8 +150,8 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 3 > ^^^-> 1-> 2 > } -1->Emitted(19, 5) Source(7, 1) + SourceIndex(0) -2 >Emitted(19, 19) Source(7, 2) + SourceIndex(0) +1->Emitted(24, 5) Source(7, 1) + SourceIndex(0) +2 >Emitted(24, 19) Source(7, 2) + SourceIndex(0) --- >>>}(AbstractGreeter)); 1-> @@ -165,11 +170,11 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts > public a = 10; > public nameA = "Ten"; > } -1->Emitted(20, 1) Source(7, 1) + SourceIndex(0) -2 >Emitted(20, 2) Source(7, 2) + SourceIndex(0) -3 >Emitted(20, 2) Source(4, 1) + SourceIndex(0) -4 >Emitted(20, 3) Source(4, 23) + SourceIndex(0) -5 >Emitted(20, 18) Source(4, 38) + SourceIndex(0) -6 >Emitted(20, 21) Source(7, 2) + SourceIndex(0) +1->Emitted(25, 1) Source(7, 1) + SourceIndex(0) +2 >Emitted(25, 2) Source(7, 2) + SourceIndex(0) +3 >Emitted(25, 2) Source(4, 1) + SourceIndex(0) +4 >Emitted(25, 3) Source(4, 23) + SourceIndex(0) +5 >Emitted(25, 18) Source(4, 38) + SourceIndex(0) +6 >Emitted(25, 21) Source(7, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationStatements.js.map b/tests/baselines/reference/sourceMapValidationStatements.js.map index 464ab4dc002..5841f329e5e 100644 --- a/tests/baselines/reference/sourceMapValidationStatements.js.map +++ b/tests/baselines/reference/sourceMapValidationStatements.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationStatements.js.map] -{"version":3,"file":"sourceMapValidationStatements.js","sourceRoot":"","sources":["sourceMapValidationStatements.ts"],"names":[],"mappings":"AAAA;IACI,IAAI,CAAC,CAAC;IACN,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1B,CAAC,IAAI,CAAC,CAAC;QACP,CAAC,IAAI,CAAC,CAAC;IACX,CAAC;IACD,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACT,CAAC,IAAI,CAAC,CAAC;IACX,CAAC;IAAC,IAAI,CAAC,CAAC;QACJ,CAAC,IAAI,EAAE,CAAC;QACR,CAAC,EAAE,CAAC;IACR,CAAC;IACD,IAAI,CAAC,GAAG;QACJ,CAAC;QACD,CAAC;QACD,CAAC;KACJ,CAAC;IACF,IAAI,GAAG,GAAG;QACN,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,OAAO;KACb,CAAC;IACF,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACd,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACb,IAAI,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACD,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;IACnB,CAAE;IAAA,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACT,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YACb,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QACf,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAClB,CAAC;IACL,CAAC;IACD,IAAI,CAAC;QACD,MAAM,IAAI,KAAK,EAAE,CAAC;IACtB,CAAE;IAAA,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACV,IAAI,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;YAAS,CAAC;QACP,CAAC,GAAG,EAAE,CAAC;IACX,CAAC;IACD,MAAM,GAAG,EAAE,CAAC;QACR,CAAC,GAAG,CAAC,CAAC;QACN,CAAC,GAAG,EAAE,CAAC;IACX,CAAC;IACD,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACZ,KAAK,CAAC,EAAE,CAAC;YACL,CAAC,EAAE,CAAC;YACJ,KAAK,CAAC;QAEV,CAAC;QACD,KAAK,CAAC,EAAE,CAAC;YACL,CAAC,EAAE,CAAC;YACJ,KAAK,CAAC;QAEV,CAAC;QACD,SAAS,CAAC;YACN,CAAC,IAAI,CAAC,CAAC;YACP,CAAC,GAAG,EAAE,CAAC;YACP,KAAK,CAAC;QAEV,CAAC;IACL,CAAC;IACD,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;QACZ,CAAC,EAAE,CAAC;IACR,CAAC;IACD,GAAG,CAAC;QACA,CAAC,EAAE,CAAC;IACR,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAC;IACf,CAAC,GAAG,CAAC,CAAC;IACN,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC,KAAK,CAAC,CAAC;IACR,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;IACX,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,CAAC;AACX,CAAC;AACD,IAAI,CAAC,GAAG;IACJ,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACd,CAAC,CAAC;AACF,CAAC,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationStatements.js","sourceRoot":"","sources":["sourceMapValidationStatements.ts"],"names":[],"mappings":"AAAA;IACI,IAAI,CAAC,CAAC;IACN,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1B,CAAC,IAAI,CAAC,CAAC;QACP,CAAC,IAAI,CAAC,CAAC;IACX,CAAC;IACD,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACT,CAAC,IAAI,CAAC,CAAC;IACX,CAAC;IAAC,IAAI,CAAC,CAAC;QACJ,CAAC,IAAI,EAAE,CAAC;QACR,CAAC,EAAE,CAAC;IACR,CAAC;IACD,IAAI,CAAC,GAAG;QACJ,CAAC;QACD,CAAC;QACD,CAAC;KACJ,CAAC;IACF,IAAI,GAAG,GAAG;QACN,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,OAAO;KACb,CAAC;IACF,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACd,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACb,IAAI,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACD,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;IACnB,CAAC;IAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACT,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YACb,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QACf,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAClB,CAAC;IACL,CAAC;IACD,IAAI,CAAC;QACD,MAAM,IAAI,KAAK,EAAE,CAAC;IACtB,CAAC;IAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACV,IAAI,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;YAAS,CAAC;QACP,CAAC,GAAG,EAAE,CAAC;IACX,CAAC;IACD,MAAM,GAAG,EAAE,CAAC;QACR,CAAC,GAAG,CAAC,CAAC;QACN,CAAC,GAAG,EAAE,CAAC;IACX,CAAC;IACD,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACZ,KAAK,CAAC,EAAE,CAAC;YACL,CAAC,EAAE,CAAC;YACJ,KAAK,CAAC;QAEV,CAAC;QACD,KAAK,CAAC,EAAE,CAAC;YACL,CAAC,EAAE,CAAC;YACJ,KAAK,CAAC;QAEV,CAAC;QACD,SAAS,CAAC;YACN,CAAC,IAAI,CAAC,CAAC;YACP,CAAC,GAAG,EAAE,CAAC;YACP,KAAK,CAAC;QAEV,CAAC;IACL,CAAC;IACD,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;QACZ,CAAC,EAAE,CAAC;IACR,CAAC;IACD,GAAG,CAAC;QACA,CAAC,EAAE,CAAC;IACR,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAC;IACf,CAAC,GAAG,CAAC,CAAC;IACN,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC,KAAK,CAAC,CAAC;IACR,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;IACX,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,CAAC;AACX,CAAC;AACD,IAAI,CAAC,GAAG;IACJ,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACd,CAAC,CAAC;AACF,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationStatements.sourcemap.txt b/tests/baselines/reference/sourceMapValidationStatements.sourcemap.txt index ed7c9395d2f..7c5c5bfcfeb 100644 --- a/tests/baselines/reference/sourceMapValidationStatements.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationStatements.sourcemap.txt @@ -525,9 +525,9 @@ sourceFile:sourceMapValidationStatements.ts 3 > ^^^^^^^^^^^-> 1 > > -2 > } +2 > } 1 >Emitted(30, 5) Source(29, 5) + SourceIndex(0) -2 >Emitted(30, 6) Source(29, 7) + SourceIndex(0) +2 >Emitted(30, 6) Source(29, 6) + SourceIndex(0) --- >>> catch (e) { 1->^^^^ @@ -539,7 +539,7 @@ sourceFile:sourceMapValidationStatements.ts 7 > ^ 8 > ^ 9 > ^^^^^^^^^^^-> -1-> +1-> 2 > catch 3 > 4 > ( @@ -727,9 +727,9 @@ sourceFile:sourceMapValidationStatements.ts 3 > ^^^^^^^^^^^^-> 1 > > -2 > } +2 > } 1 >Emitted(41, 5) Source(38, 5) + SourceIndex(0) -2 >Emitted(41, 6) Source(38, 7) + SourceIndex(0) +2 >Emitted(41, 6) Source(38, 6) + SourceIndex(0) --- >>> catch (e1) { 1->^^^^ @@ -741,7 +741,7 @@ sourceFile:sourceMapValidationStatements.ts 7 > ^ 8 > ^ 9 > ^^^^-> -1-> +1-> 2 > catch 3 > 4 > ( diff --git a/tests/baselines/reference/sourceMapValidationTryCatchFinally.js.map b/tests/baselines/reference/sourceMapValidationTryCatchFinally.js.map index 46506410856..8b8690b470d 100644 --- a/tests/baselines/reference/sourceMapValidationTryCatchFinally.js.map +++ b/tests/baselines/reference/sourceMapValidationTryCatchFinally.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationTryCatchFinally.js.map] -{"version":3,"file":"sourceMapValidationTryCatchFinally.js","sourceRoot":"","sources":["sourceMapValidationTryCatchFinally.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,EAAE,CAAC;AACX,IAAI,CAAC;IACD,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACd,CAAE;AAAA,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACT,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACd,CAAC;QAAS,CAAC;IACP,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;AACf,CAAC;AACD,IACA,CAAC;IACG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,IAAI,KAAK,EAAE,CAAC;AACtB,CACA;AAAA,KAAK,CAAC,CAAC,CAAC,CAAC,CACT,CAAC;IACG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACd,CAAC;QAED,CAAC;IACG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;AACf,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationTryCatchFinally.js","sourceRoot":"","sources":["sourceMapValidationTryCatchFinally.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,EAAE,CAAC;AACX,IAAI,CAAC;IACD,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACd,CAAC;AAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACT,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACd,CAAC;QAAS,CAAC;IACP,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;AACf,CAAC;AACD,IACA,CAAC;IACG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,IAAI,KAAK,EAAE,CAAC;AACtB,CAAC;AACD,KAAK,CAAC,CAAC,CAAC,CAAC,CACT,CAAC;IACG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACd,CAAC;QAED,CAAC;IACG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;AACf,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationTryCatchFinally.sourcemap.txt b/tests/baselines/reference/sourceMapValidationTryCatchFinally.sourcemap.txt index d625e74c262..845ec5eeb27 100644 --- a/tests/baselines/reference/sourceMapValidationTryCatchFinally.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationTryCatchFinally.sourcemap.txt @@ -71,9 +71,9 @@ sourceFile:sourceMapValidationTryCatchFinally.ts 3 > ^^^^^^^^^^^-> 1 > > -2 >} +2 >} 1 >Emitted(4, 1) Source(4, 1) + SourceIndex(0) -2 >Emitted(4, 2) Source(4, 3) + SourceIndex(0) +2 >Emitted(4, 2) Source(4, 2) + SourceIndex(0) --- >>>catch (e) { 1-> @@ -85,7 +85,7 @@ sourceFile:sourceMapValidationTryCatchFinally.ts 7 > ^ 8 > ^ 9 > ^^^^-> -1-> +1-> 2 >catch 3 > 4 > ( @@ -245,10 +245,9 @@ sourceFile:sourceMapValidationTryCatchFinally.ts 3 > ^^^^^^^^^^^-> 1 > > -2 >} - > +2 >} 1 >Emitted(14, 1) Source(13, 1) + SourceIndex(0) -2 >Emitted(14, 2) Source(14, 1) + SourceIndex(0) +2 >Emitted(14, 2) Source(13, 2) + SourceIndex(0) --- >>>catch (e) { 1-> @@ -260,7 +259,8 @@ sourceFile:sourceMapValidationTryCatchFinally.ts 7 > ^ 8 > ^ 9 > ^^^^-> -1-> +1-> + > 2 >catch 3 > 4 > ( diff --git a/tests/baselines/reference/specializedInheritedConstructors1.js b/tests/baselines/reference/specializedInheritedConstructors1.js index f65f42941bf..cd137e6dcae 100644 --- a/tests/baselines/reference/specializedInheritedConstructors1.js +++ b/tests/baselines/reference/specializedInheritedConstructors1.js @@ -18,11 +18,16 @@ var myView = new MyView(m); // was error //// [specializedInheritedConstructors1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var View = (function () { function View(options) { } @@ -36,7 +41,7 @@ var Model = (function () { var MyView = (function (_super) { __extends(MyView, _super); function MyView() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return MyView; }(View)); diff --git a/tests/baselines/reference/specializedOverloadWithRestParameters.js b/tests/baselines/reference/specializedOverloadWithRestParameters.js index b76afaff08c..892f30441f8 100644 --- a/tests/baselines/reference/specializedOverloadWithRestParameters.js +++ b/tests/baselines/reference/specializedOverloadWithRestParameters.js @@ -13,11 +13,16 @@ function g(tagName: any): Base { } //// [specializedOverloadWithRestParameters.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -27,7 +32,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.prototype.bar = function () { }; return Derived1; diff --git a/tests/baselines/reference/spreadMethods.errors.txt b/tests/baselines/reference/spreadMethods.errors.txt new file mode 100644 index 00000000000..b2b3491ba79 --- /dev/null +++ b/tests/baselines/reference/spreadMethods.errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/types/spread/spreadMethods.ts(7,4): error TS2339: Property 'm' does not exist on type '{ p: number; }'. +tests/cases/conformance/types/spread/spreadMethods.ts(9,5): error TS2339: Property 'm' does not exist on type '{ p: number; }'. + + +==== tests/cases/conformance/types/spread/spreadMethods.ts (2 errors) ==== + class K { p = 12; m() { } } + interface I { p: number, m(): void } + let k = new K() + let sk = { ...k }; + let ssk = { ...k, ...k }; + sk.p; + sk.m(); // error + ~ +!!! error TS2339: Property 'm' does not exist on type '{ p: number; }'. + ssk.p; + ssk.m(); // error + ~ +!!! error TS2339: Property 'm' does not exist on type '{ p: number; }'. + let i: I = { p: 12, m() { } }; + let si = { ...i }; + let ssi = { ...i, ...i }; + si.p; + si.m(); // ok + ssi.p; + ssi.m(); // ok + let o = { p: 12, m() { } }; + let so = { ...o }; + let sso = { ...o, ...o }; + so.p; + so.m(); // ok + sso.p; + sso.m(); // ok + \ No newline at end of file diff --git a/tests/baselines/reference/spreadMethods.js b/tests/baselines/reference/spreadMethods.js new file mode 100644 index 00000000000..691d6fa2829 --- /dev/null +++ b/tests/baselines/reference/spreadMethods.js @@ -0,0 +1,63 @@ +//// [spreadMethods.ts] +class K { p = 12; m() { } } +interface I { p: number, m(): void } +let k = new K() +let sk = { ...k }; +let ssk = { ...k, ...k }; +sk.p; +sk.m(); // error +ssk.p; +ssk.m(); // error +let i: I = { p: 12, m() { } }; +let si = { ...i }; +let ssi = { ...i, ...i }; +si.p; +si.m(); // ok +ssi.p; +ssi.m(); // ok +let o = { p: 12, m() { } }; +let so = { ...o }; +let sso = { ...o, ...o }; +so.p; +so.m(); // ok +sso.p; +sso.m(); // ok + + +//// [spreadMethods.js] +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; +var K = (function () { + function K() { + this.p = 12; + } + K.prototype.m = function () { }; + return K; +}()); +var k = new K(); +var sk = __assign({}, k); +var ssk = __assign({}, k, k); +sk.p; +sk.m(); // error +ssk.p; +ssk.m(); // error +var i = { p: 12, m: function () { } }; +var si = __assign({}, i); +var ssi = __assign({}, i, i); +si.p; +si.m(); // ok +ssi.p; +ssi.m(); // ok +var o = { p: 12, m: function () { } }; +var so = __assign({}, o); +var sso = __assign({}, o, o); +so.p; +so.m(); // ok +sso.p; +sso.m(); // ok diff --git a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types index f2bd83674cd..127a8d930c5 100644 --- a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types +++ b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types @@ -364,9 +364,9 @@ class ListWrapper { >value : T >T : T >list.splice(index, 0, value) : T[] ->list.splice : { (start: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>list.splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >list : T[] ->splice : { (start: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >index : number >0 : 0 >value : T @@ -389,9 +389,9 @@ class ListWrapper { list.splice(index, 1); >list.splice(index, 1) : T[] ->list.splice : { (start: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>list.splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >list : T[] ->splice : { (start: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >index : number >1 : 1 @@ -431,9 +431,9 @@ class ListWrapper { list.splice(index, 1); >list.splice(index, 1) : T[] ->list.splice : { (start: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>list.splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >list : T[] ->splice : { (start: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >index : number >1 : 1 } @@ -464,9 +464,9 @@ class ListWrapper { list.splice(index, 1); >list.splice(index, 1) : T[] ->list.splice : { (start: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>list.splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >list : T[] ->splice : { (start: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >index : number >1 : 1 @@ -603,9 +603,9 @@ class ListWrapper { >length : number >T : T >l.splice(from, length) : T[] ->l.splice : { (start: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>l.splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >l : T[] ->splice : { (start: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >from : number >length : number diff --git a/tests/baselines/reference/staticFactory1.js b/tests/baselines/reference/staticFactory1.js index de7588c3ebe..b73dce8a0cf 100644 --- a/tests/baselines/reference/staticFactory1.js +++ b/tests/baselines/reference/staticFactory1.js @@ -14,11 +14,16 @@ var d = Derived.create(); d.foo(); //// [staticFactory1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -31,7 +36,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.prototype.foo = function () { return 2; }; return Derived; diff --git a/tests/baselines/reference/staticInheritance.js b/tests/baselines/reference/staticInheritance.js index d204c1aed47..780e5e98782 100644 --- a/tests/baselines/reference/staticInheritance.js +++ b/tests/baselines/reference/staticInheritance.js @@ -12,11 +12,16 @@ doThing(B); //OK //// [staticInheritance.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function doThing(x) { } var A = (function () { function A() { @@ -27,7 +32,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.p1 = doThing(A); // OK _this.p2 = doThing(B); // OK return _this; diff --git a/tests/baselines/reference/staticMemberAccessOffDerivedType1.js b/tests/baselines/reference/staticMemberAccessOffDerivedType1.js index 7b8ca52b9a4..41f2da7f4af 100644 --- a/tests/baselines/reference/staticMemberAccessOffDerivedType1.js +++ b/tests/baselines/reference/staticMemberAccessOffDerivedType1.js @@ -10,11 +10,16 @@ class P extends SomeBase { //// [staticMemberAccessOffDerivedType1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var SomeBase = (function () { function SomeBase() { } @@ -26,7 +31,7 @@ var SomeBase = (function () { var P = (function (_super) { __extends(P, _super); function P() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return P; }(SomeBase)); diff --git a/tests/baselines/reference/staticPropSuper.js b/tests/baselines/reference/staticPropSuper.js index 6240f8c454f..5c22232534f 100644 --- a/tests/baselines/reference/staticPropSuper.js +++ b/tests/baselines/reference/staticPropSuper.js @@ -36,11 +36,16 @@ class E extends A { } //// [staticPropSuper.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -49,7 +54,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - var _this; + var _this = this; var x = 1; // should not error _this = _super.call(this) || this; return _this; @@ -60,7 +65,7 @@ B.s = 9; var C = (function (_super) { __extends(C, _super); function C() { - var _this; + var _this = this; _this.p = 10; var x = 1; // should error return _this; @@ -70,7 +75,7 @@ var C = (function (_super) { var D = (function (_super) { __extends(D, _super); function D() { - var _this; + var _this = this; _this.p = 11; var x = 1; // should error return _this; @@ -80,7 +85,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - var _this; + var _this = this; _this.p = 12; var x = 1; // should error return _this; diff --git a/tests/baselines/reference/strictModeInConstructor.js b/tests/baselines/reference/strictModeInConstructor.js index da45bda5c6e..65426391967 100644 --- a/tests/baselines/reference/strictModeInConstructor.js +++ b/tests/baselines/reference/strictModeInConstructor.js @@ -61,11 +61,16 @@ class Ds extends A { } //// [strictModeInConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -94,7 +99,7 @@ var C = (function (_super) { var D = (function (_super) { __extends(D, _super); function D() { - var _this; + var _this = this; _this.s = 9; var x = 1; // Error _this = _super.call(this) || this; @@ -125,7 +130,7 @@ Cs.s = 9; var Ds = (function (_super) { __extends(Ds, _super); function Ds() { - var _this; + var _this = this; var x = 1; // no Error _this = _super.call(this) || this; "use strict"; diff --git a/tests/baselines/reference/strictModeReservedWord.js b/tests/baselines/reference/strictModeReservedWord.js index 29715745890..07b514da9b7 100644 --- a/tests/baselines/reference/strictModeReservedWord.js +++ b/tests/baselines/reference/strictModeReservedWord.js @@ -28,11 +28,16 @@ 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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var let = 10; function foo() { "use strict"; @@ -48,7 +53,7 @@ function foo() { var myClass = (function (_super) { __extends(package, _super); function package() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return package; }(public)); diff --git a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.js b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.js index 1507e53d8cf..2539ce5dbbb 100644 --- a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.js +++ b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.js @@ -29,11 +29,16 @@ class G extends package { } class H extends package.A { } //// [strictModeReservedWordInClassDeclaration.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo(private, public, static) { private = public = static; @@ -75,14 +80,14 @@ var F1 = (function () { var G = (function (_super) { __extends(G, _super); function G() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return G; }(package)); var H = (function (_super) { __extends(H, _super); function H() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return H; }(package.A)); diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt index 8f4bbe2025a..606cc39afef 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt @@ -22,8 +22,8 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(71,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(73,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(74,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. - Property '2.0' is incompatible with index signature. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ a: string; b: number; c: () => void; "d": string; "e": number; 1.0: string; 2.0: number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. + Property 'b' is incompatible with index signature. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(93,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -157,8 +157,8 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon // error var b: { [x: string]: string; } = { ~ -!!! error TS2322: Type '{ 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. -!!! error TS2322: Property '2.0' is incompatible with index signature. +!!! error TS2322: Type '{ a: string; b: number; c: () => void; "d": string; "e": number; 1.0: string; 2.0: number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. +!!! error TS2322: Property 'b' is incompatible with index signature. !!! error TS2322: Type 'number' is not assignable to type 'string'. a: '', b: 1, diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.js b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.js index b532df7b120..f9942aff042 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.js +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.js @@ -41,11 +41,16 @@ var b: { [x: string]: A } = { //// [stringIndexerConstrainsPropertyDeclarations2.js] // String indexer providing a constraint of a user defined 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -55,7 +60,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { return ''; }; return B; diff --git a/tests/baselines/reference/subSubClassCanAccessProtectedConstructor.js b/tests/baselines/reference/subSubClassCanAccessProtectedConstructor.js index 15d6fc70da5..5036df4a330 100644 --- a/tests/baselines/reference/subSubClassCanAccessProtectedConstructor.js +++ b/tests/baselines/reference/subSubClassCanAccessProtectedConstructor.js @@ -17,11 +17,16 @@ class SubclassOfSubclass extends Subclass { //// [subSubClassCanAccessProtectedConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { this.instance1 = new Base(); // allowed @@ -31,7 +36,7 @@ var Base = (function () { var Subclass = (function (_super) { __extends(Subclass, _super); function Subclass() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.instance1_1 = new Base(); // allowed _this.instance1_2 = new Subclass(); // allowed return _this; @@ -41,7 +46,7 @@ var Subclass = (function (_super) { var SubclassOfSubclass = (function (_super) { __extends(SubclassOfSubclass, _super); function SubclassOfSubclass() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.instance2_1 = new Base(); // allowed _this.instance2_2 = new Subclass(); // allowed _this.instance2_3 = new SubclassOfSubclass(); // allowed diff --git a/tests/baselines/reference/subtypesOfTypeParameter.js b/tests/baselines/reference/subtypesOfTypeParameter.js index 38f5b5f1d4b..3c3a17d8f84 100644 --- a/tests/baselines/reference/subtypesOfTypeParameter.js +++ b/tests/baselines/reference/subtypesOfTypeParameter.js @@ -107,11 +107,16 @@ function f2(x: T, y: U) { //// [subtypesOfTypeParameter.js] // checking whether other types are subtypes of type parameters -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C3 = (function () { function C3() { } @@ -120,7 +125,7 @@ var C3 = (function () { var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(C3)); diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.js b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.js index 82bcbf14ecc..b594eea6e4d 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.js +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.js @@ -169,11 +169,16 @@ class D29 extends C3 { //// [subtypesOfTypeParameterWithConstraints.js] // checking whether other types are subtypes of type parameters with constraints -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C3 = (function () { function C3() { } @@ -182,28 +187,28 @@ var C3 = (function () { var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(C3)); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(C3)); var D3 = (function (_super) { __extends(D3, _super); function D3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D3; }(C3)); var D4 = (function (_super) { __extends(D4, _super); function D4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D4; }(C3)); @@ -213,21 +218,21 @@ var D4 = (function (_super) { var D5 = (function (_super) { __extends(D5, _super); function D5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D5; }(C3)); var D6 = (function (_super) { __extends(D6, _super); function D6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D6; }(C3)); var D7 = (function (_super) { __extends(D7, _super); function D7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D7; }(C3)); @@ -236,21 +241,21 @@ var D7 = (function (_super) { var D8 = (function (_super) { __extends(D8, _super); function D8() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D8; }(C3)); var D9 = (function (_super) { __extends(D9, _super); function D9() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D9; }(C3)); var D10 = (function (_super) { __extends(D10, _super); function D10() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D10; }(C3)); @@ -259,21 +264,21 @@ var D10 = (function (_super) { var D11 = (function (_super) { __extends(D11, _super); function D11() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D11; }(C3)); var D12 = (function (_super) { __extends(D12, _super); function D12() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D12; }(C3)); var D13 = (function (_super) { __extends(D13, _super); function D13() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D13; }(C3)); @@ -283,28 +288,28 @@ var D13 = (function (_super) { var D14 = (function (_super) { __extends(D14, _super); function D14() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D14; }(C3)); var D15 = (function (_super) { __extends(D15, _super); function D15() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D15; }(C3)); var D16 = (function (_super) { __extends(D16, _super); function D16() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D16; }(C3)); var D17 = (function (_super) { __extends(D17, _super); function D17() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D17; }(C3)); @@ -313,28 +318,28 @@ var D17 = (function (_super) { var D18 = (function (_super) { __extends(D18, _super); function D18() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D18; }(C3)); var D19 = (function (_super) { __extends(D19, _super); function D19() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D19; }(C3)); var D20 = (function (_super) { __extends(D20, _super); function D20() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D20; }(C3)); var D21 = (function (_super) { __extends(D21, _super); function D21() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D21; }(C3)); @@ -343,28 +348,28 @@ var D21 = (function (_super) { var D22 = (function (_super) { __extends(D22, _super); function D22() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D22; }(C3)); var D23 = (function (_super) { __extends(D23, _super); function D23() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D23; }(C3)); var D24 = (function (_super) { __extends(D24, _super); function D24() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D24; }(C3)); var D25 = (function (_super) { __extends(D25, _super); function D25() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D25; }(C3)); @@ -373,28 +378,28 @@ var D25 = (function (_super) { var D26 = (function (_super) { __extends(D26, _super); function D26() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D26; }(C3)); var D27 = (function (_super) { __extends(D27, _super); function D27() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D27; }(C3)); var D28 = (function (_super) { __extends(D28, _super); function D28() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D28; }(C3)); var D29 = (function (_super) { __extends(D29, _super); function D29() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D29; }(C3)); diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js index e0baced37a4..b3fa5971898 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js @@ -80,11 +80,16 @@ class D9 extends B1 { //// [subtypesOfTypeParameterWithConstraints4.js] // checking whether other types are subtypes of type parameters with constraints -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -118,63 +123,63 @@ var B1 = (function () { var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(B1)); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(B1)); var D3 = (function (_super) { __extends(D3, _super); function D3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D3; }(B1)); var D4 = (function (_super) { __extends(D4, _super); function D4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D4; }(B1)); var D5 = (function (_super) { __extends(D5, _super); function D5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D5; }(B1)); var D6 = (function (_super) { __extends(D6, _super); function D6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D6; }(B1)); var D7 = (function (_super) { __extends(D7, _super); function D7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D7; }(B1)); var D8 = (function (_super) { __extends(D8, _super); function D8() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D8; }(B1)); var D9 = (function (_super) { __extends(D9, _super); function D9() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D9; }(B1)); diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js index 0b17fc07f24..3d2fb052b41 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js +++ b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js @@ -159,11 +159,16 @@ module M2 { //// [subtypesOfTypeParameterWithRecursiveConstraints.js] // checking whether other types are subtypes of type parameters with constraints -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -217,63 +222,63 @@ var M1; var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(Base)); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(Base)); var D3 = (function (_super) { __extends(D3, _super); function D3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D3; }(Base)); var D4 = (function (_super) { __extends(D4, _super); function D4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D4; }(Base)); var D5 = (function (_super) { __extends(D5, _super); function D5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D5; }(Base)); var D6 = (function (_super) { __extends(D6, _super); function D6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D6; }(Base)); var D7 = (function (_super) { __extends(D7, _super); function D7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D7; }(Base)); var D8 = (function (_super) { __extends(D8, _super); function D8() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D8; }(Base)); var D9 = (function (_super) { __extends(D9, _super); function D9() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D9; }(Base)); @@ -288,63 +293,63 @@ var M2; var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(Base2)); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(Base2)); var D3 = (function (_super) { __extends(D3, _super); function D3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D3; }(Base2)); var D4 = (function (_super) { __extends(D4, _super); function D4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D4; }(Base2)); var D5 = (function (_super) { __extends(D5, _super); function D5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D5; }(Base2)); var D6 = (function (_super) { __extends(D6, _super); function D6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D6; }(Base2)); var D7 = (function (_super) { __extends(D7, _super); function D7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D7; }(Base2)); var D8 = (function (_super) { __extends(D8, _super); function D8() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D8; }(Base2)); var D9 = (function (_super) { __extends(D9, _super); function D9() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D9; }(Base2)); diff --git a/tests/baselines/reference/subtypingTransitivity.js b/tests/baselines/reference/subtypingTransitivity.js index 9c4c9011758..cbacd85a779 100644 --- a/tests/baselines/reference/subtypingTransitivity.js +++ b/tests/baselines/reference/subtypingTransitivity.js @@ -20,11 +20,16 @@ b.x = 1; // assigned number to string //// [subtypingTransitivity.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { } @@ -33,14 +38,14 @@ var B = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(B)); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(B)); diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.js b/tests/baselines/reference/subtypingWithCallSignatures2.js index 3b5fada2012..dfe34ca35f0 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.js +++ b/tests/baselines/reference/subtypingWithCallSignatures2.js @@ -174,11 +174,16 @@ var r18 = foo18(r18arg1); //// [subtypingWithCallSignatures2.js] // checking subtype relations for function types as it relates to contextual signature instantiation -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -187,21 +192,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/subtypingWithCallSignatures3.js b/tests/baselines/reference/subtypingWithCallSignatures3.js index 4ac7d3a7f24..d479bdbe618 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures3.js +++ b/tests/baselines/reference/subtypingWithCallSignatures3.js @@ -121,11 +121,16 @@ module WithGenericSignaturesInBaseType { //// [subtypingWithCallSignatures3.js] // checking subtype relations for function types as it relates to contextual signature instantiation // error cases, so function calls will all result in '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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Errors; (function (Errors) { var Base = (function () { @@ -136,21 +141,21 @@ var Errors; var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/subtypingWithCallSignatures4.js b/tests/baselines/reference/subtypingWithCallSignatures4.js index 94f549c62c1..09c5e8056ba 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.js +++ b/tests/baselines/reference/subtypingWithCallSignatures4.js @@ -113,11 +113,16 @@ var r18 = foo18(r18arg); //// [subtypingWithCallSignatures4.js] // checking subtype relations for function types as it relates to contextual signature instantiation -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -126,21 +131,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/subtypingWithConstructSignatures2.js b/tests/baselines/reference/subtypingWithConstructSignatures2.js index 1d12aeb945f..55624b63f42 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures2.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures2.js @@ -174,11 +174,16 @@ var r18 = foo18(r18arg1); //// [subtypingWithConstructSignatures2.js] // checking subtype relations for function types as it relates to contextual signature instantiation -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -187,21 +192,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/subtypingWithConstructSignatures3.js b/tests/baselines/reference/subtypingWithConstructSignatures3.js index 78582304cb8..a7a7f620389 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures3.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures3.js @@ -123,11 +123,16 @@ module WithGenericSignaturesInBaseType { //// [subtypingWithConstructSignatures3.js] // checking subtype relations for function types as it relates to contextual signature instantiation // error cases, so function calls will all result in '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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Errors; (function (Errors) { var Base = (function () { @@ -138,21 +143,21 @@ var Errors; var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/subtypingWithConstructSignatures4.js b/tests/baselines/reference/subtypingWithConstructSignatures4.js index 17252fdb809..e8ca51f317a 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures4.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures4.js @@ -113,11 +113,16 @@ var r18 = foo18(r18arg); //// [subtypingWithConstructSignatures4.js] // checking subtype relations for function types as it relates to contextual signature instantiation -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -126,21 +131,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/subtypingWithConstructSignatures5.js b/tests/baselines/reference/subtypingWithConstructSignatures5.js index a0561606393..c99e215bc89 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures5.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures5.js @@ -51,11 +51,16 @@ interface I extends B { //// [subtypingWithConstructSignatures5.js] // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithConstructSignatures2 just with an extra level of indirection in the inheritance chain -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -64,21 +69,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/subtypingWithConstructSignatures6.js b/tests/baselines/reference/subtypingWithConstructSignatures6.js index c508781e089..cbd8eebf47c 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures6.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures6.js @@ -54,11 +54,16 @@ interface I9 extends A { // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithConstructSignatures4 but using class type parameters instead of generic signatures // all are 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -67,21 +72,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/subtypingWithNumericIndexer.js b/tests/baselines/reference/subtypingWithNumericIndexer.js index 3cf75dd83fd..7f140917935 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer.js +++ b/tests/baselines/reference/subtypingWithNumericIndexer.js @@ -41,11 +41,16 @@ module Generics { //// [subtypingWithNumericIndexer.js] // Derived type indexer must be subtype of base type indexer -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -54,14 +59,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); @@ -75,28 +80,28 @@ var Generics; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A)); var B4 = (function (_super) { __extends(B4, _super); function B4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B4; }(A)); diff --git a/tests/baselines/reference/subtypingWithNumericIndexer3.js b/tests/baselines/reference/subtypingWithNumericIndexer3.js index e9e8d39bf3c..e8fbc59bed7 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer3.js +++ b/tests/baselines/reference/subtypingWithNumericIndexer3.js @@ -45,11 +45,16 @@ module Generics { //// [subtypingWithNumericIndexer3.js] // Derived type indexer must be subtype of base type indexer -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -58,14 +63,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); @@ -79,35 +84,35 @@ var Generics; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A)); var B4 = (function (_super) { __extends(B4, _super); function B4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B4; }(A)); var B5 = (function (_super) { __extends(B5, _super); function B5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B5; }(A)); diff --git a/tests/baselines/reference/subtypingWithNumericIndexer4.js b/tests/baselines/reference/subtypingWithNumericIndexer4.js index 798e775083f..ce3ed4fb4de 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer4.js +++ b/tests/baselines/reference/subtypingWithNumericIndexer4.js @@ -29,11 +29,16 @@ module Generics { //// [subtypingWithNumericIndexer4.js] // Derived type indexer must be subtype of base type indexer -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -42,7 +47,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -56,14 +61,14 @@ var Generics; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A)); diff --git a/tests/baselines/reference/subtypingWithObjectMembers.js b/tests/baselines/reference/subtypingWithObjectMembers.js index 3675ed6a410..7f1c9e9e492 100644 --- a/tests/baselines/reference/subtypingWithObjectMembers.js +++ b/tests/baselines/reference/subtypingWithObjectMembers.js @@ -68,11 +68,16 @@ module TwoLevels { } //// [subtypingWithObjectMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -81,14 +86,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); @@ -102,7 +107,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -114,7 +119,7 @@ var A2 = (function () { var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A2)); @@ -126,7 +131,7 @@ var A3 = (function () { var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A3)); @@ -140,7 +145,7 @@ var TwoLevels; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -152,7 +157,7 @@ var TwoLevels; var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A2)); @@ -164,7 +169,7 @@ var TwoLevels; var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A3)); diff --git a/tests/baselines/reference/subtypingWithObjectMembers4.js b/tests/baselines/reference/subtypingWithObjectMembers4.js index 404b6cbe988..e453b508c34 100644 --- a/tests/baselines/reference/subtypingWithObjectMembers4.js +++ b/tests/baselines/reference/subtypingWithObjectMembers4.js @@ -35,11 +35,16 @@ class B3 extends A3 { //// [subtypingWithObjectMembers4.js] // subtyping when property names do not match -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -48,7 +53,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -60,7 +65,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -72,7 +77,7 @@ var A2 = (function () { var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A2)); @@ -84,7 +89,7 @@ var A3 = (function () { var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A3)); diff --git a/tests/baselines/reference/subtypingWithObjectMembersAccessibility.js b/tests/baselines/reference/subtypingWithObjectMembersAccessibility.js index 8b168ea73b5..fae7c452edc 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersAccessibility.js +++ b/tests/baselines/reference/subtypingWithObjectMembersAccessibility.js @@ -35,11 +35,16 @@ class B3 extends A3 { //// [subtypingWithObjectMembersAccessibility.js] // Derived member is private, base member is not causes 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -48,7 +53,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -60,7 +65,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -72,7 +77,7 @@ var A2 = (function () { var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A2)); @@ -84,7 +89,7 @@ var A3 = (function () { var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A3)); diff --git a/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.js b/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.js index 0a83b760218..6fd845d2277 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.js +++ b/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.js @@ -63,11 +63,16 @@ module ImplicitPublic { //// [subtypingWithObjectMembersAccessibility2.js] // Derived member is private, base member is not causes 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -76,7 +81,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -90,7 +95,7 @@ var ExplicitPublic; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -102,7 +107,7 @@ var ExplicitPublic; var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A2)); @@ -114,7 +119,7 @@ var ExplicitPublic; var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A3)); @@ -129,7 +134,7 @@ var ImplicitPublic; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -141,7 +146,7 @@ var ImplicitPublic; var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A2)); @@ -153,7 +158,7 @@ var ImplicitPublic; var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A3)); diff --git a/tests/baselines/reference/subtypingWithStringIndexer.js b/tests/baselines/reference/subtypingWithStringIndexer.js index 195b7d2192e..36382a4ff91 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer.js +++ b/tests/baselines/reference/subtypingWithStringIndexer.js @@ -42,11 +42,16 @@ module Generics { //// [subtypingWithStringIndexer.js] // Derived type indexer must be subtype of base type indexer -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -55,14 +60,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); @@ -76,28 +81,28 @@ var Generics; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A)); var B4 = (function (_super) { __extends(B4, _super); function B4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B4; }(A)); diff --git a/tests/baselines/reference/subtypingWithStringIndexer3.js b/tests/baselines/reference/subtypingWithStringIndexer3.js index 0b2a57324eb..ed8e027e7c5 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer3.js +++ b/tests/baselines/reference/subtypingWithStringIndexer3.js @@ -45,11 +45,16 @@ module Generics { //// [subtypingWithStringIndexer3.js] // Derived type indexer must be subtype of base type indexer -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -58,14 +63,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); @@ -79,35 +84,35 @@ var Generics; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A)); var B4 = (function (_super) { __extends(B4, _super); function B4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B4; }(A)); var B5 = (function (_super) { __extends(B5, _super); function B5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B5; }(A)); diff --git a/tests/baselines/reference/subtypingWithStringIndexer4.js b/tests/baselines/reference/subtypingWithStringIndexer4.js index 2937261ad05..d8a9693e1a1 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer4.js +++ b/tests/baselines/reference/subtypingWithStringIndexer4.js @@ -29,11 +29,16 @@ module Generics { //// [subtypingWithStringIndexer4.js] // Derived type indexer must be subtype of base type indexer -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -42,7 +47,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -56,14 +61,14 @@ var Generics; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A)); diff --git a/tests/baselines/reference/super.js b/tests/baselines/reference/super.js index 504e8542d4d..3dd0e9ed538 100644 --- a/tests/baselines/reference/super.js +++ b/tests/baselines/reference/super.js @@ -38,11 +38,16 @@ s.foo() + ss.foo(); //// [super.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { var x; @@ -58,7 +63,7 @@ var Base = (function () { var Sub1 = (function (_super) { __extends(Sub1, _super); function Sub1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Sub1.prototype.foo = function () { return "sub1" + _super.prototype.foo.call(this) + _super.prototype.bar.call(this); @@ -68,7 +73,7 @@ var Sub1 = (function (_super) { var SubSub1 = (function (_super) { __extends(SubSub1, _super); function SubSub1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SubSub1.prototype.foo = function () { return "subsub1" + _super.prototype.foo.call(this); diff --git a/tests/baselines/reference/super1.js b/tests/baselines/reference/super1.js index 0094f696faf..1ed0edbe051 100644 --- a/tests/baselines/reference/super1.js +++ b/tests/baselines/reference/super1.js @@ -67,11 +67,16 @@ module Base4 { //// [super1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // Case 1 var Base1 = (function () { function Base1() { @@ -84,7 +89,7 @@ var Base1 = (function () { var Sub1 = (function (_super) { __extends(Sub1, _super); function Sub1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Sub1.prototype.bar = function () { return "base"; @@ -94,7 +99,7 @@ var Sub1 = (function (_super) { var SubSub1 = (function (_super) { __extends(SubSub1, _super); function SubSub1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SubSub1.prototype.bar = function () { return _super.prototype["super"].foo; @@ -113,7 +118,7 @@ var Base2 = (function () { var SubE2 = (function (_super) { __extends(SubE2, _super); function SubE2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SubE2.prototype.bar = function () { return _super.prototype.prototype.foo = null; @@ -132,7 +137,7 @@ var Base3 = (function () { var SubE3 = (function (_super) { __extends(SubE3, _super); function SubE3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SubE3.prototype.bar = function () { return _super.prototype.bar.call(this); @@ -153,7 +158,7 @@ var Base4; var SubSub4 = (function (_super) { __extends(SubSub4, _super); function SubSub4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SubSub4.prototype.x = function () { return _super.prototype.x.call(this); diff --git a/tests/baselines/reference/super2.js b/tests/baselines/reference/super2.js index 1d2331052db..0f2101bc4dd 100644 --- a/tests/baselines/reference/super2.js +++ b/tests/baselines/reference/super2.js @@ -51,11 +51,16 @@ results1.x() + results1.y() + results2.y(); //// [super2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // Case 5 var Base5 = (function () { function Base5() { @@ -71,7 +76,7 @@ var Base5 = (function () { var Sub5 = (function (_super) { __extends(Sub5, _super); function Sub5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Sub5.prototype.x = function () { return "SubX"; @@ -81,7 +86,7 @@ var Sub5 = (function (_super) { var SubSub5 = (function (_super) { __extends(SubSub5, _super); function SubSub5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SubSub5.prototype.x = function () { return _super.prototype.x.call(this); @@ -103,7 +108,7 @@ var Base6 = (function () { var Sub6 = (function (_super) { __extends(Sub6, _super); function Sub6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Sub6.prototype.y = function () { return "SubY"; @@ -113,7 +118,7 @@ var Sub6 = (function (_super) { var SubSub6 = (function (_super) { __extends(SubSub6, _super); function SubSub6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SubSub6.prototype.y = function () { return _super.prototype.y.call(this); diff --git a/tests/baselines/reference/superAccess.js b/tests/baselines/reference/superAccess.js index 0bd9d305d2e..468e2155e48 100644 --- a/tests/baselines/reference/superAccess.js +++ b/tests/baselines/reference/superAccess.js @@ -14,11 +14,16 @@ class MyDerived extends MyBase { } //// [superAccess.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var MyBase = (function () { function MyBase() { this.S2 = "test"; @@ -30,7 +35,7 @@ MyBase.S1 = 5; var MyDerived = (function (_super) { __extends(MyDerived, _super); function MyDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } MyDerived.prototype.foo = function () { var l3 = _super.prototype.S1; // Expected => Error: Only public instance methods of the base class are accessible via the 'super' keyword diff --git a/tests/baselines/reference/superAccess2.js b/tests/baselines/reference/superAccess2.js index da19770584a..51e8f61ab28 100644 --- a/tests/baselines/reference/superAccess2.js +++ b/tests/baselines/reference/superAccess2.js @@ -25,11 +25,16 @@ class Q extends P { } //// [superAccess2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var P = (function () { function P() { } @@ -41,9 +46,9 @@ var Q = (function (_super) { __extends(Q, _super); // Super is not allowed in constructor args function Q(z, zz, zzz) { - if (z === void 0) { z = _super.; } - if (zz === void 0) { zz = _super.; } - if (zzz === void 0) { zzz = function () { return _super.; }; } + if (z === void 0) { z = _super.prototype.; } + if (zz === void 0) { zz = _super.prototype.; } + if (zzz === void 0) { zzz = function () { return _super.prototype.; }; } var _this = _super.call(this) || this; _this.z = z; _this.xx = _super.prototype.; diff --git a/tests/baselines/reference/superAccessInFatArrow1.js b/tests/baselines/reference/superAccessInFatArrow1.js index a7f964309f7..ebbf9ccf8d2 100644 --- a/tests/baselines/reference/superAccessInFatArrow1.js +++ b/tests/baselines/reference/superAccessInFatArrow1.js @@ -16,11 +16,16 @@ module test { } //// [superAccessInFatArrow1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var test; (function (test) { var A = (function () { @@ -34,7 +39,7 @@ var test; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function (callback) { }; diff --git a/tests/baselines/reference/superCallArgsMustMatch.js b/tests/baselines/reference/superCallArgsMustMatch.js index 106d7433bf5..113fbd69625 100644 --- a/tests/baselines/reference/superCallArgsMustMatch.js +++ b/tests/baselines/reference/superCallArgsMustMatch.js @@ -26,11 +26,16 @@ class T6 extends T5{ //// [superCallArgsMustMatch.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var T5 = (function () { function T5(bar) { this.bar = bar; diff --git a/tests/baselines/reference/superCallAssignResult.js b/tests/baselines/reference/superCallAssignResult.js index 6e30cc64052..a4525cb6ec8 100644 --- a/tests/baselines/reference/superCallAssignResult.js +++ b/tests/baselines/reference/superCallAssignResult.js @@ -11,11 +11,16 @@ class H extends E { } //// [superCallAssignResult.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var E = (function () { function E(arg) { } @@ -24,7 +29,7 @@ var E = (function () { var H = (function (_super) { __extends(H, _super); function H() { - var _this; + var _this = this; var x = _this = _super.call(this, 5) || this; // Should be of type void, not E. x = 5; return _this; diff --git a/tests/baselines/reference/superCallBeforeThisAccessing1.js b/tests/baselines/reference/superCallBeforeThisAccessing1.js index e3aed9e40e9..3045968da16 100644 --- a/tests/baselines/reference/superCallBeforeThisAccessing1.js +++ b/tests/baselines/reference/superCallBeforeThisAccessing1.js @@ -17,11 +17,16 @@ class D extends Base { //// [superCallBeforeThisAccessing1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(c) { } diff --git a/tests/baselines/reference/superCallBeforeThisAccessing2.js b/tests/baselines/reference/superCallBeforeThisAccessing2.js index 91cc3d28dd6..d78ba6e4875 100644 --- a/tests/baselines/reference/superCallBeforeThisAccessing2.js +++ b/tests/baselines/reference/superCallBeforeThisAccessing2.js @@ -11,11 +11,16 @@ class D extends Base { //// [superCallBeforeThisAccessing2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(c) { } diff --git a/tests/baselines/reference/superCallBeforeThisAccessing3.js b/tests/baselines/reference/superCallBeforeThisAccessing3.js index 185767fefb6..0bf37369b7e 100644 --- a/tests/baselines/reference/superCallBeforeThisAccessing3.js +++ b/tests/baselines/reference/superCallBeforeThisAccessing3.js @@ -14,11 +14,16 @@ class D extends Base { //// [superCallBeforeThisAccessing3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(c) { } @@ -27,7 +32,7 @@ var Base = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this; + var _this = this; var x = function () { _this._t; }; x(); // no error; we only check super is called before this when the container is a constructor _this._t; // error diff --git a/tests/baselines/reference/superCallBeforeThisAccessing4.js b/tests/baselines/reference/superCallBeforeThisAccessing4.js index 91acb88ce22..80a71d02d4d 100644 --- a/tests/baselines/reference/superCallBeforeThisAccessing4.js +++ b/tests/baselines/reference/superCallBeforeThisAccessing4.js @@ -16,27 +16,29 @@ class E extends null { } //// [superCallBeforeThisAccessing4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var D = (function (_super) { __extends(D, _super); function D() { - var _this; - _this._t; + this._t; _this = _super.call(this) || this; - return _this; } return D; }(null)); var E = (function (_super) { __extends(E, _super); function E() { - var _this = _super.call(this) || this; - _this._t; - return _this; + _this = _super.call(this) || this; + this._t; } return E; }(null)); diff --git a/tests/baselines/reference/superCallBeforeThisAccessing5.js b/tests/baselines/reference/superCallBeforeThisAccessing5.js index 57228538faf..42049ff2b32 100644 --- a/tests/baselines/reference/superCallBeforeThisAccessing5.js +++ b/tests/baselines/reference/superCallBeforeThisAccessing5.js @@ -8,17 +8,20 @@ class D extends null { //// [superCallBeforeThisAccessing5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var D = (function (_super) { __extends(D, _super); function D() { - var _this; - _this._t; // No error - return _this; + this._t; // No error } return D; }(null)); diff --git a/tests/baselines/reference/superCallBeforeThisAccessing6.js b/tests/baselines/reference/superCallBeforeThisAccessing6.js index 4eb8e5266c2..244e21e6f73 100644 --- a/tests/baselines/reference/superCallBeforeThisAccessing6.js +++ b/tests/baselines/reference/superCallBeforeThisAccessing6.js @@ -11,11 +11,16 @@ class D extends Base { //// [superCallBeforeThisAccessing6.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(c) { } diff --git a/tests/baselines/reference/superCallBeforeThisAccessing7.js b/tests/baselines/reference/superCallBeforeThisAccessing7.js index 9cfe8736774..90bc4e5c466 100644 --- a/tests/baselines/reference/superCallBeforeThisAccessing7.js +++ b/tests/baselines/reference/superCallBeforeThisAccessing7.js @@ -14,11 +14,16 @@ class D extends Base { //// [superCallBeforeThisAccessing7.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(c) { } @@ -27,7 +32,7 @@ var Base = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this; + var _this = this; var x = { j: _this._t }; diff --git a/tests/baselines/reference/superCallBeforeThisAccessing8.js b/tests/baselines/reference/superCallBeforeThisAccessing8.js index fe459b5e031..2bf73681986 100644 --- a/tests/baselines/reference/superCallBeforeThisAccessing8.js +++ b/tests/baselines/reference/superCallBeforeThisAccessing8.js @@ -14,11 +14,16 @@ class D extends Base { //// [superCallBeforeThisAccessing8.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(c) { } @@ -27,7 +32,7 @@ var Base = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this; + var _this = this; var x = { k: _this = _super.call(this, undefined) || this, j: _this._t diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.js b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.js index bc196299bf9..4ee302020ef 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.js @@ -12,11 +12,16 @@ class D extends B { //// [superCallFromClassThatDerivesFromGenericType1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var D = (function (_super) { __extends(D, _super); function D() { diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.js b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.js index 8a0ef085590..3d9c8ff717e 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.js @@ -11,11 +11,16 @@ class D extends B { //// [superCallFromClassThatDerivesFromGenericType2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var D = (function (_super) { __extends(D, _super); function D() { diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js index 0529d5e3dc2..18038207125 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js @@ -11,11 +11,16 @@ class B extends A { } //// [superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(map) { this.map = map; diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js index fb08ec28902..77b0f4af212 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js @@ -11,11 +11,16 @@ class B extends A { } //// [superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(map) { this.map = map; diff --git a/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js b/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js index 50153391f62..861bd9b470c 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js @@ -11,11 +11,16 @@ class B extends A { } //// [superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(map) { this.map = map; diff --git a/tests/baselines/reference/superCallInNonStaticMethod.js b/tests/baselines/reference/superCallInNonStaticMethod.js index cd84052ca3c..056dda2bf33 100644 --- a/tests/baselines/reference/superCallInNonStaticMethod.js +++ b/tests/baselines/reference/superCallInNonStaticMethod.js @@ -51,11 +51,16 @@ class Other extends Doing { //// [superCallInNonStaticMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 b31110fdf78..c07c64304df 100644 --- a/tests/baselines/reference/superCallInStaticMethod.js +++ b/tests/baselines/reference/superCallInStaticMethod.js @@ -47,11 +47,16 @@ class Other extends Doing { //// [superCallInStaticMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Doing = (function () { function Doing() { } @@ -62,7 +67,7 @@ var Doing = (function () { var Other = (function (_super) { __extends(Other, _super); function Other() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } // in static method Other.staticMethod = function () { diff --git a/tests/baselines/reference/superCallInsideClassDeclaration.js b/tests/baselines/reference/superCallInsideClassDeclaration.js index 05e44119608..ff822037647 100644 --- a/tests/baselines/reference/superCallInsideClassDeclaration.js +++ b/tests/baselines/reference/superCallInsideClassDeclaration.js @@ -17,11 +17,16 @@ class B extends A { } //// [superCallInsideClassDeclaration.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -35,7 +40,7 @@ var C = (function () { var B = (function (_super) { __extends(B, _super); function B() { - var _this; + var _this = this; var D = (function (_super) { __extends(D, _super); function D() { diff --git a/tests/baselines/reference/superCallInsideClassExpression.js b/tests/baselines/reference/superCallInsideClassExpression.js index 3d55fe11cff..e1d146aa131 100644 --- a/tests/baselines/reference/superCallInsideClassExpression.js +++ b/tests/baselines/reference/superCallInsideClassExpression.js @@ -17,11 +17,16 @@ class B extends A { } //// [superCallInsideClassExpression.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -35,7 +40,7 @@ var C = (function () { var B = (function (_super) { __extends(B, _super); function B() { - var _this; + var _this = this; var D = (function (_super) { __extends(class_1, _super); function class_1() { diff --git a/tests/baselines/reference/superCallInsideObjectLiteralExpression.js b/tests/baselines/reference/superCallInsideObjectLiteralExpression.js index 636b03c227f..541539d39ac 100644 --- a/tests/baselines/reference/superCallInsideObjectLiteralExpression.js +++ b/tests/baselines/reference/superCallInsideObjectLiteralExpression.js @@ -13,11 +13,16 @@ class B extends A { } //// [superCallInsideObjectLiteralExpression.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -28,7 +33,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - var _this; + var _this = this; var x = { x: _this = _super.call(this) || this }; diff --git a/tests/baselines/reference/superCallOutsideConstructor.js b/tests/baselines/reference/superCallOutsideConstructor.js index e32bfc66050..60e9411d414 100644 --- a/tests/baselines/reference/superCallOutsideConstructor.js +++ b/tests/baselines/reference/superCallOutsideConstructor.js @@ -23,11 +23,16 @@ var d = new D(); //// [superCallOutsideConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 d8491b4ee83..cfb0efa9d3d 100644 --- a/tests/baselines/reference/superCallParameterContextualTyping1.js +++ b/tests/baselines/reference/superCallParameterContextualTyping1.js @@ -13,11 +13,16 @@ class B extends A { //// [superCallParameterContextualTyping1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(map) { this.map = map; diff --git a/tests/baselines/reference/superCallParameterContextualTyping2.js b/tests/baselines/reference/superCallParameterContextualTyping2.js index 9868a7db124..f1180347142 100644 --- a/tests/baselines/reference/superCallParameterContextualTyping2.js +++ b/tests/baselines/reference/superCallParameterContextualTyping2.js @@ -12,11 +12,16 @@ class C extends A { } //// [superCallParameterContextualTyping2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(map) { this.map = map; diff --git a/tests/baselines/reference/superCallParameterContextualTyping3.js b/tests/baselines/reference/superCallParameterContextualTyping3.js index 6a43d58c471..c955f210779 100644 --- a/tests/baselines/reference/superCallParameterContextualTyping3.js +++ b/tests/baselines/reference/superCallParameterContextualTyping3.js @@ -32,11 +32,16 @@ class C extends CBase { } //// [superCallParameterContextualTyping3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var CBase = (function () { function CBase(param) { } diff --git a/tests/baselines/reference/superCallWithCommentEmit01.js b/tests/baselines/reference/superCallWithCommentEmit01.js index c7ea3cc8b85..993776f0057 100644 --- a/tests/baselines/reference/superCallWithCommentEmit01.js +++ b/tests/baselines/reference/superCallWithCommentEmit01.js @@ -11,11 +11,16 @@ class B extends A { } //// [superCallWithCommentEmit01.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(text) { this.text = text; diff --git a/tests/baselines/reference/superCallWithMissingBaseClass.js b/tests/baselines/reference/superCallWithMissingBaseClass.js index 16f11088640..71c408f6df8 100644 --- a/tests/baselines/reference/superCallWithMissingBaseClass.js +++ b/tests/baselines/reference/superCallWithMissingBaseClass.js @@ -10,15 +10,20 @@ class Foo extends Bar { } //// [superCallWithMissingBaseClass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function (_super) { __extends(Foo, _super); function Foo() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Foo.prototype.m1 = function () { return _super.prototype.m1.call(this); diff --git a/tests/baselines/reference/superCalls.js b/tests/baselines/reference/superCalls.js index 99a3b78752c..8c1e70e0c9d 100644 --- a/tests/baselines/reference/superCalls.js +++ b/tests/baselines/reference/superCalls.js @@ -31,11 +31,16 @@ class OtherDerived extends OtherBase { //// [superCalls.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(n) { this.x = 43; @@ -64,7 +69,7 @@ var OtherBase = (function () { var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - var _this; + var _this = this; var p = ''; _this = _super.call(this) || this; return _this; diff --git a/tests/baselines/reference/superCallsInConstructor.js b/tests/baselines/reference/superCallsInConstructor.js index 48b79acadf4..b5d653dc34f 100644 --- a/tests/baselines/reference/superCallsInConstructor.js +++ b/tests/baselines/reference/superCallsInConstructor.js @@ -21,11 +21,16 @@ class Derived extends Base { } //// [superCallsInConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -41,7 +46,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this; + var _this = this; with (new C()) { foo(); _this = _super.call(this) || this; diff --git a/tests/baselines/reference/superErrors.js b/tests/baselines/reference/superErrors.js index 19f0d74f677..cf7edc83a63 100644 --- a/tests/baselines/reference/superErrors.js +++ b/tests/baselines/reference/superErrors.js @@ -52,11 +52,16 @@ class RegisteredUser extends User { } //// [superErrors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function foo() { var _this = this; // super in a non class context diff --git a/tests/baselines/reference/superInCatchBlock1.js b/tests/baselines/reference/superInCatchBlock1.js index e1fc0f97024..1f7375fe360 100644 --- a/tests/baselines/reference/superInCatchBlock1.js +++ b/tests/baselines/reference/superInCatchBlock1.js @@ -14,11 +14,16 @@ class B extends A { //// [superInCatchBlock1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -28,7 +33,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.m = function () { try { diff --git a/tests/baselines/reference/superInConstructorParam1.js b/tests/baselines/reference/superInConstructorParam1.js index 8c99b649917..89f88c43c4a 100644 --- a/tests/baselines/reference/superInConstructorParam1.js +++ b/tests/baselines/reference/superInConstructorParam1.js @@ -11,11 +11,16 @@ class C extends B { } //// [superInConstructorParam1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { } @@ -27,8 +32,8 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C(a) { - if (a === void 0) { a = _super.foo.call(_this); } - var _this; + if (a === void 0) { a = _super.prototype.foo.call(_this); } + var _this = this; return _this; } return C; diff --git a/tests/baselines/reference/superInLambdas.js b/tests/baselines/reference/superInLambdas.js index 73ca53c3b5c..83dad0b3251 100644 --- a/tests/baselines/reference/superInLambdas.js +++ b/tests/baselines/reference/superInLambdas.js @@ -68,11 +68,16 @@ class RegisteredUser4 extends User { } //// [superInLambdas.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var User = (function () { function User() { this.name = "Bob"; diff --git a/tests/baselines/reference/superInObjectLiterals_ES5.js b/tests/baselines/reference/superInObjectLiterals_ES5.js index 816277e4e9e..81d8c09da0d 100644 --- a/tests/baselines/reference/superInObjectLiterals_ES5.js +++ b/tests/baselines/reference/superInObjectLiterals_ES5.js @@ -60,11 +60,16 @@ class B extends A { } //// [superInObjectLiterals_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _this = this; var obj = { __proto__: { @@ -72,14 +77,14 @@ var obj = { } }, method: function () { - _super.prototype.method.call(this); + _super.method.call(this); }, get prop() { - _super.prototype.method.call(this); + _super.method.call(this); return 10; }, set prop(value) { - _super.prototype.method.call(this); + _super.method.call(this); }, p1: function () { _super.method.call(this); @@ -100,7 +105,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.f = function () { var _this = this; @@ -110,14 +115,14 @@ var B = (function (_super) { } }, method: function () { - _super.prototype.method.call(this); + _super.method.call(this); }, get prop() { - _super.prototype.method.call(this); + _super.method.call(this); return 10; }, set prop(value) { - _super.prototype.method.call(this); + _super.method.call(this); }, p1: function () { _super.method.call(this); diff --git a/tests/baselines/reference/superNewCall1.js b/tests/baselines/reference/superNewCall1.js index 30b07308bb2..a7a94deb6dc 100644 --- a/tests/baselines/reference/superNewCall1.js +++ b/tests/baselines/reference/superNewCall1.js @@ -13,11 +13,16 @@ class B extends A { } //// [superNewCall1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(map) { this.map = map; @@ -27,7 +32,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - var _this; + var _this = this; new _super.prototype(function (value) { return String(value); }); return _this; } diff --git a/tests/baselines/reference/superPropertyAccess.js b/tests/baselines/reference/superPropertyAccess.js index 7b5823e598b..342e39b9885 100644 --- a/tests/baselines/reference/superPropertyAccess.js +++ b/tests/baselines/reference/superPropertyAccess.js @@ -37,11 +37,16 @@ class MyDerived extends MyBase { } //// [superPropertyAccess.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var MyBase = (function () { function MyBase() { this.m2 = function () { }; @@ -61,7 +66,7 @@ var MyBase = (function () { var MyDerived = (function (_super) { __extends(MyDerived, _super); function MyDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } MyDerived.prototype.foo = function () { _super.prototype.m1.call(this, "hi"); // Should be allowed, method on base prototype diff --git a/tests/baselines/reference/superPropertyAccess1.js b/tests/baselines/reference/superPropertyAccess1.js index 0b1e4fc280f..8779dd7069b 100644 --- a/tests/baselines/reference/superPropertyAccess1.js +++ b/tests/baselines/reference/superPropertyAccess1.js @@ -28,11 +28,16 @@ class D extends C { } //// [superPropertyAccess1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 7c72ad5d1bb..a6fb7c95b0c 100644 --- a/tests/baselines/reference/superPropertyAccess2.js +++ b/tests/baselines/reference/superPropertyAccess2.js @@ -28,11 +28,16 @@ class D extends C { } //// [superPropertyAccess2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } diff --git a/tests/baselines/reference/superPropertyAccessInComputedPropertiesOfNestedType_ES5.js b/tests/baselines/reference/superPropertyAccessInComputedPropertiesOfNestedType_ES5.js index 956bce4ef2e..cf256fa91ec 100644 --- a/tests/baselines/reference/superPropertyAccessInComputedPropertiesOfNestedType_ES5.js +++ b/tests/baselines/reference/superPropertyAccessInComputedPropertiesOfNestedType_ES5.js @@ -15,11 +15,16 @@ class B extends A { } //// [superPropertyAccessInComputedPropertiesOfNestedType_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -29,7 +34,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.foo = function () { return 2; }; B.prototype.bar = function () { diff --git a/tests/baselines/reference/superPropertyAccessInSuperCall01.js b/tests/baselines/reference/superPropertyAccessInSuperCall01.js index f0dc925682c..d5800323de2 100644 --- a/tests/baselines/reference/superPropertyAccessInSuperCall01.js +++ b/tests/baselines/reference/superPropertyAccessInSuperCall01.js @@ -12,11 +12,16 @@ class B extends A { } //// [superPropertyAccessInSuperCall01.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(f) { } @@ -26,7 +31,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - var _this = _super.call(this, _super.blah.call(_this)) || this; + var _this = _super.call(this, _super.prototype.blah.call(_this)) || this; return _this; } return B; diff --git a/tests/baselines/reference/superPropertyAccessNoError.js b/tests/baselines/reference/superPropertyAccessNoError.js index 88a5da8b8fb..d2e3d7aad41 100644 --- a/tests/baselines/reference/superPropertyAccessNoError.js +++ b/tests/baselines/reference/superPropertyAccessNoError.js @@ -77,11 +77,16 @@ instance.returnThis().fn(); //super.publicInstanceMemberFunction in lambda in member function //super.publicStaticMemberFunction in static member function of derived class //super.publicStaticMemberFunction in static member accessor(get and set) of derived 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var SomeBaseClass = (function () { function SomeBaseClass() { } diff --git a/tests/baselines/reference/superPropertyAccess_ES5.js b/tests/baselines/reference/superPropertyAccess_ES5.js index 45c32076be9..1b74519464a 100644 --- a/tests/baselines/reference/superPropertyAccess_ES5.js +++ b/tests/baselines/reference/superPropertyAccess_ES5.js @@ -30,11 +30,16 @@ class B extends A { } //// [superPropertyAccess_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var MyBase = (function () { function MyBase() { } @@ -72,7 +77,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(B.prototype, "property", { set: function (value) { diff --git a/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.js b/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.js index 3fcf7167ee5..eb698f1ae7e 100644 --- a/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.js +++ b/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.js @@ -16,11 +16,16 @@ class C2 extends B { } //// [superPropertyInConstructorBeforeSuperCall.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B(x) { } @@ -30,7 +35,7 @@ var B = (function () { var C1 = (function (_super) { __extends(C1, _super); function C1() { - var _this; + var _this = this; _super.prototype.x.call(_this); _this = _super.call(this) || this; return _this; @@ -40,7 +45,7 @@ var C1 = (function (_super) { var C2 = (function (_super) { __extends(C2, _super); function C2() { - var _this = _super.call(this, _super.x.call(_this)) || this; + var _this = _super.call(this, _super.prototype.x.call(_this)) || this; return _this; } return C2; diff --git a/tests/baselines/reference/superSymbolIndexedAccess5.js b/tests/baselines/reference/superSymbolIndexedAccess5.js index dd37deb5af3..5820c56504d 100644 --- a/tests/baselines/reference/superSymbolIndexedAccess5.js +++ b/tests/baselines/reference/superSymbolIndexedAccess5.js @@ -14,11 +14,16 @@ class Bar extends Foo { } //// [superSymbolIndexedAccess5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var symbol; var Foo = (function () { function Foo() { @@ -31,7 +36,7 @@ var Foo = (function () { var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Bar.prototype[symbol] = function () { return _super.prototype[symbol].call(this); diff --git a/tests/baselines/reference/superSymbolIndexedAccess6.js b/tests/baselines/reference/superSymbolIndexedAccess6.js index 8c8534b428a..45984298202 100644 --- a/tests/baselines/reference/superSymbolIndexedAccess6.js +++ b/tests/baselines/reference/superSymbolIndexedAccess6.js @@ -14,11 +14,16 @@ class Bar extends Foo { } //// [superSymbolIndexedAccess6.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var symbol; var Foo = (function () { function Foo() { @@ -31,7 +36,7 @@ var Foo = (function () { var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Bar[symbol] = function () { return _super[symbol].call(this); diff --git a/tests/baselines/reference/superWithGenericSpecialization.js b/tests/baselines/reference/superWithGenericSpecialization.js index a0381d0b944..6f3cee935ef 100644 --- a/tests/baselines/reference/superWithGenericSpecialization.js +++ b/tests/baselines/reference/superWithGenericSpecialization.js @@ -15,11 +15,16 @@ var r: string = d.x; var r2: number = d.y; //// [superWithGenericSpecialization.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } diff --git a/tests/baselines/reference/superWithGenerics.js b/tests/baselines/reference/superWithGenerics.js index 803f229bd4b..a66656832f4 100644 --- a/tests/baselines/reference/superWithGenerics.js +++ b/tests/baselines/reference/superWithGenerics.js @@ -12,11 +12,16 @@ class D extends B { //// [superWithGenerics.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var D = (function (_super) { __extends(D, _super); function D() { diff --git a/tests/baselines/reference/superWithTypeArgument.js b/tests/baselines/reference/superWithTypeArgument.js index a1c04975404..34cb3137ee8 100644 --- a/tests/baselines/reference/superWithTypeArgument.js +++ b/tests/baselines/reference/superWithTypeArgument.js @@ -10,11 +10,16 @@ class D extends C { } //// [superWithTypeArgument.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -23,7 +28,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this; + var _this = this; _super.prototype..call(_this); return _this; } diff --git a/tests/baselines/reference/superWithTypeArgument2.js b/tests/baselines/reference/superWithTypeArgument2.js index 42a0e46d4c0..e382f1923c9 100644 --- a/tests/baselines/reference/superWithTypeArgument2.js +++ b/tests/baselines/reference/superWithTypeArgument2.js @@ -10,11 +10,16 @@ class D extends C { } //// [superWithTypeArgument2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -23,7 +28,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D(x) { - var _this; + var _this = this; _super.prototype..call(_this, x); return _this; } diff --git a/tests/baselines/reference/superWithTypeArgument3.js b/tests/baselines/reference/superWithTypeArgument3.js index 803e5c264c2..d5c61d54fb6 100644 --- a/tests/baselines/reference/superWithTypeArgument3.js +++ b/tests/baselines/reference/superWithTypeArgument3.js @@ -14,11 +14,16 @@ class D extends C { } //// [superWithTypeArgument3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -28,7 +33,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this; + var _this = this; _super.prototype..call(_this); return _this; } 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 6815b71ce11..140f8258669 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 @@ -28,20 +28,25 @@ class SuperObjectTest extends F { //// [super_inside-object-literal-getters-and-setters.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ObjectLiteral; (function (ObjectLiteral) { var ThisInObjectLiteral = { _foo: '1', get foo() { - return _super.prototype._foo; + return _super._foo; }, set foo(value) { - _super.prototype._foo = value; + _super._foo = value; }, test: function () { return _super._foo; @@ -57,12 +62,12 @@ var F = (function () { var SuperObjectTest = (function (_super) { __extends(SuperObjectTest, _super); function SuperObjectTest() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SuperObjectTest.prototype.testing = function () { var test = { get F() { - return _super.prototype.test.call(this); + return _super.test.call(this); } }; }; diff --git a/tests/baselines/reference/switchStatements.js b/tests/baselines/reference/switchStatements.js index 2e1aecc7288..6bce62c108b 100644 --- a/tests/baselines/reference/switchStatements.js +++ b/tests/baselines/reference/switchStatements.js @@ -56,11 +56,16 @@ switch (((x: T) => '')(1)) { } //// [switchStatements.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { function fn(x) { @@ -98,7 +103,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/symbolProperty47.errors.txt b/tests/baselines/reference/symbolProperty47.errors.txt index 2e15085eb24..143d2405d0b 100644 --- a/tests/baselines/reference/symbolProperty47.errors.txt +++ b/tests/baselines/reference/symbolProperty47.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/Symbols/symbolProperty47.ts(3,16): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/conformance/es6/Symbols/symbolProperty47.ts(3,9): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/conformance/es6/Symbols/symbolProperty47.ts(11,1): error TS2322: Type '""' is not assignable to type 'number'. @@ -6,7 +6,7 @@ tests/cases/conformance/es6/Symbols/symbolProperty47.ts(11,1): error TS2322: Typ class C { get [Symbol.hasInstance]() { return ""; - ~~ + ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'number'. } // Should take a string diff --git a/tests/baselines/reference/symbolType3.errors.txt b/tests/baselines/reference/symbolType3.errors.txt index 7cc9e82b3b3..04a71789031 100644 --- a/tests/baselines/reference/symbolType3.errors.txt +++ b/tests/baselines/reference/symbolType3.errors.txt @@ -1,3 +1,4 @@ +tests/cases/conformance/es6/Symbols/symbolType3.ts(2,8): error TS2704: The operand of a delete operator cannot be a read-only property tests/cases/conformance/es6/Symbols/symbolType3.ts(5,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/es6/Symbols/symbolType3.ts(6,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/es6/Symbols/symbolType3.ts(7,3): error TS2469: The '+' operator cannot be applied to type 'symbol'. @@ -6,9 +7,11 @@ tests/cases/conformance/es6/Symbols/symbolType3.ts(9,3): error TS2469: The '~' o tests/cases/conformance/es6/Symbols/symbolType3.ts(12,2): error TS2469: The '+' operator cannot be applied to type 'symbol'. -==== tests/cases/conformance/es6/Symbols/symbolType3.ts (6 errors) ==== +==== tests/cases/conformance/es6/Symbols/symbolType3.ts (7 errors) ==== var s = Symbol(); delete Symbol.iterator; + ~~~~~~~~~~~~~~~ +!!! error TS2704: The operand of a delete operator cannot be a read-only property void Symbol.toPrimitive; typeof Symbol.toStringTag; ++s; diff --git a/tests/baselines/reference/systemModule11.js b/tests/baselines/reference/systemModule11.js index 41574af1d9a..212a24b5e20 100644 --- a/tests/baselines/reference/systemModule11.js +++ b/tests/baselines/reference/systemModule11.js @@ -55,8 +55,7 @@ System.register(["bar"], function (exports_1, context_1) { function exportStar_1(m) { var exports = {}; for (var n in m) { - if (n !== "default" && !exportedNames_1.hasOwnProperty(n)) - exports[n] = m[n]; + if (n !== "default" && !exportedNames_1.hasOwnProperty(n)) exports[n] = m[n]; } exports_1(exports); } @@ -83,8 +82,7 @@ System.register(["bar"], function (exports_1, context_1) { function exportStar_1(m) { var exports = {}; for (var n in m) { - if (n !== "default" && !exportedNames_1.hasOwnProperty(n)) - exports[n] = m[n]; + if (n !== "default" && !exportedNames_1.hasOwnProperty(n)) exports[n] = m[n]; } exports_1(exports); } @@ -111,8 +109,7 @@ System.register(["a", "bar"], function (exports_1, context_1) { function exportStar_1(m) { var exports = {}; for (var n in m) { - if (n !== "default" && !exportedNames_1.hasOwnProperty(n)) - exports[n] = m[n]; + if (n !== "default" && !exportedNames_1.hasOwnProperty(n)) exports[n] = m[n]; } exports_1(exports); } @@ -162,8 +159,7 @@ System.register(["a"], function (exports_1, context_1) { function exportStar_1(m) { var exports = {}; for (var n in m) { - if (n !== "default") - exports[n] = m[n]; + if (n !== "default") exports[n] = m[n]; } exports_1(exports); } diff --git a/tests/baselines/reference/systemModule16.js b/tests/baselines/reference/systemModule16.js index 8058e0f2ea1..86b6a448215 100644 --- a/tests/baselines/reference/systemModule16.js +++ b/tests/baselines/reference/systemModule16.js @@ -27,8 +27,7 @@ System.register(["foo", "bar"], function (exports_1, context_1) { function exportStar_1(m) { var exports = {}; for (var n in m) { - if (n !== "default" && !exportedNames_1.hasOwnProperty(n)) - exports[n] = m[n]; + if (n !== "default" && !exportedNames_1.hasOwnProperty(n)) exports[n] = m[n]; } exports_1(exports); } diff --git a/tests/baselines/reference/systemModule9.js b/tests/baselines/reference/systemModule9.js index 9e497140083..fce3aa1bdf4 100644 --- a/tests/baselines/reference/systemModule9.js +++ b/tests/baselines/reference/systemModule9.js @@ -33,8 +33,7 @@ System.register(["file1", "file2", "file3", "file4", "file5", "file6", "file7"], function exportStar_1(m) { var exports = {}; for (var n in m) { - if (n !== "default" && !exportedNames_1.hasOwnProperty(n)) - exports[n] = m[n]; + if (n !== "default" && !exportedNames_1.hasOwnProperty(n)) exports[n] = m[n]; } exports_1(exports); } diff --git a/tests/baselines/reference/systemModuleWithSuperClass.js b/tests/baselines/reference/systemModuleWithSuperClass.js index 78c09355fa0..8ac8770d8b1 100644 --- a/tests/baselines/reference/systemModuleWithSuperClass.js +++ b/tests/baselines/reference/systemModuleWithSuperClass.js @@ -32,11 +32,16 @@ System.register([], function (exports_1, context_1) { //// [bar.js] System.register(["./foo"], function (exports_1, context_1) { "use strict"; - var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); var __moduleName = context_1 && context_1.id; var foo_1, Bar; return { @@ -49,7 +54,7 @@ System.register(["./foo"], function (exports_1, context_1) { Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar; }(foo_1.Foo)); diff --git a/tests/baselines/reference/targetTypeBaseCalls.js b/tests/baselines/reference/targetTypeBaseCalls.js index cac93023a00..70e14fd521f 100644 --- a/tests/baselines/reference/targetTypeBaseCalls.js +++ b/tests/baselines/reference/targetTypeBaseCalls.js @@ -19,11 +19,16 @@ class Bar extends Foo { constructor() { super(function(s) { s = 5 }) } } // err //// [targetTypeBaseCalls.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function foo(x) { } var Foo = (function () { function Foo(x) { diff --git a/tests/baselines/reference/targetTypeVoidFunc.errors.txt b/tests/baselines/reference/targetTypeVoidFunc.errors.txt index d47f811c2ed..6c0efe288bd 100644 --- a/tests/baselines/reference/targetTypeVoidFunc.errors.txt +++ b/tests/baselines/reference/targetTypeVoidFunc.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/targetTypeVoidFunc.ts(2,12): error TS2322: Type '() => void' is not assignable to type 'new () => number'. +tests/cases/compiler/targetTypeVoidFunc.ts(2,5): error TS2322: Type '() => void' is not assignable to type 'new () => number'. Type '() => void' provides no match for the signature 'new (): number' ==== tests/cases/compiler/targetTypeVoidFunc.ts (1 errors) ==== function f1(): { new (): number; } { return function () { return; } - ~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '() => void' is not assignable to type 'new () => number'. !!! error TS2322: Type '() => void' provides no match for the signature 'new (): number' }; diff --git a/tests/baselines/reference/templateStringInDeleteExpression.errors.txt b/tests/baselines/reference/templateStringInDeleteExpression.errors.txt new file mode 100644 index 00000000000..6cc310969b6 --- /dev/null +++ b/tests/baselines/reference/templateStringInDeleteExpression.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/templates/templateStringInDeleteExpression.ts(1,8): error TS2703: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/es6/templates/templateStringInDeleteExpression.ts (1 errors) ==== + delete `abc${0}abc`; + ~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInDeleteExpressionES6.errors.txt b/tests/baselines/reference/templateStringInDeleteExpressionES6.errors.txt new file mode 100644 index 00000000000..a3b89c880c8 --- /dev/null +++ b/tests/baselines/reference/templateStringInDeleteExpressionES6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/templates/templateStringInDeleteExpressionES6.ts(1,8): error TS2703: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/es6/templates/templateStringInDeleteExpressionES6.ts (1 errors) ==== + delete `abc${0}abc`; + ~~~~~~~~~~~~ +!!! error TS2703: The operand of a delete operator must be a property reference \ No newline at end of file diff --git a/tests/baselines/reference/thisInInvalidContexts.js b/tests/baselines/reference/thisInInvalidContexts.js index 7f299fd7e10..25350fb78cf 100644 --- a/tests/baselines/reference/thisInInvalidContexts.js +++ b/tests/baselines/reference/thisInInvalidContexts.js @@ -49,11 +49,16 @@ enum SomeEnum { //// [thisInInvalidContexts.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); //'this' in static member initializer var ErrClass1 = (function () { function ErrClass1() { @@ -98,7 +103,7 @@ genericFunc(undefined); // Should be an error var ErrClass3 = (function (_super) { __extends(ErrClass3, _super); function ErrClass3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ErrClass3; }(this)); diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.js b/tests/baselines/reference/thisInInvalidContextsExternalModule.js index 65a1ef1eee9..070d5597fcc 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.js +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.js @@ -50,11 +50,16 @@ export = this; // Should be an error //// [thisInInvalidContextsExternalModule.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); //'this' in static member initializer var ErrClass1 = (function () { function ErrClass1() { @@ -99,7 +104,7 @@ genericFunc(undefined); // Should be an error var ErrClass3 = (function (_super) { __extends(ErrClass3, _super); function ErrClass3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ErrClass3; }(this)); diff --git a/tests/baselines/reference/thisInSuperCall.js b/tests/baselines/reference/thisInSuperCall.js index 1c1f11ffbc8..e28588b2142 100644 --- a/tests/baselines/reference/thisInSuperCall.js +++ b/tests/baselines/reference/thisInSuperCall.js @@ -23,11 +23,16 @@ class Foo3 extends Base { } //// [thisInSuperCall.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 e3eea1fb91d..c975c10927e 100644 --- a/tests/baselines/reference/thisInSuperCall1.js +++ b/tests/baselines/reference/thisInSuperCall1.js @@ -11,11 +11,16 @@ class Foo extends Base { //// [thisInSuperCall1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 6288082ed64..7112f7b21d1 100644 --- a/tests/baselines/reference/thisInSuperCall2.js +++ b/tests/baselines/reference/thisInSuperCall2.js @@ -20,11 +20,16 @@ class Foo2 extends Base { //// [thisInSuperCall2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 6a72f17248f..2e07d294843 100644 --- a/tests/baselines/reference/thisInSuperCall3.js +++ b/tests/baselines/reference/thisInSuperCall3.js @@ -13,11 +13,16 @@ class Foo extends Base { //// [thisInSuperCall3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(a) { } diff --git a/tests/baselines/reference/thisTypeInFunctions.js b/tests/baselines/reference/thisTypeInFunctions.js index 6400f410a09..68513c151d9 100644 --- a/tests/baselines/reference/thisTypeInFunctions.js +++ b/tests/baselines/reference/thisTypeInFunctions.js @@ -195,11 +195,16 @@ function missingTypeIsImplicitAny(this, a: number) { return this.anything + a; } //// [thisTypeInFunctions.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _this = this; // body checking var B = (function () { @@ -227,7 +232,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); @@ -336,7 +341,7 @@ var Base1 = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived1; }(Base1)); @@ -350,7 +355,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.js b/tests/baselines/reference/thisTypeInFunctionsNegative.js index 446bc15e6d9..6cf6f477827 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.js +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.js @@ -177,11 +177,16 @@ c.explicitProperty = (this, m) => m + this.n; //// [thisTypeInFunctionsNegative.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _this = this; var C = (function () { function C() { @@ -296,7 +301,7 @@ var Base1 = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived1; }(Base1)); @@ -310,7 +315,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/transpile/Rename dependencies - UMD.js b/tests/baselines/reference/transpile/Rename dependencies - UMD.js index 88bdc515936..c2b337076ba 100644 --- a/tests/baselines/reference/transpile/Rename dependencies - UMD.js +++ b/tests/baselines/reference/transpile/Rename dependencies - UMD.js @@ -1,11 +1,12 @@ -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports", "SomeOtherName"], factory); } -})(["require", "exports", "SomeOtherName"], function (require, exports) { +})(function (require, exports) { "use strict"; var SomeName_1 = require("SomeOtherName"); use(SomeName_1.foo); diff --git a/tests/baselines/reference/tsxCorrectlyParseLessThanComparison1.js b/tests/baselines/reference/tsxCorrectlyParseLessThanComparison1.js index f5d35ccaf77..8135af8731f 100644 --- a/tests/baselines/reference/tsxCorrectlyParseLessThanComparison1.js +++ b/tests/baselines/reference/tsxCorrectlyParseLessThanComparison1.js @@ -21,15 +21,20 @@ export class ShortDetails extends React.Component<{ id: number }, {}> { //// [tsxCorrectlyParseLessThanComparison1.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ShortDetails = (function (_super) { __extends(ShortDetails, _super); function ShortDetails() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } ShortDetails.prototype.render = function () { if (this.props.id < 1) { diff --git a/tests/baselines/reference/tsxDynamicTagName5.js b/tests/baselines/reference/tsxDynamicTagName5.js index d3bb404ceea..00ecc955865 100644 --- a/tests/baselines/reference/tsxDynamicTagName5.js +++ b/tests/baselines/reference/tsxDynamicTagName5.js @@ -21,16 +21,21 @@ export class Text extends React.Component<{}, {}> { //// [app.jsx] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var React = require("react"); var Text = (function (_super) { __extends(Text, _super); function Text() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this._tagName = 'div'; return _this; } diff --git a/tests/baselines/reference/tsxDynamicTagName7.js b/tests/baselines/reference/tsxDynamicTagName7.js index 84debfd3e71..2e7802ea94f 100644 --- a/tests/baselines/reference/tsxDynamicTagName7.js +++ b/tests/baselines/reference/tsxDynamicTagName7.js @@ -21,16 +21,21 @@ export class Text extends React.Component<{}, {}> { //// [app.jsx] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var React = require("react"); var Text = (function (_super) { __extends(Text, _super); function Text() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this._tagName = 'div'; return _this; } diff --git a/tests/baselines/reference/tsxDynamicTagName8.js b/tests/baselines/reference/tsxDynamicTagName8.js index 6166b99f4ac..3b2e43fede7 100644 --- a/tests/baselines/reference/tsxDynamicTagName8.js +++ b/tests/baselines/reference/tsxDynamicTagName8.js @@ -21,16 +21,21 @@ export class Text extends React.Component<{}, {}> { //// [app.jsx] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var React = require("react"); var Text = (function (_super) { __extends(Text, _super); function Text() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this._tagName = 'div'; return _this; } diff --git a/tests/baselines/reference/tsxDynamicTagName9.js b/tests/baselines/reference/tsxDynamicTagName9.js index 928649264c8..1b13845dc18 100644 --- a/tests/baselines/reference/tsxDynamicTagName9.js +++ b/tests/baselines/reference/tsxDynamicTagName9.js @@ -21,16 +21,21 @@ export class Text extends React.Component<{}, {}> { //// [app.jsx] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var React = require("react"); var Text = (function (_super) { __extends(Text, _super); function Text() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this._tagName = 'div'; return _this; } diff --git a/tests/baselines/reference/tsxExternalModuleEmit1.js b/tests/baselines/reference/tsxExternalModuleEmit1.js index 58e7f1c8d85..5b27360d14c 100644 --- a/tests/baselines/reference/tsxExternalModuleEmit1.js +++ b/tests/baselines/reference/tsxExternalModuleEmit1.js @@ -33,16 +33,21 @@ export class Button extends React.Component { //// [button.jsx] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + 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() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Button.prototype.render = function () { return ; @@ -52,18 +57,23 @@ var Button = (function (_super) { exports.Button = Button; //// [app.jsx] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + 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() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } App.prototype.render = function () { return ; diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.js b/tests/baselines/reference/tsxReactEmitWhitespace.js index dd69091569f..54839412567 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.js +++ b/tests/baselines/reference/tsxReactEmitWhitespace.js @@ -41,7 +41,7 @@ var p = 0;
; -// Emit "foo" + ' ' + "bar" +// Emit "foo bar"
foo @@ -50,6 +50,18 @@ var p = 0;
; +// Emit "hello\\ world" +
+ + hello\ + +world +
; + +// Emit " a b c d " +
a + b c + d
; //// [file.js] @@ -75,5 +87,9 @@ React.createElement("div", null, " 3 "); React.createElement("div", null, "3"); // Emit no args React.createElement("div", null); -// Emit "foo" + ' ' + "bar" -React.createElement("div", null, "foo" + " " + "bar"); +// Emit "foo bar" +React.createElement("div", null, "foo bar"); +// Emit "hello\\ world" +React.createElement("div", null, "hello\\ world"); +// Emit " a b c d " +React.createElement("div", null, " a b c d "); diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.symbols b/tests/baselines/reference/tsxReactEmitWhitespace.symbols index a0d8266faa0..baac01227b6 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.symbols +++ b/tests/baselines/reference/tsxReactEmitWhitespace.symbols @@ -79,7 +79,7 @@ var p = 0; ; >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) -// Emit "foo" + ' ' + "bar" +// Emit "foo bar"
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) @@ -90,4 +90,21 @@ var p = 0;
; >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) +// Emit "hello\\ world" +
+>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) + + hello\ + +world +
; +>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) + +// Emit " a b c d " +
a +>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) + + b c + d
; +>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.types b/tests/baselines/reference/tsxReactEmitWhitespace.types index f5ae431d342..0527c02904f 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.types +++ b/tests/baselines/reference/tsxReactEmitWhitespace.types @@ -88,7 +88,7 @@ var p = 0; ; >div : any -// Emit "foo" + ' ' + "bar" +// Emit "foo bar"
>
foo bar
: JSX.Element >div : any @@ -100,4 +100,23 @@ var p = 0;
; >div : any +// Emit "hello\\ world" +
+>
hello\world
: JSX.Element +>div : any + + hello\ + +world +
; +>div : any + +// Emit " a b c d " +
a +>
a b c d
: JSX.Element +>div : any + + b c + d
; +>div : any diff --git a/tests/baselines/reference/tsxSpreadChildren.js b/tests/baselines/reference/tsxSpreadChildren.js new file mode 100644 index 00000000000..bcc62de0566 --- /dev/null +++ b/tests/baselines/reference/tsxSpreadChildren.js @@ -0,0 +1,41 @@ +//// [tsxSpreadChildren.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +interface TodoProp { + id: number; + todo: string; +} +interface TodoListProps { + todos: TodoProp[]; +} +function Todo(prop: { key: number, todo: string }) { + return
{prop.key.toString() + prop.todo}
; +} +function TodoList({ todos }: TodoListProps) { + return
+ {...todos.map(todo => )} +
; +} +let x: TodoListProps; + + + +//// [tsxSpreadChildren.jsx] +function Todo(prop) { + return
{prop.key.toString() + prop.todo}
; +} +function TodoList(_a) { + var todos = _a.todos; + return
+ {...todos.map(function (todo) { return ; })} +
; +} +var x; +; diff --git a/tests/baselines/reference/tsxSpreadChildren.symbols b/tests/baselines/reference/tsxSpreadChildren.symbols new file mode 100644 index 00000000000..6e726e93217 --- /dev/null +++ b/tests/baselines/reference/tsxSpreadChildren.symbols @@ -0,0 +1,86 @@ +=== tests/cases/conformance/jsx/tsxSpreadChildren.tsx === + +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxSpreadChildren.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxSpreadChildren.tsx, 1, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxSpreadChildren.tsx, 2, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxSpreadChildren.tsx, 4, 3)) + } +} +declare var React: any; +>React : Symbol(React, Decl(tsxSpreadChildren.tsx, 7, 11)) + +interface TodoProp { +>TodoProp : Symbol(TodoProp, Decl(tsxSpreadChildren.tsx, 7, 23)) + + id: number; +>id : Symbol(TodoProp.id, Decl(tsxSpreadChildren.tsx, 9, 20)) + + todo: string; +>todo : Symbol(TodoProp.todo, Decl(tsxSpreadChildren.tsx, 10, 15)) +} +interface TodoListProps { +>TodoListProps : Symbol(TodoListProps, Decl(tsxSpreadChildren.tsx, 12, 1)) + + todos: TodoProp[]; +>todos : Symbol(TodoListProps.todos, Decl(tsxSpreadChildren.tsx, 13, 25)) +>TodoProp : Symbol(TodoProp, Decl(tsxSpreadChildren.tsx, 7, 23)) +} +function Todo(prop: { key: number, todo: string }) { +>Todo : Symbol(Todo, Decl(tsxSpreadChildren.tsx, 15, 1)) +>prop : Symbol(prop, Decl(tsxSpreadChildren.tsx, 16, 14)) +>key : Symbol(key, Decl(tsxSpreadChildren.tsx, 16, 21)) +>todo : Symbol(todo, Decl(tsxSpreadChildren.tsx, 16, 34)) + + return
{prop.key.toString() + prop.todo}
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxSpreadChildren.tsx, 2, 22)) +>prop.key.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>prop.key : Symbol(key, Decl(tsxSpreadChildren.tsx, 16, 21)) +>prop : Symbol(prop, Decl(tsxSpreadChildren.tsx, 16, 14)) +>key : Symbol(key, Decl(tsxSpreadChildren.tsx, 16, 21)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>prop.todo : Symbol(todo, Decl(tsxSpreadChildren.tsx, 16, 34)) +>prop : Symbol(prop, Decl(tsxSpreadChildren.tsx, 16, 14)) +>todo : Symbol(todo, Decl(tsxSpreadChildren.tsx, 16, 34)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxSpreadChildren.tsx, 2, 22)) +} +function TodoList({ todos }: TodoListProps) { +>TodoList : Symbol(TodoList, Decl(tsxSpreadChildren.tsx, 18, 1)) +>todos : Symbol(todos, Decl(tsxSpreadChildren.tsx, 19, 19)) +>TodoListProps : Symbol(TodoListProps, Decl(tsxSpreadChildren.tsx, 12, 1)) + + return
+>div : Symbol(JSX.IntrinsicElements, Decl(tsxSpreadChildren.tsx, 2, 22)) + + {...todos.map(todo => )} +>todos.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>todos : Symbol(todos, Decl(tsxSpreadChildren.tsx, 19, 19)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>todo : Symbol(todo, Decl(tsxSpreadChildren.tsx, 21, 22)) +>Todo : Symbol(Todo, Decl(tsxSpreadChildren.tsx, 15, 1)) +>key : Symbol(key, Decl(tsxSpreadChildren.tsx, 16, 21)) +>todo.id : Symbol(TodoProp.id, Decl(tsxSpreadChildren.tsx, 9, 20)) +>todo : Symbol(todo, Decl(tsxSpreadChildren.tsx, 21, 22)) +>id : Symbol(TodoProp.id, Decl(tsxSpreadChildren.tsx, 9, 20)) +>todo : Symbol(todo, Decl(tsxSpreadChildren.tsx, 16, 34)) +>todo.todo : Symbol(TodoProp.todo, Decl(tsxSpreadChildren.tsx, 10, 15)) +>todo : Symbol(todo, Decl(tsxSpreadChildren.tsx, 21, 22)) +>todo : Symbol(TodoProp.todo, Decl(tsxSpreadChildren.tsx, 10, 15)) + +
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxSpreadChildren.tsx, 2, 22)) +} +let x: TodoListProps; +>x : Symbol(x, Decl(tsxSpreadChildren.tsx, 24, 3)) +>TodoListProps : Symbol(TodoListProps, Decl(tsxSpreadChildren.tsx, 12, 1)) + + +>TodoList : Symbol(TodoList, Decl(tsxSpreadChildren.tsx, 18, 1)) +>x : Symbol(x, Decl(tsxSpreadChildren.tsx, 24, 3)) + diff --git a/tests/baselines/reference/tsxSpreadChildren.types b/tests/baselines/reference/tsxSpreadChildren.types new file mode 100644 index 00000000000..fbf76d0679d --- /dev/null +++ b/tests/baselines/reference/tsxSpreadChildren.types @@ -0,0 +1,94 @@ +=== tests/cases/conformance/jsx/tsxSpreadChildren.tsx === + +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} +declare var React: any; +>React : any + +interface TodoProp { +>TodoProp : TodoProp + + id: number; +>id : number + + todo: string; +>todo : string +} +interface TodoListProps { +>TodoListProps : TodoListProps + + todos: TodoProp[]; +>todos : TodoProp[] +>TodoProp : TodoProp +} +function Todo(prop: { key: number, todo: string }) { +>Todo : (prop: { key: number; todo: string; }) => JSX.Element +>prop : { key: number; todo: string; } +>key : number +>todo : string + + return
{prop.key.toString() + prop.todo}
; +>
{prop.key.toString() + prop.todo}
: JSX.Element +>div : any +>prop.key.toString() + prop.todo : string +>prop.key.toString() : string +>prop.key.toString : (radix?: number) => string +>prop.key : number +>prop : { key: number; todo: string; } +>key : number +>toString : (radix?: number) => string +>prop.todo : string +>prop : { key: number; todo: string; } +>todo : string +>div : any +} +function TodoList({ todos }: TodoListProps) { +>TodoList : ({todos}: TodoListProps) => JSX.Element +>todos : TodoProp[] +>TodoListProps : TodoListProps + + return
+>
{...todos.map(todo => )}
: JSX.Element +>div : any + + {...todos.map(todo => )} +>todos.map(todo => ) : JSX.Element[] +>todos.map : { (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U]; (this: [TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): U[]; } +>todos : TodoProp[] +>map : { (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U]; (this: [TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): U[]; } +>todo => : (todo: TodoProp) => JSX.Element +>todo : TodoProp +> : JSX.Element +>Todo : (prop: { key: number; todo: string; }) => JSX.Element +>key : any +>todo.id : number +>todo : TodoProp +>id : number +>todo : any +>todo.todo : string +>todo : TodoProp +>todo : string + +
; +>div : any +} +let x: TodoListProps; +>x : TodoListProps +>TodoListProps : TodoListProps + + +> : JSX.Element +>TodoList : ({todos}: TodoListProps) => JSX.Element +>x : TodoListProps + diff --git a/tests/baselines/reference/tsxSpreadChildrenInvalidType.errors.txt b/tests/baselines/reference/tsxSpreadChildrenInvalidType.errors.txt new file mode 100644 index 00000000000..d1524c6bf3a --- /dev/null +++ b/tests/baselines/reference/tsxSpreadChildrenInvalidType.errors.txt @@ -0,0 +1,38 @@ +tests/cases/conformance/jsx/tsxSpreadChildrenInvalidType.tsx(21,9): error TS2609: JSX spread child must be an array type. + + +==== tests/cases/conformance/jsx/tsxSpreadChildrenInvalidType.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } + } + declare var React: any; + + interface TodoProp { + id: number; + todo: string; + } + interface TodoListProps { + todos: TodoProp[]; + } + function Todo(prop: { key: number, todo: string }) { + return
{prop.key.toString() + prop.todo}
; + } + function TodoList({ todos }: TodoListProps) { + return
+ {...} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2609: JSX spread child must be an array type. +
; + } + function TodoListNoError({ todos }: TodoListProps) { + // any is not checked + return
+ {...( as any)} +
; + } + let x: TodoListProps; + + \ No newline at end of file diff --git a/tests/baselines/reference/tsxSpreadChildrenInvalidType.js b/tests/baselines/reference/tsxSpreadChildrenInvalidType.js new file mode 100644 index 00000000000..e9873bfb233 --- /dev/null +++ b/tests/baselines/reference/tsxSpreadChildrenInvalidType.js @@ -0,0 +1,57 @@ +//// [tsxSpreadChildrenInvalidType.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +interface TodoProp { + id: number; + todo: string; +} +interface TodoListProps { + todos: TodoProp[]; +} +function Todo(prop: { key: number, todo: string }) { + return
{prop.key.toString() + prop.todo}
; +} +function TodoList({ todos }: TodoListProps) { + return
+ {...} +
; +} +function TodoListNoError({ todos }: TodoListProps) { + // any is not checked + return
+ {...( as any)} +
; +} +let x: TodoListProps; + + + +//// [tsxSpreadChildrenInvalidType.js] +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; +function Todo(prop) { + return React.createElement("div", null, prop.key.toString() + prop.todo); +} +function TodoList(_a) { + var todos = _a.todos; + return React.createElement("div", null, React.createElement(Todo, { key: todos[0].id, todo: todos[0].todo })); +} +function TodoListNoError(_a) { + var todos = _a.todos; + // any is not checked + return React.createElement("div", null, React.createElement(Todo, { key: todos[0].id, todo: todos[0].todo })); +} +var x; +React.createElement(TodoList, __assign({}, x)); diff --git a/tests/baselines/reference/tsxStatelessFunctionComponents2.js b/tests/baselines/reference/tsxStatelessFunctionComponents2.js index 88d91723501..a7507a15d8b 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponents2.js +++ b/tests/baselines/reference/tsxStatelessFunctionComponents2.js @@ -40,11 +40,16 @@ let i =
x.propertyNotOnHtmlDivElement} />; //// [file.jsx] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var React = require("react"); function Greet(x) { return
Hello, {x}
; @@ -52,7 +57,7 @@ function Greet(x) { var BigGreeter = (function (_super) { __extends(BigGreeter, _super); function BigGreeter() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } BigGreeter.prototype.render = function () { return
; diff --git a/tests/baselines/reference/tsxUnionTypeComponent1.js b/tests/baselines/reference/tsxUnionTypeComponent1.js index 3520b5af372..b73b1f35361 100644 --- a/tests/baselines/reference/tsxUnionTypeComponent1.js +++ b/tests/baselines/reference/tsxUnionTypeComponent1.js @@ -26,16 +26,21 @@ class MyButtonComponent extends React.Component<{},{}> { //// [file.js] "use strict"; -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var React = require("react"); var MyComponent = (function (_super) { __extends(MyComponent, _super); function MyComponent() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } MyComponent.prototype.render = function () { var AnyComponent = this.props.AnyComponent; @@ -49,7 +54,7 @@ React.createElement(MyComponent, { AnyComponent: function () { return React.crea var MyButtonComponent = (function (_super) { __extends(MyButtonComponent, _super); function MyButtonComponent() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return MyButtonComponent; }(React.Component)); diff --git a/tests/baselines/reference/typeAssertions.js b/tests/baselines/reference/typeAssertions.js index a57fb222a77..694fc617c5b 100644 --- a/tests/baselines/reference/typeAssertions.js +++ b/tests/baselines/reference/typeAssertions.js @@ -52,11 +52,16 @@ if((numOrStr === undefined) as numOrStr is string) { // Error //// [typeAssertions.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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) { } function fn2(t) { } @@ -74,7 +79,7 @@ var SomeBase = (function () { var SomeDerived = (function (_super) { __extends(SomeDerived, _super); function SomeDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived; }(SomeBase)); diff --git a/tests/baselines/reference/typeGuardFunction.js b/tests/baselines/reference/typeGuardFunction.js index b88d1038969..682143ee132 100644 --- a/tests/baselines/reference/typeGuardFunction.js +++ b/tests/baselines/reference/typeGuardFunction.js @@ -84,11 +84,16 @@ let union2: C | B; let union3: boolean | B = isA(union2) || union2; //// [typeGuardFunction.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -102,7 +107,7 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt index 88f71cda196..e9dfbf5bf27 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt +++ b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(2,7): error TS2300: Duplicate identifier 'A'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(15,12): error TS2322: Type '""' is not assignable to type 'boolean'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(15,5): error TS2322: Type '""' is not assignable to type 'boolean'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,55): error TS2304: Cannot find name 'x'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,57): error TS1144: '{' or ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,57): error TS2304: Cannot find name 'is'. @@ -47,11 +47,11 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,22) tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,25): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,27): error TS1005: ';' expected. 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 TS2322: Type 'true' is not assignable to type 'D'. -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(105,9): error TS2322: Type 'true' is not assignable to type 'D'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,9): 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(111,9): 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 TS2304: Cannot find name 'p1'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,25): error TS1005: ';' expected. @@ -82,7 +82,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 function hasANonBooleanReturnStatement(x): x is A { return ''; - ~~ + ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'boolean'. } @@ -258,9 +258,9 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 ~~~~~~~ !!! error TS1228: A type predicate is only allowed in return type position for functions and methods. return true; - ~~~~ + ~~~~~~~~~~~~ !!! error TS2322: Type 'true' is not assignable to type 'D'. - ~~~~ + ~~~~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } get m1(p1: A): p1 is C { @@ -272,7 +272,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 ~~~~~~~ !!! error TS1228: A type predicate is only allowed in return type position for functions and methods. return true; - ~~~~ + ~~~~~~~~~~~~ !!! error TS2408: Setters cannot return a value. } } diff --git a/tests/baselines/reference/typeGuardFunctionErrors.js b/tests/baselines/reference/typeGuardFunctionErrors.js index 99c25faaa88..c5f01189e7a 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.js +++ b/tests/baselines/reference/typeGuardFunctionErrors.js @@ -146,11 +146,16 @@ if (hasMissingParameter()) { } //// [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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -164,7 +169,7 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/typeGuardFunctionGenerics.js b/tests/baselines/reference/typeGuardFunctionGenerics.js index 703c809274f..af444cfc20a 100644 --- a/tests/baselines/reference/typeGuardFunctionGenerics.js +++ b/tests/baselines/reference/typeGuardFunctionGenerics.js @@ -34,11 +34,16 @@ if (funD(isC, a)) { let test3: B = funE(isB, 1); //// [typeGuardFunctionGenerics.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -52,7 +57,7 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/typeGuardFunctionOfFormThis.js b/tests/baselines/reference/typeGuardFunctionOfFormThis.js index c052ea7d72b..7ebee44cc30 100644 --- a/tests/baselines/reference/typeGuardFunctionOfFormThis.js +++ b/tests/baselines/reference/typeGuardFunctionOfFormThis.js @@ -142,11 +142,16 @@ interface MimicGuardInterface { //// [typeGuardFunctionOfFormThis.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var RoyalGuard = (function () { function RoyalGuard() { } @@ -161,7 +166,7 @@ var RoyalGuard = (function () { var LeadGuard = (function (_super) { __extends(LeadGuard, _super); function LeadGuard() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } LeadGuard.prototype.lead = function () { }; ; @@ -170,7 +175,7 @@ var LeadGuard = (function (_super) { var FollowerGuard = (function (_super) { __extends(FollowerGuard, _super); function FollowerGuard() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } FollowerGuard.prototype.follow = function () { }; ; @@ -224,7 +229,7 @@ var ArrowGuard = (function () { var ArrowElite = (function (_super) { __extends(ArrowElite, _super); function ArrowElite() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } ArrowElite.prototype.defend = function () { }; return ArrowElite; @@ -232,7 +237,7 @@ var ArrowElite = (function (_super) { var ArrowMedic = (function (_super) { __extends(ArrowMedic, _super); function ArrowMedic() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } ArrowMedic.prototype.heal = function () { }; return ArrowMedic; @@ -266,7 +271,7 @@ var MimicGuard = (function () { var MimicLeader = (function (_super) { __extends(MimicLeader, _super); function MimicLeader() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } MimicLeader.prototype.lead = function () { }; return MimicLeader; @@ -274,7 +279,7 @@ var MimicLeader = (function (_super) { var MimicFollower = (function (_super) { __extends(MimicFollower, _super); function MimicFollower() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } MimicFollower.prototype.follow = function () { }; return MimicFollower; diff --git a/tests/baselines/reference/typeGuardFunctionOfFormThisErrors.js b/tests/baselines/reference/typeGuardFunctionOfFormThisErrors.js index a85a207a665..e25c9a2dc9d 100644 --- a/tests/baselines/reference/typeGuardFunctionOfFormThisErrors.js +++ b/tests/baselines/reference/typeGuardFunctionOfFormThisErrors.js @@ -60,11 +60,16 @@ else { } //// [typeGuardFunctionOfFormThisErrors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var RoyalGuard = (function () { function RoyalGuard() { } @@ -79,7 +84,7 @@ var RoyalGuard = (function () { var LeadGuard = (function (_super) { __extends(LeadGuard, _super); function LeadGuard() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } LeadGuard.prototype.lead = function () { }; ; @@ -88,7 +93,7 @@ var LeadGuard = (function (_super) { var FollowerGuard = (function (_super) { __extends(FollowerGuard, _super); function FollowerGuard() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } FollowerGuard.prototype.follow = function () { }; ; diff --git a/tests/baselines/reference/typeGuardOfFormInstanceOf.js b/tests/baselines/reference/typeGuardOfFormInstanceOf.js index a181a446a81..1c11ce87d66 100644 --- a/tests/baselines/reference/typeGuardOfFormInstanceOf.js +++ b/tests/baselines/reference/typeGuardOfFormInstanceOf.js @@ -73,11 +73,16 @@ else { // - when true, narrows the type of x to the type of the 'prototype' property in C provided // it is a subtype of the type of x, or // - when false, has no effect on the type of 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1() { } @@ -91,7 +96,7 @@ var C2 = (function () { var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(C1)); diff --git a/tests/baselines/reference/typeGuardOfFormIsType.js b/tests/baselines/reference/typeGuardOfFormIsType.js index 14e9259a9e7..c1f3946face 100644 --- a/tests/baselines/reference/typeGuardOfFormIsType.js +++ b/tests/baselines/reference/typeGuardOfFormIsType.js @@ -38,11 +38,16 @@ str = isD1(c2Ord1) && c2Ord1.p1; // D1 var r2: C2 | D1 = isC1(c2Ord1) && c2Ord1; // C2 | D1 //// [typeGuardOfFormIsType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1() { } @@ -56,7 +61,7 @@ var C2 = (function () { var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(C1)); diff --git a/tests/baselines/reference/typeGuardOfFormThisMember.js b/tests/baselines/reference/typeGuardOfFormThisMember.js index 52097af34f7..ef9e51d7a77 100644 --- a/tests/baselines/reference/typeGuardOfFormThisMember.js +++ b/tests/baselines/reference/typeGuardOfFormThisMember.js @@ -83,11 +83,16 @@ namespace Test { //// [typeGuardOfFormThisMember.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // There's a 'File' class in the stdlib, wrap with a namespace to avoid collision var Test; (function (Test) { @@ -128,7 +133,7 @@ var Test; var Directory = (function (_super) { __extends(Directory, _super); function Directory() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Directory; }(FileSystemObject)); diff --git a/tests/baselines/reference/typeGuardOfFormThisMemberErrors.js b/tests/baselines/reference/typeGuardOfFormThisMemberErrors.js index c65445a3a5a..5dc77a29ec2 100644 --- a/tests/baselines/reference/typeGuardOfFormThisMemberErrors.js +++ b/tests/baselines/reference/typeGuardOfFormThisMemberErrors.js @@ -33,11 +33,16 @@ namespace Test { } //// [typeGuardOfFormThisMemberErrors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // There's a 'File' class in the stdlib, wrap with a namespace to avoid collision var Test; (function (Test) { @@ -78,7 +83,7 @@ var Test; var Directory = (function (_super) { __extends(Directory, _super); function Directory() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Directory; }(FileSystemObject)); diff --git a/tests/baselines/reference/typeMatch2.js b/tests/baselines/reference/typeMatch2.js index 2cae93924bc..8d42126fb1f 100644 --- a/tests/baselines/reference/typeMatch2.js +++ b/tests/baselines/reference/typeMatch2.js @@ -45,11 +45,16 @@ function f4() { //// [typeMatch2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function f1() { var a = { x: 1, y: 2 }; a = {}; // error @@ -65,7 +70,7 @@ var Animal = (function () { var Giraffe = (function (_super) { __extends(Giraffe, _super); function Giraffe() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Giraffe; }(Animal)); diff --git a/tests/baselines/reference/typeOfSuperCall.js b/tests/baselines/reference/typeOfSuperCall.js index 179e981b8d1..c1598be5c32 100644 --- a/tests/baselines/reference/typeOfSuperCall.js +++ b/tests/baselines/reference/typeOfSuperCall.js @@ -9,11 +9,16 @@ class D extends C { } //// [typeOfSuperCall.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -22,7 +27,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this; + var _this = this; var x = _this = _super.call(this) || this; return _this; } diff --git a/tests/baselines/reference/typeParameterAsBaseClass.js b/tests/baselines/reference/typeParameterAsBaseClass.js index 15d1c3b396e..ad48f6f37bc 100644 --- a/tests/baselines/reference/typeParameterAsBaseClass.js +++ b/tests/baselines/reference/typeParameterAsBaseClass.js @@ -3,15 +3,20 @@ class C extends T {} class C2 implements T {} //// [typeParameterAsBaseClass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(T)); diff --git a/tests/baselines/reference/typeParameterAsBaseType.js b/tests/baselines/reference/typeParameterAsBaseType.js index 2d0962f01d7..68eea323f0b 100644 --- a/tests/baselines/reference/typeParameterAsBaseType.js +++ b/tests/baselines/reference/typeParameterAsBaseType.js @@ -13,22 +13,27 @@ interface I2 extends U { } //// [typeParameterAsBaseType.js] // type parameters cannot be used as base types // these are all 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(T)); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(U)); diff --git a/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt b/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt index d3bc25c00b1..9665ef017c0 100644 --- a/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt +++ b/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt @@ -1,10 +1,10 @@ tests/cases/compiler/typeParameterAssignmentCompat1.ts(8,5): error TS2322: Type 'Foo' is not assignable to type 'Foo'. Type 'U' is not assignable to type 'T'. -tests/cases/compiler/typeParameterAssignmentCompat1.ts(9,12): error TS2322: Type 'Foo' is not assignable to type 'Foo'. +tests/cases/compiler/typeParameterAssignmentCompat1.ts(9,5): error TS2322: Type 'Foo' is not assignable to type 'Foo'. Type 'T' is not assignable to type 'U'. tests/cases/compiler/typeParameterAssignmentCompat1.ts(16,9): error TS2322: Type 'Foo' is not assignable to type 'Foo'. Type 'U' is not assignable to type 'T'. -tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,16): error TS2322: Type 'Foo' is not assignable to type 'Foo'. +tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,9): error TS2322: Type 'Foo' is not assignable to type 'Foo'. Type 'T' is not assignable to type 'U'. @@ -21,7 +21,7 @@ tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,16): error TS2322: Typ !!! error TS2322: Type 'Foo' is not assignable to type 'Foo'. !!! error TS2322: Type 'U' is not assignable to type 'T'. return x; - ~ + ~~~~~~~~~ !!! error TS2322: Type 'Foo' is not assignable to type 'Foo'. !!! error TS2322: Type 'T' is not assignable to type 'U'. } @@ -35,7 +35,7 @@ tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,16): error TS2322: Typ !!! error TS2322: Type 'Foo' is not assignable to type 'Foo'. !!! error TS2322: Type 'U' is not assignable to type 'T'. return x; - ~ + ~~~~~~~~~ !!! error TS2322: Type 'Foo' is not assignable to type 'Foo'. !!! error TS2322: Type 'T' is not assignable to type 'U'. } diff --git a/tests/baselines/reference/typeParameterExtendingUnion1.js b/tests/baselines/reference/typeParameterExtendingUnion1.js index 2738aa20528..b582877f35c 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion1.js +++ b/tests/baselines/reference/typeParameterExtendingUnion1.js @@ -13,11 +13,16 @@ function f(a: T) { } //// [typeParameterExtendingUnion1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Animal = (function () { function Animal() { } @@ -27,14 +32,14 @@ var Animal = (function () { var Cat = (function (_super) { __extends(Cat, _super); function Cat() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Cat; }(Animal)); var Dog = (function (_super) { __extends(Dog, _super); function Dog() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Dog; }(Animal)); diff --git a/tests/baselines/reference/typeParameterExtendingUnion2.js b/tests/baselines/reference/typeParameterExtendingUnion2.js index b3754436f26..b96298c574f 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion2.js +++ b/tests/baselines/reference/typeParameterExtendingUnion2.js @@ -13,11 +13,16 @@ function f(a: T) { } //// [typeParameterExtendingUnion2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Animal = (function () { function Animal() { } @@ -27,14 +32,14 @@ var Animal = (function () { var Cat = (function (_super) { __extends(Cat, _super); function Cat() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Cat; }(Animal)); var Dog = (function (_super) { __extends(Dog, _super); function Dog() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Dog; }(Animal)); diff --git a/tests/baselines/reference/typeParameterHasSelfAsConstraint.errors.txt b/tests/baselines/reference/typeParameterHasSelfAsConstraint.errors.txt index b459534080f..01cfff63e5f 100644 --- a/tests/baselines/reference/typeParameterHasSelfAsConstraint.errors.txt +++ b/tests/baselines/reference/typeParameterHasSelfAsConstraint.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/typeParameterHasSelfAsConstraint.ts(1,24): error TS2313: Type parameter 'T' has a circular constraint. -tests/cases/compiler/typeParameterHasSelfAsConstraint.ts(2,12): error TS2322: Type 'T' is not assignable to type 'number'. +tests/cases/compiler/typeParameterHasSelfAsConstraint.ts(2,5): error TS2322: Type 'T' is not assignable to type 'number'. ==== tests/cases/compiler/typeParameterHasSelfAsConstraint.ts (2 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/typeParameterHasSelfAsConstraint.ts(2,12): error TS2322: Ty ~ !!! error TS2313: Type parameter 'T' has a circular constraint. return x; - ~ + ~~~~~~~~~ !!! error TS2322: Type 'T' is not assignable to type 'number'. } diff --git a/tests/baselines/reference/typeParameterIndirectlyConstrainedToItself.errors.txt b/tests/baselines/reference/typeParameterIndirectlyConstrainedToItself.errors.txt index 4cfa9da2133..ac7b58bb846 100644 --- a/tests/baselines/reference/typeParameterIndirectlyConstrainedToItself.errors.txt +++ b/tests/baselines/reference/typeParameterIndirectlyConstrainedToItself.errors.txt @@ -23,11 +23,12 @@ tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterInd tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(16,21): error TS2313: Type parameter 'T' has a circular constraint. tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(16,34): error TS2313: Type parameter 'U' has a circular constraint. tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(16,47): error TS2313: Type parameter 'V' has a circular constraint. +tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(18,19): error TS2313: Type parameter 'U' has a circular constraint. tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(18,32): error TS2313: Type parameter 'T' has a circular constraint. tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(18,45): error TS2313: Type parameter 'V' has a circular constraint. -==== tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts (27 errors) ==== +==== tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts (28 errors) ==== class C { } ~ !!! error TS2313: Type parameter 'U' has a circular constraint. @@ -96,6 +97,8 @@ tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterInd !!! error TS2313: Type parameter 'V' has a circular constraint. class D { } + ~ +!!! error TS2313: Type parameter 'U' has a circular constraint. ~ !!! error TS2313: Type parameter 'T' has a circular constraint. ~ diff --git a/tests/baselines/reference/typeParameterWithInvalidConstraintType.errors.txt b/tests/baselines/reference/typeParameterWithInvalidConstraintType.errors.txt index 79af423f917..e9dfb5ba3cd 100644 --- a/tests/baselines/reference/typeParameterWithInvalidConstraintType.errors.txt +++ b/tests/baselines/reference/typeParameterWithInvalidConstraintType.errors.txt @@ -1,16 +1,24 @@ tests/cases/compiler/typeParameterWithInvalidConstraintType.ts(1,19): error TS2313: Type parameter 'T' has a circular constraint. +tests/cases/compiler/typeParameterWithInvalidConstraintType.ts(4,19): error TS2339: Property 'foo' does not exist on type 'T'. +tests/cases/compiler/typeParameterWithInvalidConstraintType.ts(5,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +tests/cases/compiler/typeParameterWithInvalidConstraintType.ts(7,17): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. -==== tests/cases/compiler/typeParameterWithInvalidConstraintType.ts (1 errors) ==== +==== tests/cases/compiler/typeParameterWithInvalidConstraintType.ts (4 errors) ==== class A { ~ !!! error TS2313: Type parameter 'T' has a circular constraint. foo() { var x: T; - // no error expected below this line var a = x.foo(); + ~~~ +!!! error TS2339: Property 'foo' does not exist on type 'T'. var b = new x(123); + ~~~~~~~~~~ +!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. var c = x[1]; var d = x(); + ~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. } } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterWithInvalidConstraintType.js b/tests/baselines/reference/typeParameterWithInvalidConstraintType.js index a40056f6a59..40a2aeacf4b 100644 --- a/tests/baselines/reference/typeParameterWithInvalidConstraintType.js +++ b/tests/baselines/reference/typeParameterWithInvalidConstraintType.js @@ -2,7 +2,6 @@ class A { foo() { var x: T; - // no error expected below this line var a = x.foo(); var b = new x(123); var c = x[1]; @@ -16,7 +15,6 @@ var A = (function () { } A.prototype.foo = function () { var x; - // no error expected below this line var a = x.foo(); var b = new x(123); var c = x[1]; diff --git a/tests/baselines/reference/typeReferenceDirectives10.trace.json b/tests/baselines/reference/typeReferenceDirectives10.trace.json index 5bd31419793..910ec0cafa6 100644 --- a/tests/baselines/reference/typeReferenceDirectives10.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives10.trace.json @@ -7,7 +7,7 @@ "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========", "======== Resolving module './ref' from '/app.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/ref'.", + "Loading module as file / folder, candidate module location '/ref', target file type 'TypeScript'.", "File '/ref.ts' does not exist.", "File '/ref.tsx' does not exist.", "File '/ref.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/typeReferenceDirectives11.trace.json b/tests/baselines/reference/typeReferenceDirectives11.trace.json index a6ab6bc8d68..ae6786cba55 100644 --- a/tests/baselines/reference/typeReferenceDirectives11.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives11.trace.json @@ -1,7 +1,7 @@ [ "======== Resolving module './mod1' from '/mod2.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/mod1'.", + "Loading module as file / folder, candidate module location '/mod1', target file type 'TypeScript'.", "File '/mod1.ts' exist - use it as a name resolution result.", "======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========", "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", diff --git a/tests/baselines/reference/typeReferenceDirectives12.trace.json b/tests/baselines/reference/typeReferenceDirectives12.trace.json index 5f87ab7ea39..96c6aee65ec 100644 --- a/tests/baselines/reference/typeReferenceDirectives12.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives12.trace.json @@ -1,12 +1,12 @@ [ "======== Resolving module './main' from '/mod2.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/main'.", + "Loading module as file / folder, candidate module location '/main', target file type 'TypeScript'.", "File '/main.ts' exist - use it as a name resolution result.", "======== Module name './main' was successfully resolved to '/main.ts'. ========", "======== Resolving module './mod1' from '/mod2.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/mod1'.", + "Loading module as file / folder, candidate module location '/mod1', target file type 'TypeScript'.", "File '/mod1.ts' exist - use it as a name resolution result.", "======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========", "======== Resolving type reference directive 'lib', containing file '/mod1.ts', root directory '/types'. ========", @@ -16,7 +16,7 @@ "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========", "======== Resolving module './main' from '/mod1.ts'. ========", - "Resolution for module './main' was found in cache", + "Resolution for module './main' was found in cache.", "======== Module name './main' was successfully resolved to '/main.ts'. ========", "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'", diff --git a/tests/baselines/reference/typeReferenceDirectives13.trace.json b/tests/baselines/reference/typeReferenceDirectives13.trace.json index 5bd31419793..910ec0cafa6 100644 --- a/tests/baselines/reference/typeReferenceDirectives13.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives13.trace.json @@ -7,7 +7,7 @@ "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========", "======== Resolving module './ref' from '/app.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/ref'.", + "Loading module as file / folder, candidate module location '/ref', target file type 'TypeScript'.", "File '/ref.ts' does not exist.", "File '/ref.tsx' does not exist.", "File '/ref.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/typeReferenceDirectives5.trace.json b/tests/baselines/reference/typeReferenceDirectives5.trace.json index 5bd31419793..910ec0cafa6 100644 --- a/tests/baselines/reference/typeReferenceDirectives5.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives5.trace.json @@ -7,7 +7,7 @@ "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========", "======== Resolving module './ref' from '/app.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/ref'.", + "Loading module as file / folder, candidate module location '/ref', target file type 'TypeScript'.", "File '/ref.ts' does not exist.", "File '/ref.tsx' does not exist.", "File '/ref.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/typeReferenceDirectives8.trace.json b/tests/baselines/reference/typeReferenceDirectives8.trace.json index a6ab6bc8d68..ae6786cba55 100644 --- a/tests/baselines/reference/typeReferenceDirectives8.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives8.trace.json @@ -1,7 +1,7 @@ [ "======== Resolving module './mod1' from '/mod2.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/mod1'.", + "Loading module as file / folder, candidate module location '/mod1', target file type 'TypeScript'.", "File '/mod1.ts' exist - use it as a name resolution result.", "======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========", "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", diff --git a/tests/baselines/reference/typeReferenceDirectives9.trace.json b/tests/baselines/reference/typeReferenceDirectives9.trace.json index 5f87ab7ea39..96c6aee65ec 100644 --- a/tests/baselines/reference/typeReferenceDirectives9.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives9.trace.json @@ -1,12 +1,12 @@ [ "======== Resolving module './main' from '/mod2.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/main'.", + "Loading module as file / folder, candidate module location '/main', target file type 'TypeScript'.", "File '/main.ts' exist - use it as a name resolution result.", "======== Module name './main' was successfully resolved to '/main.ts'. ========", "======== Resolving module './mod1' from '/mod2.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/mod1'.", + "Loading module as file / folder, candidate module location '/mod1', target file type 'TypeScript'.", "File '/mod1.ts' exist - use it as a name resolution result.", "======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========", "======== Resolving type reference directive 'lib', containing file '/mod1.ts', root directory '/types'. ========", @@ -16,7 +16,7 @@ "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========", "======== Resolving module './main' from '/mod1.ts'. ========", - "Resolution for module './main' was found in cache", + "Resolution for module './main' was found in cache.", "======== Module name './main' was successfully resolved to '/main.ts'. ========", "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'", diff --git a/tests/baselines/reference/typeRelationships.js b/tests/baselines/reference/typeRelationships.js index 2f97f4b0d1c..5227a109b17 100644 --- a/tests/baselines/reference/typeRelationships.js +++ b/tests/baselines/reference/typeRelationships.js @@ -41,11 +41,16 @@ class D extends C { //// [typeRelationships.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { this.self = this; @@ -72,7 +77,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.self1 = _this; _this.self2 = _this.self; _this.self3 = _this.foo(); diff --git a/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.trace.json b/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.trace.json index b38bb7c0acd..8074424995e 100644 --- a/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.trace.json +++ b/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.trace.json @@ -1,153 +1,60 @@ [ "======== Resolving module 'xyz' from '/foo/bar/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module 'xyz' from 'node_modules' folder.", - "File '/foo/bar/node_modules/xyz.ts' does not exist.", - "File '/foo/bar/node_modules/xyz.tsx' does not exist.", - "File '/foo/bar/node_modules/xyz.d.ts' does not exist.", - "File '/foo/bar/node_modules/xyz/package.json' does not exist.", - "File '/foo/bar/node_modules/xyz/index.ts' does not exist.", - "File '/foo/bar/node_modules/xyz/index.tsx' does not exist.", - "File '/foo/bar/node_modules/xyz/index.d.ts' does not exist.", - "File '/foo/bar/node_modules/@types/xyz.d.ts' does not exist.", - "File '/foo/bar/node_modules/@types/xyz/package.json' does not exist.", - "File '/foo/bar/node_modules/@types/xyz/index.d.ts' does not exist.", + "Loading module 'xyz' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory '/foo/bar/node_modules' does not exist, skipping all lookups in it.", "File '/foo/node_modules/xyz.ts' does not exist.", "File '/foo/node_modules/xyz.tsx' does not exist.", "File '/foo/node_modules/xyz.d.ts' does not exist.", - "File '/foo/node_modules/xyz/package.json' does not exist.", - "File '/foo/node_modules/xyz/index.ts' does not exist.", - "File '/foo/node_modules/xyz/index.tsx' does not exist.", - "File '/foo/node_modules/xyz/index.d.ts' does not exist.", "File '/foo/node_modules/@types/xyz.d.ts' does not exist.", - "File '/foo/node_modules/@types/xyz/package.json' does not exist.", - "File '/foo/node_modules/@types/xyz/index.d.ts' does not exist.", "File '/node_modules/xyz.ts' does not exist.", "File '/node_modules/xyz.tsx' does not exist.", "File '/node_modules/xyz.d.ts' does not exist.", - "File '/node_modules/xyz/package.json' does not exist.", - "File '/node_modules/xyz/index.ts' does not exist.", - "File '/node_modules/xyz/index.tsx' does not exist.", - "File '/node_modules/xyz/index.d.ts' does not exist.", "File '/node_modules/@types/xyz.d.ts' does not exist.", - "File '/node_modules/@types/xyz/package.json' does not exist.", - "File '/node_modules/@types/xyz/index.d.ts' does not exist.", - "Loading module 'xyz' from 'node_modules' folder.", - "File '/foo/bar/node_modules/xyz.js' does not exist.", - "File '/foo/bar/node_modules/xyz.jsx' does not exist.", - "File '/foo/bar/node_modules/xyz/package.json' does not exist.", - "File '/foo/bar/node_modules/xyz/index.js' does not exist.", - "File '/foo/bar/node_modules/xyz/index.jsx' does not exist.", + "Loading module 'xyz' from 'node_modules' folder, target file type 'JavaScript'.", + "Directory '/foo/bar/node_modules' does not exist, skipping all lookups in it.", "File '/foo/node_modules/xyz.js' does not exist.", "File '/foo/node_modules/xyz.jsx' does not exist.", - "File '/foo/node_modules/xyz/package.json' does not exist.", - "File '/foo/node_modules/xyz/index.js' does not exist.", - "File '/foo/node_modules/xyz/index.jsx' does not exist.", "File '/node_modules/xyz.js' does not exist.", "File '/node_modules/xyz.jsx' does not exist.", - "File '/node_modules/xyz/package.json' does not exist.", - "File '/node_modules/xyz/index.js' does not exist.", - "File '/node_modules/xyz/index.jsx' does not exist.", "======== Module name 'xyz' was not resolved. ========", "======== Resolving module 'pdq' from '/foo/bar/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module 'pdq' from 'node_modules' folder.", - "File '/foo/bar/node_modules/pdq.ts' does not exist.", - "File '/foo/bar/node_modules/pdq.tsx' does not exist.", - "File '/foo/bar/node_modules/pdq.d.ts' does not exist.", - "File '/foo/bar/node_modules/pdq/package.json' does not exist.", - "File '/foo/bar/node_modules/pdq/index.ts' does not exist.", - "File '/foo/bar/node_modules/pdq/index.tsx' does not exist.", - "File '/foo/bar/node_modules/pdq/index.d.ts' does not exist.", - "File '/foo/bar/node_modules/@types/pdq.d.ts' does not exist.", - "File '/foo/bar/node_modules/@types/pdq/package.json' does not exist.", - "File '/foo/bar/node_modules/@types/pdq/index.d.ts' does not exist.", + "Loading module 'pdq' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory '/foo/bar/node_modules' does not exist, skipping all lookups in it.", "File '/foo/node_modules/pdq.ts' does not exist.", "File '/foo/node_modules/pdq.tsx' does not exist.", "File '/foo/node_modules/pdq.d.ts' does not exist.", - "File '/foo/node_modules/pdq/package.json' does not exist.", - "File '/foo/node_modules/pdq/index.ts' does not exist.", - "File '/foo/node_modules/pdq/index.tsx' does not exist.", - "File '/foo/node_modules/pdq/index.d.ts' does not exist.", "File '/foo/node_modules/@types/pdq.d.ts' does not exist.", - "File '/foo/node_modules/@types/pdq/package.json' does not exist.", - "File '/foo/node_modules/@types/pdq/index.d.ts' does not exist.", "File '/node_modules/pdq.ts' does not exist.", "File '/node_modules/pdq.tsx' does not exist.", "File '/node_modules/pdq.d.ts' does not exist.", - "File '/node_modules/pdq/package.json' does not exist.", - "File '/node_modules/pdq/index.ts' does not exist.", - "File '/node_modules/pdq/index.tsx' does not exist.", - "File '/node_modules/pdq/index.d.ts' does not exist.", "File '/node_modules/@types/pdq.d.ts' does not exist.", - "File '/node_modules/@types/pdq/package.json' does not exist.", - "File '/node_modules/@types/pdq/index.d.ts' does not exist.", - "Loading module 'pdq' from 'node_modules' folder.", - "File '/foo/bar/node_modules/pdq.js' does not exist.", - "File '/foo/bar/node_modules/pdq.jsx' does not exist.", - "File '/foo/bar/node_modules/pdq/package.json' does not exist.", - "File '/foo/bar/node_modules/pdq/index.js' does not exist.", - "File '/foo/bar/node_modules/pdq/index.jsx' does not exist.", + "Loading module 'pdq' from 'node_modules' folder, target file type 'JavaScript'.", + "Directory '/foo/bar/node_modules' does not exist, skipping all lookups in it.", "File '/foo/node_modules/pdq.js' does not exist.", "File '/foo/node_modules/pdq.jsx' does not exist.", - "File '/foo/node_modules/pdq/package.json' does not exist.", - "File '/foo/node_modules/pdq/index.js' does not exist.", - "File '/foo/node_modules/pdq/index.jsx' does not exist.", "File '/node_modules/pdq.js' does not exist.", "File '/node_modules/pdq.jsx' does not exist.", - "File '/node_modules/pdq/package.json' does not exist.", - "File '/node_modules/pdq/index.js' does not exist.", - "File '/node_modules/pdq/index.jsx' does not exist.", "======== Module name 'pdq' was not resolved. ========", "======== Resolving module 'abc' from '/foo/bar/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module 'abc' from 'node_modules' folder.", - "File '/foo/bar/node_modules/abc.ts' does not exist.", - "File '/foo/bar/node_modules/abc.tsx' does not exist.", - "File '/foo/bar/node_modules/abc.d.ts' does not exist.", - "File '/foo/bar/node_modules/abc/package.json' does not exist.", - "File '/foo/bar/node_modules/abc/index.ts' does not exist.", - "File '/foo/bar/node_modules/abc/index.tsx' does not exist.", - "File '/foo/bar/node_modules/abc/index.d.ts' does not exist.", - "File '/foo/bar/node_modules/@types/abc.d.ts' does not exist.", - "File '/foo/bar/node_modules/@types/abc/package.json' does not exist.", - "File '/foo/bar/node_modules/@types/abc/index.d.ts' does not exist.", + "Loading module 'abc' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory '/foo/bar/node_modules' does not exist, skipping all lookups in it.", "File '/foo/node_modules/abc.ts' does not exist.", "File '/foo/node_modules/abc.tsx' does not exist.", "File '/foo/node_modules/abc.d.ts' does not exist.", - "File '/foo/node_modules/abc/package.json' does not exist.", - "File '/foo/node_modules/abc/index.ts' does not exist.", - "File '/foo/node_modules/abc/index.tsx' does not exist.", - "File '/foo/node_modules/abc/index.d.ts' does not exist.", "File '/foo/node_modules/@types/abc.d.ts' does not exist.", - "File '/foo/node_modules/@types/abc/package.json' does not exist.", - "File '/foo/node_modules/@types/abc/index.d.ts' does not exist.", "File '/node_modules/abc.ts' does not exist.", "File '/node_modules/abc.tsx' does not exist.", "File '/node_modules/abc.d.ts' does not exist.", - "File '/node_modules/abc/package.json' does not exist.", - "File '/node_modules/abc/index.ts' does not exist.", - "File '/node_modules/abc/index.tsx' does not exist.", - "File '/node_modules/abc/index.d.ts' does not exist.", "File '/node_modules/@types/abc.d.ts' does not exist.", - "File '/node_modules/@types/abc/package.json' does not exist.", - "File '/node_modules/@types/abc/index.d.ts' does not exist.", - "Loading module 'abc' from 'node_modules' folder.", - "File '/foo/bar/node_modules/abc.js' does not exist.", - "File '/foo/bar/node_modules/abc.jsx' does not exist.", - "File '/foo/bar/node_modules/abc/package.json' does not exist.", - "File '/foo/bar/node_modules/abc/index.js' does not exist.", - "File '/foo/bar/node_modules/abc/index.jsx' does not exist.", + "Loading module 'abc' from 'node_modules' folder, target file type 'JavaScript'.", + "Directory '/foo/bar/node_modules' does not exist, skipping all lookups in it.", "File '/foo/node_modules/abc.js' does not exist.", "File '/foo/node_modules/abc.jsx' does not exist.", - "File '/foo/node_modules/abc/package.json' does not exist.", - "File '/foo/node_modules/abc/index.js' does not exist.", - "File '/foo/node_modules/abc/index.jsx' does not exist.", "File '/node_modules/abc.js' does not exist.", "File '/node_modules/abc.jsx' does not exist.", - "File '/node_modules/abc/package.json' does not exist.", - "File '/node_modules/abc/index.js' does not exist.", - "File '/node_modules/abc/index.jsx' does not exist.", "======== Module name 'abc' was not resolved. ========", "======== Resolving type reference directive 'grumpy', containing file '/foo/bar/__inferred type names__.ts', root directory '/foo/node_modules/@types,/node_modules/@types'. ========", "Resolving with primary search path '/foo/node_modules/@types, /node_modules/@types'", @@ -163,8 +70,6 @@ "======== Type reference directive 'sneezy' was successfully resolved to '/foo/node_modules/@types/sneezy/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'dopey', containing file '/foo/bar/__inferred type names__.ts', root directory '/foo/node_modules/@types,/node_modules/@types'. ========", "Resolving with primary search path '/foo/node_modules/@types, /node_modules/@types'", - "File '/foo/node_modules/@types/dopey/package.json' does not exist.", - "File '/foo/node_modules/@types/dopey/index.d.ts' does not exist.", "File '/node_modules/@types/dopey/package.json' does not exist.", "File '/node_modules/@types/dopey/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/dopey/index.d.ts', result '/node_modules/@types/dopey/index.d.ts'", diff --git a/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.trace.json b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.trace.json index 6c2090e2b45..dc21070f1ae 100644 --- a/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.trace.json +++ b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.trace.json @@ -1,38 +1,16 @@ [ "======== Resolving module 'xyz' from '/src/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module 'xyz' from 'node_modules' folder.", - "File '/src/node_modules/xyz.ts' does not exist.", - "File '/src/node_modules/xyz.tsx' does not exist.", - "File '/src/node_modules/xyz.d.ts' does not exist.", - "File '/src/node_modules/xyz/package.json' does not exist.", - "File '/src/node_modules/xyz/index.ts' does not exist.", - "File '/src/node_modules/xyz/index.tsx' does not exist.", - "File '/src/node_modules/xyz/index.d.ts' does not exist.", - "File '/src/node_modules/@types/xyz.d.ts' does not exist.", - "File '/src/node_modules/@types/xyz/package.json' does not exist.", - "File '/src/node_modules/@types/xyz/index.d.ts' does not exist.", + "Loading module 'xyz' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory '/src/node_modules' does not exist, skipping all lookups in it.", "File '/node_modules/xyz.ts' does not exist.", "File '/node_modules/xyz.tsx' does not exist.", "File '/node_modules/xyz.d.ts' does not exist.", - "File '/node_modules/xyz/package.json' does not exist.", - "File '/node_modules/xyz/index.ts' does not exist.", - "File '/node_modules/xyz/index.tsx' does not exist.", - "File '/node_modules/xyz/index.d.ts' does not exist.", "File '/node_modules/@types/xyz.d.ts' does not exist.", - "File '/node_modules/@types/xyz/package.json' does not exist.", - "File '/node_modules/@types/xyz/index.d.ts' does not exist.", - "Loading module 'xyz' from 'node_modules' folder.", - "File '/src/node_modules/xyz.js' does not exist.", - "File '/src/node_modules/xyz.jsx' does not exist.", - "File '/src/node_modules/xyz/package.json' does not exist.", - "File '/src/node_modules/xyz/index.js' does not exist.", - "File '/src/node_modules/xyz/index.jsx' does not exist.", + "Loading module 'xyz' from 'node_modules' folder, target file type 'JavaScript'.", + "Directory '/src/node_modules' does not exist, skipping all lookups in it.", "File '/node_modules/xyz.js' does not exist.", "File '/node_modules/xyz.jsx' does not exist.", - "File '/node_modules/xyz/package.json' does not exist.", - "File '/node_modules/xyz/index.js' does not exist.", - "File '/node_modules/xyz/index.jsx' does not exist.", "======== Module name 'xyz' was not resolved. ========", "======== Resolving type reference directive 'foo', containing file '/src/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'", diff --git a/tests/baselines/reference/typeValueConflict1.js b/tests/baselines/reference/typeValueConflict1.js index 8711a656bf5..e0b829faf61 100644 --- a/tests/baselines/reference/typeValueConflict1.js +++ b/tests/baselines/reference/typeValueConflict1.js @@ -12,11 +12,16 @@ module M2 { //// [typeValueConflict1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M1; (function (M1) { var A = (function () { @@ -33,7 +38,7 @@ var M2; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(M1.A)); diff --git a/tests/baselines/reference/typeValueConflict2.js b/tests/baselines/reference/typeValueConflict2.js index 7abda8110b6..6782384b895 100644 --- a/tests/baselines/reference/typeValueConflict2.js +++ b/tests/baselines/reference/typeValueConflict2.js @@ -19,11 +19,16 @@ module M3 { //// [typeValueConflict2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M1; (function (M1) { var A = (function () { @@ -40,7 +45,7 @@ var M2; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(M1.A)); @@ -51,7 +56,7 @@ var M3; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(M1.A)); diff --git a/tests/baselines/reference/typeofClass2.js b/tests/baselines/reference/typeofClass2.js index f1ec6a77b14..f5b11e0c833 100644 --- a/tests/baselines/reference/typeofClass2.js +++ b/tests/baselines/reference/typeofClass2.js @@ -22,11 +22,16 @@ var r1: typeof D; var r2: typeof d; //// [typeofClass2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C(x) { } @@ -37,7 +42,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.baz = function (x) { }; D.prototype.foo = function () { }; diff --git a/tests/baselines/reference/typeofOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/typeofOperatorWithAnyOtherType.errors.txt index 94bca545609..3680b1be60f 100644 --- a/tests/baselines/reference/typeofOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/typeofOperatorWithAnyOtherType.errors.txt @@ -1,6 +1,9 @@ -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(46,32): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(47,32): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(48,32): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(46,32): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(46,39): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(47,32): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(47,39): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(48,32): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(48,44): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(58,1): error TS2695: Left side of comma operator is unused and has no side effects. tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(68,1): error TS7028: Unused label. tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(69,1): error TS7028: Unused label. @@ -11,7 +14,7 @@ tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperator tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(74,1): error TS7028: Unused label. -==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts (11 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts (14 errors) ==== // typeof operator on any type var ANY: any; @@ -58,14 +61,20 @@ tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperator var ResultIsString15 = typeof A.foo(); var ResultIsString16 = typeof (ANY + ANY1); var ResultIsString17 = typeof (null + undefined); - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsString18 = typeof (null + null); - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsString19 = typeof (undefined + undefined); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // multiple typeof operators var ResultIsString20 = typeof typeof ANY; diff --git a/tests/baselines/reference/typeofStrictNull.js b/tests/baselines/reference/typeofStrictNull.js new file mode 100644 index 00000000000..520a72b9f0f --- /dev/null +++ b/tests/baselines/reference/typeofStrictNull.js @@ -0,0 +1,8 @@ +//// [typeofStrictNull.ts] + +let a: number; +let b: typeof a; + +//// [typeofStrictNull.js] +var a; +var b; diff --git a/tests/baselines/reference/typeofStrictNull.symbols b/tests/baselines/reference/typeofStrictNull.symbols new file mode 100644 index 00000000000..7b2dfb41797 --- /dev/null +++ b/tests/baselines/reference/typeofStrictNull.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/typeofStrictNull.ts === + +let a: number; +>a : Symbol(a, Decl(typeofStrictNull.ts, 1, 3)) + +let b: typeof a; +>b : Symbol(b, Decl(typeofStrictNull.ts, 2, 3)) +>a : Symbol(a, Decl(typeofStrictNull.ts, 1, 3)) + diff --git a/tests/baselines/reference/typeofStrictNull.types b/tests/baselines/reference/typeofStrictNull.types new file mode 100644 index 00000000000..59344727987 --- /dev/null +++ b/tests/baselines/reference/typeofStrictNull.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/typeofStrictNull.ts === + +let a: number; +>a : number + +let b: typeof a; +>b : number +>a : number + diff --git a/tests/baselines/reference/typesWithSpecializedCallSignatures.js b/tests/baselines/reference/typesWithSpecializedCallSignatures.js index 045f7b40e55..7a006e1a8ce 100644 --- a/tests/baselines/reference/typesWithSpecializedCallSignatures.js +++ b/tests/baselines/reference/typesWithSpecializedCallSignatures.js @@ -43,11 +43,16 @@ var r3: Base = c.foo('hm'); //// [typesWithSpecializedCallSignatures.js] // basic uses of specialized signatures without 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -56,14 +61,14 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived1; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/typesWithSpecializedConstructSignatures.js b/tests/baselines/reference/typesWithSpecializedConstructSignatures.js index b4d42d819ed..b3de7f2efc5 100644 --- a/tests/baselines/reference/typesWithSpecializedConstructSignatures.js +++ b/tests/baselines/reference/typesWithSpecializedConstructSignatures.js @@ -41,11 +41,16 @@ var r3: Base = new a('hm'); //// [typesWithSpecializedConstructSignatures.js] // basic uses of specialized signatures without 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; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -54,14 +59,14 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived1; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/typingsLookup4.trace.json b/tests/baselines/reference/typingsLookup4.trace.json index 2b7de6a4286..451d68edf28 100644 --- a/tests/baselines/reference/typingsLookup4.trace.json +++ b/tests/baselines/reference/typingsLookup4.trace.json @@ -1,14 +1,10 @@ [ "======== Resolving module 'jquery' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module 'jquery' from 'node_modules' folder.", + "Loading module 'jquery' from 'node_modules' folder, target file type 'TypeScript'.", "File '/node_modules/jquery.ts' does not exist.", "File '/node_modules/jquery.tsx' does not exist.", "File '/node_modules/jquery.d.ts' does not exist.", - "File '/node_modules/jquery/package.json' does not exist.", - "File '/node_modules/jquery/index.ts' does not exist.", - "File '/node_modules/jquery/index.tsx' does not exist.", - "File '/node_modules/jquery/index.d.ts' does not exist.", "File '/node_modules/@types/jquery.d.ts' does not exist.", "Found 'package.json' at '/node_modules/@types/jquery/package.json'.", "'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.", @@ -17,14 +13,10 @@ "======== Module name 'jquery' was successfully resolved to '/node_modules/@types/jquery/jquery.d.ts'. ========", "======== Resolving module 'kquery' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module 'kquery' from 'node_modules' folder.", + "Loading module 'kquery' from 'node_modules' folder, target file type 'TypeScript'.", "File '/node_modules/kquery.ts' does not exist.", "File '/node_modules/kquery.tsx' does not exist.", "File '/node_modules/kquery.d.ts' does not exist.", - "File '/node_modules/kquery/package.json' does not exist.", - "File '/node_modules/kquery/index.ts' does not exist.", - "File '/node_modules/kquery/index.tsx' does not exist.", - "File '/node_modules/kquery/index.d.ts' does not exist.", "File '/node_modules/@types/kquery.d.ts' does not exist.", "Found 'package.json' at '/node_modules/@types/kquery/package.json'.", "'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.", @@ -36,14 +28,10 @@ "======== Module name 'kquery' was successfully resolved to '/node_modules/@types/kquery/kquery.d.ts'. ========", "======== Resolving module 'lquery' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module 'lquery' from 'node_modules' folder.", + "Loading module 'lquery' from 'node_modules' folder, target file type 'TypeScript'.", "File '/node_modules/lquery.ts' does not exist.", "File '/node_modules/lquery.tsx' does not exist.", "File '/node_modules/lquery.d.ts' does not exist.", - "File '/node_modules/lquery/package.json' does not exist.", - "File '/node_modules/lquery/index.ts' does not exist.", - "File '/node_modules/lquery/index.tsx' does not exist.", - "File '/node_modules/lquery/index.d.ts' does not exist.", "File '/node_modules/@types/lquery.d.ts' does not exist.", "Found 'package.json' at '/node_modules/@types/lquery/package.json'.", "'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.", diff --git a/tests/baselines/reference/typingsLookupAmd.trace.json b/tests/baselines/reference/typingsLookupAmd.trace.json index 6ad05d9cbf9..49abda2815d 100644 --- a/tests/baselines/reference/typingsLookupAmd.trace.json +++ b/tests/baselines/reference/typingsLookupAmd.trace.json @@ -10,9 +10,7 @@ "File '/b.ts' does not exist.", "File '/b.tsx' does not exist.", "File '/b.d.ts' does not exist.", - "File '/x/y/node_modules/@types/b.d.ts' does not exist.", - "File '/x/y/node_modules/@types/b/package.json' does not exist.", - "File '/x/y/node_modules/@types/b/index.d.ts' does not exist.", + "Directory '/x/y/node_modules' does not exist, skipping all lookups in it.", "File '/x/node_modules/@types/b.d.ts' does not exist.", "File '/x/node_modules/@types/b/package.json' does not exist.", "File '/x/node_modules/@types/b/index.d.ts' exist - use it as a name resolution result.", @@ -34,15 +32,9 @@ "File '/a.ts' does not exist.", "File '/a.tsx' does not exist.", "File '/a.d.ts' does not exist.", - "File '/x/node_modules/@types/b/node_modules/@types/a.d.ts' does not exist.", - "File '/x/node_modules/@types/b/node_modules/@types/a/package.json' does not exist.", - "File '/x/node_modules/@types/b/node_modules/@types/a/index.d.ts' does not exist.", - "File '/x/node_modules/@types/node_modules/@types/a.d.ts' does not exist.", - "File '/x/node_modules/@types/node_modules/@types/a/package.json' does not exist.", - "File '/x/node_modules/@types/node_modules/@types/a/index.d.ts' does not exist.", + "Directory '/x/node_modules/@types/b/node_modules' does not exist, skipping all lookups in it.", + "Directory '/x/node_modules/@types/node_modules' does not exist, skipping all lookups in it.", "File '/x/node_modules/@types/a.d.ts' does not exist.", - "File '/x/node_modules/@types/a/package.json' does not exist.", - "File '/x/node_modules/@types/a/index.d.ts' does not exist.", "File '/node_modules/@types/a.d.ts' does not exist.", "File '/node_modules/@types/a/package.json' does not exist.", "File '/node_modules/@types/a/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/umdDependencyComment2.js b/tests/baselines/reference/umdDependencyComment2.js index 68cffd22023..4e784d87fa3 100644 --- a/tests/baselines/reference/umdDependencyComment2.js +++ b/tests/baselines/reference/umdDependencyComment2.js @@ -7,14 +7,15 @@ m1.f(); //// [umdDependencyComment2.js] /// -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports", "bar", "m2"], factory); } -})(["require", "exports", "bar", "m2"], function (require, exports) { +})(function (require, exports) { "use strict"; var m1 = require("m2"); m1.f(); diff --git a/tests/baselines/reference/umdDependencyCommentName1.js b/tests/baselines/reference/umdDependencyCommentName1.js index ac2fcc99981..45cae25192a 100644 --- a/tests/baselines/reference/umdDependencyCommentName1.js +++ b/tests/baselines/reference/umdDependencyCommentName1.js @@ -7,14 +7,15 @@ m1.f(); //// [umdDependencyCommentName1.js] /// -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports", "bar", "m2"], factory); } -})(["require", "exports", "bar", "m2"], function (require, exports, b) { +})(function (require, exports, b) { "use strict"; var m1 = require("m2"); m1.f(); diff --git a/tests/baselines/reference/umdDependencyCommentName2.js b/tests/baselines/reference/umdDependencyCommentName2.js index 06bd2c8a90c..e85d5b99b14 100644 --- a/tests/baselines/reference/umdDependencyCommentName2.js +++ b/tests/baselines/reference/umdDependencyCommentName2.js @@ -11,14 +11,15 @@ m1.f(); /// /// /// -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); + else if (typeof define === "function" && define.amd) { + define(["require", "exports", "bar", "goo", "foo", "m2"], factory); } -})(["require", "exports", "bar", "goo", "foo", "m2"], function (require, exports, b, c) { +})(function (require, exports, b, c) { "use strict"; var m1 = require("m2"); m1.f(); diff --git a/tests/baselines/reference/undeclaredBase.js b/tests/baselines/reference/undeclaredBase.js index 4b7813231cf..fcb8ed39595 100644 --- a/tests/baselines/reference/undeclaredBase.js +++ b/tests/baselines/reference/undeclaredBase.js @@ -4,17 +4,22 @@ module M { export class C extends M.I { } } //// [undeclaredBase.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(M.I)); diff --git a/tests/baselines/reference/undefinedIsSubtypeOfEverything.js b/tests/baselines/reference/undefinedIsSubtypeOfEverything.js index 7e480d18a0a..c5b08f061fd 100644 --- a/tests/baselines/reference/undefinedIsSubtypeOfEverything.js +++ b/tests/baselines/reference/undefinedIsSubtypeOfEverything.js @@ -123,11 +123,16 @@ class D17 extends Base { //// [undefinedIsSubtypeOfEverything.js] // undefined is a subtype of every other types, no errors expected below -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -136,105 +141,105 @@ var Base = (function () { var D0 = (function (_super) { __extends(D0, _super); function D0() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D0; }(Base)); var DA = (function (_super) { __extends(DA, _super); function DA() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return DA; }(Base)); var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(Base)); var D1A = (function (_super) { __extends(D1A, _super); function D1A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1A; }(Base)); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(Base)); var D2A = (function (_super) { __extends(D2A, _super); function D2A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2A; }(Base)); var D3 = (function (_super) { __extends(D3, _super); function D3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D3; }(Base)); var D3A = (function (_super) { __extends(D3A, _super); function D3A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D3A; }(Base)); var D4 = (function (_super) { __extends(D4, _super); function D4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D4; }(Base)); var D5 = (function (_super) { __extends(D5, _super); function D5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D5; }(Base)); var D6 = (function (_super) { __extends(D6, _super); function D6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D6; }(Base)); var D7 = (function (_super) { __extends(D7, _super); function D7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D7; }(Base)); var D8 = (function (_super) { __extends(D8, _super); function D8() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D8; }(Base)); var D9 = (function (_super) { __extends(D9, _super); function D9() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D9; }(Base)); var D10 = (function (_super) { __extends(D10, _super); function D10() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D10; }(Base)); @@ -245,7 +250,7 @@ var E; var D11 = (function (_super) { __extends(D11, _super); function D11() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D11; }(Base)); @@ -256,7 +261,7 @@ function f() { } var D12 = (function (_super) { __extends(D12, _super); function D12() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D12; }(Base)); @@ -271,21 +276,21 @@ var c = (function () { var D13 = (function (_super) { __extends(D13, _super); function D13() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D13; }(Base)); var D14 = (function (_super) { __extends(D14, _super); function D14() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D14; }(Base)); var D15 = (function (_super) { __extends(D15, _super); function D15() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D15; }(Base)); @@ -295,14 +300,14 @@ var D15 = (function (_super) { var D16 = (function (_super) { __extends(D16, _super); function D16() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D16; }(Base)); var D17 = (function (_super) { __extends(D17, _super); function D17() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D17; }(Base)); diff --git a/tests/baselines/reference/underscoreMapFirst.js b/tests/baselines/reference/underscoreMapFirst.js index c8e936af527..dcd95f85a12 100644 --- a/tests/baselines/reference/underscoreMapFirst.js +++ b/tests/baselines/reference/underscoreMapFirst.js @@ -49,15 +49,20 @@ class MyView extends View { //// [underscoreMapFirst.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var MyView = (function (_super) { __extends(MyView, _super); function MyView() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } MyView.prototype.getDataSeries = function () { var data = this.model.get("data"); diff --git a/tests/baselines/reference/underscoreThisInDerivedClass01.js b/tests/baselines/reference/underscoreThisInDerivedClass01.js index 000176c213f..412364e55dd 100644 --- a/tests/baselines/reference/underscoreThisInDerivedClass01.js +++ b/tests/baselines/reference/underscoreThisInDerivedClass01.js @@ -25,11 +25,16 @@ class D extends C { //// [underscoreThisInDerivedClass01.js] // @target es5 -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // Original test intent: // When arrow functions capture 'this', the lexical 'this' owner // currently captures 'this' using a variable named '_this'. @@ -47,7 +52,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this; + var _this = this; var _this = "uh-oh?"; _this = _super.call(this) || this; return _this; diff --git a/tests/baselines/reference/underscoreThisInDerivedClass02.js b/tests/baselines/reference/underscoreThisInDerivedClass02.js index c1e9494376b..cb51f248e07 100644 --- a/tests/baselines/reference/underscoreThisInDerivedClass02.js +++ b/tests/baselines/reference/underscoreThisInDerivedClass02.js @@ -19,11 +19,16 @@ class D extends C { //// [underscoreThisInDerivedClass02.js] // @target es5 -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // Original test intent: // Errors on '_this' should be reported in derived constructors, // even if 'super()' is not called. @@ -36,7 +41,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this; + var _this = this; var _this = "uh-oh?"; return _this; } diff --git a/tests/baselines/reference/unionTypeEquivalence.js b/tests/baselines/reference/unionTypeEquivalence.js index e4d0acc893c..11ef3a7974e 100644 --- a/tests/baselines/reference/unionTypeEquivalence.js +++ b/tests/baselines/reference/unionTypeEquivalence.js @@ -20,11 +20,16 @@ var z1: string | typeof BC; //// [unionTypeEquivalence.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + 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 () { function C() { @@ -34,7 +39,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.foo = function () { }; return D; diff --git a/tests/baselines/reference/unionTypeFromArrayLiteral.js b/tests/baselines/reference/unionTypeFromArrayLiteral.js index 83ad2a34394..11f53a8b985 100644 --- a/tests/baselines/reference/unionTypeFromArrayLiteral.js +++ b/tests/baselines/reference/unionTypeFromArrayLiteral.js @@ -28,11 +28,16 @@ var arr9 = [e, f]; // (E|F)[] // If the array literal is empty, the resulting type is an array type with the element type Undefined. // Otherwise, if the array literal is contextually typed by a type that has a property with the numeric name ‘0’, the resulting type is a tuple type constructed from the types of the element expressions. // Otherwise, the resulting type is an array type with an element type that is the union of the types of the element expressions. -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var arr1 = [1, 2]; // number[] var arr2 = ["hello", true]; // (string | number)[] var arr3Tuple = [3, "three"]; // [number, string] @@ -54,7 +59,7 @@ var D = (function () { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.foo3 = function () { }; return E; @@ -62,7 +67,7 @@ var E = (function (_super) { var F = (function (_super) { __extends(F, _super); function F() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } F.prototype.foo4 = function () { }; return F; diff --git a/tests/baselines/reference/unionTypesAssignability.js b/tests/baselines/reference/unionTypesAssignability.js index 231b8b27f3b..a26de7d2747 100644 --- a/tests/baselines/reference/unionTypesAssignability.js +++ b/tests/baselines/reference/unionTypesAssignability.js @@ -74,11 +74,16 @@ function foo(t: T, u: U) { //// [unionTypesAssignability.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var unionNumberString; var C = (function () { function C() { @@ -88,7 +93,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.foo1 = function () { }; return D; @@ -96,7 +101,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.foo2 = function () { }; return E; diff --git a/tests/baselines/reference/unknownSymbols1.js b/tests/baselines/reference/unknownSymbols1.js index 832868c4b8f..7ec636f672a 100644 --- a/tests/baselines/reference/unknownSymbols1.js +++ b/tests/baselines/reference/unknownSymbols1.js @@ -33,11 +33,16 @@ class C5 { } //// [unknownSymbols1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x = asdf; var y; function foo(x, y) { } diff --git a/tests/baselines/reference/unspecializedConstraints.js b/tests/baselines/reference/unspecializedConstraints.js index 1343bea602e..4c459c29be1 100644 --- a/tests/baselines/reference/unspecializedConstraints.js +++ b/tests/baselines/reference/unspecializedConstraints.js @@ -154,11 +154,16 @@ module ts { //// [unspecializedConstraints.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ts; (function (ts) { var Symbol = (function () { @@ -169,7 +174,7 @@ var ts; var Type = (function (_super) { __extends(Type, _super); function Type() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Type.prototype.equals = function (that) { if (this === that) diff --git a/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.js b/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.js index b82a7cbc0ae..a4f2d1ff2fc 100644 --- a/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.js +++ b/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.js @@ -44,11 +44,16 @@ c5(1); // error //// [untypedFunctionCallsWithTypeParameters1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // none of these function calls should be allowed var x = function () { return; }; var r1 = x(); @@ -70,7 +75,7 @@ var r4 = c2(); // should be an error var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(Function)); // error diff --git a/tests/baselines/reference/unusedClassesinNamespace4.js b/tests/baselines/reference/unusedClassesinNamespace4.js index 0ab1227bf3d..1a54b1de535 100644 --- a/tests/baselines/reference/unusedClassesinNamespace4.js +++ b/tests/baselines/reference/unusedClassesinNamespace4.js @@ -15,11 +15,16 @@ namespace Validation { } //// [unusedClassesinNamespace4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Validation; (function (Validation) { var c1 = (function () { @@ -36,7 +41,7 @@ var Validation; var c3 = (function (_super) { __extends(c3, _super); function c3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return c3; }(c1)); diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.js b/tests/baselines/reference/unusedIdentifiersConsolidated1.js index dbb261e5f2a..4e21d1c5ab1 100644 --- a/tests/baselines/reference/unusedIdentifiersConsolidated1.js +++ b/tests/baselines/reference/unusedIdentifiersConsolidated1.js @@ -103,11 +103,16 @@ namespace Greeter { } //// [unusedIdentifiersConsolidated1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function greeter(person) { var unused = 20; } @@ -168,7 +173,7 @@ var Greeter; var class2 = (function (_super) { __extends(class2, _super); function class2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class2; }(class1)); diff --git a/tests/baselines/reference/unusedLocalsAndObjectSpread2.errors.txt b/tests/baselines/reference/unusedLocalsAndObjectSpread2.errors.txt new file mode 100644 index 00000000000..2d1c36d3cbf --- /dev/null +++ b/tests/baselines/reference/unusedLocalsAndObjectSpread2.errors.txt @@ -0,0 +1,29 @@ +tests/cases/compiler/unusedLocalsAndObjectSpread2.ts(6,6): error TS6133: 'rest' is declared but never used. +tests/cases/compiler/unusedLocalsAndObjectSpread2.ts(9,10): error TS6133: 'foo' is declared but never used. +tests/cases/compiler/unusedLocalsAndObjectSpread2.ts(13,8): error TS6133: 'rest' is declared but never used. + + +==== tests/cases/compiler/unusedLocalsAndObjectSpread2.ts (3 errors) ==== + + declare let props: any; + const { + children, // here! + active: _a, // here! + ...rest, + ~~~~ +!!! error TS6133: 'rest' is declared but never used. + } = props; + + function foo() { + ~~~ +!!! error TS6133: 'foo' is declared but never used. + const { + children, + active: _a, + ...rest, + ~~~~ +!!! error TS6133: 'rest' is declared but never used. + } = props; + } + + export const asdf = 123; \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsAndObjectSpread2.js b/tests/baselines/reference/unusedLocalsAndObjectSpread2.js new file mode 100644 index 00000000000..e6cd890abb7 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsAndObjectSpread2.js @@ -0,0 +1,37 @@ +//// [unusedLocalsAndObjectSpread2.ts] + +declare let props: any; +const { + children, // here! + active: _a, // here! + ...rest, +} = props; + +function foo() { + const { + children, + active: _a, + ...rest, + } = props; +} + +export const asdf = 123; + +//// [unusedLocalsAndObjectSpread2.js] +"use strict"; +var __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; +}; +var children = props.children, // here! +_a = props.active, // here! +rest = __rest(props, ["children", "active"]); +function foo() { + var children = props.children, _a = props.active, rest = __rest(props, ["children", "active"]); +} +exports.asdf = 123; diff --git a/tests/baselines/reference/validUseOfThisInSuper.js b/tests/baselines/reference/validUseOfThisInSuper.js index bbd564db366..d3f574c3cef 100644 --- a/tests/baselines/reference/validUseOfThisInSuper.js +++ b/tests/baselines/reference/validUseOfThisInSuper.js @@ -10,11 +10,16 @@ class Super extends Base { } //// [validUseOfThisInSuper.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(b) { this.b = b; diff --git a/tests/baselines/reference/varArgsOnConstructorTypes.js b/tests/baselines/reference/varArgsOnConstructorTypes.js index 0875f2ba1dd..c859b4f8260 100644 --- a/tests/baselines/reference/varArgsOnConstructorTypes.js +++ b/tests/baselines/reference/varArgsOnConstructorTypes.js @@ -25,11 +25,16 @@ reg.register(B); //// [varArgsOnConstructorTypes.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); define(["require", "exports"], function (require, exports) { "use strict"; var A = (function () { diff --git a/tests/baselines/reference/voidOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/voidOperatorWithAnyOtherType.errors.txt index 8796f316303..5867a7ad6f5 100644 --- a/tests/baselines/reference/voidOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/voidOperatorWithAnyOtherType.errors.txt @@ -1,9 +1,12 @@ -tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(46,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(47,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(48,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(46,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(46,34): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(47,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(47,34): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(48,27): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(48,39): error TS2532: Object is possibly 'undefined'. -==== tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts (3 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts (6 errors) ==== // void operator on any type var ANY: any; @@ -50,14 +53,20 @@ tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWith var ResultIsAny15 = void A.foo(); var ResultIsAny16 = void (ANY + ANY1); var ResultIsAny17 = void (null + undefined); - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsAny18 = void (null + null); - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsAny19 = void (undefined + undefined); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // multiple void operators var ResultIsAny20 = void void ANY; diff --git a/tests/baselines/reference/widenedTypes.errors.txt b/tests/baselines/reference/widenedTypes.errors.txt index 5ea097acf2e..f0e3ec33f50 100644 --- a/tests/baselines/reference/widenedTypes.errors.txt +++ b/tests/baselines/reference/widenedTypes.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/widenedTypes.ts(2,1): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter. -tests/cases/compiler/widenedTypes.ts(6,7): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter -tests/cases/compiler/widenedTypes.ts(8,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +tests/cases/compiler/widenedTypes.ts(5,1): error TS2531: Object is possibly 'null'. +tests/cases/compiler/widenedTypes.ts(6,7): error TS2531: Object is possibly 'null'. +tests/cases/compiler/widenedTypes.ts(8,15): error TS2531: Object is possibly 'null'. tests/cases/compiler/widenedTypes.ts(10,14): error TS2695: Left side of comma operator is unused and has no side effects. tests/cases/compiler/widenedTypes.ts(11,1): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/compiler/widenedTypes.ts(18,1): error TS2322: Type '""' is not assignable to type 'number'. @@ -11,7 +12,7 @@ tests/cases/compiler/widenedTypes.ts(24,5): error TS2322: Type '{ x: number; y: Type 'number' is not assignable to type 'string'. -==== tests/cases/compiler/widenedTypes.ts (8 errors) ==== +==== tests/cases/compiler/widenedTypes.ts (9 errors) ==== null instanceof (() => { }); ~~~~ @@ -19,13 +20,15 @@ tests/cases/compiler/widenedTypes.ts(24,5): error TS2322: Type '{ x: number; y: ({}) instanceof null; // Ok because null is a subtype of function null in {}; + ~~~~ +!!! error TS2531: Object is possibly 'null'. "" in null; ~~~~ -!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter +!!! error TS2531: Object is possibly 'null'. for (var a in null) { } ~~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +!!! error TS2531: Object is possibly 'null'. var t = [3, (3, null)]; ~ diff --git a/tests/cases/compiler/arraySlice.ts b/tests/cases/compiler/arraySlice.ts new file mode 100644 index 00000000000..d2c5c974a23 --- /dev/null +++ b/tests/cases/compiler/arraySlice.ts @@ -0,0 +1,2 @@ +var arr: string[] | number[]; +arr.splice(1, 1); diff --git a/tests/cases/compiler/asyncFunctionReturnType.ts b/tests/cases/compiler/asyncFunctionReturnType.ts index a1bcde38079..3bd7a0e998a 100644 --- a/tests/cases/compiler/asyncFunctionReturnType.ts +++ b/tests/cases/compiler/asyncFunctionReturnType.ts @@ -8,3 +8,69 @@ async function fAsyncExplicit(): Promise<[number, boolean]> { // This is contextually typed as a tuple. return [1, true]; } + +// https://github.com/Microsoft/TypeScript/issues/13128 +interface Obj { + stringProp: string; + anyProp: any; +} + +async function fIndexedTypeForStringProp(obj: Obj): Promise { + return obj.stringProp; +} + +async function fIndexedTypeForPromiseOfStringProp(obj: Obj): Promise { + return Promise.resolve(obj.stringProp); +} + +async function fIndexedTypeForExplicitPromiseOfStringProp(obj: Obj): Promise { + return Promise.resolve(obj.stringProp); +} + +async function fIndexedTypeForAnyProp(obj: Obj): Promise { + return obj.anyProp; +} + +async function fIndexedTypeForPromiseOfAnyProp(obj: Obj): Promise { + return Promise.resolve(obj.anyProp); +} + +async function fIndexedTypeForExplicitPromiseOfAnyProp(obj: Obj): Promise { + return Promise.resolve(obj.anyProp); +} + +async function fGenericIndexedTypeForStringProp(obj: TObj): Promise { + return obj.stringProp; +} + +async function fGenericIndexedTypeForPromiseOfStringProp(obj: TObj): Promise { + return Promise.resolve(obj.stringProp); +} + +async function fGenericIndexedTypeForExplicitPromiseOfStringProp(obj: TObj): Promise { + return Promise.resolve(obj.stringProp); +} + +async function fGenericIndexedTypeForAnyProp(obj: TObj): Promise { + return obj.anyProp; +} + +async function fGenericIndexedTypeForPromiseOfAnyProp(obj: TObj): Promise { + return Promise.resolve(obj.anyProp); +} + +async function fGenericIndexedTypeForExplicitPromiseOfAnyProp(obj: TObj): Promise { + return Promise.resolve(obj.anyProp); +} + +async function fGenericIndexedTypeForKProp(obj: TObj, key: K): Promise { + return obj[key]; +} + +async function fGenericIndexedTypeForPromiseOfKProp(obj: TObj, key: K): Promise { + return Promise.resolve(obj[key]); +} + +async function fGenericIndexedTypeForExplicitPromiseOfKProp(obj: TObj, key: K): Promise { + return Promise.resolve(obj[key]); +} \ No newline at end of file diff --git a/tests/cases/compiler/deleteReadonly.ts b/tests/cases/compiler/deleteReadonly.ts new file mode 100644 index 00000000000..cdab3f2eb23 --- /dev/null +++ b/tests/cases/compiler/deleteReadonly.ts @@ -0,0 +1,20 @@ +interface A { + readonly b +} +var a: A = { + b: 123 +}; + +delete a.b; + +interface B { + readonly [k: string]: string +} + +var b: B = { + 'test': 'test' +}; + +delete b['test']; + +delete ((((b['test'])))); diff --git a/tests/cases/compiler/es3-oldStyleOctalLiteralInEnums.ts b/tests/cases/compiler/es3-oldStyleOctalLiteralInEnums.ts new file mode 100644 index 00000000000..93489ee4820 --- /dev/null +++ b/tests/cases/compiler/es3-oldStyleOctalLiteralInEnums.ts @@ -0,0 +1,5 @@ +// @target: ES3 +enum E { + x = -01, + y = 02, +} \ No newline at end of file diff --git a/tests/cases/compiler/oldStyleOctalLiteralTypes.ts b/tests/cases/compiler/es3-oldStyleOctalLiteralTypes.ts similarity index 100% rename from tests/cases/compiler/oldStyleOctalLiteralTypes.ts rename to tests/cases/compiler/es3-oldStyleOctalLiteralTypes.ts diff --git a/tests/cases/compiler/es5-oldStyleOctalLiteralInEnums.ts b/tests/cases/compiler/es5-oldStyleOctalLiteralInEnums.ts new file mode 100644 index 00000000000..42a95eff2a2 --- /dev/null +++ b/tests/cases/compiler/es5-oldStyleOctalLiteralInEnums.ts @@ -0,0 +1,5 @@ +// @target: ES5 +enum E { + x = -01, + y = 02, +} \ No newline at end of file diff --git a/tests/cases/compiler/importHelpersInAmbientContext.ts b/tests/cases/compiler/importHelpersInAmbientContext.ts new file mode 100644 index 00000000000..8bfa5b25404 --- /dev/null +++ b/tests/cases/compiler/importHelpersInAmbientContext.ts @@ -0,0 +1,55 @@ +// @importHelpers: true +// @target: es5 + +// @filename: a.d.ts +export { }; + +// Extends +declare class C { } +declare class D extends C { } + +// Destructuring +interface I { + ({descendants, read}?: { + descendants?: boolean; + read?: any; + }): any; +} + + +// Object Rest +interface Foo { + a: number; b: string; +} +export var { a, ...x } : Foo; + +// @filename: b.ts +export {}; +declare namespace N { + // Extends + class C { } + class D extends C { } + + // Destructuring + interface I { + ({descendants, read}?: { + descendants?: boolean; + read?: any; + }): any; + } + + + // Object Rest + interface Foo { + a: number; b: string; + } + export var { a, ...x } : Foo; +} + +// @filename: tslib.d.ts +export declare function __extends(d: Function, b: Function): void; +export declare function __assign(t: any, ...sources: any[]): any; +export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; +export declare function __param(paramIndex: number, decorator: Function): Function; +export declare function __metadata(metadataKey: any, metadataValue: any): Function; +export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any; diff --git a/tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx b/tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx new file mode 100644 index 00000000000..a108a405f97 --- /dev/null +++ b/tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx @@ -0,0 +1,9 @@ +//@jsx: react + +declare var React: any; + + + } dataSource={this.state.ds} renderRow={}> + + diff --git a/tests/cases/compiler/jsxInExtendsClause.tsx b/tests/cases/compiler/jsxInExtendsClause.tsx new file mode 100644 index 00000000000..6482a5964e1 --- /dev/null +++ b/tests/cases/compiler/jsxInExtendsClause.tsx @@ -0,0 +1,12 @@ +// @jsx: react +// https://github.com/Microsoft/TypeScript/issues/13157 +declare namespace React { + interface ComponentClass

{ new (): Component; } + class Component {} +} +declare function createComponentClass

(factory: () => React.ComponentClass

): React.ComponentClass

; +class Foo extends createComponentClass(() => class extends React.Component<{}, {}> { + render() { + return Hello, world!; + } +}) {} \ No newline at end of file diff --git a/tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts b/tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts new file mode 100644 index 00000000000..8901c215115 --- /dev/null +++ b/tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts @@ -0,0 +1,12 @@ +// Repro from #13346 + +interface Chainable { + value(): T; + mapValues(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>; +} + +declare function chain(t: T): Chainable; + +const square = (x: number) => x * x; + +const v = chain({a: 1, b: 2}).mapValues(square).value(); diff --git a/tests/cases/compiler/mappedTypeWithCombinedTypeMappers.ts b/tests/cases/compiler/mappedTypeWithCombinedTypeMappers.ts new file mode 100644 index 00000000000..9c6d8479b2e --- /dev/null +++ b/tests/cases/compiler/mappedTypeWithCombinedTypeMappers.ts @@ -0,0 +1,18 @@ +// Repro from #13351 + +type Meta = { + readonly[P in keyof T]: { + value: T[P]; + also: A; + readonly children: Meta; + }; +} + +interface Input { + x: string; + y: number; +} + +declare const output: Meta; + +const shouldFail: { important: boolean } = output.x.children; diff --git a/tests/cases/compiler/metadataOfClassFromModule.ts b/tests/cases/compiler/metadataOfClassFromModule.ts new file mode 100644 index 00000000000..aca356f2247 --- /dev/null +++ b/tests/cases/compiler/metadataOfClassFromModule.ts @@ -0,0 +1,14 @@ +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @target: es5 +module MyModule { + + export function inject(target: any, key: string): void { } + + export class Leg { } + + export class Person { + @inject leftLeg: Leg; + } + +} \ No newline at end of file diff --git a/tests/cases/compiler/typeParameterWithInvalidConstraintType.ts b/tests/cases/compiler/typeParameterWithInvalidConstraintType.ts index 7c92ad4575a..a97876b0ab3 100644 --- a/tests/cases/compiler/typeParameterWithInvalidConstraintType.ts +++ b/tests/cases/compiler/typeParameterWithInvalidConstraintType.ts @@ -1,7 +1,6 @@ class A { foo() { var x: T; - // no error expected below this line var a = x.foo(); var b = new x(123); var c = x[1]; diff --git a/tests/cases/compiler/typeofStrictNull.ts b/tests/cases/compiler/typeofStrictNull.ts new file mode 100644 index 00000000000..ede2b857305 --- /dev/null +++ b/tests/cases/compiler/typeofStrictNull.ts @@ -0,0 +1,4 @@ +// @strictNullChecks: true + +let a: number; +let b: typeof a; \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsAndObjectSpread2.ts b/tests/cases/compiler/unusedLocalsAndObjectSpread2.ts new file mode 100644 index 00000000000..e55c2042a41 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsAndObjectSpread2.ts @@ -0,0 +1,18 @@ +//@noUnusedLocals:true + +declare let props: any; +const { + children, // here! + active: _a, // here! + ...rest, +} = props; + +function foo() { + const { + children, + active: _a, + ...rest, + } = props; +} + +export const asdf = 123; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts b/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts new file mode 100644 index 00000000000..243a297ed43 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts @@ -0,0 +1,10 @@ +const [a, b = a] = [1]; // ok +const [c, d = c, e = e] = [1]; // error for e = e +const [f, g = f, h = i, i = f] = [1]; // error for h = i + +(function ([a, b = a]) { // ok +})([1]); +(function ([c, d = c, e = e]) { // error for e = e +})([1]); +(function ([f, g = f, h = i, i = f]) { // error for h = i +})([1]) diff --git a/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment4.ts b/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment4.ts new file mode 100644 index 00000000000..d138c14db7a --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment4.ts @@ -0,0 +1,8 @@ +const { + a = 1, + b = 2, + c = b, // ok + d = a, // ok + e = f, // error + f = f // error +} = { } as any; diff --git a/tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts b/tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts new file mode 100644 index 00000000000..cda2d4d2ce7 --- /dev/null +++ b/tests/cases/conformance/es6/newTarget/invalidNewTarget.es5.ts @@ -0,0 +1,25 @@ +// @target: es5 +const a = new.target; +const b = () => new.target; + +class C { + [new.target]() { } + c() { return new.target; } + get d() { return new.target; } + set e(_) { _ = new.target; } + f = () => new.target; + + static [new.target]() { } + static g() { return new.target; } + static get h() { return new.target; } + static set i(_) { _ = new.target; } + static j = () => new.target; +} + +const O = { + [new.target]: undefined, + k() { return new.target; }, + get l() { return new.target; }, + set m(_) { _ = new.target; }, + n: new.target, +}; \ No newline at end of file diff --git a/tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts b/tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts new file mode 100644 index 00000000000..5043c160e10 --- /dev/null +++ b/tests/cases/conformance/es6/newTarget/invalidNewTarget.es6.ts @@ -0,0 +1,25 @@ +// @target: es6 +const a = new.target; +const b = () => new.target; + +class C { + [new.target]() { } + c() { return new.target; } + get d() { return new.target; } + set e(_) { _ = new.target; } + f = () => new.target; + + static [new.target]() { } + static g() { return new.target; } + static get h() { return new.target; } + static set i(_) { _ = new.target; } + static j = () => new.target; +} + +const O = { + [new.target]: undefined, + k() { return new.target; }, + get l() { return new.target; }, + set m(_) { _ = new.target; }, + n: new.target, +}; \ No newline at end of file diff --git a/tests/cases/conformance/es6/newTarget/newTarget.es5.ts b/tests/cases/conformance/es6/newTarget/newTarget.es5.ts new file mode 100644 index 00000000000..b912f5f0596 --- /dev/null +++ b/tests/cases/conformance/es6/newTarget/newTarget.es5.ts @@ -0,0 +1,32 @@ +// @target: es5 +class A { + constructor() { + const a = new.target; + const b = () => new.target; + } + static c = function () { return new.target; } + d = function () { return new.target; } +} + +class B extends A { + constructor() { + super(); + const e = new.target; + const f = () => new.target; + } +} + +function f1() { + const g = new.target; + const h = () => new.target; +} + +const f2 = function () { + const i = new.target; + const j = () => new.target; +} + +const O = { + k: function () { return new.target; } +}; + diff --git a/tests/cases/conformance/es6/newTarget/newTarget.es6.ts b/tests/cases/conformance/es6/newTarget/newTarget.es6.ts new file mode 100644 index 00000000000..de61a49334a --- /dev/null +++ b/tests/cases/conformance/es6/newTarget/newTarget.es6.ts @@ -0,0 +1,32 @@ +// @target: es6 +class A { + constructor() { + const a = new.target; + const b = () => new.target; + } + static c = function () { return new.target; } + d = function () { return new.target; } +} + +class B extends A { + constructor() { + super(); + const e = new.target; + const f = () => new.target; + } +} + +function f1() { + const g = new.target; + const h = () => new.target; +} + +const f2 = function () { + const i = new.target; + const j = () => new.target; +} + +const O = { + k: function () { return new.target; } +}; + diff --git a/tests/cases/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidStaticToString.ts b/tests/cases/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidStaticToString.ts new file mode 100644 index 00000000000..b99f8d71141 --- /dev/null +++ b/tests/cases/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidStaticToString.ts @@ -0,0 +1,21 @@ +declare class StaticToString { + static toString(): void; +} + +function foo(staticToString: StaticToString) { + return staticToString instanceof StaticToString; +} + +declare class StaticToNumber { + static toNumber(): void; +} +function bar(staticToNumber: StaticToNumber) { + return staticToNumber instanceof StaticToNumber; +} + +declare class NormalToString { + toString(): void; +} +function baz(normal: NormalToString) { + return normal instanceof NormalToString; +} diff --git a/tests/cases/conformance/expressions/functions/contextuallyTypedIife.ts b/tests/cases/conformance/expressions/functions/contextuallyTypedIife.ts index ed3c24e0ac7..ca0d6e67711 100644 --- a/tests/cases/conformance/expressions/functions/contextuallyTypedIife.ts +++ b/tests/cases/conformance/expressions/functions/contextuallyTypedIife.ts @@ -27,3 +27,6 @@ // contextually typed parameters. let twelve = (f => f(12))(i => i); let eleven = (o => o.a(11))({ a: function(n) { return n; } }); +// missing arguments +(function(x, undefined) { return x; })(42); +((x, y, z) => 42)(); diff --git a/tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts b/tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts new file mode 100644 index 00000000000..04951beb9f0 --- /dev/null +++ b/tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts @@ -0,0 +1,33 @@ +// @strictNullChecks: true +// arrow +(jake => { })("build"); +// function expression +(function (cats) { })("lol"); +// Lots of Irritating Superfluous Parentheses +(function (x) { } ("!")); +((((function (y) { }))))("-"); +// multiple arguments +((a, b, c) => { })("foo", 101, false); +// default parameters +((m = 10) => m + 1)(12); +((n = 10) => n + 1)(); +// optional parameters +((j?) => j + 1)(12); +((k?) => k + 1)(); +((l, o?) => l + o)(12); // o should be any +// rest parameters +((...numbers) => numbers.every(n => n > 0))(5,6,7); +((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); +((...noNumbers) => noNumbers.some(n => n > 0))(); +((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); +// destructuring parameters (with defaults too!) +(({ q }) => q)({ q : 13 }); +(({ p = 14 }) => p)({ p : 15 }); +(({ r = 17 } = { r: 18 }) => r)({r : 19}); +(({ u = 22 } = { u: 23 }) => u)(); +// contextually typed parameters. +let twelve = (f => f(12))(i => i); +let eleven = (o => o.a(11))({ a: function(n) { return n; } }); +// missing arguments +(function(x, undefined) { return x; })(42); +((x, y, z) => 42)(); diff --git a/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx index 34fd158eab1..be677b37ff8 100644 --- a/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx @@ -42,7 +42,7 @@ var p = 0;

; -// Emit "foo" + ' ' + "bar" +// Emit "foo bar"
foo @@ -51,3 +51,15 @@ var p = 0;
; +// Emit "hello\\ world" +
+ + hello\ + +world +
; + +// Emit " a b c d " +
a + b c + d
; diff --git a/tests/cases/conformance/jsx/tsxSpreadChildren.tsx b/tests/cases/conformance/jsx/tsxSpreadChildren.tsx new file mode 100644 index 00000000000..3be0b3b99e4 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxSpreadChildren.tsx @@ -0,0 +1,27 @@ +//@jsx: preserve + +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +interface TodoProp { + id: number; + todo: string; +} +interface TodoListProps { + todos: TodoProp[]; +} +function Todo(prop: { key: number, todo: string }) { + return
{prop.key.toString() + prop.todo}
; +} +function TodoList({ todos }: TodoListProps) { + return
+ {...todos.map(todo => )} +
; +} +let x: TodoListProps; + diff --git a/tests/cases/conformance/jsx/tsxSpreadChildrenInvalidType.tsx b/tests/cases/conformance/jsx/tsxSpreadChildrenInvalidType.tsx new file mode 100644 index 00000000000..41181618ce0 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxSpreadChildrenInvalidType.tsx @@ -0,0 +1,32 @@ +// @jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +interface TodoProp { + id: number; + todo: string; +} +interface TodoListProps { + todos: TodoProp[]; +} +function Todo(prop: { key: number, todo: string }) { + return
{prop.key.toString() + prop.todo}
; +} +function TodoList({ todos }: TodoListProps) { + return
+ {...} +
; +} +function TodoListNoError({ todos }: TodoListProps) { + // any is not checked + return
+ {...( as any)} +
; +} +let x: TodoListProps; + diff --git a/tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment9.ts b/tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment9.ts new file mode 100644 index 00000000000..dc3aad85335 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment9.ts @@ -0,0 +1,7 @@ +namespace Foo { + export default foo; +} + +module Bar { + export default bar; +} \ No newline at end of file diff --git a/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts b/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts index c01030c7fa9..a53fc6fbf72 100644 --- a/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts +++ b/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts @@ -13,7 +13,7 @@ declare let x2: T2<"x">; let x2x = x2.x; interface T3> { - x: T["x"]; // Error + x: T["x"]; } interface T4> { @@ -25,7 +25,16 @@ class C1 { } class C2 { - x: this["y"]; // Error - y: this["z"]; // Error - z: this["x"]; // Error -} \ No newline at end of file + x: this["y"]; + y: this["z"]; + z: this["x"]; +} + +// Repro from #12627 + +interface Foo { + hello: boolean; +} + +function foo() { +} diff --git a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts index ea6a3c2358a..27e47da177c 100644 --- a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts +++ b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts @@ -297,6 +297,30 @@ class C1 { } } +type S2 = { + a: string; + b: string; +}; + +function f90(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) { + x1 = x2; + x1 = x3; + x1 = x4; + x2 = x1; + x2 = x3; + x2 = x4; + x3 = x1; + x3 = x2; + x3 = x4; + x4 = x1; + x4 = x2; + x4 = x3; + x1.length; + x2.length; + x3.length; + x4.length; +} + // Repros from #12011 class Base { @@ -430,4 +454,50 @@ type SomeMethodDescriptor = { returnValue: string[]; } -let result = dispatchMethod("someMethod", ["hello", 35]); \ No newline at end of file +let result = dispatchMethod("someMethod", ["hello", 35]); + +// Repro from #13073 + +type KeyTypes = "a" | "b" +let MyThingy: { [key in KeyTypes]: string[] }; + +function addToMyThingy(key: S) { + MyThingy[key].push("a"); +} + +// Repro from #13102 + +type Handler = { + onChange: (name: keyof T) => void; +}; + +function onChangeGenericFunction(handler: Handler) { + handler.onChange('preset') +} + +// Repro from #13285 + +function updateIds, K extends string>( + obj: T, + idFields: K[], + idMapping: { [oldId: string]: string } +): Record { + for (const idField of idFields) { + const newId = idMapping[obj[idField]]; + if (newId) { + obj[idField] = newId; + } + } + return obj; +} + +// Repro from #13285 + +function updateIds2( + obj: T, + key: K, + stringMap: { [oldId: string]: string } +) { + var x = obj[key]; + stringMap[x]; // Should be OK. +} diff --git a/tests/cases/conformance/types/mapped/mappedTypeRelationships.ts b/tests/cases/conformance/types/mapped/mappedTypeRelationships.ts index 4af71fbea08..587ec1c9d7e 100644 --- a/tests/cases/conformance/types/mapped/mappedTypeRelationships.ts +++ b/tests/cases/conformance/types/mapped/mappedTypeRelationships.ts @@ -105,4 +105,66 @@ function f50(obj: T, key: keyof T) { function f51(obj: T, key: K) { let item: Item = obj[key]; return obj[key].name; -} \ No newline at end of file +} + +type T1 = { + [P in keyof T]: T[P]; +} + +type T2 = { + [P in keyof T]: T[P]; +} + +function f60(x: T1, y: T2) { + x = y; + y = x; +} + +type Identity = { + [P in keyof T]: T[P]; +} + +function f61(x: Identity, y: Partial) { + x = y; // Error + y = x; +} + +function f62(x: Identity, y: Readonly) { + x = y; + y = x; +} + +function f70(x: { [P in keyof T]: T[P] }, y: { [P in keyof T]: T[P] }) { + x = y; + y = x; +} + +function f71(x: { [P in keyof T]: T[P] }, y: { [P in keyof T]: U[P] }) { + x = y; + y = x; // Error +} + +function f72(x: { [P in keyof T]: T[P] }, y: { [P in keyof U]: U[P] }) { + x = y; + y = x; // Error +} + +function f73(x: { [P in K]: T[P] }, y: { [P in keyof T]: T[P] }) { + x = y; + y = x; // Error +} + +function f74(x: { [P in K]: T[P] }, y: { [P in keyof U]: U[P] }) { + x = y; + y = x; // Error +} + +function f75(x: { [P in K]: T[P] }, y: { [P in keyof T]: U[P] }) { + x = y; + y = x; // Error +} + +function f76(x: { [P in K]: T[P] }, y: { [P in K]: U[P] }) { + x = y; + y = x; // Error +} diff --git a/tests/cases/conformance/types/mapped/mappedTypes4.ts b/tests/cases/conformance/types/mapped/mappedTypes4.ts index 74b3e395f32..4def192d602 100644 --- a/tests/cases/conformance/types/mapped/mappedTypes4.ts +++ b/tests/cases/conformance/types/mapped/mappedTypes4.ts @@ -59,4 +59,15 @@ type DeepReadonlyFoo = { }; var x1: DeepReadonly; -var x1: DeepReadonlyFoo; \ No newline at end of file +var x1: DeepReadonlyFoo; + +// Repro from #13232 + +type Z = { a: number }; +type Clone = { + [P in keyof (T & {})]: T[P]; +}; +type M = Clone; // M should be { a: number } + +var z1: Z; +var z1: Clone; diff --git a/tests/cases/conformance/types/nonPrimitive/assignObjectToNonPrimitive.ts b/tests/cases/conformance/types/nonPrimitive/assignObjectToNonPrimitive.ts new file mode 100644 index 00000000000..e9dcb5671c5 --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/assignObjectToNonPrimitive.ts @@ -0,0 +1,5 @@ +var x = {}; +var y = {foo: "bar"}; +var a: object; +a = x; +a = y; diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts new file mode 100644 index 00000000000..2febbb1e2ca --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts @@ -0,0 +1,3 @@ +var a: object; +a.toString(); +a.nonExist(); // error diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAsProperty.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAsProperty.ts new file mode 100644 index 00000000000..3cd2ce4cef5 --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAsProperty.ts @@ -0,0 +1,8 @@ +// @declaration: true +interface WithNonPrimitive { + foo: object +} + +var a: WithNonPrimitive = { foo: {bar: "bar"} }; + +var b: WithNonPrimitive = {foo: "bar"}; // expect error diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts new file mode 100644 index 00000000000..83801652865 --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts @@ -0,0 +1,27 @@ +var x = {}; +var y = {foo: "bar"}; +var a: object; +x = a; +y = a; // expect error +a = x; +a = y; + +var n = 123; +var b = true; +var s = "fooo"; + +a = n; // expect error +a = b; // expect error +a = s; // expect error + +n = a; // expect error +b = a; // expect error +s = a; // expect error + +var numObj: Number = 123; +var boolObj: Boolean = true; +var strObj: String = "string"; + +a = numObj; // ok +a = boolObj; // ok +a = strObj; // ok diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts new file mode 100644 index 00000000000..d56c02fafe9 --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts @@ -0,0 +1,19 @@ +// @declaration: true +function takeObject(o: object) {} +function returnObject(): object { + return {}; +} + +var nonPrimitive: object; +var primitive: boolean; + +takeObject(nonPrimitive); +nonPrimitive = returnObject(); + +takeObject(primitive); // expect error +primitive = returnObject(); // expect error + +function returnError(): object { + var ret = 123; + return ret; // expect error +} diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts new file mode 100644 index 00000000000..490a9f88135 --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts @@ -0,0 +1,44 @@ +// @declaration: true +function generic(t: T) { + var o: object = t; // expect error +} +var a = {}; +var b = "42"; + +generic({}); +generic(a); +generic(123); // expect error +generic(b); // expect error + +function bound(t: T) { + var o: object = t; // ok +} + +bound({}); +bound(a); +bound(123); // expect error +bound(b); // expect error + +function bound2() {} + +bound2<{}>(); +bound2(); +bound2(); // expect error +bound2(); // expect error + +function bound3(t: T) { + var o: object = t; // ok +} + +interface Proxy {} + +var x: Proxy; // error +var y: Proxy; // ok +var z: Proxy ; // ok + + +interface Blah { + foo: number; +} + +var u: Proxy; // ok diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts new file mode 100644 index 00000000000..2df691958de --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts @@ -0,0 +1,22 @@ +class Narrow { + narrowed: boolean +} + +var a: object + +if (a instanceof Narrow) { + a.narrowed; // ok + a = 123; // error +} + +if (typeof a === 'number') { + a.toFixed(); // error, never +} + +var b: object | null + +if (typeof b === 'object') { + b.toString(); // ok, object | null +} else { + b.toString(); // error, never +} diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts new file mode 100644 index 00000000000..3c2b9646c7e --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts @@ -0,0 +1,61 @@ +// @strictNullChecks: true + +var a: object +declare var b: object | null +declare var c: object | undefined +declare var d: object | null | undefined +var e: object | null +a.toString; // error +a = undefined; // error +a = null; // error +a = b; // error +a = c; // error +a = d; // error + +e = a; // ok +a = e; // ok + +if (typeof b !== 'object') { + b.toString(); // error, never +} + +if (typeof b === 'object') { + a = b; // error, b is not narrowed +} + +if (typeof d === 'object') { + b = d; // ok + d.toString(); // error, object | null +} else { + d.toString(); // error, undefined +} + +if (d == null) { + d.toString(); // error, undefined | null +} else { + d.toString(); // object +} + +if (d === null) { + d.toString(); // error, null +} else { + d.toString(); // error, object | undefined +} + +if (typeof d === 'undefined') { + d.toString(); // error, undefined +} else { + d.toString(); // error, object | null +} + +interface Proxy {} + +var x: Proxy; // error +var y: Proxy; // error +var z: Proxy; // error + +interface Blah { + foo: number; +} + +var u: Proxy; // ok diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts new file mode 100644 index 00000000000..a9d5872705c --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts @@ -0,0 +1,5 @@ +// @declaration: true +var a: object & string = ""; // error +var b: object | string = ""; // ok +a = b; // error +b = a; // ok diff --git a/tests/cases/conformance/types/rest/objectRest.ts b/tests/cases/conformance/types/rest/objectRest.ts index 2fba5d0b6dc..77f0fca1ed7 100644 --- a/tests/cases/conformance/types/rest/objectRest.ts +++ b/tests/cases/conformance/types/rest/objectRest.ts @@ -29,8 +29,15 @@ class Removable { removed: string; remainder: string; } +interface I { + m(): void; + removed: string; + remainder: string; +} var removable = new Removable(); var { removed, ...removableRest } = removable; +var i: I = removable; +var { removed, ...removableRest2 } = i; let computed = 'b'; let computed2 = 'a'; diff --git a/tests/cases/conformance/types/spread/spreadMethods.ts b/tests/cases/conformance/types/spread/spreadMethods.ts new file mode 100644 index 00000000000..5d562653424 --- /dev/null +++ b/tests/cases/conformance/types/spread/spreadMethods.ts @@ -0,0 +1,23 @@ +class K { p = 12; m() { } } +interface I { p: number, m(): void } +let k = new K() +let sk = { ...k }; +let ssk = { ...k, ...k }; +sk.p; +sk.m(); // error +ssk.p; +ssk.m(); // error +let i: I = { p: 12, m() { } }; +let si = { ...i }; +let ssi = { ...i, ...i }; +si.p; +si.m(); // ok +ssi.p; +ssi.m(); // ok +let o = { p: 12, m() { } }; +let so = { ...o }; +let sso = { ...o, ...o }; +so.p; +so.m(); // ok +sso.p; +sso.m(); // ok diff --git a/tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts b/tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts index 3b115573830..f2c6476bd8e 100644 --- a/tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts +++ b/tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts @@ -3,4 +3,5 @@ type any = I; type number = I; type boolean = I; type string = I; -type void = I; \ No newline at end of file +type void = I; +type object = I; diff --git a/tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts b/tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts new file mode 100644 index 00000000000..0209d7d3ccf --- /dev/null +++ b/tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts @@ -0,0 +1,27 @@ +class A { + constructor(private a: string) { } +} + +class B { +} + +function acceptA(a: A) { } +function acceptB(b: B) { } + +function test(x: A | B) { + if (x instanceof B) { + acceptA(x); + } + + if (x instanceof A) { + acceptA(x); + } + + if (x instanceof B) { + acceptB(x); + } + + if (x instanceof B) { + acceptB(x); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/ambientShorthandGotoDefinition.ts b/tests/cases/fourslash/ambientShorthandGotoDefinition.ts index 8673d661fe2..410fc932cec 100644 --- a/tests/cases/fourslash/ambientShorthandGotoDefinition.ts +++ b/tests/cases/fourslash/ambientShorthandGotoDefinition.ts @@ -1,13 +1,13 @@ /// // @Filename: declarations.d.ts -/////*module*/declare module "jquery" +////declare module /*module*/"jquery" // @Filename: user.ts /////// ////import /*importFoo*/foo, {bar} from "jquery"; -////import /*importBaz*/* as /*idBaz*/baz from "jquery"; -/////*importBang*/import /*idBang*/bang = require("jquery"); +////import * as /*importBaz*/baz from "jquery"; +////import /*importBang*/bang = require("jquery"); ////foo/*useFoo*/(bar/*useBar*/, baz/*useBaz*/, bang/*useBang*/); verify.quickInfoAt("useFoo", "import foo"); @@ -22,11 +22,11 @@ verify.goToDefinition("useBar", "module"); verify.quickInfoAt("useBaz", "import baz"); verify.goToDefinition({ useBaz: "importBaz", - idBaz: "module" + importBaz: "module" }); verify.quickInfoAt("useBang", "import bang = require(\"jquery\")"); verify.goToDefinition({ useBang: "importBang", - idBang: "module" + importBang: "module" }); diff --git a/tests/cases/fourslash/codeFixChangeExtendsToImplements.ts b/tests/cases/fourslash/codeFixChangeExtendsToImplements.ts new file mode 100644 index 00000000000..bfaedf2818a --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeExtendsToImplements.ts @@ -0,0 +1,6 @@ +/// + +//// interface I {} +//// [|/* */ class /* */ C /* */ extends /* */ I|]{} + +verify.rangeAfterCodeFix("/* */ class /* */ C /* */ implements /* */ I"); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixChangeExtendsToImplementsAbstractModifier.ts b/tests/cases/fourslash/codeFixChangeExtendsToImplementsAbstractModifier.ts new file mode 100644 index 00000000000..5f5ca93c28f --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeExtendsToImplementsAbstractModifier.ts @@ -0,0 +1,8 @@ +/// + +//// interface I1 { } +//// interface I2 { } + +//// [|abstract class A extends I1 implements I2|] { } + +verify.rangeAfterCodeFix("abstract class A implements I1, I2"); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixChangeExtendsToImplementsTypeParams.ts b/tests/cases/fourslash/codeFixChangeExtendsToImplementsTypeParams.ts new file mode 100644 index 00000000000..869bd1a5dc0 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeExtendsToImplementsTypeParams.ts @@ -0,0 +1,6 @@ +/// + +////interface I { x: X} +////[|class C extends I|]{} + +verify.rangeAfterCodeFix("class C implements I"); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixChangeExtendsToImplementsWithDecorator.ts b/tests/cases/fourslash/codeFixChangeExtendsToImplementsWithDecorator.ts new file mode 100644 index 00000000000..9671f41def3 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeExtendsToImplementsWithDecorator.ts @@ -0,0 +1,13 @@ +/// + +//// interface I1 { } +//// interface I2 { } + +//// function sealed(constructor: Function) { +//// Object.seal(constructor); +//// Object.seal(constructor.prototype); +//// } + +//// @sealed +//// [|class A extends I1 implements I2 { }|] +verify.rangeAfterCodeFix("class A implements I1, I2 { }"); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassExprClassImplementClassFunctionVoidInferred.ts b/tests/cases/fourslash/codeFixClassExprClassImplementClassFunctionVoidInferred.ts new file mode 100644 index 00000000000..bdf8ea3bd25 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExprClassImplementClassFunctionVoidInferred.ts @@ -0,0 +1,13 @@ +/// + +//// class A { +//// f() {} +//// } +//// +//// let B = class implements A {[| |]} + +verify.rangeAfterCodeFix(` +f(): void{ + throw new Error('Method not implemented.'); +} +`); diff --git a/tests/cases/fourslash/codeFixClassExprExtendsAbstractExpressionWithTypeArgs.ts b/tests/cases/fourslash/codeFixClassExprExtendsAbstractExpressionWithTypeArgs.ts new file mode 100644 index 00000000000..a7690b4f5bf --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExprExtendsAbstractExpressionWithTypeArgs.ts @@ -0,0 +1,14 @@ +/// + +//// function foo(a: T) { +//// abstract class C { +//// abstract a: T | U; +//// } +//// return C; +//// } +//// +//// let B = class extends foo("s") {[| |]} + +verify.rangeAfterCodeFix(` +a: string | number; +`); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractExpressionWithTypeArgs.ts b/tests/cases/fourslash/codeFixClassExtendAbstractExpressionWithTypeArgs.ts new file mode 100644 index 00000000000..5796bea6fb4 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExtendAbstractExpressionWithTypeArgs.ts @@ -0,0 +1,14 @@ +/// + +//// function foo(a: T) { +//// abstract class C { +//// abstract a: T | U; +//// } +//// return C; +//// } +//// +//// class B extends foo("s") {[| |]} + +verify.rangeAfterCodeFix(` +a: string | number; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractGetter.ts b/tests/cases/fourslash/codeFixClassExtendAbstractGetter.ts new file mode 100644 index 00000000000..8d79cce710e --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExtendAbstractGetter.ts @@ -0,0 +1,11 @@ +/// + +//// abstract class A { +//// abstract get b(): number; +//// } +//// +//// class C extends A {[| |]} + +verify.rangeAfterCodeFix(` + b: number; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts b/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts new file mode 100644 index 00000000000..fc0ac400623 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts @@ -0,0 +1,17 @@ +/// + +//// abstract class A { +//// private _a: string; +//// +//// abstract get a(): string; +//// abstract set a(newName: string); +//// } +//// +//// // Don't need to add anything in this case. +//// abstract class B extends A {} +//// +//// class C extends A {[| |]} + +verify.rangeAfterCodeFix(` + a: string; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts new file mode 100644 index 00000000000..a657dfeb718 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts @@ -0,0 +1,18 @@ +/// + +//// abstract class A { +//// abstract f(a: number, b: string): boolean; +//// abstract f(a: string, b: number): Function; +//// abstract f(a: string): Function; +//// } +//// +//// class C extends A {[| |]} + +verify.rangeAfterCodeFix(` + f(a: number, b: string): boolean; + f(a: string, b: number): Function; + f(a: string): Function; + f(a: any, b?: any) { + throw new Error('Method not implemented.'); + } +`); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts new file mode 100644 index 00000000000..bdf198b89e3 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts @@ -0,0 +1,13 @@ +/// + +//// abstract class A { +//// abstract f(x: T): T; +//// } +//// +//// class C extends A {[| +//// |]} + +verify.rangeAfterCodeFix(`f(x: number): number{ + throw new Error('Method not implemented.'); +} +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts new file mode 100644 index 00000000000..647a533c1c5 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts @@ -0,0 +1,13 @@ +/// + +//// abstract class A { +//// abstract f(x: T): T; +//// } +//// +//// class C extends A {[| +//// |]} + +verify.rangeAfterCodeFix(`f(x: U): U{ + throw new Error('Method not implemented.'); +} +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractPrivateProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractPrivateProperty.ts new file mode 100644 index 00000000000..d395272b36f --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExtendAbstractPrivateProperty.ts @@ -0,0 +1,15 @@ +/// + +//// abstract class A { +//// private abstract x: number; +//// } +//// +//// class C extends A {[| +//// |]} + +// We don't know how to fix this problem. We can: +// 1) Make x protected, and then insert. +// 2) Make x private, and then insert. +// 3) Make x not abstract. +// So we offer no fixes. +verify.not.codeFixAvailable(); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts new file mode 100644 index 00000000000..46de88f7511 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts @@ -0,0 +1,12 @@ +/// + +//// abstract class A { +//// abstract x: number; +//// } +//// +//// class C extends A {[| +//// |]} + +verify.rangeAfterCodeFix(` +x: number; +`); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts new file mode 100644 index 00000000000..6d0571fce6b --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts @@ -0,0 +1,12 @@ +/// + +//// abstract class A { +//// protected abstract x: number; +//// } +//// +//// class C extends A {[| +//// |]} + +verify.rangeAfterCodeFix(` +protected x: number; +`); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts new file mode 100644 index 00000000000..917f75051f1 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts @@ -0,0 +1,12 @@ +/// + +//// abstract class A { +//// public abstract x: number; +//// } +//// +//// class C extends A {[| +//// |]} + +verify.rangeAfterCodeFix(` +public x: number; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractSetter.ts b/tests/cases/fourslash/codeFixClassExtendAbstractSetter.ts new file mode 100644 index 00000000000..e8cb55fa660 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExtendAbstractSetter.ts @@ -0,0 +1,11 @@ +/// + +//// abstract class A { +//// abstract set c(arg: number | string); +//// } +//// +//// class C extends A {[| |]} + +verify.rangeAfterCodeFix(` + c: string | number; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractSomePropertiesPresent.ts b/tests/cases/fourslash/codeFixClassExtendAbstractSomePropertiesPresent.ts new file mode 100644 index 00000000000..b6dd679bb71 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExtendAbstractSomePropertiesPresent.ts @@ -0,0 +1,16 @@ +/// + +//// abstract class A { +//// abstract x: number; +//// abstract y: number; +//// abstract z: number; +//// } +//// +//// class C extends A {[| |] +//// constructor(public x: number) { super(); } +//// y: number; +//// } + +verify.rangeAfterCodeFix(` +z: number; +`); diff --git a/tests/cases/fourslash/codeFixClassImplementClassAbstractGettersAndSetters.ts b/tests/cases/fourslash/codeFixClassImplementClassAbstractGettersAndSetters.ts new file mode 100644 index 00000000000..df78803c588 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementClassAbstractGettersAndSetters.ts @@ -0,0 +1,20 @@ +/// + +//// abstract class A { +//// private _a: string; +//// +//// abstract get a(): string; +//// abstract set a(newName: string); +//// +//// abstract get b(): number; +//// +//// abstract set c(arg: number | string); +//// } +//// +//// class C implements A {[| |]} + +verify.rangeAfterCodeFix(` + a: string; + b: number; + c: string | number; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts b/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts new file mode 100644 index 00000000000..d9b9f57d4d2 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts @@ -0,0 +1,13 @@ +/// + +//// class A { +//// f() {} +//// } +//// +//// class B implements A {[| |]} + +verify.rangeAfterCodeFix(` +f(): void{ + throw new Error('Method not implemented.'); +} +`); diff --git a/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts b/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts new file mode 100644 index 00000000000..4365a160531 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts @@ -0,0 +1,18 @@ +/// + +//// class C1 { +//// f1() {} +//// } +//// +//// class C2 extends C1 { +//// +//// } +//// +//// class C3 implements C2 {[| +//// |]f2(){} +//// } + +verify.rangeAfterCodeFix(`f1(): void{ + throw new Error('Method not implemented.'); +} +`); diff --git a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts new file mode 100644 index 00000000000..82ecde6c418 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts @@ -0,0 +1,14 @@ +/// + +//// class A { +//// method(a: number, b: string): boolean; +//// method(a: string | number, b?: string | number): boolean | Function { return true; } +//// +//// class C implements A {[| |]} + +verify.rangeAfterCodeFix(` + method(a: number, b: string): boolean; + method(a: string | number, b?: string | number): boolean | Function { + throw new Error('Method not implemented.'); + } +`); diff --git a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts new file mode 100644 index 00000000000..f187e0ca0f1 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts @@ -0,0 +1,18 @@ +/// + +//// class A { +//// method(a: any, b: string): boolean; +//// method(a: string, b: number): Function; +//// method(a: string): Function; +//// method(a: string | number, b?: string | number): boolean | Function { return true; } +//// +//// class C implements A {[| |]} + +verify.rangeAfterCodeFix(` + method(a: any, b: string): boolean; + method(a: string, b: number): Function; + method(a: string): Function; + method(a: string | number, b?: string | number): boolean | Function { + throw new Error('Method not implemented.'); + } +`); diff --git a/tests/cases/fourslash/codeFixClassImplementClassPropertyModifiers.ts b/tests/cases/fourslash/codeFixClassImplementClassPropertyModifiers.ts new file mode 100644 index 00000000000..a40ffc8aeb0 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementClassPropertyModifiers.ts @@ -0,0 +1,16 @@ +/// + +//// abstract class A { +//// abstract x: number; +//// private y: number; +//// protected z: number; +//// public w: number; +//// } +//// +//// class C implements A {[| |]} + +verify.rangeAfterCodeFix(` +x: number; +protected z: number; +public w: number; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts b/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts new file mode 100644 index 00000000000..e8b199b21af --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts @@ -0,0 +1,63 @@ +/// + + +//// // Referenced throughout the inheritance chain. +//// interface I0 { a: number } +//// +//// class C1 implements I0 { a: number } +//// interface I1 { b: number } +//// interface I2 extends C1, I1 {} +//// +//// class C2 { c: number } +//// interface I3 {d: number} +//// class C3 extends C2 implements I0, I2, I3 { +//// a: number; +//// b: number; +//// d: number; +//// } +//// +//// interface I4 { e: number } +//// interface I5 { f: number } +//// class C4 extends C3 implements I0, I4, I5 { +//// e: number; +//// f: number; +//// } +//// +//// interface I6 extends C4 {} +//// class C5 implements I6 {[| +//// |]} + + +/** + * We want to check whether the search for member to replace actually searches through + * the various possible paths of the inheritance chain correctly, and that We + * don't issue duplicates for the same member. + * + * Our class DAG: + * + * C5 + * |-I6 + * |-C4 + * |-I4 + * |-I5 + * |------------------------ I0 + * |-C3 + * |-I2 + * |-I1 + * |-C1 + * |-------------------I0 + * |-I3 + * |-----------------------I0 + * |-C2 + */ + + +verify.rangeAfterCodeFix( +` +e: number; +f: number; +a: number; +b: number; +d: number; +c: number; +`); diff --git a/tests/cases/fourslash/codeFixClassImplementDefaultClass.ts b/tests/cases/fourslash/codeFixClassImplementDefaultClass.ts new file mode 100644 index 00000000000..9f507c3dc60 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementDefaultClass.ts @@ -0,0 +1,9 @@ +/// + +//// interface I { x: number; } +//// +//// export default class implements I {[| |]} + +verify.rangeAfterCodeFix(` +x: number; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterface36.ts b/tests/cases/fourslash/codeFixClassImplementInterface36.ts new file mode 100644 index 00000000000..f9fc48991fc --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterface36.ts @@ -0,0 +1,20 @@ +/// + +//// abstract class C1 { +//// +//// } +//// +//// abstract class C2 { +//// abstract f1(); +//// } +//// +//// interface I1 extends C1, C2 {} +//// +//// class C3 implements I1 {[| +//// +//// |]} + +verify.rangeAfterCodeFix(`f1(){ + throw new Error('Method not implemented.'); +} +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterface39.ts b/tests/cases/fourslash/codeFixClassImplementInterface39.ts new file mode 100644 index 00000000000..f81dea49782 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterface39.ts @@ -0,0 +1,18 @@ +/// + +//// namespace N1 { +//// export interface I1 { +//// f1():string; +//// } +//// } +//// interface I1 { +//// f1(); +//// } +//// +//// class C1 implements N1.I1 {[| +//// |]} + +verify.rangeAfterCodeFix(`f1(): string{ + throw new Error('Method not implemented.'); +} +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceClassExpression.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceClassExpression.ts new file mode 100644 index 00000000000..5b07a582c6c --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceClassExpression.ts @@ -0,0 +1,10 @@ +/// + + +//// interface I { x: number; } +//// +//// new class implements I {[| |]}; + +verify.rangeAfterCodeFix(` +x: number; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts new file mode 100644 index 00000000000..341b4e59814 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts @@ -0,0 +1,21 @@ +/// + +//// interface I { +//// ["foo"](o: any): boolean; +//// ["x"]: boolean; +//// [1](): string; +//// [2]: boolean; +//// } +//// +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + ["foo"](o: any): boolean { + throw new Error('Method not implemented.'); + } + ["x"]: boolean; + [1](): string { + throw new Error('Method not implemented.'); + } + [2]: boolean; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts new file mode 100644 index 00000000000..7c1156acd78 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts @@ -0,0 +1,52 @@ +/// + +// @lib: es2017 + +//// interface I { +//// [Symbol.hasInstance](o: any): boolean; +//// [Symbol.isConcatSpreadable]: boolean; +//// [Symbol.iterator](): any; +//// [Symbol.match]: boolean; +//// [Symbol.replace](...args); +//// [Symbol.search](str: string): number; +//// [Symbol.species](): Species; +//// [Symbol.split](str: string, limit?: number): string[]; +//// [Symbol.toPrimitive](hint: "number"): number; +//// [Symbol.toPrimitive](hint: "default"): number; +//// [Symbol.toPrimitive](hint: "string"): string; +//// [Symbol.toStringTag]: string; +//// [Symbol.unscopables]: any; +//// } +//// +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + [Symbol.hasInstance](o: any): boolean { + throw new Error('Method not implemented.'); + } + [Symbol.isConcatSpreadable]: boolean; + [Symbol.iterator]() { + throw new Error('Method not implemented.'); + } + [Symbol.match]: boolean; + [Symbol.replace](...args: {}) { + throw new Error('Method not implemented.'); + } + [Symbol.search](str: string): number { + throw new Error('Method not implemented.'); + } + [Symbol.species](): number { + throw new Error('Method not implemented.'); + } + [Symbol.split](str: string, limit?: number): {} { + throw new Error('Method not implemented.'); + } + [Symbol.toPrimitive](hint: "number"): number; + [Symbol.toPrimitive](hint: "default"): number; + [Symbol.toPrimitive](hint: "string"): string; + [Symbol.toPrimitive](hint: any) { + throw new Error('Method not implemented.'); + } + [Symbol.toStringTag]: string; + [Symbol.unscopables]: any; +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceDuplicateMember1.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceDuplicateMember1.ts new file mode 100644 index 00000000000..a2154de567a --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceDuplicateMember1.ts @@ -0,0 +1,13 @@ +/// + +//// interface I1 { +//// x: number; +//// } +//// interface I2 { +//// x: number; +//// } +//// +//// class C implements I1,I2 {[| +//// |]} + +verify.codeFixAvailable(); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceDuplicateMember2.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceDuplicateMember2.ts new file mode 100644 index 00000000000..ac90d51b07c --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceDuplicateMember2.ts @@ -0,0 +1,14 @@ +/// + +//// interface I1 { +//// x: number; +//// } +//// interface I2 { +//// x: number; +//// } +//// +//// class C implements I1,I2 { +//// x: number; +//// } + +verify.not.codeFixAvailable(); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesBoth.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesBoth.ts new file mode 100644 index 00000000000..e47eeb6d5c1 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesBoth.ts @@ -0,0 +1,14 @@ +/// + + +//// interface I { +//// [x: number]: I; +//// [y: string]: I; +//// } +//// +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + [x: number]: I; + [y: string]: I; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNoFix.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNoFix.ts new file mode 100644 index 00000000000..07896b4cdb3 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNoFix.ts @@ -0,0 +1,11 @@ +/// + +//// interface I4 { +//// [x: string, y: number]: number; +//// } +//// +//// class C implements I {[| |]} + +verify.not.codeFixAvailable(); + + diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts new file mode 100644 index 00000000000..0f143442530 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts @@ -0,0 +1,12 @@ +/// + +//// interface I { +//// [x: number]: I; +//// } +//// +//// class C implements I {[| +//// |]} + +verify.rangeAfterCodeFix(` + [x: number]: I; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesString.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesString.ts new file mode 100644 index 00000000000..4b595c6eda7 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesString.ts @@ -0,0 +1,11 @@ +/// + +//// interface I { +//// [x: string]: X; +//// } +//// +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + [x: string]: number; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodWithParams.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodWithParams.ts new file mode 100644 index 00000000000..0ee842975e0 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodWithParams.ts @@ -0,0 +1,14 @@ +/// + +//// interface I { +//// f(x: number, y: string): I +//// } +//// +//// class C implements I {[| +//// |]} + +verify.rangeAfterCodeFix(` +f(x: number,y: string): I { + throw new Error('Method not implemented.'); +} +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements1.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements1.ts new file mode 100644 index 00000000000..c8d61227c49 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements1.ts @@ -0,0 +1,19 @@ +/// + +//// interface I1 { +//// x: number; +//// } +//// interface I2 { +//// y: number; +//// } +//// +//// class C implements I1,I2 {[| +//// y: number; +//// |]} + +verify.rangeAfterCodeFix(` +x: number; +y: number; +`); + +verify.not.codeFixAvailable(); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements2.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements2.ts new file mode 100644 index 00000000000..d29b23998b8 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements2.ts @@ -0,0 +1,19 @@ +/// + +//// interface I1 { +//// x: number; +//// } +//// interface I2 { +//// y: number; +//// } +//// +//// class C implements I1,I2 {[| +//// x: number; +//// |]} + +verify.rangeAfterCodeFix(` +y: number; +x: number; +`); + +verify.not.codeFixAvailable(); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplementsIntersection1.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplementsIntersection1.ts new file mode 100644 index 00000000000..321d41e4633 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplementsIntersection1.ts @@ -0,0 +1,13 @@ +/// + +//// interface I1 { +//// x: number; +//// } +//// interface I2 { +//// x: string; +//// } +//// +//// class C implements I1,I2 {[| +//// |]} + +verify.codeFixAvailable(); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplementsIntersection2.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplementsIntersection2.ts new file mode 100644 index 00000000000..8f744e25cae --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplementsIntersection2.ts @@ -0,0 +1,14 @@ +/// + +//// interface I1 { +//// x: number; +//// } +//// interface I2 { +//// x: string; +//// } +//// +//// class C implements I1,I2 { +//// x: string; +//// } + +verify.not.codeFixAvailable(); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts new file mode 100644 index 00000000000..beab89c06a5 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts @@ -0,0 +1,28 @@ +/// + +//// interface I1 { +//// x: number, +//// y: number +//// z: number; +//// f(), +//// g() +//// h(); +//// } +//// +//// class C1 implements I1 {[| +//// |]} + +verify.rangeAfterCodeFix(` +x: number; +y: number; +z: number; +f() { + throw new Error('Method not implemented.'); +} +g() { + throw new Error('Method not implemented.'); +} +h() { + throw new Error('Method not implemented.'); +} +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts new file mode 100644 index 00000000000..bda58b3767d --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts @@ -0,0 +1,18 @@ +/// + +//// interface I { +//// method(a: number, b: string): boolean; +//// method(a: string, b: number): Function; +//// method(a: string): Function; +//// } +//// +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + method(a: number, b: string): boolean; + method(a: string, b: number): Function; + method(a: string): Function; + method(a: any, b?: any) { + throw new Error('Method not implemented.'); + } +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts new file mode 100644 index 00000000000..6e0a272a42a --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts @@ -0,0 +1,18 @@ +/// + +//// interface I { +//// method(a: number, ...b: string[]): boolean; +//// method(a: string, ...b: number[]): Function; +//// method(a: string): Function; +//// } +//// +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + method(a: number, ...b: string[]): boolean; + method(a: string, ...b: number[]): Function; + method(a: string): Function; + method(a: any, ...b?: any[]) { + throw new Error('Method not implemented.'); + } +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts new file mode 100644 index 00000000000..7ba7ae2c98c --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts @@ -0,0 +1,18 @@ +/// + +//// interface I { +//// method(a: number, ...b: string[]): boolean; +//// method(a: string, b: number): Function; +//// method(a: string): Function; +//// } +//// +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + method(a: number, ...b: string[]): boolean; + method(a: string, b: number): Function; + method(a: string): Function; + method(a: any, b?: any, ...rest?: any[]) { + throw new Error('Method not implemented.'); + } +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts new file mode 100644 index 00000000000..4fea72aa48f --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts @@ -0,0 +1,17 @@ +/// + +//// namespace N1 { +//// export interface I1 { +//// x: number; +//// } +//// } +//// interface I1 { +//// f1(); +//// } +//// +//// class C1 implements N1.I1 {[| +//// |]} + +verify.rangeAfterCodeFix(` +x: number; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyFromParentConstructorFunction.ts b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyFromParentConstructorFunction.ts new file mode 100644 index 00000000000..2a4ca4df923 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyFromParentConstructorFunction.ts @@ -0,0 +1,16 @@ +/// + +//// class A { +//// constructor(public x: number) { } +//// } +//// +//// class B implements A {[| |]} + +verify.not.codeFixAvailable(); + +// TODO: (arozga) Get this working. +/* +verify.rangeAfterCodeFix(` +public x: number; +`); +*/ diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceSomePropertiesPresent.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceSomePropertiesPresent.ts new file mode 100644 index 00000000000..6e0658019f5 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceSomePropertiesPresent.ts @@ -0,0 +1,16 @@ +/// + +//// interface I { +//// x: number; +//// y: number; +//// z: number & { __iBrand: any }; +//// } +//// +//// class C implements I {[| |] +//// constructor(public x: number) { } +//// y: number; +//// } + +verify.rangeAfterCodeFix(` +z: number & { __iBrand: any; }; +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts new file mode 100644 index 00000000000..f76bd5dae99 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts @@ -0,0 +1,11 @@ +/// + +//// interface I { +//// x: { y: T, z: T[] }; +//// } +//// +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + x: { y: number; z: number[]; }; +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateError.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateError.ts new file mode 100644 index 00000000000..f4e433e9c0d --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateError.ts @@ -0,0 +1,13 @@ +/// + +//// interface I { +//// x: T; +//// } +//// +//// class C implements I { } + +verify.codeFixAvailable(); + +// TODO: (arozga) Don't know how to instantiate in codeFix +// if instantiation is invalid. +// verify.not.codeFixAvailable(); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts new file mode 100644 index 00000000000..af0e7a162ee --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts @@ -0,0 +1,11 @@ +/// + +//// interface I { +//// x: T; +//// } +//// +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + x: number; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts new file mode 100644 index 00000000000..45fa3fd40ca --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts @@ -0,0 +1,11 @@ +/// + +//// interface I { +//// x: T; +//// } +//// +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + x: T; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts new file mode 100644 index 00000000000..16c35f41773 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts @@ -0,0 +1,11 @@ +/// + +//// interface I { +//// x: T; +//// } +//// +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + x: U; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiation.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiation.ts new file mode 100644 index 00000000000..226aee47833 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiation.ts @@ -0,0 +1,9 @@ +/// + +//// interface I { +//// x: T; +//// } +//// +//// class C implements I { } + +verify.not.codeFixAvailable(); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts new file mode 100644 index 00000000000..4d6afaefedc --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts @@ -0,0 +1,12 @@ +/// + +//// interface I { +//// f(x: T); +//// } +//// +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(`f(x: T){ + throw new Error('Method not implemented.'); +} +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceUndeclaredSymbol.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceUndeclaredSymbol.ts new file mode 100644 index 00000000000..0acf60645c9 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceUndeclaredSymbol.ts @@ -0,0 +1,19 @@ +/// + +//// interface I { +//// x: T; +//// } +//// +//// class C implements I { } + +// T is not a declared symbol. There are a couple fixes: +// 1) Declare T. +// 2) Rename T to an existing symbol. +// 3) Make T a type parameter to I. +// +// In the latter two cases, it is premature to copy `x:T` into C. +// Since we can't guess the programmer's intent here, we do nothing. + +verify.codeFixAvailable(); +// TODO: (aozgaa) Acknowledge other errors on class/implemented interface/extended abstract class. +// verify.not.codeFixAvailable(); \ No newline at end of file diff --git a/tests/cases/fourslash/superFix2.ts b/tests/cases/fourslash/codeFixSuperAfterThis.ts similarity index 76% rename from tests/cases/fourslash/superFix2.ts rename to tests/cases/fourslash/codeFixSuperAfterThis.ts index 880b5d43167..2bff98ceca0 100644 --- a/tests/cases/fourslash/superFix2.ts +++ b/tests/cases/fourslash/codeFixSuperAfterThis.ts @@ -10,4 +10,4 @@ //// } ////} -verify.codeFixAtPosition("super(); this.a = 12;"); \ No newline at end of file +verify.rangeAfterCodeFix("super(); this.a = 12;"); \ No newline at end of file diff --git a/tests/cases/fourslash/server/codefix.ts b/tests/cases/fourslash/codeFixSuperCall.ts similarity index 73% rename from tests/cases/fourslash/server/codefix.ts rename to tests/cases/fourslash/codeFixSuperCall.ts index 9d0f42c9e4c..c918e74dc38 100644 --- a/tests/cases/fourslash/server/codefix.ts +++ b/tests/cases/fourslash/codeFixSuperCall.ts @@ -7,4 +7,4 @@ //// } ////} -verify.codeFixAtPosition('super();'); +verify.rangeAfterCodeFix('super();'); diff --git a/tests/cases/fourslash/superFix3.ts b/tests/cases/fourslash/codeFixSuperCallWithThisInside.ts similarity index 100% rename from tests/cases/fourslash/superFix3.ts rename to tests/cases/fourslash/codeFixSuperCallWithThisInside.ts diff --git a/tests/cases/fourslash/completionForStringLiteral5.ts b/tests/cases/fourslash/completionForStringLiteral5.ts new file mode 100644 index 00000000000..a850ee3aafc --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteral5.ts @@ -0,0 +1,15 @@ +/// + +////interface Foo { +//// foo: string; +//// bar: string; +////} +//// +////function f(a: K) { }; +////f("/*1*/ + +goTo.marker('1'); +verify.completionListContains("foo"); +verify.completionListContains("bar"); +verify.completionListCount(2); + diff --git a/tests/cases/fourslash/completionForStringLiteral6.ts b/tests/cases/fourslash/completionForStringLiteral6.ts new file mode 100644 index 00000000000..ac4a378abfb --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteral6.ts @@ -0,0 +1,12 @@ +/// + +////interface Foo { +//// x: "abc" | "def"; +////} +////function bar(f: Foo) { }; +////bar({x: "/**/"}); + +goTo.marker(); +verify.completionListContains("abc"); +verify.completionListContains("def"); +verify.completionListCount(2); diff --git a/tests/cases/fourslash/completionForStringLiteral7.ts b/tests/cases/fourslash/completionForStringLiteral7.ts new file mode 100644 index 00000000000..b2d250ac3fd --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteral7.ts @@ -0,0 +1,10 @@ +/// + +////type T = "foo" | "bar"; +////type U = "oof" | "rab"; +////function f(x: T, ...args: U[]) { }; +////f("/*1*/", "/*2*/", "/*3*/"); + +verify.completionsAt("1", ["foo", "bar"]); +verify.completionsAt("2", ["oof", "rab"]); +verify.completionsAt("3", ["oof", "rab"]); diff --git a/tests/cases/fourslash/completionListForExportEquals.ts b/tests/cases/fourslash/completionListForExportEquals.ts new file mode 100644 index 00000000000..28b20177c57 --- /dev/null +++ b/tests/cases/fourslash/completionListForExportEquals.ts @@ -0,0 +1,16 @@ + +/// + +// @Filename: /node_modules/foo/index.d.ts +////export = Foo; +////declare var Foo: Foo.Static; +////declare namespace Foo { +//// interface Static { +//// foo(): void; +//// } +////} + +// @Filename: /a.ts +////import { /**/ } from "foo"; + +verify.completionsAt("", ["Static", "foo"]); diff --git a/tests/cases/fourslash/completionListForExportEquals2.ts b/tests/cases/fourslash/completionListForExportEquals2.ts new file mode 100644 index 00000000000..a7b0772d55e --- /dev/null +++ b/tests/cases/fourslash/completionListForExportEquals2.ts @@ -0,0 +1,14 @@ + +/// + +// @Filename: /node_modules/foo/index.d.ts +////export = Foo; +////interface Foo { bar: number; } +////declare namespace Foo { +//// interface Static {} +////} + +// @Filename: /a.ts +////import { /**/ } from "foo"; + +verify.completionsAt("", ["Static"]); diff --git a/tests/cases/fourslash/completionListInImportClause04.ts b/tests/cases/fourslash/completionListInImportClause04.ts index 672c754e807..fa49b57c8d7 100644 --- a/tests/cases/fourslash/completionListInImportClause04.ts +++ b/tests/cases/fourslash/completionListInImportClause04.ts @@ -11,10 +11,7 @@ // @Filename: app.ts ////import {/*1*/} from './foo'; -goTo.marker('1'); -verify.completionListContains('prop1'); -verify.completionListContains('prop2'); -verify.not.completionListContains('Foo'); +verify.completionsAt("1", ["prototype", "prop1", "prop2"]); verify.numberOfErrorsInCurrentFile(0); goTo.marker('2'); verify.numberOfErrorsInCurrentFile(0); diff --git a/tests/cases/fourslash/findAllRefsForRest.ts b/tests/cases/fourslash/findAllRefsForRest.ts index c3a970e9e73..65d6a3c60e3 100644 --- a/tests/cases/fourslash/findAllRefsForRest.ts +++ b/tests/cases/fourslash/findAllRefsForRest.ts @@ -7,6 +7,5 @@ ////let t: Gen; ////var { x, ...rest } = t; ////rest.[|parent|]; -const ranges = test.ranges(); -verify.referencesOf(ranges[0], ranges); -verify.referencesOf(ranges[1], ranges); + +verify.rangesReferenceEachOther(); diff --git a/tests/cases/fourslash/findAllRefsOfConstructor_withModifier.ts b/tests/cases/fourslash/findAllRefsOfConstructor_withModifier.ts new file mode 100644 index 00000000000..0954945a546 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsOfConstructor_withModifier.ts @@ -0,0 +1,10 @@ +/// + +////class X { +//// public [|constructor|]() {} +////} +////var x = new [|X|](); + +const ranges = test.ranges(); +const ctr = ranges[0]; +verify.referencesOf(ctr, ranges); diff --git a/tests/cases/fourslash/formatVariableDeclarationList.ts b/tests/cases/fourslash/formatVariableDeclarationList.ts index 37392d38c62..089eceb1684 100644 --- a/tests/cases/fourslash/formatVariableDeclarationList.ts +++ b/tests/cases/fourslash/formatVariableDeclarationList.ts @@ -37,4 +37,4 @@ verify.currentLineContentIs(" x = 'Foo';"); goTo.marker("11"); verify.currentLineContentIs(" return fun;"); goTo.marker("12"); -verify.currentLineContentIs(" } (fun1));"); +verify.currentLineContentIs(" }(fun1));"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingJsxElements.ts b/tests/cases/fourslash/formattingJsxElements.ts index 2b3b396ed4c..a27bc809456 100644 --- a/tests/cases/fourslash/formattingJsxElements.ts +++ b/tests/cases/fourslash/formattingJsxElements.ts @@ -72,6 +72,8 @@ ////) ;/*closingParenInJsxElement2*/ ////;/*jsxExpressionSpaces*/ ////;/*jsxExpressionSpaces2*/ +//// {}}/*jsxExpressionSpaces3*/ +/////>;/*jsxDanglingSelfClosingToken*/ format.document(); goTo.marker("autoformat"); @@ -120,8 +122,7 @@ goTo.marker("expressionIndent"); verify.indentationIs(12); goTo.marker("danglingBracketAutoformat") -// TODO: verify.currentLineContentIs(" >"); -verify.currentLineContentIs(" >"); +verify.currentLineContentIs(" >"); goTo.marker("closingTagAutoformat"); verify.currentLineContentIs(" "); @@ -145,4 +146,8 @@ verify.currentLineContentIs(") ;"); goTo.marker("jsxExpressionSpaces"); verify.currentLineContentIs(";"); goTo.marker("jsxExpressionSpaces2"); -verify.currentLineContentIs(";"); \ No newline at end of file +verify.currentLineContentIs(";"); +goTo.marker("jsxExpressionSpaces3"); +verify.currentLineContentIs(" { }}"); +goTo.marker("jsxDanglingSelfClosingToken"); +verify.currentLineContentIs("/>;"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingNonNullAssertionOperator.ts b/tests/cases/fourslash/formattingNonNullAssertionOperator.ts new file mode 100644 index 00000000000..2d8b96daaff --- /dev/null +++ b/tests/cases/fourslash/formattingNonNullAssertionOperator.ts @@ -0,0 +1,19 @@ +/// + +/////*1*/ 'bar' ! ; +/////*2*/ ( 'bar' ) ! ; +/////*3*/ 'bar' [ 1 ] ! ; +/////*4*/ var bar = 'bar' . foo ! ; +/////*5*/ var foo = bar ! ; + +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("'bar'!;"); +goTo.marker("2"); +verify.currentLineContentIs("('bar')!;"); +goTo.marker("3"); +verify.currentLineContentIs("'bar'[1]!;"); +goTo.marker("4"); +verify.currentLineContentIs("var bar = 'bar'.foo!;"); +goTo.marker("5"); +verify.currentLineContentIs("var foo = bar!;"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOptionsChange.ts b/tests/cases/fourslash/formattingOptionsChange.ts index 63d51eec0ca..0e731412ede 100644 --- a/tests/cases/fourslash/formattingOptionsChange.ts +++ b/tests/cases/fourslash/formattingOptionsChange.ts @@ -1,33 +1,34 @@ /// -/////*InsertSpaceAfterCommaDelimiter*/[1,2, 3];[ 72 , ]; -/////*InsertSpaceAfterSemicolonInForStatements*/for (i = 0;i; i++); -/////*InsertSpaceBeforeAndAfterBinaryOperators*/1+2- 3 -/////*InsertSpaceAfterKeywordsInControlFlowStatements*/if (true) { } -/////*InsertSpaceAfterFunctionKeywordForAnonymousFunctions*/(function () { }) -/////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis*/(1 ) -/////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets*/[1 ]; [ ]; []; [,]; -/////*InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces*/`${1}`;`${ 1 }` -/////*InsertSpaceAfterTypeAssertion*/const bar = Thing.getFoo(); -/////*PlaceOpenBraceOnNewLineForFunctions*/class foo { +/////*insertSpaceAfterCommaDelimiter*/[1,2, 3];[ 72 , ]; +/////*insertSpaceAfterSemicolonInForStatements*/for (i = 0;i; i++); +/////*insertSpaceBeforeAndAfterBinaryOperators*/1+2- 3 +/////*insertSpaceAfterKeywordsInControlFlowStatements*/if (true) { } +/////*insertSpaceAfterFunctionKeywordForAnonymousFunctions*/(function () { }) +/////*insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis*/(1 ) +/////*insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets*/[1 ]; [ ]; []; [,]; +/////*insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces*/`${1}`;`${ 1 }` +/////*insertSpaceAfterTypeAssertion*/const bar = Thing.getFoo(); +/////*placeOpenBraceOnNewLineForFunctions*/class foo { ////} -/////*PlaceOpenBraceOnNewLineForControlBlocks*/if (true) { +/////*placeOpenBraceOnNewLineForControlBlocks*/if (true) { ////} -/////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces*/{ var t = 1}; +/////*insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces*/{ var t = 1}; var {a,b } = { a: 'sw', b:'r' };function f( { a, b}) { } -runTest("InsertSpaceAfterCommaDelimiter", "[1, 2, 3];[72,];", "[1,2,3];[72,];"); -runTest("InsertSpaceAfterSemicolonInForStatements", "for (i = 0; i; i++);", "for (i = 0;i;i++);"); -runTest("InsertSpaceBeforeAndAfterBinaryOperators", "1 + 2 - 3", "1+2-3"); -runTest("InsertSpaceAfterKeywordsInControlFlowStatements", "if (true) { }", "if(true) { }"); -runTest("InsertSpaceAfterFunctionKeywordForAnonymousFunctions", "(function () { })", "(function() { })"); -runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis", " ( 1 )", " (1)"); -runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets", "[ 1 ];[];[];[ , ];", "[1];[];[];[,];"); -runTest("InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces", "`${ 1 }`; `${ 1 }`", "`${1}`; `${1}`"); -runTest("InsertSpaceAfterTypeAssertion", "const bar = Thing.getFoo();", "const bar = Thing.getFoo();"); -runTest("PlaceOpenBraceOnNewLineForFunctions", "class foo", "class foo {"); -runTest("PlaceOpenBraceOnNewLineForControlBlocks", "if ( true )", "if ( true ) {"); -runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces", "{ var t = 1 };", "{var t = 1};"); +const defaultFormatOption = format.copyFormatOptions(); +runTest("insertSpaceAfterCommaDelimiter", "[1, 2, 3];[72,];", "[1,2,3];[72,];"); +runTest("insertSpaceAfterSemicolonInForStatements", "for (i = 0; i; i++);", "for (i = 0;i;i++);"); +runTest("insertSpaceBeforeAndAfterBinaryOperators", "1 + 2 - 3", "1+2-3"); +runTest("insertSpaceAfterKeywordsInControlFlowStatements", "if (true) { }", "if(true) { }"); +runTest("insertSpaceAfterFunctionKeywordForAnonymousFunctions", "(function () { })", "(function() { })"); +runTest("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis", " ( 1 )", " (1)"); +runTest("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets", "[ 1 ];[];[];[ , ];", "[1];[];[];[,];"); +runTest("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces", "`${ 1 }`; `${ 1 }`", "`${1}`; `${1}`"); +runTest("insertSpaceAfterTypeAssertion", "const bar = Thing.getFoo();", "const bar = Thing.getFoo();"); +runTest("placeOpenBraceOnNewLineForFunctions", "class foo", "class foo {"); +runTest("placeOpenBraceOnNewLineForControlBlocks", "if (true)", "if (true) {"); +runTest("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces", "{ var t = 1 }; var { a, b } = { a: 'sw', b: 'r' }; function f({ a, b }) { }", "{var t = 1}; var {a, b} = {a: 'sw', b: 'r'}; function f({a, b}) {}"); function runTest(propertyName: string, expectedStringWhenTrue: string, expectedStringWhenFalse: string) { // Go to the correct file @@ -52,4 +53,6 @@ function runTest(propertyName: string, expectedStringWhenTrue: string, expectedS // Verify goTo.marker(propertyName); verify.currentLineContentIs(expectedStringWhenTrue); + + format.setOption(propertyName, defaultFormatOption[propertyName]) } \ No newline at end of file diff --git a/tests/cases/fourslash/formattingSpaceBeforeCloseParen.ts b/tests/cases/fourslash/formattingSpaceBeforeCloseParen.ts new file mode 100644 index 00000000000..fb2d648e211 --- /dev/null +++ b/tests/cases/fourslash/formattingSpaceBeforeCloseParen.ts @@ -0,0 +1,33 @@ +/// + +/////*1*/({}); +/////*2*/( {}); +/////*3*/({foo:42}); +/////*4*/( {foo:42} ); +/////*5*/var bar = (function (a) { }); + +format.setOption("InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis", true); +format.document(); +goTo.marker('1'); +verify.currentLineContentIs('( {} );'); +goTo.marker('2'); +verify.currentLineContentIs('( {} );'); +goTo.marker('3'); +verify.currentLineContentIs('( { foo: 42 } );'); +goTo.marker('4'); +verify.currentLineContentIs('( { foo: 42 } );'); +goTo.marker('5'); +verify.currentLineContentIs('var bar = ( function( a ) { } );'); + +format.setOption("InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis", false); +format.document(); +goTo.marker('1'); +verify.currentLineContentIs('({});'); +goTo.marker('2'); +verify.currentLineContentIs('({});'); +goTo.marker('3'); +verify.currentLineContentIs('({ foo: 42 });'); +goTo.marker('4'); +verify.currentLineContentIs('({ foo: 42 });'); +goTo.marker('5'); +verify.currentLineContentIs('var bar = (function(a) { });'); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 745a746db11..ab67abc1bb6 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -43,6 +43,16 @@ // TODO: figure out a better solution to the API exposure problem. declare module ts { + export type MapKey = string | number; + export interface Map { + forEach(action: (value: T, key: string) => void): void; + get(key: MapKey): T; + has(key: MapKey): boolean; + set(key: MapKey, value: T): this; + delete(key: MapKey): boolean; + clear(): void; + } + interface SymbolDisplayPart { text: string; kind: string; @@ -103,14 +113,13 @@ declare namespace FourSlashInterface { markerNames(): string[]; marker(name?: string): Marker; ranges(): Range[]; - rangesByText(): { [text: string]: Range[] }; + rangesByText(): ts.Map; markerByName(s: string): Marker; } class goTo { marker(name?: string): void; bof(): void; eof(): void; - type(definitionIndex?: number): void; implementation(): void; position(position: number, fileIndex?: number): any; position(position: number, fileName?: string): any; @@ -139,6 +148,7 @@ declare namespace FourSlashInterface { class verify extends verifyNegatable { assertHasRanges(ranges: Range[]): void; caretAtMarker(markerName?: string): void; + completionsAt(markerName: string, completions: string[]): void; indentationIs(numberOfSpaces: number): void; indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle?: ts.IndentStyle, baseIndentSize?: number): void; textAtCaretIs(text: string): void; @@ -165,6 +175,8 @@ declare namespace FourSlashInterface { goToDefinition(startsAndEnds: { [startMarkerName: string]: string | string[] }): void; /** Verifies goToDefinition for each `${markerName}Reference` -> `${markerName}Definition` */ goToDefinitionForMarkers(...markerNames: string[]): void; + goToType(startsAndEnds: { [startMarkerName: string]: string | string[] }): void; + goToType(startMarkerNames: string | string[], endMarkerNames: string | string[]): void; verifyGetEmitOutputForCurrentFile(expected: string): void; verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void; /** @@ -208,7 +220,7 @@ declare namespace FourSlashInterface { noMatchingBracePositionInCurrentFile(bracePosition: number): void; DocCommentTemplate(expectedText: string, expectedOffset: number, empty?: boolean): void; noDocCommentTemplate(): void; - codeFixAtPosition(expectedText: string, errorCode?: number): void; + rangeAfterCodeFix(expectedText: string, errorCode?: number): void; importFixAtPosition(expectedTextArray: string[], errorCode?: number): void; navigationBar(json: any): void; @@ -294,9 +306,7 @@ declare namespace FourSlashInterface { setFormatOptions(options: FormatCodeOptions): any; selection(startMarker: string, endMarker: string): void; onType(posMarker: string, key: string): void; - setOption(name: string, value: number): any; - setOption(name: string, value: string): any; - setOption(name: string, value: boolean): any; + setOption(name: string, value: number | string | boolean): void; } class cancellation { resetCancelled(): void; diff --git a/tests/cases/fourslash/goToDefinitionAlias.ts b/tests/cases/fourslash/goToDefinitionAlias.ts index 23cf849f101..22aa049fde3 100644 --- a/tests/cases/fourslash/goToDefinitionAlias.ts +++ b/tests/cases/fourslash/goToDefinitionAlias.ts @@ -1,9 +1,9 @@ /// // @Filename: b.ts -/////*alias1Definition*/import alias1 = require("fileb"); +////import /*alias1Definition*/alias1 = require("fileb"); ////module Module { -//// /*alias2Definition*/export import alias2 = alias1; +//// export import /*alias2Definition*/alias2 = alias1; ////} //// ////// Type position diff --git a/tests/cases/fourslash/goToDefinitionAmbiants.ts b/tests/cases/fourslash/goToDefinitionAmbiants.ts index 57885bed4e9..b0932f0cb07 100644 --- a/tests/cases/fourslash/goToDefinitionAmbiants.ts +++ b/tests/cases/fourslash/goToDefinitionAmbiants.ts @@ -1,11 +1,11 @@ /// ////declare var /*ambientVariableDefinition*/ambientVar; -/////*ambientFunctionDefinition*/declare function ambientFunction(); +////declare function /*ambientFunctionDefinition*/ambientFunction(); ////declare class ambientClass { //// /*constructorDefinition*/constructor(); -//// /*staticMethodDefinition*/static method(); -//// /*instanceMethodDefinition*/public method(); +//// static /*staticMethodDefinition*/method(); +//// public /*instanceMethodDefinition*/method(); ////} //// /////*ambientVariableReference*/ambientVar = 1; diff --git a/tests/cases/fourslash/goToDefinitionDecorator.ts b/tests/cases/fourslash/goToDefinitionDecorator.ts index c86b02ab820..bef9c8fa5f1 100644 --- a/tests/cases/fourslash/goToDefinitionDecorator.ts +++ b/tests/cases/fourslash/goToDefinitionDecorator.ts @@ -9,10 +9,10 @@ // @Filename: a.ts -/////*decoratorDefinition*/function decorator(target) { +////function /*decoratorDefinition*/decorator(target) { //// return target; ////} -/////*decoratorFactoryDefinition*/function decoratorFactory(...args) { +////function /*decoratorFactoryDefinition*/decoratorFactory(...args) { //// return target => target; ////} diff --git a/tests/cases/fourslash/goToDeclarationDecoratorOverloads.ts b/tests/cases/fourslash/goToDefinitionDecoratorOverloads.ts similarity index 72% rename from tests/cases/fourslash/goToDeclarationDecoratorOverloads.ts rename to tests/cases/fourslash/goToDefinitionDecoratorOverloads.ts index c107f7f6803..965c8bbbc6d 100644 --- a/tests/cases/fourslash/goToDeclarationDecoratorOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionDecoratorOverloads.ts @@ -3,8 +3,8 @@ ////async function f() {} //// -/////*defDecString*/function dec(target: any, propertyKey: string): void; -/////*defDecSymbol*/function dec(target: any, propertyKey: symbol): void; +////function /*defDecString*/dec(target: any, propertyKey: string): void; +////function /*defDecSymbol*/dec(target: any, propertyKey: symbol): void; ////function dec(target: any, propertyKey: string | symbol) {} //// ////declare const s: symbol; diff --git a/tests/cases/fourslash/goToDefinitionDifferentFile.ts b/tests/cases/fourslash/goToDefinitionDifferentFile.ts index 1679563942c..67e8c44c84c 100644 --- a/tests/cases/fourslash/goToDefinitionDifferentFile.ts +++ b/tests/cases/fourslash/goToDefinitionDifferentFile.ts @@ -2,10 +2,10 @@ // @Filename: goToDefinitionDifferentFile_Definition.ts ////var /*remoteVariableDefinition*/remoteVariable; -/////*remoteFunctionDefinition*/function remoteFunction() { } -/////*remoteClassDefinition*/class remoteClass { } -/////*remoteInterfaceDefinition*/interface remoteInterface{ } -/////*remoteModuleDefinition*/module remoteModule{ export var foo = 1;} +////function /*remoteFunctionDefinition*/remoteFunction() { } +////class /*remoteClassDefinition*/remoteClass { } +////interface /*remoteInterfaceDefinition*/remoteInterface{ } +////module /*remoteModuleDefinition*/remoteModule{ export var foo = 1;} // @Filename: goToDefinitionDifferentFile_Consumption.ts /////*remoteVariableReference*/remoteVariable = 1; diff --git a/tests/cases/fourslash/goToDefinitionDifferentFileIndirectly.ts b/tests/cases/fourslash/goToDefinitionDifferentFileIndirectly.ts index 96a65a22033..f577712c930 100644 --- a/tests/cases/fourslash/goToDefinitionDifferentFileIndirectly.ts +++ b/tests/cases/fourslash/goToDefinitionDifferentFileIndirectly.ts @@ -2,10 +2,10 @@ // @Filename: Remote2.ts ////var /*remoteVariableDefinition*/rem2Var; -/////*remoteFunctionDefinition*/function rem2Fn() { } -/////*remoteClassDefinition*/class rem2Cls { } -/////*remoteInterfaceDefinition*/interface rem2Int{} -/////*remoteModuleDefinition*/module rem2Mod { export var foo; } +////function /*remoteFunctionDefinition*/rem2Fn() { } +////class /*remoteClassDefinition*/rem2Cls { } +////interface /*remoteInterfaceDefinition*/rem2Int{} +////module /*remoteModuleDefinition*/rem2Mod { export var foo; } // @Filename: Remote1.ts ////var remVar; diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName3.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName3.ts index afd3b4054a2..7ac0376474d 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName3.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName3.ts @@ -5,7 +5,7 @@ ////var x = new n.Foo(); // @Filename: a.ts -/////*2*/declare module "e" { +////declare module /*2*/"e" { //// class Foo { } ////} diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName5.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName5.ts index ae9343a8f5b..36ae9dd716f 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName5.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName5.ts @@ -1,7 +1,7 @@ /// // @Filename: a.ts -/////*2*/declare module "external/*1*/" { +////declare module /*2*/"external/*1*/" { //// class Foo { } ////} diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName6.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName6.ts index 03c3a23febc..a71030628e6 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName6.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName6.ts @@ -4,7 +4,7 @@ ////import * from 'e/*1*/'; // @Filename: a.ts -/////*2*/declare module "e" { +////declare module /*2*/"e" { //// class Foo { } ////} diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName7.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName7.ts index 4c82099ab20..b025944d012 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName7.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName7.ts @@ -4,7 +4,7 @@ ////import {Foo, Bar} from 'e/*1*/'; // @Filename: a.ts -/////*2*/declare module "e" { +////declare module /*2*/"e" { //// class Foo { } ////} diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName8.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName8.ts index 5eab37e8393..ca9d7c83e66 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName8.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName8.ts @@ -4,7 +4,7 @@ ////export {Foo, Bar} from 'e/*1*/'; // @Filename: a.ts -/////*2*/declare module "e" { +////declare module /*2*/"e" { //// class Foo { } ////} diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName9.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName9.ts index 9e0c1b4986e..80971be100f 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName9.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName9.ts @@ -4,7 +4,7 @@ ////export * from 'e/*1*/'; // @Filename: a.ts -/////*2*/declare module "e" { +////declare module /*2*/"e" { //// class Foo { } ////} diff --git a/tests/cases/fourslash/goToDefinitionFoo.ts b/tests/cases/fourslash/goToDefinitionFoo.ts new file mode 100644 index 00000000000..3e05ee20ecb --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionFoo.ts @@ -0,0 +1,6 @@ +/// + +////function /*def*/f() {} +/////*use*/f(123); + +verify.goToDefinition("use", "def"); diff --git a/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts b/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts index e30150a1f45..60c7a8111ee 100644 --- a/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts @@ -1,8 +1,8 @@ /// -/////*functionOverload1*/function /*functionOverload*/functionOverload(value: number); -/////*functionOverload2*/function functionOverload(value: string); -/////*functionOverloadDefinition*/function functionOverload() {} +////function /*functionOverload1*/functionOverload(value: number); +////function /*functionOverload2*/functionOverload(value: string); +////function /*functionOverloadDefinition*/functionOverload() {} //// /////*functionOverloadReference1*/functionOverload(123); /////*functionOverloadReference2*/functionOverload("123"); @@ -12,5 +12,5 @@ verify.goToDefinition({ functionOverloadReference1: "functionOverload1", functionOverloadReference2: "functionOverload2", brokenOverload: "functionOverload1", - functionOverload: "functionOverloadDefinition" + functionOverload1: "functionOverloadDefinition" }); diff --git a/tests/cases/fourslash/goToDefinitionFunctionOverloadsInClass.ts b/tests/cases/fourslash/goToDefinitionFunctionOverloadsInClass.ts index 3426a4d5e1e..04017123fd8 100644 --- a/tests/cases/fourslash/goToDefinitionFunctionOverloadsInClass.ts +++ b/tests/cases/fourslash/goToDefinitionFunctionOverloadsInClass.ts @@ -3,10 +3,10 @@ ////class clsInOverload { //// static fnOverload(); //// static /*staticFunctionOverload*/fnOverload(foo: string); -//// /*staticFunctionOverloadDefinition*/static fnOverload(foo: any) { } +//// static /*staticFunctionOverloadDefinition*/fnOverload(foo: any) { } //// public /*functionOverload*/fnOverload(): any; //// public fnOverload(foo: string); -//// /*functionOverloadDefinition*/public fnOverload(foo: any) { return "foo" } +//// public /*functionOverloadDefinition*/fnOverload(foo: any) { return "foo" } //// //// constructor() { } ////} diff --git a/tests/cases/fourslash/goToDefinitionImplicitConstructor.ts b/tests/cases/fourslash/goToDefinitionImplicitConstructor.ts index bf24e35307f..2d1dde785a7 100644 --- a/tests/cases/fourslash/goToDefinitionImplicitConstructor.ts +++ b/tests/cases/fourslash/goToDefinitionImplicitConstructor.ts @@ -1,6 +1,6 @@ /// -/////*constructorDefinition*/class ImplicitConstructor { +////class /*constructorDefinition*/ImplicitConstructor { ////} ////var implicitConstructor = new /*constructorReference*/ImplicitConstructor(); diff --git a/tests/cases/fourslash/goToDefinitionImportedNames.ts b/tests/cases/fourslash/goToDefinitionImportedNames.ts index b7374d00f18..41a1c443b28 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames.ts @@ -7,7 +7,7 @@ // @Filename: a.ts ////export module Module { ////} -/////*classDefinition*/export class Class { +////export class /*classDefinition*/Class { //// private f; ////} ////export interface Interface { diff --git a/tests/cases/fourslash/goToDefinitionImportedNames2.ts b/tests/cases/fourslash/goToDefinitionImportedNames2.ts index b0b8776ee37..fa3c5c862b7 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames2.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames2.ts @@ -7,7 +7,7 @@ // @Filename: a.ts ////export module Module { ////} -/////*classDefinition*/export class Class { +////export class /*classDefinition*/Class { //// private f; ////} ////export interface Interface { diff --git a/tests/cases/fourslash/goToDefinitionImportedNames3.ts b/tests/cases/fourslash/goToDefinitionImportedNames3.ts index f8016464360..b9f598f30cd 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames3.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames3.ts @@ -20,7 +20,7 @@ // @Filename: a.ts ////export module Module { ////} -/////*classDefinition*/export class Class { +////export class /*classDefinition*/Class { //// private f; ////} ////export interface Interface { diff --git a/tests/cases/fourslash/goToDefinitionImportedNames4.ts b/tests/cases/fourslash/goToDefinitionImportedNames4.ts index 4b6b019cfae..81f2e671266 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames4.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames4.ts @@ -7,7 +7,7 @@ // @Filename: a.ts ////export module Module { ////} -/////*classDefinition*/export class Class { +////export class /*classDefinition*/Class { //// private f; ////} ////export interface Interface { diff --git a/tests/cases/fourslash/goToDefinitionImportedNames5.ts b/tests/cases/fourslash/goToDefinitionImportedNames5.ts index 5add12ae0bc..b78110c95d9 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames5.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames5.ts @@ -7,7 +7,7 @@ // @Filename: a.ts ////export module Module { ////} -/////*classDefinition*/export class Class { +////export class /*classDefinition*/Class { //// private f; ////} ////export interface Interface { diff --git a/tests/cases/fourslash/goToDefinitionImportedNames7.ts b/tests/cases/fourslash/goToDefinitionImportedNames7.ts index 86be4af3d85..bdf1eff86eb 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames7.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames7.ts @@ -5,7 +5,7 @@ // @Filename: a.ts -/////*classDefinition*/class Class { +////class /*classDefinition*/Class { //// private f; ////} ////export default Class; diff --git a/tests/cases/fourslash/goToDefinitionInMemberDeclaration.ts b/tests/cases/fourslash/goToDefinitionInMemberDeclaration.ts index 66719bb621b..93be2086440 100644 --- a/tests/cases/fourslash/goToDefinitionInMemberDeclaration.ts +++ b/tests/cases/fourslash/goToDefinitionInMemberDeclaration.ts @@ -1,14 +1,14 @@ /// -/////*interfaceDefinition*/interface IFoo { method1(): number; } +////interface /*interfaceDefinition*/IFoo { method1(): number; } //// -/////*classDefinition*/class Foo implements IFoo { +////class /*classDefinition*/Foo implements IFoo { //// public method1(): number { return 0; } ////} //// -/////*enumDefinition*/enum Enum { value1, value2 }; +////enum /*enumDefinition*/Enum { value1, value2 }; //// -/////*selfDefinition*/class Bar { +////class /*selfDefinition*/Bar { //// public _interface: IFo/*interfaceReference*/o = new Fo/*classReferenceInInitializer*/o(); //// public _class: Fo/*classReference*/o = new Foo(); //// public _list: IF/*interfaceReferenceInList*/oo[]=[]; diff --git a/tests/cases/fourslash/goToDefinitionInTypeArgument.ts b/tests/cases/fourslash/goToDefinitionInTypeArgument.ts index 343b5810df3..a9bddeda434 100644 --- a/tests/cases/fourslash/goToDefinitionInTypeArgument.ts +++ b/tests/cases/fourslash/goToDefinitionInTypeArgument.ts @@ -1,8 +1,8 @@ /// -/////*fooDefinition*/class Foo { } +////class /*fooDefinition*/Foo { } //// -/////*barDefinition*/class Bar { } +////class /*barDefinition*/Bar { } //// ////var x = new Fo/*fooReference*/o(); diff --git a/tests/cases/fourslash/goToDefinitionInterfaceAfterImplement.ts b/tests/cases/fourslash/goToDefinitionInterfaceAfterImplement.ts index 585cc187e48..46d9e0182a4 100644 --- a/tests/cases/fourslash/goToDefinitionInterfaceAfterImplement.ts +++ b/tests/cases/fourslash/goToDefinitionInterfaceAfterImplement.ts @@ -1,6 +1,6 @@ /// -/////*interfaceDefinition*/interface sInt { +////interface /*interfaceDefinition*/sInt { //// sVar: number; //// sFn: () => void; ////} diff --git a/tests/cases/fourslash/goToDefinitionMethodOverloads.ts b/tests/cases/fourslash/goToDefinitionMethodOverloads.ts index 199b5aee226..4dfe4753ce7 100644 --- a/tests/cases/fourslash/goToDefinitionMethodOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionMethodOverloads.ts @@ -1,12 +1,12 @@ /// ////class MethodOverload { -//// /*staticMethodOverload1*/static /*staticMethodOverload1Name*/method(); -//// /*staticMethodOverload2*/static method(foo: string); -//// /*staticMethodDefinition*/static method(foo?: any) { } -//// /*instanceMethodOverload1*/public /*instanceMethodOverload1Name*/method(): any; -//// /*instanceMethodOverload2*/public method(foo: string); -/////*instanceMethodDefinition*/public method(foo?: any) { return "foo" } +//// static /*staticMethodOverload1*/method(); +//// static /*staticMethodOverload2*/method(foo: string); +//// static /*staticMethodDefinition*/method(foo?: any) { } +//// public /*instanceMethodOverload1*/method(): any; +//// public /*instanceMethodOverload2*/method(foo: string); +//// public /*instanceMethodDefinition*/method(foo?: any) { return "foo" } ////} ////// static method @@ -23,6 +23,6 @@ verify.goToDefinition({ staticMethodReference2: "staticMethodOverload2", instanceMethodReference1: "instanceMethodOverload1", instanceMethodReference2: "instanceMethodOverload2", - staticMethodOverload1Name: "staticMethodDefinition", - instanceMethodOverload1Name: "instanceMethodDefinition" + staticMethodOverload1: "staticMethodDefinition", + instanceMethodOverload1: "instanceMethodDefinition" }); diff --git a/tests/cases/fourslash/goToDefinitionMultipleDefinitions.ts b/tests/cases/fourslash/goToDefinitionMultipleDefinitions.ts index 7b2cf6e7a85..fb022f7711f 100644 --- a/tests/cases/fourslash/goToDefinitionMultipleDefinitions.ts +++ b/tests/cases/fourslash/goToDefinitionMultipleDefinitions.ts @@ -1,16 +1,16 @@ /// // @Filename: a.ts -/////*interfaceDefinition1*/interface IFoo { +////interface /*interfaceDefinition1*/IFoo { //// instance1: number; ////} // @Filename: b.ts -/////*interfaceDefinition2*/interface IFoo { +////interface /*interfaceDefinition2*/IFoo { //// instance2: number; ////} //// -/////*interfaceDefinition3*/interface IFoo { +////interface /*interfaceDefinition3*/IFoo { //// instance3: number; ////} //// @@ -19,12 +19,12 @@ verify.goToDefinition("interfaceReference", ["interfaceDefinition1", "interfaceDefinition2", "interfaceDefinition3"]); // @Filename: c.ts -/////*moduleDefinition1*/module Module { +////module /*moduleDefinition1*/Module { //// export class c1 { } ////} // @Filename: d.ts -/////*moduleDefinition2*/module Module { +////module /*moduleDefinition2*/Module { //// export class c2 { } ////} diff --git a/tests/cases/fourslash/goToDefinitionObjectLiteralProperties.ts b/tests/cases/fourslash/goToDefinitionObjectLiteralProperties.ts index 8523df2111b..d430df3433d 100644 --- a/tests/cases/fourslash/goToDefinitionObjectLiteralProperties.ts +++ b/tests/cases/fourslash/goToDefinitionObjectLiteralProperties.ts @@ -2,8 +2,8 @@ ////var o = { //// /*valueDefinition*/value: 0, -//// /*getterDefinition*/get getter() {return 0 }, -//// /*setterDefinition*/set setter(v: number) { }, +//// get /*getterDefinition*/getter() {return 0 }, +//// set /*setterDefinition*/setter(v: number) { }, //// /*methodDefinition*/method: () => { }, //// /*es6StyleMethodDefinition*/es6StyleMethod() { } ////}; diff --git a/tests/cases/fourslash/goToDefinitionOverloadsInMultiplePropertyAccesses.ts b/tests/cases/fourslash/goToDefinitionOverloadsInMultiplePropertyAccesses.ts index 63c23cfe46f..04a07f41a7f 100644 --- a/tests/cases/fourslash/goToDefinitionOverloadsInMultiplePropertyAccesses.ts +++ b/tests/cases/fourslash/goToDefinitionOverloadsInMultiplePropertyAccesses.ts @@ -5,7 +5,7 @@ ////namespace A { //// export namespace B { //// export function f(value: number): void; -//// /*1*/export function f(value: string): void; +//// export function /*1*/f(value: string): void; //// export function f(value: number | string) {} //// } ////} diff --git a/tests/cases/fourslash/goToDefinitionPartialImplementation.ts b/tests/cases/fourslash/goToDefinitionPartialImplementation.ts index 90402b3f8e6..81f19b578ed 100644 --- a/tests/cases/fourslash/goToDefinitionPartialImplementation.ts +++ b/tests/cases/fourslash/goToDefinitionPartialImplementation.ts @@ -2,14 +2,14 @@ // @Filename: goToDefinitionPartialImplementation_1.ts ////module A { -//// /*Part1Definition*/export interface IA { +//// export interface /*Part1Definition*/IA { //// y: string; //// } ////} // @Filename: goToDefinitionPartialImplementation_2.ts ////module A { -//// /*Part2Definition*/export interface IA { +//// export interface /*Part2Definition*/IA { //// x: number; //// } //// diff --git a/tests/cases/fourslash/goToDefinitionSameFile.ts b/tests/cases/fourslash/goToDefinitionSameFile.ts index 6bbdaf3a189..e9b8b211bf7 100644 --- a/tests/cases/fourslash/goToDefinitionSameFile.ts +++ b/tests/cases/fourslash/goToDefinitionSameFile.ts @@ -1,10 +1,10 @@ /// ////var /*localVariableDefinition*/localVariable; -/////*localFunctionDefinition*/function localFunction() { } -/////*localClassDefinition*/class localClass { } -/////*localInterfaceDefinition*/interface localInterface{ } -/////*localModuleDefinition*/module localModule{ export var foo = 1;} +////function /*localFunctionDefinition*/localFunction() { } +////class /*localClassDefinition*/localClass { } +////interface /*localInterfaceDefinition*/localInterface{ } +////module /*localModuleDefinition*/localModule{ export var foo = 1;} //// //// /////*localVariableReference*/localVariable = 1; diff --git a/tests/cases/fourslash/goToDefinitionSimple.ts b/tests/cases/fourslash/goToDefinitionSimple.ts index 39aa8ecfca9..9ae02f26bf2 100644 --- a/tests/cases/fourslash/goToDefinitionSimple.ts +++ b/tests/cases/fourslash/goToDefinitionSimple.ts @@ -1,7 +1,7 @@ /// // @Filename: Definition.ts -//// /*2*/class c { } +////class /*2*/c { } // @Filename: Consumption.ts //// var n = new /*1*/c(); diff --git a/tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts b/tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts index fad27cabbb6..b01bace4feb 100644 --- a/tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts @@ -1,7 +1,7 @@ /// -/////*defFNumber*/function f(strs: TemplateStringsArray, x: number): void; -/////*defFBool*/function f(strs: TemplateStringsArray, x: boolean): void; +////function /*defFNumber*/f(strs: TemplateStringsArray, x: number): void; +////function /*defFBool*/f(strs: TemplateStringsArray, x: boolean): void; ////function f(strs: TemplateStringsArray, x: number | boolean) {} //// /////*useFNumber*/f`${0}`; diff --git a/tests/cases/fourslash/goToDefinitionThis.ts b/tests/cases/fourslash/goToDefinitionThis.ts index 5cb94ef35c7..923fb6c8feb 100644 --- a/tests/cases/fourslash/goToDefinitionThis.ts +++ b/tests/cases/fourslash/goToDefinitionThis.ts @@ -3,7 +3,7 @@ ////function f(/*fnDecl*/this: number) { //// return /*fnUse*/this; ////} -/////*cls*/class C { +////class /*cls*/C { //// constructor() { return /*clsUse*/this; } //// get self(/*getterDecl*/this: number) { return /*getterUse*/this; } ////} diff --git a/tests/cases/fourslash/goToDefinitionTypePredicate.ts b/tests/cases/fourslash/goToDefinitionTypePredicate.ts index dd2b69f37e8..17e6fc1be6b 100644 --- a/tests/cases/fourslash/goToDefinitionTypePredicate.ts +++ b/tests/cases/fourslash/goToDefinitionTypePredicate.ts @@ -1,6 +1,6 @@ /// -//// /*classDeclaration*/class A {} +//// class /*classDeclaration*/A {} //// function f(/*parameterDeclaration*/parameter: any): /*parameterName*/parameter is /*typeReference*/A { //// return typeof parameter === "string"; //// } diff --git a/tests/cases/fourslash/goToDefinition_super.ts b/tests/cases/fourslash/goToDefinition_super.ts index 7a7008ba07f..115e4a4a6ed 100644 --- a/tests/cases/fourslash/goToDefinition_super.ts +++ b/tests/cases/fourslash/goToDefinition_super.ts @@ -4,7 +4,7 @@ //// /*ctr*/constructor() {} //// x() {} ////} -/////*B*/class B extends A {} +////class /*B*/B extends A {} ////class C extends B { //// constructor() { //// /*super*/super(); diff --git a/tests/cases/fourslash/goToModuleAliasDefinition.ts b/tests/cases/fourslash/goToModuleAliasDefinition.ts index cdec82fd0d4..dfccc3393c5 100644 --- a/tests/cases/fourslash/goToModuleAliasDefinition.ts +++ b/tests/cases/fourslash/goToModuleAliasDefinition.ts @@ -1,10 +1,10 @@ /// // @Filename: a.ts -//// /*2*/export class Foo {} +////export class /*2*/Foo {} // @Filename: b.ts -//// /*3*/import n = require('a'); +//// import /*3*/n = require('a'); //// var x = new /*1*/n.Foo(); // Won't-fixed: Should go to '2' instead diff --git a/tests/cases/fourslash/goToTypeDefinition.ts b/tests/cases/fourslash/goToTypeDefinition.ts index 6b34e7e4886..b6bbd839003 100644 --- a/tests/cases/fourslash/goToTypeDefinition.ts +++ b/tests/cases/fourslash/goToTypeDefinition.ts @@ -1,7 +1,7 @@ /// // @Filename: goToTypeDefinition_Definition.ts -/////*definition*/class C { +////class /*definition*/C { //// p; ////} ////var c: C; @@ -9,6 +9,4 @@ // @Filename: goToTypeDefinition_Consumption.ts /////*reference*/c = undefined; -goTo.marker('reference'); -goTo.type(); -verify.caretAtMarker('definition'); +verify.goToType("reference", "definition"); diff --git a/tests/cases/fourslash/goToTypeDefinition2.ts b/tests/cases/fourslash/goToTypeDefinition2.ts index 8c76655f4a8..4f93edcd68a 100644 --- a/tests/cases/fourslash/goToTypeDefinition2.ts +++ b/tests/cases/fourslash/goToTypeDefinition2.ts @@ -1,7 +1,7 @@ /// // @Filename: goToTypeDefinition2_Definition.ts -/////*definition*/interface I1 { +////interface /*definition*/I1 { //// p; ////} ////type propertyType = I1; @@ -13,6 +13,4 @@ ////var i2: I2; ////i2.prop/*reference*/erty; -goTo.marker('reference'); -goTo.type(); -verify.caretAtMarker('definition'); +verify.goToType("reference", "definition"); diff --git a/tests/cases/fourslash/goToTypeDefinitionAliases.ts b/tests/cases/fourslash/goToTypeDefinitionAliases.ts index da9d3d5a84e..89dacedc7aa 100644 --- a/tests/cases/fourslash/goToTypeDefinitionAliases.ts +++ b/tests/cases/fourslash/goToTypeDefinitionAliases.ts @@ -1,7 +1,7 @@ /// // @Filename: goToTypeDefinitioAliases_module1.ts -/////*definition*/interface I { +////interface /*definition*/I { //// p; ////} ////export {I as I2}; @@ -15,10 +15,7 @@ ////import {/*reference1*/v2 as v3} from "./goToTypeDefinitioAliases_module2"; /////*reference2*/v3; -goTo.marker('reference1'); -goTo.type(); -verify.caretAtMarker('definition'); - -goTo.marker('reference2'); -goTo.type(); -verify.caretAtMarker('definition'); +verify.goToType({ + reference1: "definition", + reference2: "definition" +}); diff --git a/tests/cases/fourslash/goToTypeDefinitionEnumMembers.ts b/tests/cases/fourslash/goToTypeDefinitionEnumMembers.ts index 1c2a0259d58..d4f89d29ee8 100644 --- a/tests/cases/fourslash/goToTypeDefinitionEnumMembers.ts +++ b/tests/cases/fourslash/goToTypeDefinitionEnumMembers.ts @@ -8,6 +8,4 @@ //// /////*reference*/x; -goTo.marker('reference'); -goTo.type(); -verify.caretAtMarker('definition'); +verify.goToType("reference", "definition"); diff --git a/tests/cases/fourslash/goToTypeDefinitionModule.ts b/tests/cases/fourslash/goToTypeDefinitionModule.ts index 2afccab97c3..00e0fa82a09 100644 --- a/tests/cases/fourslash/goToTypeDefinitionModule.ts +++ b/tests/cases/fourslash/goToTypeDefinitionModule.ts @@ -1,19 +1,16 @@ /// -// @Filename: goToTypeDefinitioAliases_module1.ts -/////*definition*/module M { +// @Filename: module1.ts +////module /*definition*/M { //// export var p; ////} ////var m: typeof M; -// @Filename: goToTypeDefinitioAliases_module3.ts +// @Filename: module3.ts /////*reference1*/M; /////*reference2*/m; -goTo.marker('reference1'); -goTo.type(); -verify.caretAtMarker('definition'); - -goTo.marker('reference2'); -goTo.type(); -verify.caretAtMarker('definition'); \ No newline at end of file +verify.goToType({ + reference1: "definition", + reference2: "definition" +}); diff --git a/tests/cases/fourslash/goToTypeDefinitionPrimitives.ts b/tests/cases/fourslash/goToTypeDefinitionPrimitives.ts index d38a0c16343..0b6f6903524 100644 --- a/tests/cases/fourslash/goToTypeDefinitionPrimitives.ts +++ b/tests/cases/fourslash/goToTypeDefinitionPrimitives.ts @@ -12,14 +12,9 @@ /////*reference3*/y; /////*reference4*/y; -goTo.marker('reference1'); -verify.typeDefinitionCountIs(0); - -goTo.marker('reference1'); -verify.typeDefinitionCountIs(0); - -goTo.marker('reference2'); -verify.typeDefinitionCountIs(0); - -goTo.marker('reference4'); -verify.typeDefinitionCountIs(0); +verify.goToType({ + reference1: [], + reference2: [], + reference3: [], + reference4: [] +}); diff --git a/tests/cases/fourslash/goToTypeDefinitionUnionType.ts b/tests/cases/fourslash/goToTypeDefinitionUnionType.ts index 0630ae3ebb9..5658ce77b64 100644 --- a/tests/cases/fourslash/goToTypeDefinitionUnionType.ts +++ b/tests/cases/fourslash/goToTypeDefinitionUnionType.ts @@ -1,15 +1,15 @@ /// -/////*definition0*/class C { +////class /*definition0*/C { //// p; ////} //// -/////*definition1*/interface I { +////interface /*definition1*/I { //// x; ////} //// ////module M { -//// /*definition2*/export interface I { +//// export interface /*definition2*/I { //// y; //// } ////} @@ -18,14 +18,4 @@ //// /////*reference*/x; -goTo.marker('reference'); -goTo.type(0); -verify.caretAtMarker('definition0'); - -goTo.marker('reference'); -goTo.type(1); -verify.caretAtMarker('definition1'); - -goTo.marker('reference'); -goTo.type(2); -verify.caretAtMarker('definition2'); +verify.goToType("reference", ["definition0", "definition1", "definition2"]); diff --git a/tests/cases/fourslash/importNameCodeFixNewImportPaths2.ts b/tests/cases/fourslash/importNameCodeFixNewImportPaths2.ts new file mode 100644 index 00000000000..b455538de08 --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFixNewImportPaths2.ts @@ -0,0 +1,28 @@ +/// + +//// [|foo/*0*/();|] + +// @Filename: folder_b/index.ts +//// export function foo() {}; + +// @Filename: tsconfig.path.json +//// { +//// "compilerOptions": { +//// "baseUrl": ".", +//// "paths": { +//// "b": [ "folder_b/index" ] +//// } +//// } +//// } + +// @Filename: tsconfig.json +//// { +//// "extends": "./tsconfig.path", +//// "compilerOptions": { } +//// } + +verify.importFixAtPosition([ +`import { foo } from "b"; + +foo();` +]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots1.ts b/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots1.ts new file mode 100644 index 00000000000..2778f51bacf --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots1.ts @@ -0,0 +1,23 @@ +/// + +// @Filename: a/f1.ts +//// [|foo/*0*/();|] + +// @Filename: types/random/index.ts +//// export function foo() {}; + +// @Filename: tsconfig.json +//// { +//// "compilerOptions": { +//// "baseUrl": ".", +//// "typeRoots": [ +//// "./types" +//// ] +//// } +//// } + +verify.importFixAtPosition([ +`import { foo } from "random"; + +foo();` +]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixUMDGlobal0.ts b/tests/cases/fourslash/importNameCodeFixUMDGlobal0.ts new file mode 100644 index 00000000000..3c780dc0af6 --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFixUMDGlobal0.ts @@ -0,0 +1,16 @@ +/// + +// @Filename: a/f1.ts +//// [|export function test() { }; +//// bar1/*0*/.bar;|] + +// @Filename: a/foo.d.ts +//// export declare function bar(): number; +//// export as namespace bar1; + +verify.importFixAtPosition([ +`import * as bar1 from "./foo"; + +export function test() { }; +bar1.bar;` +]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixUMDGlobal1.ts b/tests/cases/fourslash/importNameCodeFixUMDGlobal1.ts new file mode 100644 index 00000000000..96671ad6f91 --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFixUMDGlobal1.ts @@ -0,0 +1,19 @@ +/// + +// @Filename: a/f1.ts +//// [|import { bar } from "./foo"; +//// +//// export function test() { }; +//// bar1/*0*/.bar();|] + +// @Filename: a/foo.d.ts +//// export declare function bar(): number; +//// export as namespace bar1; + +verify.importFixAtPosition([ +`import { bar } from "./foo"; +import * as bar1 from "./foo"; + +export function test() { }; +bar1.bar();` +]); \ No newline at end of file diff --git a/tests/cases/fourslash/localGetReferences.ts b/tests/cases/fourslash/localGetReferences.ts index b05346a366a..fa9e59cabcf 100644 --- a/tests/cases/fourslash/localGetReferences.ts +++ b/tests/cases/fourslash/localGetReferences.ts @@ -202,15 +202,14 @@ goTo.marker("4"); verify.referencesAre([]); const rangesByText = test.rangesByText(); -for (const text in rangesByText) { - const ranges = rangesByText[text]; +rangesByText.forEach((ranges, text) => { if (text === "globalVar") { verify.rangesReferenceEachOther(ranges.filter(isShadow)); verify.rangesReferenceEachOther(ranges.filter(r => !isShadow(r))); } else { verify.rangesReferenceEachOther(ranges); } -} +}); function isShadow(r) { return r.marker && r.marker.data && r.marker.data.shadow; diff --git a/tests/cases/fourslash/navigationBarItemsFunctionProperties.ts b/tests/cases/fourslash/navigationBarItemsFunctionProperties.ts index 75c20736b41..9844f53d879 100644 --- a/tests/cases/fourslash/navigationBarItemsFunctionProperties.ts +++ b/tests/cases/fourslash/navigationBarItemsFunctionProperties.ts @@ -6,10 +6,6 @@ //// .a = function() { }; //// })(); -function navExact(name: string, kind: string) { - return; -} - verify.navigationTree( { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsNamedArrowFunctions.ts b/tests/cases/fourslash/navigationBarItemsNamedArrowFunctions.ts new file mode 100644 index 00000000000..32abf4092c7 --- /dev/null +++ b/tests/cases/fourslash/navigationBarItemsNamedArrowFunctions.ts @@ -0,0 +1,78 @@ +/// + +////export const value = 2; +////export const func = () => 2; +////export const func2 = function() { }; +////export function exportedFunction() { } + +verify.navigationBar([ + { + "text": "\"navigationBarItemsNamedArrowFunctions\"", + "kind": "module", + "childItems": [ + { + "text": "exportedFunction", + "kind": "function", + "kindModifiers": "export" + }, + { + "text": "func", + "kind": "function" + }, + { + "text": "func2", + "kind": "function" + }, + { + "text": "value", + "kind": "const", + "kindModifiers": "export" + } + ] + }, + { + "text": "exportedFunction", + "kind": "function", + "kindModifiers": "export", + "indent": 1 + }, + { + "text": "func", + "kind": "function", + "kindModifiers": "export", + "indent": 1 + }, + { + "text": "func2", + "kind": "function", + "kindModifiers": "export", + "indent": 1 + } +]); + +verify.navigationTree({ + "text": "\"navigationBarItemsNamedArrowFunctions\"", + "kind": "module", + "childItems": [ + { + "text": "exportedFunction", + "kind": "function", + "kindModifiers": "export" + }, + { + "text": "func", + "kind": "function", + "kindModifiers": "export" + }, + { + "text": "func2", + "kind": "function", + "kindModifiers": "export" + }, + { + "text": "value", + "kind": "const", + "kindModifiers": "export" + } + ] +}); diff --git a/tests/cases/fourslash/quickInfoMeaning.ts b/tests/cases/fourslash/quickInfoMeaning.ts index 390dc367959..414fcc0c86d 100644 --- a/tests/cases/fourslash/quickInfoMeaning.ts +++ b/tests/cases/fourslash/quickInfoMeaning.ts @@ -14,7 +14,7 @@ // @Filename: foo_user.ts /////// -/////*foo_type_declaration*/import foo = require("foo_module"); +////import /*foo_type_declaration*/foo = require("foo_module"); ////const x = foo/*foo_value*/; ////const i: foo/*foo_type*/ = { x: 1, y: 2 }; @@ -37,7 +37,7 @@ verify.goToDefinitionIs("foo_type_declaration"); // @Filename: bar.d.ts -/////*bar_type_declaration*/declare interface bar { x: number; y: number } +////declare interface /*bar_type_declaration*/bar { x: number; y: number } ////declare module "bar_module" { //// const x: number; //// export = x; @@ -45,7 +45,7 @@ verify.goToDefinitionIs("foo_type_declaration"); // @Filename: bar_user.ts /////// -/////*bar_value_declaration*/import bar = require("bar_module"); +////import /*bar_value_declaration*/bar = require("bar_module"); ////const x = bar/*bar_value*/; ////const i: bar/*bar_type*/ = { x: 1, y: 2 }; diff --git a/tests/cases/fourslash/server/jsdocTypedefTagGoToDefinition.ts b/tests/cases/fourslash/server/jsdocTypedefTagGoToDefinition.ts index 2183c8d5471..000adef9081 100644 --- a/tests/cases/fourslash/server/jsdocTypedefTagGoToDefinition.ts +++ b/tests/cases/fourslash/server/jsdocTypedefTagGoToDefinition.ts @@ -5,7 +5,7 @@ //// /** //// * @typedef {Object} Person -//// * /*1*/@property {string} personName +//// * @property {string} /*1*/personName //// * @property {number} personAge //// */ //// diff --git a/tests/cases/fourslash/server/typedefinition01.ts b/tests/cases/fourslash/server/typedefinition01.ts index bde9f4dc4d8..40e1dcf43bb 100644 --- a/tests/cases/fourslash/server/typedefinition01.ts +++ b/tests/cases/fourslash/server/typedefinition01.ts @@ -5,8 +5,6 @@ ////var x/*1*/ = new n.Foo(); // @Filename: a.ts -//// /*2*/export class Foo {} +////export class /*2*/Foo {} -goTo.marker('1'); -goTo.type(); -verify.caretAtMarker('2'); \ No newline at end of file +verify.goToType("1", "2"); diff --git a/tests/cases/fourslash/shims-pp/getDefinitionAtPosition.ts b/tests/cases/fourslash/shims-pp/getDefinitionAtPosition.ts index 1679563942c..67e8c44c84c 100644 --- a/tests/cases/fourslash/shims-pp/getDefinitionAtPosition.ts +++ b/tests/cases/fourslash/shims-pp/getDefinitionAtPosition.ts @@ -2,10 +2,10 @@ // @Filename: goToDefinitionDifferentFile_Definition.ts ////var /*remoteVariableDefinition*/remoteVariable; -/////*remoteFunctionDefinition*/function remoteFunction() { } -/////*remoteClassDefinition*/class remoteClass { } -/////*remoteInterfaceDefinition*/interface remoteInterface{ } -/////*remoteModuleDefinition*/module remoteModule{ export var foo = 1;} +////function /*remoteFunctionDefinition*/remoteFunction() { } +////class /*remoteClassDefinition*/remoteClass { } +////interface /*remoteInterfaceDefinition*/remoteInterface{ } +////module /*remoteModuleDefinition*/remoteModule{ export var foo = 1;} // @Filename: goToDefinitionDifferentFile_Consumption.ts /////*remoteVariableReference*/remoteVariable = 1; diff --git a/tests/cases/fourslash/shims-pp/goToTypeDefinition.ts b/tests/cases/fourslash/shims-pp/goToTypeDefinition.ts index 6b34e7e4886..b6bbd839003 100644 --- a/tests/cases/fourslash/shims-pp/goToTypeDefinition.ts +++ b/tests/cases/fourslash/shims-pp/goToTypeDefinition.ts @@ -1,7 +1,7 @@ /// // @Filename: goToTypeDefinition_Definition.ts -/////*definition*/class C { +////class /*definition*/C { //// p; ////} ////var c: C; @@ -9,6 +9,4 @@ // @Filename: goToTypeDefinition_Consumption.ts /////*reference*/c = undefined; -goTo.marker('reference'); -goTo.type(); -verify.caretAtMarker('definition'); +verify.goToType("reference", "definition"); diff --git a/tests/cases/fourslash/shims/getDefinitionAtPosition.ts b/tests/cases/fourslash/shims/getDefinitionAtPosition.ts index 1679563942c..67e8c44c84c 100644 --- a/tests/cases/fourslash/shims/getDefinitionAtPosition.ts +++ b/tests/cases/fourslash/shims/getDefinitionAtPosition.ts @@ -2,10 +2,10 @@ // @Filename: goToDefinitionDifferentFile_Definition.ts ////var /*remoteVariableDefinition*/remoteVariable; -/////*remoteFunctionDefinition*/function remoteFunction() { } -/////*remoteClassDefinition*/class remoteClass { } -/////*remoteInterfaceDefinition*/interface remoteInterface{ } -/////*remoteModuleDefinition*/module remoteModule{ export var foo = 1;} +////function /*remoteFunctionDefinition*/remoteFunction() { } +////class /*remoteClassDefinition*/remoteClass { } +////interface /*remoteInterfaceDefinition*/remoteInterface{ } +////module /*remoteModuleDefinition*/remoteModule{ export var foo = 1;} // @Filename: goToDefinitionDifferentFile_Consumption.ts /////*remoteVariableReference*/remoteVariable = 1; diff --git a/tests/cases/fourslash/shims/goToTypeDefinition.ts b/tests/cases/fourslash/shims/goToTypeDefinition.ts index 6b34e7e4886..b6bbd839003 100644 --- a/tests/cases/fourslash/shims/goToTypeDefinition.ts +++ b/tests/cases/fourslash/shims/goToTypeDefinition.ts @@ -1,7 +1,7 @@ /// // @Filename: goToTypeDefinition_Definition.ts -/////*definition*/class C { +////class /*definition*/C { //// p; ////} ////var c: C; @@ -9,6 +9,4 @@ // @Filename: goToTypeDefinition_Consumption.ts /////*reference*/c = undefined; -goTo.marker('reference'); -goTo.type(); -verify.caretAtMarker('definition'); +verify.goToType("reference", "definition"); diff --git a/tests/cases/fourslash/superFix1.ts b/tests/cases/fourslash/superFix1.ts deleted file mode 100644 index 7fbe2cb4fd7..00000000000 --- a/tests/cases/fourslash/superFix1.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// - -////class Base{ -////} -////class C extends Base{ -//// constructor() {[| |] -//// } -////} - -verify.codeFixAtPosition('super();'); diff --git a/tests/cases/fourslash/tsxGoToDefinitionClasses.ts b/tests/cases/fourslash/tsxGoToDefinitionClasses.ts index 9c54834534d..fb76080f6df 100644 --- a/tests/cases/fourslash/tsxGoToDefinitionClasses.ts +++ b/tests/cases/fourslash/tsxGoToDefinitionClasses.ts @@ -6,7 +6,7 @@ //// interface IntrinsicElements { } //// interface ElementAttributesProperty { props; } //// } -//// /*ct*/class MyClass { +//// class /*ct*/MyClass { //// props: { //// /*pt*/foo: string; //// } diff --git a/tests/cases/fourslash/unusedClassInNamespace1.ts b/tests/cases/fourslash/unusedClassInNamespace1.ts index 586202ab0c7..e13c889d327 100644 --- a/tests/cases/fourslash/unusedClassInNamespace1.ts +++ b/tests/cases/fourslash/unusedClassInNamespace1.ts @@ -6,5 +6,5 @@ //// } //// } |] -verify.codeFixAtPosition(`namespace greeter { +verify.rangeAfterCodeFix(`namespace greeter { }`); diff --git a/tests/cases/fourslash/unusedClassInNamespace2.ts b/tests/cases/fourslash/unusedClassInNamespace2.ts index c182f4e3655..0b6b7504633 100644 --- a/tests/cases/fourslash/unusedClassInNamespace2.ts +++ b/tests/cases/fourslash/unusedClassInNamespace2.ts @@ -8,7 +8,7 @@ //// } //// } |] -verify.codeFixAtPosition(`namespace greeter { +verify.rangeAfterCodeFix(`namespace greeter { export class class2 { } }`); diff --git a/tests/cases/fourslash/unusedClassInNamespace3.ts b/tests/cases/fourslash/unusedClassInNamespace3.ts index 391c5e833ef..95e691d3ee1 100644 --- a/tests/cases/fourslash/unusedClassInNamespace3.ts +++ b/tests/cases/fourslash/unusedClassInNamespace3.ts @@ -16,7 +16,7 @@ //// } ////} |] -verify.codeFixAtPosition(`namespace Validation { +verify.rangeAfterCodeFix(`namespace Validation { class c1 { } diff --git a/tests/cases/fourslash/unusedClassInNamespace4.ts b/tests/cases/fourslash/unusedClassInNamespace4.ts index 5db5b1aefa6..8b856379acb 100644 --- a/tests/cases/fourslash/unusedClassInNamespace4.ts +++ b/tests/cases/fourslash/unusedClassInNamespace4.ts @@ -16,7 +16,7 @@ //// } ////} |] -verify.codeFixAtPosition(`namespace Validation { +verify.rangeAfterCodeFix(`namespace Validation { class c1 { } diff --git a/tests/cases/fourslash/unusedConstantInFunction1.ts b/tests/cases/fourslash/unusedConstantInFunction1.ts index df373257809..b0fe913e722 100644 --- a/tests/cases/fourslash/unusedConstantInFunction1.ts +++ b/tests/cases/fourslash/unusedConstantInFunction1.ts @@ -5,6 +5,6 @@ //// const x: string = "x"; //// } |] -verify.codeFixAtPosition(`function f1 () { +verify.rangeAfterCodeFix(`function f1 () { }`); diff --git a/tests/cases/fourslash/unusedEnumInFunction1.ts b/tests/cases/fourslash/unusedEnumInFunction1.ts index 1d88f07ebf7..ae72b7b3da6 100644 --- a/tests/cases/fourslash/unusedEnumInFunction1.ts +++ b/tests/cases/fourslash/unusedEnumInFunction1.ts @@ -5,7 +5,7 @@ //// enum Directions { Up, Down} //// } |] -verify.codeFixAtPosition(`function f1 () { +verify.rangeAfterCodeFix(`function f1 () { } `); diff --git a/tests/cases/fourslash/unusedEnumInNamespace1.ts b/tests/cases/fourslash/unusedEnumInNamespace1.ts index 88e8e32d5f8..e856a084bfe 100644 --- a/tests/cases/fourslash/unusedEnumInNamespace1.ts +++ b/tests/cases/fourslash/unusedEnumInNamespace1.ts @@ -7,5 +7,5 @@ //// } //// } |] -verify.codeFixAtPosition(`namespace greeter { +verify.rangeAfterCodeFix(`namespace greeter { }`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace1.ts b/tests/cases/fourslash/unusedFunctionInNamespace1.ts index e0f6b2e18ac..8ebf1f7072a 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace1.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace1.ts @@ -6,5 +6,5 @@ //// }/*1*/ //// } |] -verify.codeFixAtPosition(`namespace greeter { +verify.rangeAfterCodeFix(`namespace greeter { }`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace2.ts b/tests/cases/fourslash/unusedFunctionInNamespace2.ts index c823777048e..5a2ac44d3d0 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace2.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace2.ts @@ -8,7 +8,7 @@ //// } ////} |] -verify.codeFixAtPosition(`namespace greeter { +verify.rangeAfterCodeFix(`namespace greeter { export function function2() { } }`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace3.ts b/tests/cases/fourslash/unusedFunctionInNamespace3.ts index 144e9f325b4..69df15cb3c7 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace3.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace3.ts @@ -8,5 +8,5 @@ //// } ////} |] -verify.codeFixAtPosition(`namespace Validation { +verify.rangeAfterCodeFix(`namespace Validation { }`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace4.ts b/tests/cases/fourslash/unusedFunctionInNamespace4.ts index 5b5995da9c7..36ceb319ff9 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace4.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace4.ts @@ -7,5 +7,5 @@ //// } ////} |] -verify.codeFixAtPosition(`namespace Validation { +verify.rangeAfterCodeFix(`namespace Validation { }`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace5.ts b/tests/cases/fourslash/unusedFunctionInNamespace5.ts index b839d9dcd97..3c2f20ce082 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace5.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace5.ts @@ -21,7 +21,7 @@ //// export let a = function3; |] ////} -verify.codeFixAtPosition(`function function3() { +verify.rangeAfterCodeFix(`function function3() { function1(); } diff --git a/tests/cases/fourslash/unusedImports10FS.ts b/tests/cases/fourslash/unusedImports10FS.ts index f9d38e4cfb0..ea016b73cc2 100644 --- a/tests/cases/fourslash/unusedImports10FS.ts +++ b/tests/cases/fourslash/unusedImports10FS.ts @@ -12,5 +12,5 @@ //// [|import a = A;|] //// } -verify.codeFixAtPosition(""); +verify.rangeAfterCodeFix(""); diff --git a/tests/cases/fourslash/unusedImports11FS.ts b/tests/cases/fourslash/unusedImports11FS.ts index a18a4634d71..c29b5612e88 100644 --- a/tests/cases/fourslash/unusedImports11FS.ts +++ b/tests/cases/fourslash/unusedImports11FS.ts @@ -11,4 +11,4 @@ //// export function f2(s: string){}; //// export default f1; -verify.codeFixAtPosition('import * as s from "./file1";'); \ No newline at end of file +verify.rangeAfterCodeFix('import * as s from "./file1";'); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports12FS.ts b/tests/cases/fourslash/unusedImports12FS.ts index 4d8243eb4ab..d86bc98c6cf 100644 --- a/tests/cases/fourslash/unusedImports12FS.ts +++ b/tests/cases/fourslash/unusedImports12FS.ts @@ -10,4 +10,4 @@ //// export function f2(s: string){}; //// export default f1; -verify.codeFixAtPosition('import f1 from "./file1";'); \ No newline at end of file +verify.rangeAfterCodeFix('import f1 from "./file1";'); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports1FS.ts b/tests/cases/fourslash/unusedImports1FS.ts index d9fc17a2448..0fc2d36aac7 100644 --- a/tests/cases/fourslash/unusedImports1FS.ts +++ b/tests/cases/fourslash/unusedImports1FS.ts @@ -9,4 +9,4 @@ //// //// } -verify.codeFixAtPosition(''); +verify.rangeAfterCodeFix(''); diff --git a/tests/cases/fourslash/unusedImports2FS.ts b/tests/cases/fourslash/unusedImports2FS.ts index 6e3d9527c52..d2062fc4958 100644 --- a/tests/cases/fourslash/unusedImports2FS.ts +++ b/tests/cases/fourslash/unusedImports2FS.ts @@ -16,4 +16,4 @@ //// //// } -verify.codeFixAtPosition(`import {Calculator} from "./file1"`); +verify.rangeAfterCodeFix(`import {Calculator} from "./file1"`); diff --git a/tests/cases/fourslash/unusedImports3FS.ts b/tests/cases/fourslash/unusedImports3FS.ts index 205666e971d..98dc30c4336 100644 --- a/tests/cases/fourslash/unusedImports3FS.ts +++ b/tests/cases/fourslash/unusedImports3FS.ts @@ -20,5 +20,5 @@ //// //// } -verify.codeFixAtPosition(`import {test, test2} from "./file1"`); +verify.rangeAfterCodeFix(`import {test, test2} from "./file1"`); diff --git a/tests/cases/fourslash/unusedImports4FS.ts b/tests/cases/fourslash/unusedImports4FS.ts index 302007748f4..4f7e8882429 100644 --- a/tests/cases/fourslash/unusedImports4FS.ts +++ b/tests/cases/fourslash/unusedImports4FS.ts @@ -21,4 +21,4 @@ //// //// } -verify.codeFixAtPosition(`import {Calculator, test2} from "./file1"`); \ No newline at end of file +verify.rangeAfterCodeFix(`import {Calculator, test2} from "./file1"`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports5FS.ts b/tests/cases/fourslash/unusedImports5FS.ts index 1d68f6ae643..15262df01fd 100644 --- a/tests/cases/fourslash/unusedImports5FS.ts +++ b/tests/cases/fourslash/unusedImports5FS.ts @@ -21,4 +21,4 @@ //// //// } -verify.codeFixAtPosition(`import {Calculator, test} from "./file1"`); \ No newline at end of file +verify.rangeAfterCodeFix(`import {Calculator, test} from "./file1"`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports6FS.ts b/tests/cases/fourslash/unusedImports6FS.ts index a5c6744855a..1d6a9a3232e 100644 --- a/tests/cases/fourslash/unusedImports6FS.ts +++ b/tests/cases/fourslash/unusedImports6FS.ts @@ -17,4 +17,4 @@ //// //// } -verify.codeFixAtPosition(''); \ No newline at end of file +verify.rangeAfterCodeFix(''); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports7FS.ts b/tests/cases/fourslash/unusedImports7FS.ts index 23066ef538d..1a23ea85925 100644 --- a/tests/cases/fourslash/unusedImports7FS.ts +++ b/tests/cases/fourslash/unusedImports7FS.ts @@ -13,4 +13,4 @@ //// export default function test2() { //// } -verify.codeFixAtPosition(''); \ No newline at end of file +verify.rangeAfterCodeFix(''); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports8FS.ts b/tests/cases/fourslash/unusedImports8FS.ts index 02564e35989..81bdeda36ac 100644 --- a/tests/cases/fourslash/unusedImports8FS.ts +++ b/tests/cases/fourslash/unusedImports8FS.ts @@ -21,4 +21,4 @@ //// //// } -verify.codeFixAtPosition(`import {Calculator as calc, test as t1} from "./file1"`); \ No newline at end of file +verify.rangeAfterCodeFix(`import {Calculator as calc, test as t1} from "./file1"`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports9FS.ts b/tests/cases/fourslash/unusedImports9FS.ts index 324d57a1928..f81f9a9f5ae 100644 --- a/tests/cases/fourslash/unusedImports9FS.ts +++ b/tests/cases/fourslash/unusedImports9FS.ts @@ -17,4 +17,4 @@ //// //// } -verify.codeFixAtPosition(""); \ No newline at end of file +verify.rangeAfterCodeFix(""); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace1.ts b/tests/cases/fourslash/unusedInterfaceInNamespace1.ts index 8d07a8c7912..f979069690b 100644 --- a/tests/cases/fourslash/unusedInterfaceInNamespace1.ts +++ b/tests/cases/fourslash/unusedInterfaceInNamespace1.ts @@ -6,6 +6,6 @@ //// } ////} |] -verify.codeFixAtPosition(` +verify.rangeAfterCodeFix(` namespace greeter { }`); diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace2.ts b/tests/cases/fourslash/unusedInterfaceInNamespace2.ts index baa46c65a0c..7737f9ce247 100644 --- a/tests/cases/fourslash/unusedInterfaceInNamespace2.ts +++ b/tests/cases/fourslash/unusedInterfaceInNamespace2.ts @@ -8,5 +8,5 @@ //// } |] ////} -verify.codeFixAtPosition(`export interface interface2 { +verify.rangeAfterCodeFix(`export interface interface2 { }`); diff --git a/tests/cases/fourslash/unusedLocalsInFunction1.ts b/tests/cases/fourslash/unusedLocalsInFunction1.ts index 2edd7c176e7..e74f5dbd962 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction1.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction1.ts @@ -5,6 +5,6 @@ //// var x = 0; ////} |] -verify.codeFixAtPosition(` +verify.rangeAfterCodeFix(` function greeter() { }`); diff --git a/tests/cases/fourslash/unusedLocalsInFunction2.ts b/tests/cases/fourslash/unusedLocalsInFunction2.ts index b7094328041..83816e68038 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction2.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction2.ts @@ -6,4 +6,4 @@ //// x+1; ////} -verify.codeFixAtPosition("var x;"); +verify.rangeAfterCodeFix("var x;"); diff --git a/tests/cases/fourslash/unusedLocalsInFunction3.ts b/tests/cases/fourslash/unusedLocalsInFunction3.ts index 906517ee0a7..7aa9b20a33c 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction3.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction3.ts @@ -7,4 +7,4 @@ //// z+1; ////} -verify.codeFixAtPosition("var x,z = 1;", 6133); +verify.rangeAfterCodeFix("var x,z = 1;", 6133); diff --git a/tests/cases/fourslash/unusedLocalsInFunction4.ts b/tests/cases/fourslash/unusedLocalsInFunction4.ts index 54d3223f236..a458d6d824c 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction4.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction4.ts @@ -7,4 +7,4 @@ //// z++; ////} -verify.codeFixAtPosition("var y = 0,z = 1;"); +verify.rangeAfterCodeFix("var y = 0,z = 1;"); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts index 43b782ce266..dc73ab86663 100644 --- a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts +++ b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts @@ -9,4 +9,4 @@ //// } ////} -verify.codeFixAtPosition("var y = 10;"); +verify.rangeAfterCodeFix("var y = 10;"); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts index 322cfad3940..012bf87a222 100644 --- a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts +++ b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts @@ -9,4 +9,4 @@ //// } ////} -verify.codeFixAtPosition("var y;"); +verify.rangeAfterCodeFix("var y;"); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts index 412b599b780..4ed58d3142d 100644 --- a/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts +++ b/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts @@ -8,5 +8,5 @@ //// } |] ////} -verify.codeFixAtPosition(`constructor() { +verify.rangeAfterCodeFix(`constructor() { }`); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts index eff9b7c8d54..eeaf66050d4 100644 --- a/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts +++ b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts @@ -10,7 +10,7 @@ //// }|] ////} -verify.codeFixAtPosition(` +verify.rangeAfterCodeFix(` constructor() { var used = "dummy"; used = used + "second part"; diff --git a/tests/cases/fourslash/unusedMethodInClass1.ts b/tests/cases/fourslash/unusedMethodInClass1.ts index 7795a4d1530..a5e3789c8af 100644 --- a/tests/cases/fourslash/unusedMethodInClass1.ts +++ b/tests/cases/fourslash/unusedMethodInClass1.ts @@ -6,6 +6,6 @@ //// } ////} |] -verify.codeFixAtPosition(` +verify.rangeAfterCodeFix(` class greeter { }`); diff --git a/tests/cases/fourslash/unusedMethodInClass2.ts b/tests/cases/fourslash/unusedMethodInClass2.ts index 24b6fe155ef..cce621236d4 100644 --- a/tests/cases/fourslash/unusedMethodInClass2.ts +++ b/tests/cases/fourslash/unusedMethodInClass2.ts @@ -8,7 +8,7 @@ //// } ////} |] -verify.codeFixAtPosition(` +verify.rangeAfterCodeFix(` class greeter { public function2() { } diff --git a/tests/cases/fourslash/unusedMethodInClass3.ts b/tests/cases/fourslash/unusedMethodInClass3.ts index eab535fb5af..ccf98c4bbc5 100644 --- a/tests/cases/fourslash/unusedMethodInClass3.ts +++ b/tests/cases/fourslash/unusedMethodInClass3.ts @@ -6,6 +6,6 @@ //// } ////} |] -verify.codeFixAtPosition(` +verify.rangeAfterCodeFix(` class greeter { }`); diff --git a/tests/cases/fourslash/unusedMethodInClass4.ts b/tests/cases/fourslash/unusedMethodInClass4.ts index ee27ec331eb..962b80f5bc1 100644 --- a/tests/cases/fourslash/unusedMethodInClass4.ts +++ b/tests/cases/fourslash/unusedMethodInClass4.ts @@ -8,5 +8,5 @@ //// } |] ////} -verify.codeFixAtPosition(`public function2(){ +verify.rangeAfterCodeFix(`public function2(){ }`); diff --git a/tests/cases/fourslash/unusedMethodInClass5.ts b/tests/cases/fourslash/unusedMethodInClass5.ts index 36ef3670cac..806e619817f 100644 --- a/tests/cases/fourslash/unusedMethodInClass5.ts +++ b/tests/cases/fourslash/unusedMethodInClass5.ts @@ -5,4 +5,4 @@ //// private ["string"] (){} //// }|] -verify.codeFixAtPosition("class C { }"); \ No newline at end of file +verify.rangeAfterCodeFix("class C { }"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedMethodInClass6.ts b/tests/cases/fourslash/unusedMethodInClass6.ts index 71fcb92d037..d223b3d6857 100644 --- a/tests/cases/fourslash/unusedMethodInClass6.ts +++ b/tests/cases/fourslash/unusedMethodInClass6.ts @@ -5,4 +5,4 @@ //// private "string" (){} //// }|] -verify.codeFixAtPosition("class C { }"); \ No newline at end of file +verify.rangeAfterCodeFix("class C { }"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedNamespaceInNamespace.ts b/tests/cases/fourslash/unusedNamespaceInNamespace.ts index 41fe162ef15..802336454c6 100644 --- a/tests/cases/fourslash/unusedNamespaceInNamespace.ts +++ b/tests/cases/fourslash/unusedNamespaceInNamespace.ts @@ -6,7 +6,7 @@ //// } //// }|] -verify.codeFixAtPosition(` +verify.rangeAfterCodeFix(` namespace A { } `); diff --git a/tests/cases/fourslash/unusedParameterInConstructor1.ts b/tests/cases/fourslash/unusedParameterInConstructor1.ts index f53c6d3e8bd..36539e6649b 100644 --- a/tests/cases/fourslash/unusedParameterInConstructor1.ts +++ b/tests/cases/fourslash/unusedParameterInConstructor1.ts @@ -5,4 +5,4 @@ //// [|constructor(private p1: string, public p2: boolean, public p3: any, p5)|] { p5; } //// } -verify.codeFixAtPosition("constructor(public p2: boolean, public p3: any, p5)"); \ No newline at end of file +verify.rangeAfterCodeFix("constructor(public p2: boolean, public p3: any, p5)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInConstructor2.ts b/tests/cases/fourslash/unusedParameterInConstructor2.ts index bd5f66ff966..e822a2f248d 100644 --- a/tests/cases/fourslash/unusedParameterInConstructor2.ts +++ b/tests/cases/fourslash/unusedParameterInConstructor2.ts @@ -5,4 +5,4 @@ //// [|constructor(public p1: string, private p2: boolean, public p3: any, p5)|] { p5; } //// } -verify.codeFixAtPosition("constructor(public p1: string, public p3: any, p5)"); \ No newline at end of file +verify.rangeAfterCodeFix("constructor(public p1: string, public p3: any, p5)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInConstructor3.ts b/tests/cases/fourslash/unusedParameterInConstructor3.ts index 173e00113d8..1a9682aece3 100644 --- a/tests/cases/fourslash/unusedParameterInConstructor3.ts +++ b/tests/cases/fourslash/unusedParameterInConstructor3.ts @@ -5,4 +5,4 @@ //// [|constructor(public p1: string, public p2: boolean, private p3: any, p5)|] { p5; } //// } -verify.codeFixAtPosition("constructor(public p1: string, public p2: boolean, p5)"); \ No newline at end of file +verify.rangeAfterCodeFix("constructor(public p1: string, public p2: boolean, p5)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInConstructor4.ts b/tests/cases/fourslash/unusedParameterInConstructor4.ts index 6d0223dc5f4..01df43718da 100644 --- a/tests/cases/fourslash/unusedParameterInConstructor4.ts +++ b/tests/cases/fourslash/unusedParameterInConstructor4.ts @@ -5,4 +5,4 @@ //// [|constructor(private readonly p2: boolean, p5)|] { p5; } //// } -verify.codeFixAtPosition("constructor(p5)"); \ No newline at end of file +verify.rangeAfterCodeFix("constructor(p5)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction1.ts b/tests/cases/fourslash/unusedParameterInFunction1.ts index 2243af9f5f5..baaccbbd20f 100644 --- a/tests/cases/fourslash/unusedParameterInFunction1.ts +++ b/tests/cases/fourslash/unusedParameterInFunction1.ts @@ -4,4 +4,4 @@ ////function [|greeter( x)|] { ////} -verify.codeFixAtPosition("greeter()"); +verify.rangeAfterCodeFix("greeter()"); diff --git a/tests/cases/fourslash/unusedParameterInFunction2.ts b/tests/cases/fourslash/unusedParameterInFunction2.ts index 493eafc5722..0e448c98fcc 100644 --- a/tests/cases/fourslash/unusedParameterInFunction2.ts +++ b/tests/cases/fourslash/unusedParameterInFunction2.ts @@ -5,4 +5,4 @@ //// x++; ////} -verify.codeFixAtPosition("greeter(x)"); \ No newline at end of file +verify.rangeAfterCodeFix("greeter(x)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction3.ts b/tests/cases/fourslash/unusedParameterInFunction3.ts index 6d79ba071b4..23f45475950 100644 --- a/tests/cases/fourslash/unusedParameterInFunction3.ts +++ b/tests/cases/fourslash/unusedParameterInFunction3.ts @@ -5,4 +5,4 @@ //// y++; ////} -verify.codeFixAtPosition("greeter(y)"); \ No newline at end of file +verify.rangeAfterCodeFix("greeter(y)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction4.ts b/tests/cases/fourslash/unusedParameterInFunction4.ts index b536543fb6d..1f98238d647 100644 --- a/tests/cases/fourslash/unusedParameterInFunction4.ts +++ b/tests/cases/fourslash/unusedParameterInFunction4.ts @@ -6,4 +6,4 @@ //// z++; ////} -verify.codeFixAtPosition("function greeter(x,z)"); \ No newline at end of file +verify.rangeAfterCodeFix("function greeter(x,z)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInLambda1.ts b/tests/cases/fourslash/unusedParameterInLambda1.ts index c462b742569..166d250fee7 100644 --- a/tests/cases/fourslash/unusedParameterInLambda1.ts +++ b/tests/cases/fourslash/unusedParameterInLambda1.ts @@ -6,4 +6,4 @@ //// [|return (x:number) => {}|] //// } -verify.codeFixAtPosition("return () => {}"); +verify.rangeAfterCodeFix("return () => {}"); diff --git a/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts b/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts index 593c0fe8cf4..2314ebbe447 100644 --- a/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts +++ b/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts @@ -6,6 +6,6 @@ //// export type nw = "No" | "Way"; //// } |] -verify.codeFixAtPosition(`namespace greeter { +verify.rangeAfterCodeFix(`namespace greeter { export type nw = "No" | "Way"; }`); diff --git a/tests/cases/fourslash/unusedTypeParametersInClass1.ts b/tests/cases/fourslash/unusedTypeParametersInClass1.ts index ab654a5150e..322921ab471 100644 --- a/tests/cases/fourslash/unusedTypeParametersInClass1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInClass1.ts @@ -4,4 +4,4 @@ ////[|class greeter |] { ////} -verify.codeFixAtPosition("class greeter"); \ No newline at end of file +verify.rangeAfterCodeFix("class greeter"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInClass2.ts b/tests/cases/fourslash/unusedTypeParametersInClass2.ts index 8e860c10e04..feaf9d3a14b 100644 --- a/tests/cases/fourslash/unusedTypeParametersInClass2.ts +++ b/tests/cases/fourslash/unusedTypeParametersInClass2.ts @@ -5,4 +5,4 @@ //// public a: X; ////} -verify.codeFixAtPosition("class greeter"); \ No newline at end of file +verify.rangeAfterCodeFix("class greeter"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInClass3.ts b/tests/cases/fourslash/unusedTypeParametersInClass3.ts index 75ae98f53e0..b1151265fe3 100644 --- a/tests/cases/fourslash/unusedTypeParametersInClass3.ts +++ b/tests/cases/fourslash/unusedTypeParametersInClass3.ts @@ -6,4 +6,4 @@ //// public b: Z; ////} -verify.codeFixAtPosition("class greeter"); +verify.rangeAfterCodeFix("class greeter"); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction1.ts b/tests/cases/fourslash/unusedTypeParametersInFunction1.ts index 7177ed41c84..a11156badaa 100644 --- a/tests/cases/fourslash/unusedTypeParametersInFunction1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInFunction1.ts @@ -3,4 +3,4 @@ // @noUnusedLocals: true //// [|function f1() {}|] -verify.codeFixAtPosition("function f1() {}"); +verify.rangeAfterCodeFix("function f1() {}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction2.ts b/tests/cases/fourslash/unusedTypeParametersInFunction2.ts index 344ae303c75..a011f093dab 100644 --- a/tests/cases/fourslash/unusedTypeParametersInFunction2.ts +++ b/tests/cases/fourslash/unusedTypeParametersInFunction2.ts @@ -3,4 +3,4 @@ // @noUnusedLocals: true //// [|function f1(a: X) {a}|] -verify.codeFixAtPosition("function f1(a: X) {a}"); +verify.rangeAfterCodeFix("function f1(a: X) {a}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction3.ts b/tests/cases/fourslash/unusedTypeParametersInFunction3.ts index 746b174db18..6dc56ccc7cb 100644 --- a/tests/cases/fourslash/unusedTypeParametersInFunction3.ts +++ b/tests/cases/fourslash/unusedTypeParametersInFunction3.ts @@ -3,4 +3,4 @@ // @noUnusedLocals: true //// [|function f1(a: X) {a;var b:Z;b}|] -verify.codeFixAtPosition("function f1(a: X) {a;var b:Z;b}"); +verify.rangeAfterCodeFix("function f1(a: X) {a;var b:Z;b}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInInterface1.ts b/tests/cases/fourslash/unusedTypeParametersInInterface1.ts index 70d8bc7800c..b5363b369be 100644 --- a/tests/cases/fourslash/unusedTypeParametersInInterface1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInInterface1.ts @@ -4,4 +4,4 @@ // @noUnusedParameters: true //// [|interface I {}|] -verify.codeFixAtPosition("interface I {}"); \ No newline at end of file +verify.rangeAfterCodeFix("interface I {}"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda1.ts b/tests/cases/fourslash/unusedTypeParametersInLambda1.ts index 73d70672368..01c1ebd24f5 100644 --- a/tests/cases/fourslash/unusedTypeParametersInLambda1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInLambda1.ts @@ -6,4 +6,4 @@ //// [|return (x:number) => {x}|] //// } -verify.codeFixAtPosition("return (x:number) => {x}"); +verify.rangeAfterCodeFix("return (x:number) => {x}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda2.ts b/tests/cases/fourslash/unusedTypeParametersInLambda2.ts index 77c802f5c44..e5a4acc31c5 100644 --- a/tests/cases/fourslash/unusedTypeParametersInLambda2.ts +++ b/tests/cases/fourslash/unusedTypeParametersInLambda2.ts @@ -6,4 +6,4 @@ //// [|new (a: T): void;|] //// } -verify.codeFixAtPosition("new (a: T): void;"); +verify.rangeAfterCodeFix("new (a: T): void;"); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda3.ts b/tests/cases/fourslash/unusedTypeParametersInLambda3.ts index 0ecb0338be2..e6d866dcb6a 100644 --- a/tests/cases/fourslash/unusedTypeParametersInLambda3.ts +++ b/tests/cases/fourslash/unusedTypeParametersInLambda3.ts @@ -7,4 +7,4 @@ //// [|new (a: T): A;|] //// } -verify.codeFixAtPosition("new (a: T): A;"); +verify.rangeAfterCodeFix("new (a: T): A;"); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda4.ts b/tests/cases/fourslash/unusedTypeParametersInLambda4.ts index 5a226fc9005..04bd7c7e9be 100644 --- a/tests/cases/fourslash/unusedTypeParametersInLambda4.ts +++ b/tests/cases/fourslash/unusedTypeParametersInLambda4.ts @@ -6,4 +6,4 @@ //// } //// [|var y: new (a:T)=>void;|] -verify.codeFixAtPosition("var y: new (a:T)=>void;"); \ No newline at end of file +verify.rangeAfterCodeFix("var y: new (a:T)=>void;"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethod1.ts b/tests/cases/fourslash/unusedTypeParametersInMethod1.ts index 7a9f04147d6..bc14952eca9 100644 --- a/tests/cases/fourslash/unusedTypeParametersInMethod1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInMethod1.ts @@ -5,4 +5,4 @@ //// [|f1()|] {} //// } -verify.codeFixAtPosition("f1()"); \ No newline at end of file +verify.rangeAfterCodeFix("f1()"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethod2.ts b/tests/cases/fourslash/unusedTypeParametersInMethod2.ts index 3650cfbad98..c12fd53f66b 100644 --- a/tests/cases/fourslash/unusedTypeParametersInMethod2.ts +++ b/tests/cases/fourslash/unusedTypeParametersInMethod2.ts @@ -5,4 +5,4 @@ //// [|f1(a: U)|] {a;} //// } -verify.codeFixAtPosition("f1(a: U)"); \ No newline at end of file +verify.rangeAfterCodeFix("f1(a: U)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethods1.ts b/tests/cases/fourslash/unusedTypeParametersInMethods1.ts index cb9b965ca4d..d0b170491f5 100644 --- a/tests/cases/fourslash/unusedTypeParametersInMethods1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInMethods1.ts @@ -5,4 +5,4 @@ //// [|public f1(a: X)|] { a; var b: Z; b } //// } -verify.codeFixAtPosition("public f1(a: X)"); +verify.rangeAfterCodeFix("public f1(a: X)"); diff --git a/tests/cases/fourslash/unusedVariableInBlocks.ts b/tests/cases/fourslash/unusedVariableInBlocks.ts index e9dedaef31e..2a33d0c4cf5 100644 --- a/tests/cases/fourslash/unusedVariableInBlocks.ts +++ b/tests/cases/fourslash/unusedVariableInBlocks.ts @@ -9,7 +9,7 @@ //// x;|] //// } -verify.codeFixAtPosition(`let x = 10; +verify.rangeAfterCodeFix(`let x = 10; { } x;`); diff --git a/tests/cases/fourslash/unusedVariableInClass1.ts b/tests/cases/fourslash/unusedVariableInClass1.ts index 82bb99016ef..8b0ca0db727 100644 --- a/tests/cases/fourslash/unusedVariableInClass1.ts +++ b/tests/cases/fourslash/unusedVariableInClass1.ts @@ -5,4 +5,4 @@ //// [|private greeting: string;|] ////} -verify.codeFixAtPosition(""); +verify.rangeAfterCodeFix(""); diff --git a/tests/cases/fourslash/unusedVariableInClass2.ts b/tests/cases/fourslash/unusedVariableInClass2.ts index c971092584a..6503dd02872 100644 --- a/tests/cases/fourslash/unusedVariableInClass2.ts +++ b/tests/cases/fourslash/unusedVariableInClass2.ts @@ -6,4 +6,4 @@ //// private greeting: string;|] ////} -verify.codeFixAtPosition("public greeting1;"); +verify.rangeAfterCodeFix("public greeting1;"); diff --git a/tests/cases/fourslash/unusedVariableInClass3.ts b/tests/cases/fourslash/unusedVariableInClass3.ts index 8d2a62e7175..3ac306170a2 100644 --- a/tests/cases/fourslash/unusedVariableInClass3.ts +++ b/tests/cases/fourslash/unusedVariableInClass3.ts @@ -5,4 +5,4 @@ //// private X = function() {}; ////|]} -verify.codeFixAtPosition(""); +verify.rangeAfterCodeFix(""); diff --git a/tests/cases/fourslash/unusedVariableInForLoop1FS.ts b/tests/cases/fourslash/unusedVariableInForLoop1FS.ts index 0ee02ab4363..760d8487b34 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop1FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop1FS.ts @@ -7,5 +7,5 @@ //// } //// } -verify.codeFixAtPosition("for(; ;)"); +verify.rangeAfterCodeFix("for(; ;)"); diff --git a/tests/cases/fourslash/unusedVariableInForLoop2FS.ts b/tests/cases/fourslash/unusedVariableInForLoop2FS.ts index 1b1a0798c04..a16f21e8417 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop2FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop2FS.ts @@ -7,4 +7,4 @@ //// } //// } -verify.codeFixAtPosition("for(var i = 0; ;i++)"); +verify.rangeAfterCodeFix("for(var i = 0; ;i++)"); diff --git a/tests/cases/fourslash/unusedVariableInForLoop3FS.ts b/tests/cases/fourslash/unusedVariableInForLoop3FS.ts index 4eed9599b15..07d13307ca7 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop3FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop3FS.ts @@ -7,4 +7,4 @@ //// } //// } -verify.codeFixAtPosition("for(var i = 0, k=0; ;i++,k++)"); \ No newline at end of file +verify.rangeAfterCodeFix("for(var i = 0, k=0; ;i++,k++)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedVariableInForLoop4FS.ts b/tests/cases/fourslash/unusedVariableInForLoop4FS.ts index 76e551612ba..d54f8baaa3d 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop4FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop4FS.ts @@ -7,4 +7,4 @@ //// } //// } -verify.codeFixAtPosition("for(var j = 0, k=0; ;j++,k++)"); +verify.rangeAfterCodeFix("for(var j = 0, k=0; ;j++,k++)"); diff --git a/tests/cases/fourslash/unusedVariableInForLoop6FS.ts b/tests/cases/fourslash/unusedVariableInForLoop6FS.ts index 4187c3141b5..a7b8fbfb7c8 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop6FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop6FS.ts @@ -7,5 +7,5 @@ //// } //// } -verify.codeFixAtPosition("const {} of "); +verify.rangeAfterCodeFix("const {} of "); diff --git a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts index 8fd0fee735e..fa862594ff9 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts @@ -9,4 +9,4 @@ ////} //// -verify.codeFixAtPosition(""); +verify.rangeAfterCodeFix(""); diff --git a/tests/cases/fourslash/unusedVariableInModule1.ts b/tests/cases/fourslash/unusedVariableInModule1.ts index 011434ce098..85ca41952cc 100644 --- a/tests/cases/fourslash/unusedVariableInModule1.ts +++ b/tests/cases/fourslash/unusedVariableInModule1.ts @@ -6,4 +6,4 @@ //// [|var x: string;|] //// export var y: string; -verify.codeFixAtPosition(""); +verify.rangeAfterCodeFix(""); diff --git a/tests/cases/fourslash/unusedVariableInModule2.ts b/tests/cases/fourslash/unusedVariableInModule2.ts index db4519c8faa..ac6e7120d8b 100644 --- a/tests/cases/fourslash/unusedVariableInModule2.ts +++ b/tests/cases/fourslash/unusedVariableInModule2.ts @@ -7,4 +7,4 @@ //// z; //// export var y: string; -verify.codeFixAtPosition("var z: number;"); +verify.rangeAfterCodeFix("var z: number;"); diff --git a/tests/cases/fourslash/unusedVariableInModule3.ts b/tests/cases/fourslash/unusedVariableInModule3.ts index bffffc768d3..428d234c164 100644 --- a/tests/cases/fourslash/unusedVariableInModule3.ts +++ b/tests/cases/fourslash/unusedVariableInModule3.ts @@ -6,4 +6,4 @@ //// [|var x = function f1() {}|] //// export var y: string; -verify.codeFixAtPosition(""); +verify.rangeAfterCodeFix(""); diff --git a/tests/cases/fourslash/unusedVariableInModule4.ts b/tests/cases/fourslash/unusedVariableInModule4.ts index 6a1be9fe5b8..8f23d56b03c 100644 --- a/tests/cases/fourslash/unusedVariableInModule4.ts +++ b/tests/cases/fourslash/unusedVariableInModule4.ts @@ -7,4 +7,4 @@ //// x; //// export var y: string; -verify.codeFixAtPosition(`var x = function f1() {}`); +verify.rangeAfterCodeFix(`var x = function f1() {}`); diff --git a/tests/cases/fourslash/unusedVariableInNamespace1.ts b/tests/cases/fourslash/unusedVariableInNamespace1.ts index caf778bc0da..c9f38473a51 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace1.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace1.ts @@ -5,4 +5,4 @@ //// [|let a = "dummy entry";|] ////} -verify.codeFixAtPosition(""); +verify.rangeAfterCodeFix(""); diff --git a/tests/cases/fourslash/unusedVariableInNamespace2.ts b/tests/cases/fourslash/unusedVariableInNamespace2.ts index fbb9e2d6a0c..992c229014a 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace2.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace2.ts @@ -9,4 +9,4 @@ //// } ////} -verify.codeFixAtPosition(`let a = "dummy entry", c = 0;`); +verify.rangeAfterCodeFix(`let a = "dummy entry", c = 0;`); diff --git a/tests/cases/fourslash/unusedVariableInNamespace3.ts b/tests/cases/fourslash/unusedVariableInNamespace3.ts index 33e501d0c0d..0039036b2f8 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace3.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace3.ts @@ -9,4 +9,4 @@ //// } ////} -verify.codeFixAtPosition(`let a = "dummy entry", b;`); +verify.rangeAfterCodeFix(`let a = "dummy entry", b;`); diff --git a/tests/webTestServer.ts b/tests/webTestServer.ts index 3d23ef3e961..67bbce2a472 100644 --- a/tests/webTestServer.ts +++ b/tests/webTestServer.ts @@ -48,7 +48,7 @@ function log(msg: string) { } -let directorySeparator = "/"; +const directorySeparator = "/"; function getRootLength(path: string): number { if (path.charAt(0) === directorySeparator) { @@ -129,7 +129,7 @@ function dir(dirPath: string, spec?: string, options?: any) { function deleteFolderRecursive(dirPath: string) { if (fs.existsSync(dirPath)) { fs.readdirSync(dirPath).forEach((file) => { - const curPath = path.join(path, file); + const curPath = path.join(dirPath, file); if (fs.statSync(curPath).isDirectory()) { // recurse deleteFolderRecursive(curPath); } diff --git a/tslint.json b/tslint.json index 26657981a63..13de7acec63 100644 --- a/tslint.json +++ b/tslint.json @@ -46,6 +46,7 @@ "prefer-const": true, "no-increment-decrement": true, "object-literal-surrounding-space": true, - "no-type-assertion-whitespace": true + "no-type-assertion-whitespace": true, + "no-in-operator": true } }