From 618b518e4d1c9f69076fe6e587acbacde55227bf Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Wed, 31 Mar 2021 23:20:25 +0000 Subject: [PATCH] Update LKG --- lib/lib.es5.d.ts | 4 +- lib/tsc.js | 414 ++++++++++---------------- lib/tsserver.js | 578 +++++++++++++++--------------------- lib/tsserverlibrary.d.ts | 2 +- lib/tsserverlibrary.js | 578 +++++++++++++++--------------------- lib/typescript.d.ts | 2 +- lib/typescript.js | 575 +++++++++++++++-------------------- lib/typescriptServices.d.ts | 2 +- lib/typescriptServices.js | 575 +++++++++++++++-------------------- lib/typingsInstaller.js | 464 ++++++++++++----------------- 10 files changed, 1324 insertions(+), 1870 deletions(-) diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index 08cf30954e7..606c9f20123 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -1093,7 +1093,7 @@ interface ReadonlyArray { */ toString(): string; /** - * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. + * Returns a string representation of an array. The elements are converted to string using their toLocaleString methods. */ toLocaleString(): string; /** @@ -1227,7 +1227,7 @@ interface Array { */ toString(): string; /** - * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. + * Returns a string representation of an array. The elements are converted to string using their toLocaleString methods. */ toLocaleString(): string; /** diff --git a/lib/tsc.js b/lib/tsc.js index 396884e6563..bacfdc2d704 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -1384,8 +1384,7 @@ var ts; return a === b ? 0 : a === undefined ? -1 : b === undefined ? 1 : - a < b ? -1 : - 1; + a < b ? -1 : 1; } function compareValues(a, b) { return compareComparableValues(a, b); @@ -4970,8 +4969,7 @@ var ts; if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) - ? 1 - : 0); + ? 1 : 0); } if (ts.sys && ts.sys.debugMode) { ts.Debug.isDebugging = true; @@ -4987,7 +4985,7 @@ var ts; Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), - The_parser_expected_to_find_a_to_match_the_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_to_match_the_token_here_1007", "The parser expected to find a '}' to match the '{' token here."), + The_parser_expected_to_find_a_1_to_match_the_0_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_1_to_match_the_0_token_here_1007", "The parser expected to find a '{1}' to match the '{0}' token here."), Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), @@ -5773,7 +5771,7 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), - This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_2774", "This condition will always return true since this function appears to always be defined. Did you mean to call it instead?"), Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), @@ -5800,7 +5798,7 @@ var ts; The_declaration_was_marked_as_deprecated_here: diag(2798, ts.DiagnosticCategory.Error, "The_declaration_was_marked_as_deprecated_here_2798", "The declaration was marked as deprecated here."), Type_produces_a_tuple_type_that_is_too_large_to_represent: diag(2799, ts.DiagnosticCategory.Error, "Type_produces_a_tuple_type_that_is_too_large_to_represent_2799", "Type produces a tuple type that is too large to represent."), Expression_produces_a_tuple_type_that_is_too_large_to_represent: diag(2800, ts.DiagnosticCategory.Error, "Expression_produces_a_tuple_type_that_is_too_large_to_represent_2800", "Expression produces a tuple type that is too large to represent."), - This_condition_will_always_return_true_since_the_Promise_is_always_truthy: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_Promise_is_always_truthy_2801", "This condition will always return true since the Promise is always truthy."), + This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined_2801", "This condition will always return true since this '{0}' appears to always be defined."), Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."), Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."), Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."), @@ -5808,6 +5806,7 @@ var ts; Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."), This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."), A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), + Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "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: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -12488,8 +12487,7 @@ var ts; case 217: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 62 || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 : 2 : - 0; + binaryOperator === 62 || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 : 2 : 0; case 215: case 216: var unaryOperator = parent.operator; @@ -14493,8 +14491,7 @@ var ts; if (getCheckFlags(s) & 6) { var checkFlags = s.checkFlags; var accessModifier = checkFlags & 1024 ? 8 : - checkFlags & 256 ? 4 : - 16; + checkFlags & 256 ? 4 : 16; var staticModifier = checkFlags & 2048 ? 32 : 0; return accessModifier | staticModifier; } @@ -14993,8 +14990,7 @@ var ts; } function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || - compareRelatedInformation(d1, d2) || - 0; + compareRelatedInformation(d1, d2) || 0; } ts.compareDiagnostics = compareDiagnostics; function compareDiagnosticsSkipRelatedInformation(d1, d2) { @@ -15002,8 +14998,7 @@ var ts; ts.compareValues(d1.start, d2.start) || ts.compareValues(d1.length, d2.length) || ts.compareValues(d1.code, d2.code) || - compareMessageText(d1.messageText, d2.messageText) || - 0; + compareMessageText(d1.messageText, d2.messageText) || 0; } ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; function compareRelatedInformation(d1, d2) { @@ -17142,8 +17137,7 @@ var ts; switch (token) { case 129: transformFlags = - 128 | - 64; + 128 | 64; break; case 122: case 120: @@ -17255,9 +17249,7 @@ var ts; var node = createBaseNode(159); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 512 | - 65536; + propagateChildFlags(node.expression) | 512 | 65536; return node; } function updateComputedPropertyName(node, expression) { @@ -17314,9 +17306,7 @@ var ts; var node = createBaseNode(162); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1 | - 4096; + propagateChildFlags(node.expression) | 1 | 4096; return node; } function updateDecorator(node, expression) { @@ -17345,8 +17335,7 @@ var ts; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | - propagateChildFlags(node.exclamationToken) | - 8388608; + propagateChildFlags(node.exclamationToken) | 8388608; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { node.transformFlags |= 4096; } @@ -17388,8 +17377,7 @@ var ts; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | - propagateChildFlags(node.questionToken) | - 512; + propagateChildFlags(node.questionToken) | 512; if (questionToken) { node.transformFlags |= 1; } @@ -17828,13 +17816,10 @@ var ts; var node = createBaseNode(197); node.elements = createNodeArray(elements); node.transformFlags |= - propagateChildrenFlags(node.elements) | - 512 | - 262144; + propagateChildrenFlags(node.elements) | 512 | 262144; if (node.transformFlags & 16384) { node.transformFlags |= - 64 | - 32768; + 64 | 32768; } return node; } @@ -17847,9 +17832,7 @@ var ts; var node = createBaseNode(198); node.elements = createNodeArray(elements); node.transformFlags |= - propagateChildrenFlags(node.elements) | - 512 | - 262144; + propagateChildrenFlags(node.elements) | 512 | 262144; return node; } function updateArrayBindingPattern(node, elements) { @@ -17862,8 +17845,7 @@ var ts; node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= - propagateChildFlags(node.dotDotDotToken) | - 512; + propagateChildFlags(node.dotDotDotToken) | 512; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : @@ -17920,8 +17902,7 @@ var ts; propagateChildFlags(node.name)); if (ts.isSuperKeyword(expression)) { node.transformFlags |= - 128 | - 64; + 128 | 64; } return node; } @@ -17966,8 +17947,7 @@ var ts; propagateChildFlags(node.argumentExpression); if (ts.isSuperKeyword(expression)) { node.transformFlags |= - 128 | - 64; + 128 | 64; } return node; } @@ -17989,8 +17969,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | - propagateChildFlags(node.argumentExpression) | - 16; + propagateChildFlags(node.argumentExpression) | 16; return node; } function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { @@ -18042,8 +18021,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | - propagateChildrenFlags(node.arguments) | - 16; + propagateChildrenFlags(node.arguments) | 16; if (node.typeArguments) { node.transformFlags |= 1; } @@ -18069,8 +18047,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - propagateChildrenFlags(node.arguments) | - 16; + propagateChildrenFlags(node.arguments) | 16; if (node.typeArguments) { node.transformFlags |= 1; } @@ -18091,8 +18068,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.template) | - 512; + propagateChildFlags(node.template) | 512; if (node.typeArguments) { node.transformFlags |= 1; } @@ -18114,8 +18090,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.type) | - 1; + propagateChildFlags(node.type) | 1; return node; } function updateTypeAssertion(node, type, expression) { @@ -18170,8 +18145,7 @@ var ts; var node = createBaseFunctionLikeDeclaration(210, undefined, modifiers, undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38); node.transformFlags |= - propagateChildFlags(node.equalsGreaterThanToken) | - 512; + propagateChildFlags(node.equalsGreaterThanToken) | 512; if (ts.modifiersToFlags(node.modifiers) & 256) { node.transformFlags |= 128; } @@ -18224,10 +18198,7 @@ var ts; var node = createBaseExpression(214); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 128 | - 64 | - 1048576; + propagateChildFlags(node.expression) | 128 | 64 | 1048576; return node; } function updateAwaitExpression(node, expression) { @@ -18276,15 +18247,12 @@ var ts; else if (operatorKind === 62) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 512 | - 64 | - 2048 | + 512 | 64 | 2048 | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 512 | - 2048 | + 512 | 2048 | propagateAssignmentPatternFlags(node.left); } } @@ -18354,8 +18322,7 @@ var ts; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | - propagateChildrenFlags(node.templateSpans) | - 512; + propagateChildrenFlags(node.templateSpans) | 512; return node; } function updateTemplateExpression(node, head, templateSpans) { @@ -18415,10 +18382,7 @@ var ts; node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.asteriskToken) | - 512 | - 64 | - 524288; + propagateChildFlags(node.asteriskToken) | 512 | 64 | 524288; return node; } function updateYieldExpression(node, asteriskToken, expression) { @@ -18431,9 +18395,7 @@ var ts; var node = createBaseExpression(221); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 512 | - 16384; + propagateChildFlags(node.expression) | 512 | 16384; return node; } function updateSpreadElement(node, expression) { @@ -18465,8 +18427,7 @@ var ts; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildrenFlags(node.typeArguments) | - 512; + propagateChildrenFlags(node.typeArguments) | 512; return node; } function updateExpressionWithTypeArguments(node, expression, typeArguments) { @@ -18481,8 +18442,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.type) | - 1; + propagateChildFlags(node.type) | 1; return node; } function updateAsExpression(node, expression, type) { @@ -18495,8 +18455,7 @@ var ts; var node = createBaseExpression(226); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1; + propagateChildFlags(node.expression) | 1; return node; } function updateNonNullExpression(node, expression) { @@ -18512,8 +18471,7 @@ var ts; node.flags |= 32; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1; + propagateChildFlags(node.expression) | 1; return node; } function updateNonNullChain(node, expression) { @@ -18550,8 +18508,7 @@ var ts; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.literal) | - 512; + propagateChildFlags(node.literal) | 512; return node; } function updateTemplateSpan(node, expression, literal) { @@ -18704,8 +18661,7 @@ var ts; propagateChildFlags(node.awaitModifier) | propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | - propagateChildFlags(node.statement) | - 512; + propagateChildFlags(node.statement) | 512; if (awaitModifier) node.transformFlags |= 64; return node; @@ -18722,8 +18678,7 @@ var ts; var node = createBaseNode(241); node.label = asName(label); node.transformFlags |= - propagateChildFlags(node.label) | - 2097152; + propagateChildFlags(node.label) | 2097152; return node; } function updateContinueStatement(node, label) { @@ -18735,8 +18690,7 @@ var ts; var node = createBaseNode(242); node.label = asName(label); node.transformFlags |= - propagateChildFlags(node.label) | - 2097152; + propagateChildFlags(node.label) | 2097152; return node; } function updateBreakStatement(node, label) { @@ -18748,9 +18702,7 @@ var ts; var node = createBaseNode(243); node.expression = expression; node.transformFlags |= - propagateChildFlags(node.expression) | - 64 | - 2097152; + propagateChildFlags(node.expression) | 64 | 2097152; return node; } function updateReturnStatement(node, expression) { @@ -18858,12 +18810,10 @@ var ts; node.flags |= flags & 3; node.declarations = createNodeArray(declarations); node.transformFlags |= - propagateChildrenFlags(node.declarations) | - 2097152; + propagateChildrenFlags(node.declarations) | 2097152; if (flags & 3) { node.transformFlags |= - 512 | - 131072; + 512 | 131072; } return node; } @@ -18880,8 +18830,7 @@ var ts; } else { node.transformFlags |= - propagateChildFlags(node.asteriskToken) | - 2097152; + propagateChildFlags(node.asteriskToken) | 2097152; if (ts.modifiersToFlags(node.modifiers) & 256) { if (node.asteriskToken) { node.transformFlags |= 64; @@ -18966,8 +18915,7 @@ var ts; var node = createBaseNamedDeclaration(256, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= - propagateChildrenFlags(node.members) | - 1; + propagateChildrenFlags(node.members) | 1; node.transformFlags &= ~16777216; return node; } @@ -18991,8 +18939,7 @@ var ts; else { node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.body) | - 1; + propagateChildFlags(node.body) | 1; } node.transformFlags &= ~16777216; return node; @@ -19111,8 +19058,7 @@ var ts; var node = createBaseNode(270); node.name = name; node.transformFlags |= - propagateChildFlags(node.name) | - 4; + propagateChildFlags(node.name) | 4; node.transformFlags &= ~16777216; return node; } @@ -19510,8 +19456,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.openingElement) | propagateChildrenFlags(node.children) | - propagateChildFlags(node.closingElement) | - 2; + propagateChildFlags(node.closingElement) | 2; return node; } function updateJsxElement(node, openingElement, children, closingElement) { @@ -19529,8 +19474,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.attributes) | - 2; + propagateChildFlags(node.attributes) | 2; if (node.typeArguments) { node.transformFlags |= 1; } @@ -19551,8 +19495,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.attributes) | - 2; + propagateChildFlags(node.attributes) | 2; if (typeArguments) { node.transformFlags |= 1; } @@ -19569,8 +19512,7 @@ var ts; var node = createBaseNode(277); node.tagName = tagName; node.transformFlags |= - propagateChildFlags(node.tagName) | - 2; + propagateChildFlags(node.tagName) | 2; return node; } function updateJsxClosingElement(node, tagName) { @@ -19586,8 +19528,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.openingFragment) | propagateChildrenFlags(node.children) | - propagateChildFlags(node.closingFragment) | - 2; + propagateChildFlags(node.closingFragment) | 2; return node; } function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -19626,8 +19567,7 @@ var ts; node.initializer = initializer; node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.initializer) | - 2; + propagateChildFlags(node.initializer) | 2; return node; } function updateJsxAttribute(node, name, initializer) { @@ -19640,8 +19580,7 @@ var ts; var node = createBaseNode(282); node.properties = createNodeArray(properties); node.transformFlags |= - propagateChildrenFlags(node.properties) | - 2; + propagateChildrenFlags(node.properties) | 2; return node; } function updateJsxAttributes(node, properties) { @@ -19653,8 +19592,7 @@ var ts; var node = createBaseNode(283); node.expression = expression; node.transformFlags |= - propagateChildFlags(node.expression) | - 2; + propagateChildFlags(node.expression) | 2; return node; } function updateJsxSpreadAttribute(node, expression) { @@ -19668,8 +19606,7 @@ var ts; node.expression = expression; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - propagateChildFlags(node.expression) | - 2; + propagateChildFlags(node.expression) | 2; return node; } function updateJsxExpression(node, expression) { @@ -19772,8 +19709,7 @@ var ts; var node = createBaseNamedDeclaration(290, undefined, undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= - propagateChildFlags(node.objectAssignmentInitializer) | - 512; + propagateChildFlags(node.objectAssignmentInitializer) | 512; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -19799,9 +19735,7 @@ var ts; var node = createBaseNode(291); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 64 | - 32768; + propagateChildFlags(node.expression) | 64 | 32768; return node; } function updateSpreadAssignment(node, expression) { @@ -19815,8 +19749,7 @@ var ts; node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.initializer) | - 1; + propagateChildFlags(node.initializer) | 1; return node; } function updateEnumMember(node, name, initializer) { @@ -19955,8 +19888,7 @@ var ts; node.expression = expression; node.original = original; node.transformFlags |= - propagateChildFlags(node.expression) | - 1; + propagateChildFlags(node.expression) | 1; ts.setTextRange(node, original); return node; } @@ -24134,17 +24066,20 @@ var ts; return inContext(32768); } function parseErrorAtCurrentToken(message, arg0) { - parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); + return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); } function parseErrorAtPosition(start, length, message, arg0) { var lastError = ts.lastOrUndefined(parseDiagnostics); + var result; if (!lastError || start !== lastError.start) { - parseDiagnostics.push(ts.createDetachedDiagnostic(fileName, start, length, message, arg0)); + result = ts.createDetachedDiagnostic(fileName, start, length, message, arg0); + parseDiagnostics.push(result); } parseErrorBeforeNextFinishedNode = true; + return result; } function parseErrorAt(start, end, message, arg0) { - parseErrorAtPosition(start, end - start, message, arg0); + return parseErrorAtPosition(start, end - start, message, arg0); } function parseErrorAtRange(range, message, arg0) { parseErrorAt(range.pos, range.end, message, arg0); @@ -24267,6 +24202,16 @@ var ts; parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); return false; } + function parseExpectedMatchingBrackets(openKind, closeKind, openPosition) { + if (token() === closeKind) { + nextToken(); + return; + } + var lastError = parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(closeKind)); + if (lastError) { + ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openPosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, ts.tokenToString(openKind), ts.tokenToString(closeKind))); + } + } function parseOptional(t) { if (token() === t) { nextToken(); @@ -24682,8 +24627,7 @@ var ts; var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, false)) { - var element = parseListElement(kind, parseElement); - list.push(element); + list.push(parseListElement(kind, parseElement)); continue; } if (abortParsingListOrMoveToNextToken(kind)) { @@ -26886,10 +26830,11 @@ var ts; } function parseArrayLiteralExpression() { var pos = getNodePos(); + var openBracketPosition = scanner.getTokenPos(); parseExpected(22); var multiLine = scanner.hasPrecedingLineBreak(); var elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(23); + parseExpectedMatchingBrackets(22, 23, openBracketPosition); return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos); } function parseObjectLiteralElement() { @@ -26940,12 +26885,7 @@ var ts; parseExpected(18); var multiLine = scanner.hasPrecedingLineBreak(); var properties = parseDelimitedList(12, parseObjectLiteralElement, true); - if (!parseExpected(19)) { - var lastError = ts.lastOrUndefined(parseDiagnostics); - if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { - ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); - } - } + parseExpectedMatchingBrackets(18, 19, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } function parseFunctionExpression() { @@ -27012,13 +26952,13 @@ var ts; if (parseExpected(18, diagnosticMessage) || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); var statements = parseList(1, parseStatement); - if (!parseExpected(19)) { - var lastError = ts.lastOrUndefined(parseDiagnostics); - if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { - ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); - } + parseExpectedMatchingBrackets(18, 19, openBracePosition); + var result = finishNode(factory.createBlock(statements, multiLine), pos); + if (token() === 62) { + parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); + nextToken(); } - return finishNode(factory.createBlock(statements, multiLine), pos); + return result; } else { var statements = createMissingList(); @@ -27053,9 +26993,10 @@ var ts; function parseIfStatement() { var pos = getNodePos(); parseExpected(98); + var openParenPosition = scanner.getTokenPos(); parseExpected(20); var expression = allowInAnd(parseExpression); - parseExpected(21); + parseExpectedMatchingBrackets(20, 21, openParenPosition); var thenStatement = parseStatement(); var elseStatement = parseOptional(90) ? parseStatement() : undefined; return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos); @@ -27065,18 +27006,20 @@ var ts; parseExpected(89); var statement = parseStatement(); parseExpected(114); + var openParenPosition = scanner.getTokenPos(); parseExpected(20); var expression = allowInAnd(parseExpression); - parseExpected(21); + parseExpectedMatchingBrackets(20, 21, openParenPosition); parseOptional(26); return finishNode(factory.createDoStatement(statement, expression), pos); } function parseWhileStatement() { var pos = getNodePos(); parseExpected(114); + var openParenPosition = scanner.getTokenPos(); parseExpected(20); var expression = allowInAnd(parseExpression); - parseExpected(21); + parseExpectedMatchingBrackets(20, 21, openParenPosition); var statement = parseStatement(); return finishNode(factory.createWhileStatement(expression, statement), pos); } @@ -27139,9 +27082,10 @@ var ts; function parseWithStatement() { var pos = getNodePos(); parseExpected(115); + var openParenPosition = scanner.getTokenPos(); parseExpected(20); var expression = allowInAnd(parseExpression); - parseExpected(21); + parseExpectedMatchingBrackets(20, 21, openParenPosition); var statement = doInsideOfContext(16777216, parseStatement); return finishNode(factory.createWithStatement(expression, statement), pos); } @@ -28880,8 +28824,7 @@ var ts; hasChildren = true; if (child.kind === 333) { if (childTypeTag) { - parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); - var lastError = ts.lastOrUndefined(parseDiagnostics); + var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, 0, 0, ts.Diagnostics.The_tag_was_first_specified_here)); } @@ -28911,7 +28854,7 @@ var ts; comment = parseTrailingTagComments(start, end, indent, indentText); } var typedefTag = factory.createJSDocTypedefTag(tagName, typeExpression, fullName, comment); - return finishNode(typedefTag, start); + return finishNode(typedefTag, start, end); } function parseJSDocTypeNameWithNamespace(nested) { var pos = scanner.getTokenPos(); @@ -34986,8 +34929,7 @@ var ts; } var identifier = prop.name; var currentKind = prop.kind === 289 || prop.kind === 290 || prop.kind === 166 - ? 1 - : 2; + ? 1 : 2; var existingKind = seen.get(identifier.escapedText); if (!existingKind) { seen.set(identifier.escapedText, currentKind); @@ -35522,8 +35464,7 @@ var ts; case 337: var propTag = node; var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 308 ? - 4 | 16777216 : - 4; + 4 | 16777216 : 4; return declareSymbolAndAddToSymbolTable(propTag, flags, 0); case 335: case 328: @@ -35558,8 +35499,7 @@ var ts; } else { var flags = ts.exportAssignmentIsAlias(node) - ? 2097152 - : 4; + ? 2097152 : 4; var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863); if (node.isExportEquals) { ts.setValueDeclaration(symbol, node); @@ -35654,8 +35594,7 @@ var ts; return; } var flags = ts.exportAssignmentIsAlias(node) - ? 2097152 - : 4 | 1048576 | 512; + ? 2097152 : 4 | 1048576 | 512; var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864, 0); ts.setValueDeclaration(symbol, node); } @@ -41395,8 +41334,7 @@ var ts; } else { var flags = !(symbol.flags & 2) ? undefined - : isConstVariable(symbol) ? 2 - : 1; + : isConstVariable(symbol) ? 2 : 1; var name = (needsPostExportDefault || !(symbol.flags & 4)) ? localName : getUnusedName(localName, symbol); var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { @@ -41850,9 +41788,7 @@ var ts; var statement = ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(varName, undefined, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) ], 2)); - addResult(statement, target && target.flags & 4 && target.escapedName === "export=" ? 2 - : name === varName ? 1 - : 0); + addResult(statement, target && target.flags & 4 && target.escapedName === "export=" ? 2 : name === varName ? 1 : 0); } if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment(undefined, undefined, isExportEquals, ts.factory.createIdentifier(varName))); @@ -46569,8 +46505,7 @@ var ts; return getRestTypeElementFlags(node); case 193: return node.questionToken ? 2 : - node.dotDotDotToken ? getRestTypeElementFlags(node) : - 1; + node.dotDotDotToken ? getRestTypeElementFlags(node) : 1; default: return 1; } @@ -49680,8 +49615,7 @@ var ts; } } var related = source.type === target.type ? -1 : - source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : - 0; + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : 0; if (related === 0 && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -50795,6 +50729,9 @@ var ts; } } else if (target.flags & 134217728) { + if (source.flags & 134217728) { + instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + } var result_8 = inferTypesFromTemplateLiteralType(source, target); if (result_8 && ts.every(result_8, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) { return -1; @@ -50834,20 +50771,6 @@ var ts; return result; } } - else if (source.flags & 134217728) { - if (target.flags & 134217728 && - source.texts.length === target.texts.length && - source.types.length === target.types.length && - ts.every(source.texts, function (t, i) { return t === target.texts[i]; }) && - ts.every(instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)).types, function (t, i) { return !!(target.types[i].flags & (1 | 4)) || !!isRelatedTo(t, target.types[i], false); })) { - return -1; - } - var constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, reportErrors))) { - resetErrorInfo(saveErrorInfo); - return result; - } - } else if (source.flags & 268435456) { if (target.flags & 268435456 && source.symbol === target.symbol) { if (result = isRelatedTo(source.type, target.type, reportErrors)) { @@ -51422,10 +51345,8 @@ var ts; } var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration); var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration); - var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1) ? - 0 : kind); - var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1) ? - 0 : kind); + var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1) ? 0 : kind); + var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1) ? 0 : kind); if (kind === 1 && sourceSignatures.length && targetSignatures.length) { var sourceIsAbstract = !!(sourceSignatures[0].flags & 4); var targetIsAbstract = !!(targetSignatures[0].flags & 4); @@ -51993,8 +51914,7 @@ var ts; function compareTypePredicatesIdentical(source, target, compareTypes) { return !(source && target && typePredicateKindsMatch(source, target)) ? 0 : source.type === target.type ? -1 : - source.type && target.type ? compareTypes(source.type, target.type) : - 0; + source.type && target.type ? compareTypes(source.type, target.type) : 0; } function literalTypesWithSameBaseType(types) { var commonBaseType; @@ -52040,7 +51960,12 @@ var ts; return isArrayType(type) ? getTypeArguments(type)[0] : undefined; } function isArrayLikeType(type) { - return isArrayType(type) || !(type.flags & 98304) && isTypeAssignableTo(type, anyReadonlyArrayType); + return isArrayType(type) || hasArrayOrReadonlyArrayBaseType(type) || !(type.flags & 98304) && isTypeAssignableTo(type, anyReadonlyArrayType); + } + function hasArrayOrReadonlyArrayBaseType(type) { + return !!(ts.getObjectFlags(type) & 4) + && !!(ts.getObjectFlags(type.target) & 3) + && ts.some(getBaseTypes(type.target), isArrayType); } function isEmptyArrayLiteralType(type) { var elementType = getElementTypeOfArrayType(type); @@ -53211,9 +53136,7 @@ var ts; if (inference && !inference.isFixed && !isFromInferenceBlockedSource(source)) { var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); if (inferredType) { - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 ? - 8 : - 4); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 ? 8 : 4); } } return true; @@ -57850,7 +57773,7 @@ var ts; if (isInPropertyInitializer(node) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !isPropertyDeclaredInAncestorClass(prop)) { + && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } else if (valueDeclaration.kind === 253 && @@ -58188,8 +58111,7 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 2 | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 : 0) : - 0; + 2 | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 : 0) : 0; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, undefined, node, accessFlags | 16) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } @@ -58958,14 +58880,14 @@ var ts; var i_1 = 0; var _loop_22 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; - var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0, true, chain_2); - if (diags_2) { - if (diags_2.length <= min_3) { - min_3 = diags_2.length; + var diags_3 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0, true, chain_2); + if (diags_3) { + if (diags_3.length <= min_3) { + min_3 = diags_3.length; minIndex = i_1; } - max = Math.max(max, diags_2.length); - allDiagnostics.push(diags_2); + max = Math.max(max, diags_3.length); + allDiagnostics.push(diags_3); } else { ts.Debug.fail("No error for 3 or fewer overload signatures"); @@ -58976,13 +58898,13 @@ var ts; var c = candidatesForArgumentError_1[_a]; _loop_22(c); } - var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); - ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); - var chain = ts.chainDiagnosticMessages(ts.map(diags_3, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call); - var related = __spreadArray([], ts.flatMap(diags_3, function (d) { return d.relatedInformation; })); + var diags_2 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); + ts.Debug.assert(diags_2.length > 0, "No errors reported for 3 or fewer overload signatures"); + var chain = ts.chainDiagnosticMessages(ts.map(diags_2, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call); + var related = __spreadArray([], ts.flatMap(diags_2, function (d) { return d.relatedInformation; })); var diag = void 0; - if (ts.every(diags_3, function (d) { return d.start === diags_3[0].start && d.length === diags_3[0].length && d.file === diags_3[0].file; })) { - var _b = diags_3[0], file = _b.file, start = _b.start, length_7 = _b.length; + if (ts.every(diags_2, function (d) { return d.start === diags_2[0].start && d.length === diags_2[0].length && d.file === diags_2[0].file; })) { + var _b = diags_2[0], file = _b.file, start = _b.start, length_7 = _b.length; diag = { file: file, start: start, length: length_7, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related }; } else { @@ -59218,8 +59140,7 @@ var ts; if (ts.isCallChain(node)) { var nonOptionalType = getOptionalExpressionType(funcType, node.expression); callChainFlags = nonOptionalType === funcType ? 0 : - ts.isOutermostOptionalChain(node) ? 16 : - 8; + ts.isOutermostOptionalChain(node) ? 16 : 8; funcType = nonOptionalType; } else { @@ -59876,10 +59797,8 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 252 - : resolvedRequire.flags & 3 - ? 250 - : 0; + ? 252 : resolvedRequire.flags & 3 + ? 250 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); return !!decl && !!(decl.flags & 8388608); @@ -64136,12 +64055,7 @@ var ts; if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { return false; } - var interestingFlags = 8 | - 16 | - 256 | - 128 | - 64 | - 32; + var interestingFlags = 8 | 16 | 256 | 128 | 64 | 32; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { @@ -64179,7 +64093,7 @@ var ts; if (getFalsyFlags(type)) return; if (getAwaitedTypeOfPromise(type)) { - errorAndMaybeSuggestAwait(condExpr, true, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", getTypeNameForErrorDisplay(type), "false"); + errorAndMaybeSuggestAwait(condExpr, true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined, getTypeNameForErrorDisplay(type)); return; } var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr; @@ -64203,7 +64117,7 @@ var ts; var isUsed = ts.isBinaryExpression(condExpr.parent) && isFunctionUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) || body && isFunctionUsedInConditionBody(condExpr, body, testedNode, testedSymbol); if (!isUsed) { - error(location, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead); } } function isFunctionUsedInConditionBody(expr, body, testedNode, testedSymbol) { @@ -65072,6 +64986,7 @@ var ts; switch (name.escapedText) { case "any": case "unknown": + case "never": case "number": case "bigint": case "boolean": @@ -65518,9 +65433,9 @@ var ts; ts.forEach(properties, function (p) { seen.set(p.escapedName, p); }); for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; - var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) { - var prop = properties_4[_a]; + var properties_4 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); + for (var _a = 0, properties_5 = properties_4; _a < properties_5.length; _a++) { + var prop = properties_5[_a]; var existing = seen.get(prop.escapedName); if (existing && !isPropertyIdenticalTo(existing, prop)) { seen.delete(prop.escapedName); @@ -73343,9 +73258,7 @@ var ts; } function visitPrefixUnaryExpression(node) { if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { - var operator = node.operator === 45 ? - 39 : node.operator === 46 ? - 40 : undefined; + var operator = node.operator === 45 ? 39 : node.operator === 46 ? 40 : undefined; var info = void 0; if (operator && (info = accessPrivateIdentifier(node.operand.name))) { var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); @@ -73358,9 +73271,7 @@ var ts; } function visitPostfixUnaryExpression(node, valueIsDiscarded) { if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { - var operator = node.operator === 45 ? - 39 : node.operator === 46 ? - 40 : undefined; + var operator = node.operator === 45 ? 39 : node.operator === 46 ? 40 : undefined; var info = void 0; if (operator && (info = accessPrivateIdentifier(node.operand.name))) { var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); @@ -74733,9 +74644,7 @@ var ts; return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(2, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? - 0 : - 1); + var ancestorFacts = enterSubtree(2, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? 0 : 1); exportedVariableStatement = false; var visited = ts.visitEachChild(node, visitor, context); var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [ @@ -82165,13 +82074,7 @@ var ts; }); } ts.isInternalDeclaration = isInternalDeclaration; - var declarationEmitNodeBuilderFlags = 1024 | - 2048 | - 4096 | - 8 | - 524288 | - 4 | - 1; + var declarationEmitNodeBuilderFlags = 1024 | 2048 | 4096 | 8 | 524288 | 4 | 1; function transformDeclarations(context) { var throwDiagnostic = function () { return ts.Debug.fail("Diagnostic emitted without context"); }; var getSymbolAccessibilityDiagnostic = throwDiagnostic; @@ -83900,11 +83803,8 @@ var ts; if (configFile.options.emitDeclarationOnly) return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json"); - var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), isJsonFile ? - ".json" : - configFile.options.jsx === 1 && (ts.fileExtensionIs(inputFileName, ".tsx") || ts.fileExtensionIs(inputFileName, ".jsx")) ? - ".jsx" : - ".js"); + var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), isJsonFile ? ".json" : + configFile.options.jsx === 1 && (ts.fileExtensionIs(inputFileName, ".tsx") || ts.fileExtensionIs(inputFileName, ".jsx")) ? ".jsx" : ".js"); return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 ? outputFileName : undefined; @@ -85289,9 +85189,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 295 ? - "text" : - "internal"); + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 295 ? "text" : "internal"); } } function emitUnparsedSyntheticReference(unparsed) { @@ -94176,8 +94074,7 @@ var ts; return { relativePreference: importModuleSpecifierPreference === "relative" ? 0 : importModuleSpecifierPreference === "non-relative" ? 1 : - importModuleSpecifierPreference === "project-relative" ? 3 : - 2, + importModuleSpecifierPreference === "project-relative" ? 3 : 2, ending: getEnding(), }; function getEnding() { @@ -94185,16 +94082,14 @@ var ts; case "minimal": return 0; case "index": return 1; case "js": return 2; - default: return usesJsExtensionOnImports(importingSourceFile) ? 2 - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 : 0; + default: return usesJsExtensionOnImports(importingSourceFile) ? 2 : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 : 0; } } } function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 : 1, - ending: ts.hasJSFileExtension(oldImportSpecifier) ? - 2 : + ending: ts.hasJSFileExtension(oldImportSpecifier) ? 2 : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 : 0, }; } @@ -96977,8 +96872,13 @@ var ts; continue; } var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames()); + if (!outputs.length) + continue; + var inputFileNames = new ts.Set(parsed.fileNames.map(function (f) { return toPath(state, f); })); for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) { var output = outputs_3[_a]; + if (inputFileNames.has(toPath(state, output))) + continue; if (host.fileExists(output)) { if (filesToDelete) { filesToDelete.push(output); diff --git a/lib/tsserver.js b/lib/tsserver.js index a9d19f4f7ea..2ebe0565b4e 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -1653,8 +1653,7 @@ var ts; return a === b ? 0 /* EqualTo */ : a === undefined ? -1 /* LessThan */ : b === undefined ? 1 /* GreaterThan */ : - a < b ? -1 /* LessThan */ : - 1 /* GreaterThan */; + a < b ? -1 /* LessThan */ : 1 /* GreaterThan */; } /** * Compare two numeric values for their order relative to each other. @@ -7657,8 +7656,7 @@ var ts; if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) - ? 1 /* Normal */ - : 0 /* None */); + ? 1 /* Normal */ : 0 /* None */); } if (ts.sys && ts.sys.debugMode) { ts.Debug.isDebugging = true; @@ -7677,7 +7675,7 @@ var ts; Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), - The_parser_expected_to_find_a_to_match_the_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_to_match_the_token_here_1007", "The parser expected to find a '}' to match the '{' token here."), + The_parser_expected_to_find_a_1_to_match_the_0_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_1_to_match_the_0_token_here_1007", "The parser expected to find a '{1}' to match the '{0}' token here."), Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), @@ -8463,7 +8461,7 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), - This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_2774", "This condition will always return true since this function appears to always be defined. Did you mean to call it instead?"), Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), @@ -8490,7 +8488,7 @@ var ts; The_declaration_was_marked_as_deprecated_here: diag(2798, ts.DiagnosticCategory.Error, "The_declaration_was_marked_as_deprecated_here_2798", "The declaration was marked as deprecated here."), Type_produces_a_tuple_type_that_is_too_large_to_represent: diag(2799, ts.DiagnosticCategory.Error, "Type_produces_a_tuple_type_that_is_too_large_to_represent_2799", "Type produces a tuple type that is too large to represent."), Expression_produces_a_tuple_type_that_is_too_large_to_represent: diag(2800, ts.DiagnosticCategory.Error, "Expression_produces_a_tuple_type_that_is_too_large_to_represent_2800", "Expression produces a tuple type that is too large to represent."), - This_condition_will_always_return_true_since_the_Promise_is_always_truthy: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_Promise_is_always_truthy_2801", "This condition will always return true since the Promise is always truthy."), + This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined_2801", "This condition will always return true since this '{0}' appears to always be defined."), Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."), Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."), Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."), @@ -8498,6 +8496,7 @@ var ts; Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."), This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."), A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), + Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "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: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -12974,7 +12973,7 @@ var ts; case 105 /* SuperKeyword */: case 226 /* NonNullExpression */: case 227 /* MetaProperty */: - case 99 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 99 /* ImportKeyword */: return true; default: return false; @@ -16038,8 +16037,7 @@ var ts; case 217 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : - 0 /* None */; + binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; case 215 /* PrefixUnaryExpression */: case 216 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; @@ -18464,8 +18462,7 @@ var ts; if (getCheckFlags(s) & 6 /* Synthetic */) { var checkFlags = s.checkFlags; var accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : - checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : - 16 /* Protected */; + checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : 16 /* Protected */; var staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; return accessModifier | staticModifier; } @@ -18997,8 +18994,7 @@ var ts; } function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || - compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; + compareRelatedInformation(d1, d2) || 0 /* EqualTo */; } ts.compareDiagnostics = compareDiagnostics; function compareDiagnosticsSkipRelatedInformation(d1, d2) { @@ -19006,8 +19002,7 @@ var ts; ts.compareValues(d1.start, d2.start) || ts.compareValues(d1.length, d2.length) || ts.compareValues(d1.code, d2.code) || - compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; + compareMessageText(d1.messageText, d2.messageText) || 0 /* EqualTo */; } ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; function compareRelatedInformation(d1, d2) { @@ -19841,15 +19836,15 @@ var ts; var log2Base; switch (stringValue.charCodeAt(1)) { // "x" in "0x123" case 98 /* b */: - case 66 /* B */: // 0b or 0B + case 66 /* B */: log2Base = 1; break; case 111 /* o */: - case 79 /* O */: // 0o or 0O + case 79 /* O */: log2Base = 3; break; case 120 /* x */: - case 88 /* X */: // 0x or 0X + case 88 /* X */: log2Base = 4; break; default: // already in decimal; omit trailing "n" @@ -21492,8 +21487,7 @@ var ts; case 129 /* AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */; break; case 122 /* PublicKeyword */: case 120 /* PrivateKeyword */: @@ -21512,7 +21506,7 @@ var ts; case 148 /* SymbolKeyword */: case 113 /* VoidKeyword */: case 152 /* UnknownKeyword */: - case 150 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + case 150 /* UndefinedKeyword */: transformFlags = 1 /* ContainsTypeScript */; break; case 123 /* StaticKeyword */: @@ -21625,9 +21619,7 @@ var ts; var node = createBaseNode(159 /* ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 512 /* ContainsES2015 */ | - 65536 /* ContainsComputedPropertyName */; + propagateChildFlags(node.expression) | 512 /* ContainsES2015 */ | 65536 /* ContainsComputedPropertyName */; return node; } // @api @@ -21695,9 +21687,7 @@ var ts; var node = createBaseNode(162 /* Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */ | - 4096 /* ContainsTypeScriptClassSyntax */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */ | 4096 /* ContainsTypeScriptClassSyntax */; return node; } // @api @@ -21734,8 +21724,7 @@ var ts; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | - propagateChildFlags(node.exclamationToken) | - 8388608 /* ContainsClassFields */; + propagateChildFlags(node.exclamationToken) | 8388608 /* ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; } @@ -21782,8 +21771,7 @@ var ts; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | - propagateChildFlags(node.questionToken) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.questionToken) | 512 /* ContainsES2015 */; if (questionToken) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22311,13 +22299,10 @@ var ts; var node = createBaseNode(197 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= - propagateChildrenFlags(node.elements) | - 512 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; + propagateChildrenFlags(node.elements) | 512 /* ContainsES2015 */ | 262144 /* ContainsBindingPattern */; if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { node.transformFlags |= - 64 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + 64 /* ContainsES2018 */ | 32768 /* ContainsObjectRestOrSpread */; } return node; } @@ -22332,9 +22317,7 @@ var ts; var node = createBaseNode(198 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= - propagateChildrenFlags(node.elements) | - 512 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; + propagateChildrenFlags(node.elements) | 512 /* ContainsES2015 */ | 262144 /* ContainsBindingPattern */; return node; } // @api @@ -22351,8 +22334,7 @@ var ts; node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= - propagateChildFlags(node.dotDotDotToken) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.dotDotDotToken) | 512 /* ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : @@ -22421,8 +22403,7 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */; } return node; } @@ -22475,8 +22456,7 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */; } return node; } @@ -22500,8 +22480,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | - propagateChildFlags(node.argumentExpression) | - 16 /* ContainsES2020 */; + propagateChildFlags(node.argumentExpression) | 16 /* ContainsES2020 */; return node; } // @api @@ -22559,8 +22538,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | - propagateChildrenFlags(node.arguments) | - 16 /* ContainsES2020 */; + propagateChildrenFlags(node.arguments) | 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22588,8 +22566,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - propagateChildrenFlags(node.arguments) | - 16 /* ContainsES2020 */; + propagateChildrenFlags(node.arguments) | 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22612,8 +22589,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.template) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.template) | 512 /* ContainsES2015 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22637,8 +22613,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.type) | 1 /* ContainsTypeScript */; return node; } // @api @@ -22702,8 +22677,7 @@ var ts; /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); node.transformFlags |= - propagateChildFlags(node.equalsGreaterThanToken) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.equalsGreaterThanToken) | 512 /* ContainsES2015 */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { node.transformFlags |= 128 /* ContainsES2017 */; } @@ -22764,10 +22738,7 @@ var ts; var node = createBaseExpression(214 /* AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */ | - 1048576 /* ContainsAwait */; + propagateChildFlags(node.expression) | 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */ | 1048576 /* ContainsAwait */; return node; } // @api @@ -22822,15 +22793,12 @@ var ts; else if (operatorKind === 62 /* EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 512 /* ContainsES2015 */ | - 64 /* ContainsES2018 */ | - 2048 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | 64 /* ContainsES2018 */ | 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 512 /* ContainsES2015 */ | - 2048 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } @@ -22906,8 +22874,7 @@ var ts; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | - propagateChildrenFlags(node.templateSpans) | - 512 /* ContainsES2015 */; + propagateChildrenFlags(node.templateSpans) | 512 /* ContainsES2015 */; return node; } // @api @@ -22976,10 +22943,7 @@ var ts; node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.asteriskToken) | - 512 /* ContainsES2015 */ | - 64 /* ContainsES2018 */ | - 524288 /* ContainsYield */; + propagateChildFlags(node.asteriskToken) | 512 /* ContainsES2015 */ | 64 /* ContainsES2018 */ | 524288 /* ContainsYield */; return node; } // @api @@ -22994,9 +22958,7 @@ var ts; var node = createBaseExpression(221 /* SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 512 /* ContainsES2015 */ | - 16384 /* ContainsRestOrSpread */; + propagateChildFlags(node.expression) | 512 /* ContainsES2015 */ | 16384 /* ContainsRestOrSpread */; return node; } // @api @@ -23033,8 +22995,7 @@ var ts; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildrenFlags(node.typeArguments) | - 512 /* ContainsES2015 */; + propagateChildrenFlags(node.typeArguments) | 512 /* ContainsES2015 */; return node; } // @api @@ -23051,8 +23012,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.type) | 1 /* ContainsTypeScript */; return node; } // @api @@ -23067,8 +23027,7 @@ var ts; var node = createBaseExpression(226 /* NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */; return node; } // @api @@ -23086,8 +23045,7 @@ var ts; node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */; return node; } // @api @@ -23131,8 +23089,7 @@ var ts; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.literal) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.literal) | 512 /* ContainsES2015 */; return node; } // @api @@ -23308,8 +23265,7 @@ var ts; propagateChildFlags(node.awaitModifier) | propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | - propagateChildFlags(node.statement) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.statement) | 512 /* ContainsES2015 */; if (awaitModifier) node.transformFlags |= 64 /* ContainsES2018 */; return node; @@ -23328,8 +23284,7 @@ var ts; var node = createBaseNode(241 /* ContinueStatement */); node.label = asName(label); node.transformFlags |= - propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.label) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23343,8 +23298,7 @@ var ts; var node = createBaseNode(242 /* BreakStatement */); node.label = asName(label); node.transformFlags |= - propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.label) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23359,9 +23313,7 @@ var ts; node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= - propagateChildFlags(node.expression) | - 64 /* ContainsES2018 */ | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.expression) | 64 /* ContainsES2018 */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23486,12 +23438,10 @@ var ts; node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= - propagateChildrenFlags(node.declarations) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildrenFlags(node.declarations) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (flags & 3 /* BlockScoped */) { node.transformFlags |= - 512 /* ContainsES2015 */ | - 131072 /* ContainsBlockScopedBinding */; + 512 /* ContainsES2015 */ | 131072 /* ContainsBlockScopedBinding */; } return node; } @@ -23510,8 +23460,7 @@ var ts; } else { node.transformFlags |= - propagateChildFlags(node.asteriskToken) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.asteriskToken) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (node.asteriskToken) { node.transformFlags |= 64 /* ContainsES2018 */; @@ -23604,8 +23553,7 @@ var ts; var node = createBaseNamedDeclaration(256 /* EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= - propagateChildrenFlags(node.members) | - 1 /* ContainsTypeScript */; + propagateChildrenFlags(node.members) | 1 /* ContainsTypeScript */; node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` return node; } @@ -23631,8 +23579,7 @@ var ts; else { node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.body) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.body) | 1 /* ContainsTypeScript */; } node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. return node; @@ -23769,8 +23716,7 @@ var ts; var node = createBaseNode(270 /* NamespaceExport */); node.name = name; node.transformFlags |= - propagateChildFlags(node.name) | - 4 /* ContainsESNext */; + propagateChildFlags(node.name) | 4 /* ContainsESNext */; node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } @@ -24276,8 +24222,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.openingElement) | propagateChildrenFlags(node.children) | - propagateChildFlags(node.closingElement) | - 2 /* ContainsJsx */; + propagateChildFlags(node.closingElement) | 2 /* ContainsJsx */; return node; } // @api @@ -24297,8 +24242,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + propagateChildFlags(node.attributes) | 2 /* ContainsJsx */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -24321,8 +24265,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + propagateChildFlags(node.attributes) | 2 /* ContainsJsx */; if (typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -24341,8 +24284,7 @@ var ts; var node = createBaseNode(277 /* JsxClosingElement */); node.tagName = tagName; node.transformFlags |= - propagateChildFlags(node.tagName) | - 2 /* ContainsJsx */; + propagateChildFlags(node.tagName) | 2 /* ContainsJsx */; return node; } // @api @@ -24360,8 +24302,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.openingFragment) | propagateChildrenFlags(node.children) | - propagateChildFlags(node.closingFragment) | - 2 /* ContainsJsx */; + propagateChildFlags(node.closingFragment) | 2 /* ContainsJsx */; return node; } // @api @@ -24406,8 +24347,7 @@ var ts; node.initializer = initializer; node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.initializer) | - 2 /* ContainsJsx */; + propagateChildFlags(node.initializer) | 2 /* ContainsJsx */; return node; } // @api @@ -24422,8 +24362,7 @@ var ts; var node = createBaseNode(282 /* JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= - propagateChildrenFlags(node.properties) | - 2 /* ContainsJsx */; + propagateChildrenFlags(node.properties) | 2 /* ContainsJsx */; return node; } // @api @@ -24437,8 +24376,7 @@ var ts; var node = createBaseNode(283 /* JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= - propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + propagateChildFlags(node.expression) | 2 /* ContainsJsx */; return node; } // @api @@ -24454,8 +24392,7 @@ var ts; node.expression = expression; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + propagateChildFlags(node.expression) | 2 /* ContainsJsx */; return node; } // @api @@ -24584,8 +24521,7 @@ var ts; /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= - propagateChildFlags(node.objectAssignmentInitializer) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.objectAssignmentInitializer) | 512 /* ContainsES2015 */; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -24614,9 +24550,7 @@ var ts; var node = createBaseNode(291 /* SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 64 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + propagateChildFlags(node.expression) | 64 /* ContainsES2018 */ | 32768 /* ContainsObjectRestOrSpread */; return node; } // @api @@ -24635,8 +24569,7 @@ var ts; node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.initializer) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.initializer) | 1 /* ContainsTypeScript */; return node; } // @api @@ -24812,8 +24745,7 @@ var ts; node.expression = expression; node.original = original; node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */; ts.setTextRange(node, original); return node; } @@ -29941,20 +29873,23 @@ var ts; return inContext(32768 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { - parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); + return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); } function parseErrorAtPosition(start, length, message, arg0) { // Don't report another error if it would just be at the same position as the last error. var lastError = ts.lastOrUndefined(parseDiagnostics); + var result; if (!lastError || start !== lastError.start) { - parseDiagnostics.push(ts.createDetachedDiagnostic(fileName, start, length, message, arg0)); + result = ts.createDetachedDiagnostic(fileName, start, length, message, arg0); + parseDiagnostics.push(result); } // Mark that we've encountered an error. We'll set an appropriate bit on the next // node we finish so that it can't be reused incrementally. parseErrorBeforeNextFinishedNode = true; + return result; } function parseErrorAt(start, end, message, arg0) { - parseErrorAtPosition(start, end - start, message, arg0); + return parseErrorAtPosition(start, end - start, message, arg0); } function parseErrorAtRange(range, message, arg0) { parseErrorAt(range.pos, range.end, message, arg0); @@ -30111,6 +30046,16 @@ var ts; parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); return false; } + function parseExpectedMatchingBrackets(openKind, closeKind, openPosition) { + if (token() === closeKind) { + nextToken(); + return; + } + var lastError = parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(closeKind)); + if (lastError) { + ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openPosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, ts.tokenToString(openKind), ts.tokenToString(closeKind))); + } + } function parseOptional(t) { if (token() === t) { nextToken(); @@ -30399,7 +30344,7 @@ var ts; case 22 /* OpenBracketToken */: case 41 /* AsteriskToken */: case 25 /* DotDotDotToken */: - case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 24 /* DotToken */: return true; default: return isLiteralPropertyName(); @@ -30432,7 +30377,7 @@ var ts; case 15 /* ArrayLiteralMembers */: switch (token()) { case 27 /* CommaToken */: - case 24 /* DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) + case 24 /* DotToken */: return true; } // falls through @@ -30588,8 +30533,7 @@ var ts; var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, /*inErrorRecovery*/ false)) { - var element = parseListElement(kind, parseElement); - list.push(element); + list.push(parseListElement(kind, parseElement)); continue; } if (abortParsingListOrMoveToNextToken(kind)) { @@ -33393,7 +33337,7 @@ var ts; case 50 /* AmpersandToken */: // foo & case 51 /* BarToken */: // foo | case 19 /* CloseBraceToken */: // foo } - case 1 /* EndOfFileToken */: // foo + case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal // expressions either. The user is probably in the middle of a generic type. So // treat it as such. @@ -33477,10 +33421,11 @@ var ts; } function parseArrayLiteralExpression() { var pos = getNodePos(); + var openBracketPosition = scanner.getTokenPos(); parseExpected(22 /* OpenBracketToken */); var multiLine = scanner.hasPrecedingLineBreak(); var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(23 /* CloseBracketToken */); + parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketPosition); return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos); } function parseObjectLiteralElement() { @@ -33540,12 +33485,7 @@ var ts; parseExpected(18 /* OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { - var lastError = ts.lastOrUndefined(parseDiagnostics); - if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { - ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); - } - } + parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } function parseFunctionExpression() { @@ -33618,13 +33558,13 @@ var ts; if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); var statements = parseList(1 /* BlockStatements */, parseStatement); - if (!parseExpected(19 /* CloseBraceToken */)) { - var lastError = ts.lastOrUndefined(parseDiagnostics); - if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { - ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); - } + parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBracePosition); + var result = finishNode(factory.createBlock(statements, multiLine), pos); + if (token() === 62 /* EqualsToken */) { + parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); + nextToken(); } - return finishNode(factory.createBlock(statements, multiLine), pos); + return result; } else { var statements = createMissingList(); @@ -33661,9 +33601,10 @@ var ts; function parseIfStatement() { var pos = getNodePos(); parseExpected(98 /* IfKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); var thenStatement = parseStatement(); var elseStatement = parseOptional(90 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos); @@ -33673,9 +33614,10 @@ var ts; parseExpected(89 /* DoKeyword */); var statement = parseStatement(); parseExpected(114 /* WhileKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby @@ -33686,9 +33628,10 @@ var ts; function parseWhileStatement() { var pos = getNodePos(); parseExpected(114 /* WhileKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); var statement = parseStatement(); return finishNode(factory.createWhileStatement(expression, statement), pos); } @@ -33751,9 +33694,10 @@ var ts; function parseWithStatement() { var pos = getNodePos(); parseExpected(115 /* WithKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); return finishNode(factory.createWithStatement(expression, statement), pos); } @@ -34452,7 +34396,7 @@ var ts; case 53 /* ExclamationToken */: // Non-null assertion on property name case 58 /* ColonToken */: // Type Annotation for declaration case 62 /* EqualsToken */: // Initializer for declaration - case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 57 /* QuestionToken */: return true; default: // Covers @@ -35736,8 +35680,7 @@ var ts; hasChildren = true; if (child.kind === 333 /* JSDocTypeTag */) { if (childTypeTag) { - parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); - var lastError = ts.lastOrUndefined(parseDiagnostics); + var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, 0, 0, ts.Diagnostics.The_tag_was_first_specified_here)); } @@ -35768,7 +35711,7 @@ var ts; comment = parseTrailingTagComments(start, end, indent, indentText); } var typedefTag = factory.createJSDocTypedefTag(tagName, typeExpression, fullName, comment); - return finishNode(typedefTag, start); + return finishNode(typedefTag, start, end); } function parseJSDocTypeNameWithNamespace(nested) { var pos = scanner.getTokenPos(); @@ -42853,8 +42796,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 = prop.kind === 289 /* PropertyAssignment */ || prop.kind === 290 /* ShorthandPropertyAssignment */ || prop.kind === 166 /* MethodDeclaration */ - ? 1 /* Property */ - : 2 /* Accessor */; + ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); if (!existingKind) { seen.set(identifier.escapedText, currentKind); @@ -43375,7 +43317,7 @@ var ts; case 252 /* FunctionDeclaration */: return bindFunctionDeclaration(node); case 167 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); + return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, 0 /* None */); case 168 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); case 169 /* SetAccessor */: @@ -43468,8 +43410,7 @@ var ts; case 337 /* JSDocPropertyTag */: var propTag = node; var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 308 /* JSDocOptionalType */ ? - 4 /* Property */ | 16777216 /* Optional */ : - 4 /* Property */; + 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); case 335 /* JSDocTypedefTag */: case 328 /* JSDocCallbackTag */: @@ -43507,9 +43448,9 @@ var ts; else { var flags = ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; - ? 2097152 /* Alias */ - // An export default clause with any other expression exports a value - : 4 /* Property */; + ? 2097152 /* Alias */ + // An export default clause with any other expression exports a value + : 4 /* Property */; // If there is an `export default x;` alias declaration, can't `export default` anything else. // (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.) var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */); @@ -43618,8 +43559,7 @@ var ts; } // 'module.exports = expr' assignment var flags = ts.exportAssignmentIsAlias(node) - ? 2097152 /* Alias */ - : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; + ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); ts.setValueDeclaration(symbol, node); } @@ -46402,7 +46342,7 @@ var ts; case 254 /* InterfaceDeclaration */: case 256 /* EnumDeclaration */: case 255 /* TypeAliasDeclaration */: - case 257 /* ModuleDeclaration */: // For `namespace N { N; }` + case 257 /* ModuleDeclaration */: return true; default: return false; @@ -50304,8 +50244,7 @@ var ts; // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined - : isConstVariable(symbol) ? 2 /* Const */ - : 1 /* Let */; + : isConstVariable(symbol) ? 2 /* Const */ : 1 /* Let */; var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { @@ -50945,9 +50884,7 @@ var ts; ], 2 /* Const */)); // Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`. // Otherwise, the type itself should be exported. - addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ - : name === varName ? 1 /* Export */ - : 0 /* None */); + addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ : name === varName ? 1 /* Export */ : 0 /* None */); } if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( @@ -56315,8 +56252,7 @@ var ts; return getRestTypeElementFlags(node); case 193 /* NamedTupleMember */: return node.questionToken ? 2 /* Optional */ : - node.dotDotDotToken ? getRestTypeElementFlags(node) : - 1 /* Required */; + node.dotDotDotToken ? getRestTypeElementFlags(node) : 1 /* Required */; default: return 1 /* Required */; } @@ -56893,7 +56829,7 @@ var ts; } function createUnionType(types, aliasSymbol, aliasTypeArguments, origin) { var result = createType(1048576 /* Union */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + result.objectFlags = getPropagatingFlagsOfTypes(types, 98304 /* Nullable */); result.types = types; result.origin = origin; result.aliasSymbol = aliasSymbol; @@ -57081,7 +57017,7 @@ var ts; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { var result = createType(2097152 /* Intersection */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + result.objectFlags = getPropagatingFlagsOfTypes(types, 98304 /* Nullable */); result.types = types; result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; @@ -59068,7 +59004,7 @@ var ts; case 209 /* FunctionExpression */: case 210 /* ArrowFunction */: case 166 /* MethodDeclaration */: - case 252 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 252 /* FunctionDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); case 201 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); @@ -59792,8 +59728,7 @@ var ts; } } var related = source.type === target.type ? -1 /* True */ : - source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : - 0 /* False */; + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : 0 /* False */; if (related === 0 /* False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -61108,6 +61043,11 @@ var ts; } } else if (target.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TemplateLiteral */) { + // Report unreliable variance for type variables referenced in template literal type placeholders. + // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string. + instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + } var result_8 = inferTypesFromTemplateLiteralType(source, target); if (result_8 && ts.every(result_8, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) { return -1 /* True */; @@ -61151,20 +61091,6 @@ var ts; return result; } } - else if (source.flags & 134217728 /* TemplateLiteral */) { - if (target.flags & 134217728 /* TemplateLiteral */ && - source.texts.length === target.texts.length && - source.types.length === target.types.length && - ts.every(source.texts, function (t, i) { return t === target.texts[i]; }) && - ts.every(instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)).types, function (t, i) { return !!(target.types[i].flags & (1 /* Any */ | 4 /* String */)) || !!isRelatedTo(t, target.types[i], /*reportErrors*/ false); })) { - return -1 /* True */; - } - var constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, reportErrors))) { - resetErrorInfo(saveErrorInfo); - return result; - } - } else if (source.flags & 268435456 /* StringMapping */) { if (target.flags & 268435456 /* StringMapping */ && source.symbol === target.symbol) { if (result = isRelatedTo(source.type, target.type, reportErrors)) { @@ -61839,10 +61765,8 @@ var ts; } var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration); var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration); - var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); + var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? 0 /* Call */ : kind); + var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? 0 /* Call */ : kind); if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) { var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* Abstract */); var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* Abstract */); @@ -62518,8 +62442,7 @@ var ts; function compareTypePredicatesIdentical(source, target, compareTypes) { return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : source.type === target.type ? -1 /* True */ : - source.type && target.type ? compareTypes(source.type, target.type) : - 0 /* False */; + source.type && target.type ? compareTypes(source.type, target.type) : 0 /* False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; @@ -62571,7 +62494,12 @@ var ts; function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + return isArrayType(type) || hasArrayOrReadonlyArrayBaseType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + } + function hasArrayOrReadonlyArrayBaseType(type) { + return !!(ts.getObjectFlags(type) & 4 /* Reference */) + && !!(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */) + && ts.some(getBaseTypes(type.target), isArrayType); } function isEmptyArrayLiteralType(type) { var elementType = getElementTypeOfArrayType(type); @@ -63925,9 +63853,7 @@ var ts; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 /* NonInferrableType */ ? - 8 /* PartialHomomorphicMappedType */ : - 4 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 /* NonInferrableType */ ? 8 /* PartialHomomorphicMappedType */ : 4 /* HomomorphicMappedType */); } } return true; @@ -66355,7 +66281,7 @@ var ts; return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); if (target.flags & 111551 /* Value */) { // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled @@ -69348,7 +69274,7 @@ var ts; if (isInPropertyInitializer(node) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !isPropertyDeclaredInAncestorClass(prop)) { + && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } else if (valueDeclaration.kind === 253 /* ClassDeclaration */ && @@ -69722,8 +69648,7 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : - 0 /* None */; + 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : 0 /* None */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, accessFlags | 16 /* ExpressionPosition */) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } @@ -70644,14 +70569,14 @@ var ts; var i_1 = 0; var _loop_22 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; - var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); - if (diags_2) { - if (diags_2.length <= min_3) { - min_3 = diags_2.length; + var diags_3 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); + if (diags_3) { + if (diags_3.length <= min_3) { + min_3 = diags_3.length; minIndex = i_1; } - max = Math.max(max, diags_2.length); - allDiagnostics.push(diags_2); + max = Math.max(max, diags_3.length); + allDiagnostics.push(diags_3); } else { ts.Debug.fail("No error for 3 or fewer overload signatures"); @@ -70662,15 +70587,15 @@ var ts; var c = candidatesForArgumentError_1[_a]; _loop_22(c); } - var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); - ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); - var chain = ts.chainDiagnosticMessages(ts.map(diags_3, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call); + var diags_2 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); + ts.Debug.assert(diags_2.length > 0, "No errors reported for 3 or fewer overload signatures"); + var chain = ts.chainDiagnosticMessages(ts.map(diags_2, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call); // The below is a spread to guarantee we get a new (mutable) array - our `flatMap` helper tries to do "smart" optimizations where it reuses input // arrays and the emptyArray singleton where possible, which is decidedly not what we want while we're still constructing this diagnostic - var related = __spreadArray([], ts.flatMap(diags_3, function (d) { return d.relatedInformation; })); + var related = __spreadArray([], ts.flatMap(diags_2, function (d) { return d.relatedInformation; })); var diag = void 0; - if (ts.every(diags_3, function (d) { return d.start === diags_3[0].start && d.length === diags_3[0].length && d.file === diags_3[0].file; })) { - var _b = diags_3[0], file = _b.file, start = _b.start, length_7 = _b.length; + if (ts.every(diags_2, function (d) { return d.start === diags_2[0].start && d.length === diags_2[0].length && d.file === diags_2[0].file; })) { + var _b = diags_2[0], file = _b.file, start = _b.start, length_7 = _b.length; diag = { file: file, start: start, length: length_7, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related }; } else { @@ -70932,8 +70857,7 @@ var ts; if (ts.isCallChain(node)) { var nonOptionalType = getOptionalExpressionType(funcType, node.expression); callChainFlags = nonOptionalType === funcType ? 0 /* None */ : - ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : - 8 /* IsInnerCallChain */; + ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : 8 /* IsInnerCallChain */; funcType = nonOptionalType; } else { @@ -71710,10 +71634,8 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 252 /* FunctionDeclaration */ - : resolvedRequire.flags & 3 /* Variable */ - ? 250 /* VariableDeclaration */ - : 0 /* Unknown */; + ? 252 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ + ? 250 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient @@ -75358,7 +75280,7 @@ var ts; case 199 /* BindingElement */: case 252 /* FunctionDeclaration */: case 266 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 78 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 78 /* Identifier */: // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` // SyntaxKind.ElementAccessExpression - `thing["aField"] = 42;` or `thing["aField"];` (with a doc comment on it) @@ -76634,12 +76556,7 @@ var ts; if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { return false; } - var interestingFlags = 8 /* Private */ | - 16 /* Protected */ | - 256 /* Async */ | - 128 /* Abstract */ | - 64 /* Readonly */ | - 32 /* Static */; + var interestingFlags = 8 /* Private */ | 16 /* Protected */ | 256 /* Async */ | 128 /* Abstract */ | 64 /* Readonly */ | 32 /* Static */; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { @@ -76681,7 +76598,7 @@ var ts; return; if (getAwaitedTypeOfPromise(type)) { errorAndMaybeSuggestAwait(condExpr, - /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", getTypeNameForErrorDisplay(type), "false"); + /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined, getTypeNameForErrorDisplay(type)); return; } var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr; @@ -76710,7 +76627,7 @@ var ts; var isUsed = ts.isBinaryExpression(condExpr.parent) && isFunctionUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) || body && isFunctionUsedInConditionBody(condExpr, body, testedNode, testedSymbol); if (!isUsed) { - error(location, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead); } } function isFunctionUsedInConditionBody(expr, body, testedNode, testedSymbol) { @@ -77845,6 +77762,7 @@ var ts; switch (name.escapedText) { case "any": case "unknown": + case "never": case "number": case "bigint": case "boolean": @@ -78350,9 +78268,9 @@ var ts; ts.forEach(properties, function (p) { seen.set(p.escapedName, p); }); for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; - var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) { - var prop = properties_4[_a]; + var properties_4 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); + for (var _a = 0, properties_5 = properties_4; _a < properties_5.length; _a++) { + var prop = properties_5[_a]; var existing = seen.get(prop.escapedName); if (existing && !isPropertyIdenticalTo(existing, prop)) { seen.delete(prop.escapedName); @@ -80015,7 +79933,7 @@ var ts; return resolveEntityName(name, meaning, /*ignoreErrors*/ true); } if (name.parent.kind === 173 /* TypePredicate */) { - return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); + return resolveEntityName(name, 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; @@ -80405,7 +80323,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -82788,7 +82706,7 @@ var ts; case 263 /* ImportClause */: // For default import case 261 /* ImportEqualsDeclaration */: case 264 /* NamespaceImport */: - case 266 /* ImportSpecifier */: // For rename import `x as y` + case 266 /* ImportSpecifier */: return true; case 78 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. @@ -87967,9 +87885,7 @@ var ts; } function visitPrefixUnaryExpression(node) { if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { - var operator = node.operator === 45 /* PlusPlusToken */ ? - 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? - 40 /* MinusToken */ : undefined; + var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; var info = void 0; if (operator && (info = accessPrivateIdentifier(node.operand.name))) { var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); @@ -87982,9 +87898,7 @@ var ts; } function visitPostfixUnaryExpression(node, valueIsDiscarded) { if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { - var operator = node.operator === 45 /* PlusPlusToken */ ? - 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? - 40 /* MinusToken */ : undefined; + var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; var info = void 0; if (operator && (info = accessPrivateIdentifier(node.operand.name))) { var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); @@ -89700,9 +89614,7 @@ var ts; return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? - 0 /* StrictModeSourceFileIncludes */ : - 1 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? 0 /* StrictModeSourceFileIncludes */ : 1 /* SourceFileIncludes */); exportedVariableStatement = false; var visited = ts.visitEachChild(node, visitor, context); var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [ @@ -98509,9 +98421,9 @@ var ts; var _a, _b; var result = getImportOrExportBindingReference(node, /*removeEntry*/ true); switch (result === null || result === void 0 ? void 0 : result.kind) { - case 78 /* Identifier */: // tslib import + case 78 /* Identifier */: return factory.createPropertyAccessExpression(result, node); - case 298 /* SourceFile */: // top-level export + case 298 /* SourceFile */: return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); case 263 /* ImportClause */: @@ -100685,13 +100597,7 @@ var ts; }); } ts.isInternalDeclaration = isInternalDeclaration; - var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | - 2048 /* WriteClassExpressionAsTypeLiteral */ | - 4096 /* UseTypeOfFunction */ | - 8 /* UseStructuralFallback */ | - 524288 /* AllowEmptyTuple */ | - 4 /* GenerateNamesForShadowedTypeParams */ | - 1 /* NoTruncation */; + var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | 2048 /* WriteClassExpressionAsTypeLiteral */ | 4096 /* UseTypeOfFunction */ | 8 /* UseStructuralFallback */ | 524288 /* AllowEmptyTuple */ | 4 /* GenerateNamesForShadowedTypeParams */ | 1 /* NoTruncation */; /** * Transforms a ts file into a .d.ts file * This process requires type information, which is retrieved through the emit resolver. Because of this, @@ -101592,7 +101498,7 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 255 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 255 /* TypeAliasDeclaration */: return cleanup(factory.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); case 254 /* InterfaceDeclaration */: { @@ -102680,11 +102586,8 @@ var ts; if (configFile.options.emitDeclarationOnly) return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); - var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), isJsonFile ? - ".json" /* Json */ : - configFile.options.jsx === 1 /* Preserve */ && (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) || ts.fileExtensionIs(inputFileName, ".jsx" /* Jsx */)) ? - ".jsx" /* Jsx */ : - ".js" /* Js */); + var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), isJsonFile ? ".json" /* Json */ : + configFile.options.jsx === 1 /* Preserve */ && (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) || ts.fileExtensionIs(inputFileName, ".jsx" /* Jsx */)) ? ".jsx" /* Jsx */ : ".js" /* Js */); return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? outputFileName : undefined; @@ -104190,9 +104093,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 295 /* UnparsedText */ ? - "text" /* Text */ : - "internal" /* Internal */); + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 295 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } } // SyntaxKind.UnparsedSyntheticReference @@ -114305,8 +114206,7 @@ var ts; return { relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : - importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : - 2 /* Shortest */, + importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : 2 /* Shortest */, ending: getEnding(), }; function getEnding() { @@ -114314,16 +114214,14 @@ var ts; case "minimal": return 0 /* Minimal */; case "index": return 1 /* Index */; case "js": return 2 /* JsExtension */; - default: return usesJsExtensionOnImports(importingSourceFile) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; + default: return usesJsExtensionOnImports(importingSourceFile) ? 2 /* JsExtension */ : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; } } } function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSFileExtension(oldImportSpecifier) ? - 2 /* JsExtension */ : + ending: ts.hasJSFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } @@ -117386,8 +117284,14 @@ var ts; continue; } var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames()); + if (!outputs.length) + continue; + var inputFileNames = new ts.Set(parsed.fileNames.map(function (f) { return toPath(state, f); })); for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) { var output = outputs_3[_a]; + // If output name is same as input file name, do not delete and ignore the error + if (inputFileNames.has(toPath(state, output))) + continue; if (host.fileExists(output)) { if (filesToDelete) { filesToDelete.push(output); @@ -118428,10 +118332,8 @@ var ts; } function getKindOfVariableDeclaration(v) { return ts.isVarConst(v) - ? "const" /* constElement */ - : ts.isLet(v) - ? "let" /* letElement */ - : "var" /* variableElement */; + ? "const" /* constElement */ : ts.isLet(v) + ? "let" /* letElement */ : "var" /* variableElement */; } } ts.getNodeKind = getNodeKind; @@ -120332,10 +120234,10 @@ var ts; var delta = 0; var lastPos = -1; for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { - var _a = edits_1[_i], fileName = _a.fileName, textChanges_2 = _a.textChanges; + var _a = edits_1[_i], fileName = _a.fileName, textChanges_1 = _a.textChanges; ts.Debug.assert(fileName === renameFilename); - for (var _b = 0, textChanges_1 = textChanges_2; _b < textChanges_1.length; _b++) { - var change = textChanges_1[_b]; + for (var _b = 0, textChanges_2 = textChanges_1; _b < textChanges_2.length; _b++) { + var change = textChanges_2[_b]; var span = change.span, newText = change.newText; var index = indexInTextChange(newText, name); if (index !== -1) { @@ -120401,7 +120303,9 @@ var ts; } /* @internal */ function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ || ts.isObjectLiteralExpression(expression); + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ + || ts.isObjectLiteralExpression(expression) + || ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression); } ts.needsParentheses = needsParentheses; function getContextualTypeFromParent(node, checker) { @@ -123389,8 +123293,7 @@ var ts; var replacementSpan = ts.createTextSpanFromNode(importCompletionNode, sourceFile); var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier); var exportKind = origin.isDefaultExport ? 1 /* Default */ : - origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : - 0 /* Named */; + origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : 0 /* Named */; var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options); var suffix = useSemicolons ? ";" : ""; @@ -123699,7 +123602,7 @@ var ts; } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { - var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* All */, /*useOnlyExternalAliasing*/ false); + var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, 67108863 /* All */, /*useOnlyExternalAliasing*/ false); if (chain) return ts.first(chain); return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); @@ -124286,8 +124189,7 @@ var ts; collectAutoImports(/*resolveModuleSpecifier*/ false); if (isTypeOnly) { keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) - ? 6 /* TypeAssertionKeywords */ - : 7 /* TypeKeywords */; + ? 6 /* TypeAssertionKeywords */ : 7 /* TypeKeywords */; } } function shouldOfferImportCompletions() { @@ -124517,7 +124419,7 @@ var ts; || containingNodeKind === 172 /* IndexSignature */ // [ | : string ] || containingNodeKind === 159 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 139 /* ModuleKeyword */: // module | - case 140 /* NamespaceKeyword */: // namespace | + case 140 /* NamespaceKeyword */: return true; case 24 /* DotToken */: return containingNodeKind === 257 /* ModuleDeclaration */; // module A.| @@ -124747,7 +124649,7 @@ var ts; var parent = contextToken.parent; switch (contextToken.kind) { case 18 /* OpenBraceToken */: // const x = { | - case 27 /* CommaToken */: // const x = { a: 0, | + case 27 /* CommaToken */: if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) { return parent; } @@ -124926,7 +124828,7 @@ var ts; case 118 /* LetKeyword */: case 84 /* ConstKeyword */: case 135 /* InferKeyword */: - case 149 /* TypeKeyword */: // type htm| + case 149 /* TypeKeyword */: return true; case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); @@ -125189,7 +125091,7 @@ var ts; // TODO: GH#18169 return { name: JSON.stringify(name), needsConvertPropertyAccess: false }; case 2 /* PropertyAccess */: - case 1 /* Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. + case 1 /* Global */: // Don't add a completion for a name starting with a space. See https://github.com/Microsoft/TypeScript/pull/20547 return name.charCodeAt(0) === 32 /* space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; case 5 /* None */: @@ -125379,16 +125281,16 @@ var ts; if (!contextToken) return undefined; switch (contextToken.kind) { - case 62 /* EqualsToken */: // class c { public prop = | /* global completions */ } + case 62 /* EqualsToken */: return undefined; case 26 /* SemicolonToken */: // class c {getValue(): number; | } - case 19 /* CloseBraceToken */: // class c { method() { } | } + case 19 /* CloseBraceToken */: // class c { method() { } b| } return isFromObjectTypeDeclaration(location) && location.parent.name === location ? location.parent.parent : ts.tryCast(location, ts.isObjectTypeDeclaration); case 18 /* OpenBraceToken */: // class c { | - case 27 /* CommaToken */: // class c {getValue(): number, | } + case 27 /* CommaToken */: return ts.tryCast(contextToken.parent, ts.isObjectTypeDeclaration); default: if (!isFromObjectTypeDeclaration(contextToken)) { @@ -126175,7 +126077,7 @@ var ts; } } break; - case 78 /* Identifier */: // for 'const x = require("y"); + case 78 /* Identifier */: break; // TODO: GH#23879 case 261 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); @@ -130760,11 +130662,9 @@ var ts; return ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node); } var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? - ts.getAssignmentDeclarationKind(b.node) : - 0 /* None */; + ts.getAssignmentDeclarationKind(b.node) : 0 /* None */; var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? - ts.getAssignmentDeclarationKind(a.node) : - 0 /* None */; + ts.getAssignmentDeclarationKind(a.node) : 0 /* None */; // We treat this as an es5 class and merge the nodes in in one of several cases if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member @@ -132058,8 +131958,7 @@ var ts; return ts.min(a, b, compareMatches); } function compareMatches(a, b) { - return a === undefined ? 1 /* GreaterThan */ : b === undefined ? -1 /* LessThan */ - : ts.compareValues(a.kind, b.kind) || ts.compareBooleans(!a.isCaseSensitive, !b.isCaseSensitive); + return a === undefined ? 1 /* GreaterThan */ : b === undefined ? -1 /* LessThan */ : ts.compareValues(a.kind, b.kind) || ts.compareBooleans(!a.isCaseSensitive, !b.isCaseSensitive); } function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { if (patternSpan === void 0) { patternSpan = { start: 0, length: pattern.length }; } @@ -134076,8 +133975,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 222 /* ClassExpression */) ? - "local class" /* localClassElement */ : "class" /* classElement */; + return ts.getDeclarationOfKind(symbol, 222 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) return "enum" /* enumElement */; @@ -134180,8 +134078,7 @@ var ts; var _a = symbol.declarations, declaration = _a[0], declarations = _a.slice(1); // omit deprecated flag if some declarations are not deprecated var excludeFlags = ts.length(declarations) && isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !isDeprecatedDeclaration(d); }) - ? 8192 /* Deprecated */ - : 0 /* None */; + ? 8192 /* Deprecated */ : 0 /* None */; var modifiers = ts.getNodeModifiers(declaration, excludeFlags); if (modifiers) { return modifiers.split(","); @@ -135062,8 +134959,7 @@ var ts; shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : - shouldRescanJsxAttributeValue(n) ? 6 /* RescanJsxAttributeValue */ : - 0 /* Scan */; + shouldRescanJsxAttributeValue(n) ? 6 /* RescanJsxAttributeValue */ : 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -135244,8 +135140,14 @@ var ts; var binaryKeywordOperators = [100 /* InKeyword */, 101 /* InstanceOfKeyword */, 157 /* OfKeyword */, 126 /* AsKeyword */, 137 /* IsKeyword */]; var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 78 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */ + 8 /* NumericLiteral */, + 9 /* BigIntLiteral */, + 78 /* Identifier */, + 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, + 18 /* OpenBraceToken */, + 107 /* ThisKeyword */, + 102 /* NewKeyword */ ]; var unaryPreincrementExpressions = [78 /* Identifier */, 20 /* OpenParenToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */]; var unaryPostincrementExpressions = [78 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 102 /* NewKeyword */]; @@ -135676,7 +135578,7 @@ var ts; // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 254 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 254 /* InterfaceDeclaration */: return true; } return false; @@ -136566,7 +136468,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); + processChildNode(child, -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -136737,8 +136639,7 @@ var ts; } if (indentToken) { var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? - dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : - -1 /* Unknown */; + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : -1 /* Unknown */; var indentNextTokenOrTrivia = true; if (currentTokenInfo.leadingTrivia) { var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); @@ -139352,6 +139253,7 @@ var ts; ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1.code, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined.code, ts.Diagnostics.Type_0_is_not_an_array_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code, @@ -140533,7 +140435,7 @@ var ts; // do not produce a transformed statement for a null argument break; case 202 /* PropertyAccessExpression */: - case 78 /* Identifier */: // identifier includes undefined + case 78 /* Identifier */: if (!argName) { // undefined was argument passed to promise handler break; @@ -141109,7 +141011,9 @@ var ts; } /** * Convert `import x = require("x").` - * Also converts uses like `x.y()` to `y()` and uses a named import. + * Also: + * - Convert `x.default()` to `x()` to handle ES6 default export + * - Converts uses like `x.y()` to `y()` and uses a named import. */ function convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference) { var nameSymbol = checker.getSymbolAtLocation(name); @@ -141126,14 +141030,21 @@ var ts; } var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { - var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` - var idName = namedBindingsNames.get(propertyName); - if (idName === undefined) { - idName = makeUniqueName(propertyName, identifiers); - namedBindingsNames.set(propertyName, idName); + var propertyName = parent.name.text; + if (propertyName === "default") { + needDefaultImport = true; + var importDefaultName = use.getText(); + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(importDefaultName)); + } + else { + ts.Debug.assert(parent.expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` + var idName = namedBindingsNames.get(propertyName); + if (idName === undefined) { + idName = makeUniqueName(propertyName, identifiers); + namedBindingsNames.set(propertyName, idName); + } + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } - (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } else { needDefaultImport = true; @@ -144327,7 +144238,7 @@ var ts; (function (codefix) { var fixId = "fixMissingCallParentheses"; var errorCodes = [ - ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead.code, ]; codefix.registerCodeFix({ errorCodes: errorCodes, @@ -147255,8 +147166,10 @@ var ts; } if (context.preferences.provideRefactorNotApplicableReason) { return [ - { name: refactorName, description: namespaceToNamedAction.description, actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] }, - { name: refactorName, description: namedToNamespaceAction.description, actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] } + { name: refactorName, description: namespaceToNamedAction.description, + actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] }, + { name: refactorName, description: namedToNamespaceAction.description, + actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] } ]; } return ts.emptyArray; @@ -162366,8 +162279,7 @@ var ts; } function directoryHasPackageJson(directory) { return packageJsons.has(ts.combinePaths(directory, "package.json")) ? -1 /* True */ : - directoriesWithoutPackageJson.has(directory) ? 0 /* False */ : - 3 /* Maybe */; + directoriesWithoutPackageJson.has(directory) ? 0 /* False */ : 3 /* Maybe */; } } server.createPackageJsonCache = createPackageJsonCache; diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index e6c2a786412..a2ff8fc1ea2 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -16,7 +16,7 @@ and limitations under the License. declare namespace ts { const versionMajorMinor = "4.3"; /** The version of the TypeScript compiler release */ - const version = "4.3.0-beta"; + const version: string; /** * Type of objects whose values are all of the same type. * The `in` and `for-in` operators can *not* be safely used, diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index ed2c5ba5f11..086d3b2f2a9 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -1847,8 +1847,7 @@ var ts; return a === b ? 0 /* EqualTo */ : a === undefined ? -1 /* LessThan */ : b === undefined ? 1 /* GreaterThan */ : - a < b ? -1 /* LessThan */ : - 1 /* GreaterThan */; + a < b ? -1 /* LessThan */ : 1 /* GreaterThan */; } /** * Compare two numeric values for their order relative to each other. @@ -7851,8 +7850,7 @@ var ts; if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) - ? 1 /* Normal */ - : 0 /* None */); + ? 1 /* Normal */ : 0 /* None */); } if (ts.sys && ts.sys.debugMode) { ts.Debug.isDebugging = true; @@ -7871,7 +7869,7 @@ var ts; Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), - The_parser_expected_to_find_a_to_match_the_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_to_match_the_token_here_1007", "The parser expected to find a '}' to match the '{' token here."), + The_parser_expected_to_find_a_1_to_match_the_0_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_1_to_match_the_0_token_here_1007", "The parser expected to find a '{1}' to match the '{0}' token here."), Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), @@ -8657,7 +8655,7 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), - This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_2774", "This condition will always return true since this function appears to always be defined. Did you mean to call it instead?"), Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), @@ -8684,7 +8682,7 @@ var ts; The_declaration_was_marked_as_deprecated_here: diag(2798, ts.DiagnosticCategory.Error, "The_declaration_was_marked_as_deprecated_here_2798", "The declaration was marked as deprecated here."), Type_produces_a_tuple_type_that_is_too_large_to_represent: diag(2799, ts.DiagnosticCategory.Error, "Type_produces_a_tuple_type_that_is_too_large_to_represent_2799", "Type produces a tuple type that is too large to represent."), Expression_produces_a_tuple_type_that_is_too_large_to_represent: diag(2800, ts.DiagnosticCategory.Error, "Expression_produces_a_tuple_type_that_is_too_large_to_represent_2800", "Expression produces a tuple type that is too large to represent."), - This_condition_will_always_return_true_since_the_Promise_is_always_truthy: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_Promise_is_always_truthy_2801", "This condition will always return true since the Promise is always truthy."), + This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined_2801", "This condition will always return true since this '{0}' appears to always be defined."), Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."), Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."), Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."), @@ -8692,6 +8690,7 @@ var ts; Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."), This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."), A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), + Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "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: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -13168,7 +13167,7 @@ var ts; case 105 /* SuperKeyword */: case 226 /* NonNullExpression */: case 227 /* MetaProperty */: - case 99 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 99 /* ImportKeyword */: return true; default: return false; @@ -16232,8 +16231,7 @@ var ts; case 217 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : - 0 /* None */; + binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; case 215 /* PrefixUnaryExpression */: case 216 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; @@ -18658,8 +18656,7 @@ var ts; if (getCheckFlags(s) & 6 /* Synthetic */) { var checkFlags = s.checkFlags; var accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : - checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : - 16 /* Protected */; + checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : 16 /* Protected */; var staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; return accessModifier | staticModifier; } @@ -19191,8 +19188,7 @@ var ts; } function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || - compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; + compareRelatedInformation(d1, d2) || 0 /* EqualTo */; } ts.compareDiagnostics = compareDiagnostics; function compareDiagnosticsSkipRelatedInformation(d1, d2) { @@ -19200,8 +19196,7 @@ var ts; ts.compareValues(d1.start, d2.start) || ts.compareValues(d1.length, d2.length) || ts.compareValues(d1.code, d2.code) || - compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; + compareMessageText(d1.messageText, d2.messageText) || 0 /* EqualTo */; } ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; function compareRelatedInformation(d1, d2) { @@ -20035,15 +20030,15 @@ var ts; var log2Base; switch (stringValue.charCodeAt(1)) { // "x" in "0x123" case 98 /* b */: - case 66 /* B */: // 0b or 0B + case 66 /* B */: log2Base = 1; break; case 111 /* o */: - case 79 /* O */: // 0o or 0O + case 79 /* O */: log2Base = 3; break; case 120 /* x */: - case 88 /* X */: // 0x or 0X + case 88 /* X */: log2Base = 4; break; default: // already in decimal; omit trailing "n" @@ -21686,8 +21681,7 @@ var ts; case 129 /* AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */; break; case 122 /* PublicKeyword */: case 120 /* PrivateKeyword */: @@ -21706,7 +21700,7 @@ var ts; case 148 /* SymbolKeyword */: case 113 /* VoidKeyword */: case 152 /* UnknownKeyword */: - case 150 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + case 150 /* UndefinedKeyword */: transformFlags = 1 /* ContainsTypeScript */; break; case 123 /* StaticKeyword */: @@ -21819,9 +21813,7 @@ var ts; var node = createBaseNode(159 /* ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 512 /* ContainsES2015 */ | - 65536 /* ContainsComputedPropertyName */; + propagateChildFlags(node.expression) | 512 /* ContainsES2015 */ | 65536 /* ContainsComputedPropertyName */; return node; } // @api @@ -21889,9 +21881,7 @@ var ts; var node = createBaseNode(162 /* Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */ | - 4096 /* ContainsTypeScriptClassSyntax */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */ | 4096 /* ContainsTypeScriptClassSyntax */; return node; } // @api @@ -21928,8 +21918,7 @@ var ts; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | - propagateChildFlags(node.exclamationToken) | - 8388608 /* ContainsClassFields */; + propagateChildFlags(node.exclamationToken) | 8388608 /* ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; } @@ -21976,8 +21965,7 @@ var ts; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | - propagateChildFlags(node.questionToken) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.questionToken) | 512 /* ContainsES2015 */; if (questionToken) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22505,13 +22493,10 @@ var ts; var node = createBaseNode(197 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= - propagateChildrenFlags(node.elements) | - 512 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; + propagateChildrenFlags(node.elements) | 512 /* ContainsES2015 */ | 262144 /* ContainsBindingPattern */; if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { node.transformFlags |= - 64 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + 64 /* ContainsES2018 */ | 32768 /* ContainsObjectRestOrSpread */; } return node; } @@ -22526,9 +22511,7 @@ var ts; var node = createBaseNode(198 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= - propagateChildrenFlags(node.elements) | - 512 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; + propagateChildrenFlags(node.elements) | 512 /* ContainsES2015 */ | 262144 /* ContainsBindingPattern */; return node; } // @api @@ -22545,8 +22528,7 @@ var ts; node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= - propagateChildFlags(node.dotDotDotToken) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.dotDotDotToken) | 512 /* ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : @@ -22615,8 +22597,7 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */; } return node; } @@ -22669,8 +22650,7 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */; } return node; } @@ -22694,8 +22674,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | - propagateChildFlags(node.argumentExpression) | - 16 /* ContainsES2020 */; + propagateChildFlags(node.argumentExpression) | 16 /* ContainsES2020 */; return node; } // @api @@ -22753,8 +22732,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | - propagateChildrenFlags(node.arguments) | - 16 /* ContainsES2020 */; + propagateChildrenFlags(node.arguments) | 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22782,8 +22760,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - propagateChildrenFlags(node.arguments) | - 16 /* ContainsES2020 */; + propagateChildrenFlags(node.arguments) | 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22806,8 +22783,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.template) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.template) | 512 /* ContainsES2015 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22831,8 +22807,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.type) | 1 /* ContainsTypeScript */; return node; } // @api @@ -22896,8 +22871,7 @@ var ts; /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); node.transformFlags |= - propagateChildFlags(node.equalsGreaterThanToken) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.equalsGreaterThanToken) | 512 /* ContainsES2015 */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { node.transformFlags |= 128 /* ContainsES2017 */; } @@ -22958,10 +22932,7 @@ var ts; var node = createBaseExpression(214 /* AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */ | - 1048576 /* ContainsAwait */; + propagateChildFlags(node.expression) | 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */ | 1048576 /* ContainsAwait */; return node; } // @api @@ -23016,15 +22987,12 @@ var ts; else if (operatorKind === 62 /* EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 512 /* ContainsES2015 */ | - 64 /* ContainsES2018 */ | - 2048 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | 64 /* ContainsES2018 */ | 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 512 /* ContainsES2015 */ | - 2048 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } @@ -23100,8 +23068,7 @@ var ts; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | - propagateChildrenFlags(node.templateSpans) | - 512 /* ContainsES2015 */; + propagateChildrenFlags(node.templateSpans) | 512 /* ContainsES2015 */; return node; } // @api @@ -23170,10 +23137,7 @@ var ts; node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.asteriskToken) | - 512 /* ContainsES2015 */ | - 64 /* ContainsES2018 */ | - 524288 /* ContainsYield */; + propagateChildFlags(node.asteriskToken) | 512 /* ContainsES2015 */ | 64 /* ContainsES2018 */ | 524288 /* ContainsYield */; return node; } // @api @@ -23188,9 +23152,7 @@ var ts; var node = createBaseExpression(221 /* SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 512 /* ContainsES2015 */ | - 16384 /* ContainsRestOrSpread */; + propagateChildFlags(node.expression) | 512 /* ContainsES2015 */ | 16384 /* ContainsRestOrSpread */; return node; } // @api @@ -23227,8 +23189,7 @@ var ts; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildrenFlags(node.typeArguments) | - 512 /* ContainsES2015 */; + propagateChildrenFlags(node.typeArguments) | 512 /* ContainsES2015 */; return node; } // @api @@ -23245,8 +23206,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.type) | 1 /* ContainsTypeScript */; return node; } // @api @@ -23261,8 +23221,7 @@ var ts; var node = createBaseExpression(226 /* NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */; return node; } // @api @@ -23280,8 +23239,7 @@ var ts; node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */; return node; } // @api @@ -23325,8 +23283,7 @@ var ts; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.literal) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.literal) | 512 /* ContainsES2015 */; return node; } // @api @@ -23502,8 +23459,7 @@ var ts; propagateChildFlags(node.awaitModifier) | propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | - propagateChildFlags(node.statement) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.statement) | 512 /* ContainsES2015 */; if (awaitModifier) node.transformFlags |= 64 /* ContainsES2018 */; return node; @@ -23522,8 +23478,7 @@ var ts; var node = createBaseNode(241 /* ContinueStatement */); node.label = asName(label); node.transformFlags |= - propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.label) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23537,8 +23492,7 @@ var ts; var node = createBaseNode(242 /* BreakStatement */); node.label = asName(label); node.transformFlags |= - propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.label) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23553,9 +23507,7 @@ var ts; node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= - propagateChildFlags(node.expression) | - 64 /* ContainsES2018 */ | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.expression) | 64 /* ContainsES2018 */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23680,12 +23632,10 @@ var ts; node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= - propagateChildrenFlags(node.declarations) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildrenFlags(node.declarations) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (flags & 3 /* BlockScoped */) { node.transformFlags |= - 512 /* ContainsES2015 */ | - 131072 /* ContainsBlockScopedBinding */; + 512 /* ContainsES2015 */ | 131072 /* ContainsBlockScopedBinding */; } return node; } @@ -23704,8 +23654,7 @@ var ts; } else { node.transformFlags |= - propagateChildFlags(node.asteriskToken) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.asteriskToken) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (node.asteriskToken) { node.transformFlags |= 64 /* ContainsES2018 */; @@ -23798,8 +23747,7 @@ var ts; var node = createBaseNamedDeclaration(256 /* EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= - propagateChildrenFlags(node.members) | - 1 /* ContainsTypeScript */; + propagateChildrenFlags(node.members) | 1 /* ContainsTypeScript */; node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` return node; } @@ -23825,8 +23773,7 @@ var ts; else { node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.body) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.body) | 1 /* ContainsTypeScript */; } node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. return node; @@ -23963,8 +23910,7 @@ var ts; var node = createBaseNode(270 /* NamespaceExport */); node.name = name; node.transformFlags |= - propagateChildFlags(node.name) | - 4 /* ContainsESNext */; + propagateChildFlags(node.name) | 4 /* ContainsESNext */; node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } @@ -24470,8 +24416,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.openingElement) | propagateChildrenFlags(node.children) | - propagateChildFlags(node.closingElement) | - 2 /* ContainsJsx */; + propagateChildFlags(node.closingElement) | 2 /* ContainsJsx */; return node; } // @api @@ -24491,8 +24436,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + propagateChildFlags(node.attributes) | 2 /* ContainsJsx */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -24515,8 +24459,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + propagateChildFlags(node.attributes) | 2 /* ContainsJsx */; if (typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -24535,8 +24478,7 @@ var ts; var node = createBaseNode(277 /* JsxClosingElement */); node.tagName = tagName; node.transformFlags |= - propagateChildFlags(node.tagName) | - 2 /* ContainsJsx */; + propagateChildFlags(node.tagName) | 2 /* ContainsJsx */; return node; } // @api @@ -24554,8 +24496,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.openingFragment) | propagateChildrenFlags(node.children) | - propagateChildFlags(node.closingFragment) | - 2 /* ContainsJsx */; + propagateChildFlags(node.closingFragment) | 2 /* ContainsJsx */; return node; } // @api @@ -24600,8 +24541,7 @@ var ts; node.initializer = initializer; node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.initializer) | - 2 /* ContainsJsx */; + propagateChildFlags(node.initializer) | 2 /* ContainsJsx */; return node; } // @api @@ -24616,8 +24556,7 @@ var ts; var node = createBaseNode(282 /* JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= - propagateChildrenFlags(node.properties) | - 2 /* ContainsJsx */; + propagateChildrenFlags(node.properties) | 2 /* ContainsJsx */; return node; } // @api @@ -24631,8 +24570,7 @@ var ts; var node = createBaseNode(283 /* JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= - propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + propagateChildFlags(node.expression) | 2 /* ContainsJsx */; return node; } // @api @@ -24648,8 +24586,7 @@ var ts; node.expression = expression; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + propagateChildFlags(node.expression) | 2 /* ContainsJsx */; return node; } // @api @@ -24778,8 +24715,7 @@ var ts; /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= - propagateChildFlags(node.objectAssignmentInitializer) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.objectAssignmentInitializer) | 512 /* ContainsES2015 */; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -24808,9 +24744,7 @@ var ts; var node = createBaseNode(291 /* SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 64 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + propagateChildFlags(node.expression) | 64 /* ContainsES2018 */ | 32768 /* ContainsObjectRestOrSpread */; return node; } // @api @@ -24829,8 +24763,7 @@ var ts; node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.initializer) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.initializer) | 1 /* ContainsTypeScript */; return node; } // @api @@ -25006,8 +24939,7 @@ var ts; node.expression = expression; node.original = original; node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */; ts.setTextRange(node, original); return node; } @@ -30135,20 +30067,23 @@ var ts; return inContext(32768 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { - parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); + return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); } function parseErrorAtPosition(start, length, message, arg0) { // Don't report another error if it would just be at the same position as the last error. var lastError = ts.lastOrUndefined(parseDiagnostics); + var result; if (!lastError || start !== lastError.start) { - parseDiagnostics.push(ts.createDetachedDiagnostic(fileName, start, length, message, arg0)); + result = ts.createDetachedDiagnostic(fileName, start, length, message, arg0); + parseDiagnostics.push(result); } // Mark that we've encountered an error. We'll set an appropriate bit on the next // node we finish so that it can't be reused incrementally. parseErrorBeforeNextFinishedNode = true; + return result; } function parseErrorAt(start, end, message, arg0) { - parseErrorAtPosition(start, end - start, message, arg0); + return parseErrorAtPosition(start, end - start, message, arg0); } function parseErrorAtRange(range, message, arg0) { parseErrorAt(range.pos, range.end, message, arg0); @@ -30305,6 +30240,16 @@ var ts; parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); return false; } + function parseExpectedMatchingBrackets(openKind, closeKind, openPosition) { + if (token() === closeKind) { + nextToken(); + return; + } + var lastError = parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(closeKind)); + if (lastError) { + ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openPosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, ts.tokenToString(openKind), ts.tokenToString(closeKind))); + } + } function parseOptional(t) { if (token() === t) { nextToken(); @@ -30593,7 +30538,7 @@ var ts; case 22 /* OpenBracketToken */: case 41 /* AsteriskToken */: case 25 /* DotDotDotToken */: - case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 24 /* DotToken */: return true; default: return isLiteralPropertyName(); @@ -30626,7 +30571,7 @@ var ts; case 15 /* ArrayLiteralMembers */: switch (token()) { case 27 /* CommaToken */: - case 24 /* DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) + case 24 /* DotToken */: return true; } // falls through @@ -30782,8 +30727,7 @@ var ts; var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, /*inErrorRecovery*/ false)) { - var element = parseListElement(kind, parseElement); - list.push(element); + list.push(parseListElement(kind, parseElement)); continue; } if (abortParsingListOrMoveToNextToken(kind)) { @@ -33587,7 +33531,7 @@ var ts; case 50 /* AmpersandToken */: // foo & case 51 /* BarToken */: // foo | case 19 /* CloseBraceToken */: // foo } - case 1 /* EndOfFileToken */: // foo + case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal // expressions either. The user is probably in the middle of a generic type. So // treat it as such. @@ -33671,10 +33615,11 @@ var ts; } function parseArrayLiteralExpression() { var pos = getNodePos(); + var openBracketPosition = scanner.getTokenPos(); parseExpected(22 /* OpenBracketToken */); var multiLine = scanner.hasPrecedingLineBreak(); var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(23 /* CloseBracketToken */); + parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketPosition); return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos); } function parseObjectLiteralElement() { @@ -33734,12 +33679,7 @@ var ts; parseExpected(18 /* OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { - var lastError = ts.lastOrUndefined(parseDiagnostics); - if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { - ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); - } - } + parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } function parseFunctionExpression() { @@ -33812,13 +33752,13 @@ var ts; if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); var statements = parseList(1 /* BlockStatements */, parseStatement); - if (!parseExpected(19 /* CloseBraceToken */)) { - var lastError = ts.lastOrUndefined(parseDiagnostics); - if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { - ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); - } + parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBracePosition); + var result = finishNode(factory.createBlock(statements, multiLine), pos); + if (token() === 62 /* EqualsToken */) { + parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); + nextToken(); } - return finishNode(factory.createBlock(statements, multiLine), pos); + return result; } else { var statements = createMissingList(); @@ -33855,9 +33795,10 @@ var ts; function parseIfStatement() { var pos = getNodePos(); parseExpected(98 /* IfKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); var thenStatement = parseStatement(); var elseStatement = parseOptional(90 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos); @@ -33867,9 +33808,10 @@ var ts; parseExpected(89 /* DoKeyword */); var statement = parseStatement(); parseExpected(114 /* WhileKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby @@ -33880,9 +33822,10 @@ var ts; function parseWhileStatement() { var pos = getNodePos(); parseExpected(114 /* WhileKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); var statement = parseStatement(); return finishNode(factory.createWhileStatement(expression, statement), pos); } @@ -33945,9 +33888,10 @@ var ts; function parseWithStatement() { var pos = getNodePos(); parseExpected(115 /* WithKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); return finishNode(factory.createWithStatement(expression, statement), pos); } @@ -34646,7 +34590,7 @@ var ts; case 53 /* ExclamationToken */: // Non-null assertion on property name case 58 /* ColonToken */: // Type Annotation for declaration case 62 /* EqualsToken */: // Initializer for declaration - case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 57 /* QuestionToken */: return true; default: // Covers @@ -35930,8 +35874,7 @@ var ts; hasChildren = true; if (child.kind === 333 /* JSDocTypeTag */) { if (childTypeTag) { - parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); - var lastError = ts.lastOrUndefined(parseDiagnostics); + var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, 0, 0, ts.Diagnostics.The_tag_was_first_specified_here)); } @@ -35962,7 +35905,7 @@ var ts; comment = parseTrailingTagComments(start, end, indent, indentText); } var typedefTag = factory.createJSDocTypedefTag(tagName, typeExpression, fullName, comment); - return finishNode(typedefTag, start); + return finishNode(typedefTag, start, end); } function parseJSDocTypeNameWithNamespace(nested) { var pos = scanner.getTokenPos(); @@ -43047,8 +42990,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 = prop.kind === 289 /* PropertyAssignment */ || prop.kind === 290 /* ShorthandPropertyAssignment */ || prop.kind === 166 /* MethodDeclaration */ - ? 1 /* Property */ - : 2 /* Accessor */; + ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); if (!existingKind) { seen.set(identifier.escapedText, currentKind); @@ -43569,7 +43511,7 @@ var ts; case 252 /* FunctionDeclaration */: return bindFunctionDeclaration(node); case 167 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); + return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, 0 /* None */); case 168 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); case 169 /* SetAccessor */: @@ -43662,8 +43604,7 @@ var ts; case 337 /* JSDocPropertyTag */: var propTag = node; var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 308 /* JSDocOptionalType */ ? - 4 /* Property */ | 16777216 /* Optional */ : - 4 /* Property */; + 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); case 335 /* JSDocTypedefTag */: case 328 /* JSDocCallbackTag */: @@ -43701,9 +43642,9 @@ var ts; else { var flags = ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; - ? 2097152 /* Alias */ - // An export default clause with any other expression exports a value - : 4 /* Property */; + ? 2097152 /* Alias */ + // An export default clause with any other expression exports a value + : 4 /* Property */; // If there is an `export default x;` alias declaration, can't `export default` anything else. // (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.) var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */); @@ -43812,8 +43753,7 @@ var ts; } // 'module.exports = expr' assignment var flags = ts.exportAssignmentIsAlias(node) - ? 2097152 /* Alias */ - : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; + ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); ts.setValueDeclaration(symbol, node); } @@ -46596,7 +46536,7 @@ var ts; case 254 /* InterfaceDeclaration */: case 256 /* EnumDeclaration */: case 255 /* TypeAliasDeclaration */: - case 257 /* ModuleDeclaration */: // For `namespace N { N; }` + case 257 /* ModuleDeclaration */: return true; default: return false; @@ -50498,8 +50438,7 @@ var ts; // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined - : isConstVariable(symbol) ? 2 /* Const */ - : 1 /* Let */; + : isConstVariable(symbol) ? 2 /* Const */ : 1 /* Let */; var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { @@ -51139,9 +51078,7 @@ var ts; ], 2 /* Const */)); // Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`. // Otherwise, the type itself should be exported. - addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ - : name === varName ? 1 /* Export */ - : 0 /* None */); + addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ : name === varName ? 1 /* Export */ : 0 /* None */); } if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( @@ -56509,8 +56446,7 @@ var ts; return getRestTypeElementFlags(node); case 193 /* NamedTupleMember */: return node.questionToken ? 2 /* Optional */ : - node.dotDotDotToken ? getRestTypeElementFlags(node) : - 1 /* Required */; + node.dotDotDotToken ? getRestTypeElementFlags(node) : 1 /* Required */; default: return 1 /* Required */; } @@ -57087,7 +57023,7 @@ var ts; } function createUnionType(types, aliasSymbol, aliasTypeArguments, origin) { var result = createType(1048576 /* Union */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + result.objectFlags = getPropagatingFlagsOfTypes(types, 98304 /* Nullable */); result.types = types; result.origin = origin; result.aliasSymbol = aliasSymbol; @@ -57275,7 +57211,7 @@ var ts; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { var result = createType(2097152 /* Intersection */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + result.objectFlags = getPropagatingFlagsOfTypes(types, 98304 /* Nullable */); result.types = types; result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; @@ -59262,7 +59198,7 @@ var ts; case 209 /* FunctionExpression */: case 210 /* ArrowFunction */: case 166 /* MethodDeclaration */: - case 252 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 252 /* FunctionDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); case 201 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); @@ -59986,8 +59922,7 @@ var ts; } } var related = source.type === target.type ? -1 /* True */ : - source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : - 0 /* False */; + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : 0 /* False */; if (related === 0 /* False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -61302,6 +61237,11 @@ var ts; } } else if (target.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TemplateLiteral */) { + // Report unreliable variance for type variables referenced in template literal type placeholders. + // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string. + instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + } var result_8 = inferTypesFromTemplateLiteralType(source, target); if (result_8 && ts.every(result_8, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) { return -1 /* True */; @@ -61345,20 +61285,6 @@ var ts; return result; } } - else if (source.flags & 134217728 /* TemplateLiteral */) { - if (target.flags & 134217728 /* TemplateLiteral */ && - source.texts.length === target.texts.length && - source.types.length === target.types.length && - ts.every(source.texts, function (t, i) { return t === target.texts[i]; }) && - ts.every(instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)).types, function (t, i) { return !!(target.types[i].flags & (1 /* Any */ | 4 /* String */)) || !!isRelatedTo(t, target.types[i], /*reportErrors*/ false); })) { - return -1 /* True */; - } - var constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, reportErrors))) { - resetErrorInfo(saveErrorInfo); - return result; - } - } else if (source.flags & 268435456 /* StringMapping */) { if (target.flags & 268435456 /* StringMapping */ && source.symbol === target.symbol) { if (result = isRelatedTo(source.type, target.type, reportErrors)) { @@ -62033,10 +61959,8 @@ var ts; } var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration); var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration); - var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); + var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? 0 /* Call */ : kind); + var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? 0 /* Call */ : kind); if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) { var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* Abstract */); var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* Abstract */); @@ -62712,8 +62636,7 @@ var ts; function compareTypePredicatesIdentical(source, target, compareTypes) { return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : source.type === target.type ? -1 /* True */ : - source.type && target.type ? compareTypes(source.type, target.type) : - 0 /* False */; + source.type && target.type ? compareTypes(source.type, target.type) : 0 /* False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; @@ -62765,7 +62688,12 @@ var ts; function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + return isArrayType(type) || hasArrayOrReadonlyArrayBaseType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + } + function hasArrayOrReadonlyArrayBaseType(type) { + return !!(ts.getObjectFlags(type) & 4 /* Reference */) + && !!(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */) + && ts.some(getBaseTypes(type.target), isArrayType); } function isEmptyArrayLiteralType(type) { var elementType = getElementTypeOfArrayType(type); @@ -64119,9 +64047,7 @@ var ts; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 /* NonInferrableType */ ? - 8 /* PartialHomomorphicMappedType */ : - 4 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 /* NonInferrableType */ ? 8 /* PartialHomomorphicMappedType */ : 4 /* HomomorphicMappedType */); } } return true; @@ -66549,7 +66475,7 @@ var ts; return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); if (target.flags & 111551 /* Value */) { // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled @@ -69542,7 +69468,7 @@ var ts; if (isInPropertyInitializer(node) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !isPropertyDeclaredInAncestorClass(prop)) { + && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } else if (valueDeclaration.kind === 253 /* ClassDeclaration */ && @@ -69916,8 +69842,7 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : - 0 /* None */; + 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : 0 /* None */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, accessFlags | 16 /* ExpressionPosition */) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } @@ -70838,14 +70763,14 @@ var ts; var i_1 = 0; var _loop_22 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; - var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); - if (diags_2) { - if (diags_2.length <= min_3) { - min_3 = diags_2.length; + var diags_3 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); + if (diags_3) { + if (diags_3.length <= min_3) { + min_3 = diags_3.length; minIndex = i_1; } - max = Math.max(max, diags_2.length); - allDiagnostics.push(diags_2); + max = Math.max(max, diags_3.length); + allDiagnostics.push(diags_3); } else { ts.Debug.fail("No error for 3 or fewer overload signatures"); @@ -70856,15 +70781,15 @@ var ts; var c = candidatesForArgumentError_1[_a]; _loop_22(c); } - var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); - ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); - var chain = ts.chainDiagnosticMessages(ts.map(diags_3, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call); + var diags_2 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); + ts.Debug.assert(diags_2.length > 0, "No errors reported for 3 or fewer overload signatures"); + var chain = ts.chainDiagnosticMessages(ts.map(diags_2, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call); // The below is a spread to guarantee we get a new (mutable) array - our `flatMap` helper tries to do "smart" optimizations where it reuses input // arrays and the emptyArray singleton where possible, which is decidedly not what we want while we're still constructing this diagnostic - var related = __spreadArray([], ts.flatMap(diags_3, function (d) { return d.relatedInformation; })); + var related = __spreadArray([], ts.flatMap(diags_2, function (d) { return d.relatedInformation; })); var diag = void 0; - if (ts.every(diags_3, function (d) { return d.start === diags_3[0].start && d.length === diags_3[0].length && d.file === diags_3[0].file; })) { - var _b = diags_3[0], file = _b.file, start = _b.start, length_7 = _b.length; + if (ts.every(diags_2, function (d) { return d.start === diags_2[0].start && d.length === diags_2[0].length && d.file === diags_2[0].file; })) { + var _b = diags_2[0], file = _b.file, start = _b.start, length_7 = _b.length; diag = { file: file, start: start, length: length_7, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related }; } else { @@ -71126,8 +71051,7 @@ var ts; if (ts.isCallChain(node)) { var nonOptionalType = getOptionalExpressionType(funcType, node.expression); callChainFlags = nonOptionalType === funcType ? 0 /* None */ : - ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : - 8 /* IsInnerCallChain */; + ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : 8 /* IsInnerCallChain */; funcType = nonOptionalType; } else { @@ -71904,10 +71828,8 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 252 /* FunctionDeclaration */ - : resolvedRequire.flags & 3 /* Variable */ - ? 250 /* VariableDeclaration */ - : 0 /* Unknown */; + ? 252 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ + ? 250 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient @@ -75552,7 +75474,7 @@ var ts; case 199 /* BindingElement */: case 252 /* FunctionDeclaration */: case 266 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 78 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 78 /* Identifier */: // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` // SyntaxKind.ElementAccessExpression - `thing["aField"] = 42;` or `thing["aField"];` (with a doc comment on it) @@ -76828,12 +76750,7 @@ var ts; if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { return false; } - var interestingFlags = 8 /* Private */ | - 16 /* Protected */ | - 256 /* Async */ | - 128 /* Abstract */ | - 64 /* Readonly */ | - 32 /* Static */; + var interestingFlags = 8 /* Private */ | 16 /* Protected */ | 256 /* Async */ | 128 /* Abstract */ | 64 /* Readonly */ | 32 /* Static */; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { @@ -76875,7 +76792,7 @@ var ts; return; if (getAwaitedTypeOfPromise(type)) { errorAndMaybeSuggestAwait(condExpr, - /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", getTypeNameForErrorDisplay(type), "false"); + /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined, getTypeNameForErrorDisplay(type)); return; } var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr; @@ -76904,7 +76821,7 @@ var ts; var isUsed = ts.isBinaryExpression(condExpr.parent) && isFunctionUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) || body && isFunctionUsedInConditionBody(condExpr, body, testedNode, testedSymbol); if (!isUsed) { - error(location, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead); } } function isFunctionUsedInConditionBody(expr, body, testedNode, testedSymbol) { @@ -78039,6 +77956,7 @@ var ts; switch (name.escapedText) { case "any": case "unknown": + case "never": case "number": case "bigint": case "boolean": @@ -78544,9 +78462,9 @@ var ts; ts.forEach(properties, function (p) { seen.set(p.escapedName, p); }); for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; - var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) { - var prop = properties_4[_a]; + var properties_4 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); + for (var _a = 0, properties_5 = properties_4; _a < properties_5.length; _a++) { + var prop = properties_5[_a]; var existing = seen.get(prop.escapedName); if (existing && !isPropertyIdenticalTo(existing, prop)) { seen.delete(prop.escapedName); @@ -80209,7 +80127,7 @@ var ts; return resolveEntityName(name, meaning, /*ignoreErrors*/ true); } if (name.parent.kind === 173 /* TypePredicate */) { - return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); + return resolveEntityName(name, 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; @@ -80599,7 +80517,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -82982,7 +82900,7 @@ var ts; case 263 /* ImportClause */: // For default import case 261 /* ImportEqualsDeclaration */: case 264 /* NamespaceImport */: - case 266 /* ImportSpecifier */: // For rename import `x as y` + case 266 /* ImportSpecifier */: return true; case 78 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. @@ -88161,9 +88079,7 @@ var ts; } function visitPrefixUnaryExpression(node) { if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { - var operator = node.operator === 45 /* PlusPlusToken */ ? - 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? - 40 /* MinusToken */ : undefined; + var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; var info = void 0; if (operator && (info = accessPrivateIdentifier(node.operand.name))) { var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); @@ -88176,9 +88092,7 @@ var ts; } function visitPostfixUnaryExpression(node, valueIsDiscarded) { if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { - var operator = node.operator === 45 /* PlusPlusToken */ ? - 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? - 40 /* MinusToken */ : undefined; + var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; var info = void 0; if (operator && (info = accessPrivateIdentifier(node.operand.name))) { var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); @@ -89894,9 +89808,7 @@ var ts; return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? - 0 /* StrictModeSourceFileIncludes */ : - 1 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? 0 /* StrictModeSourceFileIncludes */ : 1 /* SourceFileIncludes */); exportedVariableStatement = false; var visited = ts.visitEachChild(node, visitor, context); var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [ @@ -98703,9 +98615,9 @@ var ts; var _a, _b; var result = getImportOrExportBindingReference(node, /*removeEntry*/ true); switch (result === null || result === void 0 ? void 0 : result.kind) { - case 78 /* Identifier */: // tslib import + case 78 /* Identifier */: return factory.createPropertyAccessExpression(result, node); - case 298 /* SourceFile */: // top-level export + case 298 /* SourceFile */: return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); case 263 /* ImportClause */: @@ -100879,13 +100791,7 @@ var ts; }); } ts.isInternalDeclaration = isInternalDeclaration; - var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | - 2048 /* WriteClassExpressionAsTypeLiteral */ | - 4096 /* UseTypeOfFunction */ | - 8 /* UseStructuralFallback */ | - 524288 /* AllowEmptyTuple */ | - 4 /* GenerateNamesForShadowedTypeParams */ | - 1 /* NoTruncation */; + var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | 2048 /* WriteClassExpressionAsTypeLiteral */ | 4096 /* UseTypeOfFunction */ | 8 /* UseStructuralFallback */ | 524288 /* AllowEmptyTuple */ | 4 /* GenerateNamesForShadowedTypeParams */ | 1 /* NoTruncation */; /** * Transforms a ts file into a .d.ts file * This process requires type information, which is retrieved through the emit resolver. Because of this, @@ -101786,7 +101692,7 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 255 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 255 /* TypeAliasDeclaration */: return cleanup(factory.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); case 254 /* InterfaceDeclaration */: { @@ -102874,11 +102780,8 @@ var ts; if (configFile.options.emitDeclarationOnly) return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); - var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), isJsonFile ? - ".json" /* Json */ : - configFile.options.jsx === 1 /* Preserve */ && (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) || ts.fileExtensionIs(inputFileName, ".jsx" /* Jsx */)) ? - ".jsx" /* Jsx */ : - ".js" /* Js */); + var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), isJsonFile ? ".json" /* Json */ : + configFile.options.jsx === 1 /* Preserve */ && (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) || ts.fileExtensionIs(inputFileName, ".jsx" /* Jsx */)) ? ".jsx" /* Jsx */ : ".js" /* Js */); return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? outputFileName : undefined; @@ -104384,9 +104287,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 295 /* UnparsedText */ ? - "text" /* Text */ : - "internal" /* Internal */); + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 295 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } } // SyntaxKind.UnparsedSyntheticReference @@ -114499,8 +114400,7 @@ var ts; return { relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : - importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : - 2 /* Shortest */, + importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : 2 /* Shortest */, ending: getEnding(), }; function getEnding() { @@ -114508,16 +114408,14 @@ var ts; case "minimal": return 0 /* Minimal */; case "index": return 1 /* Index */; case "js": return 2 /* JsExtension */; - default: return usesJsExtensionOnImports(importingSourceFile) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; + default: return usesJsExtensionOnImports(importingSourceFile) ? 2 /* JsExtension */ : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; } } } function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSFileExtension(oldImportSpecifier) ? - 2 /* JsExtension */ : + ending: ts.hasJSFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } @@ -117580,8 +117478,14 @@ var ts; continue; } var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames()); + if (!outputs.length) + continue; + var inputFileNames = new ts.Set(parsed.fileNames.map(function (f) { return toPath(state, f); })); for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) { var output = outputs_3[_a]; + // If output name is same as input file name, do not delete and ignore the error + if (inputFileNames.has(toPath(state, output))) + continue; if (host.fileExists(output)) { if (filesToDelete) { filesToDelete.push(output); @@ -118997,10 +118901,8 @@ var ts; } function getKindOfVariableDeclaration(v) { return ts.isVarConst(v) - ? "const" /* constElement */ - : ts.isLet(v) - ? "let" /* letElement */ - : "var" /* variableElement */; + ? "const" /* constElement */ : ts.isLet(v) + ? "let" /* letElement */ : "var" /* variableElement */; } } ts.getNodeKind = getNodeKind; @@ -120901,10 +120803,10 @@ var ts; var delta = 0; var lastPos = -1; for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { - var _a = edits_1[_i], fileName = _a.fileName, textChanges_2 = _a.textChanges; + var _a = edits_1[_i], fileName = _a.fileName, textChanges_1 = _a.textChanges; ts.Debug.assert(fileName === renameFilename); - for (var _b = 0, textChanges_1 = textChanges_2; _b < textChanges_1.length; _b++) { - var change = textChanges_1[_b]; + for (var _b = 0, textChanges_2 = textChanges_1; _b < textChanges_2.length; _b++) { + var change = textChanges_2[_b]; var span = change.span, newText = change.newText; var index = indexInTextChange(newText, name); if (index !== -1) { @@ -120970,7 +120872,9 @@ var ts; } /* @internal */ function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ || ts.isObjectLiteralExpression(expression); + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ + || ts.isObjectLiteralExpression(expression) + || ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression); } ts.needsParentheses = needsParentheses; function getContextualTypeFromParent(node, checker) { @@ -123958,8 +123862,7 @@ var ts; var replacementSpan = ts.createTextSpanFromNode(importCompletionNode, sourceFile); var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier); var exportKind = origin.isDefaultExport ? 1 /* Default */ : - origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : - 0 /* Named */; + origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : 0 /* Named */; var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options); var suffix = useSemicolons ? ";" : ""; @@ -124268,7 +124171,7 @@ var ts; } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { - var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* All */, /*useOnlyExternalAliasing*/ false); + var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, 67108863 /* All */, /*useOnlyExternalAliasing*/ false); if (chain) return ts.first(chain); return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); @@ -124855,8 +124758,7 @@ var ts; collectAutoImports(/*resolveModuleSpecifier*/ false); if (isTypeOnly) { keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) - ? 6 /* TypeAssertionKeywords */ - : 7 /* TypeKeywords */; + ? 6 /* TypeAssertionKeywords */ : 7 /* TypeKeywords */; } } function shouldOfferImportCompletions() { @@ -125086,7 +124988,7 @@ var ts; || containingNodeKind === 172 /* IndexSignature */ // [ | : string ] || containingNodeKind === 159 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 139 /* ModuleKeyword */: // module | - case 140 /* NamespaceKeyword */: // namespace | + case 140 /* NamespaceKeyword */: return true; case 24 /* DotToken */: return containingNodeKind === 257 /* ModuleDeclaration */; // module A.| @@ -125316,7 +125218,7 @@ var ts; var parent = contextToken.parent; switch (contextToken.kind) { case 18 /* OpenBraceToken */: // const x = { | - case 27 /* CommaToken */: // const x = { a: 0, | + case 27 /* CommaToken */: if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) { return parent; } @@ -125495,7 +125397,7 @@ var ts; case 118 /* LetKeyword */: case 84 /* ConstKeyword */: case 135 /* InferKeyword */: - case 149 /* TypeKeyword */: // type htm| + case 149 /* TypeKeyword */: return true; case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); @@ -125758,7 +125660,7 @@ var ts; // TODO: GH#18169 return { name: JSON.stringify(name), needsConvertPropertyAccess: false }; case 2 /* PropertyAccess */: - case 1 /* Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. + case 1 /* Global */: // Don't add a completion for a name starting with a space. See https://github.com/Microsoft/TypeScript/pull/20547 return name.charCodeAt(0) === 32 /* space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; case 5 /* None */: @@ -125948,16 +125850,16 @@ var ts; if (!contextToken) return undefined; switch (contextToken.kind) { - case 62 /* EqualsToken */: // class c { public prop = | /* global completions */ } + case 62 /* EqualsToken */: return undefined; case 26 /* SemicolonToken */: // class c {getValue(): number; | } - case 19 /* CloseBraceToken */: // class c { method() { } | } + case 19 /* CloseBraceToken */: // class c { method() { } b| } return isFromObjectTypeDeclaration(location) && location.parent.name === location ? location.parent.parent : ts.tryCast(location, ts.isObjectTypeDeclaration); case 18 /* OpenBraceToken */: // class c { | - case 27 /* CommaToken */: // class c {getValue(): number, | } + case 27 /* CommaToken */: return ts.tryCast(contextToken.parent, ts.isObjectTypeDeclaration); default: if (!isFromObjectTypeDeclaration(contextToken)) { @@ -126744,7 +126646,7 @@ var ts; } } break; - case 78 /* Identifier */: // for 'const x = require("y"); + case 78 /* Identifier */: break; // TODO: GH#23879 case 261 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); @@ -131329,11 +131231,9 @@ var ts; return ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node); } var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? - ts.getAssignmentDeclarationKind(b.node) : - 0 /* None */; + ts.getAssignmentDeclarationKind(b.node) : 0 /* None */; var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? - ts.getAssignmentDeclarationKind(a.node) : - 0 /* None */; + ts.getAssignmentDeclarationKind(a.node) : 0 /* None */; // We treat this as an es5 class and merge the nodes in in one of several cases if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member @@ -132627,8 +132527,7 @@ var ts; return ts.min(a, b, compareMatches); } function compareMatches(a, b) { - return a === undefined ? 1 /* GreaterThan */ : b === undefined ? -1 /* LessThan */ - : ts.compareValues(a.kind, b.kind) || ts.compareBooleans(!a.isCaseSensitive, !b.isCaseSensitive); + return a === undefined ? 1 /* GreaterThan */ : b === undefined ? -1 /* LessThan */ : ts.compareValues(a.kind, b.kind) || ts.compareBooleans(!a.isCaseSensitive, !b.isCaseSensitive); } function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { if (patternSpan === void 0) { patternSpan = { start: 0, length: pattern.length }; } @@ -134645,8 +134544,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 222 /* ClassExpression */) ? - "local class" /* localClassElement */ : "class" /* classElement */; + return ts.getDeclarationOfKind(symbol, 222 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) return "enum" /* enumElement */; @@ -134749,8 +134647,7 @@ var ts; var _a = symbol.declarations, declaration = _a[0], declarations = _a.slice(1); // omit deprecated flag if some declarations are not deprecated var excludeFlags = ts.length(declarations) && isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !isDeprecatedDeclaration(d); }) - ? 8192 /* Deprecated */ - : 0 /* None */; + ? 8192 /* Deprecated */ : 0 /* None */; var modifiers = ts.getNodeModifiers(declaration, excludeFlags); if (modifiers) { return modifiers.split(","); @@ -135631,8 +135528,7 @@ var ts; shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : - shouldRescanJsxAttributeValue(n) ? 6 /* RescanJsxAttributeValue */ : - 0 /* Scan */; + shouldRescanJsxAttributeValue(n) ? 6 /* RescanJsxAttributeValue */ : 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -135813,8 +135709,14 @@ var ts; var binaryKeywordOperators = [100 /* InKeyword */, 101 /* InstanceOfKeyword */, 157 /* OfKeyword */, 126 /* AsKeyword */, 137 /* IsKeyword */]; var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 78 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */ + 8 /* NumericLiteral */, + 9 /* BigIntLiteral */, + 78 /* Identifier */, + 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, + 18 /* OpenBraceToken */, + 107 /* ThisKeyword */, + 102 /* NewKeyword */ ]; var unaryPreincrementExpressions = [78 /* Identifier */, 20 /* OpenParenToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */]; var unaryPostincrementExpressions = [78 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 102 /* NewKeyword */]; @@ -136245,7 +136147,7 @@ var ts; // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 254 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 254 /* InterfaceDeclaration */: return true; } return false; @@ -137135,7 +137037,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); + processChildNode(child, -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -137306,8 +137208,7 @@ var ts; } if (indentToken) { var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? - dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : - -1 /* Unknown */; + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : -1 /* Unknown */; var indentNextTokenOrTrivia = true; if (currentTokenInfo.leadingTrivia) { var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); @@ -139921,6 +139822,7 @@ var ts; ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1.code, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined.code, ts.Diagnostics.Type_0_is_not_an_array_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code, @@ -141102,7 +141004,7 @@ var ts; // do not produce a transformed statement for a null argument break; case 202 /* PropertyAccessExpression */: - case 78 /* Identifier */: // identifier includes undefined + case 78 /* Identifier */: if (!argName) { // undefined was argument passed to promise handler break; @@ -141678,7 +141580,9 @@ var ts; } /** * Convert `import x = require("x").` - * Also converts uses like `x.y()` to `y()` and uses a named import. + * Also: + * - Convert `x.default()` to `x()` to handle ES6 default export + * - Converts uses like `x.y()` to `y()` and uses a named import. */ function convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference) { var nameSymbol = checker.getSymbolAtLocation(name); @@ -141695,14 +141599,21 @@ var ts; } var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { - var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` - var idName = namedBindingsNames.get(propertyName); - if (idName === undefined) { - idName = makeUniqueName(propertyName, identifiers); - namedBindingsNames.set(propertyName, idName); + var propertyName = parent.name.text; + if (propertyName === "default") { + needDefaultImport = true; + var importDefaultName = use.getText(); + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(importDefaultName)); + } + else { + ts.Debug.assert(parent.expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` + var idName = namedBindingsNames.get(propertyName); + if (idName === undefined) { + idName = makeUniqueName(propertyName, identifiers); + namedBindingsNames.set(propertyName, idName); + } + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } - (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } else { needDefaultImport = true; @@ -144896,7 +144807,7 @@ var ts; (function (codefix) { var fixId = "fixMissingCallParentheses"; var errorCodes = [ - ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead.code, ]; codefix.registerCodeFix({ errorCodes: errorCodes, @@ -147824,8 +147735,10 @@ var ts; } if (context.preferences.provideRefactorNotApplicableReason) { return [ - { name: refactorName, description: namespaceToNamedAction.description, actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] }, - { name: refactorName, description: namedToNamespaceAction.description, actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] } + { name: refactorName, description: namespaceToNamedAction.description, + actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] }, + { name: refactorName, description: namedToNamespaceAction.description, + actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] } ]; } return ts.emptyArray; @@ -162560,8 +162473,7 @@ var ts; } function directoryHasPackageJson(directory) { return packageJsons.has(ts.combinePaths(directory, "package.json")) ? -1 /* True */ : - directoriesWithoutPackageJson.has(directory) ? 0 /* False */ : - 3 /* Maybe */; + directoriesWithoutPackageJson.has(directory) ? 0 /* False */ : 3 /* Maybe */; } } server.createPackageJsonCache = createPackageJsonCache; diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 2f1d94e3672..0b2d291eedd 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -16,7 +16,7 @@ and limitations under the License. declare namespace ts { const versionMajorMinor = "4.3"; /** The version of the TypeScript compiler release */ - const version = "4.3.0-beta"; + const version: string; /** * Type of objects whose values are all of the same type. * The `in` and `for-in` operators can *not* be safely used, diff --git a/lib/typescript.js b/lib/typescript.js index c8e2304cba6..9c998682479 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -1847,8 +1847,7 @@ var ts; return a === b ? 0 /* EqualTo */ : a === undefined ? -1 /* LessThan */ : b === undefined ? 1 /* GreaterThan */ : - a < b ? -1 /* LessThan */ : - 1 /* GreaterThan */; + a < b ? -1 /* LessThan */ : 1 /* GreaterThan */; } /** * Compare two numeric values for their order relative to each other. @@ -7851,8 +7850,7 @@ var ts; if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) - ? 1 /* Normal */ - : 0 /* None */); + ? 1 /* Normal */ : 0 /* None */); } if (ts.sys && ts.sys.debugMode) { ts.Debug.isDebugging = true; @@ -7871,7 +7869,7 @@ var ts; Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), - The_parser_expected_to_find_a_to_match_the_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_to_match_the_token_here_1007", "The parser expected to find a '}' to match the '{' token here."), + The_parser_expected_to_find_a_1_to_match_the_0_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_1_to_match_the_0_token_here_1007", "The parser expected to find a '{1}' to match the '{0}' token here."), Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), @@ -8657,7 +8655,7 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), - This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_2774", "This condition will always return true since this function appears to always be defined. Did you mean to call it instead?"), Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), @@ -8684,7 +8682,7 @@ var ts; The_declaration_was_marked_as_deprecated_here: diag(2798, ts.DiagnosticCategory.Error, "The_declaration_was_marked_as_deprecated_here_2798", "The declaration was marked as deprecated here."), Type_produces_a_tuple_type_that_is_too_large_to_represent: diag(2799, ts.DiagnosticCategory.Error, "Type_produces_a_tuple_type_that_is_too_large_to_represent_2799", "Type produces a tuple type that is too large to represent."), Expression_produces_a_tuple_type_that_is_too_large_to_represent: diag(2800, ts.DiagnosticCategory.Error, "Expression_produces_a_tuple_type_that_is_too_large_to_represent_2800", "Expression produces a tuple type that is too large to represent."), - This_condition_will_always_return_true_since_the_Promise_is_always_truthy: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_Promise_is_always_truthy_2801", "This condition will always return true since the Promise is always truthy."), + This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined_2801", "This condition will always return true since this '{0}' appears to always be defined."), Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."), Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."), Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."), @@ -8692,6 +8690,7 @@ var ts; Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."), This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."), A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), + Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "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: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -13168,7 +13167,7 @@ var ts; case 105 /* SuperKeyword */: case 226 /* NonNullExpression */: case 227 /* MetaProperty */: - case 99 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 99 /* ImportKeyword */: return true; default: return false; @@ -16232,8 +16231,7 @@ var ts; case 217 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : - 0 /* None */; + binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; case 215 /* PrefixUnaryExpression */: case 216 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; @@ -18658,8 +18656,7 @@ var ts; if (getCheckFlags(s) & 6 /* Synthetic */) { var checkFlags = s.checkFlags; var accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : - checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : - 16 /* Protected */; + checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : 16 /* Protected */; var staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; return accessModifier | staticModifier; } @@ -19191,8 +19188,7 @@ var ts; } function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || - compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; + compareRelatedInformation(d1, d2) || 0 /* EqualTo */; } ts.compareDiagnostics = compareDiagnostics; function compareDiagnosticsSkipRelatedInformation(d1, d2) { @@ -19200,8 +19196,7 @@ var ts; ts.compareValues(d1.start, d2.start) || ts.compareValues(d1.length, d2.length) || ts.compareValues(d1.code, d2.code) || - compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; + compareMessageText(d1.messageText, d2.messageText) || 0 /* EqualTo */; } ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; function compareRelatedInformation(d1, d2) { @@ -20035,15 +20030,15 @@ var ts; var log2Base; switch (stringValue.charCodeAt(1)) { // "x" in "0x123" case 98 /* b */: - case 66 /* B */: // 0b or 0B + case 66 /* B */: log2Base = 1; break; case 111 /* o */: - case 79 /* O */: // 0o or 0O + case 79 /* O */: log2Base = 3; break; case 120 /* x */: - case 88 /* X */: // 0x or 0X + case 88 /* X */: log2Base = 4; break; default: // already in decimal; omit trailing "n" @@ -21686,8 +21681,7 @@ var ts; case 129 /* AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */; break; case 122 /* PublicKeyword */: case 120 /* PrivateKeyword */: @@ -21706,7 +21700,7 @@ var ts; case 148 /* SymbolKeyword */: case 113 /* VoidKeyword */: case 152 /* UnknownKeyword */: - case 150 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + case 150 /* UndefinedKeyword */: transformFlags = 1 /* ContainsTypeScript */; break; case 123 /* StaticKeyword */: @@ -21819,9 +21813,7 @@ var ts; var node = createBaseNode(159 /* ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 512 /* ContainsES2015 */ | - 65536 /* ContainsComputedPropertyName */; + propagateChildFlags(node.expression) | 512 /* ContainsES2015 */ | 65536 /* ContainsComputedPropertyName */; return node; } // @api @@ -21889,9 +21881,7 @@ var ts; var node = createBaseNode(162 /* Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */ | - 4096 /* ContainsTypeScriptClassSyntax */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */ | 4096 /* ContainsTypeScriptClassSyntax */; return node; } // @api @@ -21928,8 +21918,7 @@ var ts; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | - propagateChildFlags(node.exclamationToken) | - 8388608 /* ContainsClassFields */; + propagateChildFlags(node.exclamationToken) | 8388608 /* ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; } @@ -21976,8 +21965,7 @@ var ts; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | - propagateChildFlags(node.questionToken) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.questionToken) | 512 /* ContainsES2015 */; if (questionToken) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22505,13 +22493,10 @@ var ts; var node = createBaseNode(197 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= - propagateChildrenFlags(node.elements) | - 512 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; + propagateChildrenFlags(node.elements) | 512 /* ContainsES2015 */ | 262144 /* ContainsBindingPattern */; if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { node.transformFlags |= - 64 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + 64 /* ContainsES2018 */ | 32768 /* ContainsObjectRestOrSpread */; } return node; } @@ -22526,9 +22511,7 @@ var ts; var node = createBaseNode(198 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= - propagateChildrenFlags(node.elements) | - 512 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; + propagateChildrenFlags(node.elements) | 512 /* ContainsES2015 */ | 262144 /* ContainsBindingPattern */; return node; } // @api @@ -22545,8 +22528,7 @@ var ts; node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= - propagateChildFlags(node.dotDotDotToken) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.dotDotDotToken) | 512 /* ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : @@ -22615,8 +22597,7 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */; } return node; } @@ -22669,8 +22650,7 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */; } return node; } @@ -22694,8 +22674,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | - propagateChildFlags(node.argumentExpression) | - 16 /* ContainsES2020 */; + propagateChildFlags(node.argumentExpression) | 16 /* ContainsES2020 */; return node; } // @api @@ -22753,8 +22732,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | - propagateChildrenFlags(node.arguments) | - 16 /* ContainsES2020 */; + propagateChildrenFlags(node.arguments) | 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22782,8 +22760,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - propagateChildrenFlags(node.arguments) | - 16 /* ContainsES2020 */; + propagateChildrenFlags(node.arguments) | 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22806,8 +22783,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.template) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.template) | 512 /* ContainsES2015 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22831,8 +22807,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.type) | 1 /* ContainsTypeScript */; return node; } // @api @@ -22896,8 +22871,7 @@ var ts; /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); node.transformFlags |= - propagateChildFlags(node.equalsGreaterThanToken) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.equalsGreaterThanToken) | 512 /* ContainsES2015 */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { node.transformFlags |= 128 /* ContainsES2017 */; } @@ -22958,10 +22932,7 @@ var ts; var node = createBaseExpression(214 /* AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */ | - 1048576 /* ContainsAwait */; + propagateChildFlags(node.expression) | 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */ | 1048576 /* ContainsAwait */; return node; } // @api @@ -23016,15 +22987,12 @@ var ts; else if (operatorKind === 62 /* EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 512 /* ContainsES2015 */ | - 64 /* ContainsES2018 */ | - 2048 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | 64 /* ContainsES2018 */ | 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 512 /* ContainsES2015 */ | - 2048 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } @@ -23100,8 +23068,7 @@ var ts; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | - propagateChildrenFlags(node.templateSpans) | - 512 /* ContainsES2015 */; + propagateChildrenFlags(node.templateSpans) | 512 /* ContainsES2015 */; return node; } // @api @@ -23170,10 +23137,7 @@ var ts; node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.asteriskToken) | - 512 /* ContainsES2015 */ | - 64 /* ContainsES2018 */ | - 524288 /* ContainsYield */; + propagateChildFlags(node.asteriskToken) | 512 /* ContainsES2015 */ | 64 /* ContainsES2018 */ | 524288 /* ContainsYield */; return node; } // @api @@ -23188,9 +23152,7 @@ var ts; var node = createBaseExpression(221 /* SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 512 /* ContainsES2015 */ | - 16384 /* ContainsRestOrSpread */; + propagateChildFlags(node.expression) | 512 /* ContainsES2015 */ | 16384 /* ContainsRestOrSpread */; return node; } // @api @@ -23227,8 +23189,7 @@ var ts; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildrenFlags(node.typeArguments) | - 512 /* ContainsES2015 */; + propagateChildrenFlags(node.typeArguments) | 512 /* ContainsES2015 */; return node; } // @api @@ -23245,8 +23206,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.type) | 1 /* ContainsTypeScript */; return node; } // @api @@ -23261,8 +23221,7 @@ var ts; var node = createBaseExpression(226 /* NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */; return node; } // @api @@ -23280,8 +23239,7 @@ var ts; node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */; return node; } // @api @@ -23325,8 +23283,7 @@ var ts; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.literal) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.literal) | 512 /* ContainsES2015 */; return node; } // @api @@ -23502,8 +23459,7 @@ var ts; propagateChildFlags(node.awaitModifier) | propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | - propagateChildFlags(node.statement) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.statement) | 512 /* ContainsES2015 */; if (awaitModifier) node.transformFlags |= 64 /* ContainsES2018 */; return node; @@ -23522,8 +23478,7 @@ var ts; var node = createBaseNode(241 /* ContinueStatement */); node.label = asName(label); node.transformFlags |= - propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.label) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23537,8 +23492,7 @@ var ts; var node = createBaseNode(242 /* BreakStatement */); node.label = asName(label); node.transformFlags |= - propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.label) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23553,9 +23507,7 @@ var ts; node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= - propagateChildFlags(node.expression) | - 64 /* ContainsES2018 */ | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.expression) | 64 /* ContainsES2018 */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23680,12 +23632,10 @@ var ts; node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= - propagateChildrenFlags(node.declarations) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildrenFlags(node.declarations) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (flags & 3 /* BlockScoped */) { node.transformFlags |= - 512 /* ContainsES2015 */ | - 131072 /* ContainsBlockScopedBinding */; + 512 /* ContainsES2015 */ | 131072 /* ContainsBlockScopedBinding */; } return node; } @@ -23704,8 +23654,7 @@ var ts; } else { node.transformFlags |= - propagateChildFlags(node.asteriskToken) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.asteriskToken) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (node.asteriskToken) { node.transformFlags |= 64 /* ContainsES2018 */; @@ -23798,8 +23747,7 @@ var ts; var node = createBaseNamedDeclaration(256 /* EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= - propagateChildrenFlags(node.members) | - 1 /* ContainsTypeScript */; + propagateChildrenFlags(node.members) | 1 /* ContainsTypeScript */; node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` return node; } @@ -23825,8 +23773,7 @@ var ts; else { node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.body) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.body) | 1 /* ContainsTypeScript */; } node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. return node; @@ -23963,8 +23910,7 @@ var ts; var node = createBaseNode(270 /* NamespaceExport */); node.name = name; node.transformFlags |= - propagateChildFlags(node.name) | - 4 /* ContainsESNext */; + propagateChildFlags(node.name) | 4 /* ContainsESNext */; node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } @@ -24470,8 +24416,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.openingElement) | propagateChildrenFlags(node.children) | - propagateChildFlags(node.closingElement) | - 2 /* ContainsJsx */; + propagateChildFlags(node.closingElement) | 2 /* ContainsJsx */; return node; } // @api @@ -24491,8 +24436,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + propagateChildFlags(node.attributes) | 2 /* ContainsJsx */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -24515,8 +24459,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + propagateChildFlags(node.attributes) | 2 /* ContainsJsx */; if (typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -24535,8 +24478,7 @@ var ts; var node = createBaseNode(277 /* JsxClosingElement */); node.tagName = tagName; node.transformFlags |= - propagateChildFlags(node.tagName) | - 2 /* ContainsJsx */; + propagateChildFlags(node.tagName) | 2 /* ContainsJsx */; return node; } // @api @@ -24554,8 +24496,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.openingFragment) | propagateChildrenFlags(node.children) | - propagateChildFlags(node.closingFragment) | - 2 /* ContainsJsx */; + propagateChildFlags(node.closingFragment) | 2 /* ContainsJsx */; return node; } // @api @@ -24600,8 +24541,7 @@ var ts; node.initializer = initializer; node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.initializer) | - 2 /* ContainsJsx */; + propagateChildFlags(node.initializer) | 2 /* ContainsJsx */; return node; } // @api @@ -24616,8 +24556,7 @@ var ts; var node = createBaseNode(282 /* JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= - propagateChildrenFlags(node.properties) | - 2 /* ContainsJsx */; + propagateChildrenFlags(node.properties) | 2 /* ContainsJsx */; return node; } // @api @@ -24631,8 +24570,7 @@ var ts; var node = createBaseNode(283 /* JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= - propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + propagateChildFlags(node.expression) | 2 /* ContainsJsx */; return node; } // @api @@ -24648,8 +24586,7 @@ var ts; node.expression = expression; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + propagateChildFlags(node.expression) | 2 /* ContainsJsx */; return node; } // @api @@ -24778,8 +24715,7 @@ var ts; /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= - propagateChildFlags(node.objectAssignmentInitializer) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.objectAssignmentInitializer) | 512 /* ContainsES2015 */; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -24808,9 +24744,7 @@ var ts; var node = createBaseNode(291 /* SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 64 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + propagateChildFlags(node.expression) | 64 /* ContainsES2018 */ | 32768 /* ContainsObjectRestOrSpread */; return node; } // @api @@ -24829,8 +24763,7 @@ var ts; node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.initializer) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.initializer) | 1 /* ContainsTypeScript */; return node; } // @api @@ -25006,8 +24939,7 @@ var ts; node.expression = expression; node.original = original; node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */; ts.setTextRange(node, original); return node; } @@ -30135,20 +30067,23 @@ var ts; return inContext(32768 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { - parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); + return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); } function parseErrorAtPosition(start, length, message, arg0) { // Don't report another error if it would just be at the same position as the last error. var lastError = ts.lastOrUndefined(parseDiagnostics); + var result; if (!lastError || start !== lastError.start) { - parseDiagnostics.push(ts.createDetachedDiagnostic(fileName, start, length, message, arg0)); + result = ts.createDetachedDiagnostic(fileName, start, length, message, arg0); + parseDiagnostics.push(result); } // Mark that we've encountered an error. We'll set an appropriate bit on the next // node we finish so that it can't be reused incrementally. parseErrorBeforeNextFinishedNode = true; + return result; } function parseErrorAt(start, end, message, arg0) { - parseErrorAtPosition(start, end - start, message, arg0); + return parseErrorAtPosition(start, end - start, message, arg0); } function parseErrorAtRange(range, message, arg0) { parseErrorAt(range.pos, range.end, message, arg0); @@ -30305,6 +30240,16 @@ var ts; parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); return false; } + function parseExpectedMatchingBrackets(openKind, closeKind, openPosition) { + if (token() === closeKind) { + nextToken(); + return; + } + var lastError = parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(closeKind)); + if (lastError) { + ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openPosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, ts.tokenToString(openKind), ts.tokenToString(closeKind))); + } + } function parseOptional(t) { if (token() === t) { nextToken(); @@ -30593,7 +30538,7 @@ var ts; case 22 /* OpenBracketToken */: case 41 /* AsteriskToken */: case 25 /* DotDotDotToken */: - case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 24 /* DotToken */: return true; default: return isLiteralPropertyName(); @@ -30626,7 +30571,7 @@ var ts; case 15 /* ArrayLiteralMembers */: switch (token()) { case 27 /* CommaToken */: - case 24 /* DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) + case 24 /* DotToken */: return true; } // falls through @@ -30782,8 +30727,7 @@ var ts; var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, /*inErrorRecovery*/ false)) { - var element = parseListElement(kind, parseElement); - list.push(element); + list.push(parseListElement(kind, parseElement)); continue; } if (abortParsingListOrMoveToNextToken(kind)) { @@ -33587,7 +33531,7 @@ var ts; case 50 /* AmpersandToken */: // foo & case 51 /* BarToken */: // foo | case 19 /* CloseBraceToken */: // foo } - case 1 /* EndOfFileToken */: // foo + case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal // expressions either. The user is probably in the middle of a generic type. So // treat it as such. @@ -33671,10 +33615,11 @@ var ts; } function parseArrayLiteralExpression() { var pos = getNodePos(); + var openBracketPosition = scanner.getTokenPos(); parseExpected(22 /* OpenBracketToken */); var multiLine = scanner.hasPrecedingLineBreak(); var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(23 /* CloseBracketToken */); + parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketPosition); return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos); } function parseObjectLiteralElement() { @@ -33734,12 +33679,7 @@ var ts; parseExpected(18 /* OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { - var lastError = ts.lastOrUndefined(parseDiagnostics); - if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { - ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); - } - } + parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } function parseFunctionExpression() { @@ -33812,13 +33752,13 @@ var ts; if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); var statements = parseList(1 /* BlockStatements */, parseStatement); - if (!parseExpected(19 /* CloseBraceToken */)) { - var lastError = ts.lastOrUndefined(parseDiagnostics); - if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { - ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); - } + parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBracePosition); + var result = finishNode(factory.createBlock(statements, multiLine), pos); + if (token() === 62 /* EqualsToken */) { + parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); + nextToken(); } - return finishNode(factory.createBlock(statements, multiLine), pos); + return result; } else { var statements = createMissingList(); @@ -33855,9 +33795,10 @@ var ts; function parseIfStatement() { var pos = getNodePos(); parseExpected(98 /* IfKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); var thenStatement = parseStatement(); var elseStatement = parseOptional(90 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos); @@ -33867,9 +33808,10 @@ var ts; parseExpected(89 /* DoKeyword */); var statement = parseStatement(); parseExpected(114 /* WhileKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby @@ -33880,9 +33822,10 @@ var ts; function parseWhileStatement() { var pos = getNodePos(); parseExpected(114 /* WhileKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); var statement = parseStatement(); return finishNode(factory.createWhileStatement(expression, statement), pos); } @@ -33945,9 +33888,10 @@ var ts; function parseWithStatement() { var pos = getNodePos(); parseExpected(115 /* WithKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); return finishNode(factory.createWithStatement(expression, statement), pos); } @@ -34646,7 +34590,7 @@ var ts; case 53 /* ExclamationToken */: // Non-null assertion on property name case 58 /* ColonToken */: // Type Annotation for declaration case 62 /* EqualsToken */: // Initializer for declaration - case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 57 /* QuestionToken */: return true; default: // Covers @@ -35930,8 +35874,7 @@ var ts; hasChildren = true; if (child.kind === 333 /* JSDocTypeTag */) { if (childTypeTag) { - parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); - var lastError = ts.lastOrUndefined(parseDiagnostics); + var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, 0, 0, ts.Diagnostics.The_tag_was_first_specified_here)); } @@ -35962,7 +35905,7 @@ var ts; comment = parseTrailingTagComments(start, end, indent, indentText); } var typedefTag = factory.createJSDocTypedefTag(tagName, typeExpression, fullName, comment); - return finishNode(typedefTag, start); + return finishNode(typedefTag, start, end); } function parseJSDocTypeNameWithNamespace(nested) { var pos = scanner.getTokenPos(); @@ -43047,8 +42990,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 = prop.kind === 289 /* PropertyAssignment */ || prop.kind === 290 /* ShorthandPropertyAssignment */ || prop.kind === 166 /* MethodDeclaration */ - ? 1 /* Property */ - : 2 /* Accessor */; + ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); if (!existingKind) { seen.set(identifier.escapedText, currentKind); @@ -43569,7 +43511,7 @@ var ts; case 252 /* FunctionDeclaration */: return bindFunctionDeclaration(node); case 167 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); + return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, 0 /* None */); case 168 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); case 169 /* SetAccessor */: @@ -43662,8 +43604,7 @@ var ts; case 337 /* JSDocPropertyTag */: var propTag = node; var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 308 /* JSDocOptionalType */ ? - 4 /* Property */ | 16777216 /* Optional */ : - 4 /* Property */; + 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); case 335 /* JSDocTypedefTag */: case 328 /* JSDocCallbackTag */: @@ -43701,9 +43642,9 @@ var ts; else { var flags = ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; - ? 2097152 /* Alias */ - // An export default clause with any other expression exports a value - : 4 /* Property */; + ? 2097152 /* Alias */ + // An export default clause with any other expression exports a value + : 4 /* Property */; // If there is an `export default x;` alias declaration, can't `export default` anything else. // (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.) var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */); @@ -43812,8 +43753,7 @@ var ts; } // 'module.exports = expr' assignment var flags = ts.exportAssignmentIsAlias(node) - ? 2097152 /* Alias */ - : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; + ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); ts.setValueDeclaration(symbol, node); } @@ -46596,7 +46536,7 @@ var ts; case 254 /* InterfaceDeclaration */: case 256 /* EnumDeclaration */: case 255 /* TypeAliasDeclaration */: - case 257 /* ModuleDeclaration */: // For `namespace N { N; }` + case 257 /* ModuleDeclaration */: return true; default: return false; @@ -50498,8 +50438,7 @@ var ts; // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined - : isConstVariable(symbol) ? 2 /* Const */ - : 1 /* Let */; + : isConstVariable(symbol) ? 2 /* Const */ : 1 /* Let */; var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { @@ -51139,9 +51078,7 @@ var ts; ], 2 /* Const */)); // Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`. // Otherwise, the type itself should be exported. - addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ - : name === varName ? 1 /* Export */ - : 0 /* None */); + addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ : name === varName ? 1 /* Export */ : 0 /* None */); } if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( @@ -56509,8 +56446,7 @@ var ts; return getRestTypeElementFlags(node); case 193 /* NamedTupleMember */: return node.questionToken ? 2 /* Optional */ : - node.dotDotDotToken ? getRestTypeElementFlags(node) : - 1 /* Required */; + node.dotDotDotToken ? getRestTypeElementFlags(node) : 1 /* Required */; default: return 1 /* Required */; } @@ -57087,7 +57023,7 @@ var ts; } function createUnionType(types, aliasSymbol, aliasTypeArguments, origin) { var result = createType(1048576 /* Union */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + result.objectFlags = getPropagatingFlagsOfTypes(types, 98304 /* Nullable */); result.types = types; result.origin = origin; result.aliasSymbol = aliasSymbol; @@ -57275,7 +57211,7 @@ var ts; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { var result = createType(2097152 /* Intersection */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + result.objectFlags = getPropagatingFlagsOfTypes(types, 98304 /* Nullable */); result.types = types; result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; @@ -59262,7 +59198,7 @@ var ts; case 209 /* FunctionExpression */: case 210 /* ArrowFunction */: case 166 /* MethodDeclaration */: - case 252 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 252 /* FunctionDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); case 201 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); @@ -59986,8 +59922,7 @@ var ts; } } var related = source.type === target.type ? -1 /* True */ : - source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : - 0 /* False */; + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : 0 /* False */; if (related === 0 /* False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -61302,6 +61237,11 @@ var ts; } } else if (target.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TemplateLiteral */) { + // Report unreliable variance for type variables referenced in template literal type placeholders. + // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string. + instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + } var result_8 = inferTypesFromTemplateLiteralType(source, target); if (result_8 && ts.every(result_8, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) { return -1 /* True */; @@ -61345,20 +61285,6 @@ var ts; return result; } } - else if (source.flags & 134217728 /* TemplateLiteral */) { - if (target.flags & 134217728 /* TemplateLiteral */ && - source.texts.length === target.texts.length && - source.types.length === target.types.length && - ts.every(source.texts, function (t, i) { return t === target.texts[i]; }) && - ts.every(instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)).types, function (t, i) { return !!(target.types[i].flags & (1 /* Any */ | 4 /* String */)) || !!isRelatedTo(t, target.types[i], /*reportErrors*/ false); })) { - return -1 /* True */; - } - var constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, reportErrors))) { - resetErrorInfo(saveErrorInfo); - return result; - } - } else if (source.flags & 268435456 /* StringMapping */) { if (target.flags & 268435456 /* StringMapping */ && source.symbol === target.symbol) { if (result = isRelatedTo(source.type, target.type, reportErrors)) { @@ -62033,10 +61959,8 @@ var ts; } var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration); var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration); - var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); + var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? 0 /* Call */ : kind); + var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? 0 /* Call */ : kind); if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) { var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* Abstract */); var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* Abstract */); @@ -62712,8 +62636,7 @@ var ts; function compareTypePredicatesIdentical(source, target, compareTypes) { return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : source.type === target.type ? -1 /* True */ : - source.type && target.type ? compareTypes(source.type, target.type) : - 0 /* False */; + source.type && target.type ? compareTypes(source.type, target.type) : 0 /* False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; @@ -62765,7 +62688,12 @@ var ts; function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + return isArrayType(type) || hasArrayOrReadonlyArrayBaseType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + } + function hasArrayOrReadonlyArrayBaseType(type) { + return !!(ts.getObjectFlags(type) & 4 /* Reference */) + && !!(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */) + && ts.some(getBaseTypes(type.target), isArrayType); } function isEmptyArrayLiteralType(type) { var elementType = getElementTypeOfArrayType(type); @@ -64119,9 +64047,7 @@ var ts; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 /* NonInferrableType */ ? - 8 /* PartialHomomorphicMappedType */ : - 4 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 /* NonInferrableType */ ? 8 /* PartialHomomorphicMappedType */ : 4 /* HomomorphicMappedType */); } } return true; @@ -66549,7 +66475,7 @@ var ts; return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); if (target.flags & 111551 /* Value */) { // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled @@ -69542,7 +69468,7 @@ var ts; if (isInPropertyInitializer(node) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !isPropertyDeclaredInAncestorClass(prop)) { + && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } else if (valueDeclaration.kind === 253 /* ClassDeclaration */ && @@ -69916,8 +69842,7 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : - 0 /* None */; + 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : 0 /* None */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, accessFlags | 16 /* ExpressionPosition */) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } @@ -70838,14 +70763,14 @@ var ts; var i_1 = 0; var _loop_22 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; - var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); - if (diags_2) { - if (diags_2.length <= min_3) { - min_3 = diags_2.length; + var diags_3 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); + if (diags_3) { + if (diags_3.length <= min_3) { + min_3 = diags_3.length; minIndex = i_1; } - max = Math.max(max, diags_2.length); - allDiagnostics.push(diags_2); + max = Math.max(max, diags_3.length); + allDiagnostics.push(diags_3); } else { ts.Debug.fail("No error for 3 or fewer overload signatures"); @@ -70856,15 +70781,15 @@ var ts; var c = candidatesForArgumentError_1[_a]; _loop_22(c); } - var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); - ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); - var chain = ts.chainDiagnosticMessages(ts.map(diags_3, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call); + var diags_2 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); + ts.Debug.assert(diags_2.length > 0, "No errors reported for 3 or fewer overload signatures"); + var chain = ts.chainDiagnosticMessages(ts.map(diags_2, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call); // The below is a spread to guarantee we get a new (mutable) array - our `flatMap` helper tries to do "smart" optimizations where it reuses input // arrays and the emptyArray singleton where possible, which is decidedly not what we want while we're still constructing this diagnostic - var related = __spreadArray([], ts.flatMap(diags_3, function (d) { return d.relatedInformation; })); + var related = __spreadArray([], ts.flatMap(diags_2, function (d) { return d.relatedInformation; })); var diag = void 0; - if (ts.every(diags_3, function (d) { return d.start === diags_3[0].start && d.length === diags_3[0].length && d.file === diags_3[0].file; })) { - var _b = diags_3[0], file = _b.file, start = _b.start, length_7 = _b.length; + if (ts.every(diags_2, function (d) { return d.start === diags_2[0].start && d.length === diags_2[0].length && d.file === diags_2[0].file; })) { + var _b = diags_2[0], file = _b.file, start = _b.start, length_7 = _b.length; diag = { file: file, start: start, length: length_7, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related }; } else { @@ -71126,8 +71051,7 @@ var ts; if (ts.isCallChain(node)) { var nonOptionalType = getOptionalExpressionType(funcType, node.expression); callChainFlags = nonOptionalType === funcType ? 0 /* None */ : - ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : - 8 /* IsInnerCallChain */; + ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : 8 /* IsInnerCallChain */; funcType = nonOptionalType; } else { @@ -71904,10 +71828,8 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 252 /* FunctionDeclaration */ - : resolvedRequire.flags & 3 /* Variable */ - ? 250 /* VariableDeclaration */ - : 0 /* Unknown */; + ? 252 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ + ? 250 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient @@ -75552,7 +75474,7 @@ var ts; case 199 /* BindingElement */: case 252 /* FunctionDeclaration */: case 266 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 78 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 78 /* Identifier */: // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` // SyntaxKind.ElementAccessExpression - `thing["aField"] = 42;` or `thing["aField"];` (with a doc comment on it) @@ -76828,12 +76750,7 @@ var ts; if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { return false; } - var interestingFlags = 8 /* Private */ | - 16 /* Protected */ | - 256 /* Async */ | - 128 /* Abstract */ | - 64 /* Readonly */ | - 32 /* Static */; + var interestingFlags = 8 /* Private */ | 16 /* Protected */ | 256 /* Async */ | 128 /* Abstract */ | 64 /* Readonly */ | 32 /* Static */; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { @@ -76875,7 +76792,7 @@ var ts; return; if (getAwaitedTypeOfPromise(type)) { errorAndMaybeSuggestAwait(condExpr, - /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", getTypeNameForErrorDisplay(type), "false"); + /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined, getTypeNameForErrorDisplay(type)); return; } var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr; @@ -76904,7 +76821,7 @@ var ts; var isUsed = ts.isBinaryExpression(condExpr.parent) && isFunctionUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) || body && isFunctionUsedInConditionBody(condExpr, body, testedNode, testedSymbol); if (!isUsed) { - error(location, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead); } } function isFunctionUsedInConditionBody(expr, body, testedNode, testedSymbol) { @@ -78039,6 +77956,7 @@ var ts; switch (name.escapedText) { case "any": case "unknown": + case "never": case "number": case "bigint": case "boolean": @@ -78544,9 +78462,9 @@ var ts; ts.forEach(properties, function (p) { seen.set(p.escapedName, p); }); for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; - var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) { - var prop = properties_4[_a]; + var properties_4 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); + for (var _a = 0, properties_5 = properties_4; _a < properties_5.length; _a++) { + var prop = properties_5[_a]; var existing = seen.get(prop.escapedName); if (existing && !isPropertyIdenticalTo(existing, prop)) { seen.delete(prop.escapedName); @@ -80209,7 +80127,7 @@ var ts; return resolveEntityName(name, meaning, /*ignoreErrors*/ true); } if (name.parent.kind === 173 /* TypePredicate */) { - return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); + return resolveEntityName(name, 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; @@ -80599,7 +80517,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -82982,7 +82900,7 @@ var ts; case 263 /* ImportClause */: // For default import case 261 /* ImportEqualsDeclaration */: case 264 /* NamespaceImport */: - case 266 /* ImportSpecifier */: // For rename import `x as y` + case 266 /* ImportSpecifier */: return true; case 78 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. @@ -88161,9 +88079,7 @@ var ts; } function visitPrefixUnaryExpression(node) { if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { - var operator = node.operator === 45 /* PlusPlusToken */ ? - 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? - 40 /* MinusToken */ : undefined; + var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; var info = void 0; if (operator && (info = accessPrivateIdentifier(node.operand.name))) { var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); @@ -88176,9 +88092,7 @@ var ts; } function visitPostfixUnaryExpression(node, valueIsDiscarded) { if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { - var operator = node.operator === 45 /* PlusPlusToken */ ? - 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? - 40 /* MinusToken */ : undefined; + var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; var info = void 0; if (operator && (info = accessPrivateIdentifier(node.operand.name))) { var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); @@ -89894,9 +89808,7 @@ var ts; return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? - 0 /* StrictModeSourceFileIncludes */ : - 1 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? 0 /* StrictModeSourceFileIncludes */ : 1 /* SourceFileIncludes */); exportedVariableStatement = false; var visited = ts.visitEachChild(node, visitor, context); var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [ @@ -98703,9 +98615,9 @@ var ts; var _a, _b; var result = getImportOrExportBindingReference(node, /*removeEntry*/ true); switch (result === null || result === void 0 ? void 0 : result.kind) { - case 78 /* Identifier */: // tslib import + case 78 /* Identifier */: return factory.createPropertyAccessExpression(result, node); - case 298 /* SourceFile */: // top-level export + case 298 /* SourceFile */: return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); case 263 /* ImportClause */: @@ -100879,13 +100791,7 @@ var ts; }); } ts.isInternalDeclaration = isInternalDeclaration; - var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | - 2048 /* WriteClassExpressionAsTypeLiteral */ | - 4096 /* UseTypeOfFunction */ | - 8 /* UseStructuralFallback */ | - 524288 /* AllowEmptyTuple */ | - 4 /* GenerateNamesForShadowedTypeParams */ | - 1 /* NoTruncation */; + var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | 2048 /* WriteClassExpressionAsTypeLiteral */ | 4096 /* UseTypeOfFunction */ | 8 /* UseStructuralFallback */ | 524288 /* AllowEmptyTuple */ | 4 /* GenerateNamesForShadowedTypeParams */ | 1 /* NoTruncation */; /** * Transforms a ts file into a .d.ts file * This process requires type information, which is retrieved through the emit resolver. Because of this, @@ -101786,7 +101692,7 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 255 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 255 /* TypeAliasDeclaration */: return cleanup(factory.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); case 254 /* InterfaceDeclaration */: { @@ -102874,11 +102780,8 @@ var ts; if (configFile.options.emitDeclarationOnly) return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); - var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), isJsonFile ? - ".json" /* Json */ : - configFile.options.jsx === 1 /* Preserve */ && (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) || ts.fileExtensionIs(inputFileName, ".jsx" /* Jsx */)) ? - ".jsx" /* Jsx */ : - ".js" /* Js */); + var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), isJsonFile ? ".json" /* Json */ : + configFile.options.jsx === 1 /* Preserve */ && (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) || ts.fileExtensionIs(inputFileName, ".jsx" /* Jsx */)) ? ".jsx" /* Jsx */ : ".js" /* Js */); return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? outputFileName : undefined; @@ -104384,9 +104287,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 295 /* UnparsedText */ ? - "text" /* Text */ : - "internal" /* Internal */); + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 295 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } } // SyntaxKind.UnparsedSyntheticReference @@ -114499,8 +114400,7 @@ var ts; return { relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : - importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : - 2 /* Shortest */, + importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : 2 /* Shortest */, ending: getEnding(), }; function getEnding() { @@ -114508,16 +114408,14 @@ var ts; case "minimal": return 0 /* Minimal */; case "index": return 1 /* Index */; case "js": return 2 /* JsExtension */; - default: return usesJsExtensionOnImports(importingSourceFile) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; + default: return usesJsExtensionOnImports(importingSourceFile) ? 2 /* JsExtension */ : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; } } } function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSFileExtension(oldImportSpecifier) ? - 2 /* JsExtension */ : + ending: ts.hasJSFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } @@ -117580,8 +117478,14 @@ var ts; continue; } var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames()); + if (!outputs.length) + continue; + var inputFileNames = new ts.Set(parsed.fileNames.map(function (f) { return toPath(state, f); })); for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) { var output = outputs_3[_a]; + // If output name is same as input file name, do not delete and ignore the error + if (inputFileNames.has(toPath(state, output))) + continue; if (host.fileExists(output)) { if (filesToDelete) { filesToDelete.push(output); @@ -118997,10 +118901,8 @@ var ts; } function getKindOfVariableDeclaration(v) { return ts.isVarConst(v) - ? "const" /* constElement */ - : ts.isLet(v) - ? "let" /* letElement */ - : "var" /* variableElement */; + ? "const" /* constElement */ : ts.isLet(v) + ? "let" /* letElement */ : "var" /* variableElement */; } } ts.getNodeKind = getNodeKind; @@ -120901,10 +120803,10 @@ var ts; var delta = 0; var lastPos = -1; for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { - var _a = edits_1[_i], fileName = _a.fileName, textChanges_2 = _a.textChanges; + var _a = edits_1[_i], fileName = _a.fileName, textChanges_1 = _a.textChanges; ts.Debug.assert(fileName === renameFilename); - for (var _b = 0, textChanges_1 = textChanges_2; _b < textChanges_1.length; _b++) { - var change = textChanges_1[_b]; + for (var _b = 0, textChanges_2 = textChanges_1; _b < textChanges_2.length; _b++) { + var change = textChanges_2[_b]; var span = change.span, newText = change.newText; var index = indexInTextChange(newText, name); if (index !== -1) { @@ -120970,7 +120872,9 @@ var ts; } /* @internal */ function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ || ts.isObjectLiteralExpression(expression); + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ + || ts.isObjectLiteralExpression(expression) + || ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression); } ts.needsParentheses = needsParentheses; function getContextualTypeFromParent(node, checker) { @@ -123958,8 +123862,7 @@ var ts; var replacementSpan = ts.createTextSpanFromNode(importCompletionNode, sourceFile); var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier); var exportKind = origin.isDefaultExport ? 1 /* Default */ : - origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : - 0 /* Named */; + origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : 0 /* Named */; var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options); var suffix = useSemicolons ? ";" : ""; @@ -124268,7 +124171,7 @@ var ts; } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { - var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* All */, /*useOnlyExternalAliasing*/ false); + var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, 67108863 /* All */, /*useOnlyExternalAliasing*/ false); if (chain) return ts.first(chain); return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); @@ -124855,8 +124758,7 @@ var ts; collectAutoImports(/*resolveModuleSpecifier*/ false); if (isTypeOnly) { keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) - ? 6 /* TypeAssertionKeywords */ - : 7 /* TypeKeywords */; + ? 6 /* TypeAssertionKeywords */ : 7 /* TypeKeywords */; } } function shouldOfferImportCompletions() { @@ -125086,7 +124988,7 @@ var ts; || containingNodeKind === 172 /* IndexSignature */ // [ | : string ] || containingNodeKind === 159 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 139 /* ModuleKeyword */: // module | - case 140 /* NamespaceKeyword */: // namespace | + case 140 /* NamespaceKeyword */: return true; case 24 /* DotToken */: return containingNodeKind === 257 /* ModuleDeclaration */; // module A.| @@ -125316,7 +125218,7 @@ var ts; var parent = contextToken.parent; switch (contextToken.kind) { case 18 /* OpenBraceToken */: // const x = { | - case 27 /* CommaToken */: // const x = { a: 0, | + case 27 /* CommaToken */: if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) { return parent; } @@ -125495,7 +125397,7 @@ var ts; case 118 /* LetKeyword */: case 84 /* ConstKeyword */: case 135 /* InferKeyword */: - case 149 /* TypeKeyword */: // type htm| + case 149 /* TypeKeyword */: return true; case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); @@ -125758,7 +125660,7 @@ var ts; // TODO: GH#18169 return { name: JSON.stringify(name), needsConvertPropertyAccess: false }; case 2 /* PropertyAccess */: - case 1 /* Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. + case 1 /* Global */: // Don't add a completion for a name starting with a space. See https://github.com/Microsoft/TypeScript/pull/20547 return name.charCodeAt(0) === 32 /* space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; case 5 /* None */: @@ -125948,16 +125850,16 @@ var ts; if (!contextToken) return undefined; switch (contextToken.kind) { - case 62 /* EqualsToken */: // class c { public prop = | /* global completions */ } + case 62 /* EqualsToken */: return undefined; case 26 /* SemicolonToken */: // class c {getValue(): number; | } - case 19 /* CloseBraceToken */: // class c { method() { } | } + case 19 /* CloseBraceToken */: // class c { method() { } b| } return isFromObjectTypeDeclaration(location) && location.parent.name === location ? location.parent.parent : ts.tryCast(location, ts.isObjectTypeDeclaration); case 18 /* OpenBraceToken */: // class c { | - case 27 /* CommaToken */: // class c {getValue(): number, | } + case 27 /* CommaToken */: return ts.tryCast(contextToken.parent, ts.isObjectTypeDeclaration); default: if (!isFromObjectTypeDeclaration(contextToken)) { @@ -126744,7 +126646,7 @@ var ts; } } break; - case 78 /* Identifier */: // for 'const x = require("y"); + case 78 /* Identifier */: break; // TODO: GH#23879 case 261 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); @@ -131329,11 +131231,9 @@ var ts; return ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node); } var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? - ts.getAssignmentDeclarationKind(b.node) : - 0 /* None */; + ts.getAssignmentDeclarationKind(b.node) : 0 /* None */; var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? - ts.getAssignmentDeclarationKind(a.node) : - 0 /* None */; + ts.getAssignmentDeclarationKind(a.node) : 0 /* None */; // We treat this as an es5 class and merge the nodes in in one of several cases if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member @@ -132627,8 +132527,7 @@ var ts; return ts.min(a, b, compareMatches); } function compareMatches(a, b) { - return a === undefined ? 1 /* GreaterThan */ : b === undefined ? -1 /* LessThan */ - : ts.compareValues(a.kind, b.kind) || ts.compareBooleans(!a.isCaseSensitive, !b.isCaseSensitive); + return a === undefined ? 1 /* GreaterThan */ : b === undefined ? -1 /* LessThan */ : ts.compareValues(a.kind, b.kind) || ts.compareBooleans(!a.isCaseSensitive, !b.isCaseSensitive); } function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { if (patternSpan === void 0) { patternSpan = { start: 0, length: pattern.length }; } @@ -134645,8 +134544,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 222 /* ClassExpression */) ? - "local class" /* localClassElement */ : "class" /* classElement */; + return ts.getDeclarationOfKind(symbol, 222 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) return "enum" /* enumElement */; @@ -134749,8 +134647,7 @@ var ts; var _a = symbol.declarations, declaration = _a[0], declarations = _a.slice(1); // omit deprecated flag if some declarations are not deprecated var excludeFlags = ts.length(declarations) && isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !isDeprecatedDeclaration(d); }) - ? 8192 /* Deprecated */ - : 0 /* None */; + ? 8192 /* Deprecated */ : 0 /* None */; var modifiers = ts.getNodeModifiers(declaration, excludeFlags); if (modifiers) { return modifiers.split(","); @@ -135631,8 +135528,7 @@ var ts; shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : - shouldRescanJsxAttributeValue(n) ? 6 /* RescanJsxAttributeValue */ : - 0 /* Scan */; + shouldRescanJsxAttributeValue(n) ? 6 /* RescanJsxAttributeValue */ : 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -135813,8 +135709,14 @@ var ts; var binaryKeywordOperators = [100 /* InKeyword */, 101 /* InstanceOfKeyword */, 157 /* OfKeyword */, 126 /* AsKeyword */, 137 /* IsKeyword */]; var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 78 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */ + 8 /* NumericLiteral */, + 9 /* BigIntLiteral */, + 78 /* Identifier */, + 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, + 18 /* OpenBraceToken */, + 107 /* ThisKeyword */, + 102 /* NewKeyword */ ]; var unaryPreincrementExpressions = [78 /* Identifier */, 20 /* OpenParenToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */]; var unaryPostincrementExpressions = [78 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 102 /* NewKeyword */]; @@ -136245,7 +136147,7 @@ var ts; // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 254 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 254 /* InterfaceDeclaration */: return true; } return false; @@ -137135,7 +137037,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); + processChildNode(child, -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -137306,8 +137208,7 @@ var ts; } if (indentToken) { var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? - dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : - -1 /* Unknown */; + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : -1 /* Unknown */; var indentNextTokenOrTrivia = true; if (currentTokenInfo.leadingTrivia) { var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); @@ -139921,6 +139822,7 @@ var ts; ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1.code, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined.code, ts.Diagnostics.Type_0_is_not_an_array_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code, @@ -141102,7 +141004,7 @@ var ts; // do not produce a transformed statement for a null argument break; case 202 /* PropertyAccessExpression */: - case 78 /* Identifier */: // identifier includes undefined + case 78 /* Identifier */: if (!argName) { // undefined was argument passed to promise handler break; @@ -141678,7 +141580,9 @@ var ts; } /** * Convert `import x = require("x").` - * Also converts uses like `x.y()` to `y()` and uses a named import. + * Also: + * - Convert `x.default()` to `x()` to handle ES6 default export + * - Converts uses like `x.y()` to `y()` and uses a named import. */ function convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference) { var nameSymbol = checker.getSymbolAtLocation(name); @@ -141695,14 +141599,21 @@ var ts; } var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { - var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` - var idName = namedBindingsNames.get(propertyName); - if (idName === undefined) { - idName = makeUniqueName(propertyName, identifiers); - namedBindingsNames.set(propertyName, idName); + var propertyName = parent.name.text; + if (propertyName === "default") { + needDefaultImport = true; + var importDefaultName = use.getText(); + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(importDefaultName)); + } + else { + ts.Debug.assert(parent.expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` + var idName = namedBindingsNames.get(propertyName); + if (idName === undefined) { + idName = makeUniqueName(propertyName, identifiers); + namedBindingsNames.set(propertyName, idName); + } + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } - (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } else { needDefaultImport = true; @@ -144896,7 +144807,7 @@ var ts; (function (codefix) { var fixId = "fixMissingCallParentheses"; var errorCodes = [ - ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead.code, ]; codefix.registerCodeFix({ errorCodes: errorCodes, @@ -147824,8 +147735,10 @@ var ts; } if (context.preferences.provideRefactorNotApplicableReason) { return [ - { name: refactorName, description: namespaceToNamedAction.description, actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] }, - { name: refactorName, description: namedToNamespaceAction.description, actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] } + { name: refactorName, description: namespaceToNamedAction.description, + actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] }, + { name: refactorName, description: namedToNamespaceAction.description, + actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] } ]; } return ts.emptyArray; diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 5a6f00d045e..56e1d342d96 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -16,7 +16,7 @@ and limitations under the License. declare namespace ts { const versionMajorMinor = "4.3"; /** The version of the TypeScript compiler release */ - const version = "4.3.0-beta"; + const version: string; /** * Type of objects whose values are all of the same type. * The `in` and `for-in` operators can *not* be safely used, diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 20eddcad977..b192a23a409 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -1847,8 +1847,7 @@ var ts; return a === b ? 0 /* EqualTo */ : a === undefined ? -1 /* LessThan */ : b === undefined ? 1 /* GreaterThan */ : - a < b ? -1 /* LessThan */ : - 1 /* GreaterThan */; + a < b ? -1 /* LessThan */ : 1 /* GreaterThan */; } /** * Compare two numeric values for their order relative to each other. @@ -7851,8 +7850,7 @@ var ts; if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) - ? 1 /* Normal */ - : 0 /* None */); + ? 1 /* Normal */ : 0 /* None */); } if (ts.sys && ts.sys.debugMode) { ts.Debug.isDebugging = true; @@ -7871,7 +7869,7 @@ var ts; Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), - The_parser_expected_to_find_a_to_match_the_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_to_match_the_token_here_1007", "The parser expected to find a '}' to match the '{' token here."), + The_parser_expected_to_find_a_1_to_match_the_0_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_1_to_match_the_0_token_here_1007", "The parser expected to find a '{1}' to match the '{0}' token here."), Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), @@ -8657,7 +8655,7 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), - This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_2774", "This condition will always return true since this function appears to always be defined. Did you mean to call it instead?"), Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), @@ -8684,7 +8682,7 @@ var ts; The_declaration_was_marked_as_deprecated_here: diag(2798, ts.DiagnosticCategory.Error, "The_declaration_was_marked_as_deprecated_here_2798", "The declaration was marked as deprecated here."), Type_produces_a_tuple_type_that_is_too_large_to_represent: diag(2799, ts.DiagnosticCategory.Error, "Type_produces_a_tuple_type_that_is_too_large_to_represent_2799", "Type produces a tuple type that is too large to represent."), Expression_produces_a_tuple_type_that_is_too_large_to_represent: diag(2800, ts.DiagnosticCategory.Error, "Expression_produces_a_tuple_type_that_is_too_large_to_represent_2800", "Expression produces a tuple type that is too large to represent."), - This_condition_will_always_return_true_since_the_Promise_is_always_truthy: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_Promise_is_always_truthy_2801", "This condition will always return true since the Promise is always truthy."), + This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined_2801", "This condition will always return true since this '{0}' appears to always be defined."), Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."), Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."), Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."), @@ -8692,6 +8690,7 @@ var ts; Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."), This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."), A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), + Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "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: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -13168,7 +13167,7 @@ var ts; case 105 /* SuperKeyword */: case 226 /* NonNullExpression */: case 227 /* MetaProperty */: - case 99 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 99 /* ImportKeyword */: return true; default: return false; @@ -16232,8 +16231,7 @@ var ts; case 217 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : - 0 /* None */; + binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; case 215 /* PrefixUnaryExpression */: case 216 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; @@ -18658,8 +18656,7 @@ var ts; if (getCheckFlags(s) & 6 /* Synthetic */) { var checkFlags = s.checkFlags; var accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : - checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : - 16 /* Protected */; + checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : 16 /* Protected */; var staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; return accessModifier | staticModifier; } @@ -19191,8 +19188,7 @@ var ts; } function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || - compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; + compareRelatedInformation(d1, d2) || 0 /* EqualTo */; } ts.compareDiagnostics = compareDiagnostics; function compareDiagnosticsSkipRelatedInformation(d1, d2) { @@ -19200,8 +19196,7 @@ var ts; ts.compareValues(d1.start, d2.start) || ts.compareValues(d1.length, d2.length) || ts.compareValues(d1.code, d2.code) || - compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; + compareMessageText(d1.messageText, d2.messageText) || 0 /* EqualTo */; } ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; function compareRelatedInformation(d1, d2) { @@ -20035,15 +20030,15 @@ var ts; var log2Base; switch (stringValue.charCodeAt(1)) { // "x" in "0x123" case 98 /* b */: - case 66 /* B */: // 0b or 0B + case 66 /* B */: log2Base = 1; break; case 111 /* o */: - case 79 /* O */: // 0o or 0O + case 79 /* O */: log2Base = 3; break; case 120 /* x */: - case 88 /* X */: // 0x or 0X + case 88 /* X */: log2Base = 4; break; default: // already in decimal; omit trailing "n" @@ -21686,8 +21681,7 @@ var ts; case 129 /* AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */; break; case 122 /* PublicKeyword */: case 120 /* PrivateKeyword */: @@ -21706,7 +21700,7 @@ var ts; case 148 /* SymbolKeyword */: case 113 /* VoidKeyword */: case 152 /* UnknownKeyword */: - case 150 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + case 150 /* UndefinedKeyword */: transformFlags = 1 /* ContainsTypeScript */; break; case 123 /* StaticKeyword */: @@ -21819,9 +21813,7 @@ var ts; var node = createBaseNode(159 /* ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 512 /* ContainsES2015 */ | - 65536 /* ContainsComputedPropertyName */; + propagateChildFlags(node.expression) | 512 /* ContainsES2015 */ | 65536 /* ContainsComputedPropertyName */; return node; } // @api @@ -21889,9 +21881,7 @@ var ts; var node = createBaseNode(162 /* Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */ | - 4096 /* ContainsTypeScriptClassSyntax */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */ | 4096 /* ContainsTypeScriptClassSyntax */; return node; } // @api @@ -21928,8 +21918,7 @@ var ts; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | - propagateChildFlags(node.exclamationToken) | - 8388608 /* ContainsClassFields */; + propagateChildFlags(node.exclamationToken) | 8388608 /* ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; } @@ -21976,8 +21965,7 @@ var ts; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | - propagateChildFlags(node.questionToken) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.questionToken) | 512 /* ContainsES2015 */; if (questionToken) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22505,13 +22493,10 @@ var ts; var node = createBaseNode(197 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= - propagateChildrenFlags(node.elements) | - 512 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; + propagateChildrenFlags(node.elements) | 512 /* ContainsES2015 */ | 262144 /* ContainsBindingPattern */; if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { node.transformFlags |= - 64 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + 64 /* ContainsES2018 */ | 32768 /* ContainsObjectRestOrSpread */; } return node; } @@ -22526,9 +22511,7 @@ var ts; var node = createBaseNode(198 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= - propagateChildrenFlags(node.elements) | - 512 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; + propagateChildrenFlags(node.elements) | 512 /* ContainsES2015 */ | 262144 /* ContainsBindingPattern */; return node; } // @api @@ -22545,8 +22528,7 @@ var ts; node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= - propagateChildFlags(node.dotDotDotToken) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.dotDotDotToken) | 512 /* ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : @@ -22615,8 +22597,7 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */; } return node; } @@ -22669,8 +22650,7 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */; } return node; } @@ -22694,8 +22674,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | - propagateChildFlags(node.argumentExpression) | - 16 /* ContainsES2020 */; + propagateChildFlags(node.argumentExpression) | 16 /* ContainsES2020 */; return node; } // @api @@ -22753,8 +22732,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | - propagateChildrenFlags(node.arguments) | - 16 /* ContainsES2020 */; + propagateChildrenFlags(node.arguments) | 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22782,8 +22760,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - propagateChildrenFlags(node.arguments) | - 16 /* ContainsES2020 */; + propagateChildrenFlags(node.arguments) | 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22806,8 +22783,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.template) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.template) | 512 /* ContainsES2015 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22831,8 +22807,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.type) | 1 /* ContainsTypeScript */; return node; } // @api @@ -22896,8 +22871,7 @@ var ts; /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); node.transformFlags |= - propagateChildFlags(node.equalsGreaterThanToken) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.equalsGreaterThanToken) | 512 /* ContainsES2015 */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { node.transformFlags |= 128 /* ContainsES2017 */; } @@ -22958,10 +22932,7 @@ var ts; var node = createBaseExpression(214 /* AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */ | - 1048576 /* ContainsAwait */; + propagateChildFlags(node.expression) | 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */ | 1048576 /* ContainsAwait */; return node; } // @api @@ -23016,15 +22987,12 @@ var ts; else if (operatorKind === 62 /* EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 512 /* ContainsES2015 */ | - 64 /* ContainsES2018 */ | - 2048 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | 64 /* ContainsES2018 */ | 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 512 /* ContainsES2015 */ | - 2048 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } @@ -23100,8 +23068,7 @@ var ts; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | - propagateChildrenFlags(node.templateSpans) | - 512 /* ContainsES2015 */; + propagateChildrenFlags(node.templateSpans) | 512 /* ContainsES2015 */; return node; } // @api @@ -23170,10 +23137,7 @@ var ts; node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.asteriskToken) | - 512 /* ContainsES2015 */ | - 64 /* ContainsES2018 */ | - 524288 /* ContainsYield */; + propagateChildFlags(node.asteriskToken) | 512 /* ContainsES2015 */ | 64 /* ContainsES2018 */ | 524288 /* ContainsYield */; return node; } // @api @@ -23188,9 +23152,7 @@ var ts; var node = createBaseExpression(221 /* SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 512 /* ContainsES2015 */ | - 16384 /* ContainsRestOrSpread */; + propagateChildFlags(node.expression) | 512 /* ContainsES2015 */ | 16384 /* ContainsRestOrSpread */; return node; } // @api @@ -23227,8 +23189,7 @@ var ts; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildrenFlags(node.typeArguments) | - 512 /* ContainsES2015 */; + propagateChildrenFlags(node.typeArguments) | 512 /* ContainsES2015 */; return node; } // @api @@ -23245,8 +23206,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.type) | 1 /* ContainsTypeScript */; return node; } // @api @@ -23261,8 +23221,7 @@ var ts; var node = createBaseExpression(226 /* NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */; return node; } // @api @@ -23280,8 +23239,7 @@ var ts; node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */; return node; } // @api @@ -23325,8 +23283,7 @@ var ts; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.literal) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.literal) | 512 /* ContainsES2015 */; return node; } // @api @@ -23502,8 +23459,7 @@ var ts; propagateChildFlags(node.awaitModifier) | propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | - propagateChildFlags(node.statement) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.statement) | 512 /* ContainsES2015 */; if (awaitModifier) node.transformFlags |= 64 /* ContainsES2018 */; return node; @@ -23522,8 +23478,7 @@ var ts; var node = createBaseNode(241 /* ContinueStatement */); node.label = asName(label); node.transformFlags |= - propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.label) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23537,8 +23492,7 @@ var ts; var node = createBaseNode(242 /* BreakStatement */); node.label = asName(label); node.transformFlags |= - propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.label) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23553,9 +23507,7 @@ var ts; node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= - propagateChildFlags(node.expression) | - 64 /* ContainsES2018 */ | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.expression) | 64 /* ContainsES2018 */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23680,12 +23632,10 @@ var ts; node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= - propagateChildrenFlags(node.declarations) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildrenFlags(node.declarations) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (flags & 3 /* BlockScoped */) { node.transformFlags |= - 512 /* ContainsES2015 */ | - 131072 /* ContainsBlockScopedBinding */; + 512 /* ContainsES2015 */ | 131072 /* ContainsBlockScopedBinding */; } return node; } @@ -23704,8 +23654,7 @@ var ts; } else { node.transformFlags |= - propagateChildFlags(node.asteriskToken) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.asteriskToken) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (node.asteriskToken) { node.transformFlags |= 64 /* ContainsES2018 */; @@ -23798,8 +23747,7 @@ var ts; var node = createBaseNamedDeclaration(256 /* EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= - propagateChildrenFlags(node.members) | - 1 /* ContainsTypeScript */; + propagateChildrenFlags(node.members) | 1 /* ContainsTypeScript */; node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` return node; } @@ -23825,8 +23773,7 @@ var ts; else { node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.body) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.body) | 1 /* ContainsTypeScript */; } node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. return node; @@ -23963,8 +23910,7 @@ var ts; var node = createBaseNode(270 /* NamespaceExport */); node.name = name; node.transformFlags |= - propagateChildFlags(node.name) | - 4 /* ContainsESNext */; + propagateChildFlags(node.name) | 4 /* ContainsESNext */; node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } @@ -24470,8 +24416,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.openingElement) | propagateChildrenFlags(node.children) | - propagateChildFlags(node.closingElement) | - 2 /* ContainsJsx */; + propagateChildFlags(node.closingElement) | 2 /* ContainsJsx */; return node; } // @api @@ -24491,8 +24436,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + propagateChildFlags(node.attributes) | 2 /* ContainsJsx */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -24515,8 +24459,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + propagateChildFlags(node.attributes) | 2 /* ContainsJsx */; if (typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -24535,8 +24478,7 @@ var ts; var node = createBaseNode(277 /* JsxClosingElement */); node.tagName = tagName; node.transformFlags |= - propagateChildFlags(node.tagName) | - 2 /* ContainsJsx */; + propagateChildFlags(node.tagName) | 2 /* ContainsJsx */; return node; } // @api @@ -24554,8 +24496,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.openingFragment) | propagateChildrenFlags(node.children) | - propagateChildFlags(node.closingFragment) | - 2 /* ContainsJsx */; + propagateChildFlags(node.closingFragment) | 2 /* ContainsJsx */; return node; } // @api @@ -24600,8 +24541,7 @@ var ts; node.initializer = initializer; node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.initializer) | - 2 /* ContainsJsx */; + propagateChildFlags(node.initializer) | 2 /* ContainsJsx */; return node; } // @api @@ -24616,8 +24556,7 @@ var ts; var node = createBaseNode(282 /* JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= - propagateChildrenFlags(node.properties) | - 2 /* ContainsJsx */; + propagateChildrenFlags(node.properties) | 2 /* ContainsJsx */; return node; } // @api @@ -24631,8 +24570,7 @@ var ts; var node = createBaseNode(283 /* JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= - propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + propagateChildFlags(node.expression) | 2 /* ContainsJsx */; return node; } // @api @@ -24648,8 +24586,7 @@ var ts; node.expression = expression; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + propagateChildFlags(node.expression) | 2 /* ContainsJsx */; return node; } // @api @@ -24778,8 +24715,7 @@ var ts; /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= - propagateChildFlags(node.objectAssignmentInitializer) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.objectAssignmentInitializer) | 512 /* ContainsES2015 */; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -24808,9 +24744,7 @@ var ts; var node = createBaseNode(291 /* SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 64 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + propagateChildFlags(node.expression) | 64 /* ContainsES2018 */ | 32768 /* ContainsObjectRestOrSpread */; return node; } // @api @@ -24829,8 +24763,7 @@ var ts; node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.initializer) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.initializer) | 1 /* ContainsTypeScript */; return node; } // @api @@ -25006,8 +24939,7 @@ var ts; node.expression = expression; node.original = original; node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */; ts.setTextRange(node, original); return node; } @@ -30135,20 +30067,23 @@ var ts; return inContext(32768 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { - parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); + return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); } function parseErrorAtPosition(start, length, message, arg0) { // Don't report another error if it would just be at the same position as the last error. var lastError = ts.lastOrUndefined(parseDiagnostics); + var result; if (!lastError || start !== lastError.start) { - parseDiagnostics.push(ts.createDetachedDiagnostic(fileName, start, length, message, arg0)); + result = ts.createDetachedDiagnostic(fileName, start, length, message, arg0); + parseDiagnostics.push(result); } // Mark that we've encountered an error. We'll set an appropriate bit on the next // node we finish so that it can't be reused incrementally. parseErrorBeforeNextFinishedNode = true; + return result; } function parseErrorAt(start, end, message, arg0) { - parseErrorAtPosition(start, end - start, message, arg0); + return parseErrorAtPosition(start, end - start, message, arg0); } function parseErrorAtRange(range, message, arg0) { parseErrorAt(range.pos, range.end, message, arg0); @@ -30305,6 +30240,16 @@ var ts; parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); return false; } + function parseExpectedMatchingBrackets(openKind, closeKind, openPosition) { + if (token() === closeKind) { + nextToken(); + return; + } + var lastError = parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(closeKind)); + if (lastError) { + ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openPosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, ts.tokenToString(openKind), ts.tokenToString(closeKind))); + } + } function parseOptional(t) { if (token() === t) { nextToken(); @@ -30593,7 +30538,7 @@ var ts; case 22 /* OpenBracketToken */: case 41 /* AsteriskToken */: case 25 /* DotDotDotToken */: - case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 24 /* DotToken */: return true; default: return isLiteralPropertyName(); @@ -30626,7 +30571,7 @@ var ts; case 15 /* ArrayLiteralMembers */: switch (token()) { case 27 /* CommaToken */: - case 24 /* DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) + case 24 /* DotToken */: return true; } // falls through @@ -30782,8 +30727,7 @@ var ts; var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, /*inErrorRecovery*/ false)) { - var element = parseListElement(kind, parseElement); - list.push(element); + list.push(parseListElement(kind, parseElement)); continue; } if (abortParsingListOrMoveToNextToken(kind)) { @@ -33587,7 +33531,7 @@ var ts; case 50 /* AmpersandToken */: // foo & case 51 /* BarToken */: // foo | case 19 /* CloseBraceToken */: // foo } - case 1 /* EndOfFileToken */: // foo + case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal // expressions either. The user is probably in the middle of a generic type. So // treat it as such. @@ -33671,10 +33615,11 @@ var ts; } function parseArrayLiteralExpression() { var pos = getNodePos(); + var openBracketPosition = scanner.getTokenPos(); parseExpected(22 /* OpenBracketToken */); var multiLine = scanner.hasPrecedingLineBreak(); var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(23 /* CloseBracketToken */); + parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketPosition); return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos); } function parseObjectLiteralElement() { @@ -33734,12 +33679,7 @@ var ts; parseExpected(18 /* OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { - var lastError = ts.lastOrUndefined(parseDiagnostics); - if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { - ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); - } - } + parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } function parseFunctionExpression() { @@ -33812,13 +33752,13 @@ var ts; if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); var statements = parseList(1 /* BlockStatements */, parseStatement); - if (!parseExpected(19 /* CloseBraceToken */)) { - var lastError = ts.lastOrUndefined(parseDiagnostics); - if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { - ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); - } + parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBracePosition); + var result = finishNode(factory.createBlock(statements, multiLine), pos); + if (token() === 62 /* EqualsToken */) { + parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); + nextToken(); } - return finishNode(factory.createBlock(statements, multiLine), pos); + return result; } else { var statements = createMissingList(); @@ -33855,9 +33795,10 @@ var ts; function parseIfStatement() { var pos = getNodePos(); parseExpected(98 /* IfKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); var thenStatement = parseStatement(); var elseStatement = parseOptional(90 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos); @@ -33867,9 +33808,10 @@ var ts; parseExpected(89 /* DoKeyword */); var statement = parseStatement(); parseExpected(114 /* WhileKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby @@ -33880,9 +33822,10 @@ var ts; function parseWhileStatement() { var pos = getNodePos(); parseExpected(114 /* WhileKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); var statement = parseStatement(); return finishNode(factory.createWhileStatement(expression, statement), pos); } @@ -33945,9 +33888,10 @@ var ts; function parseWithStatement() { var pos = getNodePos(); parseExpected(115 /* WithKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); return finishNode(factory.createWithStatement(expression, statement), pos); } @@ -34646,7 +34590,7 @@ var ts; case 53 /* ExclamationToken */: // Non-null assertion on property name case 58 /* ColonToken */: // Type Annotation for declaration case 62 /* EqualsToken */: // Initializer for declaration - case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 57 /* QuestionToken */: return true; default: // Covers @@ -35930,8 +35874,7 @@ var ts; hasChildren = true; if (child.kind === 333 /* JSDocTypeTag */) { if (childTypeTag) { - parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); - var lastError = ts.lastOrUndefined(parseDiagnostics); + var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, 0, 0, ts.Diagnostics.The_tag_was_first_specified_here)); } @@ -35962,7 +35905,7 @@ var ts; comment = parseTrailingTagComments(start, end, indent, indentText); } var typedefTag = factory.createJSDocTypedefTag(tagName, typeExpression, fullName, comment); - return finishNode(typedefTag, start); + return finishNode(typedefTag, start, end); } function parseJSDocTypeNameWithNamespace(nested) { var pos = scanner.getTokenPos(); @@ -43047,8 +42990,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 = prop.kind === 289 /* PropertyAssignment */ || prop.kind === 290 /* ShorthandPropertyAssignment */ || prop.kind === 166 /* MethodDeclaration */ - ? 1 /* Property */ - : 2 /* Accessor */; + ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); if (!existingKind) { seen.set(identifier.escapedText, currentKind); @@ -43569,7 +43511,7 @@ var ts; case 252 /* FunctionDeclaration */: return bindFunctionDeclaration(node); case 167 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); + return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, 0 /* None */); case 168 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); case 169 /* SetAccessor */: @@ -43662,8 +43604,7 @@ var ts; case 337 /* JSDocPropertyTag */: var propTag = node; var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 308 /* JSDocOptionalType */ ? - 4 /* Property */ | 16777216 /* Optional */ : - 4 /* Property */; + 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); case 335 /* JSDocTypedefTag */: case 328 /* JSDocCallbackTag */: @@ -43701,9 +43642,9 @@ var ts; else { var flags = ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; - ? 2097152 /* Alias */ - // An export default clause with any other expression exports a value - : 4 /* Property */; + ? 2097152 /* Alias */ + // An export default clause with any other expression exports a value + : 4 /* Property */; // If there is an `export default x;` alias declaration, can't `export default` anything else. // (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.) var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */); @@ -43812,8 +43753,7 @@ var ts; } // 'module.exports = expr' assignment var flags = ts.exportAssignmentIsAlias(node) - ? 2097152 /* Alias */ - : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; + ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); ts.setValueDeclaration(symbol, node); } @@ -46596,7 +46536,7 @@ var ts; case 254 /* InterfaceDeclaration */: case 256 /* EnumDeclaration */: case 255 /* TypeAliasDeclaration */: - case 257 /* ModuleDeclaration */: // For `namespace N { N; }` + case 257 /* ModuleDeclaration */: return true; default: return false; @@ -50498,8 +50438,7 @@ var ts; // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined - : isConstVariable(symbol) ? 2 /* Const */ - : 1 /* Let */; + : isConstVariable(symbol) ? 2 /* Const */ : 1 /* Let */; var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { @@ -51139,9 +51078,7 @@ var ts; ], 2 /* Const */)); // Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`. // Otherwise, the type itself should be exported. - addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ - : name === varName ? 1 /* Export */ - : 0 /* None */); + addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ : name === varName ? 1 /* Export */ : 0 /* None */); } if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( @@ -56509,8 +56446,7 @@ var ts; return getRestTypeElementFlags(node); case 193 /* NamedTupleMember */: return node.questionToken ? 2 /* Optional */ : - node.dotDotDotToken ? getRestTypeElementFlags(node) : - 1 /* Required */; + node.dotDotDotToken ? getRestTypeElementFlags(node) : 1 /* Required */; default: return 1 /* Required */; } @@ -57087,7 +57023,7 @@ var ts; } function createUnionType(types, aliasSymbol, aliasTypeArguments, origin) { var result = createType(1048576 /* Union */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + result.objectFlags = getPropagatingFlagsOfTypes(types, 98304 /* Nullable */); result.types = types; result.origin = origin; result.aliasSymbol = aliasSymbol; @@ -57275,7 +57211,7 @@ var ts; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { var result = createType(2097152 /* Intersection */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + result.objectFlags = getPropagatingFlagsOfTypes(types, 98304 /* Nullable */); result.types = types; result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; @@ -59262,7 +59198,7 @@ var ts; case 209 /* FunctionExpression */: case 210 /* ArrowFunction */: case 166 /* MethodDeclaration */: - case 252 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 252 /* FunctionDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); case 201 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); @@ -59986,8 +59922,7 @@ var ts; } } var related = source.type === target.type ? -1 /* True */ : - source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : - 0 /* False */; + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : 0 /* False */; if (related === 0 /* False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -61302,6 +61237,11 @@ var ts; } } else if (target.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TemplateLiteral */) { + // Report unreliable variance for type variables referenced in template literal type placeholders. + // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string. + instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + } var result_8 = inferTypesFromTemplateLiteralType(source, target); if (result_8 && ts.every(result_8, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) { return -1 /* True */; @@ -61345,20 +61285,6 @@ var ts; return result; } } - else if (source.flags & 134217728 /* TemplateLiteral */) { - if (target.flags & 134217728 /* TemplateLiteral */ && - source.texts.length === target.texts.length && - source.types.length === target.types.length && - ts.every(source.texts, function (t, i) { return t === target.texts[i]; }) && - ts.every(instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)).types, function (t, i) { return !!(target.types[i].flags & (1 /* Any */ | 4 /* String */)) || !!isRelatedTo(t, target.types[i], /*reportErrors*/ false); })) { - return -1 /* True */; - } - var constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, reportErrors))) { - resetErrorInfo(saveErrorInfo); - return result; - } - } else if (source.flags & 268435456 /* StringMapping */) { if (target.flags & 268435456 /* StringMapping */ && source.symbol === target.symbol) { if (result = isRelatedTo(source.type, target.type, reportErrors)) { @@ -62033,10 +61959,8 @@ var ts; } var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration); var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration); - var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); + var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? 0 /* Call */ : kind); + var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? 0 /* Call */ : kind); if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) { var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* Abstract */); var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* Abstract */); @@ -62712,8 +62636,7 @@ var ts; function compareTypePredicatesIdentical(source, target, compareTypes) { return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : source.type === target.type ? -1 /* True */ : - source.type && target.type ? compareTypes(source.type, target.type) : - 0 /* False */; + source.type && target.type ? compareTypes(source.type, target.type) : 0 /* False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; @@ -62765,7 +62688,12 @@ var ts; function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + return isArrayType(type) || hasArrayOrReadonlyArrayBaseType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + } + function hasArrayOrReadonlyArrayBaseType(type) { + return !!(ts.getObjectFlags(type) & 4 /* Reference */) + && !!(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */) + && ts.some(getBaseTypes(type.target), isArrayType); } function isEmptyArrayLiteralType(type) { var elementType = getElementTypeOfArrayType(type); @@ -64119,9 +64047,7 @@ var ts; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 /* NonInferrableType */ ? - 8 /* PartialHomomorphicMappedType */ : - 4 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 /* NonInferrableType */ ? 8 /* PartialHomomorphicMappedType */ : 4 /* HomomorphicMappedType */); } } return true; @@ -66549,7 +66475,7 @@ var ts; return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); if (target.flags & 111551 /* Value */) { // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled @@ -69542,7 +69468,7 @@ var ts; if (isInPropertyInitializer(node) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !isPropertyDeclaredInAncestorClass(prop)) { + && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } else if (valueDeclaration.kind === 253 /* ClassDeclaration */ && @@ -69916,8 +69842,7 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : - 0 /* None */; + 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : 0 /* None */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, accessFlags | 16 /* ExpressionPosition */) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } @@ -70838,14 +70763,14 @@ var ts; var i_1 = 0; var _loop_22 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; - var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); - if (diags_2) { - if (diags_2.length <= min_3) { - min_3 = diags_2.length; + var diags_3 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); + if (diags_3) { + if (diags_3.length <= min_3) { + min_3 = diags_3.length; minIndex = i_1; } - max = Math.max(max, diags_2.length); - allDiagnostics.push(diags_2); + max = Math.max(max, diags_3.length); + allDiagnostics.push(diags_3); } else { ts.Debug.fail("No error for 3 or fewer overload signatures"); @@ -70856,15 +70781,15 @@ var ts; var c = candidatesForArgumentError_1[_a]; _loop_22(c); } - var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); - ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); - var chain = ts.chainDiagnosticMessages(ts.map(diags_3, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call); + var diags_2 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); + ts.Debug.assert(diags_2.length > 0, "No errors reported for 3 or fewer overload signatures"); + var chain = ts.chainDiagnosticMessages(ts.map(diags_2, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call); // The below is a spread to guarantee we get a new (mutable) array - our `flatMap` helper tries to do "smart" optimizations where it reuses input // arrays and the emptyArray singleton where possible, which is decidedly not what we want while we're still constructing this diagnostic - var related = __spreadArray([], ts.flatMap(diags_3, function (d) { return d.relatedInformation; })); + var related = __spreadArray([], ts.flatMap(diags_2, function (d) { return d.relatedInformation; })); var diag = void 0; - if (ts.every(diags_3, function (d) { return d.start === diags_3[0].start && d.length === diags_3[0].length && d.file === diags_3[0].file; })) { - var _b = diags_3[0], file = _b.file, start = _b.start, length_7 = _b.length; + if (ts.every(diags_2, function (d) { return d.start === diags_2[0].start && d.length === diags_2[0].length && d.file === diags_2[0].file; })) { + var _b = diags_2[0], file = _b.file, start = _b.start, length_7 = _b.length; diag = { file: file, start: start, length: length_7, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related }; } else { @@ -71126,8 +71051,7 @@ var ts; if (ts.isCallChain(node)) { var nonOptionalType = getOptionalExpressionType(funcType, node.expression); callChainFlags = nonOptionalType === funcType ? 0 /* None */ : - ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : - 8 /* IsInnerCallChain */; + ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : 8 /* IsInnerCallChain */; funcType = nonOptionalType; } else { @@ -71904,10 +71828,8 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 252 /* FunctionDeclaration */ - : resolvedRequire.flags & 3 /* Variable */ - ? 250 /* VariableDeclaration */ - : 0 /* Unknown */; + ? 252 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ + ? 250 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient @@ -75552,7 +75474,7 @@ var ts; case 199 /* BindingElement */: case 252 /* FunctionDeclaration */: case 266 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 78 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 78 /* Identifier */: // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` // SyntaxKind.ElementAccessExpression - `thing["aField"] = 42;` or `thing["aField"];` (with a doc comment on it) @@ -76828,12 +76750,7 @@ var ts; if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { return false; } - var interestingFlags = 8 /* Private */ | - 16 /* Protected */ | - 256 /* Async */ | - 128 /* Abstract */ | - 64 /* Readonly */ | - 32 /* Static */; + var interestingFlags = 8 /* Private */ | 16 /* Protected */ | 256 /* Async */ | 128 /* Abstract */ | 64 /* Readonly */ | 32 /* Static */; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { @@ -76875,7 +76792,7 @@ var ts; return; if (getAwaitedTypeOfPromise(type)) { errorAndMaybeSuggestAwait(condExpr, - /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", getTypeNameForErrorDisplay(type), "false"); + /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined, getTypeNameForErrorDisplay(type)); return; } var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr; @@ -76904,7 +76821,7 @@ var ts; var isUsed = ts.isBinaryExpression(condExpr.parent) && isFunctionUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) || body && isFunctionUsedInConditionBody(condExpr, body, testedNode, testedSymbol); if (!isUsed) { - error(location, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead); } } function isFunctionUsedInConditionBody(expr, body, testedNode, testedSymbol) { @@ -78039,6 +77956,7 @@ var ts; switch (name.escapedText) { case "any": case "unknown": + case "never": case "number": case "bigint": case "boolean": @@ -78544,9 +78462,9 @@ var ts; ts.forEach(properties, function (p) { seen.set(p.escapedName, p); }); for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; - var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) { - var prop = properties_4[_a]; + var properties_4 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); + for (var _a = 0, properties_5 = properties_4; _a < properties_5.length; _a++) { + var prop = properties_5[_a]; var existing = seen.get(prop.escapedName); if (existing && !isPropertyIdenticalTo(existing, prop)) { seen.delete(prop.escapedName); @@ -80209,7 +80127,7 @@ var ts; return resolveEntityName(name, meaning, /*ignoreErrors*/ true); } if (name.parent.kind === 173 /* TypePredicate */) { - return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); + return resolveEntityName(name, 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; @@ -80599,7 +80517,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -82982,7 +82900,7 @@ var ts; case 263 /* ImportClause */: // For default import case 261 /* ImportEqualsDeclaration */: case 264 /* NamespaceImport */: - case 266 /* ImportSpecifier */: // For rename import `x as y` + case 266 /* ImportSpecifier */: return true; case 78 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. @@ -88161,9 +88079,7 @@ var ts; } function visitPrefixUnaryExpression(node) { if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { - var operator = node.operator === 45 /* PlusPlusToken */ ? - 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? - 40 /* MinusToken */ : undefined; + var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; var info = void 0; if (operator && (info = accessPrivateIdentifier(node.operand.name))) { var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); @@ -88176,9 +88092,7 @@ var ts; } function visitPostfixUnaryExpression(node, valueIsDiscarded) { if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { - var operator = node.operator === 45 /* PlusPlusToken */ ? - 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? - 40 /* MinusToken */ : undefined; + var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; var info = void 0; if (operator && (info = accessPrivateIdentifier(node.operand.name))) { var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); @@ -89894,9 +89808,7 @@ var ts; return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? - 0 /* StrictModeSourceFileIncludes */ : - 1 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? 0 /* StrictModeSourceFileIncludes */ : 1 /* SourceFileIncludes */); exportedVariableStatement = false; var visited = ts.visitEachChild(node, visitor, context); var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [ @@ -98703,9 +98615,9 @@ var ts; var _a, _b; var result = getImportOrExportBindingReference(node, /*removeEntry*/ true); switch (result === null || result === void 0 ? void 0 : result.kind) { - case 78 /* Identifier */: // tslib import + case 78 /* Identifier */: return factory.createPropertyAccessExpression(result, node); - case 298 /* SourceFile */: // top-level export + case 298 /* SourceFile */: return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); case 263 /* ImportClause */: @@ -100879,13 +100791,7 @@ var ts; }); } ts.isInternalDeclaration = isInternalDeclaration; - var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | - 2048 /* WriteClassExpressionAsTypeLiteral */ | - 4096 /* UseTypeOfFunction */ | - 8 /* UseStructuralFallback */ | - 524288 /* AllowEmptyTuple */ | - 4 /* GenerateNamesForShadowedTypeParams */ | - 1 /* NoTruncation */; + var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | 2048 /* WriteClassExpressionAsTypeLiteral */ | 4096 /* UseTypeOfFunction */ | 8 /* UseStructuralFallback */ | 524288 /* AllowEmptyTuple */ | 4 /* GenerateNamesForShadowedTypeParams */ | 1 /* NoTruncation */; /** * Transforms a ts file into a .d.ts file * This process requires type information, which is retrieved through the emit resolver. Because of this, @@ -101786,7 +101692,7 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 255 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 255 /* TypeAliasDeclaration */: return cleanup(factory.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); case 254 /* InterfaceDeclaration */: { @@ -102874,11 +102780,8 @@ var ts; if (configFile.options.emitDeclarationOnly) return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); - var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), isJsonFile ? - ".json" /* Json */ : - configFile.options.jsx === 1 /* Preserve */ && (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) || ts.fileExtensionIs(inputFileName, ".jsx" /* Jsx */)) ? - ".jsx" /* Jsx */ : - ".js" /* Js */); + var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), isJsonFile ? ".json" /* Json */ : + configFile.options.jsx === 1 /* Preserve */ && (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) || ts.fileExtensionIs(inputFileName, ".jsx" /* Jsx */)) ? ".jsx" /* Jsx */ : ".js" /* Js */); return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? outputFileName : undefined; @@ -104384,9 +104287,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 295 /* UnparsedText */ ? - "text" /* Text */ : - "internal" /* Internal */); + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 295 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } } // SyntaxKind.UnparsedSyntheticReference @@ -114499,8 +114400,7 @@ var ts; return { relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : - importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : - 2 /* Shortest */, + importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : 2 /* Shortest */, ending: getEnding(), }; function getEnding() { @@ -114508,16 +114408,14 @@ var ts; case "minimal": return 0 /* Minimal */; case "index": return 1 /* Index */; case "js": return 2 /* JsExtension */; - default: return usesJsExtensionOnImports(importingSourceFile) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; + default: return usesJsExtensionOnImports(importingSourceFile) ? 2 /* JsExtension */ : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; } } } function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSFileExtension(oldImportSpecifier) ? - 2 /* JsExtension */ : + ending: ts.hasJSFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } @@ -117580,8 +117478,14 @@ var ts; continue; } var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames()); + if (!outputs.length) + continue; + var inputFileNames = new ts.Set(parsed.fileNames.map(function (f) { return toPath(state, f); })); for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) { var output = outputs_3[_a]; + // If output name is same as input file name, do not delete and ignore the error + if (inputFileNames.has(toPath(state, output))) + continue; if (host.fileExists(output)) { if (filesToDelete) { filesToDelete.push(output); @@ -118997,10 +118901,8 @@ var ts; } function getKindOfVariableDeclaration(v) { return ts.isVarConst(v) - ? "const" /* constElement */ - : ts.isLet(v) - ? "let" /* letElement */ - : "var" /* variableElement */; + ? "const" /* constElement */ : ts.isLet(v) + ? "let" /* letElement */ : "var" /* variableElement */; } } ts.getNodeKind = getNodeKind; @@ -120901,10 +120803,10 @@ var ts; var delta = 0; var lastPos = -1; for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { - var _a = edits_1[_i], fileName = _a.fileName, textChanges_2 = _a.textChanges; + var _a = edits_1[_i], fileName = _a.fileName, textChanges_1 = _a.textChanges; ts.Debug.assert(fileName === renameFilename); - for (var _b = 0, textChanges_1 = textChanges_2; _b < textChanges_1.length; _b++) { - var change = textChanges_1[_b]; + for (var _b = 0, textChanges_2 = textChanges_1; _b < textChanges_2.length; _b++) { + var change = textChanges_2[_b]; var span = change.span, newText = change.newText; var index = indexInTextChange(newText, name); if (index !== -1) { @@ -120970,7 +120872,9 @@ var ts; } /* @internal */ function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ || ts.isObjectLiteralExpression(expression); + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ + || ts.isObjectLiteralExpression(expression) + || ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression); } ts.needsParentheses = needsParentheses; function getContextualTypeFromParent(node, checker) { @@ -123958,8 +123862,7 @@ var ts; var replacementSpan = ts.createTextSpanFromNode(importCompletionNode, sourceFile); var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier); var exportKind = origin.isDefaultExport ? 1 /* Default */ : - origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : - 0 /* Named */; + origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : 0 /* Named */; var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options); var suffix = useSemicolons ? ";" : ""; @@ -124268,7 +124171,7 @@ var ts; } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { - var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* All */, /*useOnlyExternalAliasing*/ false); + var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, 67108863 /* All */, /*useOnlyExternalAliasing*/ false); if (chain) return ts.first(chain); return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); @@ -124855,8 +124758,7 @@ var ts; collectAutoImports(/*resolveModuleSpecifier*/ false); if (isTypeOnly) { keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) - ? 6 /* TypeAssertionKeywords */ - : 7 /* TypeKeywords */; + ? 6 /* TypeAssertionKeywords */ : 7 /* TypeKeywords */; } } function shouldOfferImportCompletions() { @@ -125086,7 +124988,7 @@ var ts; || containingNodeKind === 172 /* IndexSignature */ // [ | : string ] || containingNodeKind === 159 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 139 /* ModuleKeyword */: // module | - case 140 /* NamespaceKeyword */: // namespace | + case 140 /* NamespaceKeyword */: return true; case 24 /* DotToken */: return containingNodeKind === 257 /* ModuleDeclaration */; // module A.| @@ -125316,7 +125218,7 @@ var ts; var parent = contextToken.parent; switch (contextToken.kind) { case 18 /* OpenBraceToken */: // const x = { | - case 27 /* CommaToken */: // const x = { a: 0, | + case 27 /* CommaToken */: if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) { return parent; } @@ -125495,7 +125397,7 @@ var ts; case 118 /* LetKeyword */: case 84 /* ConstKeyword */: case 135 /* InferKeyword */: - case 149 /* TypeKeyword */: // type htm| + case 149 /* TypeKeyword */: return true; case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); @@ -125758,7 +125660,7 @@ var ts; // TODO: GH#18169 return { name: JSON.stringify(name), needsConvertPropertyAccess: false }; case 2 /* PropertyAccess */: - case 1 /* Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. + case 1 /* Global */: // Don't add a completion for a name starting with a space. See https://github.com/Microsoft/TypeScript/pull/20547 return name.charCodeAt(0) === 32 /* space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; case 5 /* None */: @@ -125948,16 +125850,16 @@ var ts; if (!contextToken) return undefined; switch (contextToken.kind) { - case 62 /* EqualsToken */: // class c { public prop = | /* global completions */ } + case 62 /* EqualsToken */: return undefined; case 26 /* SemicolonToken */: // class c {getValue(): number; | } - case 19 /* CloseBraceToken */: // class c { method() { } | } + case 19 /* CloseBraceToken */: // class c { method() { } b| } return isFromObjectTypeDeclaration(location) && location.parent.name === location ? location.parent.parent : ts.tryCast(location, ts.isObjectTypeDeclaration); case 18 /* OpenBraceToken */: // class c { | - case 27 /* CommaToken */: // class c {getValue(): number, | } + case 27 /* CommaToken */: return ts.tryCast(contextToken.parent, ts.isObjectTypeDeclaration); default: if (!isFromObjectTypeDeclaration(contextToken)) { @@ -126744,7 +126646,7 @@ var ts; } } break; - case 78 /* Identifier */: // for 'const x = require("y"); + case 78 /* Identifier */: break; // TODO: GH#23879 case 261 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); @@ -131329,11 +131231,9 @@ var ts; return ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node); } var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? - ts.getAssignmentDeclarationKind(b.node) : - 0 /* None */; + ts.getAssignmentDeclarationKind(b.node) : 0 /* None */; var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? - ts.getAssignmentDeclarationKind(a.node) : - 0 /* None */; + ts.getAssignmentDeclarationKind(a.node) : 0 /* None */; // We treat this as an es5 class and merge the nodes in in one of several cases if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member @@ -132627,8 +132527,7 @@ var ts; return ts.min(a, b, compareMatches); } function compareMatches(a, b) { - return a === undefined ? 1 /* GreaterThan */ : b === undefined ? -1 /* LessThan */ - : ts.compareValues(a.kind, b.kind) || ts.compareBooleans(!a.isCaseSensitive, !b.isCaseSensitive); + return a === undefined ? 1 /* GreaterThan */ : b === undefined ? -1 /* LessThan */ : ts.compareValues(a.kind, b.kind) || ts.compareBooleans(!a.isCaseSensitive, !b.isCaseSensitive); } function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { if (patternSpan === void 0) { patternSpan = { start: 0, length: pattern.length }; } @@ -134645,8 +134544,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 222 /* ClassExpression */) ? - "local class" /* localClassElement */ : "class" /* classElement */; + return ts.getDeclarationOfKind(symbol, 222 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) return "enum" /* enumElement */; @@ -134749,8 +134647,7 @@ var ts; var _a = symbol.declarations, declaration = _a[0], declarations = _a.slice(1); // omit deprecated flag if some declarations are not deprecated var excludeFlags = ts.length(declarations) && isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !isDeprecatedDeclaration(d); }) - ? 8192 /* Deprecated */ - : 0 /* None */; + ? 8192 /* Deprecated */ : 0 /* None */; var modifiers = ts.getNodeModifiers(declaration, excludeFlags); if (modifiers) { return modifiers.split(","); @@ -135631,8 +135528,7 @@ var ts; shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : - shouldRescanJsxAttributeValue(n) ? 6 /* RescanJsxAttributeValue */ : - 0 /* Scan */; + shouldRescanJsxAttributeValue(n) ? 6 /* RescanJsxAttributeValue */ : 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -135813,8 +135709,14 @@ var ts; var binaryKeywordOperators = [100 /* InKeyword */, 101 /* InstanceOfKeyword */, 157 /* OfKeyword */, 126 /* AsKeyword */, 137 /* IsKeyword */]; var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 78 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */ + 8 /* NumericLiteral */, + 9 /* BigIntLiteral */, + 78 /* Identifier */, + 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, + 18 /* OpenBraceToken */, + 107 /* ThisKeyword */, + 102 /* NewKeyword */ ]; var unaryPreincrementExpressions = [78 /* Identifier */, 20 /* OpenParenToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */]; var unaryPostincrementExpressions = [78 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 102 /* NewKeyword */]; @@ -136245,7 +136147,7 @@ var ts; // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 254 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 254 /* InterfaceDeclaration */: return true; } return false; @@ -137135,7 +137037,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); + processChildNode(child, -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -137306,8 +137208,7 @@ var ts; } if (indentToken) { var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? - dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : - -1 /* Unknown */; + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : -1 /* Unknown */; var indentNextTokenOrTrivia = true; if (currentTokenInfo.leadingTrivia) { var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); @@ -139921,6 +139822,7 @@ var ts; ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1.code, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined.code, ts.Diagnostics.Type_0_is_not_an_array_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code, @@ -141102,7 +141004,7 @@ var ts; // do not produce a transformed statement for a null argument break; case 202 /* PropertyAccessExpression */: - case 78 /* Identifier */: // identifier includes undefined + case 78 /* Identifier */: if (!argName) { // undefined was argument passed to promise handler break; @@ -141678,7 +141580,9 @@ var ts; } /** * Convert `import x = require("x").` - * Also converts uses like `x.y()` to `y()` and uses a named import. + * Also: + * - Convert `x.default()` to `x()` to handle ES6 default export + * - Converts uses like `x.y()` to `y()` and uses a named import. */ function convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference) { var nameSymbol = checker.getSymbolAtLocation(name); @@ -141695,14 +141599,21 @@ var ts; } var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { - var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` - var idName = namedBindingsNames.get(propertyName); - if (idName === undefined) { - idName = makeUniqueName(propertyName, identifiers); - namedBindingsNames.set(propertyName, idName); + var propertyName = parent.name.text; + if (propertyName === "default") { + needDefaultImport = true; + var importDefaultName = use.getText(); + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(importDefaultName)); + } + else { + ts.Debug.assert(parent.expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` + var idName = namedBindingsNames.get(propertyName); + if (idName === undefined) { + idName = makeUniqueName(propertyName, identifiers); + namedBindingsNames.set(propertyName, idName); + } + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } - (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } else { needDefaultImport = true; @@ -144896,7 +144807,7 @@ var ts; (function (codefix) { var fixId = "fixMissingCallParentheses"; var errorCodes = [ - ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead.code, ]; codefix.registerCodeFix({ errorCodes: errorCodes, @@ -147824,8 +147735,10 @@ var ts; } if (context.preferences.provideRefactorNotApplicableReason) { return [ - { name: refactorName, description: namespaceToNamedAction.description, actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] }, - { name: refactorName, description: namedToNamespaceAction.description, actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] } + { name: refactorName, description: namespaceToNamedAction.description, + actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] }, + { name: refactorName, description: namedToNamespaceAction.description, + actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] } ]; } return ts.emptyArray; diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index b6e1fc9cbdc..1210fe11bb9 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -1642,8 +1642,7 @@ var ts; return a === b ? 0 /* EqualTo */ : a === undefined ? -1 /* LessThan */ : b === undefined ? 1 /* GreaterThan */ : - a < b ? -1 /* LessThan */ : - 1 /* GreaterThan */; + a < b ? -1 /* LessThan */ : 1 /* GreaterThan */; } /** * Compare two numeric values for their order relative to each other. @@ -7646,8 +7645,7 @@ var ts; if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) - ? 1 /* Normal */ - : 0 /* None */); + ? 1 /* Normal */ : 0 /* None */); } if (ts.sys && ts.sys.debugMode) { ts.Debug.isDebugging = true; @@ -7666,7 +7664,7 @@ var ts; Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), - The_parser_expected_to_find_a_to_match_the_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_to_match_the_token_here_1007", "The parser expected to find a '}' to match the '{' token here."), + The_parser_expected_to_find_a_1_to_match_the_0_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_1_to_match_the_0_token_here_1007", "The parser expected to find a '{1}' to match the '{0}' token here."), Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), @@ -8452,7 +8450,7 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), - This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_2774", "This condition will always return true since this function appears to always be defined. Did you mean to call it instead?"), Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), @@ -8479,7 +8477,7 @@ var ts; The_declaration_was_marked_as_deprecated_here: diag(2798, ts.DiagnosticCategory.Error, "The_declaration_was_marked_as_deprecated_here_2798", "The declaration was marked as deprecated here."), Type_produces_a_tuple_type_that_is_too_large_to_represent: diag(2799, ts.DiagnosticCategory.Error, "Type_produces_a_tuple_type_that_is_too_large_to_represent_2799", "Type produces a tuple type that is too large to represent."), Expression_produces_a_tuple_type_that_is_too_large_to_represent: diag(2800, ts.DiagnosticCategory.Error, "Expression_produces_a_tuple_type_that_is_too_large_to_represent_2800", "Expression produces a tuple type that is too large to represent."), - This_condition_will_always_return_true_since_the_Promise_is_always_truthy: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_Promise_is_always_truthy_2801", "This condition will always return true since the Promise is always truthy."), + This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined_2801", "This condition will always return true since this '{0}' appears to always be defined."), Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."), Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."), Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."), @@ -8487,6 +8485,7 @@ var ts; Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."), This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."), A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), + Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "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: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -12963,7 +12962,7 @@ var ts; case 105 /* SuperKeyword */: case 226 /* NonNullExpression */: case 227 /* MetaProperty */: - case 99 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 99 /* ImportKeyword */: return true; default: return false; @@ -16027,8 +16026,7 @@ var ts; case 217 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : - 0 /* None */; + binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; case 215 /* PrefixUnaryExpression */: case 216 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; @@ -18453,8 +18451,7 @@ var ts; if (getCheckFlags(s) & 6 /* Synthetic */) { var checkFlags = s.checkFlags; var accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : - checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : - 16 /* Protected */; + checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : 16 /* Protected */; var staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; return accessModifier | staticModifier; } @@ -18986,8 +18983,7 @@ var ts; } function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || - compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; + compareRelatedInformation(d1, d2) || 0 /* EqualTo */; } ts.compareDiagnostics = compareDiagnostics; function compareDiagnosticsSkipRelatedInformation(d1, d2) { @@ -18995,8 +18991,7 @@ var ts; ts.compareValues(d1.start, d2.start) || ts.compareValues(d1.length, d2.length) || ts.compareValues(d1.code, d2.code) || - compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; + compareMessageText(d1.messageText, d2.messageText) || 0 /* EqualTo */; } ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; function compareRelatedInformation(d1, d2) { @@ -19830,15 +19825,15 @@ var ts; var log2Base; switch (stringValue.charCodeAt(1)) { // "x" in "0x123" case 98 /* b */: - case 66 /* B */: // 0b or 0B + case 66 /* B */: log2Base = 1; break; case 111 /* o */: - case 79 /* O */: // 0o or 0O + case 79 /* O */: log2Base = 3; break; case 120 /* x */: - case 88 /* X */: // 0x or 0X + case 88 /* X */: log2Base = 4; break; default: // already in decimal; omit trailing "n" @@ -21481,8 +21476,7 @@ var ts; case 129 /* AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */; break; case 122 /* PublicKeyword */: case 120 /* PrivateKeyword */: @@ -21501,7 +21495,7 @@ var ts; case 148 /* SymbolKeyword */: case 113 /* VoidKeyword */: case 152 /* UnknownKeyword */: - case 150 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + case 150 /* UndefinedKeyword */: transformFlags = 1 /* ContainsTypeScript */; break; case 123 /* StaticKeyword */: @@ -21614,9 +21608,7 @@ var ts; var node = createBaseNode(159 /* ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 512 /* ContainsES2015 */ | - 65536 /* ContainsComputedPropertyName */; + propagateChildFlags(node.expression) | 512 /* ContainsES2015 */ | 65536 /* ContainsComputedPropertyName */; return node; } // @api @@ -21684,9 +21676,7 @@ var ts; var node = createBaseNode(162 /* Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */ | - 4096 /* ContainsTypeScriptClassSyntax */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */ | 4096 /* ContainsTypeScriptClassSyntax */; return node; } // @api @@ -21723,8 +21713,7 @@ var ts; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | - propagateChildFlags(node.exclamationToken) | - 8388608 /* ContainsClassFields */; + propagateChildFlags(node.exclamationToken) | 8388608 /* ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; } @@ -21771,8 +21760,7 @@ var ts; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | - propagateChildFlags(node.questionToken) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.questionToken) | 512 /* ContainsES2015 */; if (questionToken) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22300,13 +22288,10 @@ var ts; var node = createBaseNode(197 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= - propagateChildrenFlags(node.elements) | - 512 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; + propagateChildrenFlags(node.elements) | 512 /* ContainsES2015 */ | 262144 /* ContainsBindingPattern */; if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { node.transformFlags |= - 64 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + 64 /* ContainsES2018 */ | 32768 /* ContainsObjectRestOrSpread */; } return node; } @@ -22321,9 +22306,7 @@ var ts; var node = createBaseNode(198 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= - propagateChildrenFlags(node.elements) | - 512 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; + propagateChildrenFlags(node.elements) | 512 /* ContainsES2015 */ | 262144 /* ContainsBindingPattern */; return node; } // @api @@ -22340,8 +22323,7 @@ var ts; node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= - propagateChildFlags(node.dotDotDotToken) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.dotDotDotToken) | 512 /* ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : @@ -22410,8 +22392,7 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */; } return node; } @@ -22464,8 +22445,7 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */; } return node; } @@ -22489,8 +22469,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | - propagateChildFlags(node.argumentExpression) | - 16 /* ContainsES2020 */; + propagateChildFlags(node.argumentExpression) | 16 /* ContainsES2020 */; return node; } // @api @@ -22548,8 +22527,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | - propagateChildrenFlags(node.arguments) | - 16 /* ContainsES2020 */; + propagateChildrenFlags(node.arguments) | 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22577,8 +22555,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - propagateChildrenFlags(node.arguments) | - 16 /* ContainsES2020 */; + propagateChildrenFlags(node.arguments) | 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22601,8 +22578,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.template) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.template) | 512 /* ContainsES2015 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22626,8 +22602,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.type) | 1 /* ContainsTypeScript */; return node; } // @api @@ -22691,8 +22666,7 @@ var ts; /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); node.transformFlags |= - propagateChildFlags(node.equalsGreaterThanToken) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.equalsGreaterThanToken) | 512 /* ContainsES2015 */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { node.transformFlags |= 128 /* ContainsES2017 */; } @@ -22753,10 +22727,7 @@ var ts; var node = createBaseExpression(214 /* AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 128 /* ContainsES2017 */ | - 64 /* ContainsES2018 */ | - 1048576 /* ContainsAwait */; + propagateChildFlags(node.expression) | 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */ | 1048576 /* ContainsAwait */; return node; } // @api @@ -22811,15 +22782,12 @@ var ts; else if (operatorKind === 62 /* EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 512 /* ContainsES2015 */ | - 64 /* ContainsES2018 */ | - 2048 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | 64 /* ContainsES2018 */ | 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 512 /* ContainsES2015 */ | - 2048 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } @@ -22895,8 +22863,7 @@ var ts; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | - propagateChildrenFlags(node.templateSpans) | - 512 /* ContainsES2015 */; + propagateChildrenFlags(node.templateSpans) | 512 /* ContainsES2015 */; return node; } // @api @@ -22965,10 +22932,7 @@ var ts; node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.asteriskToken) | - 512 /* ContainsES2015 */ | - 64 /* ContainsES2018 */ | - 524288 /* ContainsYield */; + propagateChildFlags(node.asteriskToken) | 512 /* ContainsES2015 */ | 64 /* ContainsES2018 */ | 524288 /* ContainsYield */; return node; } // @api @@ -22983,9 +22947,7 @@ var ts; var node = createBaseExpression(221 /* SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 512 /* ContainsES2015 */ | - 16384 /* ContainsRestOrSpread */; + propagateChildFlags(node.expression) | 512 /* ContainsES2015 */ | 16384 /* ContainsRestOrSpread */; return node; } // @api @@ -23022,8 +22984,7 @@ var ts; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildrenFlags(node.typeArguments) | - 512 /* ContainsES2015 */; + propagateChildrenFlags(node.typeArguments) | 512 /* ContainsES2015 */; return node; } // @api @@ -23040,8 +23001,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.type) | 1 /* ContainsTypeScript */; return node; } // @api @@ -23056,8 +23016,7 @@ var ts; var node = createBaseExpression(226 /* NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */; return node; } // @api @@ -23075,8 +23034,7 @@ var ts; node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */; return node; } // @api @@ -23120,8 +23078,7 @@ var ts; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | - propagateChildFlags(node.literal) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.literal) | 512 /* ContainsES2015 */; return node; } // @api @@ -23297,8 +23254,7 @@ var ts; propagateChildFlags(node.awaitModifier) | propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | - propagateChildFlags(node.statement) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.statement) | 512 /* ContainsES2015 */; if (awaitModifier) node.transformFlags |= 64 /* ContainsES2018 */; return node; @@ -23317,8 +23273,7 @@ var ts; var node = createBaseNode(241 /* ContinueStatement */); node.label = asName(label); node.transformFlags |= - propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.label) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23332,8 +23287,7 @@ var ts; var node = createBaseNode(242 /* BreakStatement */); node.label = asName(label); node.transformFlags |= - propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.label) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23348,9 +23302,7 @@ var ts; node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= - propagateChildFlags(node.expression) | - 64 /* ContainsES2018 */ | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.expression) | 64 /* ContainsES2018 */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23475,12 +23427,10 @@ var ts; node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= - propagateChildrenFlags(node.declarations) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildrenFlags(node.declarations) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (flags & 3 /* BlockScoped */) { node.transformFlags |= - 512 /* ContainsES2015 */ | - 131072 /* ContainsBlockScopedBinding */; + 512 /* ContainsES2015 */ | 131072 /* ContainsBlockScopedBinding */; } return node; } @@ -23499,8 +23449,7 @@ var ts; } else { node.transformFlags |= - propagateChildFlags(node.asteriskToken) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + propagateChildFlags(node.asteriskToken) | 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (node.asteriskToken) { node.transformFlags |= 64 /* ContainsES2018 */; @@ -23593,8 +23542,7 @@ var ts; var node = createBaseNamedDeclaration(256 /* EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= - propagateChildrenFlags(node.members) | - 1 /* ContainsTypeScript */; + propagateChildrenFlags(node.members) | 1 /* ContainsTypeScript */; node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` return node; } @@ -23620,8 +23568,7 @@ var ts; else { node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.body) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.body) | 1 /* ContainsTypeScript */; } node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. return node; @@ -23758,8 +23705,7 @@ var ts; var node = createBaseNode(270 /* NamespaceExport */); node.name = name; node.transformFlags |= - propagateChildFlags(node.name) | - 4 /* ContainsESNext */; + propagateChildFlags(node.name) | 4 /* ContainsESNext */; node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } @@ -24265,8 +24211,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.openingElement) | propagateChildrenFlags(node.children) | - propagateChildFlags(node.closingElement) | - 2 /* ContainsJsx */; + propagateChildFlags(node.closingElement) | 2 /* ContainsJsx */; return node; } // @api @@ -24286,8 +24231,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + propagateChildFlags(node.attributes) | 2 /* ContainsJsx */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -24310,8 +24254,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | - propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + propagateChildFlags(node.attributes) | 2 /* ContainsJsx */; if (typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -24330,8 +24273,7 @@ var ts; var node = createBaseNode(277 /* JsxClosingElement */); node.tagName = tagName; node.transformFlags |= - propagateChildFlags(node.tagName) | - 2 /* ContainsJsx */; + propagateChildFlags(node.tagName) | 2 /* ContainsJsx */; return node; } // @api @@ -24349,8 +24291,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.openingFragment) | propagateChildrenFlags(node.children) | - propagateChildFlags(node.closingFragment) | - 2 /* ContainsJsx */; + propagateChildFlags(node.closingFragment) | 2 /* ContainsJsx */; return node; } // @api @@ -24395,8 +24336,7 @@ var ts; node.initializer = initializer; node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.initializer) | - 2 /* ContainsJsx */; + propagateChildFlags(node.initializer) | 2 /* ContainsJsx */; return node; } // @api @@ -24411,8 +24351,7 @@ var ts; var node = createBaseNode(282 /* JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= - propagateChildrenFlags(node.properties) | - 2 /* ContainsJsx */; + propagateChildrenFlags(node.properties) | 2 /* ContainsJsx */; return node; } // @api @@ -24426,8 +24365,7 @@ var ts; var node = createBaseNode(283 /* JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= - propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + propagateChildFlags(node.expression) | 2 /* ContainsJsx */; return node; } // @api @@ -24443,8 +24381,7 @@ var ts; node.expression = expression; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + propagateChildFlags(node.expression) | 2 /* ContainsJsx */; return node; } // @api @@ -24573,8 +24510,7 @@ var ts; /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= - propagateChildFlags(node.objectAssignmentInitializer) | - 512 /* ContainsES2015 */; + propagateChildFlags(node.objectAssignmentInitializer) | 512 /* ContainsES2015 */; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -24603,9 +24539,7 @@ var ts; var node = createBaseNode(291 /* SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= - propagateChildFlags(node.expression) | - 64 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + propagateChildFlags(node.expression) | 64 /* ContainsES2018 */ | 32768 /* ContainsObjectRestOrSpread */; return node; } // @api @@ -24624,8 +24558,7 @@ var ts; node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | - propagateChildFlags(node.initializer) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.initializer) | 1 /* ContainsTypeScript */; return node; } // @api @@ -24801,8 +24734,7 @@ var ts; node.expression = expression; node.original = original; node.transformFlags |= - propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */; ts.setTextRange(node, original); return node; } @@ -29930,20 +29862,23 @@ var ts; return inContext(32768 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { - parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); + return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); } function parseErrorAtPosition(start, length, message, arg0) { // Don't report another error if it would just be at the same position as the last error. var lastError = ts.lastOrUndefined(parseDiagnostics); + var result; if (!lastError || start !== lastError.start) { - parseDiagnostics.push(ts.createDetachedDiagnostic(fileName, start, length, message, arg0)); + result = ts.createDetachedDiagnostic(fileName, start, length, message, arg0); + parseDiagnostics.push(result); } // Mark that we've encountered an error. We'll set an appropriate bit on the next // node we finish so that it can't be reused incrementally. parseErrorBeforeNextFinishedNode = true; + return result; } function parseErrorAt(start, end, message, arg0) { - parseErrorAtPosition(start, end - start, message, arg0); + return parseErrorAtPosition(start, end - start, message, arg0); } function parseErrorAtRange(range, message, arg0) { parseErrorAt(range.pos, range.end, message, arg0); @@ -30100,6 +30035,16 @@ var ts; parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); return false; } + function parseExpectedMatchingBrackets(openKind, closeKind, openPosition) { + if (token() === closeKind) { + nextToken(); + return; + } + var lastError = parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(closeKind)); + if (lastError) { + ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openPosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, ts.tokenToString(openKind), ts.tokenToString(closeKind))); + } + } function parseOptional(t) { if (token() === t) { nextToken(); @@ -30388,7 +30333,7 @@ var ts; case 22 /* OpenBracketToken */: case 41 /* AsteriskToken */: case 25 /* DotDotDotToken */: - case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 24 /* DotToken */: return true; default: return isLiteralPropertyName(); @@ -30421,7 +30366,7 @@ var ts; case 15 /* ArrayLiteralMembers */: switch (token()) { case 27 /* CommaToken */: - case 24 /* DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) + case 24 /* DotToken */: return true; } // falls through @@ -30577,8 +30522,7 @@ var ts; var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, /*inErrorRecovery*/ false)) { - var element = parseListElement(kind, parseElement); - list.push(element); + list.push(parseListElement(kind, parseElement)); continue; } if (abortParsingListOrMoveToNextToken(kind)) { @@ -33382,7 +33326,7 @@ var ts; case 50 /* AmpersandToken */: // foo & case 51 /* BarToken */: // foo | case 19 /* CloseBraceToken */: // foo } - case 1 /* EndOfFileToken */: // foo + case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal // expressions either. The user is probably in the middle of a generic type. So // treat it as such. @@ -33466,10 +33410,11 @@ var ts; } function parseArrayLiteralExpression() { var pos = getNodePos(); + var openBracketPosition = scanner.getTokenPos(); parseExpected(22 /* OpenBracketToken */); var multiLine = scanner.hasPrecedingLineBreak(); var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(23 /* CloseBracketToken */); + parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketPosition); return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos); } function parseObjectLiteralElement() { @@ -33529,12 +33474,7 @@ var ts; parseExpected(18 /* OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { - var lastError = ts.lastOrUndefined(parseDiagnostics); - if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { - ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); - } - } + parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } function parseFunctionExpression() { @@ -33607,13 +33547,13 @@ var ts; if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); var statements = parseList(1 /* BlockStatements */, parseStatement); - if (!parseExpected(19 /* CloseBraceToken */)) { - var lastError = ts.lastOrUndefined(parseDiagnostics); - if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { - ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); - } + parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBracePosition); + var result = finishNode(factory.createBlock(statements, multiLine), pos); + if (token() === 62 /* EqualsToken */) { + parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); + nextToken(); } - return finishNode(factory.createBlock(statements, multiLine), pos); + return result; } else { var statements = createMissingList(); @@ -33650,9 +33590,10 @@ var ts; function parseIfStatement() { var pos = getNodePos(); parseExpected(98 /* IfKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); var thenStatement = parseStatement(); var elseStatement = parseOptional(90 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos); @@ -33662,9 +33603,10 @@ var ts; parseExpected(89 /* DoKeyword */); var statement = parseStatement(); parseExpected(114 /* WhileKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby @@ -33675,9 +33617,10 @@ var ts; function parseWhileStatement() { var pos = getNodePos(); parseExpected(114 /* WhileKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); var statement = parseStatement(); return finishNode(factory.createWhileStatement(expression, statement), pos); } @@ -33740,9 +33683,10 @@ var ts; function parseWithStatement() { var pos = getNodePos(); parseExpected(115 /* WithKeyword */); + var openParenPosition = scanner.getTokenPos(); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition); var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); return finishNode(factory.createWithStatement(expression, statement), pos); } @@ -34441,7 +34385,7 @@ var ts; case 53 /* ExclamationToken */: // Non-null assertion on property name case 58 /* ColonToken */: // Type Annotation for declaration case 62 /* EqualsToken */: // Initializer for declaration - case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 57 /* QuestionToken */: return true; default: // Covers @@ -35725,8 +35669,7 @@ var ts; hasChildren = true; if (child.kind === 333 /* JSDocTypeTag */) { if (childTypeTag) { - parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); - var lastError = ts.lastOrUndefined(parseDiagnostics); + var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, 0, 0, ts.Diagnostics.The_tag_was_first_specified_here)); } @@ -35757,7 +35700,7 @@ var ts; comment = parseTrailingTagComments(start, end, indent, indentText); } var typedefTag = factory.createJSDocTypedefTag(tagName, typeExpression, fullName, comment); - return finishNode(typedefTag, start); + return finishNode(typedefTag, start, end); } function parseJSDocTypeNameWithNamespace(nested) { var pos = scanner.getTokenPos(); @@ -42842,8 +42785,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 = prop.kind === 289 /* PropertyAssignment */ || prop.kind === 290 /* ShorthandPropertyAssignment */ || prop.kind === 166 /* MethodDeclaration */ - ? 1 /* Property */ - : 2 /* Accessor */; + ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); if (!existingKind) { seen.set(identifier.escapedText, currentKind); @@ -43364,7 +43306,7 @@ var ts; case 252 /* FunctionDeclaration */: return bindFunctionDeclaration(node); case 167 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); + return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, 0 /* None */); case 168 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); case 169 /* SetAccessor */: @@ -43457,8 +43399,7 @@ var ts; case 337 /* JSDocPropertyTag */: var propTag = node; var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 308 /* JSDocOptionalType */ ? - 4 /* Property */ | 16777216 /* Optional */ : - 4 /* Property */; + 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); case 335 /* JSDocTypedefTag */: case 328 /* JSDocCallbackTag */: @@ -43496,9 +43437,9 @@ var ts; else { var flags = ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; - ? 2097152 /* Alias */ - // An export default clause with any other expression exports a value - : 4 /* Property */; + ? 2097152 /* Alias */ + // An export default clause with any other expression exports a value + : 4 /* Property */; // If there is an `export default x;` alias declaration, can't `export default` anything else. // (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.) var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */); @@ -43607,8 +43548,7 @@ var ts; } // 'module.exports = expr' assignment var flags = ts.exportAssignmentIsAlias(node) - ? 2097152 /* Alias */ - : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; + ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); ts.setValueDeclaration(symbol, node); } @@ -46391,7 +46331,7 @@ var ts; case 254 /* InterfaceDeclaration */: case 256 /* EnumDeclaration */: case 255 /* TypeAliasDeclaration */: - case 257 /* ModuleDeclaration */: // For `namespace N { N; }` + case 257 /* ModuleDeclaration */: return true; default: return false; @@ -50293,8 +50233,7 @@ var ts; // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined - : isConstVariable(symbol) ? 2 /* Const */ - : 1 /* Let */; + : isConstVariable(symbol) ? 2 /* Const */ : 1 /* Let */; var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { @@ -50934,9 +50873,7 @@ var ts; ], 2 /* Const */)); // Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`. // Otherwise, the type itself should be exported. - addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ - : name === varName ? 1 /* Export */ - : 0 /* None */); + addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ : name === varName ? 1 /* Export */ : 0 /* None */); } if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( @@ -56304,8 +56241,7 @@ var ts; return getRestTypeElementFlags(node); case 193 /* NamedTupleMember */: return node.questionToken ? 2 /* Optional */ : - node.dotDotDotToken ? getRestTypeElementFlags(node) : - 1 /* Required */; + node.dotDotDotToken ? getRestTypeElementFlags(node) : 1 /* Required */; default: return 1 /* Required */; } @@ -56882,7 +56818,7 @@ var ts; } function createUnionType(types, aliasSymbol, aliasTypeArguments, origin) { var result = createType(1048576 /* Union */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + result.objectFlags = getPropagatingFlagsOfTypes(types, 98304 /* Nullable */); result.types = types; result.origin = origin; result.aliasSymbol = aliasSymbol; @@ -57070,7 +57006,7 @@ var ts; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { var result = createType(2097152 /* Intersection */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + result.objectFlags = getPropagatingFlagsOfTypes(types, 98304 /* Nullable */); result.types = types; result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; @@ -59057,7 +58993,7 @@ var ts; case 209 /* FunctionExpression */: case 210 /* ArrowFunction */: case 166 /* MethodDeclaration */: - case 252 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 252 /* FunctionDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); case 201 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); @@ -59781,8 +59717,7 @@ var ts; } } var related = source.type === target.type ? -1 /* True */ : - source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : - 0 /* False */; + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : 0 /* False */; if (related === 0 /* False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -61097,6 +61032,11 @@ var ts; } } else if (target.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TemplateLiteral */) { + // Report unreliable variance for type variables referenced in template literal type placeholders. + // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string. + instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + } var result_8 = inferTypesFromTemplateLiteralType(source, target); if (result_8 && ts.every(result_8, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) { return -1 /* True */; @@ -61140,20 +61080,6 @@ var ts; return result; } } - else if (source.flags & 134217728 /* TemplateLiteral */) { - if (target.flags & 134217728 /* TemplateLiteral */ && - source.texts.length === target.texts.length && - source.types.length === target.types.length && - ts.every(source.texts, function (t, i) { return t === target.texts[i]; }) && - ts.every(instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)).types, function (t, i) { return !!(target.types[i].flags & (1 /* Any */ | 4 /* String */)) || !!isRelatedTo(t, target.types[i], /*reportErrors*/ false); })) { - return -1 /* True */; - } - var constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, reportErrors))) { - resetErrorInfo(saveErrorInfo); - return result; - } - } else if (source.flags & 268435456 /* StringMapping */) { if (target.flags & 268435456 /* StringMapping */ && source.symbol === target.symbol) { if (result = isRelatedTo(source.type, target.type, reportErrors)) { @@ -61828,10 +61754,8 @@ var ts; } var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration); var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration); - var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); + var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? 0 /* Call */ : kind); + var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? 0 /* Call */ : kind); if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) { var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* Abstract */); var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* Abstract */); @@ -62507,8 +62431,7 @@ var ts; function compareTypePredicatesIdentical(source, target, compareTypes) { return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : source.type === target.type ? -1 /* True */ : - source.type && target.type ? compareTypes(source.type, target.type) : - 0 /* False */; + source.type && target.type ? compareTypes(source.type, target.type) : 0 /* False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; @@ -62560,7 +62483,12 @@ var ts; function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + return isArrayType(type) || hasArrayOrReadonlyArrayBaseType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + } + function hasArrayOrReadonlyArrayBaseType(type) { + return !!(ts.getObjectFlags(type) & 4 /* Reference */) + && !!(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */) + && ts.some(getBaseTypes(type.target), isArrayType); } function isEmptyArrayLiteralType(type) { var elementType = getElementTypeOfArrayType(type); @@ -63914,9 +63842,7 @@ var ts; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 /* NonInferrableType */ ? - 8 /* PartialHomomorphicMappedType */ : - 4 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 /* NonInferrableType */ ? 8 /* PartialHomomorphicMappedType */ : 4 /* HomomorphicMappedType */); } } return true; @@ -66344,7 +66270,7 @@ var ts; return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); if (target.flags & 111551 /* Value */) { // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled @@ -69337,7 +69263,7 @@ var ts; if (isInPropertyInitializer(node) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !isPropertyDeclaredInAncestorClass(prop)) { + && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } else if (valueDeclaration.kind === 253 /* ClassDeclaration */ && @@ -69711,8 +69637,7 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : - 0 /* None */; + 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : 0 /* None */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, accessFlags | 16 /* ExpressionPosition */) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } @@ -70633,14 +70558,14 @@ var ts; var i_1 = 0; var _loop_22 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; - var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); - if (diags_2) { - if (diags_2.length <= min_3) { - min_3 = diags_2.length; + var diags_3 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); + if (diags_3) { + if (diags_3.length <= min_3) { + min_3 = diags_3.length; minIndex = i_1; } - max = Math.max(max, diags_2.length); - allDiagnostics.push(diags_2); + max = Math.max(max, diags_3.length); + allDiagnostics.push(diags_3); } else { ts.Debug.fail("No error for 3 or fewer overload signatures"); @@ -70651,15 +70576,15 @@ var ts; var c = candidatesForArgumentError_1[_a]; _loop_22(c); } - var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); - ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); - var chain = ts.chainDiagnosticMessages(ts.map(diags_3, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call); + var diags_2 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); + ts.Debug.assert(diags_2.length > 0, "No errors reported for 3 or fewer overload signatures"); + var chain = ts.chainDiagnosticMessages(ts.map(diags_2, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call); // The below is a spread to guarantee we get a new (mutable) array - our `flatMap` helper tries to do "smart" optimizations where it reuses input // arrays and the emptyArray singleton where possible, which is decidedly not what we want while we're still constructing this diagnostic - var related = __spreadArray([], ts.flatMap(diags_3, function (d) { return d.relatedInformation; })); + var related = __spreadArray([], ts.flatMap(diags_2, function (d) { return d.relatedInformation; })); var diag = void 0; - if (ts.every(diags_3, function (d) { return d.start === diags_3[0].start && d.length === diags_3[0].length && d.file === diags_3[0].file; })) { - var _b = diags_3[0], file = _b.file, start = _b.start, length_7 = _b.length; + if (ts.every(diags_2, function (d) { return d.start === diags_2[0].start && d.length === diags_2[0].length && d.file === diags_2[0].file; })) { + var _b = diags_2[0], file = _b.file, start = _b.start, length_7 = _b.length; diag = { file: file, start: start, length: length_7, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related }; } else { @@ -70921,8 +70846,7 @@ var ts; if (ts.isCallChain(node)) { var nonOptionalType = getOptionalExpressionType(funcType, node.expression); callChainFlags = nonOptionalType === funcType ? 0 /* None */ : - ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : - 8 /* IsInnerCallChain */; + ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : 8 /* IsInnerCallChain */; funcType = nonOptionalType; } else { @@ -71699,10 +71623,8 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 252 /* FunctionDeclaration */ - : resolvedRequire.flags & 3 /* Variable */ - ? 250 /* VariableDeclaration */ - : 0 /* Unknown */; + ? 252 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ + ? 250 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient @@ -75347,7 +75269,7 @@ var ts; case 199 /* BindingElement */: case 252 /* FunctionDeclaration */: case 266 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 78 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 78 /* Identifier */: // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` // SyntaxKind.ElementAccessExpression - `thing["aField"] = 42;` or `thing["aField"];` (with a doc comment on it) @@ -76623,12 +76545,7 @@ var ts; if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { return false; } - var interestingFlags = 8 /* Private */ | - 16 /* Protected */ | - 256 /* Async */ | - 128 /* Abstract */ | - 64 /* Readonly */ | - 32 /* Static */; + var interestingFlags = 8 /* Private */ | 16 /* Protected */ | 256 /* Async */ | 128 /* Abstract */ | 64 /* Readonly */ | 32 /* Static */; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { @@ -76670,7 +76587,7 @@ var ts; return; if (getAwaitedTypeOfPromise(type)) { errorAndMaybeSuggestAwait(condExpr, - /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", getTypeNameForErrorDisplay(type), "false"); + /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined, getTypeNameForErrorDisplay(type)); return; } var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr; @@ -76699,7 +76616,7 @@ var ts; var isUsed = ts.isBinaryExpression(condExpr.parent) && isFunctionUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) || body && isFunctionUsedInConditionBody(condExpr, body, testedNode, testedSymbol); if (!isUsed) { - error(location, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead); } } function isFunctionUsedInConditionBody(expr, body, testedNode, testedSymbol) { @@ -77834,6 +77751,7 @@ var ts; switch (name.escapedText) { case "any": case "unknown": + case "never": case "number": case "bigint": case "boolean": @@ -78339,9 +78257,9 @@ var ts; ts.forEach(properties, function (p) { seen.set(p.escapedName, p); }); for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; - var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) { - var prop = properties_4[_a]; + var properties_4 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); + for (var _a = 0, properties_5 = properties_4; _a < properties_5.length; _a++) { + var prop = properties_5[_a]; var existing = seen.get(prop.escapedName); if (existing && !isPropertyIdenticalTo(existing, prop)) { seen.delete(prop.escapedName); @@ -80004,7 +79922,7 @@ var ts; return resolveEntityName(name, meaning, /*ignoreErrors*/ true); } if (name.parent.kind === 173 /* TypePredicate */) { - return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); + return resolveEntityName(name, 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; @@ -80394,7 +80312,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -82777,7 +82695,7 @@ var ts; case 263 /* ImportClause */: // For default import case 261 /* ImportEqualsDeclaration */: case 264 /* NamespaceImport */: - case 266 /* ImportSpecifier */: // For rename import `x as y` + case 266 /* ImportSpecifier */: return true; case 78 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. @@ -87956,9 +87874,7 @@ var ts; } function visitPrefixUnaryExpression(node) { if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { - var operator = node.operator === 45 /* PlusPlusToken */ ? - 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? - 40 /* MinusToken */ : undefined; + var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; var info = void 0; if (operator && (info = accessPrivateIdentifier(node.operand.name))) { var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); @@ -87971,9 +87887,7 @@ var ts; } function visitPostfixUnaryExpression(node, valueIsDiscarded) { if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { - var operator = node.operator === 45 /* PlusPlusToken */ ? - 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? - 40 /* MinusToken */ : undefined; + var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; var info = void 0; if (operator && (info = accessPrivateIdentifier(node.operand.name))) { var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); @@ -89689,9 +89603,7 @@ var ts; return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? - 0 /* StrictModeSourceFileIncludes */ : - 1 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? 0 /* StrictModeSourceFileIncludes */ : 1 /* SourceFileIncludes */); exportedVariableStatement = false; var visited = ts.visitEachChild(node, visitor, context); var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [ @@ -98498,9 +98410,9 @@ var ts; var _a, _b; var result = getImportOrExportBindingReference(node, /*removeEntry*/ true); switch (result === null || result === void 0 ? void 0 : result.kind) { - case 78 /* Identifier */: // tslib import + case 78 /* Identifier */: return factory.createPropertyAccessExpression(result, node); - case 298 /* SourceFile */: // top-level export + case 298 /* SourceFile */: return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); case 263 /* ImportClause */: @@ -100674,13 +100586,7 @@ var ts; }); } ts.isInternalDeclaration = isInternalDeclaration; - var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | - 2048 /* WriteClassExpressionAsTypeLiteral */ | - 4096 /* UseTypeOfFunction */ | - 8 /* UseStructuralFallback */ | - 524288 /* AllowEmptyTuple */ | - 4 /* GenerateNamesForShadowedTypeParams */ | - 1 /* NoTruncation */; + var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | 2048 /* WriteClassExpressionAsTypeLiteral */ | 4096 /* UseTypeOfFunction */ | 8 /* UseStructuralFallback */ | 524288 /* AllowEmptyTuple */ | 4 /* GenerateNamesForShadowedTypeParams */ | 1 /* NoTruncation */; /** * Transforms a ts file into a .d.ts file * This process requires type information, which is retrieved through the emit resolver. Because of this, @@ -101581,7 +101487,7 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 255 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 255 /* TypeAliasDeclaration */: return cleanup(factory.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); case 254 /* InterfaceDeclaration */: { @@ -102669,11 +102575,8 @@ var ts; if (configFile.options.emitDeclarationOnly) return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); - var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), isJsonFile ? - ".json" /* Json */ : - configFile.options.jsx === 1 /* Preserve */ && (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) || ts.fileExtensionIs(inputFileName, ".jsx" /* Jsx */)) ? - ".jsx" /* Jsx */ : - ".js" /* Js */); + var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), isJsonFile ? ".json" /* Json */ : + configFile.options.jsx === 1 /* Preserve */ && (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) || ts.fileExtensionIs(inputFileName, ".jsx" /* Jsx */)) ? ".jsx" /* Jsx */ : ".js" /* Js */); return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? outputFileName : undefined; @@ -104179,9 +104082,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 295 /* UnparsedText */ ? - "text" /* Text */ : - "internal" /* Internal */); + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 295 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } } // SyntaxKind.UnparsedSyntheticReference @@ -114294,8 +114195,7 @@ var ts; return { relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : - importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : - 2 /* Shortest */, + importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : 2 /* Shortest */, ending: getEnding(), }; function getEnding() { @@ -114303,16 +114203,14 @@ var ts; case "minimal": return 0 /* Minimal */; case "index": return 1 /* Index */; case "js": return 2 /* JsExtension */; - default: return usesJsExtensionOnImports(importingSourceFile) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; + default: return usesJsExtensionOnImports(importingSourceFile) ? 2 /* JsExtension */ : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; } } } function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSFileExtension(oldImportSpecifier) ? - 2 /* JsExtension */ : + ending: ts.hasJSFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } @@ -117375,8 +117273,14 @@ var ts; continue; } var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames()); + if (!outputs.length) + continue; + var inputFileNames = new ts.Set(parsed.fileNames.map(function (f) { return toPath(state, f); })); for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) { var output = outputs_3[_a]; + // If output name is same as input file name, do not delete and ignore the error + if (inputFileNames.has(toPath(state, output))) + continue; if (host.fileExists(output)) { if (filesToDelete) { filesToDelete.push(output);