From e2234f64085923c240ff13aa9bdce76a3402673c Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Tue, 31 Oct 2023 17:17:34 +0000 Subject: [PATCH] Update LKG --- lib/lib.es2023.array.d.ts | 22 +- lib/tsc.js | 1886 ++++++++++++++++---------- lib/tsserver.js | 2653 +++++++++++++++++++++--------------- lib/typescript.d.ts | 85 +- lib/typescript.js | 2700 ++++++++++++++++++++++--------------- lib/typingsInstaller.js | 519 ++++--- 6 files changed, 4729 insertions(+), 3136 deletions(-) diff --git a/lib/lib.es2023.array.d.ts b/lib/lib.es2023.array.d.ts index a49dec8e8151e..bd4db2ceb900e 100644 --- a/lib/lib.es2023.array.d.ts +++ b/lib/lib.es2023.array.d.ts @@ -209,7 +209,7 @@ interface Int8Array { * Copies and sorts the array. * @param compareFn Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts * const myNums = Uint8Array.from([11, 2, 22, 1]); * myNums.toSorted((a, b) => a - b) // Uint8Array(4) [1, 2, 11, 22] @@ -273,7 +273,7 @@ interface Uint8Array { * Copies and sorts the array. * @param compareFn Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts * const myNums = Uint8Array.from([11, 2, 22, 1]); * myNums.toSorted((a, b) => a - b) // Uint8Array(4) [1, 2, 11, 22] @@ -345,7 +345,7 @@ interface Uint8ClampedArray { * Copies and sorts the array. * @param compareFn Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts * const myNums = Uint8ClampedArray.from([11, 2, 22, 1]); * myNums.toSorted((a, b) => a - b) // Uint8ClampedArray(4) [1, 2, 11, 22] @@ -409,7 +409,7 @@ interface Int16Array { * Copies and sorts the array. * @param compareFn Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts * const myNums = Int16Array.from([11, 2, -22, 1]); * myNums.toSorted((a, b) => a - b) // Int16Array(4) [-22, 1, 2, 11] @@ -481,7 +481,7 @@ interface Uint16Array { * Copies and sorts the array. * @param compareFn Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts * const myNums = Uint16Array.from([11, 2, 22, 1]); * myNums.toSorted((a, b) => a - b) // Uint16Array(4) [1, 2, 11, 22] @@ -545,7 +545,7 @@ interface Int32Array { * Copies and sorts the array. * @param compareFn Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts * const myNums = Int32Array.from([11, 2, -22, 1]); * myNums.toSorted((a, b) => a - b) // Int32Array(4) [-22, 1, 2, 11] @@ -617,7 +617,7 @@ interface Uint32Array { * Copies and sorts the array. * @param compareFn Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts * const myNums = Uint32Array.from([11, 2, 22, 1]); * myNums.toSorted((a, b) => a - b) // Uint32Array(4) [1, 2, 11, 22] @@ -689,7 +689,7 @@ interface Float32Array { * Copies and sorts the array. * @param compareFn Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts * const myNums = Float32Array.from([11.25, 2, -22.5, 1]); * myNums.toSorted((a, b) => a - b) // Float32Array(4) [-22.5, 1, 2, 11.5] @@ -761,7 +761,7 @@ interface Float64Array { * Copies and sorts the array. * @param compareFn Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts * const myNums = Float64Array.from([11.25, 2, -22.5, 1]); * myNums.toSorted((a, b) => a - b) // Float64Array(4) [-22.5, 1, 2, 11.5] @@ -833,7 +833,7 @@ interface BigInt64Array { * Copies and sorts the array. * @param compareFn Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts * const myNums = BigInt64Array.from([11n, 2n, -22n, 1n]); * myNums.toSorted((a, b) => Number(a - b)) // BigInt64Array(4) [-22n, 1n, 2n, 11n] @@ -905,7 +905,7 @@ interface BigUint64Array { * Copies and sorts the array. * @param compareFn Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * value otherwise. If omitted, the elements are sorted in ascending order. * ```ts * const myNums = BigUint64Array.from([11n, 2n, 22n, 1n]); * myNums.toSorted((a, b) => Number(a - b)) // BigUint64Array(4) [1n, 2n, 11n, 22n] diff --git a/lib/tsc.js b/lib/tsc.js index de544cf91f77d..96906a463c07e 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -3460,32 +3460,43 @@ var NodeFlags = /* @__PURE__ */ ((NodeFlags3) => { })(NodeFlags || {}); var ModifierFlags = /* @__PURE__ */ ((ModifierFlags3) => { ModifierFlags3[ModifierFlags3["None"] = 0] = "None"; - ModifierFlags3[ModifierFlags3["Export"] = 1] = "Export"; - ModifierFlags3[ModifierFlags3["Ambient"] = 2] = "Ambient"; - ModifierFlags3[ModifierFlags3["Public"] = 4] = "Public"; - ModifierFlags3[ModifierFlags3["Private"] = 8] = "Private"; - ModifierFlags3[ModifierFlags3["Protected"] = 16] = "Protected"; - ModifierFlags3[ModifierFlags3["Static"] = 32] = "Static"; - ModifierFlags3[ModifierFlags3["Readonly"] = 64] = "Readonly"; - ModifierFlags3[ModifierFlags3["Accessor"] = 128] = "Accessor"; - ModifierFlags3[ModifierFlags3["Abstract"] = 256] = "Abstract"; - ModifierFlags3[ModifierFlags3["Async"] = 512] = "Async"; - ModifierFlags3[ModifierFlags3["Default"] = 1024] = "Default"; - ModifierFlags3[ModifierFlags3["Const"] = 2048] = "Const"; - ModifierFlags3[ModifierFlags3["HasComputedJSDocModifiers"] = 4096] = "HasComputedJSDocModifiers"; - ModifierFlags3[ModifierFlags3["Deprecated"] = 8192] = "Deprecated"; - ModifierFlags3[ModifierFlags3["Override"] = 16384] = "Override"; - ModifierFlags3[ModifierFlags3["In"] = 32768] = "In"; - ModifierFlags3[ModifierFlags3["Out"] = 65536] = "Out"; - ModifierFlags3[ModifierFlags3["Decorator"] = 131072] = "Decorator"; + ModifierFlags3[ModifierFlags3["Public"] = 1] = "Public"; + ModifierFlags3[ModifierFlags3["Private"] = 2] = "Private"; + ModifierFlags3[ModifierFlags3["Protected"] = 4] = "Protected"; + ModifierFlags3[ModifierFlags3["Readonly"] = 8] = "Readonly"; + ModifierFlags3[ModifierFlags3["Override"] = 16] = "Override"; + ModifierFlags3[ModifierFlags3["Export"] = 32] = "Export"; + ModifierFlags3[ModifierFlags3["Abstract"] = 64] = "Abstract"; + ModifierFlags3[ModifierFlags3["Ambient"] = 128] = "Ambient"; + ModifierFlags3[ModifierFlags3["Static"] = 256] = "Static"; + ModifierFlags3[ModifierFlags3["Accessor"] = 512] = "Accessor"; + ModifierFlags3[ModifierFlags3["Async"] = 1024] = "Async"; + ModifierFlags3[ModifierFlags3["Default"] = 2048] = "Default"; + ModifierFlags3[ModifierFlags3["Const"] = 4096] = "Const"; + ModifierFlags3[ModifierFlags3["In"] = 8192] = "In"; + ModifierFlags3[ModifierFlags3["Out"] = 16384] = "Out"; + ModifierFlags3[ModifierFlags3["Decorator"] = 32768] = "Decorator"; + ModifierFlags3[ModifierFlags3["Deprecated"] = 65536] = "Deprecated"; + ModifierFlags3[ModifierFlags3["JSDocPublic"] = 8388608] = "JSDocPublic"; + ModifierFlags3[ModifierFlags3["JSDocPrivate"] = 16777216] = "JSDocPrivate"; + ModifierFlags3[ModifierFlags3["JSDocProtected"] = 33554432] = "JSDocProtected"; + ModifierFlags3[ModifierFlags3["JSDocReadonly"] = 67108864] = "JSDocReadonly"; + ModifierFlags3[ModifierFlags3["JSDocOverride"] = 134217728] = "JSDocOverride"; + ModifierFlags3[ModifierFlags3["SyntacticOrJSDocModifiers"] = 31] = "SyntacticOrJSDocModifiers"; + ModifierFlags3[ModifierFlags3["SyntacticOnlyModifiers"] = 65504] = "SyntacticOnlyModifiers"; + ModifierFlags3[ModifierFlags3["SyntacticModifiers"] = 65535] = "SyntacticModifiers"; + ModifierFlags3[ModifierFlags3["JSDocCacheOnlyModifiers"] = 260046848] = "JSDocCacheOnlyModifiers"; + ModifierFlags3[ModifierFlags3["JSDocOnlyModifiers"] = 65536 /* Deprecated */] = "JSDocOnlyModifiers"; + ModifierFlags3[ModifierFlags3["NonCacheOnlyModifiers"] = 131071] = "NonCacheOnlyModifiers"; + ModifierFlags3[ModifierFlags3["HasComputedJSDocModifiers"] = 268435456] = "HasComputedJSDocModifiers"; ModifierFlags3[ModifierFlags3["HasComputedFlags"] = 536870912] = "HasComputedFlags"; - ModifierFlags3[ModifierFlags3["AccessibilityModifier"] = 28] = "AccessibilityModifier"; - ModifierFlags3[ModifierFlags3["ParameterPropertyModifier"] = 16476] = "ParameterPropertyModifier"; - ModifierFlags3[ModifierFlags3["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; - ModifierFlags3[ModifierFlags3["TypeScriptModifier"] = 117086] = "TypeScriptModifier"; - ModifierFlags3[ModifierFlags3["ExportDefault"] = 1025] = "ExportDefault"; - ModifierFlags3[ModifierFlags3["All"] = 258047] = "All"; - ModifierFlags3[ModifierFlags3["Modifier"] = 126975] = "Modifier"; + ModifierFlags3[ModifierFlags3["AccessibilityModifier"] = 7] = "AccessibilityModifier"; + ModifierFlags3[ModifierFlags3["ParameterPropertyModifier"] = 31] = "ParameterPropertyModifier"; + ModifierFlags3[ModifierFlags3["NonPublicAccessibilityModifier"] = 6] = "NonPublicAccessibilityModifier"; + ModifierFlags3[ModifierFlags3["TypeScriptModifier"] = 28895] = "TypeScriptModifier"; + ModifierFlags3[ModifierFlags3["ExportDefault"] = 2080] = "ExportDefault"; + ModifierFlags3[ModifierFlags3["All"] = 131071] = "All"; + ModifierFlags3[ModifierFlags3["Modifier"] = 98303] = "Modifier"; return ModifierFlags3; })(ModifierFlags || {}); var RelationComparisonResult = /* @__PURE__ */ ((RelationComparisonResult3) => { @@ -6633,7 +6644,7 @@ var Diagnostics = { Import_assertion_values_must_be_string_literal_expressions: diag(2837, 1 /* Error */, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."), All_declarations_of_0_must_have_identical_constraints: diag(2838, 1 /* Error */, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."), This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, 1 /* Error */, "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839", "This condition will always return '{0}' since JavaScript compares objects by reference, not value."), - An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes: diag(2840, 1 /* Error */, "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840", "An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes"), + An_interface_cannot_extend_a_primitive_type_like_0_It_can_only_extend_other_named_object_types: diag(2840, 1 /* Error */, "An_interface_cannot_extend_a_primitive_type_like_0_It_can_only_extend_other_named_object_types_2840", "An interface cannot extend a primitive type like '{0}'. It can only extend other named object types."), _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, 1 /* Error */, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"), We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, 1 /* Error */, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."), Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, 1 /* Error */, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), @@ -6653,6 +6664,9 @@ var Diagnostics = { Excessive_complexity_comparing_types_0_and_1: diag(2859, 1 /* Error */, "Excessive_complexity_comparing_types_0_and_1_2859", "Excessive complexity comparing types '{0}' and '{1}'."), The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_hand_side_s_Symbol_hasInstance_method: diag(2860, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_2860", "The left-hand side of an 'instanceof' expression must be assignable to the first argument of the right-hand side's '[Symbol.hasInstance]' method."), An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_hand_side_of_an_instanceof_expression: diag(2861, 1 /* Error */, "An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_han_2861", "An object's '[Symbol.hasInstance]' method must return a boolean value for it to be used on the right-hand side of an 'instanceof' expression."), + Type_0_is_generic_and_can_only_be_indexed_for_reading: diag(2862, 1 /* Error */, "Type_0_is_generic_and_can_only_be_indexed_for_reading_2862", "Type '{0}' is generic and can only be indexed for reading."), + A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values: diag(2863, 1 /* Error */, "A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values_2863", "A class cannot extend a primitive type like '{0}'. Classes can only extend constructable values."), + A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types: diag(2864, 1 /* Error */, "A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types_2864", "A class cannot implement a primitive type like '{0}'. It can only implement other named object types."), Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* 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, 1 /* 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, 1 /* 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}'."), @@ -10069,7 +10083,7 @@ function createTextChangeRange(span, newLength) { } var unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); function isParameterPropertyDeclaration(node, parent) { - return isParameter(node) && hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 176 /* Constructor */; + return isParameter(node) && hasSyntacticModifier(node, 31 /* ParameterPropertyModifier */) && parent.kind === 176 /* Constructor */; } function walkUpBindingElementsAndPatterns(binding) { let node = binding.parent; @@ -10344,7 +10358,7 @@ function getDecorators(node) { } } function getModifiers(node) { - if (hasSyntacticModifier(node, 126975 /* Modifier */)) { + if (hasSyntacticModifier(node, 98303 /* Modifier */)) { return filter(node.modifiers, isModifier); } } @@ -10738,7 +10752,7 @@ function isModifierKind(token) { return false; } function isParameterPropertyModifier(kind) { - return !!(modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); + return !!(modifierToFlag(kind) & 31 /* ParameterPropertyModifier */); } function isClassMemberModifier(idToken) { return isParameterPropertyModifier(idToken) || idToken === 126 /* StaticKeyword */ || idToken === 164 /* OverrideKeyword */ || idToken === 129 /* AccessorKeyword */; @@ -11082,10 +11096,10 @@ function hasScopeMarker(statements) { return some(statements, isScopeMarker); } function needsScopeMarker(result) { - return !isAnyImportOrReExport(result) && !isExportAssignment(result) && !hasSyntacticModifier(result, 1 /* Export */) && !isAmbientModule(result); + return !isAnyImportOrReExport(result) && !isExportAssignment(result) && !hasSyntacticModifier(result, 32 /* Export */) && !isAmbientModule(result); } function isExternalModuleIndicator(result) { - return isAnyImportOrReExport(result) || isExportAssignment(result) || hasSyntacticModifier(result, 1 /* Export */); + return isAnyImportOrReExport(result) || isExportAssignment(result) || hasSyntacticModifier(result, 32 /* Export */); } function isForInOrOfStatement(node) { return node.kind === 249 /* ForInStatement */ || node.kind === 250 /* ForOfStatement */; @@ -12272,7 +12286,7 @@ function isEffectiveStrictModeSourceFile(node, compilerOptions) { return false; } function isAmbientPropertyDeclaration(node) { - return !!(node.flags & 33554432 /* Ambient */) || hasSyntacticModifier(node, 2 /* Ambient */); + return !!(node.flags & 33554432 /* Ambient */) || hasSyntacticModifier(node, 128 /* Ambient */); } function isBlockScope(node, parentNode) { switch (node.kind) { @@ -12582,10 +12596,10 @@ function isJsonSourceFile(file) { return file.scriptKind === 6 /* JSON */; } function isEnumConst(node) { - return !!(getCombinedModifierFlags(node) & 2048 /* Const */); + return !!(getCombinedModifierFlags(node) & 4096 /* Const */); } function isDeclarationReadonly(declaration) { - return !!(getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !isParameterPropertyDeclaration(declaration, declaration.parent)); + return !!(getCombinedModifierFlags(declaration) & 8 /* Readonly */ && !isParameterPropertyDeclaration(declaration, declaration.parent)); } function isVarAwaitUsing(node) { return (getCombinedNodeFlags(node) & 7 /* BlockScoped */) === 6 /* AwaitUsing */; @@ -13637,6 +13651,7 @@ function tryGetModuleSpecifierFromDeclaration(node) { true ))) == null ? void 0 : _a.arguments[0]; case 272 /* ImportDeclaration */: + case 278 /* ExportDeclaration */: return tryCast(node.moduleSpecifier, isStringLiteralLike); case 271 /* ImportEqualsDeclaration */: return tryCast((_b = tryCast(node.moduleReference, isExternalModuleReference)) == null ? void 0 : _b.expression, isStringLiteralLike); @@ -13648,6 +13663,8 @@ function tryGetModuleSpecifierFromDeclaration(node) { return tryCast(node.parent.parent.moduleSpecifier, isStringLiteralLike); case 276 /* ImportSpecifier */: return tryCast(node.parent.parent.parent.moduleSpecifier, isStringLiteralLike); + case 205 /* ImportType */: + return isLiteralImportTypeNode(node) ? node.argument.literal : void 0; default: Debug.assertNever(node); } @@ -13875,9 +13892,9 @@ function ownsJSDocTag(hostNode, tag) { } function getNextJSDocCommentLocation(node) { const parent = node.parent; - if (parent.kind === 303 /* PropertyAssignment */ || parent.kind === 277 /* ExportAssignment */ || parent.kind === 172 /* PropertyDeclaration */ || parent.kind === 244 /* ExpressionStatement */ && node.kind === 211 /* PropertyAccessExpression */ || parent.kind === 253 /* ReturnStatement */ || getNestedModuleDeclaration(parent) || isBinaryExpression(node) && node.operatorToken.kind === 64 /* EqualsToken */) { + if (parent.kind === 303 /* PropertyAssignment */ || parent.kind === 277 /* ExportAssignment */ || parent.kind === 172 /* PropertyDeclaration */ || parent.kind === 244 /* ExpressionStatement */ && node.kind === 211 /* PropertyAccessExpression */ || parent.kind === 253 /* ReturnStatement */ || getNestedModuleDeclaration(parent) || isAssignmentExpression(node)) { return parent; - } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || isBinaryExpression(parent) && parent.operatorToken.kind === 64 /* EqualsToken */)) { + } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || isAssignmentExpression(parent))) { return parent.parent; } else if (parent.parent && parent.parent.parent && (getSingleVariableOfVariableStatement(parent.parent.parent) || getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || getSourceOfDefaultedAssignment(parent.parent.parent))) { return parent.parent.parent; @@ -14227,7 +14244,7 @@ function getFunctionFlags(node) { flags |= 1 /* Generator */; } case 219 /* ArrowFunction */: - if (hasSyntacticModifier(node, 512 /* Async */)) { + if (hasSyntacticModifier(node, 1024 /* Async */)) { flags |= 2 /* Async */; } break; @@ -14243,7 +14260,7 @@ function isAsyncFunction(node) { case 218 /* FunctionExpression */: case 219 /* ArrowFunction */: case 174 /* MethodDeclaration */: - return node.body !== void 0 && node.asteriskToken === void 0 && hasSyntacticModifier(node, 512 /* Async */); + return node.body !== void 0 && node.asteriskToken === void 0 && hasSyntacticModifier(node, 1024 /* Async */); } return false; } @@ -14270,6 +14287,7 @@ function getPropertyNameForPropertyNameNode(name) { case 81 /* PrivateIdentifier */: return name.escapedText; case 11 /* StringLiteral */: + case 15 /* NoSubstitutionTemplateLiteral */: case 9 /* NumericLiteral */: return escapeLeadingUnderscores(name.text); case 167 /* ComputedPropertyName */: @@ -15354,25 +15372,25 @@ function isStatic(node) { return isClassElement(node) && hasStaticModifier(node) || isClassStaticBlockDeclaration(node); } function hasStaticModifier(node) { - return hasSyntacticModifier(node, 32 /* Static */); + return hasSyntacticModifier(node, 256 /* Static */); } function hasOverrideModifier(node) { - return hasEffectiveModifier(node, 16384 /* Override */); + return hasEffectiveModifier(node, 16 /* Override */); } function hasAbstractModifier(node) { - return hasSyntacticModifier(node, 256 /* Abstract */); + return hasSyntacticModifier(node, 64 /* Abstract */); } function hasAmbientModifier(node) { - return hasSyntacticModifier(node, 2 /* Ambient */); + return hasSyntacticModifier(node, 128 /* Ambient */); } function hasAccessorModifier(node) { - return hasSyntacticModifier(node, 128 /* Accessor */); + return hasSyntacticModifier(node, 512 /* Accessor */); } function hasEffectiveReadonlyModifier(node) { - return hasEffectiveModifier(node, 64 /* Readonly */); + return hasEffectiveModifier(node, 8 /* Readonly */); } function hasDecorators(node) { - return hasSyntacticModifier(node, 131072 /* Decorator */); + return hasSyntacticModifier(node, 32768 /* Decorator */); } function getSelectedEffectiveModifierFlags(node, flags) { return getEffectiveModifierFlags(node) & flags; @@ -15387,10 +15405,13 @@ function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */; } - if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { - node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* HasComputedJSDocModifiers */; + if (alwaysIncludeJSDoc || includeJSDoc && isInJSFile(node)) { + if (!(node.modifierFlagsCache & 268435456 /* HasComputedJSDocModifiers */) && node.parent) { + node.modifierFlagsCache |= getRawJSDocModifierFlagsNoCache(node) | 268435456 /* HasComputedJSDocModifiers */; + } + return selectEffectiveModifierFlags(node.modifierFlagsCache); } - return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */); + return selectSyntacticModifierFlags(node.modifierFlagsCache); } function getEffectiveModifierFlags(node) { return getModifierFlagsWorker( @@ -15406,33 +15427,42 @@ function getSyntacticModifierFlags(node) { false ); } -function getJSDocModifierFlagsNoCache(node) { +function getRawJSDocModifierFlagsNoCache(node) { let flags = 0 /* None */; if (!!node.parent && !isParameter(node)) { if (isInJSFile(node)) { if (getJSDocPublicTagNoCache(node)) - flags |= 4 /* Public */; + flags |= 8388608 /* JSDocPublic */; if (getJSDocPrivateTagNoCache(node)) - flags |= 8 /* Private */; + flags |= 16777216 /* JSDocPrivate */; if (getJSDocProtectedTagNoCache(node)) - flags |= 16 /* Protected */; + flags |= 33554432 /* JSDocProtected */; if (getJSDocReadonlyTagNoCache(node)) - flags |= 64 /* Readonly */; + flags |= 67108864 /* JSDocReadonly */; if (getJSDocOverrideTagNoCache(node)) - flags |= 16384 /* Override */; + flags |= 134217728 /* JSDocOverride */; } if (getJSDocDeprecatedTagNoCache(node)) - flags |= 8192 /* Deprecated */; + flags |= 65536 /* Deprecated */; } return flags; } +function selectSyntacticModifierFlags(flags) { + return flags & 65535 /* SyntacticModifiers */; +} +function selectEffectiveModifierFlags(flags) { + return flags & 131071 /* NonCacheOnlyModifiers */ | (flags & 260046848 /* JSDocCacheOnlyModifiers */) >>> 23; +} +function getJSDocModifierFlagsNoCache(node) { + return selectEffectiveModifierFlags(getRawJSDocModifierFlagsNoCache(node)); +} function getEffectiveModifierFlagsNoCache(node) { return getSyntacticModifierFlagsNoCache(node) | getJSDocModifierFlagsNoCache(node); } function getSyntacticModifierFlagsNoCache(node) { let flags = canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : 0 /* None */; if (node.flags & 8 /* NestedNamespace */ || node.kind === 80 /* Identifier */ && node.flags & 4096 /* IdentifierIsInJSDocNamespace */) { - flags |= 1 /* Export */; + flags |= 32 /* Export */; } return flags; } @@ -15448,37 +15478,37 @@ function modifiersToFlags(modifiers) { function modifierToFlag(token) { switch (token) { case 126 /* StaticKeyword */: - return 32 /* Static */; + return 256 /* Static */; case 125 /* PublicKeyword */: - return 4 /* Public */; + return 1 /* Public */; case 124 /* ProtectedKeyword */: - return 16 /* Protected */; + return 4 /* Protected */; case 123 /* PrivateKeyword */: - return 8 /* Private */; + return 2 /* Private */; case 128 /* AbstractKeyword */: - return 256 /* Abstract */; + return 64 /* Abstract */; case 129 /* AccessorKeyword */: - return 128 /* Accessor */; + return 512 /* Accessor */; case 95 /* ExportKeyword */: - return 1 /* Export */; + return 32 /* Export */; case 138 /* DeclareKeyword */: - return 2 /* Ambient */; + return 128 /* Ambient */; case 87 /* ConstKeyword */: - return 2048 /* Const */; + return 4096 /* Const */; case 90 /* DefaultKeyword */: - return 1024 /* Default */; + return 2048 /* Default */; case 134 /* AsyncKeyword */: - return 512 /* Async */; + return 1024 /* Async */; case 148 /* ReadonlyKeyword */: - return 64 /* Readonly */; + return 8 /* Readonly */; case 164 /* OverrideKeyword */: - return 16384 /* Override */; + return 16 /* Override */; case 103 /* InKeyword */: - return 32768 /* In */; + return 8192 /* In */; case 147 /* OutKeyword */: - return 65536 /* Out */; + return 16384 /* Out */; case 170 /* Decorator */: - return 131072 /* Decorator */; + return 32768 /* Decorator */; } return 0 /* None */; } @@ -15615,7 +15645,7 @@ function getLocalSymbolForExportDefault(symbol) { return void 0; } function isExportDefaultSymbol(symbol) { - return symbol && length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 1024 /* Default */); + return symbol && length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 2048 /* Default */); } function tryExtractTSExtension(fileName) { return find(supportedTSExtensionsForExtractExtension, (extension) => fileExtensionIs(fileName, extension)); @@ -15834,16 +15864,16 @@ function getDeclarationModifierFlagsFromSymbol(s, isWrite = false) { if (s.valueDeclaration) { const declaration = isWrite && s.declarations && find(s.declarations, isSetAccessorDeclaration) || s.flags & 32768 /* GetAccessor */ && find(s.declarations, isGetAccessorDeclaration) || s.valueDeclaration; const flags = getCombinedModifierFlags(declaration); - return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; + return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~7 /* AccessibilityModifier */; } if (getCheckFlags(s) & 6 /* Synthetic */) { const checkFlags = s.links.checkFlags; - const accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : 16 /* Protected */; - const staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; + const accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 2 /* Private */ : checkFlags & 256 /* ContainsPublic */ ? 1 /* Public */ : 4 /* Protected */; + const staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 256 /* Static */ : 0; return accessModifier | staticModifier; } if (s.flags & 4194304 /* Prototype */) { - return 4 /* Public */ | 32 /* Static */; + return 1 /* Public */ | 256 /* Static */; } return 0; } @@ -17105,7 +17135,7 @@ function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { if (node.kind !== 167 /* ComputedPropertyName */) { return false; } - if (hasSyntacticModifier(node.parent, 256 /* Abstract */)) { + if (hasSyntacticModifier(node.parent, 64 /* Abstract */)) { return true; } const containerKind = node.parent.parent.kind; @@ -18742,8 +18772,9 @@ function createNodeFactory(flags, baseFactory2) { ensureUseStrict, liftToBlock, mergeLexicalEnvironment, - updateModifiers, - updateModifierLike + replaceModifiers, + replaceDecoratorsAndModifiers, + replacePropertyName }; forEach(nodeFactoryPatchers, (fn) => fn(factory2)); return factory2; @@ -19078,35 +19109,35 @@ function createNodeFactory(flags, baseFactory2) { } function createModifiersFromModifierFlags(flags2) { const result = []; - if (flags2 & 1 /* Export */) + if (flags2 & 32 /* Export */) result.push(createModifier(95 /* ExportKeyword */)); - if (flags2 & 2 /* Ambient */) + if (flags2 & 128 /* Ambient */) result.push(createModifier(138 /* DeclareKeyword */)); - if (flags2 & 1024 /* Default */) + if (flags2 & 2048 /* Default */) result.push(createModifier(90 /* DefaultKeyword */)); - if (flags2 & 2048 /* Const */) + if (flags2 & 4096 /* Const */) result.push(createModifier(87 /* ConstKeyword */)); - if (flags2 & 4 /* Public */) + if (flags2 & 1 /* Public */) result.push(createModifier(125 /* PublicKeyword */)); - if (flags2 & 8 /* Private */) + if (flags2 & 2 /* Private */) result.push(createModifier(123 /* PrivateKeyword */)); - if (flags2 & 16 /* Protected */) + if (flags2 & 4 /* Protected */) result.push(createModifier(124 /* ProtectedKeyword */)); - if (flags2 & 256 /* Abstract */) + if (flags2 & 64 /* Abstract */) result.push(createModifier(128 /* AbstractKeyword */)); - if (flags2 & 32 /* Static */) + if (flags2 & 256 /* Static */) result.push(createModifier(126 /* StaticKeyword */)); - if (flags2 & 16384 /* Override */) + if (flags2 & 16 /* Override */) result.push(createModifier(164 /* OverrideKeyword */)); - if (flags2 & 64 /* Readonly */) + if (flags2 & 8 /* Readonly */) result.push(createModifier(148 /* ReadonlyKeyword */)); - if (flags2 & 128 /* Accessor */) + if (flags2 & 512 /* Accessor */) result.push(createModifier(129 /* AccessorKeyword */)); - if (flags2 & 512 /* Async */) + if (flags2 & 1024 /* Async */) result.push(createModifier(134 /* AsyncKeyword */)); - if (flags2 & 32768 /* In */) + if (flags2 & 8192 /* In */) result.push(createModifier(103 /* InKeyword */)); - if (flags2 & 65536 /* Out */) + if (flags2 & 16384 /* Out */) result.push(createModifier(147 /* OutKeyword */)); return result.length ? result : void 0; } @@ -19155,7 +19186,7 @@ function createNodeFactory(flags, baseFactory2) { if (isThisIdentifier(node.name)) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.dotDotDotToken) | propagateNameFlags(node.name) | propagateChildFlags(node.questionToken) | propagateChildFlags(node.initializer) | (node.questionToken ?? node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (node.dotDotDotToken ?? node.initializer ? 1024 /* ContainsES2015 */ : 0 /* None */) | (modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */ ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */); + node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.dotDotDotToken) | propagateNameFlags(node.name) | propagateChildFlags(node.questionToken) | propagateChildFlags(node.initializer) | (node.questionToken ?? node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (node.dotDotDotToken ?? node.initializer ? 1024 /* ContainsES2015 */ : 0 /* None */) | (modifiersToFlags(node.modifiers) & 31 /* ParameterPropertyModifier */ ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */); } node.jsDoc = void 0; return node; @@ -19204,8 +19235,8 @@ function createNodeFactory(flags, baseFactory2) { node.exclamationToken = questionOrExclamationToken && isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : void 0; node.type = type; node.initializer = asInitializer(initializer); - const isAmbient = node.flags & 33554432 /* Ambient */ || modifiersToFlags(node.modifiers) & 2 /* Ambient */; - node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateNameFlags(node.name) | propagateChildFlags(node.initializer) | (isAmbient || node.questionToken || node.exclamationToken || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (isComputedPropertyName(node.name) || modifiersToFlags(node.modifiers) & 32 /* Static */ && node.initializer ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */) | 16777216 /* ContainsClassFields */; + const isAmbient = node.flags & 33554432 /* Ambient */ || modifiersToFlags(node.modifiers) & 128 /* Ambient */; + node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateNameFlags(node.name) | propagateChildFlags(node.initializer) | (isAmbient || node.questionToken || node.exclamationToken || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (isComputedPropertyName(node.name) || modifiersToFlags(node.modifiers) & 256 /* Static */ && node.initializer ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */) | 16777216 /* ContainsClassFields */; node.jsDoc = void 0; return node; } @@ -19244,7 +19275,7 @@ function createNodeFactory(flags, baseFactory2) { if (!node.body) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - const isAsync = modifiersToFlags(node.modifiers) & 512 /* Async */; + const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */; const isGenerator = !!node.asteriskToken; const isAsyncGenerator = isAsync && isGenerator; node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.asteriskToken) | propagateNameFlags(node.name) | propagateChildFlags(node.questionToken) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (isAsyncGenerator ? 128 /* ContainsES2018 */ : isAsync ? 256 /* ContainsES2017 */ : isGenerator ? 2048 /* ContainsGenerator */ : 0 /* None */) | (node.questionToken || node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | 1024 /* ContainsES2015 */; @@ -19987,7 +20018,7 @@ function createNodeFactory(flags, baseFactory2) { node.parameters = createNodeArray(parameters); node.type = type; node.body = body; - const isAsync = modifiersToFlags(node.modifiers) & 512 /* Async */; + const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */; const isGenerator = !!node.asteriskToken; const isAsyncGenerator = isAsync && isGenerator; node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.asteriskToken) | propagateNameFlags(node.name) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (isAsyncGenerator ? 128 /* ContainsES2018 */ : isAsync ? 256 /* ContainsES2017 */ : isGenerator ? 2048 /* ContainsGenerator */ : 0 /* None */) | (node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | 4194304 /* ContainsHoistedDeclarationOrCompletion */; @@ -20011,7 +20042,7 @@ function createNodeFactory(flags, baseFactory2) { node.type = type; node.equalsGreaterThanToken = equalsGreaterThanToken ?? createToken(39 /* EqualsGreaterThanToken */); node.body = parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body); - const isAsync = modifiersToFlags(node.modifiers) & 512 /* Async */; + const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */; node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.equalsGreaterThanToken) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (isAsync ? 256 /* ContainsES2017 */ | 16384 /* ContainsLexicalThis */ : 0 /* None */) | 1024 /* ContainsES2015 */; node.typeArguments = void 0; node.jsDoc = void 0; @@ -20363,7 +20394,7 @@ function createNodeFactory(flags, baseFactory2) { node.modifiers = asNodeArray(modifiers); node.declarationList = isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.declarationList); - if (modifiersToFlags(node.modifiers) & 2 /* Ambient */) { + if (modifiersToFlags(node.modifiers) & 128 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } node.jsDoc = void 0; @@ -20613,10 +20644,10 @@ function createNodeFactory(flags, baseFactory2) { node.parameters = createNodeArray(parameters); node.type = type; node.body = body; - if (!node.body || modifiersToFlags(node.modifiers) & 2 /* Ambient */) { + if (!node.body || modifiersToFlags(node.modifiers) & 128 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - const isAsync = modifiersToFlags(node.modifiers) & 512 /* Async */; + const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */; const isGenerator = !!node.asteriskToken; const isAsyncGenerator = isAsync && isGenerator; node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.asteriskToken) | propagateNameFlags(node.name) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (isAsyncGenerator ? 128 /* ContainsES2018 */ : isAsync ? 256 /* ContainsES2017 */ : isGenerator ? 2048 /* ContainsGenerator */ : 0 /* None */) | (node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | 4194304 /* ContainsHoistedDeclarationOrCompletion */; @@ -20647,7 +20678,7 @@ function createNodeFactory(flags, baseFactory2) { node.typeParameters = asNodeArray(typeParameters); node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); - if (modifiersToFlags(node.modifiers) & 2 /* Ambient */) { + if (modifiersToFlags(node.modifiers) & 128 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateNameFlags(node.name) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.heritageClauses) | propagateChildrenFlags(node.members) | (node.typeParameters ? 1 /* ContainsTypeScript */ : 0 /* None */) | 1024 /* ContainsES2015 */; @@ -20709,7 +20740,7 @@ function createNodeFactory(flags, baseFactory2) { node.flags |= flags2 & (32 /* Namespace */ | 8 /* NestedNamespace */ | 2048 /* GlobalAugmentation */); node.name = name; node.body = body; - if (modifiersToFlags(node.modifiers) & 2 /* Ambient */) { + if (modifiersToFlags(node.modifiers) & 128 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.name) | propagateChildFlags(node.body) | 1 /* ContainsTypeScript */; @@ -22140,7 +22171,7 @@ function createNodeFactory(flags, baseFactory2) { return qualifiedName; } function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && hasSyntacticModifier(node, 1 /* Export */)) { + if (ns && hasSyntacticModifier(node, 32 /* Export */)) { return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); } return getExportName(node, allowComments, allowSourceMaps); @@ -22251,7 +22282,7 @@ function createNodeFactory(flags, baseFactory2) { } return statements; } - function updateModifiers(node, modifiers) { + function replaceModifiers(node, modifiers) { let modifierArray; if (typeof modifiers === "number") { modifierArray = createModifiersFromModifierFlags(modifiers); @@ -22260,9 +22291,27 @@ function createNodeFactory(flags, baseFactory2) { } return isTypeParameterDeclaration(node) ? updateTypeParameterDeclaration(node, modifierArray, node.name, node.constraint, node.default) : isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isConstructorTypeNode(node) ? updateConstructorTypeNode1(node, modifierArray, node.typeParameters, node.parameters, node.type) : isPropertySignature(node) ? updatePropertySignature(node, modifierArray, node.name, node.questionToken, node.type) : isPropertyDeclaration(node) ? updatePropertyDeclaration(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : isMethodSignature(node) ? updateMethodSignature(node, modifierArray, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) : isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : isConstructorDeclaration(node) ? updateConstructorDeclaration(node, modifierArray, node.parameters, node.body) : isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) : isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.body) : isIndexSignatureDeclaration(node) ? updateIndexSignature(node, modifierArray, node.parameters, node.type) : isFunctionExpression(node) ? updateFunctionExpression(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : isArrowFunction(node) ? updateArrowFunction(node, modifierArray, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) : isClassExpression(node) ? updateClassExpression(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isVariableStatement(node) ? updateVariableStatement(node, modifierArray, node.declarationList) : isFunctionDeclaration(node) ? updateFunctionDeclaration(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : isClassDeclaration(node) ? updateClassDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, modifierArray, node.name, node.typeParameters, node.type) : isEnumDeclaration(node) ? updateEnumDeclaration(node, modifierArray, node.name, node.members) : isModuleDeclaration(node) ? updateModuleDeclaration(node, modifierArray, node.name, node.body) : isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, modifierArray, node.isTypeOnly, node.name, node.moduleReference) : isImportDeclaration(node) ? updateImportDeclaration(node, modifierArray, node.importClause, node.moduleSpecifier, node.attributes) : isExportAssignment(node) ? updateExportAssignment(node, modifierArray, node.expression) : isExportDeclaration(node) ? updateExportDeclaration(node, modifierArray, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.attributes) : Debug.assertNever(node); } - function updateModifierLike(node, modifierArray) { + function replaceDecoratorsAndModifiers(node, modifierArray) { return isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isPropertyDeclaration(node) ? updatePropertyDeclaration(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) : isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.body) : isClassExpression(node) ? updateClassExpression(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isClassDeclaration(node) ? updateClassDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : Debug.assertNever(node); } + function replacePropertyName(node, name) { + switch (node.kind) { + case 177 /* GetAccessor */: + return updateGetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.type, node.body); + case 178 /* SetAccessor */: + return updateSetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.body); + case 174 /* MethodDeclaration */: + return updateMethodDeclaration(node, node.modifiers, node.asteriskToken, name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body); + case 173 /* MethodSignature */: + return updateMethodSignature(node, node.modifiers, name, node.questionToken, node.typeParameters, node.parameters, node.type); + case 172 /* PropertyDeclaration */: + return updatePropertyDeclaration(node, node.modifiers, name, node.questionToken ?? node.exclamationToken, node.type, node.initializer); + case 171 /* PropertySignature */: + return updatePropertySignature(node, node.modifiers, name, node.questionToken, node.type); + case 303 /* PropertyAssignment */: + return updatePropertyAssignment(node, name, node.initializer); + } + } function asNodeArray(array) { return array ? createNodeArray(array) : void 0; } @@ -23689,17 +23738,18 @@ var asyncGeneratorHelper = { scoped: false, dependencies: [awaitHelper], text: ` - var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; - function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } - function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } - function fulfill(value) { resume("next", value); } - function reject(value) { resume("throw", value); } - function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } - };` + var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i; + function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; } + function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } + };` }; var asyncDelegator = { name: "typescript:asyncDelegator", @@ -31322,11 +31372,11 @@ var Parser; const modifierFlags = modifiersToFlags(modifiers); parseExpected(100 /* FunctionKeyword */); const asteriskToken = parseOptionalToken(42 /* AsteriskToken */); - const name = modifierFlags & 1024 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); + const name = modifierFlags & 2048 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); const isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - const isAsync = modifierFlags & 512 /* Async */ ? 2 /* Await */ : 0 /* None */; + const isAsync = modifierFlags & 1024 /* Async */ ? 2 /* Await */ : 0 /* None */; const typeParameters = parseTypeParameters(); - if (modifierFlags & 1 /* Export */) + if (modifierFlags & 32 /* Export */) setAwaitContext( /*value*/ true @@ -34839,7 +34889,7 @@ var commandOptionsWithoutBuild = [ affectsBuildInfo: true, affectsDeclarationPath: true, isFilePath: false, - // This is intentionally broken to support compatability with existing tsconfig files + // This is intentionally broken to support compatibility with existing tsconfig files // for correct behaviour, please use outFile category: Diagnostics.Backwards_Compatibility, paramType: Diagnostics.FILE, @@ -36900,7 +36950,7 @@ function resolvedTypeScriptOnly(resolved) { Debug.assert(extensionIsTS(resolved.extension)); return { fileName: resolved.path, packageId: resolved.packageId }; } -function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state, legacyResult) { +function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state, cache, legacyResult) { if (!state.resultFromCache && !state.compilerOptions.preserveSymlinks && resolved && isExternalLibraryImport && !resolved.originalPath && !isExternalModuleNameRelative(moduleName)) { const { resolvedFileName, originalPath } = getOriginalAndResolvedFileName(resolved.path, state.host, state.traceEnabled); if (originalPath) @@ -36913,15 +36963,25 @@ function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName affectingLocations, diagnostics, state.resultFromCache, + cache, legacyResult ); } -function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, legacyResult) { +function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, cache, legacyResult) { if (resultFromCache) { - resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations); - resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations); - resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics); - return resultFromCache; + if (!(cache == null ? void 0 : cache.isReadonly)) { + resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations); + resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations); + resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics); + return resultFromCache; + } else { + return { + ...resultFromCache, + failedLookupLocations: initializeResolutionFieldForReadonlyCache(resultFromCache.failedLookupLocations, failedLookupLocations), + affectingLocations: initializeResolutionFieldForReadonlyCache(resultFromCache.affectingLocations, affectingLocations), + resolutionDiagnostics: initializeResolutionFieldForReadonlyCache(resultFromCache.resolutionDiagnostics, diagnostics) + }; + } } return { resolvedModule: resolved && { @@ -36949,6 +37009,13 @@ function updateResolutionField(to, value) { to.push(...value); return to; } +function initializeResolutionFieldForReadonlyCache(fromCache, value) { + if (!(fromCache == null ? void 0 : fromCache.length)) + return initializeResolutionField(value); + if (!value.length) + return fromCache.slice(); + return [...fromCache, ...value]; +} function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) { if (!hasProperty(jsonContent, fieldName)) { if (state.traceEnabled) { @@ -37133,8 +37200,7 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil if (resolutionMode === 99 /* ESNext */ && (3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */)) { features |= 32 /* EsmMode */; } - const useImportCondition = resolutionMode === 99 /* ESNext */ || (resolutionMode !== void 0 ? false : void 0); - const conditions = features & 8 /* Exports */ ? getConditions(options, useImportCondition) : []; + const conditions = features & 8 /* Exports */ ? getConditions(options, resolutionMode) : []; const diagnostics = []; const moduleResolutionState = { compilerOptions: options, @@ -37176,15 +37242,15 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil affectingLocations: initializeResolutionField(affectingLocations), resolutionDiagnostics: initializeResolutionField(diagnostics) }; - if (containingDirectory) { - cache == null ? void 0 : cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set( + if (containingDirectory && cache && !cache.isReadonly) { + cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set( typeReferenceDirectiveName, /*mode*/ resolutionMode, result ); if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) { - cache == null ? void 0 : cache.getOrCreateCacheForNonRelativeName(typeReferenceDirectiveName, resolutionMode, redirectedReference).set(containingDirectory, result); + cache.getOrCreateCacheForNonRelativeName(typeReferenceDirectiveName, resolutionMode, redirectedReference).set(containingDirectory, result); } } if (traceEnabled) @@ -37302,16 +37368,16 @@ function getNodeResolutionFeatures(options) { } return features; } -function getConditions(options, esmMode) { +function getConditions(options, resolutionMode) { const moduleResolution = getEmitModuleResolutionKind(options); - if (esmMode === void 0) { + if (resolutionMode === void 0) { if (moduleResolution === 100 /* Bundler */) { - esmMode ?? (esmMode = moduleResolution === 100 /* Bundler */); + resolutionMode = 99 /* ESNext */; } else if (moduleResolution === 2 /* Node10 */) { return []; } } - const conditions = esmMode ? ["import"] : ["require"]; + const conditions = resolutionMode === 99 /* ESNext */ ? ["import"] : ["require"]; if (!options.noDtsResolution) { conditions.push("types"); } @@ -37376,7 +37442,8 @@ function createCacheWithRedirects(ownOptions, optionsToRedirectsKey) { getMapOfCacheRedirects, getOrCreateMapOfCacheRedirects, update, - clear: clear2 + clear: clear2, + getOwnMap: () => ownMap }; function getMapOfCacheRedirects(redirectedReference) { return redirectedReference ? getOrCreateMap( @@ -37483,7 +37550,8 @@ function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileNam getFromDirectoryCache, getOrCreateCacheForDirectory, clear: clear2, - update + update, + directoryToModuleNameMap }; function clear2() { directoryToModuleNameMap.clear(); @@ -37733,13 +37801,13 @@ function resolveModuleName(moduleName, containingFile, compilerOptions, host, ca result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); break; case 2 /* Node10 */: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode === 99 /* ESNext */) : void 0); + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode) : void 0); break; case 1 /* Classic */: result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; case 100 /* Bundler */: - result = bundlerModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode === 99 /* ESNext */) : void 0); + result = bundlerModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode) : void 0); break; default: return Debug.fail(`Unexpected moduleResolution: ${moduleResolution}`); @@ -37747,9 +37815,11 @@ function resolveModuleName(moduleName, containingFile, compilerOptions, host, ca if (result && result.resolvedModule) (_b = perfLogger) == null ? void 0 : _b.logInfoEvent(`Module "${moduleName}" resolved to "${result.resolvedModule.resolvedFileName}"`); (_c = perfLogger) == null ? void 0 : _c.logStopResolveModule(result && result.resolvedModule ? "" + result.resolvedModule.resolvedFileName : "null"); - cache == null ? void 0 : cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result); - if (!isExternalModuleNameRelative(moduleName)) { - cache == null ? void 0 : cache.getOrCreateCacheForNonRelativeName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result); + if (cache && !cache.isReadonly) { + cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result); + if (!isExternalModuleNameRelative(moduleName)) { + cache.getOrCreateCacheForNonRelativeName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result); + } } } if (traceEnabled) { @@ -38002,7 +38072,7 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, const moduleResolution = getEmitModuleResolutionKind(compilerOptions); conditions ?? (conditions = getConditions( compilerOptions, - moduleResolution === 100 /* Bundler */ || moduleResolution === 2 /* Node10 */ ? void 0 : !!(features & 32 /* EsmMode */) + moduleResolution === 100 /* Bundler */ || moduleResolution === 2 /* Node10 */ ? void 0 : features & 32 /* EsmMode */ ? 99 /* ESNext */ : 1 /* CommonJS */ )); const diagnostics = []; const state = { @@ -38051,6 +38121,7 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, affectingLocations, diagnostics, state, + cache, legacyResult ); function tryResolve(extensions2, state2) { @@ -38330,7 +38401,7 @@ function getVersionPathsOfPackageJsonInfo(packageJsonInfo, state) { return packageJsonInfo.contents.versionPaths || void 0; } function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) { - var _a, _b, _c, _d, _e, _f, _g, _h; + var _a, _b, _c, _d, _e, _f; const { host, traceEnabled } = state; const packageJsonPath = combinePaths(packageDirectory, "package.json"); if (onlyRecordFailures) { @@ -38358,15 +38429,17 @@ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) { trace(host, Diagnostics.Found_package_json_at_0, packageJsonPath); } const result = { packageDirectory, contents: { packageJsonContent, versionPaths: void 0, resolvedEntrypoints: void 0 } }; - (_e = state.packageJsonInfoCache) == null ? void 0 : _e.setPackageJsonInfo(packageJsonPath, result); - (_f = state.affectingLocations) == null ? void 0 : _f.push(packageJsonPath); + if (state.packageJsonInfoCache && !state.packageJsonInfoCache.isReadonly) + state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, result); + (_e = state.affectingLocations) == null ? void 0 : _e.push(packageJsonPath); return result; } else { if (directoryExists && traceEnabled) { trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath); } - (_g = state.packageJsonInfoCache) == null ? void 0 : _g.setPackageJsonInfo(packageJsonPath, directoryExists); - (_h = state.failedLookupLocations) == null ? void 0 : _h.push(packageJsonPath); + if (state.packageJsonInfoCache && !state.packageJsonInfoCache.isReadonly) + state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, directoryExists); + (_f = state.failedLookupLocations) == null ? void 0 : _f.push(packageJsonPath); } } function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) { @@ -39156,7 +39229,8 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host, failedLookupLocations, affectingLocations, diagnostics, - state + state, + cache ); function tryResolve(extensions) { const resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state); @@ -39275,7 +39349,9 @@ function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, hos failedLookupLocations, affectingLocations, diagnostics, - state.resultFromCache + state.resultFromCache, + /*cache*/ + void 0 ); } function toSearchResult(value) { @@ -39324,7 +39400,7 @@ function getModuleInstanceStateWorker(node, visited) { break; case 272 /* ImportDeclaration */: case 271 /* ImportEqualsDeclaration */: - if (!hasSyntacticModifier(node, 1 /* Export */)) { + if (!hasSyntacticModifier(node, 32 /* Export */)) { return 0 /* NonInstantiated */; } break; @@ -39602,7 +39678,7 @@ function createBinder() { } function declareSymbol(symbolTable, parent2, node, includes, excludes, isReplaceableByMethod, isComputedName) { Debug.assert(isComputedName || !hasDynamicName(node)); - const isDefaultExport = hasSyntacticModifier(node, 1024 /* Default */) || isExportSpecifier(node) && node.name.escapedText === "default"; + const isDefaultExport = hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) && node.name.escapedText === "default"; const name = isComputedName ? "__computed" /* Computed */ : isDefaultExport && parent2 ? "default" /* Default */ : getDeclarationName(node); let symbol; if (name === void 0) { @@ -39646,7 +39722,7 @@ function createBinder() { } } const relatedInformation = []; - if (isTypeAliasDeclaration(node) && nodeIsMissing(node.type) && hasSyntacticModifier(node, 1 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) { + if (isTypeAliasDeclaration(node) && nodeIsMissing(node.type) && hasSyntacticModifier(node, 32 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) { relatedInformation.push(createDiagnosticForNode2(node, Diagnostics.Did_you_mean_0, `export type { ${unescapeLeadingUnderscores(node.name.escapedText)} }`)); } const declarationName = getNameOfDeclaration(node) || node; @@ -39675,7 +39751,7 @@ function createBinder() { return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - const hasExportModifier = !!(getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); + const hasExportModifier = !!(getCombinedModifierFlags(node) & 32 /* Export */) || jsdocTreatAsExported(node); if (symbolFlags & 2097152 /* Alias */) { if (node.kind === 281 /* ExportSpecifier */ || node.kind === 271 /* ImportEqualsDeclaration */ && hasExportModifier) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); @@ -39694,7 +39770,7 @@ function createBinder() { if (isJSDocTypeAlias(node)) Debug.assert(isInJSFile(node)); if (!isAmbientModule(node) && (hasExportModifier || container.flags & 128 /* ExportContext */)) { - if (!canHaveLocals(container) || !container.locals || hasSyntacticModifier(node, 1024 /* Default */) && !getDeclarationName(node)) { + if (!canHaveLocals(container) || !container.locals || hasSyntacticModifier(node, 2048 /* Default */) && !getDeclarationName(node)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } const exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; @@ -39735,7 +39811,7 @@ function createBinder() { return false; if (isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent)) return true; - if (isDeclaration(declName.parent) && getCombinedModifierFlags(declName.parent) & 1 /* Export */) + if (isDeclaration(declName.parent) && getCombinedModifierFlags(declName.parent) & 32 /* Export */) return true; return false; } @@ -39766,7 +39842,7 @@ function createBinder() { const saveExceptionTarget = currentExceptionTarget; const saveActiveLabelList = activeLabelList; const saveHasExplicitReturn = hasExplicitReturn; - const isImmediatelyInvoked = containerFlags & 16 /* IsFunctionExpression */ && !hasSyntacticModifier(node, 512 /* Async */) && !node.asteriskToken && !!getImmediatelyInvokedFunctionExpression(node) || node.kind === 175 /* ClassStaticBlockDeclaration */; + const isImmediatelyInvoked = containerFlags & 16 /* IsFunctionExpression */ && !hasSyntacticModifier(node, 1024 /* Async */) && !node.asteriskToken && !!getImmediatelyInvokedFunctionExpression(node) || node.kind === 175 /* ClassStaticBlockDeclaration */; if (!isImmediatelyInvoked) { currentFlow = initFlowNode({ flags: 2 /* Start */ }); if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { @@ -40813,7 +40889,7 @@ function createBinder() { function bindModuleDeclaration(node) { setExportContextFlag(node); if (isAmbientModule(node)) { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (isModuleAugmentationExternal(node)) { @@ -41874,7 +41950,7 @@ function createBinder() { } if (!isBindingPattern(node.name)) { const possibleVariableDecl = node.kind === 260 /* VariableDeclaration */ ? node : node.parent.parent; - if (isInJSFile(node) && shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) { + if (isInJSFile(node) && shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 32 /* Export */)) { declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); } else if (isBlockOrCatchScoped(node)) { bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); @@ -42026,7 +42102,7 @@ function isPurelyTypeDeclaration(s) { case 267 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; case 266 /* EnumDeclaration */: - return hasSyntacticModifier(s, 2048 /* Const */); + return hasSyntacticModifier(s, 4096 /* Const */); default: return false; } @@ -42360,10 +42436,12 @@ function getModuleSpecifiers(moduleSymbol, checker, compilerOptions, importingSo importingSourceFile, host, userPreferences, - options + options, + /*forAutoImport*/ + false ).moduleSpecifiers; } -function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences, options = {}) { +function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) { let computedWithoutCache = false; const ambient = tryGetModuleNameFromAmbientModule(moduleSymbol, checker); if (ambient) @@ -42381,11 +42459,19 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions return { moduleSpecifiers: emptyArray, computedWithoutCache }; computedWithoutCache = true; modulePaths || (modulePaths = getAllModulePathsWorker(importingSourceFile.path, moduleSourceFile.originalFileName, host)); - const result = computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options); + const result = computeModuleSpecifiers( + modulePaths, + compilerOptions, + importingSourceFile, + host, + userPreferences, + options, + forAutoImport + ); cache == null ? void 0 : cache.set(importingSourceFile.path, moduleSourceFile.path, userPreferences, options, modulePaths, result); return { moduleSpecifiers: result, computedWithoutCache }; } -function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}) { +function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) { const info = getInfo(importingSourceFile.path, host); const preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); const existingSpecifier = forEach(modulePaths, (modulePath) => forEach( @@ -42442,7 +42528,7 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi redirectPathsSpecifiers = append(redirectPathsSpecifiers, local); } else if (pathIsBareSpecifier(local)) { pathsSpecifiers = append(pathsSpecifiers, local); - } else if (!importedFileIsInNodeModules || modulePath.isInNodeModules) { + } else if (forAutoImport || !importedFileIsInNodeModules || modulePath.isInNodeModules) { relativeSpecifiers = append(relativeSpecifiers, local); } } @@ -42833,7 +42919,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa if (getResolvePackageJsonExports(options)) { const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1); const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2); - const conditions = getConditions(options, importMode === 99 /* ESNext */); + const conditions = getConditions(options, importMode); const fromExports = packageJsonContent.exports ? tryGetModuleNameFromExports(options, path, packageRootPath, packageName2, packageJsonContent.exports, conditions) : void 0; if (fromExports) { const withJsExtension = !hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) }; @@ -45122,7 +45208,7 @@ function createTypeChecker(host) { if (lastLocation && lastLocation === location.name) { return false; } - if (location.asteriskToken || hasSyntacticModifier(location, 512 /* Async */)) { + if (location.asteriskToken || hasSyntacticModifier(location, 1024 /* Async */)) { return true; } return !getImmediatelyInvokedFunctionExpression(location); @@ -45286,8 +45372,17 @@ function createTypeChecker(host) { function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { if (meaning & 111551 /* Value */) { if (isPrimitiveTypeName(name)) { - if (isExtendedByInterface(errorLocation)) { - error(errorLocation, Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes, unescapeLeadingUnderscores(name)); + const grandparent = errorLocation.parent.parent; + if (grandparent && grandparent.parent && isHeritageClause(grandparent)) { + const heritageKind = grandparent.token; + const containerKind = grandparent.parent.kind; + if (containerKind === 264 /* InterfaceDeclaration */ && heritageKind === 96 /* ExtendsKeyword */) { + error(errorLocation, Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_It_can_only_extend_other_named_object_types, unescapeLeadingUnderscores(name)); + } else if (containerKind === 263 /* ClassDeclaration */ && heritageKind === 96 /* ExtendsKeyword */) { + error(errorLocation, Diagnostics.A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values, unescapeLeadingUnderscores(name)); + } else if (containerKind === 263 /* ClassDeclaration */ && heritageKind === 119 /* ImplementsKeyword */) { + error(errorLocation, Diagnostics.A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types, unescapeLeadingUnderscores(name)); + } } else { error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, unescapeLeadingUnderscores(name)); } @@ -45319,16 +45414,6 @@ function createTypeChecker(host) { } return false; } - function isExtendedByInterface(node) { - const grandparent = node.parent.parent; - const parentOfGrandparent = grandparent.parent; - if (grandparent && parentOfGrandparent) { - const isExtending = isHeritageClause(grandparent) && grandparent.token === 96 /* ExtendsKeyword */; - const isInterface = isInterfaceDeclaration(parentOfGrandparent); - return isExtending && isInterface; - } - return false; - } function maybeMappedType(node, symbol) { const container = findAncestor(node.parent, (n) => isComputedPropertyName(n) || isPropertySignature(n) ? false : isTypeLiteralNode(n) || "quit"); if (container && container.members.length === 1) { @@ -45507,7 +45592,7 @@ function createTypeChecker(host) { return resolved; } function isSyntacticDefault(node) { - return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 1024 /* Default */) || isExportSpecifier(node); + return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) || isNamespaceExport(node); } function getUsageModeForExpression(usage) { return isStringLiteralLike(usage) ? getModeForUsageLocation(getSourceFileOfNode(usage), usage) : void 0; @@ -47433,20 +47518,20 @@ function createTypeChecker(host) { var _a, _b; if (!isDeclarationVisible(declaration)) { const anyImportSyntax = getAnyImportSyntax(declaration); - if (anyImportSyntax && !hasSyntacticModifier(anyImportSyntax, 1 /* Export */) && // import clause without export + if (anyImportSyntax && !hasSyntacticModifier(anyImportSyntax, 32 /* Export */) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { return addVisibleAlias(declaration, anyImportSyntax); - } else if (isVariableDeclaration(declaration) && isVariableStatement(declaration.parent.parent) && !hasSyntacticModifier(declaration.parent.parent, 1 /* Export */) && // unexported variable statement + } else if (isVariableDeclaration(declaration) && isVariableStatement(declaration.parent.parent) && !hasSyntacticModifier(declaration.parent.parent, 32 /* Export */) && // unexported variable statement isDeclarationVisible(declaration.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent); - } else if (isLateVisibilityPaintedStatement(declaration) && !hasSyntacticModifier(declaration, 1 /* Export */) && isDeclarationVisible(declaration.parent)) { + } else if (isLateVisibilityPaintedStatement(declaration) && !hasSyntacticModifier(declaration, 32 /* Export */) && isDeclarationVisible(declaration.parent)) { return addVisibleAlias(declaration, declaration); } else if (isBindingElement(declaration)) { - if (symbol.flags & 2097152 /* Alias */ && isInJSFile(declaration) && ((_a = declaration.parent) == null ? void 0 : _a.parent) && isVariableDeclaration(declaration.parent.parent) && ((_b = declaration.parent.parent.parent) == null ? void 0 : _b.parent) && isVariableStatement(declaration.parent.parent.parent.parent) && !hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */) && declaration.parent.parent.parent.parent.parent && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { + if (symbol.flags & 2097152 /* Alias */ && isInJSFile(declaration) && ((_a = declaration.parent) == null ? void 0 : _a.parent) && isVariableDeclaration(declaration.parent.parent) && ((_b = declaration.parent.parent.parent) == null ? void 0 : _b.parent) && isVariableStatement(declaration.parent.parent.parent.parent) && !hasSyntacticModifier(declaration.parent.parent.parent.parent, 32 /* Export */) && declaration.parent.parent.parent.parent.parent && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); } else if (symbol.flags & 2 /* BlockScopedVariable */) { const variableStatement = findAncestor(declaration, isVariableStatement); - if (hasSyntacticModifier(variableStatement, 1 /* Export */)) { + if (hasSyntacticModifier(variableStatement, 32 /* Export */)) { return true; } if (!isDeclarationVisible(variableStatement.parent)) { @@ -47669,7 +47754,8 @@ function createTypeChecker(host) { visitedTypes: void 0, symbolDepth: void 0, inferTypeParameters: void 0, - approximateLength: 0 + approximateLength: 0, + trackedSymbols: void 0 }; context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost); const resultingNode = cb(context); @@ -48123,7 +48209,7 @@ function createTypeChecker(host) { } } function visitAndTransformType(type2, transform) { - var _a2, _b2; + var _a2, _b2, _c; const typeId = type2.id; const isConstructorObject = getObjectFlags(type2) & 16 /* Anonymous */ && type2.symbol && type2.symbol.flags & 32 /* Class */; const id = getObjectFlags(type2) & 4 /* Reference */ && type2.node ? "N" + getNodeId(type2.node) : type2.flags & 16777216 /* Conditional */ ? "N" + getNodeId(type2.root.node) : type2.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type2.symbol) : void 0; @@ -48140,6 +48226,13 @@ function createTypeChecker(host) { } const cachedResult = (_a2 = links == null ? void 0 : links.serializedTypes) == null ? void 0 : _a2.get(key); if (cachedResult) { + (_b2 = cachedResult.trackedSymbols) == null ? void 0 : _b2.forEach( + ([symbol, enclosingDeclaration, meaning]) => context.tracker.trackSymbol( + symbol, + enclosingDeclaration, + meaning + ) + ); if (cachedResult.truncating) { context.truncating = true; } @@ -48159,7 +48252,12 @@ function createTypeChecker(host) { const result = transform(type2); const addedLength = context.approximateLength - startLength; if (!context.reportedDiagnostic && !context.encounteredError) { - (_b2 = links == null ? void 0 : links.serializedTypes) == null ? void 0 : _b2.set(key, { node: result, truncating: context.truncating, addedLength }); + (_c = links == null ? void 0 : links.serializedTypes) == null ? void 0 : _c.set(key, { + node: result, + truncating: context.truncating, + addedLength, + trackedSymbols: context.trackedSymbols + }); } context.visitedTypes.delete(typeId); if (id) { @@ -48401,7 +48499,7 @@ function createTypeChecker(host) { if (propertySymbol.flags & 4194304 /* Prototype */) { continue; } - if (getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* Private */ | 16 /* Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { + if (getDeclarationModifierFlagsFromSymbol(propertySymbol) & (2 /* Private */ | 4 /* Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { context.tracker.reportPrivateInBaseOfClassExpression(unescapeLeadingUnderscores(propertySymbol.escapedName)); } } @@ -48465,6 +48563,28 @@ function createTypeChecker(host) { const propertyName = getPropertyNameNodeForSymbol(propertySymbol, context); context.enclosingDeclaration = saveEnclosingDeclaration; context.approximateLength += symbolName(propertySymbol).length + 1; + if (propertySymbol.flags & 98304 /* Accessor */) { + const writeType = getWriteTypeOfSymbol(propertySymbol); + if (propertyType !== writeType) { + const getterDeclaration = getDeclarationOfKind(propertySymbol, 177 /* GetAccessor */); + const getterSignature = getSignatureFromDeclaration(getterDeclaration); + typeElements.push( + setCommentRange( + signatureToSignatureDeclarationHelper(getterSignature, 177 /* GetAccessor */, context, { name: propertyName }), + getterDeclaration + ) + ); + const setterDeclaration = getDeclarationOfKind(propertySymbol, 178 /* SetAccessor */); + const setterSignature = getSignatureFromDeclaration(setterDeclaration); + typeElements.push( + setCommentRange( + signatureToSignatureDeclarationHelper(setterSignature, 178 /* SetAccessor */, context, { name: propertyName }), + setterDeclaration + ) + ); + return; + } + } const optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags & 32768 /* Undefined */)), 0 /* Call */); @@ -48502,9 +48622,9 @@ function createTypeChecker(host) { typeElements.push(preserveCommentsOn(propertySignature)); function preserveCommentsOn(node) { var _a2; - if (some(propertySymbol.declarations, (d) => d.kind === 355 /* JSDocPropertyTag */)) { - const d = (_a2 = propertySymbol.declarations) == null ? void 0 : _a2.find((d2) => d2.kind === 355 /* JSDocPropertyTag */); - const commentText = getTextOfJSDocComment(d.comment); + const jsdocPropertyTag = (_a2 = propertySymbol.declarations) == null ? void 0 : _a2.find((d) => d.kind === 355 /* JSDocPropertyTag */); + if (jsdocPropertyTag) { + const commentText = getTextOfJSDocComment(jsdocPropertyTag.comment); if (commentText) { setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); } @@ -48682,7 +48802,7 @@ function createTypeChecker(host) { let modifiers = options == null ? void 0 : options.modifiers; if (kind === 185 /* ConstructorType */ && signature.flags & 4 /* Abstract */) { const flags = modifiersToFlags(modifiers); - modifiers = factory.createModifiersFromModifierFlags(flags | 256 /* Abstract */); + modifiers = factory.createModifiersFromModifierFlags(flags | 64 /* Abstract */); } const node = kind === 179 /* CallSignature */ ? factory.createCallSignature(typeParameters, parameters, returnTypeNode) : kind === 180 /* ConstructSignature */ ? factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : kind === 173 /* MethodSignature */ ? factory.createMethodSignature(modifiers, (options == null ? void 0 : options.name) ?? factory.createIdentifier(""), options == null ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : kind === 174 /* MethodDeclaration */ ? factory.createMethodDeclaration( modifiers, @@ -49739,7 +49859,7 @@ function createTypeChecker(host) { const nsIndex = findIndex(statements, isModuleDeclaration); let ns = nsIndex !== -1 ? statements[nsIndex] : void 0; if (ns && exportAssignment && exportAssignment.isExportEquals && isIdentifier(exportAssignment.expression) && isIdentifier(ns.name) && idText(ns.name) === idText(exportAssignment.expression) && ns.body && isModuleBlock(ns.body)) { - const excessExports = filter(statements, (s) => !!(getEffectiveModifierFlags(s) & 1 /* Export */)); + const excessExports = filter(statements, (s) => !!(getEffectiveModifierFlags(s) & 32 /* Export */)); const name = ns.name; let body = ns.body; if (length(excessExports)) { @@ -49773,9 +49893,9 @@ function createTypeChecker(host) { } if (!find(statements, (s) => s !== ns && nodeHasName(s, name))) { results = []; - const mixinExportFlag = !some(body.statements, (s) => hasSyntacticModifier(s, 1 /* Export */) || isExportAssignment(s) || isExportDeclaration(s)); + const mixinExportFlag = !some(body.statements, (s) => hasSyntacticModifier(s, 32 /* Export */) || isExportAssignment(s) || isExportDeclaration(s)); forEach(body.statements, (s) => { - addResult(s, mixinExportFlag ? 1 /* Export */ : 0 /* None */); + addResult(s, mixinExportFlag ? 32 /* Export */ : 0 /* None */); }); statements = [...filter(statements, (s) => s !== ns && s !== exportAssignment), ...results]; } @@ -49867,12 +49987,12 @@ function createTypeChecker(host) { return statements; } function addExportModifier(node) { - const flags = (getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */; - return factory.updateModifiers(node, flags); + const flags = (getEffectiveModifierFlags(node) | 32 /* Export */) & ~128 /* Ambient */; + return factory.replaceModifiers(node, flags); } function removeExportModifier(node) { - const flags = getEffectiveModifierFlags(node) & ~1 /* Export */; - return factory.updateModifiers(node, flags); + const flags = getEffectiveModifierFlags(node) & ~32 /* Export */; + return factory.replaceModifiers(node, flags); } function visitSymbolTable(symbolTable2, suppressNewPrivateContext, propertyAsAlias) { if (!suppressNewPrivateContext) { @@ -49912,6 +50032,12 @@ function createTypeChecker(host) { if (context.reportedDiagnostic) { oldcontext.reportedDiagnostic = context.reportedDiagnostic; } + if (context.trackedSymbols) { + if (!oldContext.trackedSymbols) + oldContext.trackedSymbols = context.trackedSymbols; + else + Debug.assert(context.trackedSymbols === oldContext.trackedSymbols); + } context = oldContext; } } @@ -49928,7 +50054,7 @@ function createTypeChecker(host) { if (needsPostExportDefault || needsExportDeclaration) { isPrivate = true; } - const modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 1024 /* Default */ : 0); + const modifierFlags = (!isPrivate ? 32 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 2048 /* Default */ : 0); const isConstMergedWithNS = symbol.flags & 1536 /* Module */ && symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && escapedSymbolName !== "export=" /* ExportEquals */; const isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); if (symbol.flags & (16 /* Function */ | 8192 /* Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { @@ -49998,7 +50124,7 @@ function createTypeChecker(host) { ), textRange ); - addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + addResult(statement, name !== localName ? modifierFlags & ~32 /* Export */ : modifierFlags); if (name !== localName && !isPrivate) { addResult( factory.createExportDeclaration( @@ -50103,17 +50229,17 @@ function createTypeChecker(host) { if (canHaveModifiers(node)) { let newModifierFlags = 0 /* None */; const enclosingDeclaration2 = context.enclosingDeclaration && (isJSDocTypeAlias(context.enclosingDeclaration) ? getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); - if (additionalModifierFlags & 1 /* Export */ && enclosingDeclaration2 && (isExportingScope(enclosingDeclaration2) || isModuleDeclaration(enclosingDeclaration2)) && canHaveExportModifier(node)) { - newModifierFlags |= 1 /* Export */; + if (additionalModifierFlags & 32 /* Export */ && enclosingDeclaration2 && (isExportingScope(enclosingDeclaration2) || isModuleDeclaration(enclosingDeclaration2)) && canHaveExportModifier(node)) { + newModifierFlags |= 32 /* Export */; } - if (addingDeclare && !(newModifierFlags & 1 /* Export */) && (!enclosingDeclaration2 || !(enclosingDeclaration2.flags & 33554432 /* Ambient */)) && (isEnumDeclaration(node) || isVariableStatement(node) || isFunctionDeclaration(node) || isClassDeclaration(node) || isModuleDeclaration(node))) { - newModifierFlags |= 2 /* Ambient */; + if (addingDeclare && !(newModifierFlags & 32 /* Export */) && (!enclosingDeclaration2 || !(enclosingDeclaration2.flags & 33554432 /* Ambient */)) && (isEnumDeclaration(node) || isVariableStatement(node) || isFunctionDeclaration(node) || isClassDeclaration(node) || isModuleDeclaration(node))) { + newModifierFlags |= 128 /* Ambient */; } - if (additionalModifierFlags & 1024 /* Default */ && (isClassDeclaration(node) || isInterfaceDeclaration(node) || isFunctionDeclaration(node))) { - newModifierFlags |= 1024 /* Default */; + if (additionalModifierFlags & 2048 /* Default */ && (isClassDeclaration(node) || isInterfaceDeclaration(node) || isFunctionDeclaration(node))) { + newModifierFlags |= 2048 /* Default */; } if (newModifierFlags) { - node = factory.updateModifiers(node, newModifierFlags | getEffectiveModifierFlags(node)); + node = factory.replaceModifiers(node, newModifierFlags | getEffectiveModifierFlags(node)); } } results.push(node); @@ -50232,7 +50358,7 @@ function createTypeChecker(host) { function serializeEnum(symbol, symbolName2, modifierFlags) { addResult( factory.createEnumDeclaration( - factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), + factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 4096 /* Const */ : 0), getInternalSymbolName(symbol, symbolName2), map(filter(getPropertiesOfType(getTypeOfSymbol(symbol)), (p) => !!(p.flags & 8 /* EnumMember */)), (p) => { const initializedValue = p.declarations && p.declarations[0] && isEnumMember(p.declarations[0]) ? getConstantValue2(p.declarations[0]) : void 0; @@ -50316,7 +50442,7 @@ function createTypeChecker(host) { factory.createIdentifier("default" /* Default */) )]) ) : d); - const exportModifierStripped = every(defaultReplaced, (d) => hasSyntacticModifier(d, 1 /* Export */)) ? map(defaultReplaced, removeExportModifier) : defaultReplaced; + const exportModifierStripped = every(defaultReplaced, (d) => hasSyntacticModifier(d, 32 /* Export */)) ? map(defaultReplaced, removeExportModifier) : defaultReplaced; fakespace = factory.updateModuleDeclaration( fakespace, fakespace.modifiers, @@ -50419,7 +50545,7 @@ function createTypeChecker(host) { ); const isNonConstructableClassLikeInJsFile = !isClass && !!symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && !some(getSignaturesOfType(staticType, 1 /* Construct */)); const constructors = isNonConstructableClassLikeInJsFile ? [factory.createConstructorDeclaration( - factory.createModifiersFromModifierFlags(8 /* Private */), + factory.createModifiersFromModifierFlags(2 /* Private */), [], /*body*/ void 0 @@ -50772,7 +50898,7 @@ function createTypeChecker(host) { const varName = getUnusedName(name, symbol); const typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol))); if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { - serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 1 /* Export */); + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 32 /* Export */); } else { const flags = ((_a2 = context.enclosingDeclaration) == null ? void 0 : _a2.kind) === 267 /* ModuleDeclaration */ && (!(symbol.flags & 98304 /* Accessor */) || symbol.flags & 65536 /* SetAccessor */) ? 1 /* Let */ : 2 /* Const */; const statement = factory.createVariableStatement( @@ -50789,7 +50915,7 @@ function createTypeChecker(host) { ); addResult( statement, - target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ : name === varName ? 1 /* Export */ : 0 /* None */ + target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 128 /* Ambient */ : name === varName ? 32 /* Export */ : 0 /* None */ ); } if (isExportAssignmentCompatibleSymbolName) { @@ -50811,20 +50937,28 @@ function createTypeChecker(host) { const ctxSrc = getSourceFileOfNode(context.enclosingDeclaration); return getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && !length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class !!(length(filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && !length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK - !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && some(typeToSerialize.symbol.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && !some(getPropertiesOfType(typeToSerialize), (p) => isLateBoundName(p.escapedName)) && !some(getPropertiesOfType(typeToSerialize), (p) => some(p.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && every(getPropertiesOfType(typeToSerialize), (p) => isIdentifierText(symbolName(p), languageVersion)); + !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && some(typeToSerialize.symbol.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && !some(getPropertiesOfType(typeToSerialize), (p) => isLateBoundName(p.escapedName)) && !some(getPropertiesOfType(typeToSerialize), (p) => some(p.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && every(getPropertiesOfType(typeToSerialize), (p) => { + if (!isIdentifierText(symbolName(p), languageVersion)) { + return false; + } + if (!(p.flags & 98304 /* Accessor */)) { + return true; + } + return getNonMissingTypeOfSymbol(p) === getWriteTypeOfSymbol(p); + }); } function makeSerializePropertySymbol(createProperty2, methodKind, useAccessors) { return function serializePropertySymbol(p, isStatic2, baseType) { var _a2, _b, _c, _d, _e; const modifierFlags = getDeclarationModifierFlagsFromSymbol(p); - const isPrivate = !!(modifierFlags & 8 /* Private */); + const isPrivate = !!(modifierFlags & 2 /* Private */); if (isStatic2 && p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) { return []; } if (p.flags & 4194304 /* Prototype */ || p.escapedName === "constructor" || baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName))) { return []; } - const flag = modifierFlags & ~512 /* Async */ | (isStatic2 ? 32 /* Static */ : 0); + const flag = modifierFlags & ~1024 /* Async */ | (isStatic2 ? 256 /* Static */ : 0); const name = getPropertyNameNodeForSymbol(p, context); const firstPropertyLikeDecl = (_a2 = p.declarations) == null ? void 0 : _a2.find(or(isPropertyDeclaration, isAccessor, isVariableDeclaration, isPropertySignature, isBinaryExpression, isPropertyAccessExpression)); if (p.flags & 98304 /* Accessor */ && useAccessors) { @@ -50866,7 +51000,7 @@ function createTypeChecker(host) { )); } if (p.flags & 32768 /* GetAccessor */) { - const isPrivate2 = modifierFlags & 8 /* Private */; + const isPrivate2 = modifierFlags & 2 /* Private */; result.push(setTextRange( factory.createGetAccessorDeclaration( factory.createModifiersFromModifierFlags(flag), @@ -50883,7 +51017,7 @@ function createTypeChecker(host) { } else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) { return setTextRange( createProperty2( - factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), + factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0, isPrivate ? void 0 : serializeTypeForDeclaration(context, getWriteTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), @@ -50898,10 +51032,10 @@ function createTypeChecker(host) { if (p.flags & (8192 /* Method */ | 16 /* Function */)) { const type = getTypeOfSymbol(p); const signatures = getSignaturesOfType(type, 0 /* Call */); - if (flag & 8 /* Private */) { + if (flag & 2 /* Private */) { return setTextRange( createProperty2( - factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), + factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0, /*type*/ @@ -50977,7 +51111,7 @@ function createTypeChecker(host) { let privateProtected = 0; for (const s of signatures) { if (s.declaration) { - privateProtected |= getSelectedEffectiveModifierFlags(s.declaration, 8 /* Private */ | 16 /* Protected */); + privateProtected |= getSelectedEffectiveModifierFlags(s.declaration, 2 /* Private */ | 4 /* Protected */); } } if (privateProtected) { @@ -51170,10 +51304,10 @@ function createTypeChecker(host) { return result || types; } function visibilityToString(flags) { - if (flags === 8 /* Private */) { + if (flags === 2 /* Private */) { return "private"; } - if (flags === 16 /* Protected */) { + if (flags === 4 /* Protected */) { return "protected"; } return "public"; @@ -51291,7 +51425,7 @@ function createTypeChecker(host) { return true; } const parent = getDeclarationContainer(node); - if (!(getCombinedModifierFlagsCached(node) & 1 /* Export */) && !(node.kind !== 271 /* ImportEqualsDeclaration */ && parent.kind !== 312 /* SourceFile */ && parent.flags & 33554432 /* Ambient */)) { + if (!(getCombinedModifierFlagsCached(node) & 32 /* Export */) && !(node.kind !== 271 /* ImportEqualsDeclaration */ && parent.kind !== 312 /* SourceFile */ && parent.flags & 33554432 /* Ambient */)) { return isGlobalSourceFile(parent); } return isDeclarationVisible(parent); @@ -51301,7 +51435,7 @@ function createTypeChecker(host) { case 178 /* SetAccessor */: case 174 /* MethodDeclaration */: case 173 /* MethodSignature */: - if (hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { + if (hasEffectiveModifier(node, 2 /* Private */ | 4 /* Protected */)) { return false; } case 176 /* Constructor */: @@ -51520,7 +51654,7 @@ function createTypeChecker(host) { const unspreadableToRestKeys = []; for (const prop of getPropertiesOfType(source)) { const literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */); - if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) && !(getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) && isSpreadableProperty(prop)) { + if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) && !(getDeclarationModifierFlagsFromSymbol(prop) & (2 /* Private */ | 4 /* Protected */)) && isSpreadableProperty(prop)) { spreadableProperties.push(prop); } else { unspreadableToRestKeys.push(literalTypeFromProperty); @@ -51726,7 +51860,7 @@ function createTypeChecker(host) { if (declaredType) { return addOptionality(declaredType, isProperty, isOptional); } - if ((noImplicitAny || isInJSFile(declaration)) && isVariableDeclaration(declaration) && !isBindingPattern(declaration.name) && !(getCombinedModifierFlagsCached(declaration) & 1 /* Export */) && !(declaration.flags & 33554432 /* Ambient */)) { + if ((noImplicitAny || isInJSFile(declaration)) && isVariableDeclaration(declaration) && !isBindingPattern(declaration.name) && !(getCombinedModifierFlagsCached(declaration) & 32 /* Export */) && !(declaration.flags & 33554432 /* Ambient */)) { if (!(getCombinedNodeFlagsCached(declaration) & 6 /* Constant */) && (!declaration.initializer || isNullOrUndefined2(declaration.initializer))) { return autoType; } @@ -51774,7 +51908,7 @@ function createTypeChecker(host) { if (isPropertyDeclaration(declaration) && (noImplicitAny || isInJSFile(declaration))) { if (!hasStaticModifier(declaration)) { const constructor = findConstructorDeclaration(declaration.parent); - const type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : void 0; + const type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : getEffectiveModifierFlags(declaration) & 128 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : void 0; return type && addOptionality( type, /*isProperty*/ @@ -51783,7 +51917,7 @@ function createTypeChecker(host) { ); } else { const staticBlocks = filter(declaration.parent.members, isClassStaticBlockDeclaration); - const type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) : getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : void 0; + const type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) : getEffectiveModifierFlags(declaration) & 128 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : void 0; return type && addOptionality( type, /*isProperty*/ @@ -51887,7 +52021,7 @@ function createTypeChecker(host) { return everyType(flowType, isNullableType) ? void 0 : convertAutoToAny(flowType); } function getFlowTypeOfProperty(reference, prop) { - const initialType = (prop == null ? void 0 : prop.valueDeclaration) && (!isAutoTypedProperty(prop) || getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; + const initialType = (prop == null ? void 0 : prop.valueDeclaration) && (!isAutoTypedProperty(prop) || getEffectiveModifierFlags(prop.valueDeclaration) & 128 /* Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); } function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) { @@ -52511,6 +52645,9 @@ function createTypeChecker(host) { function getTypeOfAlias(symbol) { const links = getSymbolLinks(symbol); if (!links.type) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return errorType; + } const targetSymbol = resolveAlias(symbol); const exportSymbol = symbol.declarations && getTargetOfAliasDeclaration( getDeclarationOfAliasSymbol(symbol), @@ -52519,6 +52656,10 @@ function createTypeChecker(host) { ); const declaredType = firstDefined(exportSymbol == null ? void 0 : exportSymbol.declarations, (d) => isExportAssignment(d) ? tryGetTypeFromEffectiveTypeNode(d) : void 0); links.type = (exportSymbol == null ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType : getSymbolFlags(targetSymbol) & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType; + if (!popTypeResolution()) { + reportCircularityError(exportSymbol ?? symbol); + return links.type = errorType; + } } return links.type; } @@ -52532,12 +52673,19 @@ function createTypeChecker(host) { } function reportCircularityError(symbol) { const declaration = symbol.valueDeclaration; - if (getEffectiveTypeAnnotationNode(declaration)) { - error(symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); - return errorType; - } - if (noImplicitAny && (declaration.kind !== 169 /* Parameter */ || declaration.initializer)) { - error(symbol.valueDeclaration, Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); + if (declaration) { + if (getEffectiveTypeAnnotationNode(declaration)) { + error(symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); + return errorType; + } + if (noImplicitAny && (declaration.kind !== 169 /* Parameter */ || declaration.initializer)) { + error(symbol.valueDeclaration, Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); + } + } else if (symbol.flags & 2097152 /* Alias */) { + const node = getDeclarationOfAliasSymbol(symbol); + if (node) { + error(node, Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); + } } return anyType; } @@ -53540,7 +53688,7 @@ function createTypeChecker(host) { const baseConstructorType = getBaseConstructorTypeOfClass(classType); const baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); const declaration = getClassLikeDeclarationOfSymbol(classType.symbol); - const isAbstract = !!declaration && hasSyntacticModifier(declaration, 256 /* Abstract */); + const isAbstract = !!declaration && hasSyntacticModifier(declaration, 64 /* Abstract */); if (baseSignatures.length === 0) { return [createSignature( /*declaration*/ @@ -54316,7 +54464,7 @@ function createTypeChecker(host) { } function isConstTypeVariable(type, depth = 0) { var _a; - return depth < 5 && !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 3145728 /* UnionOrIntersection */ && some(type.types, (t) => isConstTypeVariable(t, depth)) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType, depth + 1) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type), depth + 1) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType, depth) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t, depth)) >= 0)); + return depth < 5 && !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 4096 /* Const */)) || type.flags & 3145728 /* UnionOrIntersection */ && some(type.types, (t) => isConstTypeVariable(t, depth)) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType, depth + 1) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type), depth + 1) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType, depth) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t, depth)) >= 0)); } function getConstraintOfIndexedAccess(type) { return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0; @@ -54642,7 +54790,7 @@ function createTypeChecker(host) { } else if (!isUnion && !isReadonlySymbol(prop)) { checkFlags &= ~8 /* Readonly */; } - checkFlags |= (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | (modifiers & 16 /* Protected */ ? 512 /* ContainsProtected */ : 0) | (modifiers & 8 /* Private */ ? 1024 /* ContainsPrivate */ : 0) | (modifiers & 32 /* Static */ ? 2048 /* ContainsStatic */ : 0); + checkFlags |= (!(modifiers & 6 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | (modifiers & 4 /* Protected */ ? 512 /* ContainsProtected */ : 0) | (modifiers & 2 /* Private */ ? 1024 /* ContainsPrivate */ : 0) | (modifiers & 256 /* Static */ ? 2048 /* ContainsStatic */ : 0); if (!isPrototypeProperty(prop)) { syntheticFlag = 2 /* SyntheticProperty */; } @@ -55094,7 +55242,7 @@ function createTypeChecker(host) { if (hasRestParameter(declaration) || isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { flags |= 1 /* HasRestParameter */; } - if (isConstructorTypeNode(declaration) && hasSyntacticModifier(declaration, 256 /* Abstract */) || isConstructorDeclaration(declaration) && hasSyntacticModifier(declaration.parent, 256 /* Abstract */)) { + if (isConstructorTypeNode(declaration) && hasSyntacticModifier(declaration, 64 /* Abstract */) || isConstructorDeclaration(declaration) && hasSyntacticModifier(declaration.parent, 64 /* Abstract */)) { flags |= 4 /* Abstract */; } links.resolvedSignature = createSignature( @@ -55464,7 +55612,7 @@ function createTypeChecker(host) { if (parameter.type) { forEachType(getTypeFromTypeNode(parameter.type), (keyType) => { if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos, keyType)) { - indexInfos.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, hasEffectiveModifier(declaration, 64 /* Readonly */), declaration)); + indexInfos.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, hasEffectiveModifier(declaration, 8 /* Readonly */), declaration)); } }); } @@ -57289,7 +57437,7 @@ function createTypeChecker(host) { return neverType; } function getLiteralTypeFromProperty(prop, include, includeNonPublic) { - if (includeNonPublic || !(getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { + if (includeNonPublic || !(getDeclarationModifierFlagsFromSymbol(prop) & 6 /* NonPublicAccessibilityModifier */)) { let type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; if (!type) { const name = getNameOfDeclaration(prop.valueDeclaration); @@ -57582,7 +57730,11 @@ function createTypeChecker(host) { if (indexInfo) { if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) { if (accessExpression) { - error(accessExpression, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); + if (accessFlags & 4 /* Writing */) { + error(accessExpression, Diagnostics.Type_0_is_generic_and_can_only_be_indexed_for_reading, typeToString(originalObjectType)); + } else { + error(accessExpression, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); + } } return void 0; } @@ -57719,7 +57871,7 @@ function createTypeChecker(host) { } function isPatternLiteralPlaceholderType(type) { if (type.flags & 2097152 /* Intersection */) { - return some(type.types, (t) => !!(t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) || isPatternLiteralPlaceholderType(t)); + return !isGenericType(type) && some(type.types, (t) => !!(t.flags & (2944 /* Literal */ | 98304 /* Nullable */)) || isPatternLiteralPlaceholderType(t)); } return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || isPatternLiteralType(type); } @@ -58230,7 +58382,7 @@ function createTypeChecker(host) { function getAnonymousPartialType(type2) { const members = createSymbolTable(); for (const prop of getPropertiesOfType(type2)) { - if (getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) { + if (getDeclarationModifierFlagsFromSymbol(prop) & (2 /* Private */ | 4 /* Protected */)) { } else if (isSpreadableProperty(prop)) { const isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); const flags = 4 /* Property */ | 16777216 /* Optional */; @@ -58292,7 +58444,7 @@ function createTypeChecker(host) { const skippedPrivateMembers = /* @__PURE__ */ new Set(); const indexInfos = left === emptyObjectType ? getIndexInfosOfType(right) : getUnionIndexInfos([left, right]); for (const rightProp of getPropertiesOfType(right)) { - if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { + if (getDeclarationModifierFlagsFromSymbol(rightProp) & (2 /* Private */ | 4 /* Protected */)) { skippedPrivateMembers.add(rightProp.escapedName); } else if (isSpreadableProperty(rightProp)) { members.set(rightProp.escapedName, getSpreadSymbol(rightProp, readonly)); @@ -61859,25 +62011,25 @@ function createTypeChecker(host) { function propertyRelatedTo(source2, target2, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors2, intersectionState, skipOptional) { const sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); const targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); - if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 2 /* Private */ || targetPropFlags & 2 /* Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors2) { - if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 2 /* Private */ && targetPropFlags & 2 /* Private */) { reportError(Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* Private */ ? source2 : target2), typeToString(sourcePropFlags & 8 /* Private */ ? target2 : source2)); + reportError(Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 2 /* Private */ ? source2 : target2), typeToString(sourcePropFlags & 2 /* Private */ ? target2 : source2)); } } return 0 /* False */; } - } else if (targetPropFlags & 16 /* Protected */) { + } else if (targetPropFlags & 4 /* Protected */) { if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors2) { reportError(Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source2), typeToString(getDeclaringClass(targetProp) || target2)); } return 0 /* False */; } - } else if (sourcePropFlags & 16 /* Protected */) { + } else if (sourcePropFlags & 4 /* Protected */) { if (reportErrors2) { reportError(Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source2), typeToString(target2)); } @@ -62407,15 +62559,15 @@ function createTypeChecker(host) { if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - const sourceAccessibility = getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* NonPublicAccessibilityModifier */); - const targetAccessibility = getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* NonPublicAccessibilityModifier */); - if (targetAccessibility === 8 /* Private */) { + const sourceAccessibility = getSelectedEffectiveModifierFlags(sourceSignature.declaration, 6 /* NonPublicAccessibilityModifier */); + const targetAccessibility = getSelectedEffectiveModifierFlags(targetSignature.declaration, 6 /* NonPublicAccessibilityModifier */); + if (targetAccessibility === 2 /* Private */) { return true; } - if (targetAccessibility === 16 /* Protected */ && sourceAccessibility !== 8 /* Private */) { + if (targetAccessibility === 4 /* Protected */ && sourceAccessibility !== 2 /* Private */) { return true; } - if (targetAccessibility !== 16 /* Protected */ && !sourceAccessibility) { + if (targetAccessibility !== 4 /* Protected */ && !sourceAccessibility) { return true; } if (reportErrors2) { @@ -62515,7 +62667,7 @@ function createTypeChecker(host) { const variances = []; for (const tp of typeParameters) { const modifiers = getTypeParameterModifiers(tp); - let variance = modifiers & 65536 /* Out */ ? modifiers & 32768 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ : modifiers & 32768 /* In */ ? 2 /* Contravariant */ : void 0; + let variance = modifiers & 16384 /* Out */ ? modifiers & 8192 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ : modifiers & 8192 /* In */ ? 2 /* Contravariant */ : void 0; if (variance === void 0) { let unmeasurable = false; let unreliable = false; @@ -62563,7 +62715,7 @@ function createTypeChecker(host) { } function getTypeParameterModifiers(tp) { var _a; - return reduceLeft((_a = tp.symbol) == null ? void 0 : _a.declarations, (modifiers, d) => modifiers | getEffectiveModifierFlags(d), 0 /* None */) & (32768 /* In */ | 65536 /* Out */ | 2048 /* Const */); + return reduceLeft((_a = tp.symbol) == null ? void 0 : _a.declarations, (modifiers, d) => modifiers | getEffectiveModifierFlags(d), 0 /* None */) & (8192 /* In */ | 16384 /* Out */ | 4096 /* Const */); } function hasCovariantVoidArgument(typeArguments, variances) { for (let i = 0; i < variances.length; i++) { @@ -62648,13 +62800,16 @@ function createTypeChecker(host) { }); } function isValidOverrideOf(sourceProp, targetProp) { - return !forEachProperty(targetProp, (tp) => getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ? !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false); + return !forEachProperty(targetProp, (tp) => getDeclarationModifierFlagsFromSymbol(tp) & 4 /* Protected */ ? !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false); } function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { - return forEachProperty(prop, (p) => getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* Protected */ ? !hasBaseType(checkClass, getDeclaringClass(p)) : false) ? void 0 : checkClass; + return forEachProperty(prop, (p) => getDeclarationModifierFlagsFromSymbol(p, writing) & 4 /* Protected */ ? !hasBaseType(checkClass, getDeclaringClass(p)) : false) ? void 0 : checkClass; } function isDeeplyNestedType(type, stack, depth, maxDepth = 3) { if (depth >= maxDepth) { + if ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */) { + type = getMappedTargetWithSymbol(type); + } if (type.flags & 2097152 /* Intersection */) { return some(type.types, (t) => isDeeplyNestedType(t, stack, depth, maxDepth)); } @@ -62663,7 +62818,7 @@ function createTypeChecker(host) { let lastTypeId = 0; for (let i = 0; i < depth; i++) { const t = stack[i]; - if (t.flags & 2097152 /* Intersection */ ? some(t.types, (u) => getRecursionIdentity(u) === identity2) : getRecursionIdentity(t) === identity2) { + if (hasMatchingRecursionIdentity(t, identity2)) { if (t.id >= lastTypeId) { count++; if (count >= maxDepth) { @@ -62676,18 +62831,29 @@ function createTypeChecker(host) { } return false; } + function getMappedTargetWithSymbol(type) { + let target; + while ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */ && (target = getModifiersTypeFromMappedType(type)) && (target.symbol || target.flags & 2097152 /* Intersection */ && some(target.types, (t) => !!t.symbol))) { + type = target; + } + return type; + } + function hasMatchingRecursionIdentity(type, identity2) { + if ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */) { + type = getMappedTargetWithSymbol(type); + } + if (type.flags & 2097152 /* Intersection */) { + return some(type.types, (t) => hasMatchingRecursionIdentity(t, identity2)); + } + return getRecursionIdentity(type) === identity2; + } function getRecursionIdentity(type) { if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) { if (getObjectFlags(type) & 4 /* Reference */ && type.node) { return type.node; } - if (type.symbol) { - if (getObjectFlags(type) & 32 /* Mapped */) { - type = getMappedTargetWithSymbol(type); - } - if (!(getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) { - return type.symbol; - } + if (type.symbol && !(getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) { + return type.symbol; } if (isTupleType(type)) { return type.target; @@ -62707,13 +62873,6 @@ function createTypeChecker(host) { } return type; } - function getMappedTargetWithSymbol(type) { - let target = type; - while ((getObjectFlags(target) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */ && isMappedTypeWithKeyofConstraintDeclaration(target)) { - target = getModifiersTypeFromMappedType(target); - } - return target.symbol ? target : type; - } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; } @@ -62721,8 +62880,8 @@ function createTypeChecker(host) { if (sourceProp === targetProp) { return -1 /* True */; } - const sourcePropAccessibility = getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* NonPublicAccessibilityModifier */; - const targetPropAccessibility = getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* NonPublicAccessibilityModifier */; + const sourcePropAccessibility = getDeclarationModifierFlagsFromSymbol(sourceProp) & 6 /* NonPublicAccessibilityModifier */; + const targetPropAccessibility = getDeclarationModifierFlagsFromSymbol(targetProp) & 6 /* NonPublicAccessibilityModifier */; if (sourcePropAccessibility !== targetPropAccessibility) { return 0 /* False */; } @@ -65691,7 +65850,7 @@ function createTypeChecker(host) { return createFlowType(narrowedType, isIncomplete(flowType)); } function getTypeAtSwitchClause(flow) { - const expr = flow.switchStatement.expression; + const expr = skipParentheses(flow.switchStatement.expression); const flowType = getTypeAtFlowNode(flow.antecedent); let type = getTypeFromFlowType(flowType); if (isMatchingReference(reference, expr)) { @@ -65699,16 +65858,7 @@ function createTypeChecker(host) { } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else if (expr.kind === 112 /* TrueKeyword */) { - const clause = flow.switchStatement.caseBlock.clauses.find((_, index) => index === flow.clauseStart); - const clauseExpression = clause && clause.kind === 296 /* CaseClause */ ? clause.expression : void 0; - if (clauseExpression) { - type = narrowType( - type, - clauseExpression, - /*assumeTrue*/ - true - ); - } + type = narrowTypeBySwitchOnTrue(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { if (strictNullChecks) { if (optionalChainContainsReference(expr, reference)) { @@ -65868,13 +66018,15 @@ function createTypeChecker(host) { return void 0; } function getDiscriminantPropertyAccess(expr, computedType) { - const type = !(computedType.flags & 1048576 /* Union */) && declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; - if (type.flags & 1048576 /* Union */) { + if (declaredType.flags & 1048576 /* Union */ || computedType.flags & 1048576 /* Union */) { const access = getCandidateDiscriminantPropertyAccess(expr); if (access) { const name = getAccessedPropertyName(access); - if (name && isDiscriminantProperty(type, name)) { - return access; + if (name) { + const type = declaredType.flags & 1048576 /* Union */ && isTypeSubsetOf(computedType, declaredType) ? declaredType : computedType; + if (isDiscriminantProperty(type, name)) { + return access; + } } } } @@ -66254,6 +66406,42 @@ function createTypeChecker(host) { const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd); return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType)); } + function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) { + const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */); + const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd; + for (let i = 0; i < clauseStart; i++) { + const clause = switchStatement.caseBlock.clauses[i]; + if (clause.kind === 296 /* CaseClause */) { + type = narrowType( + type, + clause.expression, + /*assumeTrue*/ + false + ); + } + } + if (hasDefaultClause) { + for (let i = clauseEnd; i < switchStatement.caseBlock.clauses.length; i++) { + const clause = switchStatement.caseBlock.clauses[i]; + if (clause.kind === 296 /* CaseClause */) { + type = narrowType( + type, + clause.expression, + /*assumeTrue*/ + false + ); + } + } + return type; + } + const clauses = switchStatement.caseBlock.clauses.slice(clauseStart, clauseEnd); + return getUnionType(map(clauses, (clause) => clause.kind === 296 /* CaseClause */ ? narrowType( + type, + clause.expression, + /*assumeTrue*/ + true + ) : neverType)); + } function isMatchingConstructorReference(expr) { return (isPropertyAccessExpression(expr) && idText(expr.name) === "constructor" || isElementAccessExpression(expr) && isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") && isMatchingReference(reference, expr.expression); } @@ -66687,7 +66875,7 @@ function createTypeChecker(host) { if (languageVersion < 2 /* ES2015 */) { if (container.kind === 219 /* ArrowFunction */) { error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); - } else if (hasSyntacticModifier(container, 512 /* Async */)) { + } else if (hasSyntacticModifier(container, 1024 /* Async */)) { error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } @@ -67100,7 +67288,7 @@ function createTypeChecker(host) { let inAsyncFunction = false; if (!isCallExpression2) { while (container && container.kind === 219 /* ArrowFunction */) { - if (hasSyntacticModifier(container, 512 /* Async */)) + if (hasSyntacticModifier(container, 1024 /* Async */)) inAsyncFunction = true; container = getSuperContainer( container, @@ -67109,7 +67297,7 @@ function createTypeChecker(host) { ); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } - if (container && hasSyntacticModifier(container, 512 /* Async */)) + if (container && hasSyntacticModifier(container, 1024 /* Async */)) inAsyncFunction = true; } let nodeCheckFlag = 0; @@ -67252,7 +67440,7 @@ function createTypeChecker(host) { return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral)); } const parent = walkUpParenthesizedExpressions(func.parent); - if (parent.kind === 226 /* BinaryExpression */ && parent.operatorToken.kind === 64 /* EqualsToken */) { + if (isAssignmentExpression(parent)) { const target = parent.left; if (isAccessExpression(target)) { const { expression } = target; @@ -67441,7 +67629,24 @@ function createTypeChecker(host) { } const signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); if (signature && !isResolvingReturnTypeOfSignature(signature)) { - return getReturnTypeOfSignature(signature); + const returnType2 = getReturnTypeOfSignature(signature); + const functionFlags = getFunctionFlags(functionDecl); + if (functionFlags & 1 /* Generator */) { + return filterType(returnType2, (t) => { + return !!(t.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || checkGeneratorInstantiationAssignabilityToReturnType( + t, + functionFlags, + /*errorNode*/ + void 0 + ); + }); + } + if (functionFlags & 2 /* Async */) { + return filterType(returnType2, (t) => { + return !!(t.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || !!getAwaitedTypeOfPromise(t); + }); + } + return returnType2; } const iife = getImmediatelyInvokedFunctionExpression(functionDecl); if (iife) { @@ -68820,7 +69025,7 @@ function createTypeChecker(host) { } } const parent = openingLikeElement.parent.kind === 284 /* JsxElement */ ? openingLikeElement.parent : void 0; - if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { + if (parent && parent.openingElement === openingLikeElement && getSemanticJsxChildren(parent.children).length > 0) { const childrenTypes = checkJsxChildren(parent, checkMode); if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { if (explicitlySpecifyChildrenAttribute) { @@ -69297,20 +69502,20 @@ function createTypeChecker(host) { return false; } } - if (flags & 256 /* Abstract */) { + if (flags & 64 /* Abstract */) { if (errorNode) { error(errorNode, Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); } return false; } - if (!(flags & 32 /* Static */) && ((_a = prop.declarations) == null ? void 0 : _a.some(isClassInstanceProperty))) { + if (!(flags & 256 /* Static */) && ((_a = prop.declarations) == null ? void 0 : _a.some(isClassInstanceProperty))) { if (errorNode) { error(errorNode, Diagnostics.Class_field_0_defined_by_the_parent_class_is_not_accessible_in_the_child_class_via_super, symbolToString(prop)); } return false; } } - if (flags & 256 /* Abstract */ && symbolHasNonMethodDeclaration(prop) && (isThisProperty(location) || isThisInitializedObjectBindingExpression(location) || isObjectBindingPattern(location.parent) && isThisInitializedDeclaration(location.parent.parent))) { + if (flags & 64 /* Abstract */ && symbolHasNonMethodDeclaration(prop) && (isThisProperty(location) || isThisInitializedObjectBindingExpression(location) || isObjectBindingPattern(location.parent) && isThisInitializedDeclaration(location.parent.parent))) { const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(location)) { if (errorNode) { @@ -69319,10 +69524,10 @@ function createTypeChecker(host) { return false; } } - if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { + if (!(flags & 6 /* NonPublicAccessibilityModifier */)) { return true; } - if (flags & 8 /* Private */) { + if (flags & 2 /* Private */) { const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(location, declaringClassDeclaration)) { if (errorNode) { @@ -69342,14 +69547,14 @@ function createTypeChecker(host) { if (!enclosingClass) { enclosingClass = getEnclosingClassFromThisParameter(location); enclosingClass = enclosingClass && isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing); - if (flags & 32 /* Static */ || !enclosingClass) { + if (flags & 256 /* Static */ || !enclosingClass) { if (errorNode) { error(errorNode, Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || containingType)); } return false; } } - if (flags & 32 /* Static */) { + if (flags & 256 /* Static */) { return true; } if (containingType.flags & 262144 /* TypeParameter */) { @@ -69769,7 +69974,7 @@ function createTypeChecker(host) { } let diagnosticMessage; const declarationName = idText(right); - if (isInPropertyInitializerOrClassStaticBlock(node) && !isOptionalPropertyDeclaration(valueDeclaration) && !(isAccessExpression(node) && isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !(isMethodDeclaration(valueDeclaration) && getCombinedModifierFlagsCached(valueDeclaration) & 32 /* Static */) && (useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { + if (isInPropertyInitializerOrClassStaticBlock(node) && !isOptionalPropertyDeclaration(valueDeclaration) && !(isAccessExpression(node) && isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !(isMethodDeclaration(valueDeclaration) && getCombinedModifierFlagsCached(valueDeclaration) & 256 /* Static */) && (useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } else if (valueDeclaration.kind === 263 /* ClassDeclaration */ && node.parent.kind !== 183 /* TypeReference */ && !(valueDeclaration.flags & 33554432 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -70023,7 +70228,7 @@ function createTypeChecker(host) { if (!valueDeclaration) { return; } - const hasPrivateModifier = hasEffectiveModifier(valueDeclaration, 8 /* Private */); + const hasPrivateModifier = hasEffectiveModifier(valueDeclaration, 2 /* Private */); const hasPrivateIdentifier = prop.valueDeclaration && isNamedDeclaration(prop.valueDeclaration) && isPrivateIdentifier(prop.valueDeclaration.name); if (!hasPrivateModifier && !hasPrivateIdentifier) { return; @@ -70443,9 +70648,11 @@ function createTypeChecker(host) { } if (arg.kind === 237 /* SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); + } else { + names.push(void 0); } } - return createTupleType(types, flags, inConstContext && !someType(restType, isMutableArrayLikeType), length(names) === length(types) ? names : void 0); + return createTupleType(types, flags, inConstContext && !someType(restType, isMutableArrayLikeType), names); } function checkTypeArguments(signature, typeArgumentNodes, reportErrors2, headMessage) { const isJavascript = isInJSFile(signature.declaration); @@ -71466,7 +71673,7 @@ function createTypeChecker(host) { return resolveErrorCall(node); } const valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && hasSyntacticModifier(valueDecl, 256 /* Abstract */)) { + if (valueDecl && hasSyntacticModifier(valueDecl, 64 /* Abstract */)) { error(node, Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } @@ -71529,7 +71736,7 @@ function createTypeChecker(host) { return true; } const declaration = signature.declaration; - const modifiers = getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); + const modifiers = getSelectedEffectiveModifierFlags(declaration, 6 /* NonPublicAccessibilityModifier */); if (!modifiers || declaration.kind !== 176 /* Constructor */) { return true; } @@ -71537,16 +71744,16 @@ function createTypeChecker(host) { const declaringClass = getDeclaredTypeOfSymbol(declaration.parent.symbol); if (!isNodeWithinClass(node, declaringClassDeclaration)) { const containingClass = getContainingClass(node); - if (containingClass && modifiers & 16 /* Protected */) { + if (containingClass && modifiers & 4 /* Protected */) { const containingType = getTypeOfNode(containingClass); if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) { return true; } } - if (modifiers & 8 /* Private */) { + if (modifiers & 2 /* Private */) { error(node, Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } - if (modifiers & 16 /* Protected */) { + if (modifiers & 4 /* Protected */) { error(node, Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } return false; @@ -72580,12 +72787,9 @@ function createTypeChecker(host) { types.push(restType); flags.push(8 /* Variadic */); } - const name = getNameableDeclarationAtPosition(source, i); - if (name) { - names.push(name); - } + names.push(getNameableDeclarationAtPosition(source, i)); } - return createTupleType(types, flags, readonly, length(names) === length(types) ? names : void 0); + return createTupleType(types, flags, readonly, names); } function getParameterCount(signature) { const length2 = signature.parameters.length; @@ -73281,8 +73485,20 @@ function createTypeChecker(host) { let hasReturnWithNoExpression = functionHasImplicitReturn(func); let hasReturnOfTypeNever = false; forEachReturnStatement(func.body, (returnStatement) => { - const expr = returnStatement.expression; + let expr = returnStatement.expression; if (expr) { + expr = skipParentheses( + expr, + /*excludeJSDocTypeAssertions*/ + true + ); + if (functionFlags & 2 /* Async */ && expr.kind === 223 /* AwaitExpression */) { + expr = skipParentheses( + expr.expression, + /*excludeJSDocTypeAssertions*/ + true + ); + } if (expr.kind === 213 /* CallExpression */ && expr.expression.kind === 80 /* Identifier */ && checkExpressionCached(expr.expression).symbol === func.symbol) { hasReturnOfTypeNever = true; return; @@ -73514,7 +73730,7 @@ function createTypeChecker(host) { return !setProp; } function isReadonlySymbol(symbol) { - return !!(getCheckFlags(symbol) & 8 /* Readonly */ || symbol.flags & 4 /* Property */ && getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 6 /* Constant */ || symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || symbol.flags & 8 /* EnumMember */ || some(symbol.declarations, isReadonlyAssignmentDeclaration)); + return !!(getCheckFlags(symbol) & 8 /* Readonly */ || symbol.flags & 4 /* Property */ && getDeclarationModifierFlagsFromSymbol(symbol) & 8 /* Readonly */ || symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 6 /* Constant */ || symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || symbol.flags & 8 /* EnumMember */ || some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) { var _a, _b; @@ -73595,7 +73811,7 @@ function createTypeChecker(host) { return typeofType; } function checkVoidExpression(node) { - checkExpression(node.expression); + checkNodeDeferred(node); return undefinedWideningType; } function checkAwaitGrammar(node) { @@ -74631,7 +74847,15 @@ function createTypeChecker(host) { checkExternalEmitHelpers(node, 256 /* Values */); } } - const returnType = getReturnTypeFromAnnotation(func); + let returnType = getReturnTypeFromAnnotation(func); + if (returnType && returnType.flags & 1048576 /* Union */) { + returnType = filterType(returnType, (t) => checkGeneratorInstantiationAssignabilityToReturnType( + t, + functionFlags, + /*errorNode*/ + void 0 + )); + } const iterationTypes = returnType && getIterationTypesOfGeneratorFunctionReturnType(returnType, isAsync); const signatureYieldType = iterationTypes && iterationTypes.yieldType || anyType; const signatureNextType = iterationTypes && iterationTypes.nextType || anyType; @@ -75252,15 +75476,15 @@ function createTypeChecker(host) { var _a, _b; if (isInterfaceDeclaration(node.parent) || isClassLike(node.parent) || isTypeAliasDeclaration(node.parent)) { const typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfDeclaration(node)); - const modifiers = getTypeParameterModifiers(typeParameter) & (32768 /* In */ | 65536 /* Out */); + const modifiers = getTypeParameterModifiers(typeParameter) & (8192 /* In */ | 16384 /* Out */); if (modifiers) { const symbol = getSymbolOfDeclaration(node.parent); if (isTypeAliasDeclaration(node.parent) && !(getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) { error(node, Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types); - } else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) { + } else if (modifiers === 8192 /* In */ || modifiers === 16384 /* Out */) { (_a = tracing) == null ? void 0 : _a.push(tracing.Phase.CheckTypes, "checkTypeParameterDeferred", { parent: getTypeId(getDeclaredTypeOfSymbol(symbol)), id: getTypeId(typeParameter) }); - const source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck); - const target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck); + const source = createMarkerType(symbol, typeParameter, modifiers === 16384 /* Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck); + const target = createMarkerType(symbol, typeParameter, modifiers === 16384 /* Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck); const saveVarianceTypeParameter = typeParameter; varianceTypeParameter = typeParameter; checkTypeAssignableTo(source, target, node, Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); @@ -75274,7 +75498,7 @@ function createTypeChecker(host) { checkGrammarModifiers(node); checkVariableLikeDeclaration(node); const func = getContainingFunction(node); - if (hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (hasSyntacticModifier(node, 31 /* ParameterPropertyModifier */)) { if (!(func.kind === 176 /* Constructor */ && nodeIsPresent(func.body))) { error(node, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } @@ -75444,11 +75668,7 @@ function createTypeChecker(host) { if (returnType === voidType) { error(returnTypeErrorLocation, Diagnostics.A_generator_cannot_have_a_void_type_annotation); } else { - const generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || anyType; - const generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || generatorYieldType; - const generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || unknownType; - const generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags2 & 2 /* Async */)); - checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeErrorLocation); + checkGeneratorInstantiationAssignabilityToReturnType(returnType, functionFlags2, returnTypeErrorLocation); } } else if ((functionFlags2 & 3 /* AsyncGenerator */) === 2 /* Async */) { checkAsyncFunctionReturnType(node, returnTypeNode, returnTypeErrorLocation); @@ -75459,6 +75679,13 @@ function createTypeChecker(host) { } } } + function checkGeneratorInstantiationAssignabilityToReturnType(returnType, functionFlags, errorNode) { + const generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags & 2 /* Async */) !== 0) || anyType; + const generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags & 2 /* Async */) !== 0) || generatorYieldType; + const generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags & 2 /* Async */) !== 0) || unknownType; + const generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags & 2 /* Async */)); + return checkTypeAssignableTo(generatorInstantiation, returnType, errorNode); + } function checkClassForDuplicateDeclarations(node) { const instanceNames = /* @__PURE__ */ new Map(); const staticNames = /* @__PURE__ */ new Map(); @@ -75606,7 +75833,7 @@ function createTypeChecker(host) { checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); setNodeLinksForPrivateIdentifierScope(node); - if (hasSyntacticModifier(node, 256 /* Abstract */) && node.kind === 172 /* PropertyDeclaration */ && node.initializer) { + if (hasSyntacticModifier(node, 64 /* Abstract */) && node.kind === 172 /* PropertyDeclaration */ && node.initializer) { error(node, Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, declarationNameToString(node.name)); } } @@ -75623,7 +75850,7 @@ function createTypeChecker(host) { error(node.name, Diagnostics.Class_constructor_may_not_be_a_generator); } checkFunctionOrMethodDeclaration(node); - if (hasSyntacticModifier(node, 256 /* Abstract */) && node.kind === 174 /* MethodDeclaration */ && node.body) { + if (hasSyntacticModifier(node, 64 /* Abstract */) && node.kind === 174 /* MethodDeclaration */ && node.body) { error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)); } if (isPrivateIdentifier(node.name) && !getContainingClass(node)) { @@ -75680,7 +75907,7 @@ function createTypeChecker(host) { if (classExtendsNull) { error(superCall, Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); } - const superCallShouldBeRootLevel = !emitStandardClassFields && (some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || some(node.parameters, (p) => hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */))); + const superCallShouldBeRootLevel = !emitStandardClassFields && (some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || some(node.parameters, (p) => hasSyntacticModifier(p, 31 /* ParameterPropertyModifier */))); if (superCallShouldBeRootLevel) { if (!superCallIsRootLevelInConstructor(superCall, node.body)) { error(superCall, Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers); @@ -75749,11 +75976,11 @@ function createTypeChecker(host) { getNodeLinks(getter).flags |= 1 /* TypeChecked */; const getterFlags = getEffectiveModifierFlags(getter); const setterFlags = getEffectiveModifierFlags(setter); - if ((getterFlags & 256 /* Abstract */) !== (setterFlags & 256 /* Abstract */)) { + if ((getterFlags & 64 /* Abstract */) !== (setterFlags & 64 /* Abstract */)) { error(getter.name, Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); error(setter.name, Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } - if (getterFlags & 16 /* Protected */ && !(setterFlags & (16 /* Protected */ | 8 /* Private */)) || getterFlags & 8 /* Private */ && !(setterFlags & 8 /* Private */)) { + if (getterFlags & 4 /* Protected */ && !(setterFlags & (4 /* Protected */ | 2 /* Private */)) || getterFlags & 2 /* Private */ && !(setterFlags & 2 /* Private */)) { error(getter.name, Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); error(setter.name, Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); } @@ -75933,7 +76160,7 @@ function createTypeChecker(host) { const propertyName = getPropertyNameFromIndex(indexType, accessNode); if (propertyName) { const propertySymbol = forEachType(apparentObjectType, (t) => getPropertyOfType(t, propertyName)); - if (propertySymbol && getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* NonPublicAccessibilityModifier */) { + if (propertySymbol && getDeclarationModifierFlagsFromSymbol(propertySymbol) & 6 /* NonPublicAccessibilityModifier */) { error(accessNode, Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, unescapeLeadingUnderscores(propertyName)); return errorType; } @@ -76031,16 +76258,16 @@ function createTypeChecker(host) { getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return (hasEffectiveModifier(node, 8 /* Private */) || isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 33554432 /* Ambient */); + return (hasEffectiveModifier(node, 2 /* Private */) || isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 33554432 /* Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { let flags = getCombinedModifierFlagsCached(n); if (n.parent.kind !== 264 /* InterfaceDeclaration */ && n.parent.kind !== 263 /* ClassDeclaration */ && n.parent.kind !== 231 /* ClassExpression */ && n.flags & 33554432 /* Ambient */) { const container = getEnclosingContainer(n); - if (container && container.flags & 128 /* ExportContext */ && !(flags & 2 /* Ambient */) && !(isModuleBlock(n.parent) && isModuleDeclaration(n.parent.parent) && isGlobalScopeAugmentation(n.parent.parent))) { - flags |= 1 /* Export */; + if (container && container.flags & 128 /* ExportContext */ && !(flags & 128 /* Ambient */) && !(isModuleBlock(n.parent) && isModuleDeclaration(n.parent.parent) && isGlobalScopeAugmentation(n.parent.parent))) { + flags |= 32 /* Export */; } - flags |= 2 /* Ambient */; + flags |= 128 /* Ambient */; } return flags & flagsToCheck; } @@ -76058,13 +76285,13 @@ function createTypeChecker(host) { const canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck2); forEach(overloads, (o) => { const deviation = getEffectiveDeclarationFlags(o, flagsToCheck2) ^ canonicalFlags; - if (deviation & 1 /* Export */) { + if (deviation & 32 /* Export */) { error(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); - } else if (deviation & 2 /* Ambient */) { + } else if (deviation & 128 /* Ambient */) { error(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); - } else if (deviation & (8 /* Private */ | 16 /* Protected */)) { + } else if (deviation & (2 /* Private */ | 4 /* Protected */)) { error(getNameOfDeclaration(o) || o, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); - } else if (deviation & 256 /* Abstract */) { + } else if (deviation & 64 /* Abstract */) { error(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); @@ -76081,7 +76308,7 @@ function createTypeChecker(host) { }); } } - const flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 8 /* Private */ | 16 /* Protected */ | 256 /* Abstract */; + const flagsToCheck = 32 /* Export */ | 128 /* Ambient */ | 2 /* Private */ | 4 /* Protected */ | 64 /* Abstract */; let someNodeFlags = 0 /* None */; let allNodeFlags = flagsToCheck; let someHaveQuestionToken = false; @@ -76129,7 +76356,7 @@ function createTypeChecker(host) { if (isConstructor) { error(errorNode, Diagnostics.Constructor_implementation_is_missing); } else { - if (hasSyntacticModifier(node, 256 /* Abstract */)) { + if (hasSyntacticModifier(node, 64 /* Abstract */)) { error(errorNode, Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { error(errorNode, Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); @@ -76215,7 +76442,7 @@ function createTypeChecker(host) { } }); } - if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !hasSyntacticModifier(lastSeenNonAmbientDeclaration, 256 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { + if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !hasSyntacticModifier(lastSeenNonAmbientDeclaration, 64 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -76258,9 +76485,9 @@ function createTypeChecker(host) { let defaultExportedDeclarationSpaces = 0 /* None */; for (const d of symbol.declarations) { const declarationSpaces = getDeclarationSpaces(d); - const effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 1024 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 1024 /* Default */) { + const effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 32 /* Export */ | 2048 /* Default */); + if (effectiveDeclarationFlags & 32 /* Export */) { + if (effectiveDeclarationFlags & 2048 /* Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { exportedDeclarationSpaces |= declarationSpaces; @@ -76901,6 +77128,12 @@ function createTypeChecker(host) { } } } + function checkJSDocThisTag(node) { + const host2 = getEffectiveJSDocHost(node); + if (host2 && isArrowFunction(host2)) { + error(node.tagName, Diagnostics.An_arrow_function_cannot_have_a_this_parameter); + } + } function checkJSDocImplementsTag(node) { const classLike = getEffectiveJSDocHost(node); if (!classLike || !isClassDeclaration(classLike) && !isClassExpression(classLike)) { @@ -77063,13 +77296,13 @@ function createTypeChecker(host) { break; } const symbol = getSymbolOfDeclaration(member); - if (!symbol.isReferenced && (hasEffectiveModifier(member, 8 /* Private */) || isNamedDeclaration(member) && isPrivateIdentifier(member.name)) && !(member.flags & 33554432 /* Ambient */)) { + if (!symbol.isReferenced && (hasEffectiveModifier(member, 2 /* Private */) || isNamedDeclaration(member) && isPrivateIdentifier(member.name)) && !(member.flags & 33554432 /* Ambient */)) { addDiagnostic(member, 0 /* Local */, createDiagnosticForNode(member.name, Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; case 176 /* Constructor */: for (const parameter of member.parameters) { - if (!parameter.symbol.isReferenced && hasSyntacticModifier(parameter, 8 /* Private */)) { + if (!parameter.symbol.isReferenced && hasSyntacticModifier(parameter, 2 /* Private */)) { addDiagnostic(parameter, 0 /* Local */, createDiagnosticForNode(parameter.name, Diagnostics.Property_0_is_declared_but_its_value_is_never_read, symbolName(parameter.symbol))); } } @@ -77515,7 +77748,7 @@ function createTypeChecker(host) { } forEach(node.name.elements, checkSourceElement); } - if (isParameter(node) && node.initializer && nodeIsMissing(getContainingFunction(node).body)) { + if (node.initializer && isParameterDeclaration(node) && nodeIsMissing(getContainingFunction(node).body)) { error(node, Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -77645,7 +77878,7 @@ function createTypeChecker(host) { if (hasQuestionToken(left) !== hasQuestionToken(right)) { return false; } - const interestingFlags = 8 /* Private */ | 16 /* Protected */ | 512 /* Async */ | 256 /* Abstract */ | 64 /* Readonly */ | 32 /* Static */; + const interestingFlags = 2 /* Private */ | 4 /* Protected */ | 1024 /* Async */ | 64 /* Abstract */ | 8 /* Readonly */ | 256 /* Static */; return getSelectedEffectiveModifierFlags(left, interestingFlags) === getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { @@ -78973,7 +79206,7 @@ function createTypeChecker(host) { if (legacyDecorators && firstDecorator && some(node.members, (p) => hasStaticModifier(p) && isPrivateIdentifierClassElementDeclaration(p))) { grammarErrorOnNode(firstDecorator, Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); } - if (!node.name && !hasSyntacticModifier(node, 1024 /* Default */)) { + if (!node.name && !hasSyntacticModifier(node, 2048 /* Default */)) { grammarErrorOnFirstToken(node, Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -79039,7 +79272,7 @@ function createTypeChecker(host) { error(node.name || node, Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } else { const constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); - if (constructSignatures.some((signature) => signature.flags & 4 /* Abstract */) && !hasSyntacticModifier(node, 256 /* Abstract */)) { + if (constructSignatures.some((signature) => signature.flags & 4 /* Abstract */) && !hasSyntacticModifier(node, 64 /* Abstract */)) { error(node.name || node, Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract); } } @@ -79253,7 +79486,7 @@ function createTypeChecker(host) { const signatures = getSignaturesOfType(type, 1 /* Construct */); if (signatures.length) { const declaration = signatures[0].declaration; - if (declaration && hasEffectiveModifier(declaration, 8 /* Private */)) { + if (declaration && hasEffectiveModifier(declaration, 2 /* Private */)) { const typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error(node, Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -79273,7 +79506,7 @@ function createTypeChecker(host) { const baseTypes = baseTypeNode && getBaseTypes(type); const baseWithThis = (baseTypes == null ? void 0 : baseTypes.length) ? getTypeWithThisArgument(first(baseTypes), type.thisType) : void 0; const baseStaticType = getBaseConstructorTypeOfClass(type); - const memberHasOverrideModifier = member.parent ? hasOverrideModifier(member) : hasSyntacticModifier(member, 16384 /* Override */); + const memberHasOverrideModifier = member.parent ? hasOverrideModifier(member) : hasSyntacticModifier(member, 16 /* Override */); return checkMemberForOverrideModifier( node, staticType, @@ -79314,7 +79547,7 @@ function createTypeChecker(host) { Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived === base) { const derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); - if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !hasSyntacticModifier(derivedClassDecl, 256 /* Abstract */))) { + if (baseDeclarationFlags & 64 /* Abstract */ && (!derivedClassDecl || !hasSyntacticModifier(derivedClassDecl, 64 /* Abstract */))) { for (const otherBaseType of getBaseTypes(type)) { if (otherBaseType === baseType) continue; @@ -79357,7 +79590,7 @@ function createTypeChecker(host) { } } else { const derivedDeclarationFlags = getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + if (baseDeclarationFlags & 2 /* Private */ || derivedDeclarationFlags & 2 /* Private */) { continue; } let errorMessage; @@ -79374,7 +79607,7 @@ function createTypeChecker(host) { error(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage2, symbolToString(base), typeToString(baseType), typeToString(type)); } else if (useDefineForClassFields) { const uninitialized = (_c = derived.declarations) == null ? void 0 : _c.find((d) => d.kind === 172 /* PropertyDeclaration */ && !d.initializer); - if (uninitialized && !(derived.flags & 33554432 /* Transient */) && !(baseDeclarationFlags & 256 /* Abstract */) && !(derivedDeclarationFlags & 256 /* Abstract */) && !((_d = derived.declarations) == null ? void 0 : _d.some((d) => !!(d.flags & 33554432 /* Ambient */)))) { + if (uninitialized && !(derived.flags & 33554432 /* Transient */) && !(baseDeclarationFlags & 64 /* Abstract */) && !(derivedDeclarationFlags & 64 /* Abstract */) && !((_d = derived.declarations) == null ? void 0 : _d.some((d) => !!(d.flags & 33554432 /* Ambient */)))) { const constructor = findConstructorDeclaration(getClassLikeDeclarationOfSymbol(type.symbol)); const propName = uninitialized.name; if (uninitialized.exclamationToken || !constructor || !isIdentifier(propName) || !strictNullChecks || !isPropertyInitializedInConstructor(propName, type, constructor)) { @@ -79401,7 +79634,7 @@ function createTypeChecker(host) { } } function isPropertyAbstractOrInterface(declaration, baseDeclarationFlags) { - return baseDeclarationFlags & 256 /* Abstract */ && (!isPropertyDeclaration(declaration) || !declaration.initializer) || isInterfaceDeclaration(declaration.parent); + return baseDeclarationFlags & 64 /* Abstract */ && (!isPropertyDeclaration(declaration) || !declaration.initializer) || isInterfaceDeclaration(declaration.parent); } function getNonInheritedProperties(type, baseTypes, properties) { if (!length(baseTypes)) { @@ -79466,7 +79699,7 @@ function createTypeChecker(host) { } const constructor = findConstructorDeclaration(node); for (const member of node.members) { - if (getEffectiveModifierFlags(member) & 2 /* Ambient */) { + if (getEffectiveModifierFlags(member) & 128 /* Ambient */) { continue; } if (!isStatic(member) && isPropertyWithoutInitializer(member)) { @@ -80053,7 +80286,7 @@ function createTypeChecker(host) { name ); } - if (isType && node.kind === 271 /* ImportEqualsDeclaration */ && hasEffectiveModifier(node, 1 /* Export */)) { + if (isType && node.kind === 271 /* ImportEqualsDeclaration */ && hasEffectiveModifier(node, 32 /* Export */)) { error(node, Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_0_is_enabled, isolatedModulesLikeFlagName); } break; @@ -80175,7 +80408,7 @@ function createTypeChecker(host) { checkGrammarModifiers(node); if (isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { markExportAsReferenced(node); } if (node.moduleReference.kind !== 283 /* ExternalModuleReference */) { @@ -80587,6 +80820,8 @@ function createTypeChecker(host) { return checkJSDocAccessibilityModifiers(node); case 357 /* JSDocSatisfiesTag */: return checkJSDocSatisfiesTag(node); + case 350 /* JSDocThisTag */: + return checkJSDocThisTag(node); case 199 /* IndexedAccessType */: return checkIndexedAccessType(node); case 200 /* MappedType */: @@ -80791,6 +81026,9 @@ function createTypeChecker(host) { case 217 /* ParenthesizedExpression */: checkAssertionDeferred(node); break; + case 222 /* VoidExpression */: + checkExpression(node.expression); + break; case 226 /* BinaryExpression */: if (isInstanceOfExpression(node)) { resolveUntypedCall(node); @@ -81810,7 +82048,7 @@ function createTypeChecker(host) { return true; } const target = getSymbolLinks(symbol).aliasTarget; - if (target && getEffectiveModifierFlags(node) & 1 /* Export */ && getSymbolFlags(target) & 111551 /* Value */ && (shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { + if (target && getEffectiveModifierFlags(node) & 32 /* Export */ && getSymbolFlags(target) & 111551 /* Value */ && (shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { return true; } } @@ -81835,10 +82073,10 @@ function createTypeChecker(host) { return false; } function isRequiredInitializedParameter(parameter) { - return !!strictNullChecks && !isOptionalParameter(parameter) && !isJSDocParameterTag(parameter) && !!parameter.initializer && !hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + return !!strictNullChecks && !isOptionalParameter(parameter) && !isJSDocParameterTag(parameter) && !!parameter.initializer && !hasSyntacticModifier(parameter, 31 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { - return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && hasSyntacticModifier(parameter, 31 /* ParameterPropertyModifier */); } function isExpandoFunctionDeclaration(node) { const declaration = getParseTreeNode(node, isFunctionDeclaration); @@ -82259,7 +82497,16 @@ function createTypeChecker(host) { } return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); }, - isImportRequiredByAugmentation + isImportRequiredByAugmentation, + tryFindAmbientModule: (moduleReferenceExpression) => { + const node = getParseTreeNode(moduleReferenceExpression); + const moduleSpecifier = node && isStringLiteralLike(node) ? node.text : void 0; + return moduleSpecifier !== void 0 ? tryFindAmbientModule( + moduleSpecifier, + /*withAugmentations*/ + true + ) : void 0; + } }; function isImportRequiredByAugmentation(node) { const file = getSourceFileOfNode(node); @@ -82683,10 +82930,10 @@ function createTypeChecker(host) { return grammarErrorOnFirstToken(node, Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); } } - if (flags & ~(1025 /* ExportDefault */ | 131072 /* Decorator */)) { + if (flags & ~(2080 /* ExportDefault */ | 32768 /* Decorator */)) { return grammarErrorOnNode(modifier, Diagnostics.Decorators_are_not_valid_here); } - if (hasLeadingDecorators && flags & 126975 /* Modifier */) { + if (hasLeadingDecorators && flags & 98303 /* Modifier */) { Debug.assertIsDefined(firstDecorator); const sourceFile = getSourceFileOfNode(modifier); if (!hasParseDiagnostics(sourceFile)) { @@ -82698,10 +82945,10 @@ function createTypeChecker(host) { } return false; } - flags |= 131072 /* Decorator */; - if (!(flags & 126975 /* Modifier */)) { + flags |= 32768 /* Decorator */; + if (!(flags & 98303 /* Modifier */)) { hasLeadingDecorators = true; - } else if (flags & 1 /* Export */) { + } else if (flags & 32 /* Export */) { sawExportBeforeDecorators = true; } firstDecorator ?? (firstDecorator = modifier); @@ -82730,39 +82977,39 @@ function createTypeChecker(host) { } break; case 164 /* OverrideKeyword */: - if (flags & 16384 /* Override */) { + if (flags & 16 /* Override */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "override"); - } else if (flags & 2 /* Ambient */) { + } else if (flags & 128 /* Ambient */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); - } else if (flags & 64 /* Readonly */) { + } else if (flags & 8 /* Readonly */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); - } else if (flags & 128 /* Accessor */) { + } else if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "override", "accessor"); - } else if (flags & 512 /* Async */) { + } else if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); } - flags |= 16384 /* Override */; + flags |= 16 /* Override */; lastOverride = modifier; break; case 125 /* PublicKeyword */: case 124 /* ProtectedKeyword */: case 123 /* PrivateKeyword */: const text = visibilityToString(modifierToFlag(modifier.kind)); - if (flags & 28 /* AccessibilityModifier */) { + if (flags & 7 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, Diagnostics.Accessibility_modifier_already_seen); - } else if (flags & 16384 /* Override */) { + } else if (flags & 16 /* Override */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); - } else if (flags & 32 /* Static */) { + } else if (flags & 256 /* Static */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); - } else if (flags & 128 /* Accessor */) { + } else if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "accessor"); - } else if (flags & 64 /* Readonly */) { + } else if (flags & 8 /* Readonly */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly"); - } else if (flags & 512 /* Async */) { + } else if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } else if (node.parent.kind === 268 /* ModuleBlock */ || node.parent.kind === 312 /* SourceFile */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); - } else if (flags & 256 /* Abstract */) { + } else if (flags & 64 /* Abstract */) { if (modifier.kind === 123 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -82774,60 +83021,60 @@ function createTypeChecker(host) { flags |= modifierToFlag(modifier.kind); break; case 126 /* StaticKeyword */: - if (flags & 32 /* Static */) { + if (flags & 256 /* Static */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "static"); - } else if (flags & 64 /* Readonly */) { + } else if (flags & 8 /* Readonly */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly"); - } else if (flags & 512 /* Async */) { + } else if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); - } else if (flags & 128 /* Accessor */) { + } else if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "accessor"); } else if (node.parent.kind === 268 /* ModuleBlock */ || node.parent.kind === 312 /* SourceFile */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 169 /* Parameter */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); - } else if (flags & 256 /* Abstract */) { + } else if (flags & 64 /* Abstract */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); - } else if (flags & 16384 /* Override */) { + } else if (flags & 16 /* Override */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } - flags |= 32 /* Static */; + flags |= 256 /* Static */; lastStatic = modifier; break; case 129 /* AccessorKeyword */: - if (flags & 128 /* Accessor */) { + if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "accessor"); - } else if (flags & 64 /* Readonly */) { + } else if (flags & 8 /* Readonly */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "accessor", "readonly"); - } else if (flags & 2 /* Ambient */) { + } else if (flags & 128 /* Ambient */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "accessor", "declare"); } else if (node.kind !== 172 /* PropertyDeclaration */) { return grammarErrorOnNode(modifier, Diagnostics.accessor_modifier_can_only_appear_on_a_property_declaration); } - flags |= 128 /* Accessor */; + flags |= 512 /* Accessor */; break; case 148 /* ReadonlyKeyword */: - if (flags & 64 /* Readonly */) { + if (flags & 8 /* Readonly */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "readonly"); } else if (node.kind !== 172 /* PropertyDeclaration */ && node.kind !== 171 /* PropertySignature */ && node.kind !== 181 /* IndexSignature */ && node.kind !== 169 /* Parameter */) { return grammarErrorOnNode(modifier, Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); - } else if (flags & 128 /* Accessor */) { + } else if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "readonly", "accessor"); } - flags |= 64 /* Readonly */; + flags |= 8 /* Readonly */; break; case 95 /* ExportKeyword */: if (compilerOptions.verbatimModuleSyntax && !(node.flags & 33554432 /* Ambient */) && node.kind !== 265 /* TypeAliasDeclaration */ && node.kind !== 264 /* InterfaceDeclaration */ && // ModuleDeclaration needs to be checked that it is uninstantiated later node.kind !== 267 /* ModuleDeclaration */ && node.parent.kind === 312 /* SourceFile */ && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) { return grammarErrorOnNode(modifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled); } - if (flags & 1 /* Export */) { + if (flags & 32 /* Export */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "export"); - } else if (flags & 2 /* Ambient */) { + } else if (flags & 128 /* Ambient */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); - } else if (flags & 256 /* Abstract */) { + } else if (flags & 64 /* Abstract */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); - } else if (flags & 512 /* Async */) { + } else if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (isClassLike(node.parent)) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export"); @@ -82838,7 +83085,7 @@ function createTypeChecker(host) { } else if (blockScopeKind === 6 /* AwaitUsing */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_an_await_using_declaration, "export"); } - flags |= 1 /* Export */; + flags |= 32 /* Export */; break; case 90 /* DefaultKeyword */: const container = node.parent.kind === 312 /* SourceFile */ ? node.parent : node.parent.parent; @@ -82848,19 +83095,19 @@ function createTypeChecker(host) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_using_declaration, "default"); } else if (blockScopeKind === 6 /* AwaitUsing */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_an_await_using_declaration, "default"); - } else if (!(flags & 1 /* Export */)) { + } else if (!(flags & 32 /* Export */)) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "default"); } else if (sawExportBeforeDecorators) { return grammarErrorOnNode(firstDecorator, Diagnostics.Decorators_are_not_valid_here); } - flags |= 1024 /* Default */; + flags |= 2048 /* Default */; break; case 138 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { + if (flags & 128 /* Ambient */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "declare"); - } else if (flags & 512 /* Async */) { + } else if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); - } else if (flags & 16384 /* Override */) { + } else if (flags & 16 /* Override */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "override"); } else if (isClassLike(node.parent) && !isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare"); @@ -82874,62 +83121,62 @@ function createTypeChecker(host) { return grammarErrorOnNode(modifier, Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } else if (isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); - } else if (flags & 128 /* Accessor */) { + } else if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "declare", "accessor"); } - flags |= 2 /* Ambient */; + flags |= 128 /* Ambient */; lastDeclare = modifier; break; case 128 /* AbstractKeyword */: - if (flags & 256 /* Abstract */) { + if (flags & 64 /* Abstract */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "abstract"); } if (node.kind !== 263 /* ClassDeclaration */ && node.kind !== 185 /* ConstructorType */) { if (node.kind !== 174 /* MethodDeclaration */ && node.kind !== 172 /* PropertyDeclaration */ && node.kind !== 177 /* GetAccessor */ && node.kind !== 178 /* SetAccessor */) { return grammarErrorOnNode(modifier, Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 263 /* ClassDeclaration */ && hasSyntacticModifier(node.parent, 256 /* Abstract */))) { + if (!(node.parent.kind === 263 /* ClassDeclaration */ && hasSyntacticModifier(node.parent, 64 /* Abstract */))) { const message = node.kind === 172 /* PropertyDeclaration */ ? Diagnostics.Abstract_properties_can_only_appear_within_an_abstract_class : Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class; return grammarErrorOnNode(modifier, message); } - if (flags & 32 /* Static */) { + if (flags & 256 /* Static */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 8 /* Private */) { + if (flags & 2 /* Private */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } - if (flags & 512 /* Async */ && lastAsync) { + if (flags & 1024 /* Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - if (flags & 16384 /* Override */) { + if (flags & 16 /* Override */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); } - if (flags & 128 /* Accessor */) { + if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "accessor"); } } if (isNamedDeclaration(node) && node.name.kind === 81 /* PrivateIdentifier */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } - flags |= 256 /* Abstract */; + flags |= 64 /* Abstract */; break; case 134 /* AsyncKeyword */: - if (flags & 512 /* Async */) { + if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "async"); - } else if (flags & 2 /* Ambient */ || node.parent.flags & 33554432 /* Ambient */) { + } else if (flags & 128 /* Ambient */ || node.parent.flags & 33554432 /* Ambient */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (node.kind === 169 /* Parameter */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - if (flags & 256 /* Abstract */) { + if (flags & 64 /* Abstract */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - flags |= 512 /* Async */; + flags |= 1024 /* Async */; lastAsync = modifier; break; case 103 /* InKeyword */: case 147 /* OutKeyword */: - const inOutFlag = modifier.kind === 103 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */; + const inOutFlag = modifier.kind === 103 /* InKeyword */ ? 8192 /* In */ : 16384 /* Out */; const inOutText = modifier.kind === 103 /* InKeyword */ ? "in" : "out"; if (node.kind !== 168 /* TypeParameter */ || !(isInterfaceDeclaration(node.parent) || isClassLike(node.parent) || isTypeAliasDeclaration(node.parent))) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText); @@ -82937,7 +83184,7 @@ function createTypeChecker(host) { if (flags & inOutFlag) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, inOutText); } - if (inOutFlag & 32768 /* In */ && flags & 65536 /* Out */) { + if (inOutFlag & 8192 /* In */ && flags & 16384 /* Out */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "in", "out"); } flags |= inOutFlag; @@ -82946,24 +83193,24 @@ function createTypeChecker(host) { } } if (node.kind === 176 /* Constructor */) { - if (flags & 32 /* Static */) { + if (flags & 256 /* Static */) { return grammarErrorOnNode(lastStatic, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 16384 /* Override */) { + if (flags & 16 /* Override */) { return grammarErrorOnNode(lastOverride, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); } - if (flags & 512 /* Async */) { + if (flags & 1024 /* Async */) { return grammarErrorOnNode(lastAsync, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return false; - } else if ((node.kind === 272 /* ImportDeclaration */ || node.kind === 271 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + } else if ((node.kind === 272 /* ImportDeclaration */ || node.kind === 271 /* ImportEqualsDeclaration */) && flags & 128 /* Ambient */) { return grammarErrorOnNode(lastDeclare, Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); - } else if (node.kind === 169 /* Parameter */ && flags & 16476 /* ParameterPropertyModifier */ && isBindingPattern(node.name)) { + } else if (node.kind === 169 /* Parameter */ && flags & 31 /* ParameterPropertyModifier */ && isBindingPattern(node.name)) { return grammarErrorOnNode(node, Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); - } else if (node.kind === 169 /* Parameter */ && flags & 16476 /* ParameterPropertyModifier */ && node.dotDotDotToken) { + } else if (node.kind === 169 /* Parameter */ && flags & 31 /* ParameterPropertyModifier */ && node.dotDotDotToken) { return grammarErrorOnNode(node, Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } - if (flags & 512 /* Async */) { + if (flags & 1024 /* Async */) { return checkGrammarAsyncModifier(node, lastAsync); } return false; @@ -83483,12 +83730,12 @@ function createTypeChecker(host) { if (languageVersion < 2 /* ES2015 */ && isPrivateIdentifier(accessor.name)) { return grammarErrorOnNode(accessor.name, Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } - if (accessor.body === void 0 && !hasSyntacticModifier(accessor, 256 /* Abstract */)) { + if (accessor.body === void 0 && !hasSyntacticModifier(accessor, 64 /* Abstract */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, Diagnostics._0_expected, "{"); } } if (accessor.body) { - if (hasSyntacticModifier(accessor, 256 /* Abstract */)) { + if (hasSyntacticModifier(accessor, 64 /* Abstract */)) { return grammarErrorOnNode(accessor, Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } if (accessor.parent.kind === 187 /* TypeLiteral */ || accessor.parent.kind === 264 /* InterfaceDeclaration */) { @@ -83560,7 +83807,7 @@ function createTypeChecker(host) { } break; case 171 /* PropertySignature */: - if (!hasSyntacticModifier(parent, 64 /* Readonly */)) { + if (!hasSyntacticModifier(parent, 8 /* Readonly */)) { return grammarErrorOnNode(parent.name, Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } break; @@ -83730,7 +83977,7 @@ function createTypeChecker(host) { const message = node.initializer ? Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type ? Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations : Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context; return grammarErrorOnNode(node.exclamationToken, message); } - if ((moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && moduleKind !== 4 /* System */ && !(node.parent.parent.flags & 33554432 /* Ambient */) && hasSyntacticModifier(node.parent.parent, 1 /* Export */)) { + if ((moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && moduleKind !== 4 /* System */ && !(node.parent.parent.flags & 33554432 /* Ambient */) && hasSyntacticModifier(node.parent.parent, 32 /* Export */)) { checkESModuleMarker(node.name); } return !!blockScopeKind && checkGrammarNameInLetOrConstDeclarations(node.name); @@ -83920,7 +84167,7 @@ function createTypeChecker(host) { } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 264 /* InterfaceDeclaration */ || node.kind === 265 /* TypeAliasDeclaration */ || node.kind === 272 /* ImportDeclaration */ || node.kind === 271 /* ImportEqualsDeclaration */ || node.kind === 278 /* ExportDeclaration */ || node.kind === 277 /* ExportAssignment */ || node.kind === 270 /* NamespaceExportDeclaration */ || hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 1024 /* Default */)) { + if (node.kind === 264 /* InterfaceDeclaration */ || node.kind === 265 /* TypeAliasDeclaration */ || node.kind === 272 /* ImportDeclaration */ || node.kind === 271 /* ImportEqualsDeclaration */ || node.kind === 278 /* ExportDeclaration */ || node.kind === 277 /* ExportAssignment */ || node.kind === 270 /* NamespaceExportDeclaration */ || hasSyntacticModifier(node, 128 /* Ambient */ | 32 /* Export */ | 2048 /* Default */)) { return false; } return grammarErrorOnFirstToken(node, Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier); @@ -84235,12 +84482,14 @@ var SymbolTrackerImpl = class _SymbolTrackerImpl { this.canTrackSymbol = !!((_a = this.inner) == null ? void 0 : _a.trackSymbol); } trackSymbol(symbol, enclosingDeclaration, meaning) { - var _a; + var _a, _b; if (((_a = this.inner) == null ? void 0 : _a.trackSymbol) && !this.disableTrackSymbol) { if (this.inner.trackSymbol(symbol, enclosingDeclaration, meaning)) { this.onDiagnosticReported(); return true; } + if (!(symbol.flags & 262144 /* TypeParameter */)) + ((_b = this.context).trackedSymbols ?? (_b.trackedSymbols = [])).push([symbol, enclosingDeclaration, meaning]); } return false; } @@ -86125,15 +86374,15 @@ function collectExternalModuleInfo(context, sourceFile) { } break; case 243 /* VariableStatement */: - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { for (const decl of node.declarationList.declarations) { exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames, exportedBindings); } } break; case 262 /* FunctionDeclaration */: - if (hasSyntacticModifier(node, 1 /* Export */)) { - if (hasSyntacticModifier(node, 1024 /* Default */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { + if (hasSyntacticModifier(node, 2048 /* Default */)) { if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); hasExportDefault = true; @@ -86149,8 +86398,8 @@ function collectExternalModuleInfo(context, sourceFile) { } break; case 263 /* ClassDeclaration */: - if (hasSyntacticModifier(node, 1 /* Export */)) { - if (hasSyntacticModifier(node, 1024 /* Default */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { + if (hasSyntacticModifier(node, 2048 /* Default */)) { if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); hasExportDefault = true; @@ -87015,7 +87264,7 @@ function injectClassThisAssignmentIfMissing(factory2, node, classThis, thisExpre // src/compiler/transformers/namedEvaluation.ts function getAssignedNameOfIdentifier(factory2, name, expression) { const original = getOriginalNode(skipOuterExpressions(expression)); - if ((isClassDeclaration(original) || isFunctionDeclaration(original)) && !original.name && hasSyntacticModifier(original, 1024 /* Default */)) { + if ((isClassDeclaration(original) || isFunctionDeclaration(original)) && !original.name && hasSyntacticModifier(original, 2048 /* Default */)) { return factory2.createStringLiteral("default"); } return factory2.createStringLiteralFromNode(name); @@ -87369,13 +87618,13 @@ function transformTypeScript(context) { break; case 263 /* ClassDeclaration */: case 262 /* FunctionDeclaration */: - if (hasSyntacticModifier(node, 2 /* Ambient */)) { + if (hasSyntacticModifier(node, 128 /* Ambient */)) { break; } if (node.name) { recordEmittedDeclarationInScope(node); } else { - Debug.assert(node.kind === 263 /* ClassDeclaration */ || hasSyntacticModifier(node, 1024 /* Default */)); + Debug.assert(node.kind === 263 /* ClassDeclaration */ || hasSyntacticModifier(node, 2048 /* Default */)); } break; } @@ -87430,7 +87679,7 @@ function transformTypeScript(context) { function namespaceElementVisitorWorker(node) { if (node.kind === 278 /* ExportDeclaration */ || node.kind === 272 /* ImportDeclaration */ || node.kind === 273 /* ImportClause */ || node.kind === 271 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 283 /* ExternalModuleReference */) { return void 0; - } else if (node.transformFlags & 1 /* ContainsTypeScript */ || hasSyntacticModifier(node, 1 /* Export */)) { + } else if (node.transformFlags & 1 /* ContainsTypeScript */ || hasSyntacticModifier(node, 32 /* Export */)) { return visitTypeScript(node); } return node; @@ -87488,7 +87737,7 @@ function transformTypeScript(context) { function modifierVisitor(node) { if (isDecorator(node)) return void 0; - if (modifierToFlag(node.kind) & 117086 /* TypeScriptModifier */) { + if (modifierToFlag(node.kind) & 28895 /* TypeScriptModifier */) { return void 0; } else if (currentNamespace && node.kind === 95 /* ExportKeyword */) { return void 0; @@ -87496,7 +87745,7 @@ function transformTypeScript(context) { return node; } function visitTypeScript(node) { - if (isStatement(node) && hasSyntacticModifier(node, 2 /* Ambient */)) { + if (isStatement(node) && hasSyntacticModifier(node, 128 /* Ambient */)) { return factory2.createNotEmittedStatement(node); } switch (node.kind) { @@ -87986,7 +88235,7 @@ function transformTypeScript(context) { return !nodeIsMissing(node.body); } function visitPropertyDeclaration(node, parent) { - const isAmbient = node.flags & 33554432 /* Ambient */ || hasSyntacticModifier(node, 256 /* Abstract */); + const isAmbient = node.flags & 33554432 /* Ambient */ || hasSyntacticModifier(node, 64 /* Abstract */); if (isAmbient && !(legacyDecorators && hasDecorators(node))) { return void 0; } @@ -87995,7 +88244,7 @@ function transformTypeScript(context) { if (isAmbient) { return factory2.updatePropertyDeclaration( node, - concatenate(modifiers, factory2.createModifiersFromModifierFlags(2 /* Ambient */)), + concatenate(modifiers, factory2.createModifiersFromModifierFlags(128 /* Ambient */)), Debug.checkDefined(visitNode(node.name, visitor, isPropertyName)), /*questionOrExclamationToken*/ void 0, @@ -88158,7 +88407,7 @@ function transformTypeScript(context) { ); } function shouldEmitAccessorDeclaration(node) { - return !(nodeIsMissing(node.body) && hasSyntacticModifier(node, 256 /* Abstract */)); + return !(nodeIsMissing(node.body) && hasSyntacticModifier(node, 64 /* Abstract */)); } function visitGetAccessor(node, parent) { if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { @@ -88891,16 +89140,16 @@ function transformTypeScript(context) { } } function isExportOfNamespace(node) { - return currentNamespace !== void 0 && hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace !== void 0 && hasSyntacticModifier(node, 32 /* Export */); } function isExternalModuleExport(node) { - return currentNamespace === void 0 && hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace === void 0 && hasSyntacticModifier(node, 32 /* Export */); } function isNamedExternalModuleExport(node) { - return isExternalModuleExport(node) && !hasSyntacticModifier(node, 1024 /* Default */); + return isExternalModuleExport(node) && !hasSyntacticModifier(node, 2048 /* Default */); } function isDefaultExternalModuleExport(node) { - return isExternalModuleExport(node) && hasSyntacticModifier(node, 1024 /* Default */); + return isExternalModuleExport(node) && hasSyntacticModifier(node, 2048 /* Default */); } function createExportMemberAssignmentStatement(node) { const expression = factory2.createAssignment( @@ -90233,8 +90482,8 @@ function transformClassFields(context) { getClassLexicalEnvironment().classThis = node.emitNode.classThis; } const isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 262144 /* ContainsConstructorReference */; - const isExport = hasSyntacticModifier(node, 1 /* Export */); - const isDefault = hasSyntacticModifier(node, 1024 /* Default */); + const isExport = hasSyntacticModifier(node, 32 /* Export */); + const isDefault = hasSyntacticModifier(node, 2048 /* Default */); let modifiers = visitNodes2(node.modifiers, modifierVisitor, isModifier); const heritageClauses = visitNodes2(node.heritageClauses, heritageClauseVisitor, isHeritageClause); const { members, prologue } = transformClassMembers(node); @@ -90780,7 +91029,7 @@ function transformClassFields(context) { return void 0; } const propertyOriginalNode = getOriginalNode(property); - if (hasSyntacticModifier(propertyOriginalNode, 256 /* Abstract */)) { + if (hasSyntacticModifier(propertyOriginalNode, 64 /* Abstract */)) { return void 0; } let initializer = visitNode(property.initializer, visitor, isExpression); @@ -91816,8 +92065,8 @@ function transformLegacyDecorators(context) { return addRange([updated], decorationStatements); } function transformClassDeclarationWithClassDecorators(node, name) { - const isExport = hasSyntacticModifier(node, 1 /* Export */); - const isDefault = hasSyntacticModifier(node, 1024 /* Default */); + const isExport = hasSyntacticModifier(node, 32 /* Export */); + const isDefault = hasSyntacticModifier(node, 2048 /* Default */); const modifiers = visitNodes2(node.modifiers, (node2) => isExportOrDefaultModifier(node2) || isDecorator(node2) ? void 0 : node2, isModifierLike); const location = moveRangePastModifiers(node); const classAlias = getClassAliasIfNeeded(node); @@ -91838,7 +92087,7 @@ function transformLegacyDecorators(context) { let members = visitNodes2(node.members, visitor, isClassElement); let decorationStatements = []; ({ members, decorationStatements } = transformDecoratorsOfClassElements(node, members)); - const assignClassAliasInStaticBlock = languageVersion >= 9 /* ES2022 */ && !!classAlias && some(members, (member) => isPropertyDeclaration(member) && hasSyntacticModifier(member, 32 /* Static */) || isClassStaticBlockDeclaration(member)); + const assignClassAliasInStaticBlock = languageVersion >= 9 /* ES2022 */ && !!classAlias && some(members, (member) => isPropertyDeclaration(member) && hasSyntacticModifier(member, 256 /* Static */) || isClassStaticBlockDeclaration(member)); if (assignClassAliasInStaticBlock) { members = setTextRange( factory2.createNodeArray([ @@ -91969,7 +92218,7 @@ function transformLegacyDecorators(context) { ); } function visitPropertyDeclaration(node) { - if (node.flags & 33554432 /* Ambient */ || hasSyntacticModifier(node, 2 /* Ambient */)) { + if (node.flags & 33554432 /* Ambient */ || hasSyntacticModifier(node, 128 /* Ambient */)) { return void 0; } return finishClassElement( @@ -92057,7 +92306,7 @@ function transformLegacyDecorators(context) { const memberName = getExpressionForPropertyName( member, /*generateNameForComputedPropertyName*/ - !hasSyntacticModifier(member, 2 /* Ambient */) + !hasSyntacticModifier(member, 128 /* Ambient */) ); const descriptor = languageVersion > 0 /* ES3 */ ? isPropertyDeclaration(member) && !hasAccessorModifier(member) ? factory2.createVoidZero() : factory2.createNull() : void 0; const helper = emitHelpers().createDecorateHelper( @@ -92840,8 +93089,8 @@ function transformESDecorators(context) { const statements = []; const originalClass = getOriginalNode(node, isClassLike) ?? node; const className = originalClass.name ? factory2.createStringLiteralFromNode(originalClass.name) : factory2.createStringLiteral("default"); - const isExport = hasSyntacticModifier(node, 1 /* Export */); - const isDefault = hasSyntacticModifier(node, 1024 /* Default */); + const isExport = hasSyntacticModifier(node, 32 /* Export */); + const isDefault = hasSyntacticModifier(node, 2048 /* Default */); if (!node.name) { node = injectClassNamedEvaluationHelperBlockIfMissing(context, node, className); } @@ -95152,7 +95401,7 @@ function transformES2018(context) { return visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { const savedExportedVariableStatement = exportedVariableStatement; exportedVariableStatement = true; const visited = visitEachChild(node, visitor, context); @@ -96364,7 +96613,7 @@ function transformESNext(context) { addRange(topLevelStatements, endLexicalEnvironment()); if (exportVars.length) { topLevelStatements.push(factory2.createVariableStatement( - factory2.createModifiersFromModifierFlags(1 /* Export */), + factory2.createModifiersFromModifierFlags(32 /* Export */), factory2.createVariableDeclarationList( exportVars, 1 /* Let */ @@ -96661,8 +96910,8 @@ function transformESNext(context) { if (!node.name && defaultExportBinding) { return node; } - const isExported = hasSyntacticModifier(node, 1 /* Export */); - const isDefault = hasSyntacticModifier(node, 1024 /* Default */); + const isExported = hasSyntacticModifier(node, 32 /* Export */); + const isDefault = hasSyntacticModifier(node, 2048 /* Default */); let expression = factory2.converters.convertToClassExpression(node); if (node.name) { hoistBindingIdentifier( @@ -96710,7 +96959,7 @@ function transformESNext(context) { } function hoistVariableStatement(node) { let expressions; - const isExported = hasSyntacticModifier(node, 1 /* Export */); + const isExported = hasSyntacticModifier(node, 32 /* Export */); for (const variable of node.declarationList.declarations) { hoistBindingElement(variable, isExported, variable); if (variable.initializer) { @@ -97298,7 +97547,7 @@ function transformJsx(context) { } function transformJsxSpreadAttributeToProps(node) { if (isObjectLiteralExpression(node.expression) && !hasProto(node.expression)) { - return node.expression.properties; + return sameMap(node.expression.properties, (p) => Debug.checkDefined(visitNode(p, visitor, isObjectLiteralElementLike))); } return factory2.createSpreadAssignment(Debug.checkDefined(visitNode(node.expression, visitor, isExpression))); } @@ -97866,7 +98115,7 @@ function transformES2015(context) { hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 && node.kind === 253 /* ReturnStatement */ && !node.expression; + return (hierarchyFacts & 8192 /* ConstructorWithSuperCall */) !== 0 && node.kind === 253 /* ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { return node.transformFlags & 4194304 /* ContainsHoistedDeclarationOrCompletion */ && (isReturnStatement(node) || isIfStatement(node) || isWithStatement(node) || isSwitchStatement(node) || isCaseBlock(node) || isCaseClause(node) || isDefaultClause(node) || isTryStatement(node) || isCatchClause(node) || isLabeledStatement(node) || isIterationStatement( @@ -97876,7 +98125,7 @@ function transformES2015(context) { ) || isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node) || isIterationStatement( + return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /* ConstructorWithSuperCall */ && isOrMayContainReturnCompletion(node) || isIterationStatement( node, /*lookInLabeledStatements*/ false @@ -97909,7 +98158,7 @@ function transformES2015(context) { /*expressionResultIsUnused*/ false ); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); return result; } return visitorWorker( @@ -97923,6 +98172,7 @@ function transformES2015(context) { function callExpressionVisitor(node) { if (node.kind === 108 /* SuperKeyword */) { return visitSuperKeyword( + node, /*isExpressionOfCall*/ true ); @@ -98032,6 +98282,7 @@ function transformES2015(context) { return visitSpreadElement(node); case 108 /* SuperKeyword */: return visitSuperKeyword( + node, /*isExpressionOfCall*/ false ); @@ -98101,7 +98352,10 @@ function transformES2015(context) { return updated; } function returnCapturedThis(node) { - return setOriginalNode(factory2.createReturnStatement(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)), node); + return setOriginalNode(factory2.createReturnStatement(createCapturedThis()), node); + } + function createCapturedThis() { + return factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */); } function visitReturnStatement(node) { if (convertedLoopState) { @@ -98125,8 +98379,9 @@ function transformES2015(context) { return visitEachChild(node, visitor, context); } function visitThisKeyword(node) { + hierarchyFacts |= 65536 /* LexicalThis */; if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + hierarchyFacts |= 131072 /* CapturedLexicalThis */; } if (convertedLoopState) { if (hierarchyFacts & 2 /* ArrowFunction */) { @@ -98236,8 +98491,8 @@ function transformES2015(context) { setTextRange(statement, node); startOnNewLine(statement); statements.push(statement); - if (hasSyntacticModifier(node, 1 /* Export */)) { - const exportStatement = hasSyntacticModifier(node, 1024 /* Default */) ? factory2.createExportDefault(factory2.getLocalName(node)) : factory2.createExternalModuleExport(factory2.getLocalName(node)); + if (hasSyntacticModifier(node, 32 /* Export */)) { + const exportStatement = hasSyntacticModifier(node, 2048 /* Default */) ? factory2.createExportDefault(factory2.getLocalName(node)) : factory2.createExternalModuleExport(factory2.getLocalName(node)); setOriginalNode(exportStatement, statement); statements.push(exportStatement); } @@ -98265,7 +98520,7 @@ function transformES2015(context) { void 0, /*dotDotDotToken*/ void 0, - factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */) + createSyntheticSuper() )] : [], /*type*/ void 0, @@ -98355,7 +98610,7 @@ function transformES2015(context) { setEmitFlags(constructorFunction, 16 /* CapturesThis */); } statements.push(constructorFunction); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; } function transformConstructorParameters(constructor, hasSynthesizedSuper) { @@ -98379,103 +98634,35 @@ function transformES2015(context) { setEmitFlags(block, 3072 /* NoComments */); return block; } - function transformConstructorBodyWorker(prologueOut, statementsOut, statementsIn, statementOffset, superPath, superPathDepth, constructor, isDerivedClass, hasSynthesizedSuper, isFirstStatement) { - let mayReplaceThis = false; - const superStatementIndex = superPathDepth < superPath.length ? superPath[superPathDepth] : -1; - const leadingStatementsEnd = superStatementIndex >= 0 ? superStatementIndex : statementsIn.length; - if (isFirstStatement && superStatementIndex >= 0) { - let firstMaterialIndex = statementOffset; - while (isFirstStatement && firstMaterialIndex < superStatementIndex) { - const statement = constructor.body.statements[firstMaterialIndex]; - if (!isUninitializedVariableStatement(statement) && !isUsingDeclarationStateVariableStatement(statement)) - break; - firstMaterialIndex++; - } - isFirstStatement = superStatementIndex === firstMaterialIndex; - } - addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, statementOffset, leadingStatementsEnd - statementOffset)); - const superStatement = superStatementIndex >= 0 ? statementsIn[superStatementIndex] : void 0; - if (superStatement && isTryStatement(superStatement)) { - const tryBlockStatements = []; - mayReplaceThis = transformConstructorBodyWorker( - prologueOut, - tryBlockStatements, - superStatement.tryBlock.statements, - /*statementOffset*/ - 0, - superPath, - superPathDepth + 1, - constructor, - isDerivedClass, - hasSynthesizedSuper, - isFirstStatement - ); - const tryBlockStatementsArray = factory2.createNodeArray(tryBlockStatements); - setTextRange(tryBlockStatementsArray, superStatement.tryBlock.statements); - statementsOut.push(factory2.updateTryStatement( - superStatement, - factory2.updateBlock(superStatement.tryBlock, tryBlockStatements), - visitNode(superStatement.catchClause, visitor, isCatchClause), - visitNode(superStatement.finallyBlock, visitor, isBlock) - )); - } else { - const superCall = superStatement && getSuperCallFromStatement(superStatement); - let superCallExpression; - if (hasSynthesizedSuper) { - superCallExpression = createDefaultSuperCallOrThis(); - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; - } else if (superCall) { - superCallExpression = visitSuperCallInBody(superCall); - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; - } - if (isDerivedClass || superCallExpression) { - if (superCallExpression && superStatementIndex === statementsIn.length - 1 && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) { - const superCall2 = cast(cast(superCallExpression, isBinaryExpression).left, isCallExpression); - const returnStatement = factory2.createReturnStatement(superCallExpression); - setCommentRange(returnStatement, getCommentRange(superCall2)); - setEmitFlags(superCall2, 3072 /* NoComments */); - statementsOut.push(returnStatement); - return false; - } else { - if (isFirstStatement) { - insertCaptureThisForNode(statementsOut, constructor, superCallExpression || createActualThis()); - } else { - insertCaptureThisForNode(prologueOut, constructor, createActualThis()); - if (superCallExpression) { - addSuperThisCaptureThisForNode(statementsOut, superCallExpression); - } - } - mayReplaceThis = true; - } - } else { - insertCaptureThisForNodeIfNeeded(prologueOut, constructor); - } - } - if (superStatementIndex >= 0) { - addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, superStatementIndex + 1)); - } - return mayReplaceThis; - } function isUninitializedVariableStatement(node) { return isVariableStatement(node) && every(node.declarationList.declarations, (decl) => isIdentifier(decl.name) && !decl.initializer); } - function isUsingDeclarationStateVariableStatement(node) { - if (!isVariableStatement(node) || node.declarationList.declarations.length !== 1) - return false; - const varDecl = node.declarationList.declarations[0]; - if (!isIdentifier(varDecl.name) || !varDecl.initializer) - return false; - const initializer = varDecl.initializer; - if (!isObjectLiteralExpression(initializer) || initializer.properties.length !== 3) - return false; - const [stackProp, errorProp, hasErrorProp] = initializer.properties; - if (!isPropertyAssignment(stackProp) || !isIdentifier(stackProp.name) || idText(stackProp.name) !== "stack" || !isArrayLiteralExpression(stackProp.initializer)) - return false; - if (!isPropertyAssignment(errorProp) || !isIdentifier(errorProp.name) || idText(errorProp.name) !== "error" || !isVoidExpression(errorProp.initializer) || !isNumericLiteral(errorProp.initializer.expression)) - return false; - if (!isPropertyAssignment(hasErrorProp) || !isIdentifier(hasErrorProp.name) || idText(hasErrorProp.name) !== "hasError" || hasErrorProp.initializer.kind !== 97 /* FalseKeyword */) + function containsSuperCall(node) { + if (isSuperCall(node)) { + return true; + } + if (!(node.transformFlags & 134217728 /* ContainsLexicalSuper */)) { return false; - return true; + } + switch (node.kind) { + case 219 /* ArrowFunction */: + case 218 /* FunctionExpression */: + case 262 /* FunctionDeclaration */: + case 176 /* Constructor */: + case 175 /* ClassStaticBlockDeclaration */: + return false; + case 177 /* GetAccessor */: + case 178 /* SetAccessor */: + case 174 /* MethodDeclaration */: + case 172 /* PropertyDeclaration */: { + const named = node; + if (isComputedPropertyName(named.name)) { + return !!forEachChild(named.name, containsSuperCall); + } + return false; + } + } + return !!forEachChild(node, containsSuperCall); } function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { const isDerivedClass = !!extendsClauseElement && skipOuterExpressions(extendsClauseElement.expression).kind !== 106 /* NullKeyword */; @@ -98490,31 +98677,22 @@ function transformES2015(context) { /*statementOffset*/ 0 ); - const superStatementIndices = findSuperStatementIndexPath(constructor.body.statements, standardPrologueEnd); - if (hasSynthesizedSuper || superStatementIndices.length > 0) { - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; + if (hasSynthesizedSuper || containsSuperCall(constructor.body)) { + hierarchyFacts |= 8192 /* ConstructorWithSuperCall */; } - const mayReplaceThis = transformConstructorBodyWorker( - prologue, - statements, - constructor.body.statements, - standardPrologueEnd, - superStatementIndices, - /*superPathDepth*/ - 0, - constructor, - isDerivedClass, - hasSynthesizedSuper, - /*isFirstStatement*/ - true - // NOTE: this will be recalculated inside of transformConstructorBodyWorker - ); + addRange(statements, visitNodes2(constructor.body.statements, visitor, isStatement, standardPrologueEnd)); + const mayReplaceThis = isDerivedClass || hierarchyFacts & 8192 /* ConstructorWithSuperCall */; addDefaultValueAssignmentsIfNeeded2(prologue, constructor); addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper); insertCaptureNewTargetIfNeeded(prologue, constructor); + if (mayReplaceThis) { + insertCaptureThisForNode(prologue, constructor, createActualThis()); + } else { + insertCaptureThisForNodeIfNeeded(prologue, constructor); + } factory2.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); if (mayReplaceThis && !isSufficientlyCoveredByReturnStatements(constructor.body)) { - statements.push(factory2.createReturnStatement(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */))); + statements.push(factory2.createReturnStatement(createCapturedThis())); } const body = factory2.createBlock( setTextRange( @@ -98531,6 +98709,230 @@ function transformES2015(context) { true ); setTextRange(body, constructor.body); + return simplifyConstructor(body, constructor.body, hasSynthesizedSuper); + } + function isCapturedThis(node) { + return isGeneratedIdentifier(node) && idText(node) === "_this"; + } + function isSyntheticSuper(node) { + return isGeneratedIdentifier(node) && idText(node) === "_super"; + } + function isThisCapturingVariableStatement(node) { + return isVariableStatement(node) && node.declarationList.declarations.length === 1 && isThisCapturingVariableDeclaration(node.declarationList.declarations[0]); + } + function isThisCapturingVariableDeclaration(node) { + return isVariableDeclaration(node) && isCapturedThis(node.name) && !!node.initializer; + } + function isThisCapturingAssignment(node) { + return isAssignmentExpression( + node, + /*excludeCompoundAssignment*/ + true + ) && isCapturedThis(node.left); + } + function isTransformedSuperCall(node) { + return isCallExpression(node) && isPropertyAccessExpression(node.expression) && isSyntheticSuper(node.expression.expression) && isIdentifier(node.expression.name) && (idText(node.expression.name) === "call" || idText(node.expression.name) === "apply") && node.arguments.length >= 1 && node.arguments[0].kind === 110 /* ThisKeyword */; + } + function isTransformedSuperCallWithFallback(node) { + return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isTransformedSuperCall(node.left); + } + function isImplicitSuperCall(node) { + return isBinaryExpression(node) && node.operatorToken.kind === 56 /* AmpersandAmpersandToken */ && isBinaryExpression(node.left) && node.left.operatorToken.kind === 38 /* ExclamationEqualsEqualsToken */ && isSyntheticSuper(node.left.left) && node.left.right.kind === 106 /* NullKeyword */ && isTransformedSuperCall(node.right) && idText(node.right.expression.name) === "apply"; + } + function isImplicitSuperCallWithFallback(node) { + return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isImplicitSuperCall(node.left); + } + function isThisCapturingTransformedSuperCallWithFallback(node) { + return isThisCapturingAssignment(node) && isTransformedSuperCallWithFallback(node.right); + } + function isThisCapturingImplicitSuperCallWithFallback(node) { + return isThisCapturingAssignment(node) && isImplicitSuperCallWithFallback(node.right); + } + function isTransformedSuperCallLike(node) { + return isTransformedSuperCall(node) || isTransformedSuperCallWithFallback(node) || isThisCapturingTransformedSuperCallWithFallback(node) || isImplicitSuperCall(node) || isImplicitSuperCallWithFallback(node) || isThisCapturingImplicitSuperCallWithFallback(node); + } + function simplifyConstructorInlineSuperInThisCaptureVariable(body) { + for (let i = 0; i < body.statements.length - 1; i++) { + const statement = body.statements[i]; + if (!isThisCapturingVariableStatement(statement)) { + continue; + } + const varDecl = statement.declarationList.declarations[0]; + if (varDecl.initializer.kind !== 110 /* ThisKeyword */) { + continue; + } + const thisCaptureStatementIndex = i; + let superCallIndex = i + 1; + while (superCallIndex < body.statements.length) { + const statement2 = body.statements[superCallIndex]; + if (isExpressionStatement(statement2)) { + if (isTransformedSuperCallLike(skipOuterExpressions(statement2.expression))) { + break; + } + } + if (isUninitializedVariableStatement(statement2)) { + superCallIndex++; + continue; + } + return body; + } + const following = body.statements[superCallIndex]; + let expression = following.expression; + if (isThisCapturingAssignment(expression)) { + expression = expression.right; + } + const newVarDecl = factory2.updateVariableDeclaration( + varDecl, + varDecl.name, + /*exclamationToken*/ + void 0, + /*type*/ + void 0, + expression + ); + const newDeclList = factory2.updateVariableDeclarationList(statement.declarationList, [newVarDecl]); + const newVarStatement = factory2.createVariableStatement(statement.modifiers, newDeclList); + setOriginalNode(newVarStatement, following); + setTextRange(newVarStatement, following); + const newStatements = factory2.createNodeArray([ + ...body.statements.slice(0, thisCaptureStatementIndex), + // copy statements preceding to `var _this` + ...body.statements.slice(thisCaptureStatementIndex + 1, superCallIndex), + // copy intervening temp variables + newVarStatement, + ...body.statements.slice(superCallIndex + 1) + // copy statements following `super.call(this, ...)` + ]); + setTextRange(newStatements, body.statements); + return factory2.updateBlock(body, newStatements); + } + return body; + } + function simplifyConstructorInlineSuperReturn(body, original) { + for (const statement of original.statements) { + if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) { + return body; + } + } + const canElideThisCapturingVariable = !(original.transformFlags & 16384 /* ContainsLexicalThis */) && !(hierarchyFacts & 65536 /* LexicalThis */) && !(hierarchyFacts & 131072 /* CapturedLexicalThis */); + for (let i = body.statements.length - 1; i > 0; i--) { + const statement = body.statements[i]; + if (isReturnStatement(statement) && statement.expression && isCapturedThis(statement.expression)) { + const preceding = body.statements[i - 1]; + let expression; + if (isExpressionStatement(preceding) && isThisCapturingTransformedSuperCallWithFallback(skipOuterExpressions(preceding.expression))) { + expression = preceding.expression; + } else if (canElideThisCapturingVariable && isThisCapturingVariableStatement(preceding)) { + const varDecl = preceding.declarationList.declarations[0]; + if (isTransformedSuperCallLike(skipOuterExpressions(varDecl.initializer))) { + expression = factory2.createAssignment( + createCapturedThis(), + varDecl.initializer + ); + } + } + if (!expression) { + break; + } + const newReturnStatement = factory2.createReturnStatement(expression); + setOriginalNode(newReturnStatement, preceding); + setTextRange(newReturnStatement, preceding); + const newStatements = factory2.createNodeArray([ + ...body.statements.slice(0, i - 1), + // copy all statements preceding `_super.call(this, ...)` + newReturnStatement, + ...body.statements.slice(i + 1) + // copy all statements following `return _this;` + ]); + setTextRange(newStatements, body.statements); + return factory2.updateBlock(body, newStatements); + } + } + return body; + } + function elideUnusedThisCaptureWorker(node) { + if (isThisCapturingVariableStatement(node)) { + const varDecl = node.declarationList.declarations[0]; + if (varDecl.initializer.kind === 110 /* ThisKeyword */) { + return void 0; + } + } else if (isThisCapturingAssignment(node)) { + return factory2.createPartiallyEmittedExpression(node.right, node); + } + switch (node.kind) { + case 219 /* ArrowFunction */: + case 218 /* FunctionExpression */: + case 262 /* FunctionDeclaration */: + case 176 /* Constructor */: + case 175 /* ClassStaticBlockDeclaration */: + return node; + case 177 /* GetAccessor */: + case 178 /* SetAccessor */: + case 174 /* MethodDeclaration */: + case 172 /* PropertyDeclaration */: { + const named = node; + if (isComputedPropertyName(named.name)) { + return factory2.replacePropertyName(named, visitEachChild(named.name, elideUnusedThisCaptureWorker, nullTransformationContext)); + } + return node; + } + } + return visitEachChild(node, elideUnusedThisCaptureWorker, nullTransformationContext); + } + function simplifyConstructorElideUnusedThisCapture(body, original) { + if (original.transformFlags & 16384 /* ContainsLexicalThis */ || hierarchyFacts & 65536 /* LexicalThis */ || hierarchyFacts & 131072 /* CapturedLexicalThis */) { + return body; + } + for (const statement of original.statements) { + if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) { + return body; + } + } + return factory2.updateBlock(body, visitNodes2(body.statements, elideUnusedThisCaptureWorker, isStatement)); + } + function injectSuperPresenceCheckWorker(node) { + if (isTransformedSuperCall(node) && node.arguments.length === 2 && isIdentifier(node.arguments[1]) && idText(node.arguments[1]) === "arguments") { + return factory2.createLogicalAnd( + factory2.createStrictInequality( + createSyntheticSuper(), + factory2.createNull() + ), + node + ); + } + switch (node.kind) { + case 219 /* ArrowFunction */: + case 218 /* FunctionExpression */: + case 262 /* FunctionDeclaration */: + case 176 /* Constructor */: + case 175 /* ClassStaticBlockDeclaration */: + return node; + case 177 /* GetAccessor */: + case 178 /* SetAccessor */: + case 174 /* MethodDeclaration */: + case 172 /* PropertyDeclaration */: { + const named = node; + if (isComputedPropertyName(named.name)) { + return factory2.replacePropertyName(named, visitEachChild(named.name, injectSuperPresenceCheckWorker, nullTransformationContext)); + } + return node; + } + } + return visitEachChild(node, injectSuperPresenceCheckWorker, nullTransformationContext); + } + function complicateConstructorInjectSuperPresenceCheck(body) { + return factory2.updateBlock(body, visitNodes2(body.statements, injectSuperPresenceCheckWorker, isStatement)); + } + function simplifyConstructor(body, original, hasSynthesizedSuper) { + const inputBody = body; + body = simplifyConstructorInlineSuperInThisCaptureVariable(body); + body = simplifyConstructorInlineSuperReturn(body, original); + if (body !== inputBody) { + body = simplifyConstructorElideUnusedThisCapture(body, original); + } + if (hasSynthesizedSuper) { + body = complicateConstructorInjectSuperPresenceCheck(body); + } return body; } function isSufficientlyCoveredByReturnStatements(statement) { @@ -98556,11 +98958,11 @@ function transformES2015(context) { return factory2.createLogicalOr( factory2.createLogicalAnd( factory2.createStrictInequality( - factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), + createSyntheticSuper(), factory2.createNull() ), factory2.createFunctionApplyCall( - factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), + createSyntheticSuper(), createActualThis(), factory2.createIdentifier("arguments") ) @@ -98815,24 +99217,12 @@ function transformES2015(context) { return true; } function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 219 /* ArrowFunction */) { + if (hierarchyFacts & 131072 /* CapturedLexicalThis */ && node.kind !== 219 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, factory2.createThis()); return true; } return false; } - function addSuperThisCaptureThisForNode(statements, superExpression) { - enableSubstitutionsForCapturedThis(); - const assignSuperExpression = factory2.createExpressionStatement( - factory2.createBinaryExpression( - factory2.createThis(), - 64 /* EqualsToken */, - superExpression - ) - ); - statements.push(assignSuperExpression); - setCommentRange(assignSuperExpression, getOriginalNode(superExpression).parent); - } function insertCaptureThisForNode(statements, node, initializer) { enableSubstitutionsForCapturedThis(); const captureThisStatement = factory2.createVariableStatement( @@ -98840,7 +99230,7 @@ function transformES2015(context) { void 0, factory2.createVariableDeclarationList([ factory2.createVariableDeclaration( - factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), + createCapturedThis(), /*exclamationToken*/ void 0, /*type*/ @@ -99061,7 +99451,7 @@ function transformES2015(context) { } function visitArrowFunction(node) { if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + hierarchyFacts |= 131072 /* CapturedLexicalThis */; } const savedConvertedLoopState = convertedLoopState; convertedLoopState = void 0; @@ -99094,7 +99484,7 @@ function transformES2015(context) { const parameters = visitParameterList(node.parameters, visitor, context); const body = transformFunctionBody(node); const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return factory2.updateFunctionExpression( node, @@ -99117,7 +99507,7 @@ function transformES2015(context) { const parameters = visitParameterList(node.parameters, visitor, context); const body = transformFunctionBody(node); const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return factory2.updateFunctionDeclaration( node, @@ -99141,7 +99531,7 @@ function transformES2015(context) { if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 262 /* FunctionDeclaration */ || node.kind === 218 /* FunctionExpression */)) { name = factory2.getGeneratedNameForNode(node); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return setOriginalNode( setTextRange( @@ -99294,7 +99684,7 @@ function transformES2015(context) { return node.declarationList.declarations.length === 1 && !!node.declarationList.declarations[0].initializer && !!(getInternalEmitFlags(node.declarationList.declarations[0].initializer) & 1 /* TypeScriptClassWrapper */); } function visitVariableStatement(node) { - const ancestorFacts = enterSubtree(0 /* None */, hasSyntacticModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + const ancestorFacts = enterSubtree(0 /* None */, hasSyntacticModifier(node, 32 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); let updated; if (convertedLoopState && (node.declarationList.flags & 7 /* BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { let assignments; @@ -100550,7 +100940,7 @@ function transformES2015(context) { } else { updated = factory2.updateSetAccessorDeclaration(node, node.modifiers, node.name, parameters, body); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return updated; } @@ -100700,13 +101090,6 @@ function transformES2015(context) { ) ); } - function visitSuperCallInBody(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment( - node, - /*assignToCapturedThis*/ - false - ); - } function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { if (node.transformFlags & 32768 /* ContainsRestOrSpread */ || node.expression.kind === 108 /* SuperKeyword */ || isSuperProperty(skipOuterExpressions(node.expression))) { const { target, thisArg } = factory2.createCallBinding(node.expression, hoistVariableDeclaration); @@ -100743,10 +101126,13 @@ function transformES2015(context) { resultingCall, createActualThis() ); - resultingCall = assignToCapturedThis ? factory2.createAssignment(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) : initializer; + resultingCall = assignToCapturedThis ? factory2.createAssignment(createCapturedThis(), initializer) : initializer; } return setOriginalNode(resultingCall, node); } + if (isSuperCall(node)) { + hierarchyFacts |= 131072 /* CapturedLexicalThis */; + } return visitEachChild(node, visitor, context); } function visitNewExpression(node) { @@ -100873,8 +101259,15 @@ function transformES2015(context) { } return setTextRange(expression, node); } - function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? factory2.createPropertyAccessExpression(factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), "prototype") : factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); + function createSyntheticSuper() { + return factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); + } + function visitSuperKeyword(node, isExpressionOfCall) { + const expression = hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? factory2.createPropertyAccessExpression(setOriginalNode(createSyntheticSuper(), node), "prototype") : createSyntheticSuper(); + setOriginalNode(expression, node); + setCommentRange(expression, node); + setSourceMapRange(expression, node); + return expression; } function visitMetaProperty(node) { if (node.keywordToken === 105 /* NewKeyword */ && node.name.escapedText === "target") { @@ -100980,7 +101373,7 @@ function transformES2015(context) { } function substituteThisKeyword(node) { if (enabledSubstitutions & 1 /* CapturedThis */ && hierarchyFacts & 16 /* CapturesThis */) { - return setTextRange(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), node); + return setTextRange(createCapturedThis(), node); } return node; } @@ -104240,7 +104633,7 @@ function transformModule(context) { Debug.assert(isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); let statements; if (moduleKind !== 2 /* AMD */) { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { statements = append( statements, setOriginalNode( @@ -104286,7 +104679,7 @@ function transformModule(context) { ); } } else { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { statements = append( statements, setOriginalNode( @@ -104424,7 +104817,7 @@ function transformModule(context) { } function visitFunctionDeclaration(node) { let statements; - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { statements = append( statements, setOriginalNode( @@ -104461,7 +104854,7 @@ function transformModule(context) { } function visitClassDeclaration(node) { let statements; - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { statements = append( statements, setOriginalNode( @@ -104495,7 +104888,7 @@ function transformModule(context) { let statements; let variables; let expressions; - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { let modifiers; let removeCommentsOnExpressions = false; for (const variable of node.declarationList.declarations) { @@ -104681,8 +105074,8 @@ function transformModule(context) { return statements; } const seen = new IdentifierNameMap(); - if (hasSyntacticModifier(decl, 1 /* Export */)) { - const exportName = hasSyntacticModifier(decl, 1024 /* Default */) ? factory2.createIdentifier("default") : factory2.getDeclarationName(decl); + if (hasSyntacticModifier(decl, 32 /* Export */)) { + const exportName = hasSyntacticModifier(decl, 2048 /* Default */) ? factory2.createIdentifier("default") : factory2.getDeclarationName(decl); statements = appendExportStatement( statements, seen, @@ -105169,7 +105562,7 @@ function transformSystemModule(context) { addRange(statements, hoistedStatements); insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); const exportStarFunction = addExportStarIfNeeded(statements); - const modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ? factory2.createModifiersFromModifierFlags(512 /* Async */) : void 0; + const modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ? factory2.createModifiersFromModifierFlags(1024 /* Async */) : void 0; const moduleObject = factory2.createObjectLiteralExpression( [ factory2.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), @@ -105371,7 +105764,7 @@ function transformSystemModule(context) { factory2.createAssignment(importVariableName, parameterName) ) ); - if (hasSyntacticModifier(entry, 1 /* Export */)) { + if (hasSyntacticModifier(entry, 32 /* Export */)) { statements.push( factory2.createExpressionStatement( factory2.createCallExpression( @@ -105524,7 +105917,7 @@ function transformSystemModule(context) { ); } function visitFunctionDeclaration(node) { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { hoistedStatements = append( hoistedStatements, factory2.updateFunctionDeclaration( @@ -105611,7 +106004,7 @@ function transformSystemModule(context) { statements = append(statements, factory2.updateVariableStatement(node, modifiers, declarationList)); } else { let expressions; - const isExportedDeclaration = hasSyntacticModifier(node, 1 /* Export */); + const isExportedDeclaration = hasSyntacticModifier(node, 32 /* Export */); for (const variable of node.declarationList.declarations) { if (variable.initializer) { expressions = append(expressions, transformInitializedVariable(variable, isExportedDeclaration)); @@ -105747,8 +106140,8 @@ function transformSystemModule(context) { return statements; } let excludeName; - if (hasSyntacticModifier(decl, 1 /* Export */)) { - const exportName = hasSyntacticModifier(decl, 1024 /* Default */) ? factory2.createStringLiteral("default") : decl.name; + if (hasSyntacticModifier(decl, 32 /* Export */)) { + const exportName = hasSyntacticModifier(decl, 2048 /* Default */) ? factory2.createStringLiteral("default") : decl.name; statements = appendExportStatement(statements, exportName, factory2.getLocalName(decl)); excludeName = getTextOfIdentifierOrLiteral(exportName); } @@ -106493,7 +106886,7 @@ function transformECMAScriptModule(context) { return singleOrMany(statements); } function appendExportsOfImportEqualsDeclaration(statements, node) { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { statements = append( statements, factory2.createExportDeclaration( @@ -106703,7 +107096,7 @@ function createGetSymbolAccessibilityDiagnosticForNode(node) { } else if (isConstructSignatureDeclaration(node) || isCallSignatureDeclaration(node) || isMethodDeclaration(node) || isMethodSignature(node) || isFunctionDeclaration(node) || isIndexSignatureDeclaration(node)) { return getReturnTypeVisibilityError; } else if (isParameter(node)) { - if (isParameterPropertyDeclaration(node, node.parent) && hasSyntacticModifier(node.parent, 8 /* Private */)) { + if (isParameterPropertyDeclaration(node, node.parent) && hasSyntacticModifier(node.parent, 2 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -106721,7 +107114,7 @@ function createGetSymbolAccessibilityDiagnosticForNode(node) { function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (node.kind === 260 /* VariableDeclaration */ || node.kind === 208 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; - } else if (node.kind === 172 /* PropertyDeclaration */ || node.kind === 211 /* PropertyAccessExpression */ || node.kind === 212 /* ElementAccessExpression */ || node.kind === 226 /* BinaryExpression */ || node.kind === 171 /* PropertySignature */ || node.kind === 169 /* Parameter */ && hasSyntacticModifier(node.parent, 8 /* Private */)) { + } else if (node.kind === 172 /* PropertyDeclaration */ || node.kind === 211 /* PropertyAccessExpression */ || node.kind === 212 /* ElementAccessExpression */ || node.kind === 226 /* BinaryExpression */ || node.kind === 171 /* PropertySignature */ || node.kind === 169 /* Parameter */ && hasSyntacticModifier(node.parent, 2 /* Private */)) { if (isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } else if (node.parent.kind === 263 /* ClassDeclaration */ || node.kind === 169 /* Parameter */) { @@ -107019,6 +107412,17 @@ function transformDeclarations(context) { const container = getSourceFileOfNode(node); refs.set(getOriginalNodeId(container), container); } + function trackReferencedAmbientModuleFromImport(node) { + const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(node); + const symbol = moduleSpecifier && resolver.tryFindAmbientModule(moduleSpecifier); + if (symbol == null ? void 0 : symbol.declarations) { + for (const decl of symbol.declarations) { + if (isAmbientModule(decl) && getSourceFileOfNode(decl) !== currentSourceFile) { + trackReferencedAmbientModule(decl, symbol); + } + } + } + } function handleSymbolAccessibilityError(symbolAccessibilityResult) { if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) { if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { @@ -107431,7 +107835,7 @@ function transformDeclarations(context) { return void 0; } function ensureType(node, type, ignorePrivate) { - if (!ignorePrivate && hasEffectiveModifier(node, 8 /* Private */)) { + if (!ignorePrivate && hasEffectiveModifier(node, 2 /* Private */)) { return; } if (shouldPrintWithInitializer(node)) { @@ -107511,7 +107915,7 @@ function transformDeclarations(context) { } } function updateParamsList(node, params, modifierMask) { - if (hasEffectiveModifier(node, 8 /* Private */)) { + if (hasEffectiveModifier(node, 2 /* Private */)) { return factory2.createNodeArray(); } const newParams = map(params, (p) => ensureParameter(p, modifierMask)); @@ -107556,7 +107960,7 @@ function transformDeclarations(context) { return factory2.createNodeArray(newParams || emptyArray); } function ensureTypeParams(node, params) { - return hasEffectiveModifier(node, 8 /* Private */) ? void 0 : visitNodes2(params, visitDeclarationSubtree, isTypeParameterDeclaration); + return hasEffectiveModifier(node, 2 /* Private */) ? void 0 : visitNodes2(params, visitDeclarationSubtree, isTypeParameterDeclaration); } function isEnclosingDeclaration(node) { return isSourceFile(node) || isTypeAliasDeclaration(node) || isModuleDeclaration(node) || isClassDeclaration(node) || isInterfaceDeclaration(node) || isFunctionLike(node) || isIndexSignatureDeclaration(node) || isMappedTypeNode(node); @@ -107742,7 +108146,7 @@ function transformDeclarations(context) { const oldWithinObjectLiteralType = suppressNewDiagnosticContexts; let shouldEnterSuppressNewDiagnosticsContextContext = (input.kind === 187 /* TypeLiteral */ || input.kind === 200 /* MappedType */) && input.parent.kind !== 265 /* TypeAliasDeclaration */; if (isMethodDeclaration(input) || isMethodSignature(input)) { - if (hasEffectiveModifier(input, 8 /* Private */)) { + if (hasEffectiveModifier(input, 2 /* Private */)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; return cleanup(factory2.createPropertyDeclaration( @@ -107830,7 +108234,7 @@ function transformDeclarations(context) { input, ensureModifiers(input), input.name, - updateAccessorParamsList(input, hasEffectiveModifier(input, 8 /* Private */)), + updateAccessorParamsList(input, hasEffectiveModifier(input, 2 /* Private */)), ensureType(input, accessorType), /*body*/ void 0 @@ -107847,7 +108251,7 @@ function transformDeclarations(context) { input, ensureModifiers(input), input.name, - updateAccessorParamsList(input, hasEffectiveModifier(input, 8 /* Private */)), + updateAccessorParamsList(input, hasEffectiveModifier(input, 2 /* Private */)), /*body*/ void 0 )); @@ -107966,6 +108370,7 @@ function transformDeclarations(context) { case 205 /* ImportType */: { if (!isLiteralImportTypeNode(input)) return cleanup(input); + trackReferencedAmbientModuleFromImport(input); return cleanup(factory2.updateImportTypeNode( input, factory2.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), @@ -108003,7 +108408,7 @@ function transformDeclarations(context) { } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 174 /* MethodDeclaration */ && hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 174 /* MethodDeclaration */ && hasEffectiveModifier(node.parent, 2 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -108017,6 +108422,7 @@ function transformDeclarations(context) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; + trackReferencedAmbientModuleFromImport(input); return factory2.updateExportDeclaration( input, input.modifiers, @@ -108061,11 +108467,11 @@ function transformDeclarations(context) { return input; } function stripExportModifiers(statement) { - if (isImportEqualsDeclaration(statement) || hasEffectiveModifier(statement, 1024 /* Default */) || !canHaveModifiers(statement)) { + if (isImportEqualsDeclaration(statement) || hasEffectiveModifier(statement, 2048 /* Default */) || !canHaveModifiers(statement)) { return statement; } - const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (258047 /* All */ ^ 1 /* Export */)); - return factory2.updateModifiers(statement, modifiers); + const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (131071 /* All */ ^ 32 /* Export */)); + return factory2.replaceModifiers(statement, modifiers); } function updateModuleDeclarationAndKeyword(node, modifiers, name, body) { const updated = factory2.updateModuleDeclaration(node, modifiers, name, body); @@ -108091,10 +108497,18 @@ function transformDeclarations(context) { return; switch (input.kind) { case 271 /* ImportEqualsDeclaration */: { - return transformImportEqualsDeclaration(input); + const transformed = transformImportEqualsDeclaration(input); + if (transformed) { + trackReferencedAmbientModuleFromImport(input); + } + return transformed; } case 272 /* ImportDeclaration */: { - return transformImportDeclaration(input); + const transformed = transformImportDeclaration(input); + if (transformed) { + trackReferencedAmbientModuleFromImport(input); + } + return transformed; } } if (isDeclaration(input) && isDeclarationAndNotVisible(input)) @@ -108188,7 +108602,7 @@ function transformDeclarations(context) { return factory2.createVariableStatement(isNonContextualKeywordName ? void 0 : [factory2.createToken(95 /* ExportKeyword */)], factory2.createVariableDeclarationList([varDecl])); }); if (!exportMappings.length) { - declarations = mapDefined(declarations, (declaration) => factory2.updateModifiers(declaration, 0 /* None */)); + declarations = mapDefined(declarations, (declaration) => factory2.replaceModifiers(declaration, 0 /* None */)); } else { declarations.push(factory2.createExportDeclaration( /*modifiers*/ @@ -108206,10 +108620,10 @@ function transformDeclarations(context) { )); } const namespaceDecl = factory2.createModuleDeclaration(ensureModifiers(input), input.name, factory2.createModuleBlock(declarations), 32 /* Namespace */); - if (!hasEffectiveModifier(clean2, 1024 /* Default */)) { + if (!hasEffectiveModifier(clean2, 2048 /* Default */)) { return [clean2, namespaceDecl]; } - const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(clean2) & ~1025 /* ExportDefault */ | 2 /* Ambient */); + const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(clean2) & ~2080 /* ExportDefault */ | 128 /* Ambient */); const cleanDeclaration = factory2.updateFunctionDeclaration( clean2, modifiers, @@ -108301,7 +108715,7 @@ function transformDeclarations(context) { if (ctor) { const oldDiag2 = getSymbolAccessibilityDiagnostic; parameterProperties = compact(flatMap(ctor.parameters, (param) => { - if (!hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!hasSyntacticModifier(param, 31 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(param); if (param.name.kind === 80 /* Identifier */) { @@ -108530,11 +108944,11 @@ function transformDeclarations(context) { return factory2.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - let mask = 258047 /* All */ ^ (4 /* Public */ | 512 /* Async */ | 16384 /* Override */); - let additions = needsDeclare && !isAlwaysType(node) ? 2 /* Ambient */ : 0 /* None */; + let mask = 131071 /* All */ ^ (1 /* Public */ | 1024 /* Async */ | 16 /* Override */); + let additions = needsDeclare && !isAlwaysType(node) ? 128 /* Ambient */ : 0 /* None */; const parentIsFile = node.parent.kind === 312 /* SourceFile */; if (!parentIsFile || isBundledEmit && parentIsFile && isExternalModule(node.parent)) { - mask ^= 2 /* Ambient */; + mask ^= 128 /* Ambient */; additions = 0 /* None */; } return maskModifierFlags(node, mask, additions); @@ -108576,13 +108990,13 @@ function isAlwaysType(node) { function maskModifiers(factory2, node, modifierMask, modifierAdditions) { return factory2.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } -function maskModifierFlags(node, modifierMask = 258047 /* All */ ^ 4 /* Public */, modifierAdditions = 0 /* None */) { +function maskModifierFlags(node, modifierMask = 131071 /* All */ ^ 1 /* Public */, modifierAdditions = 0 /* None */) { let flags = getEffectiveModifierFlags(node) & modifierMask | modifierAdditions; - if (flags & 1024 /* Default */ && !(flags & 1 /* Export */)) { - flags ^= 1 /* Export */; + if (flags & 2048 /* Default */ && !(flags & 32 /* Export */)) { + flags ^= 32 /* Export */; } - if (flags & 1024 /* Default */ && flags & 2 /* Ambient */) { - flags ^= 2 /* Ambient */; + if (flags & 2048 /* Default */ && flags & 128 /* Ambient */) { + flags ^= 128 /* Ambient */; } return flags; } @@ -108595,7 +109009,7 @@ function canHaveLiteralInitializer(node) { switch (node.kind) { case 172 /* PropertyDeclaration */: case 171 /* PropertySignature */: - return !hasEffectiveModifier(node, 8 /* Private */); + return !hasEffectiveModifier(node, 2 /* Private */); case 169 /* Parameter */: case 260 /* VariableDeclaration */: return true; @@ -109697,7 +110111,8 @@ var notImplementedResolver = { getSymbolOfExternalModuleSpecifier: notImplemented, isBindingCapturedByNode: notImplemented, getDeclarationStatementsForSourceFile: notImplemented, - isImportRequiredByAugmentation: notImplemented + isImportRequiredByAugmentation: notImplemented, + tryFindAmbientModule: notImplemented }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var _a; @@ -117353,7 +117768,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config } } } else if (isModuleDeclaration(node)) { - if (isAmbientModule(node) && (inAmbientModule || hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) { + if (isAmbientModule(node) && (inAmbientModule || hasSyntacticModifier(node, 128 /* Ambient */) || file.isDeclarationFile)) { node.name.parent = node; const nameText = getTextOfIdentifierOrLiteral(node.name); if (isExternalModuleFile || inAmbientModule && !isExternalModuleNameRelative(nameText)) { @@ -120899,6 +121314,10 @@ function getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirec const normalized = getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()); return !isDiskPathRoot(normalized) ? removeTrailingDirectorySeparator(normalized) : normalized; } +function getModuleResolutionHost(resolutionHost) { + var _a; + return ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost; +} function createModuleResolutionLoaderUsingGlobalCache(containingFile, redirectedReference, options, resolutionHost, moduleResolutionCache) { return { nameAndMode: moduleResolutionNameAndModeGetter, @@ -120914,8 +121333,7 @@ function createModuleResolutionLoaderUsingGlobalCache(containingFile, redirected }; } function resolveModuleNameUsingGlobalCache(resolutionHost, moduleResolutionCache, moduleName, containingFile, compilerOptions, redirectedReference, mode) { - var _a; - const host = ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost; + const host = getModuleResolutionHost(resolutionHost); const primaryResult = resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode); if (!resolutionHost.getGlobalCache) { return primaryResult; @@ -121086,6 +121504,10 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW }; } function startCachingPerDirectoryResolution() { + moduleResolutionCache.isReadonly = void 0; + typeReferenceDirectiveResolutionCache.isReadonly = void 0; + libraryResolutionCache.isReadonly = void 0; + moduleResolutionCache.getPackageJsonInfoCache().isReadonly = void 0; moduleResolutionCache.clearAllExceptPackageJsonInfoCache(); typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache(); libraryResolutionCache.clearAllExceptPackageJsonInfoCache(); @@ -121143,6 +121565,10 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW directoryWatchesOfFailedLookups.forEach(closeDirectoryWatchesOfFailedLookup); fileWatchesOfAffectingLocations.forEach(closeFileWatcherOfAffectingLocation); hasChangedAutomaticTypeDirectiveNames = false; + moduleResolutionCache.isReadonly = true; + typeReferenceDirectiveResolutionCache.isReadonly = true; + libraryResolutionCache.isReadonly = true; + moduleResolutionCache.getPackageJsonInfoCache().isReadonly = true; } function closeDirectoryWatchesOfFailedLookup(watcher, path) { if (watcher.refCount === 0) { @@ -121171,7 +121597,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW shouldRetryResolution, logChanges }) { - var _a; const path = resolutionHost.toPath(containingFile); const resolutionsInFile = perFileCache.get(path) || perFileCache.set(path, createModeAwareCache()).get(path); const resolvedModules = []; @@ -121203,7 +121628,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW logChanges = false; } } else { - const host = ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost; + const host = getModuleResolutionHost(resolutionHost); if (isTraceEnabled(options, host) && !seenNamesInFile.has(name, mode)) { const resolved = getResolutionWithResolvedFileName(resolution); trace( @@ -121255,7 +121680,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW } } function resolveTypeReferenceDirectiveReferences(typeDirectiveReferences, containingFile, redirectedReference, options, containingSourceFile, reusedNames) { - var _a; return resolveNamesWithLocalCache({ entries: typeDirectiveReferences, containingFile, @@ -121268,7 +121692,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW containingFile, redirectedReference, options, - ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost, + getModuleResolutionHost(resolutionHost), typeReferenceDirectiveResolutionCache ), getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective, @@ -121300,8 +121724,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW }); } function resolveLibrary2(libraryName, resolveFrom, options, libFileName) { - var _a; - const host = ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost; + const host = getModuleResolutionHost(resolutionHost); let resolution = resolvedLibraries == null ? void 0 : resolvedLibraries.get(libFileName); if (!resolution || resolution.isInvalidated) { const existingResolution = resolution; @@ -121335,6 +121758,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW return resolution; } function resolveSingleModuleNameWithoutWatching(moduleName, containingFile) { + var _a, _b; const path = resolutionHost.toPath(containingFile); const resolutionsInFile = resolvedModuleNames.get(path); const resolution = resolutionsInFile == null ? void 0 : resolutionsInFile.get( @@ -121344,7 +121768,17 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW ); if (resolution && !resolution.isInvalidated) return resolution; - return resolveModuleNameUsingGlobalCache(resolutionHost, moduleResolutionCache, moduleName, containingFile, resolutionHost.getCompilationSettings()); + const data = (_a = resolutionHost.beforeResolveSingleModuleNameWithoutWatching) == null ? void 0 : _a.call(resolutionHost, moduleResolutionCache); + const host = getModuleResolutionHost(resolutionHost); + const result = resolveModuleName( + moduleName, + containingFile, + resolutionHost.getCompilationSettings(), + host, + moduleResolutionCache + ); + (_b = resolutionHost.afterResolveSingleModuleNameWithoutWatching) == null ? void 0 : _b.call(resolutionHost, moduleResolutionCache, moduleName, containingFile, result, data); + return result; } function isNodeModulesAtTypesDirectory(dirPath) { return endsWith(dirPath, "/node_modules/@types"); @@ -122490,7 +122924,7 @@ function createIncrementalProgram({ } function createWatchProgram(host) { let builderProgram; - let reloadLevel; + let updateLevel; let missingFilesMap; let watchedWildcardDirectories; let timerToUpdateProgram; @@ -122849,7 +123283,7 @@ function createWatchProgram(host) { } function scheduleProgramReload() { Debug.assert(!!configFileName); - reloadLevel = 2 /* Full */; + updateLevel = 2 /* Full */; scheduleProgramUpdate(); } function updateProgramWithWatchStatus() { @@ -122859,8 +123293,8 @@ function createWatchProgram(host) { } function updateProgram() { var _a, _b, _c, _d; - switch (reloadLevel) { - case 1 /* Partial */: + switch (updateLevel) { + case 1 /* RootNamesAndUpdate */: (_a = perfLogger) == null ? void 0 : _a.logStartUpdateProgram("PartialConfigReload"); reloadFileNamesFromConfigFile(); break; @@ -122880,7 +123314,7 @@ function createWatchProgram(host) { writeLog("Reloading new file names and options"); Debug.assert(compilerOptions); Debug.assert(configFileName); - reloadLevel = 0 /* None */; + updateLevel = 0 /* Update */; rootFileNames = getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, getNormalizedAbsolutePath(getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions); if (updateErrorForNoInputFiles(rootFileNames, getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) { hasChangedConfigFileParsingErrors = true; @@ -122890,7 +123324,7 @@ function createWatchProgram(host) { function reloadConfigFile() { Debug.assert(configFileName); writeLog(`Reloading config file: ${configFileName}`); - reloadLevel = 0 /* None */; + updateLevel = 0 /* Update */; if (cachedDirectoryStructureHost) { cachedDirectoryStructureHost.clearCache(); } @@ -122927,9 +123361,9 @@ function createWatchProgram(host) { const configPath = toPath3(configFileName2); let config = parsedConfigs == null ? void 0 : parsedConfigs.get(configPath); if (config) { - if (!config.reloadLevel) + if (!config.updateLevel) return config.parsedCommandLine; - if (config.parsedCommandLine && config.reloadLevel === 1 /* Partial */ && !host.getParsedCommandLine) { + if (config.parsedCommandLine && config.updateLevel === 1 /* RootNamesAndUpdate */ && !host.getParsedCommandLine) { writeLog("Reloading new file names and options"); Debug.assert(compilerOptions); const fileNames = getFileNamesFromConfigSpecs( @@ -122939,7 +123373,7 @@ function createWatchProgram(host) { parseConfigFileHost ); config.parsedCommandLine = { ...config.parsedCommandLine, fileNames }; - config.reloadLevel = void 0; + config.updateLevel = void 0; return config.parsedCommandLine; } } @@ -122947,7 +123381,7 @@ function createWatchProgram(host) { const parsedCommandLine = host.getParsedCommandLine ? host.getParsedCommandLine(configFileName2) : getParsedCommandLineFromConfigFileHost(configFileName2); if (config) { config.parsedCommandLine = parsedCommandLine; - config.reloadLevel = void 0; + config.updateLevel = void 0; } else { (parsedConfigs || (parsedConfigs = /* @__PURE__ */ new Map())).set(configPath, config = { parsedCommandLine }); } @@ -123044,8 +123478,8 @@ function createWatchProgram(host) { toPath: toPath3 })) return; - if (reloadLevel !== 2 /* Full */) { - reloadLevel = 1 /* Partial */; + if (updateLevel !== 2 /* Full */) { + updateLevel = 1 /* RootNamesAndUpdate */; scheduleProgramUpdate(); } }, @@ -123071,11 +123505,11 @@ function createWatchProgram(host) { return; projects.forEach((projectPath) => { if (configFileName && toPath3(configFileName) === projectPath) { - reloadLevel = 2 /* Full */; + updateLevel = 2 /* Full */; } else { const config = parsedConfigs == null ? void 0 : parsedConfigs.get(projectPath); if (config) - config.reloadLevel = 2 /* Full */; + config.updateLevel = 2 /* Full */; resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath); } scheduleProgramUpdate(); @@ -123096,7 +123530,7 @@ function createWatchProgram(host) { updateCachedSystemWithFile(configFileName2, configPath, eventKind); const config = parsedConfigs == null ? void 0 : parsedConfigs.get(configPath); if (config) - config.reloadLevel = 2 /* Full */; + config.updateLevel = 2 /* Full */; resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath); scheduleProgramUpdate(); }, @@ -123134,8 +123568,8 @@ function createWatchProgram(host) { toPath: toPath3 })) return; - if (config.reloadLevel !== 2 /* Full */) { - config.reloadLevel = 1 /* Partial */; + if (config.updateLevel !== 2 /* Full */) { + config.updateLevel = 1 /* RootNamesAndUpdate */; scheduleProgramUpdate(); } }, @@ -123577,12 +124011,12 @@ function clearProjectStatus(state, resolved) { state.projectStatus.delete(resolved); state.diagnostics.delete(resolved); } -function addProjToQueue({ projectPendingBuild }, proj, reloadLevel) { +function addProjToQueue({ projectPendingBuild }, proj, updateLevel) { const value = projectPendingBuild.get(proj); if (value === void 0) { - projectPendingBuild.set(proj, reloadLevel); - } else if (value < reloadLevel) { - projectPendingBuild.set(proj, reloadLevel); + projectPendingBuild.set(proj, updateLevel); + } else if (value < updateLevel) { + projectPendingBuild.set(proj, updateLevel); } } function setupInitialBuild(state, cancellationToken) { @@ -123596,7 +124030,7 @@ function setupInitialBuild(state, cancellationToken) { buildOrder.forEach( (configFileName) => state.projectPendingBuild.set( toResolvedConfigFilePath(state, configFileName), - 0 /* None */ + 0 /* Update */ ) ); if (cancellationToken) { @@ -124032,8 +124466,8 @@ function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) { for (let projectIndex = 0; projectIndex < buildOrder.length; projectIndex++) { const project = buildOrder[projectIndex]; const projectPath = toResolvedConfigFilePath(state, project); - const reloadLevel = state.projectPendingBuild.get(projectPath); - if (reloadLevel === void 0) + const updateLevel = state.projectPendingBuild.get(projectPath); + if (updateLevel === void 0) continue; if (reportQueue) { reportQueue = false; @@ -124045,13 +124479,13 @@ function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) { projectPendingBuild.delete(projectPath); continue; } - if (reloadLevel === 2 /* Full */) { + if (updateLevel === 2 /* Full */) { watchConfigFile(state, project, projectPath, config); watchExtendedConfigFiles(state, projectPath, config); watchWildCardDirectories(state, project, projectPath, config); watchInputFiles(state, project, projectPath, config); watchPackageJsonFiles(state, project, projectPath, config); - } else if (reloadLevel === 1 /* Partial */) { + } else if (updateLevel === 1 /* RootNamesAndUpdate */) { config.fileNames = getFileNamesFromConfigSpecs(config.options.configFile.configFileSpecs, getDirectoryPath(project), config.options, state.parseConfigFileHost); updateErrorForNoInputFiles(config.fileNames, project, config.options.configFile.configFileSpecs, config.errors, canJsonReportNoInputFiles(config.raw)); watchInputFiles(state, project, projectPath, config); @@ -124638,7 +125072,7 @@ function queueReferencingProjects(state, project, projectPath, projectIndex, con break; } } - addProjToQueue(state, nextProjectPath, 0 /* None */); + addProjToQueue(state, nextProjectPath, 0 /* Update */); break; } } @@ -124707,7 +125141,7 @@ function cleanWorker(state, project, onlyReferences) { filesToDelete.push(output); } else { host.deleteFile(output); - invalidateProject(state, resolvedPath, 0 /* None */); + invalidateProject(state, resolvedPath, 0 /* Update */); } } } @@ -124718,22 +125152,22 @@ function cleanWorker(state, project, onlyReferences) { } return 0 /* Success */; } -function invalidateProject(state, resolved, reloadLevel) { - if (state.host.getParsedCommandLine && reloadLevel === 1 /* Partial */) { - reloadLevel = 2 /* Full */; +function invalidateProject(state, resolved, updateLevel) { + if (state.host.getParsedCommandLine && updateLevel === 1 /* RootNamesAndUpdate */) { + updateLevel = 2 /* Full */; } - if (reloadLevel === 2 /* Full */) { + if (updateLevel === 2 /* Full */) { state.configFileCache.delete(resolved); state.buildOrder = void 0; } state.needsSummary = true; clearProjectStatus(state, resolved); - addProjToQueue(state, resolved, reloadLevel); + addProjToQueue(state, resolved, updateLevel); enableCache(state); } -function invalidateProjectAndScheduleBuilds(state, resolvedPath, reloadLevel) { +function invalidateProjectAndScheduleBuilds(state, resolvedPath, updateLevel) { state.reportFileChangeDetected = true; - invalidateProject(state, resolvedPath, reloadLevel); + invalidateProject(state, resolvedPath, updateLevel); scheduleBuildInvalidatedProject( state, 250, @@ -124864,7 +125298,7 @@ function watchWildCardDirectories(state, resolved, resolvedPath, parsed) { toPath: (fileName) => toPath2(state, fileName) })) return; - invalidateProjectAndScheduleBuilds(state, resolvedPath, 1 /* Partial */); + invalidateProjectAndScheduleBuilds(state, resolvedPath, 1 /* RootNamesAndUpdate */); }, flags, parsed == null ? void 0 : parsed.watchOptions, @@ -124883,7 +125317,7 @@ function watchInputFiles(state, resolved, resolvedPath, parsed) { createNewValue: (_path, input) => watchFile( state, input, - () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* None */), + () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* Update */), 250 /* Low */, parsed == null ? void 0 : parsed.watchOptions, WatchType.SourceFile, @@ -124903,7 +125337,7 @@ function watchPackageJsonFiles(state, resolved, resolvedPath, parsed) { createNewValue: (path, _input) => watchFile( state, path, - () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* None */), + () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* Update */), 2e3 /* High */, parsed == null ? void 0 : parsed.watchOptions, WatchType.PackageJson, @@ -124974,7 +125408,7 @@ function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, opti const configFilePath = toResolvedConfigFilePath(state, configFileName); return getUpToDateStatus(state, parseConfigFile(state, configFileName, configFilePath), configFilePath); }, - invalidateProject: (configFilePath, reloadLevel) => invalidateProject(state, configFilePath, reloadLevel || 0 /* None */), + invalidateProject: (configFilePath, updateLevel) => invalidateProject(state, configFilePath, updateLevel || 0 /* Update */), close: () => stopWatching(state) }; } diff --git a/lib/tsserver.js b/lib/tsserver.js index 01baa73140352..a50f196cdf704 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -58,7 +58,6 @@ __export(server_exports, { CompletionInfoFlags: () => CompletionInfoFlags, CompletionTriggerKind: () => CompletionTriggerKind, Completions: () => ts_Completions_exports, - ConfigFileProgramReloadLevel: () => ConfigFileProgramReloadLevel, ContainerFlags: () => ContainerFlags, ContextFlags: () => ContextFlags, Debug: () => Debug, @@ -145,6 +144,7 @@ __export(server_exports, { PragmaKindFlags: () => PragmaKindFlags, PrivateIdentifierKind: () => PrivateIdentifierKind, ProcessLevel: () => ProcessLevel, + ProgramUpdateLevel: () => ProgramUpdateLevel, QuotePreference: () => QuotePreference, RelationComparisonResult: () => RelationComparisonResult, Rename: () => ts_Rename_exports, @@ -6185,32 +6185,43 @@ var NodeFlags = /* @__PURE__ */ ((NodeFlags3) => { })(NodeFlags || {}); var ModifierFlags = /* @__PURE__ */ ((ModifierFlags3) => { ModifierFlags3[ModifierFlags3["None"] = 0] = "None"; - ModifierFlags3[ModifierFlags3["Export"] = 1] = "Export"; - ModifierFlags3[ModifierFlags3["Ambient"] = 2] = "Ambient"; - ModifierFlags3[ModifierFlags3["Public"] = 4] = "Public"; - ModifierFlags3[ModifierFlags3["Private"] = 8] = "Private"; - ModifierFlags3[ModifierFlags3["Protected"] = 16] = "Protected"; - ModifierFlags3[ModifierFlags3["Static"] = 32] = "Static"; - ModifierFlags3[ModifierFlags3["Readonly"] = 64] = "Readonly"; - ModifierFlags3[ModifierFlags3["Accessor"] = 128] = "Accessor"; - ModifierFlags3[ModifierFlags3["Abstract"] = 256] = "Abstract"; - ModifierFlags3[ModifierFlags3["Async"] = 512] = "Async"; - ModifierFlags3[ModifierFlags3["Default"] = 1024] = "Default"; - ModifierFlags3[ModifierFlags3["Const"] = 2048] = "Const"; - ModifierFlags3[ModifierFlags3["HasComputedJSDocModifiers"] = 4096] = "HasComputedJSDocModifiers"; - ModifierFlags3[ModifierFlags3["Deprecated"] = 8192] = "Deprecated"; - ModifierFlags3[ModifierFlags3["Override"] = 16384] = "Override"; - ModifierFlags3[ModifierFlags3["In"] = 32768] = "In"; - ModifierFlags3[ModifierFlags3["Out"] = 65536] = "Out"; - ModifierFlags3[ModifierFlags3["Decorator"] = 131072] = "Decorator"; + ModifierFlags3[ModifierFlags3["Public"] = 1] = "Public"; + ModifierFlags3[ModifierFlags3["Private"] = 2] = "Private"; + ModifierFlags3[ModifierFlags3["Protected"] = 4] = "Protected"; + ModifierFlags3[ModifierFlags3["Readonly"] = 8] = "Readonly"; + ModifierFlags3[ModifierFlags3["Override"] = 16] = "Override"; + ModifierFlags3[ModifierFlags3["Export"] = 32] = "Export"; + ModifierFlags3[ModifierFlags3["Abstract"] = 64] = "Abstract"; + ModifierFlags3[ModifierFlags3["Ambient"] = 128] = "Ambient"; + ModifierFlags3[ModifierFlags3["Static"] = 256] = "Static"; + ModifierFlags3[ModifierFlags3["Accessor"] = 512] = "Accessor"; + ModifierFlags3[ModifierFlags3["Async"] = 1024] = "Async"; + ModifierFlags3[ModifierFlags3["Default"] = 2048] = "Default"; + ModifierFlags3[ModifierFlags3["Const"] = 4096] = "Const"; + ModifierFlags3[ModifierFlags3["In"] = 8192] = "In"; + ModifierFlags3[ModifierFlags3["Out"] = 16384] = "Out"; + ModifierFlags3[ModifierFlags3["Decorator"] = 32768] = "Decorator"; + ModifierFlags3[ModifierFlags3["Deprecated"] = 65536] = "Deprecated"; + ModifierFlags3[ModifierFlags3["JSDocPublic"] = 8388608] = "JSDocPublic"; + ModifierFlags3[ModifierFlags3["JSDocPrivate"] = 16777216] = "JSDocPrivate"; + ModifierFlags3[ModifierFlags3["JSDocProtected"] = 33554432] = "JSDocProtected"; + ModifierFlags3[ModifierFlags3["JSDocReadonly"] = 67108864] = "JSDocReadonly"; + ModifierFlags3[ModifierFlags3["JSDocOverride"] = 134217728] = "JSDocOverride"; + ModifierFlags3[ModifierFlags3["SyntacticOrJSDocModifiers"] = 31] = "SyntacticOrJSDocModifiers"; + ModifierFlags3[ModifierFlags3["SyntacticOnlyModifiers"] = 65504] = "SyntacticOnlyModifiers"; + ModifierFlags3[ModifierFlags3["SyntacticModifiers"] = 65535] = "SyntacticModifiers"; + ModifierFlags3[ModifierFlags3["JSDocCacheOnlyModifiers"] = 260046848] = "JSDocCacheOnlyModifiers"; + ModifierFlags3[ModifierFlags3["JSDocOnlyModifiers"] = 65536 /* Deprecated */] = "JSDocOnlyModifiers"; + ModifierFlags3[ModifierFlags3["NonCacheOnlyModifiers"] = 131071] = "NonCacheOnlyModifiers"; + ModifierFlags3[ModifierFlags3["HasComputedJSDocModifiers"] = 268435456] = "HasComputedJSDocModifiers"; ModifierFlags3[ModifierFlags3["HasComputedFlags"] = 536870912] = "HasComputedFlags"; - ModifierFlags3[ModifierFlags3["AccessibilityModifier"] = 28] = "AccessibilityModifier"; - ModifierFlags3[ModifierFlags3["ParameterPropertyModifier"] = 16476] = "ParameterPropertyModifier"; - ModifierFlags3[ModifierFlags3["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; - ModifierFlags3[ModifierFlags3["TypeScriptModifier"] = 117086] = "TypeScriptModifier"; - ModifierFlags3[ModifierFlags3["ExportDefault"] = 1025] = "ExportDefault"; - ModifierFlags3[ModifierFlags3["All"] = 258047] = "All"; - ModifierFlags3[ModifierFlags3["Modifier"] = 126975] = "Modifier"; + ModifierFlags3[ModifierFlags3["AccessibilityModifier"] = 7] = "AccessibilityModifier"; + ModifierFlags3[ModifierFlags3["ParameterPropertyModifier"] = 31] = "ParameterPropertyModifier"; + ModifierFlags3[ModifierFlags3["NonPublicAccessibilityModifier"] = 6] = "NonPublicAccessibilityModifier"; + ModifierFlags3[ModifierFlags3["TypeScriptModifier"] = 28895] = "TypeScriptModifier"; + ModifierFlags3[ModifierFlags3["ExportDefault"] = 2080] = "ExportDefault"; + ModifierFlags3[ModifierFlags3["All"] = 131071] = "All"; + ModifierFlags3[ModifierFlags3["Modifier"] = 98303] = "Modifier"; return ModifierFlags3; })(ModifierFlags || {}); var JsxFlags = /* @__PURE__ */ ((JsxFlags2) => { @@ -10161,7 +10172,7 @@ var Diagnostics = { Import_assertion_values_must_be_string_literal_expressions: diag(2837, 1 /* Error */, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."), All_declarations_of_0_must_have_identical_constraints: diag(2838, 1 /* Error */, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."), This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, 1 /* Error */, "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839", "This condition will always return '{0}' since JavaScript compares objects by reference, not value."), - An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes: diag(2840, 1 /* Error */, "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840", "An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes"), + An_interface_cannot_extend_a_primitive_type_like_0_It_can_only_extend_other_named_object_types: diag(2840, 1 /* Error */, "An_interface_cannot_extend_a_primitive_type_like_0_It_can_only_extend_other_named_object_types_2840", "An interface cannot extend a primitive type like '{0}'. It can only extend other named object types."), _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, 1 /* Error */, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"), We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, 1 /* Error */, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."), Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, 1 /* Error */, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), @@ -10181,6 +10192,9 @@ var Diagnostics = { Excessive_complexity_comparing_types_0_and_1: diag(2859, 1 /* Error */, "Excessive_complexity_comparing_types_0_and_1_2859", "Excessive complexity comparing types '{0}' and '{1}'."), The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_hand_side_s_Symbol_hasInstance_method: diag(2860, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_2860", "The left-hand side of an 'instanceof' expression must be assignable to the first argument of the right-hand side's '[Symbol.hasInstance]' method."), An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_hand_side_of_an_instanceof_expression: diag(2861, 1 /* Error */, "An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_han_2861", "An object's '[Symbol.hasInstance]' method must return a boolean value for it to be used on the right-hand side of an 'instanceof' expression."), + Type_0_is_generic_and_can_only_be_indexed_for_reading: diag(2862, 1 /* Error */, "Type_0_is_generic_and_can_only_be_indexed_for_reading_2862", "Type '{0}' is generic and can only be indexed for reading."), + A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values: diag(2863, 1 /* Error */, "A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values_2863", "A class cannot extend a primitive type like '{0}'. Classes can only extend constructable values."), + A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types: diag(2864, 1 /* Error */, "A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types_2864", "A class cannot implement a primitive type like '{0}'. It can only implement other named object types."), Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* 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, 1 /* 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, 1 /* 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}'."), @@ -13685,7 +13699,7 @@ function getTypeParameterOwner(d) { } } function isParameterPropertyDeclaration(node, parent2) { - return isParameter(node) && hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent2.kind === 176 /* Constructor */; + return isParameter(node) && hasSyntacticModifier(node, 31 /* ParameterPropertyModifier */) && parent2.kind === 176 /* Constructor */; } function isEmptyBindingPattern(node) { if (isBindingPattern(node)) { @@ -13975,7 +13989,7 @@ function getDecorators(node) { } } function getModifiers(node) { - if (hasSyntacticModifier(node, 126975 /* Modifier */)) { + if (hasSyntacticModifier(node, 98303 /* Modifier */)) { return filter(node.modifiers, isModifier); } } @@ -14409,7 +14423,7 @@ function isModifierKind(token) { return false; } function isParameterPropertyModifier(kind) { - return !!(modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); + return !!(modifierToFlag(kind) & 31 /* ParameterPropertyModifier */); } function isClassMemberModifier(idToken) { return isParameterPropertyModifier(idToken) || idToken === 126 /* StaticKeyword */ || idToken === 164 /* OverrideKeyword */ || idToken === 129 /* AccessorKeyword */; @@ -14773,10 +14787,10 @@ function hasScopeMarker(statements) { return some(statements, isScopeMarker); } function needsScopeMarker(result) { - return !isAnyImportOrReExport(result) && !isExportAssignment(result) && !hasSyntacticModifier(result, 1 /* Export */) && !isAmbientModule(result); + return !isAnyImportOrReExport(result) && !isExportAssignment(result) && !hasSyntacticModifier(result, 32 /* Export */) && !isAmbientModule(result); } function isExternalModuleIndicator(result) { - return isAnyImportOrReExport(result) || isExportAssignment(result) || hasSyntacticModifier(result, 1 /* Export */); + return isAnyImportOrReExport(result) || isExportAssignment(result) || hasSyntacticModifier(result, 32 /* Export */); } function isForInOrOfStatement(node) { return node.kind === 249 /* ForInStatement */ || node.kind === 250 /* ForOfStatement */; @@ -16052,7 +16066,7 @@ function isEffectiveStrictModeSourceFile(node, compilerOptions) { return false; } function isAmbientPropertyDeclaration(node) { - return !!(node.flags & 33554432 /* Ambient */) || hasSyntacticModifier(node, 2 /* Ambient */); + return !!(node.flags & 33554432 /* Ambient */) || hasSyntacticModifier(node, 128 /* Ambient */); } function isBlockScope(node, parentNode) { switch (node.kind) { @@ -16405,10 +16419,10 @@ function isJsonSourceFile(file) { return file.scriptKind === 6 /* JSON */; } function isEnumConst(node) { - return !!(getCombinedModifierFlags(node) & 2048 /* Const */); + return !!(getCombinedModifierFlags(node) & 4096 /* Const */); } function isDeclarationReadonly(declaration) { - return !!(getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !isParameterPropertyDeclaration(declaration, declaration.parent)); + return !!(getCombinedModifierFlags(declaration) & 8 /* Readonly */ && !isParameterPropertyDeclaration(declaration, declaration.parent)); } function isVarAwaitUsing(node) { return (getCombinedNodeFlags(node) & 7 /* BlockScoped */) === 6 /* AwaitUsing */; @@ -17481,6 +17495,7 @@ function tryGetModuleSpecifierFromDeclaration(node) { true ))) == null ? void 0 : _a.arguments[0]; case 272 /* ImportDeclaration */: + case 278 /* ExportDeclaration */: return tryCast(node.moduleSpecifier, isStringLiteralLike); case 271 /* ImportEqualsDeclaration */: return tryCast((_b = tryCast(node.moduleReference, isExternalModuleReference)) == null ? void 0 : _b.expression, isStringLiteralLike); @@ -17492,6 +17507,8 @@ function tryGetModuleSpecifierFromDeclaration(node) { return tryCast(node.parent.parent.moduleSpecifier, isStringLiteralLike); case 276 /* ImportSpecifier */: return tryCast(node.parent.parent.parent.moduleSpecifier, isStringLiteralLike); + case 205 /* ImportType */: + return isLiteralImportTypeNode(node) ? node.argument.literal : void 0; default: Debug.assertNever(node); } @@ -17742,9 +17759,9 @@ function ownsJSDocTag(hostNode, tag) { } function getNextJSDocCommentLocation(node) { const parent2 = node.parent; - if (parent2.kind === 303 /* PropertyAssignment */ || parent2.kind === 277 /* ExportAssignment */ || parent2.kind === 172 /* PropertyDeclaration */ || parent2.kind === 244 /* ExpressionStatement */ && node.kind === 211 /* PropertyAccessExpression */ || parent2.kind === 253 /* ReturnStatement */ || getNestedModuleDeclaration(parent2) || isBinaryExpression(node) && node.operatorToken.kind === 64 /* EqualsToken */) { + if (parent2.kind === 303 /* PropertyAssignment */ || parent2.kind === 277 /* ExportAssignment */ || parent2.kind === 172 /* PropertyDeclaration */ || parent2.kind === 244 /* ExpressionStatement */ && node.kind === 211 /* PropertyAccessExpression */ || parent2.kind === 253 /* ReturnStatement */ || getNestedModuleDeclaration(parent2) || isAssignmentExpression(node)) { return parent2; - } else if (parent2.parent && (getSingleVariableOfVariableStatement(parent2.parent) === node || isBinaryExpression(parent2) && parent2.operatorToken.kind === 64 /* EqualsToken */)) { + } else if (parent2.parent && (getSingleVariableOfVariableStatement(parent2.parent) === node || isAssignmentExpression(parent2))) { return parent2.parent; } else if (parent2.parent && parent2.parent.parent && (getSingleVariableOfVariableStatement(parent2.parent.parent) || getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent2.parent.parent) === node || getSourceOfDefaultedAssignment(parent2.parent.parent))) { return parent2.parent.parent; @@ -18154,7 +18171,7 @@ function getFunctionFlags(node) { flags |= 1 /* Generator */; } case 219 /* ArrowFunction */: - if (hasSyntacticModifier(node, 512 /* Async */)) { + if (hasSyntacticModifier(node, 1024 /* Async */)) { flags |= 2 /* Async */; } break; @@ -18170,7 +18187,7 @@ function isAsyncFunction(node) { case 218 /* FunctionExpression */: case 219 /* ArrowFunction */: case 174 /* MethodDeclaration */: - return node.body !== void 0 && node.asteriskToken === void 0 && hasSyntacticModifier(node, 512 /* Async */); + return node.body !== void 0 && node.asteriskToken === void 0 && hasSyntacticModifier(node, 1024 /* Async */); } return false; } @@ -18197,6 +18214,7 @@ function getPropertyNameForPropertyNameNode(name) { case 81 /* PrivateIdentifier */: return name.escapedText; case 11 /* StringLiteral */: + case 15 /* NoSubstitutionTemplateLiteral */: case 9 /* NumericLiteral */: return escapeLeadingUnderscores(name.text); case 167 /* ComputedPropertyName */: @@ -19333,25 +19351,25 @@ function isStatic(node) { return isClassElement(node) && hasStaticModifier(node) || isClassStaticBlockDeclaration(node); } function hasStaticModifier(node) { - return hasSyntacticModifier(node, 32 /* Static */); + return hasSyntacticModifier(node, 256 /* Static */); } function hasOverrideModifier(node) { - return hasEffectiveModifier(node, 16384 /* Override */); + return hasEffectiveModifier(node, 16 /* Override */); } function hasAbstractModifier(node) { - return hasSyntacticModifier(node, 256 /* Abstract */); + return hasSyntacticModifier(node, 64 /* Abstract */); } function hasAmbientModifier(node) { - return hasSyntacticModifier(node, 2 /* Ambient */); + return hasSyntacticModifier(node, 128 /* Ambient */); } function hasAccessorModifier(node) { - return hasSyntacticModifier(node, 128 /* Accessor */); + return hasSyntacticModifier(node, 512 /* Accessor */); } function hasEffectiveReadonlyModifier(node) { - return hasEffectiveModifier(node, 64 /* Readonly */); + return hasEffectiveModifier(node, 8 /* Readonly */); } function hasDecorators(node) { - return hasSyntacticModifier(node, 131072 /* Decorator */); + return hasSyntacticModifier(node, 32768 /* Decorator */); } function getSelectedEffectiveModifierFlags(node, flags) { return getEffectiveModifierFlags(node) & flags; @@ -19366,10 +19384,13 @@ function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */; } - if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { - node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* HasComputedJSDocModifiers */; + if (alwaysIncludeJSDoc || includeJSDoc && isInJSFile(node)) { + if (!(node.modifierFlagsCache & 268435456 /* HasComputedJSDocModifiers */) && node.parent) { + node.modifierFlagsCache |= getRawJSDocModifierFlagsNoCache(node) | 268435456 /* HasComputedJSDocModifiers */; + } + return selectEffectiveModifierFlags(node.modifierFlagsCache); } - return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */); + return selectSyntacticModifierFlags(node.modifierFlagsCache); } function getEffectiveModifierFlags(node) { return getModifierFlagsWorker( @@ -19394,33 +19415,42 @@ function getSyntacticModifierFlags(node) { false ); } -function getJSDocModifierFlagsNoCache(node) { +function getRawJSDocModifierFlagsNoCache(node) { let flags = 0 /* None */; if (!!node.parent && !isParameter(node)) { if (isInJSFile(node)) { if (getJSDocPublicTagNoCache(node)) - flags |= 4 /* Public */; + flags |= 8388608 /* JSDocPublic */; if (getJSDocPrivateTagNoCache(node)) - flags |= 8 /* Private */; + flags |= 16777216 /* JSDocPrivate */; if (getJSDocProtectedTagNoCache(node)) - flags |= 16 /* Protected */; + flags |= 33554432 /* JSDocProtected */; if (getJSDocReadonlyTagNoCache(node)) - flags |= 64 /* Readonly */; + flags |= 67108864 /* JSDocReadonly */; if (getJSDocOverrideTagNoCache(node)) - flags |= 16384 /* Override */; + flags |= 134217728 /* JSDocOverride */; } if (getJSDocDeprecatedTagNoCache(node)) - flags |= 8192 /* Deprecated */; + flags |= 65536 /* Deprecated */; } return flags; } +function selectSyntacticModifierFlags(flags) { + return flags & 65535 /* SyntacticModifiers */; +} +function selectEffectiveModifierFlags(flags) { + return flags & 131071 /* NonCacheOnlyModifiers */ | (flags & 260046848 /* JSDocCacheOnlyModifiers */) >>> 23; +} +function getJSDocModifierFlagsNoCache(node) { + return selectEffectiveModifierFlags(getRawJSDocModifierFlagsNoCache(node)); +} function getEffectiveModifierFlagsNoCache(node) { return getSyntacticModifierFlagsNoCache(node) | getJSDocModifierFlagsNoCache(node); } function getSyntacticModifierFlagsNoCache(node) { let flags = canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : 0 /* None */; if (node.flags & 8 /* NestedNamespace */ || node.kind === 80 /* Identifier */ && node.flags & 4096 /* IdentifierIsInJSDocNamespace */) { - flags |= 1 /* Export */; + flags |= 32 /* Export */; } return flags; } @@ -19436,37 +19466,37 @@ function modifiersToFlags(modifiers) { function modifierToFlag(token) { switch (token) { case 126 /* StaticKeyword */: - return 32 /* Static */; + return 256 /* Static */; case 125 /* PublicKeyword */: - return 4 /* Public */; + return 1 /* Public */; case 124 /* ProtectedKeyword */: - return 16 /* Protected */; + return 4 /* Protected */; case 123 /* PrivateKeyword */: - return 8 /* Private */; + return 2 /* Private */; case 128 /* AbstractKeyword */: - return 256 /* Abstract */; + return 64 /* Abstract */; case 129 /* AccessorKeyword */: - return 128 /* Accessor */; + return 512 /* Accessor */; case 95 /* ExportKeyword */: - return 1 /* Export */; + return 32 /* Export */; case 138 /* DeclareKeyword */: - return 2 /* Ambient */; + return 128 /* Ambient */; case 87 /* ConstKeyword */: - return 2048 /* Const */; + return 4096 /* Const */; case 90 /* DefaultKeyword */: - return 1024 /* Default */; + return 2048 /* Default */; case 134 /* AsyncKeyword */: - return 512 /* Async */; + return 1024 /* Async */; case 148 /* ReadonlyKeyword */: - return 64 /* Readonly */; + return 8 /* Readonly */; case 164 /* OverrideKeyword */: - return 16384 /* Override */; + return 16 /* Override */; case 103 /* InKeyword */: - return 32768 /* In */; + return 8192 /* In */; case 147 /* OutKeyword */: - return 65536 /* Out */; + return 16384 /* Out */; case 170 /* Decorator */: - return 131072 /* Decorator */; + return 32768 /* Decorator */; } return 0 /* None */; } @@ -19606,7 +19636,7 @@ function getLocalSymbolForExportDefault(symbol) { return void 0; } function isExportDefaultSymbol(symbol) { - return symbol && length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 1024 /* Default */); + return symbol && length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 2048 /* Default */); } function tryExtractTSExtension(fileName) { return find(supportedTSExtensionsForExtractExtension, (extension) => fileExtensionIs(fileName, extension)); @@ -19889,16 +19919,16 @@ function getDeclarationModifierFlagsFromSymbol(s, isWrite = false) { if (s.valueDeclaration) { const declaration = isWrite && s.declarations && find(s.declarations, isSetAccessorDeclaration) || s.flags & 32768 /* GetAccessor */ && find(s.declarations, isGetAccessorDeclaration) || s.valueDeclaration; const flags = getCombinedModifierFlags(declaration); - return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; + return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~7 /* AccessibilityModifier */; } if (getCheckFlags(s) & 6 /* Synthetic */) { const checkFlags = s.links.checkFlags; - const accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : 16 /* Protected */; - const staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; + const accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 2 /* Private */ : checkFlags & 256 /* ContainsPublic */ ? 1 /* Public */ : 4 /* Protected */; + const staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 256 /* Static */ : 0; return accessModifier | staticModifier; } if (s.flags & 4194304 /* Prototype */) { - return 4 /* Public */ | 32 /* Static */; + return 1 /* Public */ | 256 /* Static */; } return 0; } @@ -19997,7 +20027,7 @@ function mutateMap(map2, newMap, options) { function isAbstractConstructorSymbol(symbol) { if (symbol.flags & 32 /* Class */) { const declaration = getClassLikeDeclarationOfSymbol(symbol); - return !!declaration && hasSyntacticModifier(declaration, 256 /* Abstract */); + return !!declaration && hasSyntacticModifier(declaration, 64 /* Abstract */); } return false; } @@ -21291,7 +21321,7 @@ function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { if (node.kind !== 167 /* ComputedPropertyName */) { return false; } - if (hasSyntacticModifier(node.parent, 256 /* Abstract */)) { + if (hasSyntacticModifier(node.parent, 64 /* Abstract */)) { return true; } const containerKind = node.parent.parent.kind; @@ -22950,8 +22980,9 @@ function createNodeFactory(flags, baseFactory2) { ensureUseStrict, liftToBlock, mergeLexicalEnvironment, - updateModifiers, - updateModifierLike + replaceModifiers, + replaceDecoratorsAndModifiers, + replacePropertyName }; forEach(nodeFactoryPatchers, (fn) => fn(factory2)); return factory2; @@ -23286,35 +23317,35 @@ function createNodeFactory(flags, baseFactory2) { } function createModifiersFromModifierFlags(flags2) { const result = []; - if (flags2 & 1 /* Export */) + if (flags2 & 32 /* Export */) result.push(createModifier(95 /* ExportKeyword */)); - if (flags2 & 2 /* Ambient */) + if (flags2 & 128 /* Ambient */) result.push(createModifier(138 /* DeclareKeyword */)); - if (flags2 & 1024 /* Default */) + if (flags2 & 2048 /* Default */) result.push(createModifier(90 /* DefaultKeyword */)); - if (flags2 & 2048 /* Const */) + if (flags2 & 4096 /* Const */) result.push(createModifier(87 /* ConstKeyword */)); - if (flags2 & 4 /* Public */) + if (flags2 & 1 /* Public */) result.push(createModifier(125 /* PublicKeyword */)); - if (flags2 & 8 /* Private */) + if (flags2 & 2 /* Private */) result.push(createModifier(123 /* PrivateKeyword */)); - if (flags2 & 16 /* Protected */) + if (flags2 & 4 /* Protected */) result.push(createModifier(124 /* ProtectedKeyword */)); - if (flags2 & 256 /* Abstract */) + if (flags2 & 64 /* Abstract */) result.push(createModifier(128 /* AbstractKeyword */)); - if (flags2 & 32 /* Static */) + if (flags2 & 256 /* Static */) result.push(createModifier(126 /* StaticKeyword */)); - if (flags2 & 16384 /* Override */) + if (flags2 & 16 /* Override */) result.push(createModifier(164 /* OverrideKeyword */)); - if (flags2 & 64 /* Readonly */) + if (flags2 & 8 /* Readonly */) result.push(createModifier(148 /* ReadonlyKeyword */)); - if (flags2 & 128 /* Accessor */) + if (flags2 & 512 /* Accessor */) result.push(createModifier(129 /* AccessorKeyword */)); - if (flags2 & 512 /* Async */) + if (flags2 & 1024 /* Async */) result.push(createModifier(134 /* AsyncKeyword */)); - if (flags2 & 32768 /* In */) + if (flags2 & 8192 /* In */) result.push(createModifier(103 /* InKeyword */)); - if (flags2 & 65536 /* Out */) + if (flags2 & 16384 /* Out */) result.push(createModifier(147 /* OutKeyword */)); return result.length ? result : void 0; } @@ -23363,7 +23394,7 @@ function createNodeFactory(flags, baseFactory2) { if (isThisIdentifier(node.name)) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.dotDotDotToken) | propagateNameFlags(node.name) | propagateChildFlags(node.questionToken) | propagateChildFlags(node.initializer) | (node.questionToken ?? node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (node.dotDotDotToken ?? node.initializer ? 1024 /* ContainsES2015 */ : 0 /* None */) | (modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */ ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */); + node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.dotDotDotToken) | propagateNameFlags(node.name) | propagateChildFlags(node.questionToken) | propagateChildFlags(node.initializer) | (node.questionToken ?? node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (node.dotDotDotToken ?? node.initializer ? 1024 /* ContainsES2015 */ : 0 /* None */) | (modifiersToFlags(node.modifiers) & 31 /* ParameterPropertyModifier */ ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */); } node.jsDoc = void 0; return node; @@ -23412,8 +23443,8 @@ function createNodeFactory(flags, baseFactory2) { node.exclamationToken = questionOrExclamationToken && isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : void 0; node.type = type; node.initializer = asInitializer(initializer); - const isAmbient = node.flags & 33554432 /* Ambient */ || modifiersToFlags(node.modifiers) & 2 /* Ambient */; - node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateNameFlags(node.name) | propagateChildFlags(node.initializer) | (isAmbient || node.questionToken || node.exclamationToken || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (isComputedPropertyName(node.name) || modifiersToFlags(node.modifiers) & 32 /* Static */ && node.initializer ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */) | 16777216 /* ContainsClassFields */; + const isAmbient = node.flags & 33554432 /* Ambient */ || modifiersToFlags(node.modifiers) & 128 /* Ambient */; + node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateNameFlags(node.name) | propagateChildFlags(node.initializer) | (isAmbient || node.questionToken || node.exclamationToken || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (isComputedPropertyName(node.name) || modifiersToFlags(node.modifiers) & 256 /* Static */ && node.initializer ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */) | 16777216 /* ContainsClassFields */; node.jsDoc = void 0; return node; } @@ -23452,7 +23483,7 @@ function createNodeFactory(flags, baseFactory2) { if (!node.body) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - const isAsync = modifiersToFlags(node.modifiers) & 512 /* Async */; + const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */; const isGenerator = !!node.asteriskToken; const isAsyncGenerator = isAsync && isGenerator; node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.asteriskToken) | propagateNameFlags(node.name) | propagateChildFlags(node.questionToken) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (isAsyncGenerator ? 128 /* ContainsES2018 */ : isAsync ? 256 /* ContainsES2017 */ : isGenerator ? 2048 /* ContainsGenerator */ : 0 /* None */) | (node.questionToken || node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | 1024 /* ContainsES2015 */; @@ -24195,7 +24226,7 @@ function createNodeFactory(flags, baseFactory2) { node.parameters = createNodeArray(parameters); node.type = type; node.body = body; - const isAsync = modifiersToFlags(node.modifiers) & 512 /* Async */; + const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */; const isGenerator = !!node.asteriskToken; const isAsyncGenerator = isAsync && isGenerator; node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.asteriskToken) | propagateNameFlags(node.name) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (isAsyncGenerator ? 128 /* ContainsES2018 */ : isAsync ? 256 /* ContainsES2017 */ : isGenerator ? 2048 /* ContainsGenerator */ : 0 /* None */) | (node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | 4194304 /* ContainsHoistedDeclarationOrCompletion */; @@ -24219,7 +24250,7 @@ function createNodeFactory(flags, baseFactory2) { node.type = type; node.equalsGreaterThanToken = equalsGreaterThanToken ?? createToken(39 /* EqualsGreaterThanToken */); node.body = parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body); - const isAsync = modifiersToFlags(node.modifiers) & 512 /* Async */; + const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */; node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.equalsGreaterThanToken) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (isAsync ? 256 /* ContainsES2017 */ | 16384 /* ContainsLexicalThis */ : 0 /* None */) | 1024 /* ContainsES2015 */; node.typeArguments = void 0; node.jsDoc = void 0; @@ -24571,7 +24602,7 @@ function createNodeFactory(flags, baseFactory2) { node.modifiers = asNodeArray(modifiers); node.declarationList = isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.declarationList); - if (modifiersToFlags(node.modifiers) & 2 /* Ambient */) { + if (modifiersToFlags(node.modifiers) & 128 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } node.jsDoc = void 0; @@ -24821,10 +24852,10 @@ function createNodeFactory(flags, baseFactory2) { node.parameters = createNodeArray(parameters); node.type = type; node.body = body; - if (!node.body || modifiersToFlags(node.modifiers) & 2 /* Ambient */) { + if (!node.body || modifiersToFlags(node.modifiers) & 128 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - const isAsync = modifiersToFlags(node.modifiers) & 512 /* Async */; + const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */; const isGenerator = !!node.asteriskToken; const isAsyncGenerator = isAsync && isGenerator; node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.asteriskToken) | propagateNameFlags(node.name) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (isAsyncGenerator ? 128 /* ContainsES2018 */ : isAsync ? 256 /* ContainsES2017 */ : isGenerator ? 2048 /* ContainsGenerator */ : 0 /* None */) | (node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | 4194304 /* ContainsHoistedDeclarationOrCompletion */; @@ -24855,7 +24886,7 @@ function createNodeFactory(flags, baseFactory2) { node.typeParameters = asNodeArray(typeParameters); node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); - if (modifiersToFlags(node.modifiers) & 2 /* Ambient */) { + if (modifiersToFlags(node.modifiers) & 128 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateNameFlags(node.name) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.heritageClauses) | propagateChildrenFlags(node.members) | (node.typeParameters ? 1 /* ContainsTypeScript */ : 0 /* None */) | 1024 /* ContainsES2015 */; @@ -24917,7 +24948,7 @@ function createNodeFactory(flags, baseFactory2) { node.flags |= flags2 & (32 /* Namespace */ | 8 /* NestedNamespace */ | 2048 /* GlobalAugmentation */); node.name = name; node.body = body; - if (modifiersToFlags(node.modifiers) & 2 /* Ambient */) { + if (modifiersToFlags(node.modifiers) & 128 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.name) | propagateChildFlags(node.body) | 1 /* ContainsTypeScript */; @@ -26348,7 +26379,7 @@ function createNodeFactory(flags, baseFactory2) { return qualifiedName; } function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && hasSyntacticModifier(node, 1 /* Export */)) { + if (ns && hasSyntacticModifier(node, 32 /* Export */)) { return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); } return getExportName(node, allowComments, allowSourceMaps); @@ -26459,7 +26490,7 @@ function createNodeFactory(flags, baseFactory2) { } return statements; } - function updateModifiers(node, modifiers) { + function replaceModifiers(node, modifiers) { let modifierArray; if (typeof modifiers === "number") { modifierArray = createModifiersFromModifierFlags(modifiers); @@ -26468,9 +26499,27 @@ function createNodeFactory(flags, baseFactory2) { } return isTypeParameterDeclaration(node) ? updateTypeParameterDeclaration(node, modifierArray, node.name, node.constraint, node.default) : isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isConstructorTypeNode(node) ? updateConstructorTypeNode1(node, modifierArray, node.typeParameters, node.parameters, node.type) : isPropertySignature(node) ? updatePropertySignature(node, modifierArray, node.name, node.questionToken, node.type) : isPropertyDeclaration(node) ? updatePropertyDeclaration2(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : isMethodSignature(node) ? updateMethodSignature(node, modifierArray, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) : isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : isConstructorDeclaration(node) ? updateConstructorDeclaration(node, modifierArray, node.parameters, node.body) : isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) : isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.body) : isIndexSignatureDeclaration(node) ? updateIndexSignature(node, modifierArray, node.parameters, node.type) : isFunctionExpression(node) ? updateFunctionExpression(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : isArrowFunction(node) ? updateArrowFunction(node, modifierArray, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) : isClassExpression(node) ? updateClassExpression(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isVariableStatement(node) ? updateVariableStatement(node, modifierArray, node.declarationList) : isFunctionDeclaration(node) ? updateFunctionDeclaration(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : isClassDeclaration(node) ? updateClassDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, modifierArray, node.name, node.typeParameters, node.type) : isEnumDeclaration(node) ? updateEnumDeclaration(node, modifierArray, node.name, node.members) : isModuleDeclaration(node) ? updateModuleDeclaration(node, modifierArray, node.name, node.body) : isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, modifierArray, node.isTypeOnly, node.name, node.moduleReference) : isImportDeclaration(node) ? updateImportDeclaration(node, modifierArray, node.importClause, node.moduleSpecifier, node.attributes) : isExportAssignment(node) ? updateExportAssignment(node, modifierArray, node.expression) : isExportDeclaration(node) ? updateExportDeclaration(node, modifierArray, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.attributes) : Debug.assertNever(node); } - function updateModifierLike(node, modifierArray) { + function replaceDecoratorsAndModifiers(node, modifierArray) { return isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isPropertyDeclaration(node) ? updatePropertyDeclaration2(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) : isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.body) : isClassExpression(node) ? updateClassExpression(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isClassDeclaration(node) ? updateClassDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : Debug.assertNever(node); } + function replacePropertyName(node, name) { + switch (node.kind) { + case 177 /* GetAccessor */: + return updateGetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.type, node.body); + case 178 /* SetAccessor */: + return updateSetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.body); + case 174 /* MethodDeclaration */: + return updateMethodDeclaration(node, node.modifiers, node.asteriskToken, name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body); + case 173 /* MethodSignature */: + return updateMethodSignature(node, node.modifiers, name, node.questionToken, node.typeParameters, node.parameters, node.type); + case 172 /* PropertyDeclaration */: + return updatePropertyDeclaration2(node, node.modifiers, name, node.questionToken ?? node.exclamationToken, node.type, node.initializer); + case 171 /* PropertySignature */: + return updatePropertySignature(node, node.modifiers, name, node.questionToken, node.type); + case 303 /* PropertyAssignment */: + return updatePropertyAssignment(node, name, node.initializer); + } + } function asNodeArray(array) { return array ? createNodeArray(array) : void 0; } @@ -27953,17 +28002,18 @@ var asyncGeneratorHelper = { scoped: false, dependencies: [awaitHelper], text: ` - var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; - function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } - function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } - function fulfill(value) { resume("next", value); } - function reject(value) { resume("throw", value); } - function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } - };` + var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i; + function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; } + function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } + };` }; var asyncDelegator = { name: "typescript:asyncDelegator", @@ -35726,11 +35776,11 @@ var Parser; const modifierFlags = modifiersToFlags(modifiers); parseExpected(100 /* FunctionKeyword */); const asteriskToken = parseOptionalToken(42 /* AsteriskToken */); - const name = modifierFlags & 1024 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); + const name = modifierFlags & 2048 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); const isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - const isAsync = modifierFlags & 512 /* Async */ ? 2 /* Await */ : 0 /* None */; + const isAsync = modifierFlags & 1024 /* Async */ ? 2 /* Await */ : 0 /* None */; const typeParameters = parseTypeParameters(); - if (modifierFlags & 1 /* Export */) + if (modifierFlags & 32 /* Export */) setAwaitContext( /*value*/ true @@ -39243,7 +39293,7 @@ var commandOptionsWithoutBuild = [ affectsBuildInfo: true, affectsDeclarationPath: true, isFilePath: false, - // This is intentionally broken to support compatability with existing tsconfig files + // This is intentionally broken to support compatibility with existing tsconfig files // for correct behaviour, please use outFile category: Diagnostics.Backwards_Compatibility, paramType: Diagnostics.FILE, @@ -41389,7 +41439,7 @@ function resolvedTypeScriptOnly(resolved) { Debug.assert(extensionIsTS(resolved.extension)); return { fileName: resolved.path, packageId: resolved.packageId }; } -function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state, legacyResult) { +function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state, cache, legacyResult) { if (!state.resultFromCache && !state.compilerOptions.preserveSymlinks && resolved && isExternalLibraryImport && !resolved.originalPath && !isExternalModuleNameRelative(moduleName)) { const { resolvedFileName, originalPath } = getOriginalAndResolvedFileName(resolved.path, state.host, state.traceEnabled); if (originalPath) @@ -41402,15 +41452,25 @@ function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName affectingLocations, diagnostics, state.resultFromCache, + cache, legacyResult ); } -function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, legacyResult) { +function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, cache, legacyResult) { if (resultFromCache) { - resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations); - resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations); - resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics); - return resultFromCache; + if (!(cache == null ? void 0 : cache.isReadonly)) { + resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations); + resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations); + resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics); + return resultFromCache; + } else { + return { + ...resultFromCache, + failedLookupLocations: initializeResolutionFieldForReadonlyCache(resultFromCache.failedLookupLocations, failedLookupLocations), + affectingLocations: initializeResolutionFieldForReadonlyCache(resultFromCache.affectingLocations, affectingLocations), + resolutionDiagnostics: initializeResolutionFieldForReadonlyCache(resultFromCache.resolutionDiagnostics, diagnostics) + }; + } } return { resolvedModule: resolved && { @@ -41438,6 +41498,13 @@ function updateResolutionField(to, value) { to.push(...value); return to; } +function initializeResolutionFieldForReadonlyCache(fromCache, value) { + if (!(fromCache == null ? void 0 : fromCache.length)) + return initializeResolutionField(value); + if (!value.length) + return fromCache.slice(); + return [...fromCache, ...value]; +} function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) { if (!hasProperty(jsonContent, fieldName)) { if (state.traceEnabled) { @@ -41622,8 +41689,7 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil if (resolutionMode === 99 /* ESNext */ && (3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */)) { features |= 32 /* EsmMode */; } - const useImportCondition = resolutionMode === 99 /* ESNext */ || (resolutionMode !== void 0 ? false : void 0); - const conditions = features & 8 /* Exports */ ? getConditions(options, useImportCondition) : []; + const conditions = features & 8 /* Exports */ ? getConditions(options, resolutionMode) : []; const diagnostics = []; const moduleResolutionState = { compilerOptions: options, @@ -41665,15 +41731,15 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil affectingLocations: initializeResolutionField(affectingLocations), resolutionDiagnostics: initializeResolutionField(diagnostics) }; - if (containingDirectory) { - cache == null ? void 0 : cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set( + if (containingDirectory && cache && !cache.isReadonly) { + cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set( typeReferenceDirectiveName, /*mode*/ resolutionMode, result ); if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) { - cache == null ? void 0 : cache.getOrCreateCacheForNonRelativeName(typeReferenceDirectiveName, resolutionMode, redirectedReference).set(containingDirectory, result); + cache.getOrCreateCacheForNonRelativeName(typeReferenceDirectiveName, resolutionMode, redirectedReference).set(containingDirectory, result); } } if (traceEnabled) @@ -41791,16 +41857,16 @@ function getNodeResolutionFeatures(options) { } return features; } -function getConditions(options, esmMode) { +function getConditions(options, resolutionMode) { const moduleResolution = getEmitModuleResolutionKind(options); - if (esmMode === void 0) { + if (resolutionMode === void 0) { if (moduleResolution === 100 /* Bundler */) { - esmMode ?? (esmMode = moduleResolution === 100 /* Bundler */); + resolutionMode = 99 /* ESNext */; } else if (moduleResolution === 2 /* Node10 */) { return []; } } - const conditions = esmMode ? ["import"] : ["require"]; + const conditions = resolutionMode === 99 /* ESNext */ ? ["import"] : ["require"]; if (!options.noDtsResolution) { conditions.push("types"); } @@ -41880,7 +41946,8 @@ function createCacheWithRedirects(ownOptions, optionsToRedirectsKey) { getMapOfCacheRedirects, getOrCreateMapOfCacheRedirects, update, - clear: clear2 + clear: clear2, + getOwnMap: () => ownMap }; function getMapOfCacheRedirects(redirectedReference) { return redirectedReference ? getOrCreateMap( @@ -41987,7 +42054,8 @@ function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileNam getFromDirectoryCache, getOrCreateCacheForDirectory, clear: clear2, - update + update, + directoryToModuleNameMap }; function clear2() { directoryToModuleNameMap.clear(); @@ -42247,13 +42315,13 @@ function resolveModuleName(moduleName, containingFile, compilerOptions, host, ca result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); break; case 2 /* Node10 */: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode === 99 /* ESNext */) : void 0); + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode) : void 0); break; case 1 /* Classic */: result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; case 100 /* Bundler */: - result = bundlerModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode === 99 /* ESNext */) : void 0); + result = bundlerModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode) : void 0); break; default: return Debug.fail(`Unexpected moduleResolution: ${moduleResolution}`); @@ -42261,9 +42329,11 @@ function resolveModuleName(moduleName, containingFile, compilerOptions, host, ca if (result && result.resolvedModule) (_b = perfLogger) == null ? void 0 : _b.logInfoEvent(`Module "${moduleName}" resolved to "${result.resolvedModule.resolvedFileName}"`); (_c = perfLogger) == null ? void 0 : _c.logStopResolveModule(result && result.resolvedModule ? "" + result.resolvedModule.resolvedFileName : "null"); - cache == null ? void 0 : cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result); - if (!isExternalModuleNameRelative(moduleName)) { - cache == null ? void 0 : cache.getOrCreateCacheForNonRelativeName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result); + if (cache && !cache.isReadonly) { + cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result); + if (!isExternalModuleNameRelative(moduleName)) { + cache.getOrCreateCacheForNonRelativeName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result); + } } } if (traceEnabled) { @@ -42529,7 +42599,7 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, const moduleResolution = getEmitModuleResolutionKind(compilerOptions); conditions ?? (conditions = getConditions( compilerOptions, - moduleResolution === 100 /* Bundler */ || moduleResolution === 2 /* Node10 */ ? void 0 : !!(features & 32 /* EsmMode */) + moduleResolution === 100 /* Bundler */ || moduleResolution === 2 /* Node10 */ ? void 0 : features & 32 /* EsmMode */ ? 99 /* ESNext */ : 1 /* CommonJS */ )); const diagnostics = []; const state = { @@ -42578,6 +42648,7 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, affectingLocations, diagnostics, state, + cache, legacyResult ); function tryResolve(extensions2, state2) { @@ -42839,15 +42910,7 @@ function getEntrypointsFromPackageJsonInfo(packageJsonInfo, options, host, cache entrypoints = append(entrypoints, mainResolution == null ? void 0 : mainResolution.path); if (features & 8 /* Exports */ && packageJsonInfo.contents.packageJsonContent.exports) { const conditionSets = deduplicate( - [getConditions( - options, - /*esmMode*/ - true - ), getConditions( - options, - /*esmMode*/ - false - )], + [getConditions(options, 99 /* ESNext */), getConditions(options, 1 /* CommonJS */)], arrayIsEqualTo ); for (const conditions of conditionSets) { @@ -42979,7 +43042,7 @@ function getVersionPathsOfPackageJsonInfo(packageJsonInfo, state) { return packageJsonInfo.contents.versionPaths || void 0; } function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) { - var _a, _b, _c, _d, _e, _f, _g, _h; + var _a, _b, _c, _d, _e, _f; const { host, traceEnabled } = state; const packageJsonPath = combinePaths(packageDirectory, "package.json"); if (onlyRecordFailures) { @@ -43007,15 +43070,17 @@ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) { trace(host, Diagnostics.Found_package_json_at_0, packageJsonPath); } const result = { packageDirectory, contents: { packageJsonContent, versionPaths: void 0, resolvedEntrypoints: void 0 } }; - (_e = state.packageJsonInfoCache) == null ? void 0 : _e.setPackageJsonInfo(packageJsonPath, result); - (_f = state.affectingLocations) == null ? void 0 : _f.push(packageJsonPath); + if (state.packageJsonInfoCache && !state.packageJsonInfoCache.isReadonly) + state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, result); + (_e = state.affectingLocations) == null ? void 0 : _e.push(packageJsonPath); return result; } else { if (directoryExists && traceEnabled) { trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath); } - (_g = state.packageJsonInfoCache) == null ? void 0 : _g.setPackageJsonInfo(packageJsonPath, directoryExists); - (_h = state.failedLookupLocations) == null ? void 0 : _h.push(packageJsonPath); + if (state.packageJsonInfoCache && !state.packageJsonInfoCache.isReadonly) + state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, directoryExists); + (_f = state.failedLookupLocations) == null ? void 0 : _f.push(packageJsonPath); } } function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) { @@ -43805,7 +43870,8 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host, failedLookupLocations, affectingLocations, diagnostics, - state + state, + cache ); function tryResolve(extensions) { const resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state); @@ -43924,7 +43990,9 @@ function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, hos failedLookupLocations, affectingLocations, diagnostics, - state.resultFromCache + state.resultFromCache, + /*cache*/ + void 0 ); } function toSearchResult(value) { @@ -43979,7 +44047,7 @@ function getModuleInstanceStateWorker(node, visited) { break; case 272 /* ImportDeclaration */: case 271 /* ImportEqualsDeclaration */: - if (!hasSyntacticModifier(node, 1 /* Export */)) { + if (!hasSyntacticModifier(node, 32 /* Export */)) { return 0 /* NonInstantiated */; } break; @@ -44269,7 +44337,7 @@ function createBinder() { } function declareSymbol(symbolTable, parent3, node, includes, excludes, isReplaceableByMethod, isComputedName) { Debug.assert(isComputedName || !hasDynamicName(node)); - const isDefaultExport = hasSyntacticModifier(node, 1024 /* Default */) || isExportSpecifier(node) && node.name.escapedText === "default"; + const isDefaultExport = hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) && node.name.escapedText === "default"; const name = isComputedName ? "__computed" /* Computed */ : isDefaultExport && parent3 ? "default" /* Default */ : getDeclarationName(node); let symbol; if (name === void 0) { @@ -44313,7 +44381,7 @@ function createBinder() { } } const relatedInformation = []; - if (isTypeAliasDeclaration(node) && nodeIsMissing(node.type) && hasSyntacticModifier(node, 1 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) { + if (isTypeAliasDeclaration(node) && nodeIsMissing(node.type) && hasSyntacticModifier(node, 32 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) { relatedInformation.push(createDiagnosticForNode2(node, Diagnostics.Did_you_mean_0, `export type { ${unescapeLeadingUnderscores(node.name.escapedText)} }`)); } const declarationName = getNameOfDeclaration(node) || node; @@ -44342,7 +44410,7 @@ function createBinder() { return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - const hasExportModifier = !!(getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); + const hasExportModifier = !!(getCombinedModifierFlags(node) & 32 /* Export */) || jsdocTreatAsExported(node); if (symbolFlags & 2097152 /* Alias */) { if (node.kind === 281 /* ExportSpecifier */ || node.kind === 271 /* ImportEqualsDeclaration */ && hasExportModifier) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); @@ -44361,7 +44429,7 @@ function createBinder() { if (isJSDocTypeAlias(node)) Debug.assert(isInJSFile(node)); if (!isAmbientModule(node) && (hasExportModifier || container.flags & 128 /* ExportContext */)) { - if (!canHaveLocals(container) || !container.locals || hasSyntacticModifier(node, 1024 /* Default */) && !getDeclarationName(node)) { + if (!canHaveLocals(container) || !container.locals || hasSyntacticModifier(node, 2048 /* Default */) && !getDeclarationName(node)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } const exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; @@ -44402,7 +44470,7 @@ function createBinder() { return false; if (isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent)) return true; - if (isDeclaration(declName.parent) && getCombinedModifierFlags(declName.parent) & 1 /* Export */) + if (isDeclaration(declName.parent) && getCombinedModifierFlags(declName.parent) & 32 /* Export */) return true; return false; } @@ -44433,7 +44501,7 @@ function createBinder() { const saveExceptionTarget = currentExceptionTarget; const saveActiveLabelList = activeLabelList; const saveHasExplicitReturn = hasExplicitReturn; - const isImmediatelyInvoked = containerFlags & 16 /* IsFunctionExpression */ && !hasSyntacticModifier(node, 512 /* Async */) && !node.asteriskToken && !!getImmediatelyInvokedFunctionExpression(node) || node.kind === 175 /* ClassStaticBlockDeclaration */; + const isImmediatelyInvoked = containerFlags & 16 /* IsFunctionExpression */ && !hasSyntacticModifier(node, 1024 /* Async */) && !node.asteriskToken && !!getImmediatelyInvokedFunctionExpression(node) || node.kind === 175 /* ClassStaticBlockDeclaration */; if (!isImmediatelyInvoked) { currentFlow = initFlowNode({ flags: 2 /* Start */ }); if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { @@ -45480,7 +45548,7 @@ function createBinder() { function bindModuleDeclaration(node) { setExportContextFlag(node); if (isAmbientModule(node)) { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (isModuleAugmentationExternal(node)) { @@ -46541,7 +46609,7 @@ function createBinder() { } if (!isBindingPattern(node.name)) { const possibleVariableDecl = node.kind === 260 /* VariableDeclaration */ ? node : node.parent.parent; - if (isInJSFile(node) && shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) { + if (isInJSFile(node) && shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 32 /* Export */)) { declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); } else if (isBlockOrCatchScoped(node)) { bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); @@ -46693,7 +46761,7 @@ function isPurelyTypeDeclaration(s) { case 267 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; case 266 /* EnumDeclaration */: - return hasSyntacticModifier(s, 2048 /* Const */); + return hasSyntacticModifier(s, 4096 /* Const */); default: return false; } @@ -47072,10 +47140,12 @@ function getModuleSpecifiers(moduleSymbol, checker, compilerOptions, importingSo importingSourceFile, host, userPreferences, - options + options, + /*forAutoImport*/ + false ).moduleSpecifiers; } -function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences, options = {}) { +function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) { let computedWithoutCache = false; const ambient = tryGetModuleNameFromAmbientModule(moduleSymbol, checker); if (ambient) @@ -47093,11 +47163,19 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions return { moduleSpecifiers: emptyArray, computedWithoutCache }; computedWithoutCache = true; modulePaths || (modulePaths = getAllModulePathsWorker(importingSourceFile.path, moduleSourceFile.originalFileName, host)); - const result = computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options); + const result = computeModuleSpecifiers( + modulePaths, + compilerOptions, + importingSourceFile, + host, + userPreferences, + options, + forAutoImport + ); cache == null ? void 0 : cache.set(importingSourceFile.path, moduleSourceFile.path, userPreferences, options, modulePaths, result); return { moduleSpecifiers: result, computedWithoutCache }; } -function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}) { +function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) { const info = getInfo(importingSourceFile.path, host); const preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); const existingSpecifier = forEach(modulePaths, (modulePath) => forEach( @@ -47154,7 +47232,7 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi redirectPathsSpecifiers = append(redirectPathsSpecifiers, local); } else if (pathIsBareSpecifier(local)) { pathsSpecifiers = append(pathsSpecifiers, local); - } else if (!importedFileIsInNodeModules || modulePath.isInNodeModules) { + } else if (forAutoImport || !importedFileIsInNodeModules || modulePath.isInNodeModules) { relativeSpecifiers = append(relativeSpecifiers, local); } } @@ -47545,7 +47623,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa if (getResolvePackageJsonExports(options)) { const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1); const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2); - const conditions = getConditions(options, importMode === 99 /* ESNext */); + const conditions = getConditions(options, importMode); const fromExports = packageJsonContent.exports ? tryGetModuleNameFromExports(options, path, packageRootPath, packageName2, packageJsonContent.exports, conditions) : void 0; if (fromExports) { const withJsExtension = !hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) }; @@ -49834,7 +49912,7 @@ function createTypeChecker(host) { if (lastLocation && lastLocation === location.name) { return false; } - if (location.asteriskToken || hasSyntacticModifier(location, 512 /* Async */)) { + if (location.asteriskToken || hasSyntacticModifier(location, 1024 /* Async */)) { return true; } return !getImmediatelyInvokedFunctionExpression(location); @@ -49998,8 +50076,17 @@ function createTypeChecker(host) { function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { if (meaning & 111551 /* Value */) { if (isPrimitiveTypeName(name)) { - if (isExtendedByInterface(errorLocation)) { - error2(errorLocation, Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes, unescapeLeadingUnderscores(name)); + const grandparent = errorLocation.parent.parent; + if (grandparent && grandparent.parent && isHeritageClause(grandparent)) { + const heritageKind = grandparent.token; + const containerKind = grandparent.parent.kind; + if (containerKind === 264 /* InterfaceDeclaration */ && heritageKind === 96 /* ExtendsKeyword */) { + error2(errorLocation, Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_It_can_only_extend_other_named_object_types, unescapeLeadingUnderscores(name)); + } else if (containerKind === 263 /* ClassDeclaration */ && heritageKind === 96 /* ExtendsKeyword */) { + error2(errorLocation, Diagnostics.A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values, unescapeLeadingUnderscores(name)); + } else if (containerKind === 263 /* ClassDeclaration */ && heritageKind === 119 /* ImplementsKeyword */) { + error2(errorLocation, Diagnostics.A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types, unescapeLeadingUnderscores(name)); + } } else { error2(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, unescapeLeadingUnderscores(name)); } @@ -50031,16 +50118,6 @@ function createTypeChecker(host) { } return false; } - function isExtendedByInterface(node) { - const grandparent = node.parent.parent; - const parentOfGrandparent = grandparent.parent; - if (grandparent && parentOfGrandparent) { - const isExtending = isHeritageClause(grandparent) && grandparent.token === 96 /* ExtendsKeyword */; - const isInterface = isInterfaceDeclaration(parentOfGrandparent); - return isExtending && isInterface; - } - return false; - } function maybeMappedType(node, symbol) { const container = findAncestor(node.parent, (n) => isComputedPropertyName(n) || isPropertySignature(n) ? false : isTypeLiteralNode(n) || "quit"); if (container && container.members.length === 1) { @@ -50219,7 +50296,7 @@ function createTypeChecker(host) { return resolved; } function isSyntacticDefault(node) { - return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 1024 /* Default */) || isExportSpecifier(node); + return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) || isNamespaceExport(node); } function getUsageModeForExpression(usage) { return isStringLiteralLike(usage) ? getModeForUsageLocation(getSourceFileOfNode(usage), usage) : void 0; @@ -52145,20 +52222,20 @@ function createTypeChecker(host) { var _a, _b; if (!isDeclarationVisible(declaration)) { const anyImportSyntax = getAnyImportSyntax(declaration); - if (anyImportSyntax && !hasSyntacticModifier(anyImportSyntax, 1 /* Export */) && // import clause without export + if (anyImportSyntax && !hasSyntacticModifier(anyImportSyntax, 32 /* Export */) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { return addVisibleAlias(declaration, anyImportSyntax); - } else if (isVariableDeclaration(declaration) && isVariableStatement(declaration.parent.parent) && !hasSyntacticModifier(declaration.parent.parent, 1 /* Export */) && // unexported variable statement + } else if (isVariableDeclaration(declaration) && isVariableStatement(declaration.parent.parent) && !hasSyntacticModifier(declaration.parent.parent, 32 /* Export */) && // unexported variable statement isDeclarationVisible(declaration.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent); - } else if (isLateVisibilityPaintedStatement(declaration) && !hasSyntacticModifier(declaration, 1 /* Export */) && isDeclarationVisible(declaration.parent)) { + } else if (isLateVisibilityPaintedStatement(declaration) && !hasSyntacticModifier(declaration, 32 /* Export */) && isDeclarationVisible(declaration.parent)) { return addVisibleAlias(declaration, declaration); } else if (isBindingElement(declaration)) { - if (symbol.flags & 2097152 /* Alias */ && isInJSFile(declaration) && ((_a = declaration.parent) == null ? void 0 : _a.parent) && isVariableDeclaration(declaration.parent.parent) && ((_b = declaration.parent.parent.parent) == null ? void 0 : _b.parent) && isVariableStatement(declaration.parent.parent.parent.parent) && !hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */) && declaration.parent.parent.parent.parent.parent && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { + if (symbol.flags & 2097152 /* Alias */ && isInJSFile(declaration) && ((_a = declaration.parent) == null ? void 0 : _a.parent) && isVariableDeclaration(declaration.parent.parent) && ((_b = declaration.parent.parent.parent) == null ? void 0 : _b.parent) && isVariableStatement(declaration.parent.parent.parent.parent) && !hasSyntacticModifier(declaration.parent.parent.parent.parent, 32 /* Export */) && declaration.parent.parent.parent.parent.parent && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); } else if (symbol.flags & 2 /* BlockScopedVariable */) { const variableStatement = findAncestor(declaration, isVariableStatement); - if (hasSyntacticModifier(variableStatement, 1 /* Export */)) { + if (hasSyntacticModifier(variableStatement, 32 /* Export */)) { return true; } if (!isDeclarationVisible(variableStatement.parent)) { @@ -52381,7 +52458,8 @@ function createTypeChecker(host) { visitedTypes: void 0, symbolDepth: void 0, inferTypeParameters: void 0, - approximateLength: 0 + approximateLength: 0, + trackedSymbols: void 0 }; context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost); const resultingNode = cb(context); @@ -52835,7 +52913,7 @@ function createTypeChecker(host) { } } function visitAndTransformType(type2, transform2) { - var _a2, _b2; + var _a2, _b2, _c; const typeId = type2.id; const isConstructorObject = getObjectFlags(type2) & 16 /* Anonymous */ && type2.symbol && type2.symbol.flags & 32 /* Class */; const id = getObjectFlags(type2) & 4 /* Reference */ && type2.node ? "N" + getNodeId(type2.node) : type2.flags & 16777216 /* Conditional */ ? "N" + getNodeId(type2.root.node) : type2.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type2.symbol) : void 0; @@ -52852,6 +52930,13 @@ function createTypeChecker(host) { } const cachedResult = (_a2 = links == null ? void 0 : links.serializedTypes) == null ? void 0 : _a2.get(key); if (cachedResult) { + (_b2 = cachedResult.trackedSymbols) == null ? void 0 : _b2.forEach( + ([symbol, enclosingDeclaration, meaning]) => context.tracker.trackSymbol( + symbol, + enclosingDeclaration, + meaning + ) + ); if (cachedResult.truncating) { context.truncating = true; } @@ -52871,7 +52956,12 @@ function createTypeChecker(host) { const result = transform2(type2); const addedLength = context.approximateLength - startLength; if (!context.reportedDiagnostic && !context.encounteredError) { - (_b2 = links == null ? void 0 : links.serializedTypes) == null ? void 0 : _b2.set(key, { node: result, truncating: context.truncating, addedLength }); + (_c = links == null ? void 0 : links.serializedTypes) == null ? void 0 : _c.set(key, { + node: result, + truncating: context.truncating, + addedLength, + trackedSymbols: context.trackedSymbols + }); } context.visitedTypes.delete(typeId); if (id) { @@ -53113,7 +53203,7 @@ function createTypeChecker(host) { if (propertySymbol.flags & 4194304 /* Prototype */) { continue; } - if (getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* Private */ | 16 /* Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { + if (getDeclarationModifierFlagsFromSymbol(propertySymbol) & (2 /* Private */ | 4 /* Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { context.tracker.reportPrivateInBaseOfClassExpression(unescapeLeadingUnderscores(propertySymbol.escapedName)); } } @@ -53177,6 +53267,28 @@ function createTypeChecker(host) { const propertyName = getPropertyNameNodeForSymbol(propertySymbol, context); context.enclosingDeclaration = saveEnclosingDeclaration; context.approximateLength += symbolName(propertySymbol).length + 1; + if (propertySymbol.flags & 98304 /* Accessor */) { + const writeType = getWriteTypeOfSymbol(propertySymbol); + if (propertyType !== writeType) { + const getterDeclaration = getDeclarationOfKind(propertySymbol, 177 /* GetAccessor */); + const getterSignature = getSignatureFromDeclaration(getterDeclaration); + typeElements.push( + setCommentRange( + signatureToSignatureDeclarationHelper(getterSignature, 177 /* GetAccessor */, context, { name: propertyName }), + getterDeclaration + ) + ); + const setterDeclaration = getDeclarationOfKind(propertySymbol, 178 /* SetAccessor */); + const setterSignature = getSignatureFromDeclaration(setterDeclaration); + typeElements.push( + setCommentRange( + signatureToSignatureDeclarationHelper(setterSignature, 178 /* SetAccessor */, context, { name: propertyName }), + setterDeclaration + ) + ); + return; + } + } const optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags & 32768 /* Undefined */)), 0 /* Call */); @@ -53214,9 +53326,9 @@ function createTypeChecker(host) { typeElements.push(preserveCommentsOn(propertySignature)); function preserveCommentsOn(node) { var _a2; - if (some(propertySymbol.declarations, (d) => d.kind === 355 /* JSDocPropertyTag */)) { - const d = (_a2 = propertySymbol.declarations) == null ? void 0 : _a2.find((d2) => d2.kind === 355 /* JSDocPropertyTag */); - const commentText = getTextOfJSDocComment(d.comment); + const jsdocPropertyTag = (_a2 = propertySymbol.declarations) == null ? void 0 : _a2.find((d) => d.kind === 355 /* JSDocPropertyTag */); + if (jsdocPropertyTag) { + const commentText = getTextOfJSDocComment(jsdocPropertyTag.comment); if (commentText) { setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); } @@ -53394,7 +53506,7 @@ function createTypeChecker(host) { let modifiers = options == null ? void 0 : options.modifiers; if (kind === 185 /* ConstructorType */ && signature.flags & 4 /* Abstract */) { const flags = modifiersToFlags(modifiers); - modifiers = factory.createModifiersFromModifierFlags(flags | 256 /* Abstract */); + modifiers = factory.createModifiersFromModifierFlags(flags | 64 /* Abstract */); } const node = kind === 179 /* CallSignature */ ? factory.createCallSignature(typeParameters, parameters, returnTypeNode) : kind === 180 /* ConstructSignature */ ? factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : kind === 173 /* MethodSignature */ ? factory.createMethodSignature(modifiers, (options == null ? void 0 : options.name) ?? factory.createIdentifier(""), options == null ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : kind === 174 /* MethodDeclaration */ ? factory.createMethodDeclaration( modifiers, @@ -54451,7 +54563,7 @@ function createTypeChecker(host) { const nsIndex = findIndex(statements, isModuleDeclaration); let ns = nsIndex !== -1 ? statements[nsIndex] : void 0; if (ns && exportAssignment && exportAssignment.isExportEquals && isIdentifier(exportAssignment.expression) && isIdentifier(ns.name) && idText(ns.name) === idText(exportAssignment.expression) && ns.body && isModuleBlock(ns.body)) { - const excessExports = filter(statements, (s) => !!(getEffectiveModifierFlags(s) & 1 /* Export */)); + const excessExports = filter(statements, (s) => !!(getEffectiveModifierFlags(s) & 32 /* Export */)); const name = ns.name; let body = ns.body; if (length(excessExports)) { @@ -54485,9 +54597,9 @@ function createTypeChecker(host) { } if (!find(statements, (s) => s !== ns && nodeHasName(s, name))) { results = []; - const mixinExportFlag = !some(body.statements, (s) => hasSyntacticModifier(s, 1 /* Export */) || isExportAssignment(s) || isExportDeclaration(s)); + const mixinExportFlag = !some(body.statements, (s) => hasSyntacticModifier(s, 32 /* Export */) || isExportAssignment(s) || isExportDeclaration(s)); forEach(body.statements, (s) => { - addResult(s, mixinExportFlag ? 1 /* Export */ : 0 /* None */); + addResult(s, mixinExportFlag ? 32 /* Export */ : 0 /* None */); }); statements = [...filter(statements, (s) => s !== ns && s !== exportAssignment), ...results]; } @@ -54579,12 +54691,12 @@ function createTypeChecker(host) { return statements; } function addExportModifier(node) { - const flags = (getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */; - return factory.updateModifiers(node, flags); + const flags = (getEffectiveModifierFlags(node) | 32 /* Export */) & ~128 /* Ambient */; + return factory.replaceModifiers(node, flags); } function removeExportModifier(node) { - const flags = getEffectiveModifierFlags(node) & ~1 /* Export */; - return factory.updateModifiers(node, flags); + const flags = getEffectiveModifierFlags(node) & ~32 /* Export */; + return factory.replaceModifiers(node, flags); } function visitSymbolTable(symbolTable2, suppressNewPrivateContext, propertyAsAlias) { if (!suppressNewPrivateContext) { @@ -54624,6 +54736,12 @@ function createTypeChecker(host) { if (context.reportedDiagnostic) { oldcontext.reportedDiagnostic = context.reportedDiagnostic; } + if (context.trackedSymbols) { + if (!oldContext.trackedSymbols) + oldContext.trackedSymbols = context.trackedSymbols; + else + Debug.assert(context.trackedSymbols === oldContext.trackedSymbols); + } context = oldContext; } } @@ -54640,7 +54758,7 @@ function createTypeChecker(host) { if (needsPostExportDefault || needsExportDeclaration) { isPrivate = true; } - const modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 1024 /* Default */ : 0); + const modifierFlags = (!isPrivate ? 32 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 2048 /* Default */ : 0); const isConstMergedWithNS = symbol.flags & 1536 /* Module */ && symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && escapedSymbolName !== "export=" /* ExportEquals */; const isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); if (symbol.flags & (16 /* Function */ | 8192 /* Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { @@ -54710,7 +54828,7 @@ function createTypeChecker(host) { ), textRange ); - addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + addResult(statement, name !== localName ? modifierFlags & ~32 /* Export */ : modifierFlags); if (name !== localName && !isPrivate) { addResult( factory.createExportDeclaration( @@ -54815,17 +54933,17 @@ function createTypeChecker(host) { if (canHaveModifiers(node)) { let newModifierFlags = 0 /* None */; const enclosingDeclaration2 = context.enclosingDeclaration && (isJSDocTypeAlias(context.enclosingDeclaration) ? getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); - if (additionalModifierFlags & 1 /* Export */ && enclosingDeclaration2 && (isExportingScope(enclosingDeclaration2) || isModuleDeclaration(enclosingDeclaration2)) && canHaveExportModifier(node)) { - newModifierFlags |= 1 /* Export */; + if (additionalModifierFlags & 32 /* Export */ && enclosingDeclaration2 && (isExportingScope(enclosingDeclaration2) || isModuleDeclaration(enclosingDeclaration2)) && canHaveExportModifier(node)) { + newModifierFlags |= 32 /* Export */; } - if (addingDeclare && !(newModifierFlags & 1 /* Export */) && (!enclosingDeclaration2 || !(enclosingDeclaration2.flags & 33554432 /* Ambient */)) && (isEnumDeclaration(node) || isVariableStatement(node) || isFunctionDeclaration(node) || isClassDeclaration(node) || isModuleDeclaration(node))) { - newModifierFlags |= 2 /* Ambient */; + if (addingDeclare && !(newModifierFlags & 32 /* Export */) && (!enclosingDeclaration2 || !(enclosingDeclaration2.flags & 33554432 /* Ambient */)) && (isEnumDeclaration(node) || isVariableStatement(node) || isFunctionDeclaration(node) || isClassDeclaration(node) || isModuleDeclaration(node))) { + newModifierFlags |= 128 /* Ambient */; } - if (additionalModifierFlags & 1024 /* Default */ && (isClassDeclaration(node) || isInterfaceDeclaration(node) || isFunctionDeclaration(node))) { - newModifierFlags |= 1024 /* Default */; + if (additionalModifierFlags & 2048 /* Default */ && (isClassDeclaration(node) || isInterfaceDeclaration(node) || isFunctionDeclaration(node))) { + newModifierFlags |= 2048 /* Default */; } if (newModifierFlags) { - node = factory.updateModifiers(node, newModifierFlags | getEffectiveModifierFlags(node)); + node = factory.replaceModifiers(node, newModifierFlags | getEffectiveModifierFlags(node)); } } results.push(node); @@ -54944,7 +55062,7 @@ function createTypeChecker(host) { function serializeEnum(symbol, symbolName2, modifierFlags) { addResult( factory.createEnumDeclaration( - factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), + factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 4096 /* Const */ : 0), getInternalSymbolName(symbol, symbolName2), map(filter(getPropertiesOfType(getTypeOfSymbol(symbol)), (p) => !!(p.flags & 8 /* EnumMember */)), (p) => { const initializedValue = p.declarations && p.declarations[0] && isEnumMember(p.declarations[0]) ? getConstantValue2(p.declarations[0]) : void 0; @@ -55028,7 +55146,7 @@ function createTypeChecker(host) { factory.createIdentifier("default" /* Default */) )]) ) : d); - const exportModifierStripped = every(defaultReplaced, (d) => hasSyntacticModifier(d, 1 /* Export */)) ? map(defaultReplaced, removeExportModifier) : defaultReplaced; + const exportModifierStripped = every(defaultReplaced, (d) => hasSyntacticModifier(d, 32 /* Export */)) ? map(defaultReplaced, removeExportModifier) : defaultReplaced; fakespace = factory.updateModuleDeclaration( fakespace, fakespace.modifiers, @@ -55131,7 +55249,7 @@ function createTypeChecker(host) { ); const isNonConstructableClassLikeInJsFile = !isClass && !!symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && !some(getSignaturesOfType(staticType, 1 /* Construct */)); const constructors = isNonConstructableClassLikeInJsFile ? [factory.createConstructorDeclaration( - factory.createModifiersFromModifierFlags(8 /* Private */), + factory.createModifiersFromModifierFlags(2 /* Private */), [], /*body*/ void 0 @@ -55484,7 +55602,7 @@ function createTypeChecker(host) { const varName = getUnusedName(name, symbol); const typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol))); if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { - serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 1 /* Export */); + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 32 /* Export */); } else { const flags = ((_a2 = context.enclosingDeclaration) == null ? void 0 : _a2.kind) === 267 /* ModuleDeclaration */ && (!(symbol.flags & 98304 /* Accessor */) || symbol.flags & 65536 /* SetAccessor */) ? 1 /* Let */ : 2 /* Const */; const statement = factory.createVariableStatement( @@ -55501,7 +55619,7 @@ function createTypeChecker(host) { ); addResult( statement, - target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ : name === varName ? 1 /* Export */ : 0 /* None */ + target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 128 /* Ambient */ : name === varName ? 32 /* Export */ : 0 /* None */ ); } if (isExportAssignmentCompatibleSymbolName) { @@ -55523,20 +55641,28 @@ function createTypeChecker(host) { const ctxSrc = getSourceFileOfNode(context.enclosingDeclaration); return getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && !length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class !!(length(filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && !length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK - !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && some(typeToSerialize.symbol.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && !some(getPropertiesOfType(typeToSerialize), (p) => isLateBoundName(p.escapedName)) && !some(getPropertiesOfType(typeToSerialize), (p) => some(p.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && every(getPropertiesOfType(typeToSerialize), (p) => isIdentifierText(symbolName(p), languageVersion)); + !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && some(typeToSerialize.symbol.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && !some(getPropertiesOfType(typeToSerialize), (p) => isLateBoundName(p.escapedName)) && !some(getPropertiesOfType(typeToSerialize), (p) => some(p.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && every(getPropertiesOfType(typeToSerialize), (p) => { + if (!isIdentifierText(symbolName(p), languageVersion)) { + return false; + } + if (!(p.flags & 98304 /* Accessor */)) { + return true; + } + return getNonMissingTypeOfSymbol(p) === getWriteTypeOfSymbol(p); + }); } function makeSerializePropertySymbol(createProperty2, methodKind, useAccessors) { return function serializePropertySymbol(p, isStatic2, baseType) { var _a2, _b, _c, _d, _e; const modifierFlags = getDeclarationModifierFlagsFromSymbol(p); - const isPrivate = !!(modifierFlags & 8 /* Private */); + const isPrivate = !!(modifierFlags & 2 /* Private */); if (isStatic2 && p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) { return []; } if (p.flags & 4194304 /* Prototype */ || p.escapedName === "constructor" || baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName))) { return []; } - const flag = modifierFlags & ~512 /* Async */ | (isStatic2 ? 32 /* Static */ : 0); + const flag = modifierFlags & ~1024 /* Async */ | (isStatic2 ? 256 /* Static */ : 0); const name = getPropertyNameNodeForSymbol(p, context); const firstPropertyLikeDecl = (_a2 = p.declarations) == null ? void 0 : _a2.find(or(isPropertyDeclaration, isAccessor, isVariableDeclaration, isPropertySignature, isBinaryExpression, isPropertyAccessExpression)); if (p.flags & 98304 /* Accessor */ && useAccessors) { @@ -55578,7 +55704,7 @@ function createTypeChecker(host) { )); } if (p.flags & 32768 /* GetAccessor */) { - const isPrivate2 = modifierFlags & 8 /* Private */; + const isPrivate2 = modifierFlags & 2 /* Private */; result.push(setTextRange( factory.createGetAccessorDeclaration( factory.createModifiersFromModifierFlags(flag), @@ -55595,7 +55721,7 @@ function createTypeChecker(host) { } else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) { return setTextRange( createProperty2( - factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), + factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0, isPrivate ? void 0 : serializeTypeForDeclaration(context, getWriteTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), @@ -55610,10 +55736,10 @@ function createTypeChecker(host) { if (p.flags & (8192 /* Method */ | 16 /* Function */)) { const type = getTypeOfSymbol(p); const signatures = getSignaturesOfType(type, 0 /* Call */); - if (flag & 8 /* Private */) { + if (flag & 2 /* Private */) { return setTextRange( createProperty2( - factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), + factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0, /*type*/ @@ -55689,7 +55815,7 @@ function createTypeChecker(host) { let privateProtected = 0; for (const s of signatures) { if (s.declaration) { - privateProtected |= getSelectedEffectiveModifierFlags(s.declaration, 8 /* Private */ | 16 /* Protected */); + privateProtected |= getSelectedEffectiveModifierFlags(s.declaration, 2 /* Private */ | 4 /* Protected */); } } if (privateProtected) { @@ -55882,10 +56008,10 @@ function createTypeChecker(host) { return result || types; } function visibilityToString(flags) { - if (flags === 8 /* Private */) { + if (flags === 2 /* Private */) { return "private"; } - if (flags === 16 /* Protected */) { + if (flags === 4 /* Protected */) { return "protected"; } return "public"; @@ -56003,7 +56129,7 @@ function createTypeChecker(host) { return true; } const parent2 = getDeclarationContainer(node); - if (!(getCombinedModifierFlagsCached(node) & 1 /* Export */) && !(node.kind !== 271 /* ImportEqualsDeclaration */ && parent2.kind !== 312 /* SourceFile */ && parent2.flags & 33554432 /* Ambient */)) { + if (!(getCombinedModifierFlagsCached(node) & 32 /* Export */) && !(node.kind !== 271 /* ImportEqualsDeclaration */ && parent2.kind !== 312 /* SourceFile */ && parent2.flags & 33554432 /* Ambient */)) { return isGlobalSourceFile(parent2); } return isDeclarationVisible(parent2); @@ -56013,7 +56139,7 @@ function createTypeChecker(host) { case 178 /* SetAccessor */: case 174 /* MethodDeclaration */: case 173 /* MethodSignature */: - if (hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { + if (hasEffectiveModifier(node, 2 /* Private */ | 4 /* Protected */)) { return false; } case 176 /* Constructor */: @@ -56232,7 +56358,7 @@ function createTypeChecker(host) { const unspreadableToRestKeys = []; for (const prop of getPropertiesOfType(source)) { const literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */); - if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) && !(getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) && isSpreadableProperty(prop)) { + if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) && !(getDeclarationModifierFlagsFromSymbol(prop) & (2 /* Private */ | 4 /* Protected */)) && isSpreadableProperty(prop)) { spreadableProperties.push(prop); } else { unspreadableToRestKeys.push(literalTypeFromProperty); @@ -56438,7 +56564,7 @@ function createTypeChecker(host) { if (declaredType) { return addOptionality(declaredType, isProperty, isOptional); } - if ((noImplicitAny || isInJSFile(declaration)) && isVariableDeclaration(declaration) && !isBindingPattern(declaration.name) && !(getCombinedModifierFlagsCached(declaration) & 1 /* Export */) && !(declaration.flags & 33554432 /* Ambient */)) { + if ((noImplicitAny || isInJSFile(declaration)) && isVariableDeclaration(declaration) && !isBindingPattern(declaration.name) && !(getCombinedModifierFlagsCached(declaration) & 32 /* Export */) && !(declaration.flags & 33554432 /* Ambient */)) { if (!(getCombinedNodeFlagsCached(declaration) & 6 /* Constant */) && (!declaration.initializer || isNullOrUndefined3(declaration.initializer))) { return autoType; } @@ -56486,7 +56612,7 @@ function createTypeChecker(host) { if (isPropertyDeclaration(declaration) && (noImplicitAny || isInJSFile(declaration))) { if (!hasStaticModifier(declaration)) { const constructor = findConstructorDeclaration(declaration.parent); - const type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : void 0; + const type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : getEffectiveModifierFlags(declaration) & 128 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : void 0; return type && addOptionality( type, /*isProperty*/ @@ -56495,7 +56621,7 @@ function createTypeChecker(host) { ); } else { const staticBlocks = filter(declaration.parent.members, isClassStaticBlockDeclaration); - const type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) : getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : void 0; + const type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) : getEffectiveModifierFlags(declaration) & 128 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : void 0; return type && addOptionality( type, /*isProperty*/ @@ -56599,7 +56725,7 @@ function createTypeChecker(host) { return everyType(flowType, isNullableType) ? void 0 : convertAutoToAny(flowType); } function getFlowTypeOfProperty(reference, prop) { - const initialType = (prop == null ? void 0 : prop.valueDeclaration) && (!isAutoTypedProperty(prop) || getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; + const initialType = (prop == null ? void 0 : prop.valueDeclaration) && (!isAutoTypedProperty(prop) || getEffectiveModifierFlags(prop.valueDeclaration) & 128 /* Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); } function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) { @@ -57223,6 +57349,9 @@ function createTypeChecker(host) { function getTypeOfAlias(symbol) { const links = getSymbolLinks(symbol); if (!links.type) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return errorType; + } const targetSymbol = resolveAlias(symbol); const exportSymbol = symbol.declarations && getTargetOfAliasDeclaration( getDeclarationOfAliasSymbol(symbol), @@ -57231,6 +57360,10 @@ function createTypeChecker(host) { ); const declaredType = firstDefined(exportSymbol == null ? void 0 : exportSymbol.declarations, (d) => isExportAssignment(d) ? tryGetTypeFromEffectiveTypeNode(d) : void 0); links.type = (exportSymbol == null ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType : getSymbolFlags(targetSymbol) & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType; + if (!popTypeResolution()) { + reportCircularityError(exportSymbol ?? symbol); + return links.type = errorType; + } } return links.type; } @@ -57244,12 +57377,19 @@ function createTypeChecker(host) { } function reportCircularityError(symbol) { const declaration = symbol.valueDeclaration; - if (getEffectiveTypeAnnotationNode(declaration)) { - error2(symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); - return errorType; - } - if (noImplicitAny && (declaration.kind !== 169 /* Parameter */ || declaration.initializer)) { - error2(symbol.valueDeclaration, Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); + if (declaration) { + if (getEffectiveTypeAnnotationNode(declaration)) { + error2(symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); + return errorType; + } + if (noImplicitAny && (declaration.kind !== 169 /* Parameter */ || declaration.initializer)) { + error2(symbol.valueDeclaration, Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); + } + } else if (symbol.flags & 2097152 /* Alias */) { + const node = getDeclarationOfAliasSymbol(symbol); + if (node) { + error2(node, Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); + } } return anyType; } @@ -58252,7 +58392,7 @@ function createTypeChecker(host) { const baseConstructorType = getBaseConstructorTypeOfClass(classType); const baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); const declaration = getClassLikeDeclarationOfSymbol(classType.symbol); - const isAbstract = !!declaration && hasSyntacticModifier(declaration, 256 /* Abstract */); + const isAbstract = !!declaration && hasSyntacticModifier(declaration, 64 /* Abstract */); if (baseSignatures.length === 0) { return [createSignature( /*declaration*/ @@ -59028,7 +59168,7 @@ function createTypeChecker(host) { } function isConstTypeVariable(type, depth = 0) { var _a; - return depth < 5 && !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 3145728 /* UnionOrIntersection */ && some(type.types, (t) => isConstTypeVariable(t, depth)) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType, depth + 1) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type), depth + 1) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType, depth) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t, depth)) >= 0)); + return depth < 5 && !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 4096 /* Const */)) || type.flags & 3145728 /* UnionOrIntersection */ && some(type.types, (t) => isConstTypeVariable(t, depth)) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType, depth + 1) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type), depth + 1) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType, depth) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t, depth)) >= 0)); } function getConstraintOfIndexedAccess(type) { return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0; @@ -59354,7 +59494,7 @@ function createTypeChecker(host) { } else if (!isUnion && !isReadonlySymbol(prop)) { checkFlags &= ~8 /* Readonly */; } - checkFlags |= (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | (modifiers & 16 /* Protected */ ? 512 /* ContainsProtected */ : 0) | (modifiers & 8 /* Private */ ? 1024 /* ContainsPrivate */ : 0) | (modifiers & 32 /* Static */ ? 2048 /* ContainsStatic */ : 0); + checkFlags |= (!(modifiers & 6 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | (modifiers & 4 /* Protected */ ? 512 /* ContainsProtected */ : 0) | (modifiers & 2 /* Private */ ? 1024 /* ContainsPrivate */ : 0) | (modifiers & 256 /* Static */ ? 2048 /* ContainsStatic */ : 0); if (!isPrototypeProperty(prop)) { syntheticFlag = 2 /* SyntheticProperty */; } @@ -59806,7 +59946,7 @@ function createTypeChecker(host) { if (hasRestParameter(declaration) || isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { flags |= 1 /* HasRestParameter */; } - if (isConstructorTypeNode(declaration) && hasSyntacticModifier(declaration, 256 /* Abstract */) || isConstructorDeclaration(declaration) && hasSyntacticModifier(declaration.parent, 256 /* Abstract */)) { + if (isConstructorTypeNode(declaration) && hasSyntacticModifier(declaration, 64 /* Abstract */) || isConstructorDeclaration(declaration) && hasSyntacticModifier(declaration.parent, 64 /* Abstract */)) { flags |= 4 /* Abstract */; } links.resolvedSignature = createSignature( @@ -60176,7 +60316,7 @@ function createTypeChecker(host) { if (parameter.type) { forEachType(getTypeFromTypeNode(parameter.type), (keyType) => { if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos, keyType)) { - indexInfos.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, hasEffectiveModifier(declaration, 64 /* Readonly */), declaration)); + indexInfos.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, hasEffectiveModifier(declaration, 8 /* Readonly */), declaration)); } }); } @@ -62001,7 +62141,7 @@ function createTypeChecker(host) { return neverType; } function getLiteralTypeFromProperty(prop, include, includeNonPublic) { - if (includeNonPublic || !(getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { + if (includeNonPublic || !(getDeclarationModifierFlagsFromSymbol(prop) & 6 /* NonPublicAccessibilityModifier */)) { let type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; if (!type) { const name = getNameOfDeclaration(prop.valueDeclaration); @@ -62294,7 +62434,11 @@ function createTypeChecker(host) { if (indexInfo) { if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) { if (accessExpression) { - error2(accessExpression, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); + if (accessFlags & 4 /* Writing */) { + error2(accessExpression, Diagnostics.Type_0_is_generic_and_can_only_be_indexed_for_reading, typeToString(originalObjectType)); + } else { + error2(accessExpression, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); + } } return void 0; } @@ -62431,7 +62575,7 @@ function createTypeChecker(host) { } function isPatternLiteralPlaceholderType(type) { if (type.flags & 2097152 /* Intersection */) { - return some(type.types, (t) => !!(t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) || isPatternLiteralPlaceholderType(t)); + return !isGenericType(type) && some(type.types, (t) => !!(t.flags & (2944 /* Literal */ | 98304 /* Nullable */)) || isPatternLiteralPlaceholderType(t)); } return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || isPatternLiteralType(type); } @@ -62942,7 +63086,7 @@ function createTypeChecker(host) { function getAnonymousPartialType(type2) { const members = createSymbolTable(); for (const prop of getPropertiesOfType(type2)) { - if (getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) { + if (getDeclarationModifierFlagsFromSymbol(prop) & (2 /* Private */ | 4 /* Protected */)) { } else if (isSpreadableProperty(prop)) { const isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); const flags = 4 /* Property */ | 16777216 /* Optional */; @@ -63004,7 +63148,7 @@ function createTypeChecker(host) { const skippedPrivateMembers = /* @__PURE__ */ new Set(); const indexInfos = left === emptyObjectType ? getIndexInfosOfType(right) : getUnionIndexInfos([left, right]); for (const rightProp of getPropertiesOfType(right)) { - if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { + if (getDeclarationModifierFlagsFromSymbol(rightProp) & (2 /* Private */ | 4 /* Protected */)) { skippedPrivateMembers.add(rightProp.escapedName); } else if (isSpreadableProperty(rightProp)) { members.set(rightProp.escapedName, getSpreadSymbol(rightProp, readonly)); @@ -66571,25 +66715,25 @@ function createTypeChecker(host) { function propertyRelatedTo(source2, target2, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors2, intersectionState, skipOptional) { const sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); const targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); - if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 2 /* Private */ || targetPropFlags & 2 /* Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors2) { - if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 2 /* Private */ && targetPropFlags & 2 /* Private */) { reportError(Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* Private */ ? source2 : target2), typeToString(sourcePropFlags & 8 /* Private */ ? target2 : source2)); + reportError(Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 2 /* Private */ ? source2 : target2), typeToString(sourcePropFlags & 2 /* Private */ ? target2 : source2)); } } return 0 /* False */; } - } else if (targetPropFlags & 16 /* Protected */) { + } else if (targetPropFlags & 4 /* Protected */) { if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors2) { reportError(Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source2), typeToString(getDeclaringClass(targetProp) || target2)); } return 0 /* False */; } - } else if (sourcePropFlags & 16 /* Protected */) { + } else if (sourcePropFlags & 4 /* Protected */) { if (reportErrors2) { reportError(Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source2), typeToString(target2)); } @@ -67119,15 +67263,15 @@ function createTypeChecker(host) { if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - const sourceAccessibility = getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* NonPublicAccessibilityModifier */); - const targetAccessibility = getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* NonPublicAccessibilityModifier */); - if (targetAccessibility === 8 /* Private */) { + const sourceAccessibility = getSelectedEffectiveModifierFlags(sourceSignature.declaration, 6 /* NonPublicAccessibilityModifier */); + const targetAccessibility = getSelectedEffectiveModifierFlags(targetSignature.declaration, 6 /* NonPublicAccessibilityModifier */); + if (targetAccessibility === 2 /* Private */) { return true; } - if (targetAccessibility === 16 /* Protected */ && sourceAccessibility !== 8 /* Private */) { + if (targetAccessibility === 4 /* Protected */ && sourceAccessibility !== 2 /* Private */) { return true; } - if (targetAccessibility !== 16 /* Protected */ && !sourceAccessibility) { + if (targetAccessibility !== 4 /* Protected */ && !sourceAccessibility) { return true; } if (reportErrors2) { @@ -67227,7 +67371,7 @@ function createTypeChecker(host) { const variances = []; for (const tp of typeParameters) { const modifiers = getTypeParameterModifiers(tp); - let variance = modifiers & 65536 /* Out */ ? modifiers & 32768 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ : modifiers & 32768 /* In */ ? 2 /* Contravariant */ : void 0; + let variance = modifiers & 16384 /* Out */ ? modifiers & 8192 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ : modifiers & 8192 /* In */ ? 2 /* Contravariant */ : void 0; if (variance === void 0) { let unmeasurable = false; let unreliable = false; @@ -67275,7 +67419,7 @@ function createTypeChecker(host) { } function getTypeParameterModifiers(tp) { var _a; - return reduceLeft((_a = tp.symbol) == null ? void 0 : _a.declarations, (modifiers, d) => modifiers | getEffectiveModifierFlags(d), 0 /* None */) & (32768 /* In */ | 65536 /* Out */ | 2048 /* Const */); + return reduceLeft((_a = tp.symbol) == null ? void 0 : _a.declarations, (modifiers, d) => modifiers | getEffectiveModifierFlags(d), 0 /* None */) & (8192 /* In */ | 16384 /* Out */ | 4096 /* Const */); } function hasCovariantVoidArgument(typeArguments, variances) { for (let i = 0; i < variances.length; i++) { @@ -67360,13 +67504,16 @@ function createTypeChecker(host) { }); } function isValidOverrideOf(sourceProp, targetProp) { - return !forEachProperty2(targetProp, (tp) => getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ? !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false); + return !forEachProperty2(targetProp, (tp) => getDeclarationModifierFlagsFromSymbol(tp) & 4 /* Protected */ ? !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false); } function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { - return forEachProperty2(prop, (p) => getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* Protected */ ? !hasBaseType(checkClass, getDeclaringClass(p)) : false) ? void 0 : checkClass; + return forEachProperty2(prop, (p) => getDeclarationModifierFlagsFromSymbol(p, writing) & 4 /* Protected */ ? !hasBaseType(checkClass, getDeclaringClass(p)) : false) ? void 0 : checkClass; } function isDeeplyNestedType(type, stack, depth, maxDepth = 3) { if (depth >= maxDepth) { + if ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */) { + type = getMappedTargetWithSymbol(type); + } if (type.flags & 2097152 /* Intersection */) { return some(type.types, (t) => isDeeplyNestedType(t, stack, depth, maxDepth)); } @@ -67375,7 +67522,7 @@ function createTypeChecker(host) { let lastTypeId = 0; for (let i = 0; i < depth; i++) { const t = stack[i]; - if (t.flags & 2097152 /* Intersection */ ? some(t.types, (u) => getRecursionIdentity(u) === identity2) : getRecursionIdentity(t) === identity2) { + if (hasMatchingRecursionIdentity(t, identity2)) { if (t.id >= lastTypeId) { count++; if (count >= maxDepth) { @@ -67388,18 +67535,29 @@ function createTypeChecker(host) { } return false; } + function getMappedTargetWithSymbol(type) { + let target; + while ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */ && (target = getModifiersTypeFromMappedType(type)) && (target.symbol || target.flags & 2097152 /* Intersection */ && some(target.types, (t) => !!t.symbol))) { + type = target; + } + return type; + } + function hasMatchingRecursionIdentity(type, identity2) { + if ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */) { + type = getMappedTargetWithSymbol(type); + } + if (type.flags & 2097152 /* Intersection */) { + return some(type.types, (t) => hasMatchingRecursionIdentity(t, identity2)); + } + return getRecursionIdentity(type) === identity2; + } function getRecursionIdentity(type) { if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) { if (getObjectFlags(type) & 4 /* Reference */ && type.node) { return type.node; } - if (type.symbol) { - if (getObjectFlags(type) & 32 /* Mapped */) { - type = getMappedTargetWithSymbol(type); - } - if (!(getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) { - return type.symbol; - } + if (type.symbol && !(getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) { + return type.symbol; } if (isTupleType(type)) { return type.target; @@ -67419,13 +67577,6 @@ function createTypeChecker(host) { } return type; } - function getMappedTargetWithSymbol(type) { - let target = type; - while ((getObjectFlags(target) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */ && isMappedTypeWithKeyofConstraintDeclaration(target)) { - target = getModifiersTypeFromMappedType(target); - } - return target.symbol ? target : type; - } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties2(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; } @@ -67433,8 +67584,8 @@ function createTypeChecker(host) { if (sourceProp === targetProp) { return -1 /* True */; } - const sourcePropAccessibility = getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* NonPublicAccessibilityModifier */; - const targetPropAccessibility = getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* NonPublicAccessibilityModifier */; + const sourcePropAccessibility = getDeclarationModifierFlagsFromSymbol(sourceProp) & 6 /* NonPublicAccessibilityModifier */; + const targetPropAccessibility = getDeclarationModifierFlagsFromSymbol(targetProp) & 6 /* NonPublicAccessibilityModifier */; if (sourcePropAccessibility !== targetPropAccessibility) { return 0 /* False */; } @@ -70403,7 +70554,7 @@ function createTypeChecker(host) { return createFlowType(narrowedType, isIncomplete(flowType)); } function getTypeAtSwitchClause(flow) { - const expr = flow.switchStatement.expression; + const expr = skipParentheses(flow.switchStatement.expression); const flowType = getTypeAtFlowNode(flow.antecedent); let type = getTypeFromFlowType(flowType); if (isMatchingReference(reference, expr)) { @@ -70411,16 +70562,7 @@ function createTypeChecker(host) { } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else if (expr.kind === 112 /* TrueKeyword */) { - const clause = flow.switchStatement.caseBlock.clauses.find((_, index) => index === flow.clauseStart); - const clauseExpression = clause && clause.kind === 296 /* CaseClause */ ? clause.expression : void 0; - if (clauseExpression) { - type = narrowType( - type, - clauseExpression, - /*assumeTrue*/ - true - ); - } + type = narrowTypeBySwitchOnTrue(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { if (strictNullChecks) { if (optionalChainContainsReference(expr, reference)) { @@ -70580,13 +70722,15 @@ function createTypeChecker(host) { return void 0; } function getDiscriminantPropertyAccess(expr, computedType) { - const type = !(computedType.flags & 1048576 /* Union */) && declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; - if (type.flags & 1048576 /* Union */) { + if (declaredType.flags & 1048576 /* Union */ || computedType.flags & 1048576 /* Union */) { const access = getCandidateDiscriminantPropertyAccess(expr); if (access) { const name = getAccessedPropertyName(access); - if (name && isDiscriminantProperty(type, name)) { - return access; + if (name) { + const type = declaredType.flags & 1048576 /* Union */ && isTypeSubsetOf(computedType, declaredType) ? declaredType : computedType; + if (isDiscriminantProperty(type, name)) { + return access; + } } } } @@ -70966,6 +71110,42 @@ function createTypeChecker(host) { const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd); return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType)); } + function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) { + const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */); + const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd; + for (let i = 0; i < clauseStart; i++) { + const clause = switchStatement.caseBlock.clauses[i]; + if (clause.kind === 296 /* CaseClause */) { + type = narrowType( + type, + clause.expression, + /*assumeTrue*/ + false + ); + } + } + if (hasDefaultClause) { + for (let i = clauseEnd; i < switchStatement.caseBlock.clauses.length; i++) { + const clause = switchStatement.caseBlock.clauses[i]; + if (clause.kind === 296 /* CaseClause */) { + type = narrowType( + type, + clause.expression, + /*assumeTrue*/ + false + ); + } + } + return type; + } + const clauses = switchStatement.caseBlock.clauses.slice(clauseStart, clauseEnd); + return getUnionType(map(clauses, (clause) => clause.kind === 296 /* CaseClause */ ? narrowType( + type, + clause.expression, + /*assumeTrue*/ + true + ) : neverType)); + } function isMatchingConstructorReference(expr) { return (isPropertyAccessExpression(expr) && idText(expr.name) === "constructor" || isElementAccessExpression(expr) && isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") && isMatchingReference(reference, expr.expression); } @@ -71399,7 +71579,7 @@ function createTypeChecker(host) { if (languageVersion < 2 /* ES2015 */) { if (container.kind === 219 /* ArrowFunction */) { error2(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); - } else if (hasSyntacticModifier(container, 512 /* Async */)) { + } else if (hasSyntacticModifier(container, 1024 /* Async */)) { error2(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } @@ -71812,7 +71992,7 @@ function createTypeChecker(host) { let inAsyncFunction = false; if (!isCallExpression2) { while (container && container.kind === 219 /* ArrowFunction */) { - if (hasSyntacticModifier(container, 512 /* Async */)) + if (hasSyntacticModifier(container, 1024 /* Async */)) inAsyncFunction = true; container = getSuperContainer( container, @@ -71821,7 +72001,7 @@ function createTypeChecker(host) { ); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } - if (container && hasSyntacticModifier(container, 512 /* Async */)) + if (container && hasSyntacticModifier(container, 1024 /* Async */)) inAsyncFunction = true; } let nodeCheckFlag = 0; @@ -71964,7 +72144,7 @@ function createTypeChecker(host) { return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral)); } const parent2 = walkUpParenthesizedExpressions(func.parent); - if (parent2.kind === 226 /* BinaryExpression */ && parent2.operatorToken.kind === 64 /* EqualsToken */) { + if (isAssignmentExpression(parent2)) { const target = parent2.left; if (isAccessExpression(target)) { const { expression } = target; @@ -72153,7 +72333,24 @@ function createTypeChecker(host) { } const signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); if (signature && !isResolvingReturnTypeOfSignature(signature)) { - return getReturnTypeOfSignature(signature); + const returnType2 = getReturnTypeOfSignature(signature); + const functionFlags = getFunctionFlags(functionDecl); + if (functionFlags & 1 /* Generator */) { + return filterType(returnType2, (t) => { + return !!(t.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || checkGeneratorInstantiationAssignabilityToReturnType( + t, + functionFlags, + /*errorNode*/ + void 0 + ); + }); + } + if (functionFlags & 2 /* Async */) { + return filterType(returnType2, (t) => { + return !!(t.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || !!getAwaitedTypeOfPromise(t); + }); + } + return returnType2; } const iife = getImmediatelyInvokedFunctionExpression(functionDecl); if (iife) { @@ -73532,7 +73729,7 @@ function createTypeChecker(host) { } } const parent2 = openingLikeElement.parent.kind === 284 /* JsxElement */ ? openingLikeElement.parent : void 0; - if (parent2 && parent2.openingElement === openingLikeElement && parent2.children.length > 0) { + if (parent2 && parent2.openingElement === openingLikeElement && getSemanticJsxChildren(parent2.children).length > 0) { const childrenTypes = checkJsxChildren(parent2, checkMode); if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { if (explicitlySpecifyChildrenAttribute) { @@ -74009,20 +74206,20 @@ function createTypeChecker(host) { return false; } } - if (flags & 256 /* Abstract */) { + if (flags & 64 /* Abstract */) { if (errorNode) { error2(errorNode, Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); } return false; } - if (!(flags & 32 /* Static */) && ((_a = prop.declarations) == null ? void 0 : _a.some(isClassInstanceProperty))) { + if (!(flags & 256 /* Static */) && ((_a = prop.declarations) == null ? void 0 : _a.some(isClassInstanceProperty))) { if (errorNode) { error2(errorNode, Diagnostics.Class_field_0_defined_by_the_parent_class_is_not_accessible_in_the_child_class_via_super, symbolToString(prop)); } return false; } } - if (flags & 256 /* Abstract */ && symbolHasNonMethodDeclaration(prop) && (isThisProperty(location) || isThisInitializedObjectBindingExpression(location) || isObjectBindingPattern(location.parent) && isThisInitializedDeclaration(location.parent.parent))) { + if (flags & 64 /* Abstract */ && symbolHasNonMethodDeclaration(prop) && (isThisProperty(location) || isThisInitializedObjectBindingExpression(location) || isObjectBindingPattern(location.parent) && isThisInitializedDeclaration(location.parent.parent))) { const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(location)) { if (errorNode) { @@ -74031,10 +74228,10 @@ function createTypeChecker(host) { return false; } } - if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { + if (!(flags & 6 /* NonPublicAccessibilityModifier */)) { return true; } - if (flags & 8 /* Private */) { + if (flags & 2 /* Private */) { const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(location, declaringClassDeclaration)) { if (errorNode) { @@ -74054,14 +74251,14 @@ function createTypeChecker(host) { if (!enclosingClass) { enclosingClass = getEnclosingClassFromThisParameter(location); enclosingClass = enclosingClass && isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing); - if (flags & 32 /* Static */ || !enclosingClass) { + if (flags & 256 /* Static */ || !enclosingClass) { if (errorNode) { error2(errorNode, Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || containingType)); } return false; } } - if (flags & 32 /* Static */) { + if (flags & 256 /* Static */) { return true; } if (containingType.flags & 262144 /* TypeParameter */) { @@ -74481,7 +74678,7 @@ function createTypeChecker(host) { } let diagnosticMessage; const declarationName = idText(right); - if (isInPropertyInitializerOrClassStaticBlock(node) && !isOptionalPropertyDeclaration(valueDeclaration) && !(isAccessExpression(node) && isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !(isMethodDeclaration(valueDeclaration) && getCombinedModifierFlagsCached(valueDeclaration) & 32 /* Static */) && (useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { + if (isInPropertyInitializerOrClassStaticBlock(node) && !isOptionalPropertyDeclaration(valueDeclaration) && !(isAccessExpression(node) && isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !(isMethodDeclaration(valueDeclaration) && getCombinedModifierFlagsCached(valueDeclaration) & 256 /* Static */) && (useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error2(right, Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } else if (valueDeclaration.kind === 263 /* ClassDeclaration */ && node.parent.kind !== 183 /* TypeReference */ && !(valueDeclaration.flags & 33554432 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error2(right, Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -74735,7 +74932,7 @@ function createTypeChecker(host) { if (!valueDeclaration) { return; } - const hasPrivateModifier = hasEffectiveModifier(valueDeclaration, 8 /* Private */); + const hasPrivateModifier = hasEffectiveModifier(valueDeclaration, 2 /* Private */); const hasPrivateIdentifier = prop.valueDeclaration && isNamedDeclaration(prop.valueDeclaration) && isPrivateIdentifier(prop.valueDeclaration.name); if (!hasPrivateModifier && !hasPrivateIdentifier) { return; @@ -75155,9 +75352,11 @@ function createTypeChecker(host) { } if (arg.kind === 237 /* SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); + } else { + names.push(void 0); } } - return createTupleType(types, flags, inConstContext && !someType(restType, isMutableArrayLikeType), length(names) === length(types) ? names : void 0); + return createTupleType(types, flags, inConstContext && !someType(restType, isMutableArrayLikeType), names); } function checkTypeArguments(signature, typeArgumentNodes, reportErrors2, headMessage) { const isJavascript = isInJSFile(signature.declaration); @@ -76178,7 +76377,7 @@ function createTypeChecker(host) { return resolveErrorCall(node); } const valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && hasSyntacticModifier(valueDecl, 256 /* Abstract */)) { + if (valueDecl && hasSyntacticModifier(valueDecl, 64 /* Abstract */)) { error2(node, Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } @@ -76241,7 +76440,7 @@ function createTypeChecker(host) { return true; } const declaration = signature.declaration; - const modifiers = getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); + const modifiers = getSelectedEffectiveModifierFlags(declaration, 6 /* NonPublicAccessibilityModifier */); if (!modifiers || declaration.kind !== 176 /* Constructor */) { return true; } @@ -76249,16 +76448,16 @@ function createTypeChecker(host) { const declaringClass = getDeclaredTypeOfSymbol(declaration.parent.symbol); if (!isNodeWithinClass(node, declaringClassDeclaration)) { const containingClass = getContainingClass(node); - if (containingClass && modifiers & 16 /* Protected */) { + if (containingClass && modifiers & 4 /* Protected */) { const containingType = getTypeOfNode(containingClass); if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) { return true; } } - if (modifiers & 8 /* Private */) { + if (modifiers & 2 /* Private */) { error2(node, Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } - if (modifiers & 16 /* Protected */) { + if (modifiers & 4 /* Protected */) { error2(node, Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } return false; @@ -77292,12 +77491,9 @@ function createTypeChecker(host) { types.push(restType); flags.push(8 /* Variadic */); } - const name = getNameableDeclarationAtPosition(source, i); - if (name) { - names.push(name); - } + names.push(getNameableDeclarationAtPosition(source, i)); } - return createTupleType(types, flags, readonly, length(names) === length(types) ? names : void 0); + return createTupleType(types, flags, readonly, names); } function getParameterCount(signature) { const length2 = signature.parameters.length; @@ -77993,8 +78189,20 @@ function createTypeChecker(host) { let hasReturnWithNoExpression = functionHasImplicitReturn(func); let hasReturnOfTypeNever = false; forEachReturnStatement(func.body, (returnStatement) => { - const expr = returnStatement.expression; + let expr = returnStatement.expression; if (expr) { + expr = skipParentheses( + expr, + /*excludeJSDocTypeAssertions*/ + true + ); + if (functionFlags & 2 /* Async */ && expr.kind === 223 /* AwaitExpression */) { + expr = skipParentheses( + expr.expression, + /*excludeJSDocTypeAssertions*/ + true + ); + } if (expr.kind === 213 /* CallExpression */ && expr.expression.kind === 80 /* Identifier */ && checkExpressionCached(expr.expression).symbol === func.symbol) { hasReturnOfTypeNever = true; return; @@ -78226,7 +78434,7 @@ function createTypeChecker(host) { return !setProp; } function isReadonlySymbol(symbol) { - return !!(getCheckFlags(symbol) & 8 /* Readonly */ || symbol.flags & 4 /* Property */ && getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 6 /* Constant */ || symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || symbol.flags & 8 /* EnumMember */ || some(symbol.declarations, isReadonlyAssignmentDeclaration)); + return !!(getCheckFlags(symbol) & 8 /* Readonly */ || symbol.flags & 4 /* Property */ && getDeclarationModifierFlagsFromSymbol(symbol) & 8 /* Readonly */ || symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 6 /* Constant */ || symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || symbol.flags & 8 /* EnumMember */ || some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) { var _a, _b; @@ -78307,7 +78515,7 @@ function createTypeChecker(host) { return typeofType; } function checkVoidExpression(node) { - checkExpression(node.expression); + checkNodeDeferred(node); return undefinedWideningType; } function checkAwaitGrammar(node) { @@ -79343,7 +79551,15 @@ function createTypeChecker(host) { checkExternalEmitHelpers(node, 256 /* Values */); } } - const returnType = getReturnTypeFromAnnotation(func); + let returnType = getReturnTypeFromAnnotation(func); + if (returnType && returnType.flags & 1048576 /* Union */) { + returnType = filterType(returnType, (t) => checkGeneratorInstantiationAssignabilityToReturnType( + t, + functionFlags, + /*errorNode*/ + void 0 + )); + } const iterationTypes = returnType && getIterationTypesOfGeneratorFunctionReturnType(returnType, isAsync); const signatureYieldType = iterationTypes && iterationTypes.yieldType || anyType; const signatureNextType = iterationTypes && iterationTypes.nextType || anyType; @@ -79964,15 +80180,15 @@ function createTypeChecker(host) { var _a, _b; if (isInterfaceDeclaration(node.parent) || isClassLike(node.parent) || isTypeAliasDeclaration(node.parent)) { const typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfDeclaration(node)); - const modifiers = getTypeParameterModifiers(typeParameter) & (32768 /* In */ | 65536 /* Out */); + const modifiers = getTypeParameterModifiers(typeParameter) & (8192 /* In */ | 16384 /* Out */); if (modifiers) { const symbol = getSymbolOfDeclaration(node.parent); if (isTypeAliasDeclaration(node.parent) && !(getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) { error2(node, Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types); - } else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) { + } else if (modifiers === 8192 /* In */ || modifiers === 16384 /* Out */) { (_a = tracing) == null ? void 0 : _a.push(tracing.Phase.CheckTypes, "checkTypeParameterDeferred", { parent: getTypeId(getDeclaredTypeOfSymbol(symbol)), id: getTypeId(typeParameter) }); - const source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck); - const target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck); + const source = createMarkerType(symbol, typeParameter, modifiers === 16384 /* Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck); + const target = createMarkerType(symbol, typeParameter, modifiers === 16384 /* Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck); const saveVarianceTypeParameter = typeParameter; varianceTypeParameter = typeParameter; checkTypeAssignableTo(source, target, node, Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); @@ -79986,7 +80202,7 @@ function createTypeChecker(host) { checkGrammarModifiers(node); checkVariableLikeDeclaration(node); const func = getContainingFunction(node); - if (hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (hasSyntacticModifier(node, 31 /* ParameterPropertyModifier */)) { if (!(func.kind === 176 /* Constructor */ && nodeIsPresent(func.body))) { error2(node, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } @@ -80156,11 +80372,7 @@ function createTypeChecker(host) { if (returnType === voidType) { error2(returnTypeErrorLocation, Diagnostics.A_generator_cannot_have_a_void_type_annotation); } else { - const generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || anyType; - const generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || generatorYieldType; - const generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || unknownType; - const generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags2 & 2 /* Async */)); - checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeErrorLocation); + checkGeneratorInstantiationAssignabilityToReturnType(returnType, functionFlags2, returnTypeErrorLocation); } } else if ((functionFlags2 & 3 /* AsyncGenerator */) === 2 /* Async */) { checkAsyncFunctionReturnType(node, returnTypeNode, returnTypeErrorLocation); @@ -80171,6 +80383,13 @@ function createTypeChecker(host) { } } } + function checkGeneratorInstantiationAssignabilityToReturnType(returnType, functionFlags, errorNode) { + const generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags & 2 /* Async */) !== 0) || anyType; + const generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags & 2 /* Async */) !== 0) || generatorYieldType; + const generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags & 2 /* Async */) !== 0) || unknownType; + const generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags & 2 /* Async */)); + return checkTypeAssignableTo(generatorInstantiation, returnType, errorNode); + } function checkClassForDuplicateDeclarations(node) { const instanceNames = /* @__PURE__ */ new Map(); const staticNames = /* @__PURE__ */ new Map(); @@ -80318,7 +80537,7 @@ function createTypeChecker(host) { checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); setNodeLinksForPrivateIdentifierScope(node); - if (hasSyntacticModifier(node, 256 /* Abstract */) && node.kind === 172 /* PropertyDeclaration */ && node.initializer) { + if (hasSyntacticModifier(node, 64 /* Abstract */) && node.kind === 172 /* PropertyDeclaration */ && node.initializer) { error2(node, Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, declarationNameToString(node.name)); } } @@ -80335,7 +80554,7 @@ function createTypeChecker(host) { error2(node.name, Diagnostics.Class_constructor_may_not_be_a_generator); } checkFunctionOrMethodDeclaration(node); - if (hasSyntacticModifier(node, 256 /* Abstract */) && node.kind === 174 /* MethodDeclaration */ && node.body) { + if (hasSyntacticModifier(node, 64 /* Abstract */) && node.kind === 174 /* MethodDeclaration */ && node.body) { error2(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)); } if (isPrivateIdentifier(node.name) && !getContainingClass(node)) { @@ -80392,7 +80611,7 @@ function createTypeChecker(host) { if (classExtendsNull) { error2(superCall, Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); } - const superCallShouldBeRootLevel = !emitStandardClassFields && (some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || some(node.parameters, (p) => hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */))); + const superCallShouldBeRootLevel = !emitStandardClassFields && (some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || some(node.parameters, (p) => hasSyntacticModifier(p, 31 /* ParameterPropertyModifier */))); if (superCallShouldBeRootLevel) { if (!superCallIsRootLevelInConstructor(superCall, node.body)) { error2(superCall, Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers); @@ -80461,11 +80680,11 @@ function createTypeChecker(host) { getNodeLinks(getter).flags |= 1 /* TypeChecked */; const getterFlags = getEffectiveModifierFlags(getter); const setterFlags = getEffectiveModifierFlags(setter); - if ((getterFlags & 256 /* Abstract */) !== (setterFlags & 256 /* Abstract */)) { + if ((getterFlags & 64 /* Abstract */) !== (setterFlags & 64 /* Abstract */)) { error2(getter.name, Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); error2(setter.name, Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } - if (getterFlags & 16 /* Protected */ && !(setterFlags & (16 /* Protected */ | 8 /* Private */)) || getterFlags & 8 /* Private */ && !(setterFlags & 8 /* Private */)) { + if (getterFlags & 4 /* Protected */ && !(setterFlags & (4 /* Protected */ | 2 /* Private */)) || getterFlags & 2 /* Private */ && !(setterFlags & 2 /* Private */)) { error2(getter.name, Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); error2(setter.name, Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); } @@ -80645,7 +80864,7 @@ function createTypeChecker(host) { const propertyName = getPropertyNameFromIndex(indexType, accessNode); if (propertyName) { const propertySymbol = forEachType(apparentObjectType, (t) => getPropertyOfType(t, propertyName)); - if (propertySymbol && getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* NonPublicAccessibilityModifier */) { + if (propertySymbol && getDeclarationModifierFlagsFromSymbol(propertySymbol) & 6 /* NonPublicAccessibilityModifier */) { error2(accessNode, Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, unescapeLeadingUnderscores(propertyName)); return errorType; } @@ -80743,16 +80962,16 @@ function createTypeChecker(host) { getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return (hasEffectiveModifier(node, 8 /* Private */) || isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 33554432 /* Ambient */); + return (hasEffectiveModifier(node, 2 /* Private */) || isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 33554432 /* Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { let flags = getCombinedModifierFlagsCached(n); if (n.parent.kind !== 264 /* InterfaceDeclaration */ && n.parent.kind !== 263 /* ClassDeclaration */ && n.parent.kind !== 231 /* ClassExpression */ && n.flags & 33554432 /* Ambient */) { const container = getEnclosingContainer(n); - if (container && container.flags & 128 /* ExportContext */ && !(flags & 2 /* Ambient */) && !(isModuleBlock(n.parent) && isModuleDeclaration(n.parent.parent) && isGlobalScopeAugmentation(n.parent.parent))) { - flags |= 1 /* Export */; + if (container && container.flags & 128 /* ExportContext */ && !(flags & 128 /* Ambient */) && !(isModuleBlock(n.parent) && isModuleDeclaration(n.parent.parent) && isGlobalScopeAugmentation(n.parent.parent))) { + flags |= 32 /* Export */; } - flags |= 2 /* Ambient */; + flags |= 128 /* Ambient */; } return flags & flagsToCheck; } @@ -80770,13 +80989,13 @@ function createTypeChecker(host) { const canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck2); forEach(overloads, (o) => { const deviation = getEffectiveDeclarationFlags(o, flagsToCheck2) ^ canonicalFlags; - if (deviation & 1 /* Export */) { + if (deviation & 32 /* Export */) { error2(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); - } else if (deviation & 2 /* Ambient */) { + } else if (deviation & 128 /* Ambient */) { error2(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); - } else if (deviation & (8 /* Private */ | 16 /* Protected */)) { + } else if (deviation & (2 /* Private */ | 4 /* Protected */)) { error2(getNameOfDeclaration(o) || o, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); - } else if (deviation & 256 /* Abstract */) { + } else if (deviation & 64 /* Abstract */) { error2(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); @@ -80793,7 +81012,7 @@ function createTypeChecker(host) { }); } } - const flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 8 /* Private */ | 16 /* Protected */ | 256 /* Abstract */; + const flagsToCheck = 32 /* Export */ | 128 /* Ambient */ | 2 /* Private */ | 4 /* Protected */ | 64 /* Abstract */; let someNodeFlags = 0 /* None */; let allNodeFlags = flagsToCheck; let someHaveQuestionToken = false; @@ -80841,7 +81060,7 @@ function createTypeChecker(host) { if (isConstructor) { error2(errorNode, Diagnostics.Constructor_implementation_is_missing); } else { - if (hasSyntacticModifier(node, 256 /* Abstract */)) { + if (hasSyntacticModifier(node, 64 /* Abstract */)) { error2(errorNode, Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { error2(errorNode, Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); @@ -80927,7 +81146,7 @@ function createTypeChecker(host) { } }); } - if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !hasSyntacticModifier(lastSeenNonAmbientDeclaration, 256 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { + if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !hasSyntacticModifier(lastSeenNonAmbientDeclaration, 64 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -80970,9 +81189,9 @@ function createTypeChecker(host) { let defaultExportedDeclarationSpaces = 0 /* None */; for (const d of symbol.declarations) { const declarationSpaces = getDeclarationSpaces(d); - const effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 1024 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 1024 /* Default */) { + const effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 32 /* Export */ | 2048 /* Default */); + if (effectiveDeclarationFlags & 32 /* Export */) { + if (effectiveDeclarationFlags & 2048 /* Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { exportedDeclarationSpaces |= declarationSpaces; @@ -81613,6 +81832,12 @@ function createTypeChecker(host) { } } } + function checkJSDocThisTag(node) { + const host2 = getEffectiveJSDocHost(node); + if (host2 && isArrowFunction(host2)) { + error2(node.tagName, Diagnostics.An_arrow_function_cannot_have_a_this_parameter); + } + } function checkJSDocImplementsTag(node) { const classLike = getEffectiveJSDocHost(node); if (!classLike || !isClassDeclaration(classLike) && !isClassExpression(classLike)) { @@ -81775,13 +82000,13 @@ function createTypeChecker(host) { break; } const symbol = getSymbolOfDeclaration(member); - if (!symbol.isReferenced && (hasEffectiveModifier(member, 8 /* Private */) || isNamedDeclaration(member) && isPrivateIdentifier(member.name)) && !(member.flags & 33554432 /* Ambient */)) { + if (!symbol.isReferenced && (hasEffectiveModifier(member, 2 /* Private */) || isNamedDeclaration(member) && isPrivateIdentifier(member.name)) && !(member.flags & 33554432 /* Ambient */)) { addDiagnostic(member, 0 /* Local */, createDiagnosticForNode(member.name, Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; case 176 /* Constructor */: for (const parameter of member.parameters) { - if (!parameter.symbol.isReferenced && hasSyntacticModifier(parameter, 8 /* Private */)) { + if (!parameter.symbol.isReferenced && hasSyntacticModifier(parameter, 2 /* Private */)) { addDiagnostic(parameter, 0 /* Local */, createDiagnosticForNode(parameter.name, Diagnostics.Property_0_is_declared_but_its_value_is_never_read, symbolName(parameter.symbol))); } } @@ -82227,7 +82452,7 @@ function createTypeChecker(host) { } forEach(node.name.elements, checkSourceElement); } - if (isParameter(node) && node.initializer && nodeIsMissing(getContainingFunction(node).body)) { + if (node.initializer && isParameterDeclaration(node) && nodeIsMissing(getContainingFunction(node).body)) { error2(node, Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -82357,7 +82582,7 @@ function createTypeChecker(host) { if (hasQuestionToken(left) !== hasQuestionToken(right)) { return false; } - const interestingFlags = 8 /* Private */ | 16 /* Protected */ | 512 /* Async */ | 256 /* Abstract */ | 64 /* Readonly */ | 32 /* Static */; + const interestingFlags = 2 /* Private */ | 4 /* Protected */ | 1024 /* Async */ | 64 /* Abstract */ | 8 /* Readonly */ | 256 /* Static */; return getSelectedEffectiveModifierFlags(left, interestingFlags) === getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { @@ -83685,7 +83910,7 @@ function createTypeChecker(host) { if (legacyDecorators && firstDecorator && some(node.members, (p) => hasStaticModifier(p) && isPrivateIdentifierClassElementDeclaration(p))) { grammarErrorOnNode(firstDecorator, Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); } - if (!node.name && !hasSyntacticModifier(node, 1024 /* Default */)) { + if (!node.name && !hasSyntacticModifier(node, 2048 /* Default */)) { grammarErrorOnFirstToken(node, Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -83751,7 +83976,7 @@ function createTypeChecker(host) { error2(node.name || node, Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } else { const constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); - if (constructSignatures.some((signature) => signature.flags & 4 /* Abstract */) && !hasSyntacticModifier(node, 256 /* Abstract */)) { + if (constructSignatures.some((signature) => signature.flags & 4 /* Abstract */) && !hasSyntacticModifier(node, 64 /* Abstract */)) { error2(node.name || node, Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract); } } @@ -83965,7 +84190,7 @@ function createTypeChecker(host) { const signatures = getSignaturesOfType(type, 1 /* Construct */); if (signatures.length) { const declaration = signatures[0].declaration; - if (declaration && hasEffectiveModifier(declaration, 8 /* Private */)) { + if (declaration && hasEffectiveModifier(declaration, 2 /* Private */)) { const typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error2(node, Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -83985,7 +84210,7 @@ function createTypeChecker(host) { const baseTypes = baseTypeNode && getBaseTypes(type); const baseWithThis = (baseTypes == null ? void 0 : baseTypes.length) ? getTypeWithThisArgument(first(baseTypes), type.thisType) : void 0; const baseStaticType = getBaseConstructorTypeOfClass(type); - const memberHasOverrideModifier = member.parent ? hasOverrideModifier(member) : hasSyntacticModifier(member, 16384 /* Override */); + const memberHasOverrideModifier = member.parent ? hasOverrideModifier(member) : hasSyntacticModifier(member, 16 /* Override */); return checkMemberForOverrideModifier( node, staticType, @@ -84026,7 +84251,7 @@ function createTypeChecker(host) { Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived === base) { const derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); - if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !hasSyntacticModifier(derivedClassDecl, 256 /* Abstract */))) { + if (baseDeclarationFlags & 64 /* Abstract */ && (!derivedClassDecl || !hasSyntacticModifier(derivedClassDecl, 64 /* Abstract */))) { for (const otherBaseType of getBaseTypes(type)) { if (otherBaseType === baseType) continue; @@ -84069,7 +84294,7 @@ function createTypeChecker(host) { } } else { const derivedDeclarationFlags = getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + if (baseDeclarationFlags & 2 /* Private */ || derivedDeclarationFlags & 2 /* Private */) { continue; } let errorMessage; @@ -84086,7 +84311,7 @@ function createTypeChecker(host) { error2(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage2, symbolToString(base), typeToString(baseType), typeToString(type)); } else if (useDefineForClassFields) { const uninitialized = (_c = derived.declarations) == null ? void 0 : _c.find((d) => d.kind === 172 /* PropertyDeclaration */ && !d.initializer); - if (uninitialized && !(derived.flags & 33554432 /* Transient */) && !(baseDeclarationFlags & 256 /* Abstract */) && !(derivedDeclarationFlags & 256 /* Abstract */) && !((_d = derived.declarations) == null ? void 0 : _d.some((d) => !!(d.flags & 33554432 /* Ambient */)))) { + if (uninitialized && !(derived.flags & 33554432 /* Transient */) && !(baseDeclarationFlags & 64 /* Abstract */) && !(derivedDeclarationFlags & 64 /* Abstract */) && !((_d = derived.declarations) == null ? void 0 : _d.some((d) => !!(d.flags & 33554432 /* Ambient */)))) { const constructor = findConstructorDeclaration(getClassLikeDeclarationOfSymbol(type.symbol)); const propName = uninitialized.name; if (uninitialized.exclamationToken || !constructor || !isIdentifier(propName) || !strictNullChecks || !isPropertyInitializedInConstructor(propName, type, constructor)) { @@ -84113,7 +84338,7 @@ function createTypeChecker(host) { } } function isPropertyAbstractOrInterface(declaration, baseDeclarationFlags) { - return baseDeclarationFlags & 256 /* Abstract */ && (!isPropertyDeclaration(declaration) || !declaration.initializer) || isInterfaceDeclaration(declaration.parent); + return baseDeclarationFlags & 64 /* Abstract */ && (!isPropertyDeclaration(declaration) || !declaration.initializer) || isInterfaceDeclaration(declaration.parent); } function getNonInheritedProperties(type, baseTypes, properties) { if (!length(baseTypes)) { @@ -84178,7 +84403,7 @@ function createTypeChecker(host) { } const constructor = findConstructorDeclaration(node); for (const member of node.members) { - if (getEffectiveModifierFlags(member) & 2 /* Ambient */) { + if (getEffectiveModifierFlags(member) & 128 /* Ambient */) { continue; } if (!isStatic(member) && isPropertyWithoutInitializer(member)) { @@ -84765,7 +84990,7 @@ function createTypeChecker(host) { name ); } - if (isType && node.kind === 271 /* ImportEqualsDeclaration */ && hasEffectiveModifier(node, 1 /* Export */)) { + if (isType && node.kind === 271 /* ImportEqualsDeclaration */ && hasEffectiveModifier(node, 32 /* Export */)) { error2(node, Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_0_is_enabled, isolatedModulesLikeFlagName); } break; @@ -84887,7 +85112,7 @@ function createTypeChecker(host) { checkGrammarModifiers(node); if (isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { markExportAsReferenced(node); } if (node.moduleReference.kind !== 283 /* ExternalModuleReference */) { @@ -85299,6 +85524,8 @@ function createTypeChecker(host) { return checkJSDocAccessibilityModifiers(node); case 357 /* JSDocSatisfiesTag */: return checkJSDocSatisfiesTag(node); + case 350 /* JSDocThisTag */: + return checkJSDocThisTag(node); case 199 /* IndexedAccessType */: return checkIndexedAccessType(node); case 200 /* MappedType */: @@ -85503,6 +85730,9 @@ function createTypeChecker(host) { case 217 /* ParenthesizedExpression */: checkAssertionDeferred(node); break; + case 222 /* VoidExpression */: + checkExpression(node.expression); + break; case 226 /* BinaryExpression */: if (isInstanceOfExpression(node)) { resolveUntypedCall(node); @@ -86522,7 +86752,7 @@ function createTypeChecker(host) { return true; } const target = getSymbolLinks(symbol).aliasTarget; - if (target && getEffectiveModifierFlags(node) & 1 /* Export */ && getSymbolFlags(target) & 111551 /* Value */ && (shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { + if (target && getEffectiveModifierFlags(node) & 32 /* Export */ && getSymbolFlags(target) & 111551 /* Value */ && (shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { return true; } } @@ -86547,10 +86777,10 @@ function createTypeChecker(host) { return false; } function isRequiredInitializedParameter(parameter) { - return !!strictNullChecks && !isOptionalParameter(parameter) && !isJSDocParameterTag(parameter) && !!parameter.initializer && !hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + return !!strictNullChecks && !isOptionalParameter(parameter) && !isJSDocParameterTag(parameter) && !!parameter.initializer && !hasSyntacticModifier(parameter, 31 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { - return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && hasSyntacticModifier(parameter, 31 /* ParameterPropertyModifier */); } function isExpandoFunctionDeclaration(node) { const declaration = getParseTreeNode(node, isFunctionDeclaration); @@ -86971,7 +87201,16 @@ function createTypeChecker(host) { } return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); }, - isImportRequiredByAugmentation + isImportRequiredByAugmentation, + tryFindAmbientModule: (moduleReferenceExpression) => { + const node = getParseTreeNode(moduleReferenceExpression); + const moduleSpecifier = node && isStringLiteralLike(node) ? node.text : void 0; + return moduleSpecifier !== void 0 ? tryFindAmbientModule( + moduleSpecifier, + /*withAugmentations*/ + true + ) : void 0; + } }; function isImportRequiredByAugmentation(node) { const file = getSourceFileOfNode(node); @@ -87395,10 +87634,10 @@ function createTypeChecker(host) { return grammarErrorOnFirstToken(node, Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); } } - if (flags & ~(1025 /* ExportDefault */ | 131072 /* Decorator */)) { + if (flags & ~(2080 /* ExportDefault */ | 32768 /* Decorator */)) { return grammarErrorOnNode(modifier, Diagnostics.Decorators_are_not_valid_here); } - if (hasLeadingDecorators && flags & 126975 /* Modifier */) { + if (hasLeadingDecorators && flags & 98303 /* Modifier */) { Debug.assertIsDefined(firstDecorator); const sourceFile = getSourceFileOfNode(modifier); if (!hasParseDiagnostics(sourceFile)) { @@ -87410,10 +87649,10 @@ function createTypeChecker(host) { } return false; } - flags |= 131072 /* Decorator */; - if (!(flags & 126975 /* Modifier */)) { + flags |= 32768 /* Decorator */; + if (!(flags & 98303 /* Modifier */)) { hasLeadingDecorators = true; - } else if (flags & 1 /* Export */) { + } else if (flags & 32 /* Export */) { sawExportBeforeDecorators = true; } firstDecorator ?? (firstDecorator = modifier); @@ -87442,39 +87681,39 @@ function createTypeChecker(host) { } break; case 164 /* OverrideKeyword */: - if (flags & 16384 /* Override */) { + if (flags & 16 /* Override */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "override"); - } else if (flags & 2 /* Ambient */) { + } else if (flags & 128 /* Ambient */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); - } else if (flags & 64 /* Readonly */) { + } else if (flags & 8 /* Readonly */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); - } else if (flags & 128 /* Accessor */) { + } else if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "override", "accessor"); - } else if (flags & 512 /* Async */) { + } else if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); } - flags |= 16384 /* Override */; + flags |= 16 /* Override */; lastOverride = modifier; break; case 125 /* PublicKeyword */: case 124 /* ProtectedKeyword */: case 123 /* PrivateKeyword */: const text = visibilityToString(modifierToFlag(modifier.kind)); - if (flags & 28 /* AccessibilityModifier */) { + if (flags & 7 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, Diagnostics.Accessibility_modifier_already_seen); - } else if (flags & 16384 /* Override */) { + } else if (flags & 16 /* Override */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); - } else if (flags & 32 /* Static */) { + } else if (flags & 256 /* Static */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); - } else if (flags & 128 /* Accessor */) { + } else if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "accessor"); - } else if (flags & 64 /* Readonly */) { + } else if (flags & 8 /* Readonly */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly"); - } else if (flags & 512 /* Async */) { + } else if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } else if (node.parent.kind === 268 /* ModuleBlock */ || node.parent.kind === 312 /* SourceFile */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); - } else if (flags & 256 /* Abstract */) { + } else if (flags & 64 /* Abstract */) { if (modifier.kind === 123 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -87486,60 +87725,60 @@ function createTypeChecker(host) { flags |= modifierToFlag(modifier.kind); break; case 126 /* StaticKeyword */: - if (flags & 32 /* Static */) { + if (flags & 256 /* Static */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "static"); - } else if (flags & 64 /* Readonly */) { + } else if (flags & 8 /* Readonly */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly"); - } else if (flags & 512 /* Async */) { + } else if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); - } else if (flags & 128 /* Accessor */) { + } else if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "accessor"); } else if (node.parent.kind === 268 /* ModuleBlock */ || node.parent.kind === 312 /* SourceFile */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 169 /* Parameter */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); - } else if (flags & 256 /* Abstract */) { + } else if (flags & 64 /* Abstract */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); - } else if (flags & 16384 /* Override */) { + } else if (flags & 16 /* Override */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } - flags |= 32 /* Static */; + flags |= 256 /* Static */; lastStatic = modifier; break; case 129 /* AccessorKeyword */: - if (flags & 128 /* Accessor */) { + if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "accessor"); - } else if (flags & 64 /* Readonly */) { + } else if (flags & 8 /* Readonly */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "accessor", "readonly"); - } else if (flags & 2 /* Ambient */) { + } else if (flags & 128 /* Ambient */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "accessor", "declare"); } else if (node.kind !== 172 /* PropertyDeclaration */) { return grammarErrorOnNode(modifier, Diagnostics.accessor_modifier_can_only_appear_on_a_property_declaration); } - flags |= 128 /* Accessor */; + flags |= 512 /* Accessor */; break; case 148 /* ReadonlyKeyword */: - if (flags & 64 /* Readonly */) { + if (flags & 8 /* Readonly */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "readonly"); } else if (node.kind !== 172 /* PropertyDeclaration */ && node.kind !== 171 /* PropertySignature */ && node.kind !== 181 /* IndexSignature */ && node.kind !== 169 /* Parameter */) { return grammarErrorOnNode(modifier, Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); - } else if (flags & 128 /* Accessor */) { + } else if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "readonly", "accessor"); } - flags |= 64 /* Readonly */; + flags |= 8 /* Readonly */; break; case 95 /* ExportKeyword */: if (compilerOptions.verbatimModuleSyntax && !(node.flags & 33554432 /* Ambient */) && node.kind !== 265 /* TypeAliasDeclaration */ && node.kind !== 264 /* InterfaceDeclaration */ && // ModuleDeclaration needs to be checked that it is uninstantiated later node.kind !== 267 /* ModuleDeclaration */ && node.parent.kind === 312 /* SourceFile */ && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) { return grammarErrorOnNode(modifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled); } - if (flags & 1 /* Export */) { + if (flags & 32 /* Export */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "export"); - } else if (flags & 2 /* Ambient */) { + } else if (flags & 128 /* Ambient */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); - } else if (flags & 256 /* Abstract */) { + } else if (flags & 64 /* Abstract */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); - } else if (flags & 512 /* Async */) { + } else if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (isClassLike(node.parent)) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export"); @@ -87550,7 +87789,7 @@ function createTypeChecker(host) { } else if (blockScopeKind === 6 /* AwaitUsing */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_an_await_using_declaration, "export"); } - flags |= 1 /* Export */; + flags |= 32 /* Export */; break; case 90 /* DefaultKeyword */: const container = node.parent.kind === 312 /* SourceFile */ ? node.parent : node.parent.parent; @@ -87560,19 +87799,19 @@ function createTypeChecker(host) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_using_declaration, "default"); } else if (blockScopeKind === 6 /* AwaitUsing */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_an_await_using_declaration, "default"); - } else if (!(flags & 1 /* Export */)) { + } else if (!(flags & 32 /* Export */)) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "default"); } else if (sawExportBeforeDecorators) { return grammarErrorOnNode(firstDecorator, Diagnostics.Decorators_are_not_valid_here); } - flags |= 1024 /* Default */; + flags |= 2048 /* Default */; break; case 138 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { + if (flags & 128 /* Ambient */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "declare"); - } else if (flags & 512 /* Async */) { + } else if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); - } else if (flags & 16384 /* Override */) { + } else if (flags & 16 /* Override */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "override"); } else if (isClassLike(node.parent) && !isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare"); @@ -87586,62 +87825,62 @@ function createTypeChecker(host) { return grammarErrorOnNode(modifier, Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } else if (isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); - } else if (flags & 128 /* Accessor */) { + } else if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "declare", "accessor"); } - flags |= 2 /* Ambient */; + flags |= 128 /* Ambient */; lastDeclare = modifier; break; case 128 /* AbstractKeyword */: - if (flags & 256 /* Abstract */) { + if (flags & 64 /* Abstract */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "abstract"); } if (node.kind !== 263 /* ClassDeclaration */ && node.kind !== 185 /* ConstructorType */) { if (node.kind !== 174 /* MethodDeclaration */ && node.kind !== 172 /* PropertyDeclaration */ && node.kind !== 177 /* GetAccessor */ && node.kind !== 178 /* SetAccessor */) { return grammarErrorOnNode(modifier, Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 263 /* ClassDeclaration */ && hasSyntacticModifier(node.parent, 256 /* Abstract */))) { + if (!(node.parent.kind === 263 /* ClassDeclaration */ && hasSyntacticModifier(node.parent, 64 /* Abstract */))) { const message = node.kind === 172 /* PropertyDeclaration */ ? Diagnostics.Abstract_properties_can_only_appear_within_an_abstract_class : Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class; return grammarErrorOnNode(modifier, message); } - if (flags & 32 /* Static */) { + if (flags & 256 /* Static */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 8 /* Private */) { + if (flags & 2 /* Private */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } - if (flags & 512 /* Async */ && lastAsync) { + if (flags & 1024 /* Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - if (flags & 16384 /* Override */) { + if (flags & 16 /* Override */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); } - if (flags & 128 /* Accessor */) { + if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "accessor"); } } if (isNamedDeclaration(node) && node.name.kind === 81 /* PrivateIdentifier */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } - flags |= 256 /* Abstract */; + flags |= 64 /* Abstract */; break; case 134 /* AsyncKeyword */: - if (flags & 512 /* Async */) { + if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "async"); - } else if (flags & 2 /* Ambient */ || node.parent.flags & 33554432 /* Ambient */) { + } else if (flags & 128 /* Ambient */ || node.parent.flags & 33554432 /* Ambient */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (node.kind === 169 /* Parameter */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - if (flags & 256 /* Abstract */) { + if (flags & 64 /* Abstract */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - flags |= 512 /* Async */; + flags |= 1024 /* Async */; lastAsync = modifier; break; case 103 /* InKeyword */: case 147 /* OutKeyword */: - const inOutFlag = modifier.kind === 103 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */; + const inOutFlag = modifier.kind === 103 /* InKeyword */ ? 8192 /* In */ : 16384 /* Out */; const inOutText = modifier.kind === 103 /* InKeyword */ ? "in" : "out"; if (node.kind !== 168 /* TypeParameter */ || !(isInterfaceDeclaration(node.parent) || isClassLike(node.parent) || isTypeAliasDeclaration(node.parent))) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText); @@ -87649,7 +87888,7 @@ function createTypeChecker(host) { if (flags & inOutFlag) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, inOutText); } - if (inOutFlag & 32768 /* In */ && flags & 65536 /* Out */) { + if (inOutFlag & 8192 /* In */ && flags & 16384 /* Out */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "in", "out"); } flags |= inOutFlag; @@ -87658,24 +87897,24 @@ function createTypeChecker(host) { } } if (node.kind === 176 /* Constructor */) { - if (flags & 32 /* Static */) { + if (flags & 256 /* Static */) { return grammarErrorOnNode(lastStatic, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 16384 /* Override */) { + if (flags & 16 /* Override */) { return grammarErrorOnNode(lastOverride, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); } - if (flags & 512 /* Async */) { + if (flags & 1024 /* Async */) { return grammarErrorOnNode(lastAsync, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return false; - } else if ((node.kind === 272 /* ImportDeclaration */ || node.kind === 271 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + } else if ((node.kind === 272 /* ImportDeclaration */ || node.kind === 271 /* ImportEqualsDeclaration */) && flags & 128 /* Ambient */) { return grammarErrorOnNode(lastDeclare, Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); - } else if (node.kind === 169 /* Parameter */ && flags & 16476 /* ParameterPropertyModifier */ && isBindingPattern(node.name)) { + } else if (node.kind === 169 /* Parameter */ && flags & 31 /* ParameterPropertyModifier */ && isBindingPattern(node.name)) { return grammarErrorOnNode(node, Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); - } else if (node.kind === 169 /* Parameter */ && flags & 16476 /* ParameterPropertyModifier */ && node.dotDotDotToken) { + } else if (node.kind === 169 /* Parameter */ && flags & 31 /* ParameterPropertyModifier */ && node.dotDotDotToken) { return grammarErrorOnNode(node, Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } - if (flags & 512 /* Async */) { + if (flags & 1024 /* Async */) { return checkGrammarAsyncModifier(node, lastAsync); } return false; @@ -88195,12 +88434,12 @@ function createTypeChecker(host) { if (languageVersion < 2 /* ES2015 */ && isPrivateIdentifier(accessor.name)) { return grammarErrorOnNode(accessor.name, Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } - if (accessor.body === void 0 && !hasSyntacticModifier(accessor, 256 /* Abstract */)) { + if (accessor.body === void 0 && !hasSyntacticModifier(accessor, 64 /* Abstract */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, Diagnostics._0_expected, "{"); } } if (accessor.body) { - if (hasSyntacticModifier(accessor, 256 /* Abstract */)) { + if (hasSyntacticModifier(accessor, 64 /* Abstract */)) { return grammarErrorOnNode(accessor, Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } if (accessor.parent.kind === 187 /* TypeLiteral */ || accessor.parent.kind === 264 /* InterfaceDeclaration */) { @@ -88272,7 +88511,7 @@ function createTypeChecker(host) { } break; case 171 /* PropertySignature */: - if (!hasSyntacticModifier(parent2, 64 /* Readonly */)) { + if (!hasSyntacticModifier(parent2, 8 /* Readonly */)) { return grammarErrorOnNode(parent2.name, Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } break; @@ -88442,7 +88681,7 @@ function createTypeChecker(host) { const message = node.initializer ? Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type ? Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations : Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context; return grammarErrorOnNode(node.exclamationToken, message); } - if ((moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && moduleKind !== 4 /* System */ && !(node.parent.parent.flags & 33554432 /* Ambient */) && hasSyntacticModifier(node.parent.parent, 1 /* Export */)) { + if ((moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && moduleKind !== 4 /* System */ && !(node.parent.parent.flags & 33554432 /* Ambient */) && hasSyntacticModifier(node.parent.parent, 32 /* Export */)) { checkESModuleMarker(node.name); } return !!blockScopeKind && checkGrammarNameInLetOrConstDeclarations(node.name); @@ -88632,7 +88871,7 @@ function createTypeChecker(host) { } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 264 /* InterfaceDeclaration */ || node.kind === 265 /* TypeAliasDeclaration */ || node.kind === 272 /* ImportDeclaration */ || node.kind === 271 /* ImportEqualsDeclaration */ || node.kind === 278 /* ExportDeclaration */ || node.kind === 277 /* ExportAssignment */ || node.kind === 270 /* NamespaceExportDeclaration */ || hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 1024 /* Default */)) { + if (node.kind === 264 /* InterfaceDeclaration */ || node.kind === 265 /* TypeAliasDeclaration */ || node.kind === 272 /* ImportDeclaration */ || node.kind === 271 /* ImportEqualsDeclaration */ || node.kind === 278 /* ExportDeclaration */ || node.kind === 277 /* ExportAssignment */ || node.kind === 270 /* NamespaceExportDeclaration */ || hasSyntacticModifier(node, 128 /* Ambient */ | 32 /* Export */ | 2048 /* Default */)) { return false; } return grammarErrorOnFirstToken(node, Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier); @@ -88947,12 +89186,14 @@ var SymbolTrackerImpl = class _SymbolTrackerImpl { this.canTrackSymbol = !!((_a = this.inner) == null ? void 0 : _a.trackSymbol); } trackSymbol(symbol, enclosingDeclaration, meaning) { - var _a; + var _a, _b; if (((_a = this.inner) == null ? void 0 : _a.trackSymbol) && !this.disableTrackSymbol) { if (this.inner.trackSymbol(symbol, enclosingDeclaration, meaning)) { this.onDiagnosticReported(); return true; } + if (!(symbol.flags & 262144 /* TypeParameter */)) + ((_b = this.context).trackedSymbols ?? (_b.trackedSymbols = [])).push([symbol, enclosingDeclaration, meaning]); } return false; } @@ -90998,15 +91239,15 @@ function collectExternalModuleInfo(context, sourceFile) { } break; case 243 /* VariableStatement */: - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { for (const decl of node.declarationList.declarations) { exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames, exportedBindings); } } break; case 262 /* FunctionDeclaration */: - if (hasSyntacticModifier(node, 1 /* Export */)) { - if (hasSyntacticModifier(node, 1024 /* Default */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { + if (hasSyntacticModifier(node, 2048 /* Default */)) { if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); hasExportDefault = true; @@ -91022,8 +91263,8 @@ function collectExternalModuleInfo(context, sourceFile) { } break; case 263 /* ClassDeclaration */: - if (hasSyntacticModifier(node, 1 /* Export */)) { - if (hasSyntacticModifier(node, 1024 /* Default */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { + if (hasSyntacticModifier(node, 2048 /* Default */)) { if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); hasExportDefault = true; @@ -91893,7 +92134,7 @@ function injectClassThisAssignmentIfMissing(factory2, node, classThis, thisExpre // src/compiler/transformers/namedEvaluation.ts function getAssignedNameOfIdentifier(factory2, name, expression) { const original = getOriginalNode(skipOuterExpressions(expression)); - if ((isClassDeclaration(original) || isFunctionDeclaration(original)) && !original.name && hasSyntacticModifier(original, 1024 /* Default */)) { + if ((isClassDeclaration(original) || isFunctionDeclaration(original)) && !original.name && hasSyntacticModifier(original, 2048 /* Default */)) { return factory2.createStringLiteral("default"); } return factory2.createStringLiteralFromNode(name); @@ -92252,13 +92493,13 @@ function transformTypeScript(context) { break; case 263 /* ClassDeclaration */: case 262 /* FunctionDeclaration */: - if (hasSyntacticModifier(node, 2 /* Ambient */)) { + if (hasSyntacticModifier(node, 128 /* Ambient */)) { break; } if (node.name) { recordEmittedDeclarationInScope(node); } else { - Debug.assert(node.kind === 263 /* ClassDeclaration */ || hasSyntacticModifier(node, 1024 /* Default */)); + Debug.assert(node.kind === 263 /* ClassDeclaration */ || hasSyntacticModifier(node, 2048 /* Default */)); } break; } @@ -92313,7 +92554,7 @@ function transformTypeScript(context) { function namespaceElementVisitorWorker(node) { if (node.kind === 278 /* ExportDeclaration */ || node.kind === 272 /* ImportDeclaration */ || node.kind === 273 /* ImportClause */ || node.kind === 271 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 283 /* ExternalModuleReference */) { return void 0; - } else if (node.transformFlags & 1 /* ContainsTypeScript */ || hasSyntacticModifier(node, 1 /* Export */)) { + } else if (node.transformFlags & 1 /* ContainsTypeScript */ || hasSyntacticModifier(node, 32 /* Export */)) { return visitTypeScript(node); } return node; @@ -92371,7 +92612,7 @@ function transformTypeScript(context) { function modifierVisitor(node) { if (isDecorator(node)) return void 0; - if (modifierToFlag(node.kind) & 117086 /* TypeScriptModifier */) { + if (modifierToFlag(node.kind) & 28895 /* TypeScriptModifier */) { return void 0; } else if (currentNamespace && node.kind === 95 /* ExportKeyword */) { return void 0; @@ -92379,7 +92620,7 @@ function transformTypeScript(context) { return node; } function visitTypeScript(node) { - if (isStatement(node) && hasSyntacticModifier(node, 2 /* Ambient */)) { + if (isStatement(node) && hasSyntacticModifier(node, 128 /* Ambient */)) { return factory2.createNotEmittedStatement(node); } switch (node.kind) { @@ -92869,7 +93110,7 @@ function transformTypeScript(context) { return !nodeIsMissing(node.body); } function visitPropertyDeclaration(node, parent2) { - const isAmbient = node.flags & 33554432 /* Ambient */ || hasSyntacticModifier(node, 256 /* Abstract */); + const isAmbient = node.flags & 33554432 /* Ambient */ || hasSyntacticModifier(node, 64 /* Abstract */); if (isAmbient && !(legacyDecorators && hasDecorators(node))) { return void 0; } @@ -92878,7 +93119,7 @@ function transformTypeScript(context) { if (isAmbient) { return factory2.updatePropertyDeclaration( node, - concatenate(modifiers, factory2.createModifiersFromModifierFlags(2 /* Ambient */)), + concatenate(modifiers, factory2.createModifiersFromModifierFlags(128 /* Ambient */)), Debug.checkDefined(visitNode(node.name, visitor, isPropertyName)), /*questionOrExclamationToken*/ void 0, @@ -93041,7 +93282,7 @@ function transformTypeScript(context) { ); } function shouldEmitAccessorDeclaration(node) { - return !(nodeIsMissing(node.body) && hasSyntacticModifier(node, 256 /* Abstract */)); + return !(nodeIsMissing(node.body) && hasSyntacticModifier(node, 64 /* Abstract */)); } function visitGetAccessor(node, parent2) { if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { @@ -93774,16 +94015,16 @@ function transformTypeScript(context) { } } function isExportOfNamespace(node) { - return currentNamespace !== void 0 && hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace !== void 0 && hasSyntacticModifier(node, 32 /* Export */); } function isExternalModuleExport(node) { - return currentNamespace === void 0 && hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace === void 0 && hasSyntacticModifier(node, 32 /* Export */); } function isNamedExternalModuleExport(node) { - return isExternalModuleExport(node) && !hasSyntacticModifier(node, 1024 /* Default */); + return isExternalModuleExport(node) && !hasSyntacticModifier(node, 2048 /* Default */); } function isDefaultExternalModuleExport(node) { - return isExternalModuleExport(node) && hasSyntacticModifier(node, 1024 /* Default */); + return isExternalModuleExport(node) && hasSyntacticModifier(node, 2048 /* Default */); } function createExportMemberAssignmentStatement(node) { const expression = factory2.createAssignment( @@ -95116,8 +95357,8 @@ function transformClassFields(context) { getClassLexicalEnvironment().classThis = node.emitNode.classThis; } const isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 262144 /* ContainsConstructorReference */; - const isExport = hasSyntacticModifier(node, 1 /* Export */); - const isDefault = hasSyntacticModifier(node, 1024 /* Default */); + const isExport = hasSyntacticModifier(node, 32 /* Export */); + const isDefault = hasSyntacticModifier(node, 2048 /* Default */); let modifiers = visitNodes2(node.modifiers, modifierVisitor, isModifier); const heritageClauses = visitNodes2(node.heritageClauses, heritageClauseVisitor, isHeritageClause); const { members, prologue } = transformClassMembers(node); @@ -95663,7 +95904,7 @@ function transformClassFields(context) { return void 0; } const propertyOriginalNode = getOriginalNode(property); - if (hasSyntacticModifier(propertyOriginalNode, 256 /* Abstract */)) { + if (hasSyntacticModifier(propertyOriginalNode, 64 /* Abstract */)) { return void 0; } let initializer = visitNode(property.initializer, visitor, isExpression); @@ -96699,8 +96940,8 @@ function transformLegacyDecorators(context) { return addRange([updated], decorationStatements); } function transformClassDeclarationWithClassDecorators(node, name) { - const isExport = hasSyntacticModifier(node, 1 /* Export */); - const isDefault = hasSyntacticModifier(node, 1024 /* Default */); + const isExport = hasSyntacticModifier(node, 32 /* Export */); + const isDefault = hasSyntacticModifier(node, 2048 /* Default */); const modifiers = visitNodes2(node.modifiers, (node2) => isExportOrDefaultModifier(node2) || isDecorator(node2) ? void 0 : node2, isModifierLike); const location = moveRangePastModifiers(node); const classAlias = getClassAliasIfNeeded(node); @@ -96721,7 +96962,7 @@ function transformLegacyDecorators(context) { let members = visitNodes2(node.members, visitor, isClassElement); let decorationStatements = []; ({ members, decorationStatements } = transformDecoratorsOfClassElements(node, members)); - const assignClassAliasInStaticBlock = languageVersion >= 9 /* ES2022 */ && !!classAlias && some(members, (member) => isPropertyDeclaration(member) && hasSyntacticModifier(member, 32 /* Static */) || isClassStaticBlockDeclaration(member)); + const assignClassAliasInStaticBlock = languageVersion >= 9 /* ES2022 */ && !!classAlias && some(members, (member) => isPropertyDeclaration(member) && hasSyntacticModifier(member, 256 /* Static */) || isClassStaticBlockDeclaration(member)); if (assignClassAliasInStaticBlock) { members = setTextRange( factory2.createNodeArray([ @@ -96852,7 +97093,7 @@ function transformLegacyDecorators(context) { ); } function visitPropertyDeclaration(node) { - if (node.flags & 33554432 /* Ambient */ || hasSyntacticModifier(node, 2 /* Ambient */)) { + if (node.flags & 33554432 /* Ambient */ || hasSyntacticModifier(node, 128 /* Ambient */)) { return void 0; } return finishClassElement( @@ -96940,7 +97181,7 @@ function transformLegacyDecorators(context) { const memberName = getExpressionForPropertyName( member, /*generateNameForComputedPropertyName*/ - !hasSyntacticModifier(member, 2 /* Ambient */) + !hasSyntacticModifier(member, 128 /* Ambient */) ); const descriptor = languageVersion > 0 /* ES3 */ ? isPropertyDeclaration(member) && !hasAccessorModifier(member) ? factory2.createVoidZero() : factory2.createNull() : void 0; const helper = emitHelpers().createDecorateHelper( @@ -97723,8 +97964,8 @@ function transformESDecorators(context) { const statements = []; const originalClass = getOriginalNode(node, isClassLike) ?? node; const className = originalClass.name ? factory2.createStringLiteralFromNode(originalClass.name) : factory2.createStringLiteral("default"); - const isExport = hasSyntacticModifier(node, 1 /* Export */); - const isDefault = hasSyntacticModifier(node, 1024 /* Default */); + const isExport = hasSyntacticModifier(node, 32 /* Export */); + const isDefault = hasSyntacticModifier(node, 2048 /* Default */); if (!node.name) { node = injectClassNamedEvaluationHelperBlockIfMissing(context, node, className); } @@ -100035,7 +100276,7 @@ function transformES2018(context) { return visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { const savedExportedVariableStatement = exportedVariableStatement; exportedVariableStatement = true; const visited = visitEachChild(node, visitor, context); @@ -101247,7 +101488,7 @@ function transformESNext(context) { addRange(topLevelStatements, endLexicalEnvironment()); if (exportVars.length) { topLevelStatements.push(factory2.createVariableStatement( - factory2.createModifiersFromModifierFlags(1 /* Export */), + factory2.createModifiersFromModifierFlags(32 /* Export */), factory2.createVariableDeclarationList( exportVars, 1 /* Let */ @@ -101544,8 +101785,8 @@ function transformESNext(context) { if (!node.name && defaultExportBinding) { return node; } - const isExported2 = hasSyntacticModifier(node, 1 /* Export */); - const isDefault = hasSyntacticModifier(node, 1024 /* Default */); + const isExported2 = hasSyntacticModifier(node, 32 /* Export */); + const isDefault = hasSyntacticModifier(node, 2048 /* Default */); let expression = factory2.converters.convertToClassExpression(node); if (node.name) { hoistBindingIdentifier( @@ -101593,7 +101834,7 @@ function transformESNext(context) { } function hoistVariableStatement(node) { let expressions; - const isExported2 = hasSyntacticModifier(node, 1 /* Export */); + const isExported2 = hasSyntacticModifier(node, 32 /* Export */); for (const variable of node.declarationList.declarations) { hoistBindingElement(variable, isExported2, variable); if (variable.initializer) { @@ -102181,7 +102422,7 @@ function transformJsx(context) { } function transformJsxSpreadAttributeToProps(node) { if (isObjectLiteralExpression(node.expression) && !hasProto(node.expression)) { - return node.expression.properties; + return sameMap(node.expression.properties, (p) => Debug.checkDefined(visitNode(p, visitor, isObjectLiteralElementLike))); } return factory2.createSpreadAssignment(Debug.checkDefined(visitNode(node.expression, visitor, isExpression))); } @@ -102749,7 +102990,7 @@ function transformES2015(context) { hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 && node.kind === 253 /* ReturnStatement */ && !node.expression; + return (hierarchyFacts & 8192 /* ConstructorWithSuperCall */) !== 0 && node.kind === 253 /* ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { return node.transformFlags & 4194304 /* ContainsHoistedDeclarationOrCompletion */ && (isReturnStatement(node) || isIfStatement(node) || isWithStatement(node) || isSwitchStatement(node) || isCaseBlock(node) || isCaseClause(node) || isDefaultClause(node) || isTryStatement(node) || isCatchClause(node) || isLabeledStatement(node) || isIterationStatement( @@ -102759,7 +103000,7 @@ function transformES2015(context) { ) || isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node) || isIterationStatement( + return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /* ConstructorWithSuperCall */ && isOrMayContainReturnCompletion(node) || isIterationStatement( node, /*lookInLabeledStatements*/ false @@ -102792,7 +103033,7 @@ function transformES2015(context) { /*expressionResultIsUnused*/ false ); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); return result; } return visitorWorker( @@ -102806,6 +103047,7 @@ function transformES2015(context) { function callExpressionVisitor(node) { if (node.kind === 108 /* SuperKeyword */) { return visitSuperKeyword( + node, /*isExpressionOfCall*/ true ); @@ -102915,6 +103157,7 @@ function transformES2015(context) { return visitSpreadElement(node); case 108 /* SuperKeyword */: return visitSuperKeyword( + node, /*isExpressionOfCall*/ false ); @@ -102984,7 +103227,10 @@ function transformES2015(context) { return updated; } function returnCapturedThis(node) { - return setOriginalNode(factory2.createReturnStatement(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)), node); + return setOriginalNode(factory2.createReturnStatement(createCapturedThis()), node); + } + function createCapturedThis() { + return factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */); } function visitReturnStatement(node) { if (convertedLoopState) { @@ -103008,8 +103254,9 @@ function transformES2015(context) { return visitEachChild(node, visitor, context); } function visitThisKeyword(node) { + hierarchyFacts |= 65536 /* LexicalThis */; if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + hierarchyFacts |= 131072 /* CapturedLexicalThis */; } if (convertedLoopState) { if (hierarchyFacts & 2 /* ArrowFunction */) { @@ -103119,8 +103366,8 @@ function transformES2015(context) { setTextRange(statement, node); startOnNewLine(statement); statements.push(statement); - if (hasSyntacticModifier(node, 1 /* Export */)) { - const exportStatement = hasSyntacticModifier(node, 1024 /* Default */) ? factory2.createExportDefault(factory2.getLocalName(node)) : factory2.createExternalModuleExport(factory2.getLocalName(node)); + if (hasSyntacticModifier(node, 32 /* Export */)) { + const exportStatement = hasSyntacticModifier(node, 2048 /* Default */) ? factory2.createExportDefault(factory2.getLocalName(node)) : factory2.createExternalModuleExport(factory2.getLocalName(node)); setOriginalNode(exportStatement, statement); statements.push(exportStatement); } @@ -103148,7 +103395,7 @@ function transformES2015(context) { void 0, /*dotDotDotToken*/ void 0, - factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */) + createSyntheticSuper() )] : [], /*type*/ void 0, @@ -103238,7 +103485,7 @@ function transformES2015(context) { setEmitFlags(constructorFunction, 16 /* CapturesThis */); } statements.push(constructorFunction); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; } function transformConstructorParameters(constructor, hasSynthesizedSuper) { @@ -103262,103 +103509,35 @@ function transformES2015(context) { setEmitFlags(block, 3072 /* NoComments */); return block; } - function transformConstructorBodyWorker(prologueOut, statementsOut, statementsIn, statementOffset, superPath, superPathDepth, constructor, isDerivedClass, hasSynthesizedSuper, isFirstStatement) { - let mayReplaceThis = false; - const superStatementIndex = superPathDepth < superPath.length ? superPath[superPathDepth] : -1; - const leadingStatementsEnd = superStatementIndex >= 0 ? superStatementIndex : statementsIn.length; - if (isFirstStatement && superStatementIndex >= 0) { - let firstMaterialIndex = statementOffset; - while (isFirstStatement && firstMaterialIndex < superStatementIndex) { - const statement = constructor.body.statements[firstMaterialIndex]; - if (!isUninitializedVariableStatement(statement) && !isUsingDeclarationStateVariableStatement(statement)) - break; - firstMaterialIndex++; - } - isFirstStatement = superStatementIndex === firstMaterialIndex; - } - addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, statementOffset, leadingStatementsEnd - statementOffset)); - const superStatement = superStatementIndex >= 0 ? statementsIn[superStatementIndex] : void 0; - if (superStatement && isTryStatement(superStatement)) { - const tryBlockStatements = []; - mayReplaceThis = transformConstructorBodyWorker( - prologueOut, - tryBlockStatements, - superStatement.tryBlock.statements, - /*statementOffset*/ - 0, - superPath, - superPathDepth + 1, - constructor, - isDerivedClass, - hasSynthesizedSuper, - isFirstStatement - ); - const tryBlockStatementsArray = factory2.createNodeArray(tryBlockStatements); - setTextRange(tryBlockStatementsArray, superStatement.tryBlock.statements); - statementsOut.push(factory2.updateTryStatement( - superStatement, - factory2.updateBlock(superStatement.tryBlock, tryBlockStatements), - visitNode(superStatement.catchClause, visitor, isCatchClause), - visitNode(superStatement.finallyBlock, visitor, isBlock) - )); - } else { - const superCall = superStatement && getSuperCallFromStatement(superStatement); - let superCallExpression; - if (hasSynthesizedSuper) { - superCallExpression = createDefaultSuperCallOrThis(); - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; - } else if (superCall) { - superCallExpression = visitSuperCallInBody(superCall); - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; - } - if (isDerivedClass || superCallExpression) { - if (superCallExpression && superStatementIndex === statementsIn.length - 1 && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) { - const superCall2 = cast(cast(superCallExpression, isBinaryExpression).left, isCallExpression); - const returnStatement = factory2.createReturnStatement(superCallExpression); - setCommentRange(returnStatement, getCommentRange(superCall2)); - setEmitFlags(superCall2, 3072 /* NoComments */); - statementsOut.push(returnStatement); - return false; - } else { - if (isFirstStatement) { - insertCaptureThisForNode(statementsOut, constructor, superCallExpression || createActualThis()); - } else { - insertCaptureThisForNode(prologueOut, constructor, createActualThis()); - if (superCallExpression) { - addSuperThisCaptureThisForNode(statementsOut, superCallExpression); - } - } - mayReplaceThis = true; - } - } else { - insertCaptureThisForNodeIfNeeded(prologueOut, constructor); - } - } - if (superStatementIndex >= 0) { - addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, superStatementIndex + 1)); - } - return mayReplaceThis; - } function isUninitializedVariableStatement(node) { return isVariableStatement(node) && every(node.declarationList.declarations, (decl) => isIdentifier(decl.name) && !decl.initializer); } - function isUsingDeclarationStateVariableStatement(node) { - if (!isVariableStatement(node) || node.declarationList.declarations.length !== 1) - return false; - const varDecl = node.declarationList.declarations[0]; - if (!isIdentifier(varDecl.name) || !varDecl.initializer) - return false; - const initializer = varDecl.initializer; - if (!isObjectLiteralExpression(initializer) || initializer.properties.length !== 3) - return false; - const [stackProp, errorProp, hasErrorProp] = initializer.properties; - if (!isPropertyAssignment(stackProp) || !isIdentifier(stackProp.name) || idText(stackProp.name) !== "stack" || !isArrayLiteralExpression(stackProp.initializer)) - return false; - if (!isPropertyAssignment(errorProp) || !isIdentifier(errorProp.name) || idText(errorProp.name) !== "error" || !isVoidExpression(errorProp.initializer) || !isNumericLiteral(errorProp.initializer.expression)) - return false; - if (!isPropertyAssignment(hasErrorProp) || !isIdentifier(hasErrorProp.name) || idText(hasErrorProp.name) !== "hasError" || hasErrorProp.initializer.kind !== 97 /* FalseKeyword */) + function containsSuperCall(node) { + if (isSuperCall(node)) { + return true; + } + if (!(node.transformFlags & 134217728 /* ContainsLexicalSuper */)) { return false; - return true; + } + switch (node.kind) { + case 219 /* ArrowFunction */: + case 218 /* FunctionExpression */: + case 262 /* FunctionDeclaration */: + case 176 /* Constructor */: + case 175 /* ClassStaticBlockDeclaration */: + return false; + case 177 /* GetAccessor */: + case 178 /* SetAccessor */: + case 174 /* MethodDeclaration */: + case 172 /* PropertyDeclaration */: { + const named = node; + if (isComputedPropertyName(named.name)) { + return !!forEachChild(named.name, containsSuperCall); + } + return false; + } + } + return !!forEachChild(node, containsSuperCall); } function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { const isDerivedClass = !!extendsClauseElement && skipOuterExpressions(extendsClauseElement.expression).kind !== 106 /* NullKeyword */; @@ -103373,31 +103552,22 @@ function transformES2015(context) { /*statementOffset*/ 0 ); - const superStatementIndices = findSuperStatementIndexPath(constructor.body.statements, standardPrologueEnd); - if (hasSynthesizedSuper || superStatementIndices.length > 0) { - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; + if (hasSynthesizedSuper || containsSuperCall(constructor.body)) { + hierarchyFacts |= 8192 /* ConstructorWithSuperCall */; } - const mayReplaceThis = transformConstructorBodyWorker( - prologue, - statements, - constructor.body.statements, - standardPrologueEnd, - superStatementIndices, - /*superPathDepth*/ - 0, - constructor, - isDerivedClass, - hasSynthesizedSuper, - /*isFirstStatement*/ - true - // NOTE: this will be recalculated inside of transformConstructorBodyWorker - ); + addRange(statements, visitNodes2(constructor.body.statements, visitor, isStatement, standardPrologueEnd)); + const mayReplaceThis = isDerivedClass || hierarchyFacts & 8192 /* ConstructorWithSuperCall */; addDefaultValueAssignmentsIfNeeded2(prologue, constructor); addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper); insertCaptureNewTargetIfNeeded(prologue, constructor); + if (mayReplaceThis) { + insertCaptureThisForNode(prologue, constructor, createActualThis()); + } else { + insertCaptureThisForNodeIfNeeded(prologue, constructor); + } factory2.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); if (mayReplaceThis && !isSufficientlyCoveredByReturnStatements(constructor.body)) { - statements.push(factory2.createReturnStatement(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */))); + statements.push(factory2.createReturnStatement(createCapturedThis())); } const body = factory2.createBlock( setTextRange( @@ -103414,6 +103584,230 @@ function transformES2015(context) { true ); setTextRange(body, constructor.body); + return simplifyConstructor(body, constructor.body, hasSynthesizedSuper); + } + function isCapturedThis(node) { + return isGeneratedIdentifier(node) && idText(node) === "_this"; + } + function isSyntheticSuper(node) { + return isGeneratedIdentifier(node) && idText(node) === "_super"; + } + function isThisCapturingVariableStatement(node) { + return isVariableStatement(node) && node.declarationList.declarations.length === 1 && isThisCapturingVariableDeclaration(node.declarationList.declarations[0]); + } + function isThisCapturingVariableDeclaration(node) { + return isVariableDeclaration(node) && isCapturedThis(node.name) && !!node.initializer; + } + function isThisCapturingAssignment(node) { + return isAssignmentExpression( + node, + /*excludeCompoundAssignment*/ + true + ) && isCapturedThis(node.left); + } + function isTransformedSuperCall(node) { + return isCallExpression(node) && isPropertyAccessExpression(node.expression) && isSyntheticSuper(node.expression.expression) && isIdentifier(node.expression.name) && (idText(node.expression.name) === "call" || idText(node.expression.name) === "apply") && node.arguments.length >= 1 && node.arguments[0].kind === 110 /* ThisKeyword */; + } + function isTransformedSuperCallWithFallback(node) { + return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isTransformedSuperCall(node.left); + } + function isImplicitSuperCall(node) { + return isBinaryExpression(node) && node.operatorToken.kind === 56 /* AmpersandAmpersandToken */ && isBinaryExpression(node.left) && node.left.operatorToken.kind === 38 /* ExclamationEqualsEqualsToken */ && isSyntheticSuper(node.left.left) && node.left.right.kind === 106 /* NullKeyword */ && isTransformedSuperCall(node.right) && idText(node.right.expression.name) === "apply"; + } + function isImplicitSuperCallWithFallback(node) { + return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isImplicitSuperCall(node.left); + } + function isThisCapturingTransformedSuperCallWithFallback(node) { + return isThisCapturingAssignment(node) && isTransformedSuperCallWithFallback(node.right); + } + function isThisCapturingImplicitSuperCallWithFallback(node) { + return isThisCapturingAssignment(node) && isImplicitSuperCallWithFallback(node.right); + } + function isTransformedSuperCallLike(node) { + return isTransformedSuperCall(node) || isTransformedSuperCallWithFallback(node) || isThisCapturingTransformedSuperCallWithFallback(node) || isImplicitSuperCall(node) || isImplicitSuperCallWithFallback(node) || isThisCapturingImplicitSuperCallWithFallback(node); + } + function simplifyConstructorInlineSuperInThisCaptureVariable(body) { + for (let i = 0; i < body.statements.length - 1; i++) { + const statement = body.statements[i]; + if (!isThisCapturingVariableStatement(statement)) { + continue; + } + const varDecl = statement.declarationList.declarations[0]; + if (varDecl.initializer.kind !== 110 /* ThisKeyword */) { + continue; + } + const thisCaptureStatementIndex = i; + let superCallIndex = i + 1; + while (superCallIndex < body.statements.length) { + const statement2 = body.statements[superCallIndex]; + if (isExpressionStatement(statement2)) { + if (isTransformedSuperCallLike(skipOuterExpressions(statement2.expression))) { + break; + } + } + if (isUninitializedVariableStatement(statement2)) { + superCallIndex++; + continue; + } + return body; + } + const following = body.statements[superCallIndex]; + let expression = following.expression; + if (isThisCapturingAssignment(expression)) { + expression = expression.right; + } + const newVarDecl = factory2.updateVariableDeclaration( + varDecl, + varDecl.name, + /*exclamationToken*/ + void 0, + /*type*/ + void 0, + expression + ); + const newDeclList = factory2.updateVariableDeclarationList(statement.declarationList, [newVarDecl]); + const newVarStatement = factory2.createVariableStatement(statement.modifiers, newDeclList); + setOriginalNode(newVarStatement, following); + setTextRange(newVarStatement, following); + const newStatements = factory2.createNodeArray([ + ...body.statements.slice(0, thisCaptureStatementIndex), + // copy statements preceding to `var _this` + ...body.statements.slice(thisCaptureStatementIndex + 1, superCallIndex), + // copy intervening temp variables + newVarStatement, + ...body.statements.slice(superCallIndex + 1) + // copy statements following `super.call(this, ...)` + ]); + setTextRange(newStatements, body.statements); + return factory2.updateBlock(body, newStatements); + } + return body; + } + function simplifyConstructorInlineSuperReturn(body, original) { + for (const statement of original.statements) { + if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) { + return body; + } + } + const canElideThisCapturingVariable = !(original.transformFlags & 16384 /* ContainsLexicalThis */) && !(hierarchyFacts & 65536 /* LexicalThis */) && !(hierarchyFacts & 131072 /* CapturedLexicalThis */); + for (let i = body.statements.length - 1; i > 0; i--) { + const statement = body.statements[i]; + if (isReturnStatement(statement) && statement.expression && isCapturedThis(statement.expression)) { + const preceding = body.statements[i - 1]; + let expression; + if (isExpressionStatement(preceding) && isThisCapturingTransformedSuperCallWithFallback(skipOuterExpressions(preceding.expression))) { + expression = preceding.expression; + } else if (canElideThisCapturingVariable && isThisCapturingVariableStatement(preceding)) { + const varDecl = preceding.declarationList.declarations[0]; + if (isTransformedSuperCallLike(skipOuterExpressions(varDecl.initializer))) { + expression = factory2.createAssignment( + createCapturedThis(), + varDecl.initializer + ); + } + } + if (!expression) { + break; + } + const newReturnStatement = factory2.createReturnStatement(expression); + setOriginalNode(newReturnStatement, preceding); + setTextRange(newReturnStatement, preceding); + const newStatements = factory2.createNodeArray([ + ...body.statements.slice(0, i - 1), + // copy all statements preceding `_super.call(this, ...)` + newReturnStatement, + ...body.statements.slice(i + 1) + // copy all statements following `return _this;` + ]); + setTextRange(newStatements, body.statements); + return factory2.updateBlock(body, newStatements); + } + } + return body; + } + function elideUnusedThisCaptureWorker(node) { + if (isThisCapturingVariableStatement(node)) { + const varDecl = node.declarationList.declarations[0]; + if (varDecl.initializer.kind === 110 /* ThisKeyword */) { + return void 0; + } + } else if (isThisCapturingAssignment(node)) { + return factory2.createPartiallyEmittedExpression(node.right, node); + } + switch (node.kind) { + case 219 /* ArrowFunction */: + case 218 /* FunctionExpression */: + case 262 /* FunctionDeclaration */: + case 176 /* Constructor */: + case 175 /* ClassStaticBlockDeclaration */: + return node; + case 177 /* GetAccessor */: + case 178 /* SetAccessor */: + case 174 /* MethodDeclaration */: + case 172 /* PropertyDeclaration */: { + const named = node; + if (isComputedPropertyName(named.name)) { + return factory2.replacePropertyName(named, visitEachChild(named.name, elideUnusedThisCaptureWorker, nullTransformationContext)); + } + return node; + } + } + return visitEachChild(node, elideUnusedThisCaptureWorker, nullTransformationContext); + } + function simplifyConstructorElideUnusedThisCapture(body, original) { + if (original.transformFlags & 16384 /* ContainsLexicalThis */ || hierarchyFacts & 65536 /* LexicalThis */ || hierarchyFacts & 131072 /* CapturedLexicalThis */) { + return body; + } + for (const statement of original.statements) { + if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) { + return body; + } + } + return factory2.updateBlock(body, visitNodes2(body.statements, elideUnusedThisCaptureWorker, isStatement)); + } + function injectSuperPresenceCheckWorker(node) { + if (isTransformedSuperCall(node) && node.arguments.length === 2 && isIdentifier(node.arguments[1]) && idText(node.arguments[1]) === "arguments") { + return factory2.createLogicalAnd( + factory2.createStrictInequality( + createSyntheticSuper(), + factory2.createNull() + ), + node + ); + } + switch (node.kind) { + case 219 /* ArrowFunction */: + case 218 /* FunctionExpression */: + case 262 /* FunctionDeclaration */: + case 176 /* Constructor */: + case 175 /* ClassStaticBlockDeclaration */: + return node; + case 177 /* GetAccessor */: + case 178 /* SetAccessor */: + case 174 /* MethodDeclaration */: + case 172 /* PropertyDeclaration */: { + const named = node; + if (isComputedPropertyName(named.name)) { + return factory2.replacePropertyName(named, visitEachChild(named.name, injectSuperPresenceCheckWorker, nullTransformationContext)); + } + return node; + } + } + return visitEachChild(node, injectSuperPresenceCheckWorker, nullTransformationContext); + } + function complicateConstructorInjectSuperPresenceCheck(body) { + return factory2.updateBlock(body, visitNodes2(body.statements, injectSuperPresenceCheckWorker, isStatement)); + } + function simplifyConstructor(body, original, hasSynthesizedSuper) { + const inputBody = body; + body = simplifyConstructorInlineSuperInThisCaptureVariable(body); + body = simplifyConstructorInlineSuperReturn(body, original); + if (body !== inputBody) { + body = simplifyConstructorElideUnusedThisCapture(body, original); + } + if (hasSynthesizedSuper) { + body = complicateConstructorInjectSuperPresenceCheck(body); + } return body; } function isSufficientlyCoveredByReturnStatements(statement) { @@ -103439,11 +103833,11 @@ function transformES2015(context) { return factory2.createLogicalOr( factory2.createLogicalAnd( factory2.createStrictInequality( - factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), + createSyntheticSuper(), factory2.createNull() ), factory2.createFunctionApplyCall( - factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), + createSyntheticSuper(), createActualThis(), factory2.createIdentifier("arguments") ) @@ -103698,24 +104092,12 @@ function transformES2015(context) { return true; } function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 219 /* ArrowFunction */) { + if (hierarchyFacts & 131072 /* CapturedLexicalThis */ && node.kind !== 219 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, factory2.createThis()); return true; } return false; } - function addSuperThisCaptureThisForNode(statements, superExpression) { - enableSubstitutionsForCapturedThis(); - const assignSuperExpression = factory2.createExpressionStatement( - factory2.createBinaryExpression( - factory2.createThis(), - 64 /* EqualsToken */, - superExpression - ) - ); - statements.push(assignSuperExpression); - setCommentRange(assignSuperExpression, getOriginalNode(superExpression).parent); - } function insertCaptureThisForNode(statements, node, initializer) { enableSubstitutionsForCapturedThis(); const captureThisStatement = factory2.createVariableStatement( @@ -103723,7 +104105,7 @@ function transformES2015(context) { void 0, factory2.createVariableDeclarationList([ factory2.createVariableDeclaration( - factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), + createCapturedThis(), /*exclamationToken*/ void 0, /*type*/ @@ -103944,7 +104326,7 @@ function transformES2015(context) { } function visitArrowFunction(node) { if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + hierarchyFacts |= 131072 /* CapturedLexicalThis */; } const savedConvertedLoopState = convertedLoopState; convertedLoopState = void 0; @@ -103977,7 +104359,7 @@ function transformES2015(context) { const parameters = visitParameterList(node.parameters, visitor, context); const body = transformFunctionBody2(node); const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return factory2.updateFunctionExpression( node, @@ -104000,7 +104382,7 @@ function transformES2015(context) { const parameters = visitParameterList(node.parameters, visitor, context); const body = transformFunctionBody2(node); const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return factory2.updateFunctionDeclaration( node, @@ -104024,7 +104406,7 @@ function transformES2015(context) { if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 262 /* FunctionDeclaration */ || node.kind === 218 /* FunctionExpression */)) { name = factory2.getGeneratedNameForNode(node); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return setOriginalNode( setTextRange( @@ -104177,7 +104559,7 @@ function transformES2015(context) { return node.declarationList.declarations.length === 1 && !!node.declarationList.declarations[0].initializer && !!(getInternalEmitFlags(node.declarationList.declarations[0].initializer) & 1 /* TypeScriptClassWrapper */); } function visitVariableStatement(node) { - const ancestorFacts = enterSubtree(0 /* None */, hasSyntacticModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + const ancestorFacts = enterSubtree(0 /* None */, hasSyntacticModifier(node, 32 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); let updated; if (convertedLoopState && (node.declarationList.flags & 7 /* BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { let assignments; @@ -105433,7 +105815,7 @@ function transformES2015(context) { } else { updated = factory2.updateSetAccessorDeclaration(node, node.modifiers, node.name, parameters, body); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return updated; } @@ -105583,13 +105965,6 @@ function transformES2015(context) { ) ); } - function visitSuperCallInBody(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment( - node, - /*assignToCapturedThis*/ - false - ); - } function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { if (node.transformFlags & 32768 /* ContainsRestOrSpread */ || node.expression.kind === 108 /* SuperKeyword */ || isSuperProperty(skipOuterExpressions(node.expression))) { const { target, thisArg } = factory2.createCallBinding(node.expression, hoistVariableDeclaration); @@ -105626,10 +106001,13 @@ function transformES2015(context) { resultingCall, createActualThis() ); - resultingCall = assignToCapturedThis ? factory2.createAssignment(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) : initializer; + resultingCall = assignToCapturedThis ? factory2.createAssignment(createCapturedThis(), initializer) : initializer; } return setOriginalNode(resultingCall, node); } + if (isSuperCall(node)) { + hierarchyFacts |= 131072 /* CapturedLexicalThis */; + } return visitEachChild(node, visitor, context); } function visitNewExpression(node) { @@ -105756,8 +106134,15 @@ function transformES2015(context) { } return setTextRange(expression, node); } - function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? factory2.createPropertyAccessExpression(factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), "prototype") : factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); + function createSyntheticSuper() { + return factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); + } + function visitSuperKeyword(node, isExpressionOfCall) { + const expression = hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? factory2.createPropertyAccessExpression(setOriginalNode(createSyntheticSuper(), node), "prototype") : createSyntheticSuper(); + setOriginalNode(expression, node); + setCommentRange(expression, node); + setSourceMapRange(expression, node); + return expression; } function visitMetaProperty(node) { if (node.keywordToken === 105 /* NewKeyword */ && node.name.escapedText === "target") { @@ -105863,7 +106248,7 @@ function transformES2015(context) { } function substituteThisKeyword(node) { if (enabledSubstitutions & 1 /* CapturedThis */ && hierarchyFacts & 16 /* CapturesThis */) { - return setTextRange(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), node); + return setTextRange(createCapturedThis(), node); } return node; } @@ -109123,7 +109508,7 @@ function transformModule(context) { Debug.assert(isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); let statements; if (moduleKind !== 2 /* AMD */) { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { statements = append( statements, setOriginalNode( @@ -109169,7 +109554,7 @@ function transformModule(context) { ); } } else { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { statements = append( statements, setOriginalNode( @@ -109307,7 +109692,7 @@ function transformModule(context) { } function visitFunctionDeclaration(node) { let statements; - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { statements = append( statements, setOriginalNode( @@ -109344,7 +109729,7 @@ function transformModule(context) { } function visitClassDeclaration(node) { let statements; - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { statements = append( statements, setOriginalNode( @@ -109378,7 +109763,7 @@ function transformModule(context) { let statements; let variables; let expressions; - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { let modifiers; let removeCommentsOnExpressions = false; for (const variable of node.declarationList.declarations) { @@ -109564,8 +109949,8 @@ function transformModule(context) { return statements; } const seen = new IdentifierNameMap(); - if (hasSyntacticModifier(decl, 1 /* Export */)) { - const exportName = hasSyntacticModifier(decl, 1024 /* Default */) ? factory2.createIdentifier("default") : factory2.getDeclarationName(decl); + if (hasSyntacticModifier(decl, 32 /* Export */)) { + const exportName = hasSyntacticModifier(decl, 2048 /* Default */) ? factory2.createIdentifier("default") : factory2.getDeclarationName(decl); statements = appendExportStatement( statements, seen, @@ -110052,7 +110437,7 @@ function transformSystemModule(context) { addRange(statements, hoistedStatements); insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); const exportStarFunction = addExportStarIfNeeded(statements); - const modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ? factory2.createModifiersFromModifierFlags(512 /* Async */) : void 0; + const modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ? factory2.createModifiersFromModifierFlags(1024 /* Async */) : void 0; const moduleObject = factory2.createObjectLiteralExpression( [ factory2.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), @@ -110254,7 +110639,7 @@ function transformSystemModule(context) { factory2.createAssignment(importVariableName, parameterName) ) ); - if (hasSyntacticModifier(entry, 1 /* Export */)) { + if (hasSyntacticModifier(entry, 32 /* Export */)) { statements.push( factory2.createExpressionStatement( factory2.createCallExpression( @@ -110407,7 +110792,7 @@ function transformSystemModule(context) { ); } function visitFunctionDeclaration(node) { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { hoistedStatements = append( hoistedStatements, factory2.updateFunctionDeclaration( @@ -110494,7 +110879,7 @@ function transformSystemModule(context) { statements = append(statements, factory2.updateVariableStatement(node, modifiers, declarationList)); } else { let expressions; - const isExportedDeclaration = hasSyntacticModifier(node, 1 /* Export */); + const isExportedDeclaration = hasSyntacticModifier(node, 32 /* Export */); for (const variable of node.declarationList.declarations) { if (variable.initializer) { expressions = append(expressions, transformInitializedVariable(variable, isExportedDeclaration)); @@ -110630,8 +111015,8 @@ function transformSystemModule(context) { return statements; } let excludeName; - if (hasSyntacticModifier(decl, 1 /* Export */)) { - const exportName = hasSyntacticModifier(decl, 1024 /* Default */) ? factory2.createStringLiteral("default") : decl.name; + if (hasSyntacticModifier(decl, 32 /* Export */)) { + const exportName = hasSyntacticModifier(decl, 2048 /* Default */) ? factory2.createStringLiteral("default") : decl.name; statements = appendExportStatement(statements, exportName, factory2.getLocalName(decl)); excludeName = getTextOfIdentifierOrLiteral(exportName); } @@ -111376,7 +111761,7 @@ function transformECMAScriptModule(context) { return singleOrMany(statements); } function appendExportsOfImportEqualsDeclaration(statements, node) { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { statements = append( statements, factory2.createExportDeclaration( @@ -111586,7 +111971,7 @@ function createGetSymbolAccessibilityDiagnosticForNode(node) { } else if (isConstructSignatureDeclaration(node) || isCallSignatureDeclaration(node) || isMethodDeclaration(node) || isMethodSignature(node) || isFunctionDeclaration(node) || isIndexSignatureDeclaration(node)) { return getReturnTypeVisibilityError; } else if (isParameter(node)) { - if (isParameterPropertyDeclaration(node, node.parent) && hasSyntacticModifier(node.parent, 8 /* Private */)) { + if (isParameterPropertyDeclaration(node, node.parent) && hasSyntacticModifier(node.parent, 2 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -111604,7 +111989,7 @@ function createGetSymbolAccessibilityDiagnosticForNode(node) { function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (node.kind === 260 /* VariableDeclaration */ || node.kind === 208 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; - } else if (node.kind === 172 /* PropertyDeclaration */ || node.kind === 211 /* PropertyAccessExpression */ || node.kind === 212 /* ElementAccessExpression */ || node.kind === 226 /* BinaryExpression */ || node.kind === 171 /* PropertySignature */ || node.kind === 169 /* Parameter */ && hasSyntacticModifier(node.parent, 8 /* Private */)) { + } else if (node.kind === 172 /* PropertyDeclaration */ || node.kind === 211 /* PropertyAccessExpression */ || node.kind === 212 /* ElementAccessExpression */ || node.kind === 226 /* BinaryExpression */ || node.kind === 171 /* PropertySignature */ || node.kind === 169 /* Parameter */ && hasSyntacticModifier(node.parent, 2 /* Private */)) { if (isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } else if (node.parent.kind === 263 /* ClassDeclaration */ || node.kind === 169 /* Parameter */) { @@ -111902,6 +112287,17 @@ function transformDeclarations(context) { const container = getSourceFileOfNode(node); refs.set(getOriginalNodeId(container), container); } + function trackReferencedAmbientModuleFromImport(node) { + const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(node); + const symbol = moduleSpecifier && resolver.tryFindAmbientModule(moduleSpecifier); + if (symbol == null ? void 0 : symbol.declarations) { + for (const decl of symbol.declarations) { + if (isAmbientModule(decl) && getSourceFileOfNode(decl) !== currentSourceFile) { + trackReferencedAmbientModule(decl, symbol); + } + } + } + } function handleSymbolAccessibilityError(symbolAccessibilityResult) { if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) { if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { @@ -112314,7 +112710,7 @@ function transformDeclarations(context) { return void 0; } function ensureType(node, type, ignorePrivate) { - if (!ignorePrivate && hasEffectiveModifier(node, 8 /* Private */)) { + if (!ignorePrivate && hasEffectiveModifier(node, 2 /* Private */)) { return; } if (shouldPrintWithInitializer(node)) { @@ -112394,7 +112790,7 @@ function transformDeclarations(context) { } } function updateParamsList(node, params, modifierMask) { - if (hasEffectiveModifier(node, 8 /* Private */)) { + if (hasEffectiveModifier(node, 2 /* Private */)) { return factory2.createNodeArray(); } const newParams = map(params, (p) => ensureParameter(p, modifierMask)); @@ -112439,7 +112835,7 @@ function transformDeclarations(context) { return factory2.createNodeArray(newParams || emptyArray); } function ensureTypeParams(node, params) { - return hasEffectiveModifier(node, 8 /* Private */) ? void 0 : visitNodes2(params, visitDeclarationSubtree, isTypeParameterDeclaration); + return hasEffectiveModifier(node, 2 /* Private */) ? void 0 : visitNodes2(params, visitDeclarationSubtree, isTypeParameterDeclaration); } function isEnclosingDeclaration(node) { return isSourceFile(node) || isTypeAliasDeclaration(node) || isModuleDeclaration(node) || isClassDeclaration(node) || isInterfaceDeclaration(node) || isFunctionLike(node) || isIndexSignatureDeclaration(node) || isMappedTypeNode(node); @@ -112625,7 +113021,7 @@ function transformDeclarations(context) { const oldWithinObjectLiteralType = suppressNewDiagnosticContexts; let shouldEnterSuppressNewDiagnosticsContextContext = (input.kind === 187 /* TypeLiteral */ || input.kind === 200 /* MappedType */) && input.parent.kind !== 265 /* TypeAliasDeclaration */; if (isMethodDeclaration(input) || isMethodSignature(input)) { - if (hasEffectiveModifier(input, 8 /* Private */)) { + if (hasEffectiveModifier(input, 2 /* Private */)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; return cleanup(factory2.createPropertyDeclaration( @@ -112713,7 +113109,7 @@ function transformDeclarations(context) { input, ensureModifiers(input), input.name, - updateAccessorParamsList(input, hasEffectiveModifier(input, 8 /* Private */)), + updateAccessorParamsList(input, hasEffectiveModifier(input, 2 /* Private */)), ensureType(input, accessorType), /*body*/ void 0 @@ -112730,7 +113126,7 @@ function transformDeclarations(context) { input, ensureModifiers(input), input.name, - updateAccessorParamsList(input, hasEffectiveModifier(input, 8 /* Private */)), + updateAccessorParamsList(input, hasEffectiveModifier(input, 2 /* Private */)), /*body*/ void 0 )); @@ -112849,6 +113245,7 @@ function transformDeclarations(context) { case 205 /* ImportType */: { if (!isLiteralImportTypeNode(input)) return cleanup(input); + trackReferencedAmbientModuleFromImport(input); return cleanup(factory2.updateImportTypeNode( input, factory2.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), @@ -112886,7 +113283,7 @@ function transformDeclarations(context) { } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 174 /* MethodDeclaration */ && hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 174 /* MethodDeclaration */ && hasEffectiveModifier(node.parent, 2 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -112900,6 +113297,7 @@ function transformDeclarations(context) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; + trackReferencedAmbientModuleFromImport(input); return factory2.updateExportDeclaration( input, input.modifiers, @@ -112944,11 +113342,11 @@ function transformDeclarations(context) { return input; } function stripExportModifiers(statement) { - if (isImportEqualsDeclaration(statement) || hasEffectiveModifier(statement, 1024 /* Default */) || !canHaveModifiers(statement)) { + if (isImportEqualsDeclaration(statement) || hasEffectiveModifier(statement, 2048 /* Default */) || !canHaveModifiers(statement)) { return statement; } - const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (258047 /* All */ ^ 1 /* Export */)); - return factory2.updateModifiers(statement, modifiers); + const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (131071 /* All */ ^ 32 /* Export */)); + return factory2.replaceModifiers(statement, modifiers); } function updateModuleDeclarationAndKeyword(node, modifiers, name, body) { const updated = factory2.updateModuleDeclaration(node, modifiers, name, body); @@ -112974,10 +113372,18 @@ function transformDeclarations(context) { return; switch (input.kind) { case 271 /* ImportEqualsDeclaration */: { - return transformImportEqualsDeclaration(input); + const transformed = transformImportEqualsDeclaration(input); + if (transformed) { + trackReferencedAmbientModuleFromImport(input); + } + return transformed; } case 272 /* ImportDeclaration */: { - return transformImportDeclaration(input); + const transformed = transformImportDeclaration(input); + if (transformed) { + trackReferencedAmbientModuleFromImport(input); + } + return transformed; } } if (isDeclaration(input) && isDeclarationAndNotVisible(input)) @@ -113071,7 +113477,7 @@ function transformDeclarations(context) { return factory2.createVariableStatement(isNonContextualKeywordName ? void 0 : [factory2.createToken(95 /* ExportKeyword */)], factory2.createVariableDeclarationList([varDecl])); }); if (!exportMappings.length) { - declarations = mapDefined(declarations, (declaration) => factory2.updateModifiers(declaration, 0 /* None */)); + declarations = mapDefined(declarations, (declaration) => factory2.replaceModifiers(declaration, 0 /* None */)); } else { declarations.push(factory2.createExportDeclaration( /*modifiers*/ @@ -113089,10 +113495,10 @@ function transformDeclarations(context) { )); } const namespaceDecl = factory2.createModuleDeclaration(ensureModifiers(input), input.name, factory2.createModuleBlock(declarations), 32 /* Namespace */); - if (!hasEffectiveModifier(clean2, 1024 /* Default */)) { + if (!hasEffectiveModifier(clean2, 2048 /* Default */)) { return [clean2, namespaceDecl]; } - const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(clean2) & ~1025 /* ExportDefault */ | 2 /* Ambient */); + const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(clean2) & ~2080 /* ExportDefault */ | 128 /* Ambient */); const cleanDeclaration = factory2.updateFunctionDeclaration( clean2, modifiers, @@ -113184,7 +113590,7 @@ function transformDeclarations(context) { if (ctor) { const oldDiag2 = getSymbolAccessibilityDiagnostic; parameterProperties = compact(flatMap(ctor.parameters, (param) => { - if (!hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!hasSyntacticModifier(param, 31 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(param); if (param.name.kind === 80 /* Identifier */) { @@ -113413,11 +113819,11 @@ function transformDeclarations(context) { return factory2.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - let mask2 = 258047 /* All */ ^ (4 /* Public */ | 512 /* Async */ | 16384 /* Override */); - let additions = needsDeclare && !isAlwaysType(node) ? 2 /* Ambient */ : 0 /* None */; + let mask2 = 131071 /* All */ ^ (1 /* Public */ | 1024 /* Async */ | 16 /* Override */); + let additions = needsDeclare && !isAlwaysType(node) ? 128 /* Ambient */ : 0 /* None */; const parentIsFile = node.parent.kind === 312 /* SourceFile */; if (!parentIsFile || isBundledEmit && parentIsFile && isExternalModule(node.parent)) { - mask2 ^= 2 /* Ambient */; + mask2 ^= 128 /* Ambient */; additions = 0 /* None */; } return maskModifierFlags(node, mask2, additions); @@ -113459,13 +113865,13 @@ function isAlwaysType(node) { function maskModifiers(factory2, node, modifierMask, modifierAdditions) { return factory2.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } -function maskModifierFlags(node, modifierMask = 258047 /* All */ ^ 4 /* Public */, modifierAdditions = 0 /* None */) { +function maskModifierFlags(node, modifierMask = 131071 /* All */ ^ 1 /* Public */, modifierAdditions = 0 /* None */) { let flags = getEffectiveModifierFlags(node) & modifierMask | modifierAdditions; - if (flags & 1024 /* Default */ && !(flags & 1 /* Export */)) { - flags ^= 1 /* Export */; + if (flags & 2048 /* Default */ && !(flags & 32 /* Export */)) { + flags ^= 32 /* Export */; } - if (flags & 1024 /* Default */ && flags & 2 /* Ambient */) { - flags ^= 2 /* Ambient */; + if (flags & 2048 /* Default */ && flags & 128 /* Ambient */) { + flags ^= 128 /* Ambient */; } return flags; } @@ -113478,7 +113884,7 @@ function canHaveLiteralInitializer(node) { switch (node.kind) { case 172 /* PropertyDeclaration */: case 171 /* PropertySignature */: - return !hasEffectiveModifier(node, 8 /* Private */); + return !hasEffectiveModifier(node, 2 /* Private */); case 169 /* Parameter */: case 260 /* VariableDeclaration */: return true; @@ -114591,7 +114997,8 @@ var notImplementedResolver = { getSymbolOfExternalModuleSpecifier: notImplemented, isBindingCapturedByNode: notImplemented, getDeclarationStatementsForSourceFile: notImplemented, - isImportRequiredByAugmentation: notImplemented + isImportRequiredByAugmentation: notImplemented, + tryFindAmbientModule: notImplemented }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var _a; @@ -119666,12 +120073,12 @@ function createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensi cachedReadDirectoryResult.clear(); } } -var ConfigFileProgramReloadLevel = /* @__PURE__ */ ((ConfigFileProgramReloadLevel2) => { - ConfigFileProgramReloadLevel2[ConfigFileProgramReloadLevel2["None"] = 0] = "None"; - ConfigFileProgramReloadLevel2[ConfigFileProgramReloadLevel2["Partial"] = 1] = "Partial"; - ConfigFileProgramReloadLevel2[ConfigFileProgramReloadLevel2["Full"] = 2] = "Full"; - return ConfigFileProgramReloadLevel2; -})(ConfigFileProgramReloadLevel || {}); +var ProgramUpdateLevel = /* @__PURE__ */ ((ProgramUpdateLevel2) => { + ProgramUpdateLevel2[ProgramUpdateLevel2["Update"] = 0] = "Update"; + ProgramUpdateLevel2[ProgramUpdateLevel2["RootNamesAndUpdate"] = 1] = "RootNamesAndUpdate"; + ProgramUpdateLevel2[ProgramUpdateLevel2["Full"] = 2] = "Full"; + return ProgramUpdateLevel2; +})(ProgramUpdateLevel || {}); function updateSharedExtendedConfigFileWatcher(projectPath, options, extendedConfigFilesMap, createExtendedConfigFileWatch, toPath3) { var _a; const extendedConfigs = arrayToMap(((_a = options == null ? void 0 : options.configFile) == null ? void 0 : _a.extendedSourceFiles) || emptyArray, toPath3); @@ -122301,7 +122708,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config } } } else if (isModuleDeclaration(node)) { - if (isAmbientModule(node) && (inAmbientModule || hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) { + if (isAmbientModule(node) && (inAmbientModule || hasSyntacticModifier(node, 128 /* Ambient */) || file.isDeclarationFile)) { node.name.parent = node; const nameText = getTextOfIdentifierOrLiteral(node.name); if (isExternalModuleFile || inAmbientModule && !isExternalModuleNameRelative(nameText)) { @@ -125882,6 +126289,10 @@ function getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirec function getRootPathSplitLength(rootPath) { return rootPath.split(directorySeparator).length - (hasTrailingDirectorySeparator(rootPath) ? 1 : 0); } +function getModuleResolutionHost(resolutionHost) { + var _a; + return ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost; +} function createModuleResolutionLoaderUsingGlobalCache(containingFile, redirectedReference, options, resolutionHost, moduleResolutionCache) { return { nameAndMode: moduleResolutionNameAndModeGetter, @@ -125897,8 +126308,7 @@ function createModuleResolutionLoaderUsingGlobalCache(containingFile, redirected }; } function resolveModuleNameUsingGlobalCache(resolutionHost, moduleResolutionCache, moduleName, containingFile, compilerOptions, redirectedReference, mode) { - var _a; - const host = ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost; + const host = getModuleResolutionHost(resolutionHost); const primaryResult = resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode); if (!resolutionHost.getGlobalCache) { return primaryResult; @@ -126069,6 +126479,10 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW }; } function startCachingPerDirectoryResolution() { + moduleResolutionCache.isReadonly = void 0; + typeReferenceDirectiveResolutionCache.isReadonly = void 0; + libraryResolutionCache.isReadonly = void 0; + moduleResolutionCache.getPackageJsonInfoCache().isReadonly = void 0; moduleResolutionCache.clearAllExceptPackageJsonInfoCache(); typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache(); libraryResolutionCache.clearAllExceptPackageJsonInfoCache(); @@ -126126,6 +126540,10 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW directoryWatchesOfFailedLookups.forEach(closeDirectoryWatchesOfFailedLookup); fileWatchesOfAffectingLocations.forEach(closeFileWatcherOfAffectingLocation); hasChangedAutomaticTypeDirectiveNames = false; + moduleResolutionCache.isReadonly = true; + typeReferenceDirectiveResolutionCache.isReadonly = true; + libraryResolutionCache.isReadonly = true; + moduleResolutionCache.getPackageJsonInfoCache().isReadonly = true; } function closeDirectoryWatchesOfFailedLookup(watcher, path) { if (watcher.refCount === 0) { @@ -126154,7 +126572,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW shouldRetryResolution, logChanges }) { - var _a; const path = resolutionHost.toPath(containingFile); const resolutionsInFile = perFileCache.get(path) || perFileCache.set(path, createModeAwareCache()).get(path); const resolvedModules = []; @@ -126186,7 +126603,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW logChanges = false; } } else { - const host = ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost; + const host = getModuleResolutionHost(resolutionHost); if (isTraceEnabled(options, host) && !seenNamesInFile.has(name, mode)) { const resolved = getResolutionWithResolvedFileName(resolution); trace( @@ -126238,7 +126655,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW } } function resolveTypeReferenceDirectiveReferences(typeDirectiveReferences, containingFile, redirectedReference, options, containingSourceFile, reusedNames) { - var _a; return resolveNamesWithLocalCache({ entries: typeDirectiveReferences, containingFile, @@ -126251,7 +126667,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW containingFile, redirectedReference, options, - ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost, + getModuleResolutionHost(resolutionHost), typeReferenceDirectiveResolutionCache ), getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective, @@ -126283,8 +126699,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW }); } function resolveLibrary2(libraryName, resolveFrom, options, libFileName) { - var _a; - const host = ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost; + const host = getModuleResolutionHost(resolutionHost); let resolution = resolvedLibraries == null ? void 0 : resolvedLibraries.get(libFileName); if (!resolution || resolution.isInvalidated) { const existingResolution = resolution; @@ -126318,6 +126733,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW return resolution; } function resolveSingleModuleNameWithoutWatching(moduleName, containingFile) { + var _a, _b; const path = resolutionHost.toPath(containingFile); const resolutionsInFile = resolvedModuleNames.get(path); const resolution = resolutionsInFile == null ? void 0 : resolutionsInFile.get( @@ -126327,7 +126743,17 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW ); if (resolution && !resolution.isInvalidated) return resolution; - return resolveModuleNameUsingGlobalCache(resolutionHost, moduleResolutionCache, moduleName, containingFile, resolutionHost.getCompilationSettings()); + const data = (_a = resolutionHost.beforeResolveSingleModuleNameWithoutWatching) == null ? void 0 : _a.call(resolutionHost, moduleResolutionCache); + const host = getModuleResolutionHost(resolutionHost); + const result = resolveModuleName( + moduleName, + containingFile, + resolutionHost.getCompilationSettings(), + host, + moduleResolutionCache + ); + (_b = resolutionHost.afterResolveSingleModuleNameWithoutWatching) == null ? void 0 : _b.call(resolutionHost, moduleResolutionCache, moduleName, containingFile, result, data); + return result; } function isNodeModulesAtTypesDirectory(dirPath) { return endsWith(dirPath, "/node_modules/@types"); @@ -127498,7 +127924,7 @@ function createWatchCompilerHost2(rootFilesOrConfigFileName, options, system, cr } function createWatchProgram(host) { let builderProgram; - let reloadLevel; + let updateLevel; let missingFilesMap; let watchedWildcardDirectories; let timerToUpdateProgram; @@ -127857,7 +128283,7 @@ function createWatchProgram(host) { } function scheduleProgramReload() { Debug.assert(!!configFileName); - reloadLevel = 2 /* Full */; + updateLevel = 2 /* Full */; scheduleProgramUpdate(); } function updateProgramWithWatchStatus() { @@ -127867,8 +128293,8 @@ function createWatchProgram(host) { } function updateProgram() { var _a, _b, _c, _d; - switch (reloadLevel) { - case 1 /* Partial */: + switch (updateLevel) { + case 1 /* RootNamesAndUpdate */: (_a = perfLogger) == null ? void 0 : _a.logStartUpdateProgram("PartialConfigReload"); reloadFileNamesFromConfigFile(); break; @@ -127888,7 +128314,7 @@ function createWatchProgram(host) { writeLog("Reloading new file names and options"); Debug.assert(compilerOptions); Debug.assert(configFileName); - reloadLevel = 0 /* None */; + updateLevel = 0 /* Update */; rootFileNames = getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, getNormalizedAbsolutePath(getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions); if (updateErrorForNoInputFiles(rootFileNames, getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) { hasChangedConfigFileParsingErrors = true; @@ -127898,7 +128324,7 @@ function createWatchProgram(host) { function reloadConfigFile() { Debug.assert(configFileName); writeLog(`Reloading config file: ${configFileName}`); - reloadLevel = 0 /* None */; + updateLevel = 0 /* Update */; if (cachedDirectoryStructureHost) { cachedDirectoryStructureHost.clearCache(); } @@ -127935,9 +128361,9 @@ function createWatchProgram(host) { const configPath = toPath3(configFileName2); let config = parsedConfigs == null ? void 0 : parsedConfigs.get(configPath); if (config) { - if (!config.reloadLevel) + if (!config.updateLevel) return config.parsedCommandLine; - if (config.parsedCommandLine && config.reloadLevel === 1 /* Partial */ && !host.getParsedCommandLine) { + if (config.parsedCommandLine && config.updateLevel === 1 /* RootNamesAndUpdate */ && !host.getParsedCommandLine) { writeLog("Reloading new file names and options"); Debug.assert(compilerOptions); const fileNames = getFileNamesFromConfigSpecs( @@ -127947,7 +128373,7 @@ function createWatchProgram(host) { parseConfigFileHost ); config.parsedCommandLine = { ...config.parsedCommandLine, fileNames }; - config.reloadLevel = void 0; + config.updateLevel = void 0; return config.parsedCommandLine; } } @@ -127955,7 +128381,7 @@ function createWatchProgram(host) { const parsedCommandLine = host.getParsedCommandLine ? host.getParsedCommandLine(configFileName2) : getParsedCommandLineFromConfigFileHost(configFileName2); if (config) { config.parsedCommandLine = parsedCommandLine; - config.reloadLevel = void 0; + config.updateLevel = void 0; } else { (parsedConfigs || (parsedConfigs = /* @__PURE__ */ new Map())).set(configPath, config = { parsedCommandLine }); } @@ -128052,8 +128478,8 @@ function createWatchProgram(host) { toPath: toPath3 })) return; - if (reloadLevel !== 2 /* Full */) { - reloadLevel = 1 /* Partial */; + if (updateLevel !== 2 /* Full */) { + updateLevel = 1 /* RootNamesAndUpdate */; scheduleProgramUpdate(); } }, @@ -128079,11 +128505,11 @@ function createWatchProgram(host) { return; projects.forEach((projectPath) => { if (configFileName && toPath3(configFileName) === projectPath) { - reloadLevel = 2 /* Full */; + updateLevel = 2 /* Full */; } else { const config = parsedConfigs == null ? void 0 : parsedConfigs.get(projectPath); if (config) - config.reloadLevel = 2 /* Full */; + config.updateLevel = 2 /* Full */; resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath); } scheduleProgramUpdate(); @@ -128104,7 +128530,7 @@ function createWatchProgram(host) { updateCachedSystemWithFile(configFileName2, configPath, eventKind); const config = parsedConfigs == null ? void 0 : parsedConfigs.get(configPath); if (config) - config.reloadLevel = 2 /* Full */; + config.updateLevel = 2 /* Full */; resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath); scheduleProgramUpdate(); }, @@ -128142,8 +128568,8 @@ function createWatchProgram(host) { toPath: toPath3 })) return; - if (config.reloadLevel !== 2 /* Full */) { - config.reloadLevel = 1 /* Partial */; + if (config.updateLevel !== 2 /* Full */) { + config.updateLevel = 1 /* RootNamesAndUpdate */; scheduleProgramUpdate(); } }, @@ -128606,12 +129032,12 @@ function clearProjectStatus(state, resolved) { state.projectStatus.delete(resolved); state.diagnostics.delete(resolved); } -function addProjToQueue({ projectPendingBuild }, proj, reloadLevel) { +function addProjToQueue({ projectPendingBuild }, proj, updateLevel) { const value = projectPendingBuild.get(proj); if (value === void 0) { - projectPendingBuild.set(proj, reloadLevel); - } else if (value < reloadLevel) { - projectPendingBuild.set(proj, reloadLevel); + projectPendingBuild.set(proj, updateLevel); + } else if (value < updateLevel) { + projectPendingBuild.set(proj, updateLevel); } } function setupInitialBuild(state, cancellationToken) { @@ -128625,7 +129051,7 @@ function setupInitialBuild(state, cancellationToken) { buildOrder.forEach( (configFileName) => state.projectPendingBuild.set( toResolvedConfigFilePath(state, configFileName), - 0 /* None */ + 0 /* Update */ ) ); if (cancellationToken) { @@ -129067,8 +129493,8 @@ function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) { for (let projectIndex = 0; projectIndex < buildOrder.length; projectIndex++) { const project = buildOrder[projectIndex]; const projectPath = toResolvedConfigFilePath(state, project); - const reloadLevel = state.projectPendingBuild.get(projectPath); - if (reloadLevel === void 0) + const updateLevel = state.projectPendingBuild.get(projectPath); + if (updateLevel === void 0) continue; if (reportQueue) { reportQueue = false; @@ -129080,13 +129506,13 @@ function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) { projectPendingBuild.delete(projectPath); continue; } - if (reloadLevel === 2 /* Full */) { + if (updateLevel === 2 /* Full */) { watchConfigFile(state, project, projectPath, config); watchExtendedConfigFiles(state, projectPath, config); watchWildCardDirectories(state, project, projectPath, config); watchInputFiles(state, project, projectPath, config); watchPackageJsonFiles(state, project, projectPath, config); - } else if (reloadLevel === 1 /* Partial */) { + } else if (updateLevel === 1 /* RootNamesAndUpdate */) { config.fileNames = getFileNamesFromConfigSpecs(config.options.configFile.configFileSpecs, getDirectoryPath(project), config.options, state.parseConfigFileHost); updateErrorForNoInputFiles(config.fileNames, project, config.options.configFile.configFileSpecs, config.errors, canJsonReportNoInputFiles(config.raw)); watchInputFiles(state, project, projectPath, config); @@ -129673,7 +130099,7 @@ function queueReferencingProjects(state, project, projectPath, projectIndex, con break; } } - addProjToQueue(state, nextProjectPath, 0 /* None */); + addProjToQueue(state, nextProjectPath, 0 /* Update */); break; } } @@ -129742,7 +130168,7 @@ function cleanWorker(state, project, onlyReferences) { filesToDelete.push(output); } else { host.deleteFile(output); - invalidateProject(state, resolvedPath, 0 /* None */); + invalidateProject(state, resolvedPath, 0 /* Update */); } } } @@ -129753,22 +130179,22 @@ function cleanWorker(state, project, onlyReferences) { } return 0 /* Success */; } -function invalidateProject(state, resolved, reloadLevel) { - if (state.host.getParsedCommandLine && reloadLevel === 1 /* Partial */) { - reloadLevel = 2 /* Full */; +function invalidateProject(state, resolved, updateLevel) { + if (state.host.getParsedCommandLine && updateLevel === 1 /* RootNamesAndUpdate */) { + updateLevel = 2 /* Full */; } - if (reloadLevel === 2 /* Full */) { + if (updateLevel === 2 /* Full */) { state.configFileCache.delete(resolved); state.buildOrder = void 0; } state.needsSummary = true; clearProjectStatus(state, resolved); - addProjToQueue(state, resolved, reloadLevel); + addProjToQueue(state, resolved, updateLevel); enableCache(state); } -function invalidateProjectAndScheduleBuilds(state, resolvedPath, reloadLevel) { +function invalidateProjectAndScheduleBuilds(state, resolvedPath, updateLevel) { state.reportFileChangeDetected = true; - invalidateProject(state, resolvedPath, reloadLevel); + invalidateProject(state, resolvedPath, updateLevel); scheduleBuildInvalidatedProject( state, 250, @@ -129899,7 +130325,7 @@ function watchWildCardDirectories(state, resolved, resolvedPath, parsed) { toPath: (fileName) => toPath2(state, fileName) })) return; - invalidateProjectAndScheduleBuilds(state, resolvedPath, 1 /* Partial */); + invalidateProjectAndScheduleBuilds(state, resolvedPath, 1 /* RootNamesAndUpdate */); }, flags, parsed == null ? void 0 : parsed.watchOptions, @@ -129918,7 +130344,7 @@ function watchInputFiles(state, resolved, resolvedPath, parsed) { createNewValue: (_path, input) => watchFile( state, input, - () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* None */), + () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* Update */), 250 /* Low */, parsed == null ? void 0 : parsed.watchOptions, WatchType.SourceFile, @@ -129938,7 +130364,7 @@ function watchPackageJsonFiles(state, resolved, resolvedPath, parsed) { createNewValue: (path, _input) => watchFile( state, path, - () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* None */), + () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* Update */), 2e3 /* High */, parsed == null ? void 0 : parsed.watchOptions, WatchType.PackageJson, @@ -130009,7 +130435,7 @@ function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, opti const configFilePath = toResolvedConfigFilePath(state, configFileName); return getUpToDateStatus(state, parseConfigFile(state, configFileName, configFilePath), configFilePath); }, - invalidateProject: (configFilePath, reloadLevel) => invalidateProject(state, configFilePath, reloadLevel || 0 /* None */), + invalidateProject: (configFilePath, updateLevel) => invalidateProject(state, configFilePath, updateLevel || 0 /* Update */), close: () => stopWatching(state) }; } @@ -130222,6 +130648,44 @@ __export(ts_JsTyping_exports, { validatePackageName: () => validatePackageName }); +// src/jsTyping/shared.ts +var ActionSet = "action::set"; +var ActionInvalidate = "action::invalidate"; +var ActionPackageInstalled = "action::packageInstalled"; +var EventTypesRegistry = "event::typesRegistry"; +var EventBeginInstallTypes = "event::beginInstallTypes"; +var EventEndInstallTypes = "event::endInstallTypes"; +var EventInitializationFailed = "event::initializationFailed"; +var ActionWatchTypingLocations = "action::watchTypingLocations"; +var Arguments; +((Arguments2) => { + Arguments2.GlobalCacheLocation = "--globalTypingsCacheLocation"; + Arguments2.LogFile = "--logFile"; + Arguments2.EnableTelemetry = "--enableTelemetry"; + Arguments2.TypingSafeListLocation = "--typingSafeListLocation"; + Arguments2.TypesMapLocation = "--typesMapLocation"; + Arguments2.NpmLocation = "--npmLocation"; + Arguments2.ValidateDefaultNpmLocation = "--validateDefaultNpmLocation"; +})(Arguments || (Arguments = {})); +function hasArgument(argumentName) { + return sys.args.includes(argumentName); +} +function findArgument(argumentName) { + const index = sys.args.indexOf(argumentName); + return index >= 0 && index < sys.args.length - 1 ? sys.args[index + 1] : void 0; +} +function nowString() { + const d = /* @__PURE__ */ new Date(); + return `${d.getHours().toString().padStart(2, "0")}:${d.getMinutes().toString().padStart(2, "0")}:${d.getSeconds().toString().padStart(2, "0")}.${d.getMilliseconds().toString().padStart(3, "0")}`; +} +var indentStr = "\n "; +function indent2(str) { + return indentStr + str.replace(/\n/g, indentStr); +} +function stringifyIndented(json) { + return indent2(JSON.stringify(json, void 0, 2)); +} + // src/jsTyping/jsTyping.ts function isTypingUpToDate(cachedTyping, availableTypingVersions) { const availableVersion = new Version(getProperty(availableTypingVersions, `ts${versionMajorMinor}`) || getProperty(availableTypingVersions, "latest")); @@ -130328,21 +130792,21 @@ function discoverTypings(host, log, fileNames, projectRootPath, safeList, packag ); addInferredTypings(module2, "Inferred typings from unresolved imports"); } - packageNameToTypingLocation.forEach((typing, name) => { - const registryEntry = typesRegistry.get(name); - if (inferredTypings.has(name) && inferredTypings.get(name) === void 0 && registryEntry !== void 0 && isTypingUpToDate(typing, registryEntry)) { - inferredTypings.set(name, typing.typingLocation); - } - }); for (const excludeTypingName of exclude) { const didDelete = inferredTypings.delete(excludeTypingName); if (didDelete && log) log(`Typing for ${excludeTypingName} is in exclude list, will be ignored.`); } + packageNameToTypingLocation.forEach((typing, name) => { + const registryEntry = typesRegistry.get(name); + if (inferredTypings.get(name) === false && registryEntry !== void 0 && isTypingUpToDate(typing, registryEntry)) { + inferredTypings.set(name, typing.typingLocation); + } + }); const newTypingNames = []; const cachedTypingPaths = []; inferredTypings.forEach((inferred, typing) => { - if (inferred !== void 0) { + if (inferred) { cachedTypingPaths.push(inferred); } else { newTypingNames.push(typing); @@ -130350,11 +130814,11 @@ function discoverTypings(host, log, fileNames, projectRootPath, safeList, packag }); const result = { cachedTypingPaths, newTypingNames, filesToWatch }; if (log) - log(`Result: ${JSON.stringify(result)}`); + log(`Finished typings discovery:${stringifyIndented(result)}`); return result; function addInferredTyping(typingName) { if (!inferredTypings.has(typingName)) { - inferredTypings.set(typingName, void 0); + inferredTypings.set(typingName, false); } } function addInferredTypings(typingNames, message) { @@ -130527,37 +130991,6 @@ function renderPackageNameValidationFailureWorker(typing, result, name, isScopeN } } -// src/jsTyping/shared.ts -var ActionSet = "action::set"; -var ActionInvalidate = "action::invalidate"; -var ActionPackageInstalled = "action::packageInstalled"; -var EventTypesRegistry = "event::typesRegistry"; -var EventBeginInstallTypes = "event::beginInstallTypes"; -var EventEndInstallTypes = "event::endInstallTypes"; -var EventInitializationFailed = "event::initializationFailed"; -var ActionWatchTypingLocations = "action::watchTypingLocations"; -var Arguments; -((Arguments2) => { - Arguments2.GlobalCacheLocation = "--globalTypingsCacheLocation"; - Arguments2.LogFile = "--logFile"; - Arguments2.EnableTelemetry = "--enableTelemetry"; - Arguments2.TypingSafeListLocation = "--typingSafeListLocation"; - Arguments2.TypesMapLocation = "--typesMapLocation"; - Arguments2.NpmLocation = "--npmLocation"; - Arguments2.ValidateDefaultNpmLocation = "--validateDefaultNpmLocation"; -})(Arguments || (Arguments = {})); -function hasArgument(argumentName) { - return sys.args.includes(argumentName); -} -function findArgument(argumentName) { - const index = sys.args.indexOf(argumentName); - return index >= 0 && index < sys.args.length - 1 ? sys.args[index + 1] : void 0; -} -function nowString() { - const d = /* @__PURE__ */ new Date(); - return `${d.getHours().toString().padStart(2, "0")}:${d.getMinutes().toString().padStart(2, "0")}:${d.getSeconds().toString().padStart(2, "0")}.${d.getMilliseconds().toString().padStart(3, "0")}`; -} - // src/services/types.ts var ScriptSnapshot; ((ScriptSnapshot2) => { @@ -131213,7 +131646,7 @@ function getNodeKind(node) { case 306 /* EnumMember */: return "enum member" /* enumMemberElement */; case 169 /* Parameter */: - return hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + return hasSyntacticModifier(node, 31 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; case 271 /* ImportEqualsDeclaration */: case 276 /* ImportSpecifier */: case 281 /* ExportSpecifier */: @@ -132117,19 +132550,19 @@ function nodeHasTokens(n, sourceFile) { function getNodeModifiers(node, excludeFlags = 0 /* None */) { const result = []; const flags = isDeclaration(node) ? getCombinedNodeFlagsAlwaysIncludeJSDoc(node) & ~excludeFlags : 0 /* None */; - if (flags & 8 /* Private */) + if (flags & 2 /* Private */) result.push("private" /* privateMemberModifier */); - if (flags & 16 /* Protected */) + if (flags & 4 /* Protected */) result.push("protected" /* protectedMemberModifier */); - if (flags & 4 /* Public */) + if (flags & 1 /* Public */) result.push("public" /* publicMemberModifier */); - if (flags & 32 /* Static */ || isClassStaticBlockDeclaration(node)) + if (flags & 256 /* Static */ || isClassStaticBlockDeclaration(node)) result.push("static" /* staticModifier */); - if (flags & 256 /* Abstract */) + if (flags & 64 /* Abstract */) result.push("abstract" /* abstractModifier */); - if (flags & 1 /* Export */) + if (flags & 32 /* Export */) result.push("export" /* exportedModifier */); - if (flags & 8192 /* Deprecated */) + if (flags & 65536 /* Deprecated */) result.push("deprecated" /* deprecatedModifier */); if (node.flags & 33554432 /* Ambient */) result.push("declare" /* ambientModifier */); @@ -133543,7 +133976,7 @@ function isNonGlobalDeclaration(declaration) { return isInJSFile(declaration) || !findAncestor(declaration, (d) => isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); } function isDeprecatedDeclaration(decl) { - return !!(getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); + return !!(getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 65536 /* Deprecated */); } function shouldUseUriStyleNodeCoreModules(file, program) { const decisionFromFile = firstDefined(file.imports, (node) => { @@ -135152,7 +135585,7 @@ var DocumentHighlights; case 241 /* Block */: case 296 /* CaseClause */: case 297 /* DefaultClause */: - if (modifierFlag & 256 /* Abstract */ && isClassDeclaration(declaration)) { + if (modifierFlag & 64 /* Abstract */ && isClassDeclaration(declaration)) { return [...declaration.members, declaration]; } else { return container.statements; @@ -135166,12 +135599,12 @@ var DocumentHighlights; case 264 /* InterfaceDeclaration */: case 187 /* TypeLiteral */: const nodes = container.members; - if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { + if (modifierFlag & (7 /* AccessibilityModifier */ | 8 /* Readonly */)) { const constructor = find(container.members, isConstructorDeclaration); if (constructor) { return [...nodes, ...constructor.parameters]; } - } else if (modifierFlag & 256 /* Abstract */) { + } else if (modifierFlag & 64 /* Abstract */) { return [...nodes, container]; } return nodes; @@ -137634,7 +138067,7 @@ function getItemName(node, name) { case 218 /* FunctionExpression */: case 263 /* ClassDeclaration */: case 231 /* ClassExpression */: - if (getSyntacticModifierFlags(node) & 1024 /* Default */) { + if (getSyntacticModifierFlags(node) & 2048 /* Default */) { return "default"; } return getFunctionOrClassName(node); @@ -137784,7 +138217,7 @@ function getFunctionOrClassName(node) { return nodeText(parent2.left).replace(whiteSpaceRegex, ""); } else if (isPropertyAssignment(parent2)) { return nodeText(parent2.name); - } else if (getSyntacticModifierFlags(node) & 1024 /* Default */) { + } else if (getSyntacticModifierFlags(node) & 2048 /* Default */) { return "default"; } else if (isClassLike(node)) { return ""; @@ -137931,15 +138364,15 @@ function getInfo2(context, considerPartialSpans = true) { const { file, program } = context; const span = getRefactorContextSpan(context); const token = getTokenAtPosition(file, span.start); - const exportNode = !!(token.parent && getSyntacticModifierFlags(token.parent) & 1 /* Export */) && considerPartialSpans ? token.parent : getParentNodeInSpan(token, file, span); + const exportNode = !!(token.parent && getSyntacticModifierFlags(token.parent) & 32 /* Export */) && considerPartialSpans ? token.parent : getParentNodeInSpan(token, file, span); if (!exportNode || !isSourceFile(exportNode.parent) && !(isModuleBlock(exportNode.parent) && isAmbientModule(exportNode.parent.parent))) { return { error: getLocaleSpecificMessage(Diagnostics.Could_not_find_export_statement) }; } const checker = program.getTypeChecker(); const exportingModuleSymbol = getExportingModuleSymbol(exportNode.parent, checker); - const flags = getSyntacticModifierFlags(exportNode) || (isExportAssignment(exportNode) && !exportNode.isExportEquals ? 1025 /* ExportDefault */ : 0 /* None */); - const wasDefault = !!(flags & 1024 /* Default */); - if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { + const flags = getSyntacticModifierFlags(exportNode) || (isExportAssignment(exportNode) && !exportNode.isExportEquals ? 2080 /* ExportDefault */ : 0 /* None */); + const wasDefault = !!(flags & 2048 /* Default */); + if (!(flags & 32 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { return { error: getLocaleSpecificMessage(Diagnostics.This_file_already_has_a_default_export) }; } const noSymbolError = (id) => isIdentifier(id) && checker.getSymbolAtLocation(id) ? void 0 : { error: getLocaleSpecificMessage(Diagnostics.Can_only_convert_named_export) }; @@ -138436,26 +138869,50 @@ function getRangeToExtract(context, considerEmptySpans = true) { const current = getTokenAtPosition(file, startPosition); const range = createTextRangeFromSpan(getRefactorContextSpan(context)); const cursorRequest = range.pos === range.end && considerEmptySpans; - const selection = findAncestor(current, (node) => node.parent && isTypeNode(node) && !rangeContainsSkipTrivia(range, node.parent, file) && (cursorRequest || nodeOverlapsWithStartEnd(current, file, range.pos, range.end))); - if (!selection || !isTypeNode(selection)) + const overlappingRange = nodeOverlapsWithStartEnd(current, file, range.pos, range.end); + const firstType = findAncestor(current, (node) => node.parent && isTypeNode(node) && !rangeContainsSkipTrivia(range, node.parent, file) && (cursorRequest || overlappingRange)); + if (!firstType || !isTypeNode(firstType)) return { error: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_type_node) }; const checker = context.program.getTypeChecker(); - const enclosingNode = getEnclosingNode(selection, isJS); + const enclosingNode = getEnclosingNode(firstType, isJS); if (enclosingNode === void 0) return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) }; + const expandedFirstType = getExpandedSelectionNode(firstType, enclosingNode); + if (!isTypeNode(expandedFirstType)) + return { error: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_type_node) }; + const typeList = []; + if ((isUnionTypeNode(expandedFirstType.parent) || isIntersectionTypeNode(expandedFirstType.parent)) && range.end > firstType.end) { + addRange( + typeList, + expandedFirstType.parent.types.filter((type) => { + return nodeOverlapsWithStartEnd(type, file, range.pos, range.end); + }) + ); + } + const selection = typeList.length > 1 ? typeList : expandedFirstType; const typeParameters = collectTypeParameters(checker, selection, enclosingNode, file); if (!typeParameters) return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) }; const typeElements = flattenTypeLiteralNodeReference(checker, selection); return { isJS, selection, enclosingNode, typeParameters, typeElements }; } -function flattenTypeLiteralNodeReference(checker, node) { - if (!node) +function flattenTypeLiteralNodeReference(checker, selection) { + if (!selection) return void 0; - if (isIntersectionTypeNode(node)) { + if (isArray(selection)) { + const result = []; + for (const type of selection) { + const flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type); + if (!flattenedTypeMembers) + return void 0; + addRange(result, flattenedTypeMembers); + } + return result; + } + if (isIntersectionTypeNode(selection)) { const result = []; const seen = /* @__PURE__ */ new Map(); - for (const type of node.types) { + for (const type of selection.types) { const flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type); if (!flattenedTypeMembers || !flattenedTypeMembers.every((type2) => type2.name && addToSeen(seen, getNameFromPropertyName(type2.name)))) { return void 0; @@ -138463,10 +138920,10 @@ function flattenTypeLiteralNodeReference(checker, node) { addRange(result, flattenedTypeMembers); } return result; - } else if (isParenthesizedTypeNode(node)) { - return flattenTypeLiteralNodeReference(checker, node.type); - } else if (isTypeLiteralNode(node)) { - return node.members; + } else if (isParenthesizedTypeNode(selection)) { + return flattenTypeLiteralNodeReference(checker, selection.type); + } else if (isTypeLiteralNode(selection)) { + return selection.members; } return void 0; } @@ -138475,7 +138932,13 @@ function rangeContainsSkipTrivia(r1, node, file) { } function collectTypeParameters(checker, selection, enclosingNode, file) { const result = []; - return visitor(selection) ? void 0 : result; + const selectionArray = toArray(selection); + const selectionRange = { pos: selectionArray[0].pos, end: selectionArray[selectionArray.length - 1].end }; + for (const t of selectionArray) { + if (visitor(t)) + return void 0; + } + return result; function visitor(node) { if (isTypeReferenceNode(node)) { if (isIdentifier(node.typeName)) { @@ -138489,10 +138952,10 @@ function collectTypeParameters(checker, selection, enclosingNode, file) { ); for (const decl of (symbol == null ? void 0 : symbol.declarations) || emptyArray) { if (isTypeParameterDeclaration(decl) && decl.getSourceFile() === file) { - if (decl.name.escapedText === typeName.escapedText && rangeContainsSkipTrivia(decl, selection, file)) { + if (decl.name.escapedText === typeName.escapedText && rangeContainsSkipTrivia(decl, selectionRange, file)) { return true; } - if (rangeContainsSkipTrivia(enclosingNode, decl, file) && !rangeContainsSkipTrivia(selection, decl, file)) { + if (rangeContainsSkipTrivia(enclosingNode, decl, file) && !rangeContainsSkipTrivia(selectionRange, decl, file)) { pushIfUnique(result, decl); break; } @@ -138501,12 +138964,12 @@ function collectTypeParameters(checker, selection, enclosingNode, file) { } } else if (isInferTypeNode(node)) { const conditionalTypeNode = findAncestor(node, (n) => isConditionalTypeNode(n) && rangeContainsSkipTrivia(n.extendsType, node, file)); - if (!conditionalTypeNode || !rangeContainsSkipTrivia(selection, conditionalTypeNode, file)) { + if (!conditionalTypeNode || !rangeContainsSkipTrivia(selectionRange, conditionalTypeNode, file)) { return true; } } else if (isTypePredicateNode(node) || isThisTypeNode(node)) { const functionLikeNode = findAncestor(node.parent, isFunctionLike); - if (functionLikeNode && functionLikeNode.type && rangeContainsSkipTrivia(functionLikeNode.type, node, file) && !rangeContainsSkipTrivia(selection, functionLikeNode, file)) { + if (functionLikeNode && functionLikeNode.type && rangeContainsSkipTrivia(functionLikeNode.type, node, file) && !rangeContainsSkipTrivia(selectionRange, functionLikeNode, file)) { return true; } } else if (isTypeQueryNode(node)) { @@ -138518,11 +138981,11 @@ function collectTypeParameters(checker, selection, enclosingNode, file) { /*excludeGlobals*/ false ); - if ((symbol == null ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(enclosingNode, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { + if ((symbol == null ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(enclosingNode, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selectionRange, symbol.valueDeclaration, file)) { return true; } } else { - if (isThisIdentifier(node.exprName.left) && !rangeContainsSkipTrivia(selection, node.parent, file)) { + if (isThisIdentifier(node.exprName.left) && !rangeContainsSkipTrivia(selectionRange, node.parent, file)) { return true; } } @@ -138534,8 +138997,9 @@ function collectTypeParameters(checker, selection, enclosingNode, file) { } } function doTypeAliasChange(changes, file, name, info) { - const { enclosingNode, selection, typeParameters } = info; - const newTypeNode = factory.createTypeAliasDeclaration( + const { enclosingNode, typeParameters } = info; + const { firstTypeNode, lastTypeNode, newTypeNode } = getNodesToEdit(info); + const newTypeDeclaration = factory.createTypeAliasDeclaration( /*modifiers*/ void 0, name, @@ -138547,16 +139011,16 @@ function doTypeAliasChange(changes, file, name, info) { /*defaultType*/ void 0 )), - selection + newTypeNode ); changes.insertNodeBefore( file, enclosingNode, - ignoreSourceNewlines(newTypeNode), + ignoreSourceNewlines(newTypeDeclaration), /*blankLineBetween*/ true ); - changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode( + changes.replaceNodeRange(file, firstTypeNode, lastTypeNode, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode( id.name, /*typeArguments*/ void 0 @@ -138564,7 +139028,7 @@ function doTypeAliasChange(changes, file, name, info) { } function doInterfaceChange(changes, file, name, info) { var _a; - const { enclosingNode, selection, typeParameters, typeElements } = info; + const { enclosingNode, typeParameters, typeElements } = info; const newTypeNode = factory.createInterfaceDeclaration( /*modifiers*/ void 0, @@ -138582,7 +139046,8 @@ function doInterfaceChange(changes, file, name, info) { /*blankLineBetween*/ true ); - changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode( + const { firstTypeNode, lastTypeNode } = getNodesToEdit(info); + changes.replaceNodeRange(file, firstTypeNode, lastTypeNode, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode( id.name, /*typeArguments*/ void 0 @@ -138590,11 +139055,14 @@ function doInterfaceChange(changes, file, name, info) { } function doTypedefChange(changes, context, file, name, info) { var _a; - const { enclosingNode, selection, typeParameters } = info; - setEmitFlags(selection, 3072 /* NoComments */ | 4096 /* NoNestedComments */); + toArray(info.selection).forEach((typeNode) => { + setEmitFlags(typeNode, 3072 /* NoComments */ | 4096 /* NoNestedComments */); + }); + const { enclosingNode, typeParameters } = info; + const { firstTypeNode, lastTypeNode, newTypeNode } = getNodesToEdit(info); const node = factory.createJSDocTypedefTag( factory.createIdentifier("typedef"), - factory.createJSDocTypeExpression(selection), + factory.createJSDocTypeExpression(newTypeNode), factory.createIdentifier(name) ); const templates = []; @@ -138632,15 +139100,39 @@ function doTypedefChange(changes, context, file, name, info) { true ); } - changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode( + changes.replaceNodeRange(file, firstTypeNode, lastTypeNode, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode( id.name, /*typeArguments*/ void 0 )))); } +function getNodesToEdit(info) { + if (isArray(info.selection)) { + return { + firstTypeNode: info.selection[0], + lastTypeNode: info.selection[info.selection.length - 1], + newTypeNode: isUnionTypeNode(info.selection[0].parent) ? factory.createUnionTypeNode(info.selection) : factory.createIntersectionTypeNode(info.selection) + }; + } + return { + firstTypeNode: info.selection, + lastTypeNode: info.selection, + newTypeNode: info.selection + }; +} function getEnclosingNode(node, isJS) { return findAncestor(node, isStatement) || (isJS ? findAncestor(node, isJSDoc) : void 0); } +function getExpandedSelectionNode(firstType, enclosingNode) { + return findAncestor(firstType, (node) => { + if (node === enclosingNode) + return "quit"; + if (isUnionTypeNode(node.parent) || isIntersectionTypeNode(node.parent)) { + return true; + } + return false; + }) ?? firstType; +} // src/services/refactors/helpers.ts function isRefactorErrorInfo(info) { @@ -138893,7 +139385,7 @@ function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileI if (markSeenTop(top)) { addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax); } - if (hasSyntacticModifier(decl, 1024 /* Default */)) { + if (hasSyntacticModifier(decl, 2048 /* Default */)) { oldFileDefault = name; } else { oldFileNamedImports.push(name.text); @@ -138948,14 +139440,13 @@ function error(notApplicableReason) { } function doChange4(context, oldFile, targetFile, program, toMove, changes, host, preferences) { const checker = program.getTypeChecker(); - const usage = getUsageInfo(oldFile, toMove.all, checker); if (!host.fileExists(targetFile)) { - changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences)); + changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, getUsageInfo(oldFile, toMove.all, checker), changes, toMove, program, host, preferences)); addNewFileToTsconfig(program, changes, oldFile.fileName, targetFile, hostGetCanonicalFileName(host)); } else { const targetSourceFile = Debug.checkDefined(program.getSourceFile(targetFile)); const importAdder = ts_codefix_exports.createImportAdder(targetSourceFile, context.program, context.preferences, context.host); - getNewStatementsAndRemoveFromOldFile2(oldFile, targetSourceFile, usage, changes, toMove, program, host, preferences, importAdder); + getNewStatementsAndRemoveFromOldFile2(oldFile, targetSourceFile, getUsageInfo(oldFile, toMove.all, checker, getExistingImports(targetSourceFile, checker)), changes, toMove, program, host, preferences, importAdder); } } function getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences, importAdder) { @@ -139075,7 +139566,7 @@ function getTargetFileImportsAndAddExportInOldFile(oldFile, targetFile, importsT if (importAdder && checker.isUnknownSymbol(symbol)) { importAdder.addImportFromExportedSymbol(skipAlias(symbol, checker)); } else { - if (hasSyntacticModifier(decl, 1024 /* Default */)) { + if (hasSyntacticModifier(decl, 2048 /* Default */)) { oldFileDefault = name; } else { oldFileNamedImports.push(name.text); @@ -139315,7 +139806,7 @@ function addExports(sourceFile, toMove, needExport, useEs6Exports) { function isExported(sourceFile, decl, useEs6Exports, name) { var _a; if (useEs6Exports) { - return !isExpressionStatement(decl) && hasSyntacticModifier(decl, 1 /* Export */) || !!(name && sourceFile.symbol && ((_a = sourceFile.symbol.exports) == null ? void 0 : _a.has(name.escapedText))); + return !isExpressionStatement(decl) && hasSyntacticModifier(decl, 32 /* Export */) || !!(name && sourceFile.symbol && ((_a = sourceFile.symbol.exports) == null ? void 0 : _a.has(name.escapedText))); } return !!sourceFile.symbol && !!sourceFile.symbol.exports && getNamesToExportInCommonJS(decl).some((name2) => sourceFile.symbol.exports.has(escapeLeadingUnderscores(name2))); } @@ -139610,7 +140101,7 @@ function isPureImport(node) { case 272 /* ImportDeclaration */: return true; case 271 /* ImportEqualsDeclaration */: - return !hasSyntacticModifier(node, 1 /* Export */); + return !hasSyntacticModifier(node, 32 /* Export */); case 243 /* VariableStatement */: return node.declarationList.declarations.every((d) => !!d.initializer && isRequireCall( d.initializer, @@ -139621,7 +140112,7 @@ function isPureImport(node) { return false; } } -function getUsageInfo(oldFile, toMove, checker) { +function getUsageInfo(oldFile, toMove, checker, existingTargetImports = /* @__PURE__ */ new Set()) { const movedSymbols = /* @__PURE__ */ new Set(); const oldImportsNeededByTargetFile = /* @__PURE__ */ new Map(); const targetFileImportsFromOldFile = /* @__PURE__ */ new Set(); @@ -139635,10 +140126,16 @@ function getUsageInfo(oldFile, toMove, checker) { movedSymbols.add(Debug.checkDefined(isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here")); }); } + const unusedImportsFromOldFile = /* @__PURE__ */ new Set(); for (const statement of toMove) { forEachReference(statement, checker, (symbol, isValidTypeOnlyUseSite) => { - if (!symbol.declarations) + if (!symbol.declarations) { return; + } + if (existingTargetImports.has(skipAlias(symbol, checker))) { + unusedImportsFromOldFile.add(symbol); + return; + } for (const decl of symbol.declarations) { if (isInImport(decl)) { const prevIsTypeOnly = oldImportsNeededByTargetFile.get(symbol); @@ -139649,7 +140146,9 @@ function getUsageInfo(oldFile, toMove, checker) { } }); } - const unusedImportsFromOldFile = new Set(oldImportsNeededByTargetFile.keys()); + for (const unusedImport of oldImportsNeededByTargetFile.keys()) { + unusedImportsFromOldFile.add(unusedImport); + } const oldFileImportsFromTargetFile = /* @__PURE__ */ new Set(); for (const statement of oldFile.statements) { if (contains(toMove, statement)) @@ -139781,7 +140280,7 @@ function moveStatementsToTargetFile(changes, program, statements, targetFile, to const checker = program.getTypeChecker(); const targetToSourceExports = /* @__PURE__ */ new Map(); for (const node of toMove.all) { - if (isTopLevelDeclarationStatement(node) && hasSyntacticModifier(node, 1 /* Export */)) { + if (isTopLevelDeclarationStatement(node) && hasSyntacticModifier(node, 32 /* Export */)) { forEachTopLevelDeclaration(node, (declaration) => { var _a2; const targetDeclarations = canHaveSymbol(declaration) ? (_a2 = targetExports.get(declaration.symbol.escapedName)) == null ? void 0 : _a2.declarations : void 0; @@ -139835,6 +140334,29 @@ function getOverloadRangeToMove(sourceFile, statement) { } return void 0; } +function getExistingImports(sourceFile, checker) { + const imports = /* @__PURE__ */ new Set(); + for (const moduleSpecifier of sourceFile.imports) { + const declaration = importFromModuleSpecifier(moduleSpecifier); + if (isImportDeclaration(declaration) && declaration.importClause && declaration.importClause.namedBindings && isNamedImports(declaration.importClause.namedBindings)) { + for (const e of declaration.importClause.namedBindings.elements) { + const symbol = checker.getSymbolAtLocation(e.propertyName || e.name); + if (symbol) { + imports.add(skipAlias(symbol, checker)); + } + } + } + if (isVariableDeclarationInitializedToRequire(declaration.parent) && isObjectBindingPattern(declaration.parent.name)) { + for (const e of declaration.parent.name.elements) { + const symbol = checker.getSymbolAtLocation(e.propertyName || e.name); + if (symbol) { + imports.add(skipAlias(symbol, checker)); + } + } + } + } + return imports; +} // src/services/_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.ts var ts_refactor_addOrRemoveBracesToArrowFunction_exports = {}; @@ -140377,7 +140899,7 @@ function getEditInfoForConvertToNamedFunction(context, func, variableInfo) { const body = convertToBlock(func.body); const { variableDeclaration, variableDeclarationList, statement, name } = variableInfo; suppressLeadingTrivia(statement); - const modifiersFlags = getCombinedModifierFlags(variableDeclaration) & 1 /* Export */ | getEffectiveModifierFlags(func); + const modifiersFlags = getCombinedModifierFlags(variableDeclaration) & 32 /* Export */ | getEffectiveModifierFlags(func); const modifiers = factory.createModifiersFromModifierFlags(modifiersFlags); const newNode = factory.createFunctionDeclaration(length(modifiers) ? modifiers : void 0, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); if (variableDeclarationList.declarations.length === 1) { @@ -141734,7 +142256,7 @@ function getRangeToExtract2(sourceFile, span, invoked = true) { } if (isDeclaration(node2)) { const declaringNode = node2.kind === 260 /* VariableDeclaration */ ? node2.parent.parent : node2; - if (hasSyntacticModifier(declaringNode, 1 /* Export */)) { + if (hasSyntacticModifier(declaringNode, 32 /* Export */)) { (errors2 || (errors2 = [])).push(createDiagnosticForNode(node2, Messages.cannotExtractExportedEntity)); return true; } @@ -142742,7 +143264,7 @@ function collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFi usagesPerScope[i].usages.forEach((value) => { if (value.usage === 2 /* Write */) { hasWrite = true; - if (value.symbol.flags & 106500 /* ClassMember */ && value.symbol.valueDeclaration && hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* Readonly */)) { + if (value.symbol.flags & 106500 /* ClassMember */ && value.symbol.valueDeclaration && hasEffectiveModifier(value.symbol.valueDeclaration, 8 /* Readonly */)) { readonlyClassPropertyWrite = value.symbol.valueDeclaration; } } @@ -143081,7 +143603,7 @@ function doChange7(sourceFile, changes, declaration, typeNode) { function getInfo4(context) { if (isInJSFile(context.file) || !refactorKindBeginsWith(inferReturnTypeAction.kind, context.kind)) return; - const token = getTokenAtPosition(context.file, context.startPosition); + const token = getTouchingPropertyName(context.file, context.startPosition); const declaration = findAncestor(token, (n) => isBlock(n) || n.parent && isArrowFunction(n.parent) && (n.kind === 39 /* EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : isConvertibleDeclaration(n)); if (!declaration || !declaration.body || declaration.type) { return { error: getLocaleSpecificMessage(Diagnostics.Return_type_must_be_inferred_from_a_function) }; @@ -143226,14 +143748,14 @@ function collectTokens(program, sourceFile, span, collector, cancellationToken) if (decl) { const modifiers = getCombinedModifierFlags(decl); const nodeFlags = getCombinedNodeFlags(decl); - if (modifiers & 32 /* Static */) { + if (modifiers & 256 /* Static */) { modifierSet |= 1 << 1 /* static */; } - if (modifiers & 512 /* Async */) { + if (modifiers & 1024 /* Async */) { modifierSet |= 1 << 2 /* async */; } if (typeIdx !== 0 /* class */ && typeIdx !== 2 /* interface */) { - if (modifiers & 64 /* Readonly */ || nodeFlags & 2 /* Const */ || symbol.getFlags() & 8 /* EnumMember */) { + if (modifiers & 8 /* Readonly */ || nodeFlags & 2 /* Const */ || symbol.getFlags() & 8 /* EnumMember */) { modifierSet |= 1 << 3 /* readonly */; } } @@ -143951,7 +144473,7 @@ var SourceFileObject = class extends NodeObject { forEachChild(node, visit); break; case 169 /* Parameter */: - if (!hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (!hasSyntacticModifier(node, 31 /* ParameterPropertyModifier */)) { break; } case 260 /* VariableDeclaration */: @@ -145804,7 +146326,7 @@ function spanInSourceFileAtLocation(sourceFile, position) { if (isBindingPattern(variableDeclaration.name)) { return spanInBindingPattern(variableDeclaration.name); } - if (hasOnlyExpressionInitializer(variableDeclaration) && variableDeclaration.initializer || hasSyntacticModifier(variableDeclaration, 1 /* Export */) || parent2.parent.kind === 250 /* ForOfStatement */) { + if (hasOnlyExpressionInitializer(variableDeclaration) && variableDeclaration.initializer || hasSyntacticModifier(variableDeclaration, 32 /* Export */) || parent2.parent.kind === 250 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (isVariableDeclarationList(variableDeclaration.parent) && variableDeclaration.parent.declarations[0] !== variableDeclaration) { @@ -145812,7 +146334,7 @@ function spanInSourceFileAtLocation(sourceFile, position) { } } function canHaveSpanInParameterDeclaration(parameter) { - return !!parameter.initializer || parameter.dotDotDotToken !== void 0 || hasSyntacticModifier(parameter, 4 /* Public */ | 8 /* Private */); + return !!parameter.initializer || parameter.dotDotDotToken !== void 0 || hasSyntacticModifier(parameter, 1 /* Public */ | 2 /* Private */); } function spanInParameterDeclaration(parameter) { if (isBindingPattern(parameter.name)) { @@ -145831,7 +146353,7 @@ function spanInSourceFileAtLocation(sourceFile, position) { } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return hasSyntacticModifier(functionDeclaration, 1 /* Export */) || functionDeclaration.parent.kind === 263 /* ClassDeclaration */ && functionDeclaration.kind !== 176 /* Constructor */; + return hasSyntacticModifier(functionDeclaration, 32 /* Export */) || functionDeclaration.parent.kind === 263 /* ClassDeclaration */ && functionDeclaration.kind !== 176 /* Constructor */; } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -146393,7 +146915,7 @@ function collectCallSitesOfSourceFile(node, collect) { forEach(node.statements, collect); } function collectCallSitesOfModuleDeclaration(node, collect) { - if (!hasSyntacticModifier(node, 2 /* Ambient */) && node.body && isModuleBlock(node.body)) { + if (!hasSyntacticModifier(node, 128 /* Ambient */) && node.body && isModuleBlock(node.body)) { forEach(node.body.statements, collect); } } @@ -146719,13 +147241,13 @@ function makeChange2(changeTracker, sourceFile, insertionSite, fixedDeclarations } } fixedDeclarations == null ? void 0 : fixedDeclarations.add(getNodeId(insertionSite)); - const cloneWithModifier = factory.updateModifiers( + const cloneWithModifier = factory.replaceModifiers( getSynthesizedDeepClone( insertionSite, /*includeTrivia*/ true ), - factory.createNodeArray(factory.createModifiersFromModifierFlags(getSyntacticModifierFlags(insertionSite) | 512 /* Async */)) + factory.createNodeArray(factory.createModifiersFromModifierFlags(getSyntacticModifierFlags(insertionSite) | 1024 /* Async */)) ); changeTracker.replaceNode( sourceFile, @@ -146850,7 +147372,7 @@ function findAwaitableInitializers(expression, sourceFile, cancellationToken, pr const declaration = tryCast(symbol.valueDeclaration, isVariableDeclaration); const variableName = declaration && tryCast(declaration.name, isIdentifier); const variableStatement = getAncestor(declaration, 243 /* VariableStatement */); - if (!declaration || !variableStatement || declaration.type || !declaration.initializer || variableStatement.getSourceFile() !== sourceFile || hasSyntacticModifier(variableStatement, 1 /* Export */) || !variableName || !isInsideAwaitableBody(declaration.initializer)) { + if (!declaration || !variableStatement || declaration.type || !declaration.initializer || variableStatement.getSourceFile() !== sourceFile || hasSyntacticModifier(variableStatement, 32 /* Export */) || !variableName || !isInsideAwaitableBody(declaration.initializer)) { isCompleteFix = false; continue; } @@ -149494,7 +150016,7 @@ function getClass(sourceFile, pos) { return Debug.checkDefined(getContainingClass(getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { - return !symbol.valueDeclaration || !(getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* Private */); + return !symbol.valueDeclaration || !(getEffectiveModifierFlags(symbol.valueDeclaration) & 2 /* Private */); } function addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, changeTracker, preferences) { const checker = context.program.getTypeChecker(); @@ -149784,7 +150306,8 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre defaultImport, namedImports && arrayFrom(namedImports.entries(), ([name, addAsTypeOnly]) => ({ addAsTypeOnly, name })), namespaceLikeImport, - compilerOptions + compilerOptions, + preferences ); newDeclarations = combine(newDeclarations, declarations); }); @@ -150091,7 +150614,18 @@ function getNewImportFixes(program, sourceFile, usagePosition, isValidTypeOnlyUs const getChecker = createGetChecker(program, host); const moduleResolution = getEmitModuleResolutionKind(compilerOptions); const rejectNodeModulesRelativePaths = moduleResolutionUsesNodeModules(moduleResolution); - const getModuleSpecifiers2 = fromCacheOnly ? (moduleSymbol) => ({ moduleSpecifiers: ts_moduleSpecifiers_exports.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }) : (moduleSymbol, checker) => ts_moduleSpecifiers_exports.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); + const getModuleSpecifiers2 = fromCacheOnly ? (moduleSymbol) => ({ moduleSpecifiers: ts_moduleSpecifiers_exports.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }) : (moduleSymbol, checker) => ts_moduleSpecifiers_exports.getModuleSpecifiersWithCacheInfo( + moduleSymbol, + checker, + compilerOptions, + sourceFile, + moduleSpecifierResolutionHost, + preferences, + /*options*/ + void 0, + /*forAutoImport*/ + true + ); let computedWithoutCacheCount = 0; const fixes = flatMap(exportInfo, (exportInfo2, i) => { const checker = getChecker(exportInfo2.isFromPackageJson); @@ -150478,7 +151012,8 @@ function codeActionForFixWorker(changes, sourceFile, symbolName2, fix, includeSy defaultImport, namedImports, namespaceLikeImport, - program.getCompilerOptions() + program.getCompilerOptions(), + preferences ), /*blankLineBetween*/ true, @@ -150610,7 +151145,7 @@ function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImpor const newSpecifiers = stableSort( namedImports.map( (namedImport) => factory.createImportSpecifier( - (!clause.isTypeOnly || promoteFromTypeOnly2) && needsTypeOnly(namedImport), + (!clause.isTypeOnly || promoteFromTypeOnly2) && shouldUseTypeOnly(namedImport, preferences), /*propertyName*/ void 0, factory.createIdentifier(namedImport.name) @@ -150674,21 +151209,24 @@ function getImportTypePrefix(moduleSpecifier, quotePreference) { function needsTypeOnly({ addAsTypeOnly }) { return addAsTypeOnly === 2 /* Required */; } -function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport, compilerOptions) { +function shouldUseTypeOnly(info, preferences) { + return needsTypeOnly(info) || !!preferences.preferTypeOnlyAutoImports && info.addAsTypeOnly !== 4 /* NotAllowed */; +} +function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport, compilerOptions, preferences) { const quotedModuleSpecifier = makeStringLiteral(moduleSpecifier, quotePreference); let statements; if (defaultImport !== void 0 || (namedImports == null ? void 0 : namedImports.length)) { - const topLevelTypeOnly = (!defaultImport || needsTypeOnly(defaultImport)) && every(namedImports, needsTypeOnly) || compilerOptions.verbatimModuleSyntax && (defaultImport == null ? void 0 : defaultImport.addAsTypeOnly) !== 4 /* NotAllowed */ && !some(namedImports, (i) => i.addAsTypeOnly === 4 /* NotAllowed */); + const topLevelTypeOnly = (!defaultImport || needsTypeOnly(defaultImport)) && every(namedImports, needsTypeOnly) || (compilerOptions.verbatimModuleSyntax || preferences.preferTypeOnlyAutoImports) && (defaultImport == null ? void 0 : defaultImport.addAsTypeOnly) !== 4 /* NotAllowed */ && !some(namedImports, (i) => i.addAsTypeOnly === 4 /* NotAllowed */); statements = combine( statements, makeImport( defaultImport && factory.createIdentifier(defaultImport.name), namedImports == null ? void 0 : namedImports.map( - ({ addAsTypeOnly, name }) => factory.createImportSpecifier( - !topLevelTypeOnly && addAsTypeOnly === 2 /* Required */, + (namedImport) => factory.createImportSpecifier( + !topLevelTypeOnly && shouldUseTypeOnly(namedImport, preferences), /*propertyName*/ void 0, - factory.createIdentifier(name) + factory.createIdentifier(namedImport.name) ) ), moduleSpecifier, @@ -150701,14 +151239,14 @@ function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImp const declaration = namespaceLikeImport.importKind === 3 /* CommonJS */ ? factory.createImportEqualsDeclaration( /*modifiers*/ void 0, - needsTypeOnly(namespaceLikeImport), + shouldUseTypeOnly(namespaceLikeImport, preferences), factory.createIdentifier(namespaceLikeImport.name), factory.createExternalModuleReference(quotedModuleSpecifier) ) : factory.createImportDeclaration( /*modifiers*/ void 0, factory.createImportClause( - needsTypeOnly(namespaceLikeImport), + shouldUseTypeOnly(namespaceLikeImport, preferences), /*name*/ void 0, factory.createNamespaceImport(factory.createIdentifier(namespaceLikeImport.name)) @@ -151451,7 +151989,7 @@ function getInfo8(sourceFile, pos, context, errorCode) { const tag = findAncestor(node, isJsxOpeningLikeElement); const props = checker.getContextualTypeForArgumentAtIndex(tag, 0); suggestedSymbol = checker.getSuggestedSymbolForNonexistentJSXAttribute(node, props); - } else if (hasSyntacticModifier(parent2, 16384 /* Override */) && isClassElement(parent2) && parent2.name === node) { + } else if (hasOverrideModifier(parent2) && isClassElement(parent2) && parent2.name === node) { const baseDeclaration = findAncestor(node, isClassLike); const baseTypeNode = baseDeclaration ? getEffectiveBaseTypeNode(baseDeclaration) : void 0; const baseType = baseTypeNode ? checker.getTypeAtLocation(baseTypeNode) : void 0; @@ -151625,7 +152163,7 @@ function checkFixedAssignableTo(checker, declaration, exprType, type, isFunction if (isFunctionType) { const sig = checker.getSignatureFromDeclaration(declaration); if (sig) { - if (hasSyntacticModifier(declaration, 512 /* Async */)) { + if (hasSyntacticModifier(declaration, 1024 /* Async */)) { exprType = checker.createPromiseType(exprType); } const newSig = checker.createSignature( @@ -151839,13 +152377,13 @@ registerCodeFix({ continue; const { parentDeclaration, declSourceFile, modifierFlags, token, call, isJSFile } = info; if (call && !isPrivateIdentifier(token)) { - addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* Static */, parentDeclaration, declSourceFile); + addMethodDeclaration(context, changes, call, token, modifierFlags & 256 /* Static */, parentDeclaration, declSourceFile); } else { if (isJSFile && !isInterfaceDeclaration(parentDeclaration) && !isTypeLiteralNode(parentDeclaration)) { - addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); + addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 256 /* Static */)); } else { const typeNode = getTypeNode2(checker, parentDeclaration, token); - addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* Static */); + addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 256 /* Static */); } } } @@ -151926,13 +152464,13 @@ function getInfo10(sourceFile, tokenPos, errorCode, checker, program) { const moduleDeclaration = find(symbol.declarations, isModuleDeclaration); const moduleDeclarationSourceFile = moduleDeclaration == null ? void 0 : moduleDeclaration.getSourceFile(); if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) { - return { kind: 2 /* Function */, token, call: parent2.parent, sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration }; + return { kind: 2 /* Function */, token, call: parent2.parent, sourceFile, modifierFlags: 32 /* Export */, parentDeclaration: moduleDeclaration }; } const moduleSourceFile = find(symbol.declarations, isSourceFile); if (sourceFile.commonJsModuleIndicator) return void 0; if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) { - return { kind: 2 /* Function */, token, call: parent2.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile }; + return { kind: 2 /* Function */, token, call: parent2.parent, sourceFile: moduleSourceFile, modifierFlags: 32 /* Export */, parentDeclaration: moduleSourceFile }; } } const classDeclaration = find(symbol.declarations, isClassLike); @@ -151944,7 +152482,7 @@ function getInfo10(sourceFile, tokenPos, errorCode, checker, program) { if (makeStatic && (isPrivateIdentifier(token) || isInterfaceDeclaration(declaration))) return void 0; const declSourceFile = declaration.getSourceFile(); - const modifierFlags = isTypeLiteralNode(declaration) ? 0 /* None */ : (makeStatic ? 32 /* Static */ : 0 /* None */) | (startsWithUnderscore(token.text) ? 8 /* Private */ : 0 /* None */); + const modifierFlags = isTypeLiteralNode(declaration) ? 0 /* None */ : (makeStatic ? 256 /* Static */ : 0 /* None */) | (startsWithUnderscore(token.text) ? 2 /* Private */ : 0 /* None */); const isJSFile = isSourceFileJS(declSourceFile); const call = tryCast(parent2.parent, isCallExpression); return { kind: 0 /* TypeLikeDeclaration */, token, call, modifierFlags, parentDeclaration: declaration, declSourceFile, isJSFile }; @@ -151962,11 +152500,11 @@ function createActionForAddMissingMemberInJavascriptFile(context, { parentDeclar if (isInterfaceDeclaration(parentDeclaration) || isTypeLiteralNode(parentDeclaration)) { return void 0; } - const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */))); + const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 256 /* Static */))); if (changes.length === 0) { return void 0; } - const diagnostic = modifierFlags & 32 /* Static */ ? Diagnostics.Initialize_static_property_0 : isPrivateIdentifier(token) ? Diagnostics.Declare_a_private_field_named_0 : Diagnostics.Initialize_property_0_in_the_constructor; + const diagnostic = modifierFlags & 256 /* Static */ ? Diagnostics.Initialize_static_property_0 : isPrivateIdentifier(token) ? Diagnostics.Declare_a_private_field_named_0 : Diagnostics.Initialize_property_0_in_the_constructor; return createCodeFixAction(fixMissingMember, changes, [diagnostic, token.text], fixMissingMember, Diagnostics.Add_all_missing_members); } function addMissingMemberInJs(changeTracker, sourceFile, classDeclaration, token, makeStatic) { @@ -152010,15 +152548,15 @@ function initializePropertyToUndefined(obj, propertyName) { } function createActionsForAddMissingMemberInTypeScriptFile(context, { parentDeclaration, declSourceFile, modifierFlags, token }) { const memberName = token.text; - const isStatic2 = modifierFlags & 32 /* Static */; + const isStatic2 = modifierFlags & 256 /* Static */; const typeNode = getTypeNode2(context.program.getTypeChecker(), parentDeclaration, token); const addPropertyDeclarationChanges = (modifierFlags2) => ts_textChanges_exports.ChangeTracker.with(context, (t) => addPropertyDeclaration(t, declSourceFile, parentDeclaration, memberName, typeNode, modifierFlags2)); - const actions2 = [createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* Static */), [isStatic2 ? Diagnostics.Declare_static_property_0 : Diagnostics.Declare_property_0, memberName], fixMissingMember, Diagnostics.Add_all_missing_members)]; + const actions2 = [createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 256 /* Static */), [isStatic2 ? Diagnostics.Declare_static_property_0 : Diagnostics.Declare_property_0, memberName], fixMissingMember, Diagnostics.Add_all_missing_members)]; if (isStatic2 || isPrivateIdentifier(token)) { return actions2; } - if (modifierFlags & 8 /* Private */) { - actions2.unshift(createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* Private */), [Diagnostics.Declare_private_property_0, memberName])); + if (modifierFlags & 2 /* Private */) { + actions2.unshift(createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(2 /* Private */), [Diagnostics.Declare_private_property_0, memberName])); } actions2.push(createAddIndexSignatureAction(context, declSourceFile, parentDeclaration, token.text, typeNode)); return actions2; @@ -152105,9 +152643,9 @@ function getActionsForMissingMethodDeclaration(context, info) { } const methodName = token.text; const addMethodDeclarationChanges = (modifierFlags2) => ts_textChanges_exports.ChangeTracker.with(context, (t) => addMethodDeclaration(context, t, call, token, modifierFlags2, parentDeclaration, declSourceFile)); - const actions2 = [createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* Static */), [modifierFlags & 32 /* Static */ ? Diagnostics.Declare_static_method_0 : Diagnostics.Declare_method_0, methodName], fixMissingMember, Diagnostics.Add_all_missing_members)]; - if (modifierFlags & 8 /* Private */) { - actions2.unshift(createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* Private */), [Diagnostics.Declare_private_method_0, methodName])); + const actions2 = [createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 256 /* Static */), [modifierFlags & 256 /* Static */ ? Diagnostics.Declare_static_method_0 : Diagnostics.Declare_method_0, methodName], fixMissingMember, Diagnostics.Add_all_missing_members)]; + if (modifierFlags & 2 /* Private */) { + actions2.unshift(createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(2 /* Private */), [Diagnostics.Declare_private_method_0, methodName])); } return actions2; } @@ -152523,7 +153061,7 @@ function addMissingMembers(classDeclaration, sourceFile, context, changeTracker, } function symbolPointsToNonPrivateAndAbstractMember(symbol) { const flags = getSyntacticModifierFlags(first(symbol.getDeclarations())); - return !(flags & 8 /* Private */) && !!(flags & 256 /* Abstract */); + return !(flags & 2 /* Private */) && !!(flags & 64 /* Abstract */); } // src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts @@ -154857,10 +155395,10 @@ function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, con const kind = (declaration == null ? void 0 : declaration.kind) ?? 171 /* PropertySignature */; const declarationName = createDeclarationName(symbol, declaration); const effectiveModifierFlags = declaration ? getEffectiveModifierFlags(declaration) : 0 /* None */; - let modifierFlags = effectiveModifierFlags & 32 /* Static */; - modifierFlags |= effectiveModifierFlags & 4 /* Public */ ? 4 /* Public */ : effectiveModifierFlags & 16 /* Protected */ ? 16 /* Protected */ : 0 /* None */; + let modifierFlags = effectiveModifierFlags & 256 /* Static */; + modifierFlags |= effectiveModifierFlags & 1 /* Public */ ? 1 /* Public */ : effectiveModifierFlags & 4 /* Protected */ ? 4 /* Protected */ : 0 /* None */; if (declaration && isAutoAccessorPropertyDeclaration(declaration)) { - modifierFlags |= 128 /* Accessor */; + modifierFlags |= 512 /* Accessor */; } const modifiers = createModifiers(); const type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); @@ -155526,24 +156064,24 @@ function createAccessorAccessExpression(fieldName, isStatic2, container) { return isIdentifier(fieldName) ? factory.createPropertyAccessExpression(leftHead, fieldName) : factory.createElementAccessExpression(leftHead, factory.createStringLiteralFromNode(fieldName)); } function prepareModifierFlagsForAccessor(modifierFlags) { - modifierFlags &= ~64 /* Readonly */; - modifierFlags &= ~8 /* Private */; - if (!(modifierFlags & 16 /* Protected */)) { - modifierFlags |= 4 /* Public */; + modifierFlags &= ~8 /* Readonly */; + modifierFlags &= ~2 /* Private */; + if (!(modifierFlags & 4 /* Protected */)) { + modifierFlags |= 1 /* Public */; } return modifierFlags; } function prepareModifierFlagsForField(modifierFlags) { - modifierFlags &= ~4 /* Public */; - modifierFlags &= ~16 /* Protected */; - modifierFlags |= 8 /* Private */; + modifierFlags &= ~1 /* Public */; + modifierFlags &= ~4 /* Protected */; + modifierFlags |= 2 /* Private */; return modifierFlags; } function getAccessorConvertiblePropertyAtPosition(file, program, start2, end, considerEmptySpans = true) { const node = getTokenAtPosition(file, start2); const cursorRequest = start2 === end && considerEmptySpans; const declaration = findAncestor(node.parent, isAcceptedDeclaration); - const meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */; + const meaning = 7 /* AccessibilityModifier */ | 256 /* Static */ | 8 /* Readonly */; if (!declaration || !(nodeOverlapsWithStartEnd(declaration.name, file, start2, end) || cursorRequest)) { return { error: getLocaleSpecificMessage(Diagnostics.Could_not_find_property_for_which_to_generate_accessor) @@ -155554,7 +156092,7 @@ function getAccessorConvertiblePropertyAtPosition(file, program, start2, end, co error: getLocaleSpecificMessage(Diagnostics.Name_is_not_valid) }; } - if ((getEffectiveModifierFlags(declaration) & 126975 /* Modifier */ | meaning) !== meaning) { + if ((getEffectiveModifierFlags(declaration) & 98303 /* Modifier */ | meaning) !== meaning) { return { error: getLocaleSpecificMessage(Diagnostics.Can_only_convert_property_with_modifier) }; @@ -155924,7 +156462,7 @@ function getDefaultValueFromType(checker, type) { return firstDefined(type.types, (t) => getDefaultValueFromType(checker, t)); } else if (type.isClass()) { const classDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); - if (!classDeclaration || hasSyntacticModifier(classDeclaration, 256 /* Abstract */)) + if (!classDeclaration || hasSyntacticModifier(classDeclaration, 64 /* Abstract */)) return void 0; const constructorDeclaration = getFirstConstructorWithBody(classDeclaration); if (constructorDeclaration && constructorDeclaration.parameters.length) @@ -157214,7 +157752,7 @@ function completionInfoFromData(sourceFile, host, program, compilerOptions, log, ); if (keywordFilters !== 0 /* None */) { for (const keywordEntry of getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && isSourceFileJS(sourceFile))) { - if (isTypeOnlyLocation && isTypeKeyword(stringToToken(keywordEntry.name)) || !uniqueNames.has(keywordEntry.name)) { + if (isTypeOnlyLocation && isTypeKeyword(stringToToken(keywordEntry.name)) || !isTypeOnlyLocation && isContextualKeywordInAutoImportableExpressionSpace(keywordEntry.name) || !uniqueNames.has(keywordEntry.name)) { uniqueNames.add(keywordEntry.name); insertSorted( entries, @@ -157641,7 +158179,7 @@ function getEntryForMemberCompletion(host, program, options, preferences, name, } let modifiers = 0 /* None */; const { modifiers: presentModifiers, range: eraseRange, decorators: presentDecorators } = getPresentModifiers(contextToken, sourceFile, position); - const isAbstract = presentModifiers & 256 /* Abstract */ && classLikeDeclaration.modifierFlagsCache & 256 /* Abstract */; + const isAbstract = presentModifiers & 64 /* Abstract */ && classLikeDeclaration.modifierFlagsCache & 64 /* Abstract */; let completionNodes = []; ts_codefix_exports.addNewNodeForMemberSymbol( symbol, @@ -157660,15 +158198,15 @@ function getEntryForMemberCompletion(host, program, options, preferences, name, (node) => { let requiredModifiers = 0 /* None */; if (isAbstract) { - requiredModifiers |= 256 /* Abstract */; + requiredModifiers |= 64 /* Abstract */; } if (isClassElement(node) && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node, symbol) === 1 /* NeedsOverride */) { - requiredModifiers |= 16384 /* Override */; + requiredModifiers |= 16 /* Override */; } if (!completionNodes.length) { modifiers = node.modifierFlagsCache | requiredModifiers; } - node = factory.updateModifiers(node, modifiers); + node = factory.replaceModifiers(node, modifiers); completionNodes.push(node); }, body, @@ -157677,28 +158215,28 @@ function getEntryForMemberCompletion(host, program, options, preferences, name, ); if (completionNodes.length) { const isMethod = symbol.flags & 8192 /* Method */; - let allowedModifiers = modifiers | 16384 /* Override */ | 4 /* Public */; + let allowedModifiers = modifiers | 16 /* Override */ | 1 /* Public */; if (!isMethod) { - allowedModifiers |= 2 /* Ambient */ | 64 /* Readonly */; + allowedModifiers |= 128 /* Ambient */ | 8 /* Readonly */; } else { - allowedModifiers |= 512 /* Async */; + allowedModifiers |= 1024 /* Async */; } const allowedAndPresent = presentModifiers & allowedModifiers; if (presentModifiers & ~allowedModifiers) { return void 0; } - if (modifiers & 16 /* Protected */ && allowedAndPresent & 4 /* Public */) { - modifiers &= ~16 /* Protected */; + if (modifiers & 4 /* Protected */ && allowedAndPresent & 1 /* Public */) { + modifiers &= ~4 /* Protected */; } - if (allowedAndPresent !== 0 /* None */ && !(allowedAndPresent & 4 /* Public */)) { - modifiers &= ~4 /* Public */; + if (allowedAndPresent !== 0 /* None */ && !(allowedAndPresent & 1 /* Public */)) { + modifiers &= ~1 /* Public */; } modifiers |= allowedAndPresent; - completionNodes = completionNodes.map((node) => factory.updateModifiers(node, modifiers)); + completionNodes = completionNodes.map((node) => factory.replaceModifiers(node, modifiers)); if (presentDecorators == null ? void 0 : presentDecorators.length) { const lastNode = completionNodes[completionNodes.length - 1]; if (canHaveDecorators(lastNode)) { - completionNodes[completionNodes.length - 1] = factory.updateModifierLike(lastNode, presentDecorators.concat(getModifiers(lastNode) || [])); + completionNodes[completionNodes.length - 1] = factory.replaceDecoratorsAndModifiers(lastNode, presentDecorators.concat(getModifiers(lastNode) || [])); } } const format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */; @@ -157728,7 +158266,7 @@ function getPresentModifiers(contextToken, sourceFile, position) { let contextMod; const range = { pos: position, end: position }; if (isPropertyDeclaration(contextToken.parent) && contextToken.parent.modifiers) { - modifiers |= modifiersToFlags(contextToken.parent.modifiers) & 126975 /* Modifier */; + modifiers |= modifiersToFlags(contextToken.parent.modifiers) & 98303 /* Modifier */; decorators = contextToken.parent.modifiers.filter(isDecorator) || []; range.pos = Math.min(range.pos, contextToken.parent.modifiers.pos); } @@ -158303,7 +158841,7 @@ function getCompletionEntryDetails(program, log, sourceFile, position, entryId, return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* string */, typeof literal === "string" ? 8 /* stringLiteral */ : 7 /* numericLiteral */); } case "cases": { - const { entry, importAdder } = getExhaustiveCaseSnippets( + const snippets = getExhaustiveCaseSnippets( contextToken.parent, sourceFile, preferences, @@ -158313,7 +158851,8 @@ function getCompletionEntryDetails(program, log, sourceFile, position, entryId, /*formatContext*/ void 0 ); - if (importAdder.hasFixes()) { + if (snippets == null ? void 0 : snippets.importAdder.hasFixes()) { + const { entry, importAdder } = snippets; const changes = ts_textChanges_exports.ChangeTracker.with( { host, formatContext, preferences }, importAdder.writeFixes @@ -158331,7 +158870,7 @@ function getCompletionEntryDetails(program, log, sourceFile, position, entryId, }; } return { - name: entry.name, + name, kind: "" /* unknown */, kindModifiers: "", displayParts: [], @@ -159477,24 +160016,24 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position, if (contextToken.kind === 80 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": - classElementModifierFlags = classElementModifierFlags | 8 /* Private */; + classElementModifierFlags = classElementModifierFlags | 2 /* Private */; break; case "static": - classElementModifierFlags = classElementModifierFlags | 32 /* Static */; + classElementModifierFlags = classElementModifierFlags | 256 /* Static */; break; case "override": - classElementModifierFlags = classElementModifierFlags | 16384 /* Override */; + classElementModifierFlags = classElementModifierFlags | 16 /* Override */; break; } } if (isClassStaticBlockDeclaration(classElement)) { - classElementModifierFlags |= 32 /* Static */; + classElementModifierFlags |= 256 /* Static */; } - if (!(classElementModifierFlags & 8 /* Private */)) { - const baseTypeNodes = isClassLike(decl) && classElementModifierFlags & 16384 /* Override */ ? singleElementArray(getEffectiveBaseTypeNode(decl)) : getAllSuperTypeNodes(decl); + if (!(classElementModifierFlags & 2 /* Private */)) { + const baseTypeNodes = isClassLike(decl) && classElementModifierFlags & 16 /* Override */ ? singleElementArray(getEffectiveBaseTypeNode(decl)) : getAllSuperTypeNodes(decl); const baseSymbols = flatMap(baseTypeNodes, (baseTypeNode) => { const type = typeChecker.getTypeAtLocation(baseTypeNode); - return classElementModifierFlags & 32 /* Static */ ? (type == null ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : type && typeChecker.getPropertiesOfType(type); + return classElementModifierFlags & 256 /* Static */ ? (type == null ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : type && typeChecker.getPropertiesOfType(type); }); symbols = concatenate(symbols, filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags)); forEach(symbols, (symbol, index) => { @@ -159797,10 +160336,10 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position, if (isCurrentlyEditingNode(m)) { continue; } - if (hasEffectiveModifier(m, 8 /* Private */)) { + if (hasEffectiveModifier(m, 2 /* Private */)) { continue; } - if (isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* Static */)) { + if (isStatic(m) !== !!(currentClassElementModifierFlags & 256 /* Static */)) { continue; } const existingName = getPropertyNameForPropertyNameNode(m.name); @@ -159809,7 +160348,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position, } } return baseSymbols.filter( - (propertySymbol) => !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && !(getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) && !(propertySymbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration)) + (propertySymbol) => !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && !(getDeclarationModifierFlagsFromSymbol(propertySymbol) & 2 /* Private */) && !(propertySymbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration)) ); } function filterJsxAttributes(symbols2, attributes) { @@ -160071,7 +160610,7 @@ function getApparentProperties(type, node, checker) { return checker.getAllPossiblePropertiesOfTypes(filter(type.types, (memberType) => !(memberType.flags & 402784252 /* Primitive */ || checker.isArrayLikeType(memberType) || checker.isTypeInvalidDueToUnionDiscriminant(memberType, node) || checker.typeHasCallOrConstructSignatures(memberType) || memberType.isClass() && containsNonPublicProperties(memberType.getApparentProperties())))); } function containsNonPublicProperties(props) { - return some(props, (p) => !!(getDeclarationModifierFlagsFromSymbol(p) & 24 /* NonPublicAccessibilityModifier */)); + return some(props, (p) => !!(getDeclarationModifierFlagsFromSymbol(p) & 6 /* NonPublicAccessibilityModifier */)); } function getPropertiesForCompletion(type, checker) { return type.isUnion() ? Debug.checkEachDefined(checker.getAllPossiblePropertiesOfTypes(type.types), "getAllPossiblePropertiesOfTypes() should all be defined") : Debug.checkEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); @@ -160231,7 +160770,7 @@ function isProbablyGlobalType(type, sourceFile, checker) { return false; } function isStaticProperty(symbol) { - return !!(symbol.valueDeclaration && getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* Static */ && isClassLike(symbol.valueDeclaration.parent)); + return !!(symbol.valueDeclaration && getEffectiveModifierFlags(symbol.valueDeclaration) & 256 /* Static */ && isClassLike(symbol.valueDeclaration.parent)); } function tryGetObjectLiteralContextualType(node, typeChecker) { const type = typeChecker.getContextualType(node); @@ -160402,6 +160941,9 @@ function toUpperCharCode(charCode) { } return charCode; } +function isContextualKeywordInAutoImportableExpressionSpace(keyword) { + return keyword === "abstract" || keyword === "async" || keyword === "await" || keyword === "declare" || keyword === "module" || keyword === "namespace" || keyword === "type"; +} // src/services/_namespaces/ts.Completions.StringCompletions.ts var ts_Completions_StringCompletions_exports = {}; @@ -161028,7 +161570,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, c } const keys = getOwnKeys(exports); const fragmentSubpath = components.join("/") + (components.length && hasTrailingDirectorySeparator(fragment) ? "/" : ""); - const conditions = getConditions(compilerOptions, mode === 99 /* ESNext */); + const conditions = getConditions(compilerOptions, mode); addCompletionEntriesFromPathsOrExports( result, fragmentSubpath, @@ -161361,7 +161903,7 @@ function getImportersForExport(sourceFiles, sourceFilesSet, allDirectImports, { handleNamespaceImport( direct, direct.name, - hasSyntacticModifier(direct, 1 /* Export */), + hasSyntacticModifier(direct, 32 /* Export */), /*alreadyAddedDirect*/ false ); @@ -161676,7 +162218,7 @@ function getImportOrExportSymbol(node, symbol, checker, comingFromExport) { } } else { const exportNode = getExportNode(parent2, node); - if (exportNode && hasSyntacticModifier(exportNode, 1 /* Export */)) { + if (exportNode && hasSyntacticModifier(exportNode, 32 /* Export */)) { if (isImportEqualsDeclaration(exportNode) && exportNode.moduleReference === node) { if (comingFromExport) { return void 0; @@ -161753,7 +162295,7 @@ function getImportOrExportSymbol(node, symbol, checker, comingFromExport) { return exportInfo2 && { kind: 1 /* Export */, symbol: symbol2, exportInfo: exportInfo2 }; } function getExportKindForDeclaration(node2) { - return hasSyntacticModifier(node2, 1024 /* Default */) ? 1 /* Default */ : 0 /* Named */; + return hasSyntacticModifier(node2, 2048 /* Default */) ? 1 /* Default */ : 0 /* Named */; } } function getExportEqualsLocalSymbol(importedSymbol, checker) { @@ -161896,7 +162438,7 @@ function getContextNodeForNodeEntry(node) { if (node.parent.name === node || // node is name of declaration, use parent isConstructorDeclaration(node.parent) || isExportAssignment(node.parent) || // Property name of the import export specifier or binding pattern, use parent (isImportOrExportSpecifier(node.parent) || isBindingElement(node.parent)) && node.parent.propertyName === node || // Is default export - node.kind === 90 /* DefaultKeyword */ && hasSyntacticModifier(node.parent, 1025 /* ExportDefault */)) { + node.kind === 90 /* DefaultKeyword */ && hasSyntacticModifier(node.parent, 2080 /* ExportDefault */)) { return getContextNode(node.parent); } return void 0; @@ -162857,7 +163399,7 @@ var Core; return void 0; } if (flags & (4 /* Property */ | 8192 /* Method */)) { - const privateDeclaration = find(declarations, (d) => hasEffectiveModifier(d, 8 /* Private */) || isPrivateIdentifierClassElementDeclaration(d)); + const privateDeclaration = find(declarations, (d) => hasEffectiveModifier(d, 2 /* Private */) || isPrivateIdentifierClassElementDeclaration(d)); if (privateDeclaration) { return getAncestor(privateDeclaration, 263 /* ClassDeclaration */); } @@ -163367,7 +163909,7 @@ var Core; if (!searchSpaceNode) { return void 0; } - let staticFlag = 32 /* Static */; + let staticFlag = 256 /* Static */; switch (searchSpaceNode.kind) { case 172 /* PropertyDeclaration */: case 171 /* PropertySignature */: @@ -163407,7 +163949,7 @@ var Core; /*includeClassComputedPropertyName*/ false ); - let staticFlag = 32 /* Static */; + let staticFlag = 256 /* Static */; switch (searchSpaceNode.kind) { case 174 /* MethodDeclaration */: case 173 /* MethodSignature */: @@ -163649,7 +164191,7 @@ var Core; if (!symbol.valueDeclaration) return false; const modifierFlags = getEffectiveModifierFlags(symbol.valueDeclaration); - return !!(modifierFlags & 32 /* Static */); + return !!(modifierFlags & 256 /* Static */); } function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { const { checker } = state; @@ -164199,7 +164741,7 @@ function isDefinitionVisible(checker, declaration) { case 177 /* GetAccessor */: case 178 /* SetAccessor */: case 174 /* MethodDeclaration */: - if (hasEffectiveModifier(declaration, 8 /* Private */)) + if (hasEffectiveModifier(declaration, 2 /* Private */)) return false; case 176 /* Constructor */: case 303 /* PropertyAssignment */: @@ -164283,6 +164825,7 @@ function provideInlayHints(context) { const { file, program, span, cancellationToken, preferences } = context; const sourceFileText = file.text; const compilerOptions = program.getCompilerOptions(); + const quotePreference = getQuotePreference(file, preferences); const checker = program.getTypeChecker(); const result = []; visitor(file); @@ -164590,6 +165133,10 @@ function provideInlayHints(context) { parts.push({ text: tokenString }); return; } + if (isLiteralExpression(node)) { + parts.push({ text: getLiteralText2(node) }); + return; + } switch (node.kind) { case 80 /* Identifier */: const identifier = node; @@ -164601,12 +165148,6 @@ function provideInlayHints(context) { parts.push({ text: identifierText }); } break; - case 9 /* NumericLiteral */: - parts.push({ text: node.text }); - break; - case 11 /* StringLiteral */: - parts.push({ text: `"${node.text}"` }); - break; case 166 /* QualifiedName */: const qualifiedName = node; visitForDisplayParts(qualifiedName.left); @@ -164862,6 +165403,12 @@ function provideInlayHints(context) { visitForDisplayParts(node); }); } + function getLiteralText2(node) { + if (isStringLiteral(node)) { + return quotePreference === 0 /* Single */ ? `'${escapeString(node.text, 39 /* singleQuote */)}'` : `"${escapeString(node.text, 34 /* doubleQuote */)}"`; + } + return node.text; + } } function isUndefined(name) { return name === "undefined"; @@ -165015,6 +165562,10 @@ function getCommentHavingNodes(declaration) { case 345 /* JSDocCallbackTag */: case 353 /* JSDocTypedefTag */: return [declaration, declaration.parent]; + case 330 /* JSDocSignature */: + if (isJSDocOverloadTag(declaration.parent)) { + return [declaration.parent.parent]; + } default: return getJSDocCommentsAndTags(declaration); } @@ -166155,7 +166706,6 @@ function getOutliningSpanForNode(n, sourceFile) { case 275 /* NamedImports */: case 279 /* NamedExports */: case 300 /* ImportAttributes */: - case 300 /* AssertClause */: return spanForImportExportElements(n); } function spanForImportExportElements(node) { @@ -167271,7 +167821,7 @@ function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeCheck function getNormalizedSymbolModifiers(symbol) { if (symbol.declarations && symbol.declarations.length) { const [declaration, ...declarations] = symbol.declarations; - const excludeFlags = length(declarations) && isDeprecatedDeclaration(declaration) && some(declarations, (d) => !isDeprecatedDeclaration(d)) ? 8192 /* Deprecated */ : 0 /* None */; + const excludeFlags = length(declarations) && isDeprecatedDeclaration(declaration) && some(declarations, (d) => !isDeprecatedDeclaration(d)) ? 65536 /* Deprecated */ : 0 /* None */; const modifiers = getNodeModifiers(declaration, excludeFlags); if (modifiers) { return modifiers.split(","); @@ -167547,7 +168097,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb const resolvedNode = resolvedSymbol.declarations[0]; const declarationName = getNameOfDeclaration(resolvedNode); if (declarationName && !hasAddedSymbolInfo) { - const isExternalModuleDeclaration = isModuleWithStringLiteralName(resolvedNode) && hasSyntacticModifier(resolvedNode, 2 /* Ambient */); + const isExternalModuleDeclaration = isModuleWithStringLiteralName(resolvedNode) && hasSyntacticModifier(resolvedNode, 128 /* Ambient */); const shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration; const resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKindWorker( typeChecker, @@ -171933,7 +172483,6 @@ __export(ts_exports2, { CompletionInfoFlags: () => CompletionInfoFlags, CompletionTriggerKind: () => CompletionTriggerKind, Completions: () => ts_Completions_exports, - ConfigFileProgramReloadLevel: () => ConfigFileProgramReloadLevel, ContainerFlags: () => ContainerFlags, ContextFlags: () => ContextFlags, Debug: () => Debug, @@ -172020,6 +172569,7 @@ __export(ts_exports2, { PragmaKindFlags: () => PragmaKindFlags, PrivateIdentifierKind: () => PrivateIdentifierKind, ProcessLevel: () => ProcessLevel, + ProgramUpdateLevel: () => ProgramUpdateLevel, QuotePreference: () => QuotePreference, RelationComparisonResult: () => RelationComparisonResult, Rename: () => ts_Rename_exports, @@ -174411,6 +174961,7 @@ __export(ts_server_exports3, { hasArgument: () => hasArgument, hasNoTypeScriptSource: () => hasNoTypeScriptSource, indent: () => indent2, + isBackgroundProject: () => isBackgroundProject, isConfigFile: () => isConfigFile, isConfiguredProject: () => isConfiguredProject, isDynamicFileName: () => isDynamicFileName, @@ -174528,7 +175079,7 @@ var TypingsInstaller = class { } install(req) { if (this.log.isEnabled()) { - this.log.writeLine(`Got install request ${JSON.stringify(req)}`); + this.log.writeLine(`Got install request${stringifyIndented(req)}`); } if (req.cachePath) { if (this.log.isEnabled()) { @@ -174551,9 +175102,6 @@ var TypingsInstaller = class { this.typesRegistry, req.compilerOptions ); - if (this.log.isEnabled()) { - this.log.writeLine(`Finished typings discovery: ${JSON.stringify(discoverTypingsResult)}`); - } this.watchFiles(req.projectName, discoverTypingsResult.filesToWatch); if (discoverTypingsResult.newTypingNames.length) { this.installTypings(req, req.cachePath || this.globalCachePath, discoverTypingsResult.cachedTypingPaths, discoverTypingsResult.newTypingNames); @@ -174595,8 +175143,8 @@ var TypingsInstaller = class { const npmConfig = JSON.parse(this.installTypingHost.readFile(packageJson)); const npmLock = JSON.parse(this.installTypingHost.readFile(packageLockJson)); if (this.log.isEnabled()) { - this.log.writeLine(`Loaded content of '${packageJson}': ${JSON.stringify(npmConfig)}`); - this.log.writeLine(`Loaded content of '${packageLockJson}'`); + this.log.writeLine(`Loaded content of '${packageJson}':${stringifyIndented(npmConfig)}`); + this.log.writeLine(`Loaded content of '${packageLockJson}':${stringifyIndented(npmLock)}`); } if (npmConfig.devDependencies && npmLock.dependencies) { for (const key in npmConfig.devDependencies) { @@ -174973,13 +175521,6 @@ function removeSorted(array, remove, compare) { array.splice(removeIndex, 1); } } -var indentStr = "\n "; -function indent2(str) { - return indentStr + str.replace(/\n/g, indentStr); -} -function stringifyIndented(json) { - return indentStr + JSON.stringify(json); -} // src/server/_namespaces/ts.server.protocol.ts var ts_server_protocol_exports = {}; @@ -175678,7 +176219,7 @@ var ScriptInfo = class { isContainedByBackgroundProject() { return some( this.containingProjects, - (p) => p.projectKind === 3 /* AutoImportProvider */ || p.projectKind === 4 /* Auxiliary */ + isBackgroundProject ); } /** @@ -175709,7 +176250,7 @@ var ScriptInfo = class { } }; function ensurePrimaryProjectKind(project) { - if (!project || project.projectKind === 3 /* AutoImportProvider */ || project.projectKind === 4 /* Auxiliary */) { + if (!project || isBackgroundProject(project)) { return Errors.ThrowNoProject(); } return project; @@ -175995,9 +176536,10 @@ var Project3 = class _Project { this.disableLanguageService(lastFileExceededProgramSize); } this.markAsDirty(); - if (projectKind !== 3 /* AutoImportProvider */) { + if (!isBackgroundProject(this)) { this.projectService.pendingEnsureProjectForOpenFiles = true; } + this.projectService.onProjectCreation(this); } /** @internal */ getResolvedProjectReferenceToRedirect(_fileName) { @@ -176167,6 +176709,7 @@ var Project3 = class _Project { resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames) { return this.resolutionCache.resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames); } + /** @internal */ getModuleResolutionCache() { return this.resolutionCache.getModuleResolutionCache(); } @@ -176432,12 +176975,12 @@ var Project3 = class _Project { } return { ...newTypeAcquisition, include: this.removeExistingTypings(newTypeAcquisition.include) }; } - getExternalFiles() { + getExternalFiles(updateLevel) { return sort(flatMap(this.plugins, (plugin) => { if (typeof plugin.module.getExternalFiles !== "function") return; try { - return plugin.module.getExternalFiles(this); + return plugin.module.getExternalFiles(this, updateLevel || 0 /* Update */); } catch (e) { this.projectService.logger.info(`A plugin threw an exception in getExternalFiles: ${e}`); if (e.stack) { @@ -177172,6 +177715,7 @@ var Project3 = class _Project { } /** @internal */ getChangesSinceVersion(lastKnownVersion, includeProjectReferenceRedirectInfo) { + var _a, _b; const includeProjectReferenceRedirectInfoIfRequested = includeProjectReferenceRedirectInfo ? (files) => arrayFrom(files.entries(), ([fileName, isSourceOfProjectReferenceRedirect]) => ({ fileName, isSourceOfProjectReferenceRedirect @@ -177194,10 +177738,10 @@ var Project3 = class _Project { return { info, projectErrors: this.getGlobalProjectErrors() }; } const lastReportedFileNames = this.lastReportedFileNames; - const externalFiles = this.getExternalFiles().map((f) => ({ + const externalFiles = ((_a = this.externalFiles) == null ? void 0 : _a.map((f) => ({ fileName: toNormalizedPath(f), isSourceOfProjectReferenceRedirect: false - })); + }))) || emptyArray2; const currentFiles = arrayToMap( this.getFileNamesWithRedirectInfo(!!includeProjectReferenceRedirectInfo).concat(externalFiles), (info2) => info2.fileName, @@ -177239,10 +177783,10 @@ var Project3 = class _Project { }; } else { const projectFileNames = this.getFileNamesWithRedirectInfo(!!includeProjectReferenceRedirectInfo); - const externalFiles = this.getExternalFiles().map((f) => ({ + const externalFiles = ((_b = this.externalFiles) == null ? void 0 : _b.map((f) => ({ fileName: toNormalizedPath(f), isSourceOfProjectReferenceRedirect: false - })); + }))) || emptyArray2; const allFiles = projectFileNames.concat(externalFiles); this.lastReportedFileNames = arrayToMap( allFiles, @@ -177444,32 +177988,15 @@ var Project3 = class _Project { return this.projectService.getIncompleteCompletionsCache(); } /** @internal */ - getNoDtsResolutionProject(rootFileNames) { + getNoDtsResolutionProject(rootFile) { Debug.assert(this.projectService.serverMode === 0 /* Semantic */); if (!this.noDtsResolutionProject) { this.noDtsResolutionProject = new AuxiliaryProject(this.projectService, this.documentRegistry, this.getCompilerOptionsForNoDtsResolutionProject(), this.currentDirectory); } - enumerateInsertsAndDeletes( - rootFileNames.map(toNormalizedPath), - this.noDtsResolutionProject.getRootFiles(), - getStringComparer(!this.useCaseSensitiveFileNames()), - (pathToAdd) => { - const info = this.projectService.getOrCreateScriptInfoNotOpenedByClient( - pathToAdd, - this.currentDirectory, - this.noDtsResolutionProject.directoryStructureHost - ); - if (info) { - this.noDtsResolutionProject.addRoot(info, pathToAdd); - } - }, - (pathToRemove) => { - const info = this.noDtsResolutionProject.getScriptInfo(pathToRemove); - if (info) { - this.noDtsResolutionProject.removeRoot(info); - } - } - ); + if (this.noDtsResolutionProject.rootFile !== rootFile) { + this.projectService.setFileNamesOfAutpImportProviderOrAuxillaryProject(this.noDtsResolutionProject, [rootFile]); + this.noDtsResolutionProject.rootFile = rootFile; + } return this.noDtsResolutionProject; } /** @internal */ @@ -177801,7 +178328,7 @@ var _AutoImportProviderProject = class _AutoImportProviderProject extends Projec this.getCompilationSettings() ); } - this.projectService.setFileNamesOfAutoImportProviderProject(this, rootFileNames); + this.projectService.setFileNamesOfAutpImportProviderOrAuxillaryProject(this, rootFileNames); this.rootFileNames = rootFileNames; const oldProgram = this.getCurrentProgram(); const hasSameSetOfFiles = super.updateGraph(); @@ -177846,9 +178373,6 @@ var _AutoImportProviderProject = class _AutoImportProviderProject extends Projec includePackageJsonAutoImports() { return 0 /* Off */; } - getTypeAcquisition() { - return { enable: false }; - } /** @internal */ getSymlinkCache() { return this.hostProject.getSymlinkCache(); @@ -177946,18 +178470,18 @@ var ConfiguredProject2 = class extends Project3 { updateGraph() { const isInitialLoad = this.isInitialLoadPending(); this.isInitialLoadPending = returnFalse; - const reloadLevel = this.pendingReload; - this.pendingReload = 0 /* None */; + const updateLevel = this.pendingUpdateLevel; + this.pendingUpdateLevel = 0 /* Update */; let result; - switch (reloadLevel) { - case 1 /* Partial */: + switch (updateLevel) { + case 1 /* RootNamesAndUpdate */: this.openFileWatchTriggered.clear(); result = this.projectService.reloadFileNamesOfConfiguredProject(this); break; case 2 /* Full */: this.openFileWatchTriggered.clear(); - const reason = Debug.checkDefined(this.pendingReloadReason); - this.pendingReloadReason = void 0; + const reason = Debug.checkDefined(this.pendingUpdateReason); + this.pendingUpdateReason = void 0; this.projectService.reloadConfiguredProject( this, reason, @@ -178157,6 +178681,9 @@ function isConfiguredProject(project) { function isExternalProject(project) { return project.projectKind === 2 /* External */; } +function isBackgroundProject(project) { + return project.projectKind === 3 /* AutoImportProvider */ || project.projectKind === 4 /* Auxiliary */; +} // src/server/editorServices.ts var maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; @@ -178597,6 +179124,8 @@ var _ProjectService = class _ProjectService { this.verifyDocumentRegistry = noop; /** @internal */ this.verifyProgram = noop; + /** @internal */ + this.onProjectCreation = noop; var _a; this.host = opts.host; this.logger = opts.logger; @@ -178764,20 +179293,20 @@ var _ProjectService = class _ProjectService { } delayUpdateProjectGraph(project) { project.markAsDirty(); - if (project.projectKind !== 3 /* AutoImportProvider */ && project.projectKind !== 4 /* Auxiliary */) { - const projectName = project.getProjectName(); - this.pendingProjectUpdates.set(projectName, project); - this.throttledOperations.schedule( - projectName, - /*delay*/ - 250, - () => { - if (this.pendingProjectUpdates.delete(projectName)) { - updateProjectIfDirty(project); - } + if (isBackgroundProject(project)) + return; + const projectName = project.getProjectName(); + this.pendingProjectUpdates.set(projectName, project); + this.throttledOperations.schedule( + projectName, + /*delay*/ + 250, + () => { + if (this.pendingProjectUpdates.delete(projectName)) { + updateProjectIfDirty(project); } - ); - } + } + ); } /** @internal */ hasPendingProjectUpdate(project) { @@ -179053,28 +179582,28 @@ var _ProjectService = class _ProjectService { getScriptKind: configuredProjectForConfig ? (fileName) => configuredProjectForConfig.getScriptKind(fileName) : void 0 })) return; - if (config.reloadLevel !== 2 /* Full */) - config.reloadLevel = 1 /* Partial */; + if (config.updateLevel !== 2 /* Full */) + config.updateLevel = 1 /* RootNamesAndUpdate */; config.projects.forEach((watchWildcardDirectories, projectCanonicalPath) => { if (!watchWildcardDirectories) return; const project = this.getConfiguredProjectByCanonicalConfigFilePath(projectCanonicalPath); if (!project) return; - const reloadLevel = configuredProjectForConfig === project ? 1 /* Partial */ : 0 /* None */; - if (project.pendingReload !== void 0 && project.pendingReload > reloadLevel) + const updateLevel = configuredProjectForConfig === project ? 1 /* RootNamesAndUpdate */ : 0 /* Update */; + if (project.pendingUpdateLevel !== void 0 && project.pendingUpdateLevel > updateLevel) return; if (this.openFiles.has(fileOrDirectoryPath)) { const info = Debug.checkDefined(this.getScriptInfoForPath(fileOrDirectoryPath)); if (info.isAttached(project)) { - const loadLevelToSet = Math.max(reloadLevel, project.openFileWatchTriggered.get(fileOrDirectoryPath) || 0 /* None */); + const loadLevelToSet = Math.max(updateLevel, project.openFileWatchTriggered.get(fileOrDirectoryPath) || 0 /* Update */); project.openFileWatchTriggered.set(fileOrDirectoryPath, loadLevelToSet); } else { - project.pendingReload = reloadLevel; + project.pendingUpdateLevel = updateLevel; this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project); } } else { - project.pendingReload = reloadLevel; + project.pendingUpdateLevel = updateLevel; this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project); } }); @@ -179086,12 +179615,12 @@ var _ProjectService = class _ProjectService { ); } /** @internal */ - delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalConfigFilePath, reloadReason) { + delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalConfigFilePath, loadReason) { const configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (!(configFileExistenceInfo == null ? void 0 : configFileExistenceInfo.config)) return false; let scheduledAnyProjectUpdate = false; - configFileExistenceInfo.config.reloadLevel = 2 /* Full */; + configFileExistenceInfo.config.updateLevel = 2 /* Full */; configFileExistenceInfo.config.projects.forEach((_watchWildcardDirectories, projectCanonicalPath) => { const project = this.getConfiguredProjectByCanonicalConfigFilePath(projectCanonicalPath); if (!project) @@ -179100,8 +179629,8 @@ var _ProjectService = class _ProjectService { if (projectCanonicalPath === canonicalConfigFilePath) { if (project.isInitialLoadPending()) return; - project.pendingReload = 2 /* Full */; - project.pendingReloadReason = reloadReason; + project.pendingUpdateLevel = 2 /* Full */; + project.pendingUpdateReason = loadReason; this.delayUpdateProjectGraph(project); } else { project.resolutionCache.removeResolutionsFromProjectReferenceRedirects(this.toPath(canonicalConfigFilePath)); @@ -179250,11 +179779,11 @@ var _ProjectService = class _ProjectService { if (info.hasMixedContent) { info.registerFileUpdate(); } - const reloadLevel = p.openFileWatchTriggered.get(info.path); - if (reloadLevel !== void 0) { + const updateLevel = p.openFileWatchTriggered.get(info.path); + if (updateLevel !== void 0) { p.openFileWatchTriggered.delete(info.path); - if (p.pendingReload !== void 0 && p.pendingReload < reloadLevel) { - p.pendingReload = reloadLevel; + if (p.pendingUpdateLevel !== void 0 && p.pendingUpdateLevel < updateLevel) { + p.pendingUpdateLevel = updateLevel; p.markFileAsDirty(info.path); } } @@ -179634,6 +180163,7 @@ var _ProjectService = class _ProjectService { addFilesToNonInferredProject(project, files, propertyReader, typeAcquisition) { this.updateNonInferredProjectFiles(project, files, propertyReader); project.setTypeAcquisition(typeAcquisition); + project.markAsDirty(); } /** @internal */ createConfiguredProject(configFileName) { @@ -179651,7 +180181,7 @@ var _ProjectService = class _ProjectService { configFileExistenceInfo.config = { cachedDirectoryStructureHost: createCachedDirectoryStructureHost(this.host, this.host.getCurrentDirectory(), this.host.useCaseSensitiveFileNames), projects: /* @__PURE__ */ new Map(), - reloadLevel: 2 /* Full */ + updateLevel: 2 /* Full */ }; } const project = new ConfiguredProject2( @@ -179668,8 +180198,8 @@ var _ProjectService = class _ProjectService { /** @internal */ createConfiguredProjectWithDelayLoad(configFileName, reason) { const project = this.createConfiguredProject(configFileName); - project.pendingReload = 2 /* Full */; - project.pendingReloadReason = reason; + project.pendingUpdateLevel = 2 /* Full */; + project.pendingUpdateReason = reason; return project; } /** @internal */ @@ -179725,7 +180255,7 @@ var _ProjectService = class _ProjectService { this.watchWildcards(configFilename, configFileExistenceInfo, project); } project.enablePluginsWithOptions(compilerOptions); - const filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles()); + const filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles(2 /* Full */)); this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave, parsedCommandLine.watchOptions); (_b = tracing) == null ? void 0 : _b.pop(); } @@ -179733,9 +180263,9 @@ var _ProjectService = class _ProjectService { ensureParsedConfigUptoDate(configFilename, canonicalConfigFilePath, configFileExistenceInfo, forProject) { var _a, _b, _c; if (configFileExistenceInfo.config) { - if (!configFileExistenceInfo.config.reloadLevel) + if (!configFileExistenceInfo.config.updateLevel) return configFileExistenceInfo; - if (configFileExistenceInfo.config.reloadLevel === 1 /* Partial */) { + if (configFileExistenceInfo.config.updateLevel === 1 /* RootNamesAndUpdate */) { this.reloadFileNamesOfParsedConfig(configFilename, configFileExistenceInfo.config); return configFileExistenceInfo; } @@ -179778,7 +180308,7 @@ var _ProjectService = class _ProjectService { } else { configFileExistenceInfo.config.parsedCommandLine = parsedCommandLine; configFileExistenceInfo.config.watchedDirectoriesStale = true; - configFileExistenceInfo.config.reloadLevel = void 0; + configFileExistenceInfo.config.updateLevel = void 0; } if (!oldCommandLine && !isJsonEqual( // Old options @@ -179919,7 +180449,6 @@ var _ProjectService = class _ProjectService { } }); } - project.markAsDirty(); } updateRootAndOptionsOfNonInferredProject(project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave, watchOptions) { project.setCompilerOptions(newOptions); @@ -179937,14 +180466,15 @@ var _ProjectService = class _ProjectService { reloadFileNamesOfConfiguredProject(project) { const fileNames = this.reloadFileNamesOfParsedConfig(project.getConfigFilePath(), this.configFileExistenceInfoCache.get(project.canonicalConfigFilePath).config); project.updateErrorOnNoInputFiles(fileNames); - this.updateNonInferredProjectFiles(project, fileNames.concat(project.getExternalFiles()), fileNamePropertyReader); + this.updateNonInferredProjectFiles(project, fileNames.concat(project.getExternalFiles(1 /* RootNamesAndUpdate */)), fileNamePropertyReader); + project.markAsDirty(); return project.updateGraph(); } /** @internal */ reloadFileNamesOfParsedConfig(configFileName, config) { - if (config.reloadLevel === void 0) + if (config.updateLevel === void 0) return config.parsedCommandLine.fileNames; - Debug.assert(config.reloadLevel === 1 /* Partial */); + Debug.assert(config.updateLevel === 1 /* RootNamesAndUpdate */); const configFileSpecs = config.parsedCommandLine.options.configFile.configFileSpecs; const fileNames = getFileNamesFromConfigSpecs( configFileSpecs, @@ -179957,7 +180487,7 @@ var _ProjectService = class _ProjectService { return fileNames; } /** @internal */ - setFileNamesOfAutoImportProviderProject(project, fileNames) { + setFileNamesOfAutpImportProviderOrAuxillaryProject(project, fileNames) { this.updateNonInferredProjectFiles(project, fileNames, fileNamePropertyReader); } /** @@ -180486,7 +181016,7 @@ Dynamic files must always be opened with service's current directory or service this.hostConfiguration.preferences = { ...this.hostConfiguration.preferences, ...args.preferences }; if (lazyConfiguredProjectsFromExternalProject && !this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject) { this.configuredProjects.forEach((project) => { - if (project.hasExternalProjectRef() && project.pendingReload === 2 /* Full */ && !this.pendingProjectUpdates.has(project.getProjectName())) { + if (project.hasExternalProjectRef() && project.pendingUpdateLevel === 2 /* Full */ && !this.pendingProjectUpdates.has(project.getProjectName())) { project.updateGraph(); } }); @@ -180541,7 +181071,7 @@ Dynamic files must always be opened with service's current directory or service this.pendingEnsureProjectForOpenFiles = false; this.configFileExistenceInfoCache.forEach((info) => { if (info.config) - info.config.reloadLevel = 2 /* Full */; + info.config.updateLevel = 2 /* Full */; }); this.reloadConfiguredProjectForFiles( this.openFiles, @@ -180593,8 +181123,8 @@ Dynamic files must always be opened with service's current directory or service if (!updatedProjects.has(project.canonicalConfigFilePath)) { updatedProjects.set(project.canonicalConfigFilePath, true); if (delayReload) { - project.pendingReload = 2 /* Full */; - project.pendingReloadReason = reason; + project.pendingUpdateLevel = 2 /* Full */; + project.pendingUpdateReason = reason; if (clearSemanticCache) this.clearSemanticCache(project); this.delayUpdateProjectGraph(project); @@ -181766,7 +182296,7 @@ function formatMessage2(msg, logger, byteLength, newLine) { const verboseLogging = logger.hasLevel(3 /* verbose */); const json = JSON.stringify(msg); if (verboseLogging) { - logger.info(`${msg.type}:${indent2(JSON.stringify(msg, void 0, " "))}`); + logger.info(`${msg.type}:${stringifyIndented(msg)}`); } const len = byteLength(json, "utf8"); return `Content-Length: ${1 + len}\r @@ -183353,7 +183883,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter if (needsJsResolution) { const definitionSet = createSet((d) => d.textSpan.start, documentSpansEqual); definitions == null ? void 0 : definitions.forEach((d) => definitionSet.add(d)); - const noDtsProject = project.getNoDtsResolutionProject([file]); + const noDtsProject = project.getNoDtsResolutionProject(file); const ls = noDtsProject.getLanguageService(); const jsDefinitions = (_a = ls.getDefinitionAtPosition( file, @@ -183380,8 +183910,18 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter const ambientCandidates = definitions.filter((d) => toNormalizedPath(d.fileName) !== file && d.isAmbient); for (const candidate of some(ambientCandidates) ? ambientCandidates : getAmbientCandidatesByClimbingAccessChain()) { const fileNameToSearch = findImplementationFileFromDtsFileName(candidate.fileName, file, noDtsProject); - if (!fileNameToSearch || !ensureRoot(noDtsProject, fileNameToSearch)) { + if (!fileNameToSearch) + continue; + const info = this.projectService.getOrCreateScriptInfoNotOpenedByClient( + fileNameToSearch, + noDtsProject.currentDirectory, + noDtsProject.directoryStructureHost + ); + if (!info) continue; + if (!noDtsProject.containsScriptInfo(info)) { + noDtsProject.addRoot(info); + noDtsProject.updateGraph(); } const noDtsProgram = ls.getProgram(); const fileToSearch = Debug.checkDefined(noDtsProgram.getSourceFile(fileNameToSearch)); @@ -183484,16 +184024,6 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter } }); } - function ensureRoot(project2, fileName) { - const info = project2.getScriptInfo(fileName); - if (!info) - return false; - if (!project2.containsScriptInfo(info)) { - project2.addRoot(info); - project2.updateGraph(); - } - return true; - } } getEmitOutput(args) { const { file, project } = this.getFileAndProject(args); @@ -185820,6 +186350,7 @@ __export(ts_server_exports4, { hasNoTypeScriptSource: () => hasNoTypeScriptSource, indent: () => indent2, initializeNodeSystem: () => initializeNodeSystem, + isBackgroundProject: () => isBackgroundProject, isConfigFile: () => isConfigFile, isConfiguredProject: () => isConfiguredProject, isDynamicFileName: () => isDynamicFileName, @@ -186612,7 +187143,6 @@ start(initializeNodeSystem(), require("os").platform()); CompletionInfoFlags, CompletionTriggerKind, Completions, - ConfigFileProgramReloadLevel, ContainerFlags, ContextFlags, Debug, @@ -186699,6 +187229,7 @@ start(initializeNodeSystem(), require("os").platform()); PragmaKindFlags, PrivateIdentifierKind, ProcessLevel, + ProgramUpdateLevel, QuotePreference, RelationComparisonResult, Rename, diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 8f70f7cfa107a..5ee1d5258cb01 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -3274,7 +3274,7 @@ declare namespace ts { } interface PluginModule { create(createInfo: PluginCreateInfo): LanguageService; - getExternalFiles?(proj: Project): string[]; + getExternalFiles?(proj: Project, updateLevel: ProgramUpdateLevel): string[]; onConfigurationChanged?(config: any): void; } interface PluginModuleWithName { @@ -3354,7 +3354,6 @@ declare namespace ts { readFile(fileName: string): string | undefined; writeFile(fileName: string, content: string): void; fileExists(file: string): boolean; - getModuleResolutionCache(): ModuleResolutionCache | undefined; directoryExists(path: string): boolean; getDirectories(path: string): string[]; log(s: string): void; @@ -3379,7 +3378,7 @@ declare namespace ts { disableLanguageService(lastFileExceededProgramSize?: string): void; getProjectName(): string; protected removeLocalTypingsFromTypeAcquisition(newTypeAcquisition: TypeAcquisition): TypeAcquisition; - getExternalFiles(): SortedReadonlyArray; + getExternalFiles(updateLevel?: ProgramUpdateLevel): SortedReadonlyArray; getSourceFile(path: Path): ts.SourceFile | undefined; close(): void; private detachScriptInfoIfNotRoot; @@ -3451,7 +3450,6 @@ declare namespace ts { getLanguageService(): never; getHostForAutoImportProvider(): never; getProjectReferences(): readonly ts.ProjectReference[] | undefined; - getTypeAcquisition(): TypeAcquisition; } /** * If a file is opened, the server will look for a tsconfig (or jsconfig) @@ -4754,32 +4752,32 @@ declare namespace ts { } enum ModifierFlags { None = 0, - Export = 1, - Ambient = 2, - Public = 4, - Private = 8, - Protected = 16, - Static = 32, - Readonly = 64, - Accessor = 128, - Abstract = 256, - Async = 512, - Default = 1024, - Const = 2048, - HasComputedJSDocModifiers = 4096, - Deprecated = 8192, - Override = 16384, - In = 32768, - Out = 65536, - Decorator = 131072, + Public = 1, + Private = 2, + Protected = 4, + Readonly = 8, + Override = 16, + Export = 32, + Abstract = 64, + Ambient = 128, + Static = 256, + Accessor = 512, + Async = 1024, + Default = 2048, + Const = 4096, + In = 8192, + Out = 16384, + Decorator = 32768, + Deprecated = 65536, + HasComputedJSDocModifiers = 268435456, HasComputedFlags = 536870912, - AccessibilityModifier = 28, - ParameterPropertyModifier = 16476, - NonPublicAccessibilityModifier = 24, - TypeScriptModifier = 117086, - ExportDefault = 1025, - All = 258047, - Modifier = 126975, + AccessibilityModifier = 7, + ParameterPropertyModifier = 31, + NonPublicAccessibilityModifier = 6, + TypeScriptModifier = 28895, + ExportDefault = 2080, + All = 131071, + Modifier = 98303, } enum JsxFlags { None = 0, @@ -4976,7 +4974,7 @@ declare namespace ts { readonly right: Identifier; } type EntityName = Identifier | QualifiedName; - type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier; + type PropertyName = Identifier | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier; type MemberName = Identifier | PrivateIdentifier; type DeclarationName = PropertyName | JsxAttributeName | StringLiteralLike | ElementAccessExpression | BindingPattern | EntityNameExpression; interface Declaration extends Node { @@ -6780,6 +6778,7 @@ declare namespace ts { isUndefinedSymbol(symbol: Symbol): boolean; isArgumentsSymbol(symbol: Symbol): boolean; isUnknownSymbol(symbol: Symbol): boolean; + getMergedSymbol(symbol: Symbol): Symbol; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number | undefined; isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName | ImportTypeNode, propertyName: string): boolean; /** Follow all aliases to get the original symbol. */ @@ -8388,6 +8387,18 @@ declare namespace ts { createExportDefault(expression: Expression): ExportAssignment; createExternalModuleExport(exportName: Identifier): ExportDeclaration; restoreOuterExpressions(outerExpression: Expression | undefined, innerExpression: Expression, kinds?: OuterExpressionKinds): Expression; + /** + * Updates a node that may contain modifiers, replacing only the modifiers of the node. + */ + replaceModifiers(node: T, modifiers: readonly Modifier[] | ModifierFlags | undefined): T; + /** + * Updates a node that may contain decorators or modifiers, replacing only the decorators and modifiers of the node. + */ + replaceDecoratorsAndModifiers(node: T, modifiers: readonly ModifierLike[] | undefined): T; + /** + * Updates a node that contains a property name, replacing only the name of the node. + */ + replacePropertyName(node: T, name: T["name"]): T; } interface CoreTransformationContext { readonly factory: NodeFactory; @@ -8744,6 +8755,7 @@ declare namespace ts { readonly interactiveInlayHints?: boolean; readonly allowRenameOfImportPath?: boolean; readonly autoImportFileExcludePatterns?: string[]; + readonly preferTypeOnlyAutoImports?: boolean; readonly organizeImportsIgnoreCase?: "auto" | boolean; readonly organizeImportsCollation?: "ordinal" | "unicode"; readonly organizeImportsLocale?: string; @@ -9829,6 +9841,19 @@ declare namespace ts { function getTsBuildInfoEmitOutputFilePath(options: CompilerOptions): string | undefined; function getOutputFileNames(commandLine: ParsedCommandLine, inputFileName: string, ignoreCase: boolean): readonly string[]; function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; + enum ProgramUpdateLevel { + /** Program is updated with same root file names and options */ + Update = 0, + /** Loads program after updating root file names from the disk */ + RootNamesAndUpdate = 1, + /** + * Loads program completely, including: + * - re-reading contents of config file from disk + * - calculating root file names for the program + * - Updating the program + */ + Full = 2, + } function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string | undefined; function resolveTripleslashReference(moduleName: string, containingFile: string): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; diff --git a/lib/typescript.js b/lib/typescript.js index b266047f4d991..3f3798f016e0f 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -3950,32 +3950,43 @@ ${lanes.join("\n")} })(NodeFlags || {}); ModifierFlags = /* @__PURE__ */ ((ModifierFlags3) => { ModifierFlags3[ModifierFlags3["None"] = 0] = "None"; - ModifierFlags3[ModifierFlags3["Export"] = 1] = "Export"; - ModifierFlags3[ModifierFlags3["Ambient"] = 2] = "Ambient"; - ModifierFlags3[ModifierFlags3["Public"] = 4] = "Public"; - ModifierFlags3[ModifierFlags3["Private"] = 8] = "Private"; - ModifierFlags3[ModifierFlags3["Protected"] = 16] = "Protected"; - ModifierFlags3[ModifierFlags3["Static"] = 32] = "Static"; - ModifierFlags3[ModifierFlags3["Readonly"] = 64] = "Readonly"; - ModifierFlags3[ModifierFlags3["Accessor"] = 128] = "Accessor"; - ModifierFlags3[ModifierFlags3["Abstract"] = 256] = "Abstract"; - ModifierFlags3[ModifierFlags3["Async"] = 512] = "Async"; - ModifierFlags3[ModifierFlags3["Default"] = 1024] = "Default"; - ModifierFlags3[ModifierFlags3["Const"] = 2048] = "Const"; - ModifierFlags3[ModifierFlags3["HasComputedJSDocModifiers"] = 4096] = "HasComputedJSDocModifiers"; - ModifierFlags3[ModifierFlags3["Deprecated"] = 8192] = "Deprecated"; - ModifierFlags3[ModifierFlags3["Override"] = 16384] = "Override"; - ModifierFlags3[ModifierFlags3["In"] = 32768] = "In"; - ModifierFlags3[ModifierFlags3["Out"] = 65536] = "Out"; - ModifierFlags3[ModifierFlags3["Decorator"] = 131072] = "Decorator"; + ModifierFlags3[ModifierFlags3["Public"] = 1] = "Public"; + ModifierFlags3[ModifierFlags3["Private"] = 2] = "Private"; + ModifierFlags3[ModifierFlags3["Protected"] = 4] = "Protected"; + ModifierFlags3[ModifierFlags3["Readonly"] = 8] = "Readonly"; + ModifierFlags3[ModifierFlags3["Override"] = 16] = "Override"; + ModifierFlags3[ModifierFlags3["Export"] = 32] = "Export"; + ModifierFlags3[ModifierFlags3["Abstract"] = 64] = "Abstract"; + ModifierFlags3[ModifierFlags3["Ambient"] = 128] = "Ambient"; + ModifierFlags3[ModifierFlags3["Static"] = 256] = "Static"; + ModifierFlags3[ModifierFlags3["Accessor"] = 512] = "Accessor"; + ModifierFlags3[ModifierFlags3["Async"] = 1024] = "Async"; + ModifierFlags3[ModifierFlags3["Default"] = 2048] = "Default"; + ModifierFlags3[ModifierFlags3["Const"] = 4096] = "Const"; + ModifierFlags3[ModifierFlags3["In"] = 8192] = "In"; + ModifierFlags3[ModifierFlags3["Out"] = 16384] = "Out"; + ModifierFlags3[ModifierFlags3["Decorator"] = 32768] = "Decorator"; + ModifierFlags3[ModifierFlags3["Deprecated"] = 65536] = "Deprecated"; + ModifierFlags3[ModifierFlags3["JSDocPublic"] = 8388608] = "JSDocPublic"; + ModifierFlags3[ModifierFlags3["JSDocPrivate"] = 16777216] = "JSDocPrivate"; + ModifierFlags3[ModifierFlags3["JSDocProtected"] = 33554432] = "JSDocProtected"; + ModifierFlags3[ModifierFlags3["JSDocReadonly"] = 67108864] = "JSDocReadonly"; + ModifierFlags3[ModifierFlags3["JSDocOverride"] = 134217728] = "JSDocOverride"; + ModifierFlags3[ModifierFlags3["SyntacticOrJSDocModifiers"] = 31] = "SyntacticOrJSDocModifiers"; + ModifierFlags3[ModifierFlags3["SyntacticOnlyModifiers"] = 65504] = "SyntacticOnlyModifiers"; + ModifierFlags3[ModifierFlags3["SyntacticModifiers"] = 65535] = "SyntacticModifiers"; + ModifierFlags3[ModifierFlags3["JSDocCacheOnlyModifiers"] = 260046848] = "JSDocCacheOnlyModifiers"; + ModifierFlags3[ModifierFlags3["JSDocOnlyModifiers"] = 65536 /* Deprecated */] = "JSDocOnlyModifiers"; + ModifierFlags3[ModifierFlags3["NonCacheOnlyModifiers"] = 131071] = "NonCacheOnlyModifiers"; + ModifierFlags3[ModifierFlags3["HasComputedJSDocModifiers"] = 268435456] = "HasComputedJSDocModifiers"; ModifierFlags3[ModifierFlags3["HasComputedFlags"] = 536870912] = "HasComputedFlags"; - ModifierFlags3[ModifierFlags3["AccessibilityModifier"] = 28] = "AccessibilityModifier"; - ModifierFlags3[ModifierFlags3["ParameterPropertyModifier"] = 16476] = "ParameterPropertyModifier"; - ModifierFlags3[ModifierFlags3["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; - ModifierFlags3[ModifierFlags3["TypeScriptModifier"] = 117086] = "TypeScriptModifier"; - ModifierFlags3[ModifierFlags3["ExportDefault"] = 1025] = "ExportDefault"; - ModifierFlags3[ModifierFlags3["All"] = 258047] = "All"; - ModifierFlags3[ModifierFlags3["Modifier"] = 126975] = "Modifier"; + ModifierFlags3[ModifierFlags3["AccessibilityModifier"] = 7] = "AccessibilityModifier"; + ModifierFlags3[ModifierFlags3["ParameterPropertyModifier"] = 31] = "ParameterPropertyModifier"; + ModifierFlags3[ModifierFlags3["NonPublicAccessibilityModifier"] = 6] = "NonPublicAccessibilityModifier"; + ModifierFlags3[ModifierFlags3["TypeScriptModifier"] = 28895] = "TypeScriptModifier"; + ModifierFlags3[ModifierFlags3["ExportDefault"] = 2080] = "ExportDefault"; + ModifierFlags3[ModifierFlags3["All"] = 131071] = "All"; + ModifierFlags3[ModifierFlags3["Modifier"] = 98303] = "Modifier"; return ModifierFlags3; })(ModifierFlags || {}); JsxFlags = /* @__PURE__ */ ((JsxFlags2) => { @@ -7943,7 +7954,7 @@ ${lanes.join("\n")} Import_assertion_values_must_be_string_literal_expressions: diag(2837, 1 /* Error */, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."), All_declarations_of_0_must_have_identical_constraints: diag(2838, 1 /* Error */, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."), This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, 1 /* Error */, "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839", "This condition will always return '{0}' since JavaScript compares objects by reference, not value."), - An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes: diag(2840, 1 /* Error */, "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840", "An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes"), + An_interface_cannot_extend_a_primitive_type_like_0_It_can_only_extend_other_named_object_types: diag(2840, 1 /* Error */, "An_interface_cannot_extend_a_primitive_type_like_0_It_can_only_extend_other_named_object_types_2840", "An interface cannot extend a primitive type like '{0}'. It can only extend other named object types."), _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, 1 /* Error */, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"), We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, 1 /* Error */, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."), Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, 1 /* Error */, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), @@ -7963,6 +7974,9 @@ ${lanes.join("\n")} Excessive_complexity_comparing_types_0_and_1: diag(2859, 1 /* Error */, "Excessive_complexity_comparing_types_0_and_1_2859", "Excessive complexity comparing types '{0}' and '{1}'."), The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_hand_side_s_Symbol_hasInstance_method: diag(2860, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_2860", "The left-hand side of an 'instanceof' expression must be assignable to the first argument of the right-hand side's '[Symbol.hasInstance]' method."), An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_hand_side_of_an_instanceof_expression: diag(2861, 1 /* Error */, "An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_han_2861", "An object's '[Symbol.hasInstance]' method must return a boolean value for it to be used on the right-hand side of an 'instanceof' expression."), + Type_0_is_generic_and_can_only_be_indexed_for_reading: diag(2862, 1 /* Error */, "Type_0_is_generic_and_can_only_be_indexed_for_reading_2862", "Type '{0}' is generic and can only be indexed for reading."), + A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values: diag(2863, 1 /* Error */, "A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values_2863", "A class cannot extend a primitive type like '{0}'. Classes can only extend constructable values."), + A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types: diag(2864, 1 /* Error */, "A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types_2864", "A class cannot implement a primitive type like '{0}'. It can only implement other named object types."), Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* 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, 1 /* 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, 1 /* 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}'."), @@ -11475,7 +11489,7 @@ ${lanes.join("\n")} } } function isParameterPropertyDeclaration(node, parent2) { - return isParameter(node) && hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent2.kind === 176 /* Constructor */; + return isParameter(node) && hasSyntacticModifier(node, 31 /* ParameterPropertyModifier */) && parent2.kind === 176 /* Constructor */; } function isEmptyBindingPattern(node) { if (isBindingPattern(node)) { @@ -11764,7 +11778,7 @@ ${lanes.join("\n")} } } function getModifiers(node) { - if (hasSyntacticModifier(node, 126975 /* Modifier */)) { + if (hasSyntacticModifier(node, 98303 /* Modifier */)) { return filter(node.modifiers, isModifier); } } @@ -12198,7 +12212,7 @@ ${lanes.join("\n")} return false; } function isParameterPropertyModifier(kind) { - return !!(modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); + return !!(modifierToFlag(kind) & 31 /* ParameterPropertyModifier */); } function isClassMemberModifier(idToken) { return isParameterPropertyModifier(idToken) || idToken === 126 /* StaticKeyword */ || idToken === 164 /* OverrideKeyword */ || idToken === 129 /* AccessorKeyword */; @@ -12562,10 +12576,10 @@ ${lanes.join("\n")} return some(statements, isScopeMarker); } function needsScopeMarker(result) { - return !isAnyImportOrReExport(result) && !isExportAssignment(result) && !hasSyntacticModifier(result, 1 /* Export */) && !isAmbientModule(result); + return !isAnyImportOrReExport(result) && !isExportAssignment(result) && !hasSyntacticModifier(result, 32 /* Export */) && !isAmbientModule(result); } function isExternalModuleIndicator(result) { - return isAnyImportOrReExport(result) || isExportAssignment(result) || hasSyntacticModifier(result, 1 /* Export */); + return isAnyImportOrReExport(result) || isExportAssignment(result) || hasSyntacticModifier(result, 32 /* Export */); } function isForInOrOfStatement(node) { return node.kind === 249 /* ForInStatement */ || node.kind === 250 /* ForOfStatement */; @@ -13441,7 +13455,7 @@ ${lanes.join("\n")} return false; } function isAmbientPropertyDeclaration(node) { - return !!(node.flags & 33554432 /* Ambient */) || hasSyntacticModifier(node, 2 /* Ambient */); + return !!(node.flags & 33554432 /* Ambient */) || hasSyntacticModifier(node, 128 /* Ambient */); } function isBlockScope(node, parentNode) { switch (node.kind) { @@ -13794,10 +13808,10 @@ ${lanes.join("\n")} return file.scriptKind === 6 /* JSON */; } function isEnumConst(node) { - return !!(getCombinedModifierFlags(node) & 2048 /* Const */); + return !!(getCombinedModifierFlags(node) & 4096 /* Const */); } function isDeclarationReadonly(declaration) { - return !!(getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !isParameterPropertyDeclaration(declaration, declaration.parent)); + return !!(getCombinedModifierFlags(declaration) & 8 /* Readonly */ && !isParameterPropertyDeclaration(declaration, declaration.parent)); } function isVarAwaitUsing(node) { return (getCombinedNodeFlags(node) & 7 /* BlockScoped */) === 6 /* AwaitUsing */; @@ -14864,6 +14878,7 @@ ${lanes.join("\n")} true ))) == null ? void 0 : _a.arguments[0]; case 272 /* ImportDeclaration */: + case 278 /* ExportDeclaration */: return tryCast(node.moduleSpecifier, isStringLiteralLike); case 271 /* ImportEqualsDeclaration */: return tryCast((_b = tryCast(node.moduleReference, isExternalModuleReference)) == null ? void 0 : _b.expression, isStringLiteralLike); @@ -14875,6 +14890,8 @@ ${lanes.join("\n")} return tryCast(node.parent.parent.moduleSpecifier, isStringLiteralLike); case 276 /* ImportSpecifier */: return tryCast(node.parent.parent.parent.moduleSpecifier, isStringLiteralLike); + case 205 /* ImportType */: + return isLiteralImportTypeNode(node) ? node.argument.literal : void 0; default: Debug.assertNever(node); } @@ -15125,9 +15142,9 @@ ${lanes.join("\n")} } function getNextJSDocCommentLocation(node) { const parent2 = node.parent; - if (parent2.kind === 303 /* PropertyAssignment */ || parent2.kind === 277 /* ExportAssignment */ || parent2.kind === 172 /* PropertyDeclaration */ || parent2.kind === 244 /* ExpressionStatement */ && node.kind === 211 /* PropertyAccessExpression */ || parent2.kind === 253 /* ReturnStatement */ || getNestedModuleDeclaration(parent2) || isBinaryExpression(node) && node.operatorToken.kind === 64 /* EqualsToken */) { + if (parent2.kind === 303 /* PropertyAssignment */ || parent2.kind === 277 /* ExportAssignment */ || parent2.kind === 172 /* PropertyDeclaration */ || parent2.kind === 244 /* ExpressionStatement */ && node.kind === 211 /* PropertyAccessExpression */ || parent2.kind === 253 /* ReturnStatement */ || getNestedModuleDeclaration(parent2) || isAssignmentExpression(node)) { return parent2; - } else if (parent2.parent && (getSingleVariableOfVariableStatement(parent2.parent) === node || isBinaryExpression(parent2) && parent2.operatorToken.kind === 64 /* EqualsToken */)) { + } else if (parent2.parent && (getSingleVariableOfVariableStatement(parent2.parent) === node || isAssignmentExpression(parent2))) { return parent2.parent; } else if (parent2.parent && parent2.parent.parent && (getSingleVariableOfVariableStatement(parent2.parent.parent) || getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent2.parent.parent) === node || getSourceOfDefaultedAssignment(parent2.parent.parent))) { return parent2.parent.parent; @@ -15523,7 +15540,7 @@ ${lanes.join("\n")} flags |= 1 /* Generator */; } case 219 /* ArrowFunction */: - if (hasSyntacticModifier(node, 512 /* Async */)) { + if (hasSyntacticModifier(node, 1024 /* Async */)) { flags |= 2 /* Async */; } break; @@ -15539,7 +15556,7 @@ ${lanes.join("\n")} case 218 /* FunctionExpression */: case 219 /* ArrowFunction */: case 174 /* MethodDeclaration */: - return node.body !== void 0 && node.asteriskToken === void 0 && hasSyntacticModifier(node, 512 /* Async */); + return node.body !== void 0 && node.asteriskToken === void 0 && hasSyntacticModifier(node, 1024 /* Async */); } return false; } @@ -15566,6 +15583,7 @@ ${lanes.join("\n")} case 81 /* PrivateIdentifier */: return name.escapedText; case 11 /* StringLiteral */: + case 15 /* NoSubstitutionTemplateLiteral */: case 9 /* NumericLiteral */: return escapeLeadingUnderscores(name.text); case 167 /* ComputedPropertyName */: @@ -16637,25 +16655,25 @@ ${lanes.join("\n")} return isClassElement(node) && hasStaticModifier(node) || isClassStaticBlockDeclaration(node); } function hasStaticModifier(node) { - return hasSyntacticModifier(node, 32 /* Static */); + return hasSyntacticModifier(node, 256 /* Static */); } function hasOverrideModifier(node) { - return hasEffectiveModifier(node, 16384 /* Override */); + return hasEffectiveModifier(node, 16 /* Override */); } function hasAbstractModifier(node) { - return hasSyntacticModifier(node, 256 /* Abstract */); + return hasSyntacticModifier(node, 64 /* Abstract */); } function hasAmbientModifier(node) { - return hasSyntacticModifier(node, 2 /* Ambient */); + return hasSyntacticModifier(node, 128 /* Ambient */); } function hasAccessorModifier(node) { - return hasSyntacticModifier(node, 128 /* Accessor */); + return hasSyntacticModifier(node, 512 /* Accessor */); } function hasEffectiveReadonlyModifier(node) { - return hasEffectiveModifier(node, 64 /* Readonly */); + return hasEffectiveModifier(node, 8 /* Readonly */); } function hasDecorators(node) { - return hasSyntacticModifier(node, 131072 /* Decorator */); + return hasSyntacticModifier(node, 32768 /* Decorator */); } function getSelectedEffectiveModifierFlags(node, flags) { return getEffectiveModifierFlags(node) & flags; @@ -16670,10 +16688,13 @@ ${lanes.join("\n")} if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */; } - if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { - node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* HasComputedJSDocModifiers */; + if (alwaysIncludeJSDoc || includeJSDoc && isInJSFile(node)) { + if (!(node.modifierFlagsCache & 268435456 /* HasComputedJSDocModifiers */) && node.parent) { + node.modifierFlagsCache |= getRawJSDocModifierFlagsNoCache(node) | 268435456 /* HasComputedJSDocModifiers */; + } + return selectEffectiveModifierFlags(node.modifierFlagsCache); } - return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */); + return selectSyntacticModifierFlags(node.modifierFlagsCache); } function getEffectiveModifierFlags(node) { return getModifierFlagsWorker( @@ -16698,33 +16719,42 @@ ${lanes.join("\n")} false ); } - function getJSDocModifierFlagsNoCache(node) { + function getRawJSDocModifierFlagsNoCache(node) { let flags = 0 /* None */; if (!!node.parent && !isParameter(node)) { if (isInJSFile(node)) { if (getJSDocPublicTagNoCache(node)) - flags |= 4 /* Public */; + flags |= 8388608 /* JSDocPublic */; if (getJSDocPrivateTagNoCache(node)) - flags |= 8 /* Private */; + flags |= 16777216 /* JSDocPrivate */; if (getJSDocProtectedTagNoCache(node)) - flags |= 16 /* Protected */; + flags |= 33554432 /* JSDocProtected */; if (getJSDocReadonlyTagNoCache(node)) - flags |= 64 /* Readonly */; + flags |= 67108864 /* JSDocReadonly */; if (getJSDocOverrideTagNoCache(node)) - flags |= 16384 /* Override */; + flags |= 134217728 /* JSDocOverride */; } if (getJSDocDeprecatedTagNoCache(node)) - flags |= 8192 /* Deprecated */; + flags |= 65536 /* Deprecated */; } return flags; } + function selectSyntacticModifierFlags(flags) { + return flags & 65535 /* SyntacticModifiers */; + } + function selectEffectiveModifierFlags(flags) { + return flags & 131071 /* NonCacheOnlyModifiers */ | (flags & 260046848 /* JSDocCacheOnlyModifiers */) >>> 23; + } + function getJSDocModifierFlagsNoCache(node) { + return selectEffectiveModifierFlags(getRawJSDocModifierFlagsNoCache(node)); + } function getEffectiveModifierFlagsNoCache(node) { return getSyntacticModifierFlagsNoCache(node) | getJSDocModifierFlagsNoCache(node); } function getSyntacticModifierFlagsNoCache(node) { let flags = canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : 0 /* None */; if (node.flags & 8 /* NestedNamespace */ || node.kind === 80 /* Identifier */ && node.flags & 4096 /* IdentifierIsInJSDocNamespace */) { - flags |= 1 /* Export */; + flags |= 32 /* Export */; } return flags; } @@ -16740,37 +16770,37 @@ ${lanes.join("\n")} function modifierToFlag(token) { switch (token) { case 126 /* StaticKeyword */: - return 32 /* Static */; + return 256 /* Static */; case 125 /* PublicKeyword */: - return 4 /* Public */; + return 1 /* Public */; case 124 /* ProtectedKeyword */: - return 16 /* Protected */; + return 4 /* Protected */; case 123 /* PrivateKeyword */: - return 8 /* Private */; + return 2 /* Private */; case 128 /* AbstractKeyword */: - return 256 /* Abstract */; + return 64 /* Abstract */; case 129 /* AccessorKeyword */: - return 128 /* Accessor */; + return 512 /* Accessor */; case 95 /* ExportKeyword */: - return 1 /* Export */; + return 32 /* Export */; case 138 /* DeclareKeyword */: - return 2 /* Ambient */; + return 128 /* Ambient */; case 87 /* ConstKeyword */: - return 2048 /* Const */; + return 4096 /* Const */; case 90 /* DefaultKeyword */: - return 1024 /* Default */; + return 2048 /* Default */; case 134 /* AsyncKeyword */: - return 512 /* Async */; + return 1024 /* Async */; case 148 /* ReadonlyKeyword */: - return 64 /* Readonly */; + return 8 /* Readonly */; case 164 /* OverrideKeyword */: - return 16384 /* Override */; + return 16 /* Override */; case 103 /* InKeyword */: - return 32768 /* In */; + return 8192 /* In */; case 147 /* OutKeyword */: - return 65536 /* Out */; + return 16384 /* Out */; case 170 /* Decorator */: - return 131072 /* Decorator */; + return 32768 /* Decorator */; } return 0 /* None */; } @@ -16910,7 +16940,7 @@ ${lanes.join("\n")} return void 0; } function isExportDefaultSymbol(symbol) { - return symbol && length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 1024 /* Default */); + return symbol && length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 2048 /* Default */); } function tryExtractTSExtension(fileName) { return find(supportedTSExtensionsForExtractExtension, (extension) => fileExtensionIs(fileName, extension)); @@ -17190,16 +17220,16 @@ ${lanes.join("\n")} if (s.valueDeclaration) { const declaration = isWrite && s.declarations && find(s.declarations, isSetAccessorDeclaration) || s.flags & 32768 /* GetAccessor */ && find(s.declarations, isGetAccessorDeclaration) || s.valueDeclaration; const flags = getCombinedModifierFlags(declaration); - return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; + return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~7 /* AccessibilityModifier */; } if (getCheckFlags(s) & 6 /* Synthetic */) { const checkFlags = s.links.checkFlags; - const accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : 16 /* Protected */; - const staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; + const accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 2 /* Private */ : checkFlags & 256 /* ContainsPublic */ ? 1 /* Public */ : 4 /* Protected */; + const staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 256 /* Static */ : 0; return accessModifier | staticModifier; } if (s.flags & 4194304 /* Prototype */) { - return 4 /* Public */ | 32 /* Static */; + return 1 /* Public */ | 256 /* Static */; } return 0; } @@ -17298,7 +17328,7 @@ ${lanes.join("\n")} function isAbstractConstructorSymbol(symbol) { if (symbol.flags & 32 /* Class */) { const declaration = getClassLikeDeclarationOfSymbol(symbol); - return !!declaration && hasSyntacticModifier(declaration, 256 /* Abstract */); + return !!declaration && hasSyntacticModifier(declaration, 64 /* Abstract */); } return false; } @@ -18518,7 +18548,7 @@ ${lanes.join("\n")} if (node.kind !== 167 /* ComputedPropertyName */) { return false; } - if (hasSyntacticModifier(node.parent, 256 /* Abstract */)) { + if (hasSyntacticModifier(node.parent, 64 /* Abstract */)) { return true; } const containerKind = node.parent.parent.kind; @@ -20764,8 +20794,9 @@ ${lanes.join("\n")} ensureUseStrict, liftToBlock, mergeLexicalEnvironment, - updateModifiers, - updateModifierLike + replaceModifiers, + replaceDecoratorsAndModifiers, + replacePropertyName }; forEach(nodeFactoryPatchers, (fn) => fn(factory2)); return factory2; @@ -21100,35 +21131,35 @@ ${lanes.join("\n")} } function createModifiersFromModifierFlags(flags2) { const result = []; - if (flags2 & 1 /* Export */) + if (flags2 & 32 /* Export */) result.push(createModifier(95 /* ExportKeyword */)); - if (flags2 & 2 /* Ambient */) + if (flags2 & 128 /* Ambient */) result.push(createModifier(138 /* DeclareKeyword */)); - if (flags2 & 1024 /* Default */) + if (flags2 & 2048 /* Default */) result.push(createModifier(90 /* DefaultKeyword */)); - if (flags2 & 2048 /* Const */) + if (flags2 & 4096 /* Const */) result.push(createModifier(87 /* ConstKeyword */)); - if (flags2 & 4 /* Public */) + if (flags2 & 1 /* Public */) result.push(createModifier(125 /* PublicKeyword */)); - if (flags2 & 8 /* Private */) + if (flags2 & 2 /* Private */) result.push(createModifier(123 /* PrivateKeyword */)); - if (flags2 & 16 /* Protected */) + if (flags2 & 4 /* Protected */) result.push(createModifier(124 /* ProtectedKeyword */)); - if (flags2 & 256 /* Abstract */) + if (flags2 & 64 /* Abstract */) result.push(createModifier(128 /* AbstractKeyword */)); - if (flags2 & 32 /* Static */) + if (flags2 & 256 /* Static */) result.push(createModifier(126 /* StaticKeyword */)); - if (flags2 & 16384 /* Override */) + if (flags2 & 16 /* Override */) result.push(createModifier(164 /* OverrideKeyword */)); - if (flags2 & 64 /* Readonly */) + if (flags2 & 8 /* Readonly */) result.push(createModifier(148 /* ReadonlyKeyword */)); - if (flags2 & 128 /* Accessor */) + if (flags2 & 512 /* Accessor */) result.push(createModifier(129 /* AccessorKeyword */)); - if (flags2 & 512 /* Async */) + if (flags2 & 1024 /* Async */) result.push(createModifier(134 /* AsyncKeyword */)); - if (flags2 & 32768 /* In */) + if (flags2 & 8192 /* In */) result.push(createModifier(103 /* InKeyword */)); - if (flags2 & 65536 /* Out */) + if (flags2 & 16384 /* Out */) result.push(createModifier(147 /* OutKeyword */)); return result.length ? result : void 0; } @@ -21177,7 +21208,7 @@ ${lanes.join("\n")} if (isThisIdentifier(node.name)) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.dotDotDotToken) | propagateNameFlags(node.name) | propagateChildFlags(node.questionToken) | propagateChildFlags(node.initializer) | (node.questionToken ?? node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (node.dotDotDotToken ?? node.initializer ? 1024 /* ContainsES2015 */ : 0 /* None */) | (modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */ ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */); + node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.dotDotDotToken) | propagateNameFlags(node.name) | propagateChildFlags(node.questionToken) | propagateChildFlags(node.initializer) | (node.questionToken ?? node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (node.dotDotDotToken ?? node.initializer ? 1024 /* ContainsES2015 */ : 0 /* None */) | (modifiersToFlags(node.modifiers) & 31 /* ParameterPropertyModifier */ ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */); } node.jsDoc = void 0; return node; @@ -21226,8 +21257,8 @@ ${lanes.join("\n")} node.exclamationToken = questionOrExclamationToken && isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : void 0; node.type = type; node.initializer = asInitializer(initializer); - const isAmbient = node.flags & 33554432 /* Ambient */ || modifiersToFlags(node.modifiers) & 2 /* Ambient */; - node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateNameFlags(node.name) | propagateChildFlags(node.initializer) | (isAmbient || node.questionToken || node.exclamationToken || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (isComputedPropertyName(node.name) || modifiersToFlags(node.modifiers) & 32 /* Static */ && node.initializer ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */) | 16777216 /* ContainsClassFields */; + const isAmbient = node.flags & 33554432 /* Ambient */ || modifiersToFlags(node.modifiers) & 128 /* Ambient */; + node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateNameFlags(node.name) | propagateChildFlags(node.initializer) | (isAmbient || node.questionToken || node.exclamationToken || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (isComputedPropertyName(node.name) || modifiersToFlags(node.modifiers) & 256 /* Static */ && node.initializer ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */) | 16777216 /* ContainsClassFields */; node.jsDoc = void 0; return node; } @@ -21266,7 +21297,7 @@ ${lanes.join("\n")} if (!node.body) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - const isAsync = modifiersToFlags(node.modifiers) & 512 /* Async */; + const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */; const isGenerator = !!node.asteriskToken; const isAsyncGenerator = isAsync && isGenerator; node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.asteriskToken) | propagateNameFlags(node.name) | propagateChildFlags(node.questionToken) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (isAsyncGenerator ? 128 /* ContainsES2018 */ : isAsync ? 256 /* ContainsES2017 */ : isGenerator ? 2048 /* ContainsGenerator */ : 0 /* None */) | (node.questionToken || node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | 1024 /* ContainsES2015 */; @@ -22009,7 +22040,7 @@ ${lanes.join("\n")} node.parameters = createNodeArray(parameters); node.type = type; node.body = body; - const isAsync = modifiersToFlags(node.modifiers) & 512 /* Async */; + const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */; const isGenerator = !!node.asteriskToken; const isAsyncGenerator = isAsync && isGenerator; node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.asteriskToken) | propagateNameFlags(node.name) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (isAsyncGenerator ? 128 /* ContainsES2018 */ : isAsync ? 256 /* ContainsES2017 */ : isGenerator ? 2048 /* ContainsGenerator */ : 0 /* None */) | (node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | 4194304 /* ContainsHoistedDeclarationOrCompletion */; @@ -22033,7 +22064,7 @@ ${lanes.join("\n")} node.type = type; node.equalsGreaterThanToken = equalsGreaterThanToken ?? createToken(39 /* EqualsGreaterThanToken */); node.body = parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body); - const isAsync = modifiersToFlags(node.modifiers) & 512 /* Async */; + const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */; node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.equalsGreaterThanToken) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (isAsync ? 256 /* ContainsES2017 */ | 16384 /* ContainsLexicalThis */ : 0 /* None */) | 1024 /* ContainsES2015 */; node.typeArguments = void 0; node.jsDoc = void 0; @@ -22385,7 +22416,7 @@ ${lanes.join("\n")} node.modifiers = asNodeArray(modifiers); node.declarationList = isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.declarationList); - if (modifiersToFlags(node.modifiers) & 2 /* Ambient */) { + if (modifiersToFlags(node.modifiers) & 128 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } node.jsDoc = void 0; @@ -22635,10 +22666,10 @@ ${lanes.join("\n")} node.parameters = createNodeArray(parameters); node.type = type; node.body = body; - if (!node.body || modifiersToFlags(node.modifiers) & 2 /* Ambient */) { + if (!node.body || modifiersToFlags(node.modifiers) & 128 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - const isAsync = modifiersToFlags(node.modifiers) & 512 /* Async */; + const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */; const isGenerator = !!node.asteriskToken; const isAsyncGenerator = isAsync && isGenerator; node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.asteriskToken) | propagateNameFlags(node.name) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (isAsyncGenerator ? 128 /* ContainsES2018 */ : isAsync ? 256 /* ContainsES2017 */ : isGenerator ? 2048 /* ContainsGenerator */ : 0 /* None */) | (node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | 4194304 /* ContainsHoistedDeclarationOrCompletion */; @@ -22669,7 +22700,7 @@ ${lanes.join("\n")} node.typeParameters = asNodeArray(typeParameters); node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); - if (modifiersToFlags(node.modifiers) & 2 /* Ambient */) { + if (modifiersToFlags(node.modifiers) & 128 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateNameFlags(node.name) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.heritageClauses) | propagateChildrenFlags(node.members) | (node.typeParameters ? 1 /* ContainsTypeScript */ : 0 /* None */) | 1024 /* ContainsES2015 */; @@ -22731,7 +22762,7 @@ ${lanes.join("\n")} node.flags |= flags2 & (32 /* Namespace */ | 8 /* NestedNamespace */ | 2048 /* GlobalAugmentation */); node.name = name; node.body = body; - if (modifiersToFlags(node.modifiers) & 2 /* Ambient */) { + if (modifiersToFlags(node.modifiers) & 128 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.name) | propagateChildFlags(node.body) | 1 /* ContainsTypeScript */; @@ -24162,7 +24193,7 @@ ${lanes.join("\n")} return qualifiedName; } function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && hasSyntacticModifier(node, 1 /* Export */)) { + if (ns && hasSyntacticModifier(node, 32 /* Export */)) { return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); } return getExportName(node, allowComments, allowSourceMaps); @@ -24273,7 +24304,7 @@ ${lanes.join("\n")} } return statements; } - function updateModifiers(node, modifiers) { + function replaceModifiers(node, modifiers) { let modifierArray; if (typeof modifiers === "number") { modifierArray = createModifiersFromModifierFlags(modifiers); @@ -24282,9 +24313,27 @@ ${lanes.join("\n")} } return isTypeParameterDeclaration(node) ? updateTypeParameterDeclaration(node, modifierArray, node.name, node.constraint, node.default) : isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isConstructorTypeNode(node) ? updateConstructorTypeNode1(node, modifierArray, node.typeParameters, node.parameters, node.type) : isPropertySignature(node) ? updatePropertySignature(node, modifierArray, node.name, node.questionToken, node.type) : isPropertyDeclaration(node) ? updatePropertyDeclaration2(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : isMethodSignature(node) ? updateMethodSignature(node, modifierArray, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) : isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : isConstructorDeclaration(node) ? updateConstructorDeclaration(node, modifierArray, node.parameters, node.body) : isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) : isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.body) : isIndexSignatureDeclaration(node) ? updateIndexSignature(node, modifierArray, node.parameters, node.type) : isFunctionExpression(node) ? updateFunctionExpression(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : isArrowFunction(node) ? updateArrowFunction(node, modifierArray, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) : isClassExpression(node) ? updateClassExpression(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isVariableStatement(node) ? updateVariableStatement(node, modifierArray, node.declarationList) : isFunctionDeclaration(node) ? updateFunctionDeclaration(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : isClassDeclaration(node) ? updateClassDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, modifierArray, node.name, node.typeParameters, node.type) : isEnumDeclaration(node) ? updateEnumDeclaration(node, modifierArray, node.name, node.members) : isModuleDeclaration(node) ? updateModuleDeclaration(node, modifierArray, node.name, node.body) : isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, modifierArray, node.isTypeOnly, node.name, node.moduleReference) : isImportDeclaration(node) ? updateImportDeclaration(node, modifierArray, node.importClause, node.moduleSpecifier, node.attributes) : isExportAssignment(node) ? updateExportAssignment(node, modifierArray, node.expression) : isExportDeclaration(node) ? updateExportDeclaration(node, modifierArray, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.attributes) : Debug.assertNever(node); } - function updateModifierLike(node, modifierArray) { + function replaceDecoratorsAndModifiers(node, modifierArray) { return isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isPropertyDeclaration(node) ? updatePropertyDeclaration2(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) : isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.body) : isClassExpression(node) ? updateClassExpression(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isClassDeclaration(node) ? updateClassDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : Debug.assertNever(node); } + function replacePropertyName(node, name) { + switch (node.kind) { + case 177 /* GetAccessor */: + return updateGetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.type, node.body); + case 178 /* SetAccessor */: + return updateSetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.body); + case 174 /* MethodDeclaration */: + return updateMethodDeclaration(node, node.modifiers, node.asteriskToken, name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body); + case 173 /* MethodSignature */: + return updateMethodSignature(node, node.modifiers, name, node.questionToken, node.typeParameters, node.parameters, node.type); + case 172 /* PropertyDeclaration */: + return updatePropertyDeclaration2(node, node.modifiers, name, node.questionToken ?? node.exclamationToken, node.type, node.initializer); + case 171 /* PropertySignature */: + return updatePropertySignature(node, node.modifiers, name, node.questionToken, node.type); + case 303 /* PropertyAssignment */: + return updatePropertyAssignment(node, name, node.initializer); + } + } function asNodeArray(array) { return array ? createNodeArray(array) : void 0; } @@ -25830,17 +25879,18 @@ ${lanes.join("\n")} scoped: false, dependencies: [awaitHelper], text: ` - var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; - function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } - function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } - function fulfill(value) { resume("next", value); } - function reject(value) { resume("throw", value); } - function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } - };` + var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i; + function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; } + function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } + };` }; asyncDelegator = { name: "typescript:asyncDelegator", @@ -33798,11 +33848,11 @@ ${lanes.join("\n")} const modifierFlags = modifiersToFlags(modifiers); parseExpected(100 /* FunctionKeyword */); const asteriskToken = parseOptionalToken(42 /* AsteriskToken */); - const name = modifierFlags & 1024 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); + const name = modifierFlags & 2048 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); const isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - const isAsync = modifierFlags & 512 /* Async */ ? 2 /* Await */ : 0 /* None */; + const isAsync = modifierFlags & 1024 /* Async */ ? 2 /* Await */ : 0 /* None */; const typeParameters = parseTypeParameters(); - if (modifierFlags & 1 /* Export */) + if (modifierFlags & 32 /* Export */) setAwaitContext( /*value*/ true @@ -38726,7 +38776,7 @@ ${lanes.join("\n")} affectsBuildInfo: true, affectsDeclarationPath: true, isFilePath: false, - // This is intentionally broken to support compatability with existing tsconfig files + // This is intentionally broken to support compatibility with existing tsconfig files // for correct behaviour, please use outFile category: Diagnostics.Backwards_Compatibility, paramType: Diagnostics.FILE, @@ -39249,7 +39299,7 @@ ${lanes.join("\n")} Debug.assert(extensionIsTS(resolved.extension)); return { fileName: resolved.path, packageId: resolved.packageId }; } - function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state, legacyResult) { + function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state, cache, legacyResult) { if (!state.resultFromCache && !state.compilerOptions.preserveSymlinks && resolved && isExternalLibraryImport && !resolved.originalPath && !isExternalModuleNameRelative(moduleName)) { const { resolvedFileName, originalPath } = getOriginalAndResolvedFileName(resolved.path, state.host, state.traceEnabled); if (originalPath) @@ -39262,15 +39312,25 @@ ${lanes.join("\n")} affectingLocations, diagnostics, state.resultFromCache, + cache, legacyResult ); } - function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, legacyResult) { + function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, cache, legacyResult) { if (resultFromCache) { - resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations); - resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations); - resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics); - return resultFromCache; + if (!(cache == null ? void 0 : cache.isReadonly)) { + resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations); + resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations); + resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics); + return resultFromCache; + } else { + return { + ...resultFromCache, + failedLookupLocations: initializeResolutionFieldForReadonlyCache(resultFromCache.failedLookupLocations, failedLookupLocations), + affectingLocations: initializeResolutionFieldForReadonlyCache(resultFromCache.affectingLocations, affectingLocations), + resolutionDiagnostics: initializeResolutionFieldForReadonlyCache(resultFromCache.resolutionDiagnostics, diagnostics) + }; + } } return { resolvedModule: resolved && { @@ -39298,6 +39358,13 @@ ${lanes.join("\n")} to.push(...value); return to; } + function initializeResolutionFieldForReadonlyCache(fromCache, value) { + if (!(fromCache == null ? void 0 : fromCache.length)) + return initializeResolutionField(value); + if (!value.length) + return fromCache.slice(); + return [...fromCache, ...value]; + } function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) { if (!hasProperty(jsonContent, fieldName)) { if (state.traceEnabled) { @@ -39480,8 +39547,7 @@ ${lanes.join("\n")} if (resolutionMode === 99 /* ESNext */ && (3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */)) { features |= 32 /* EsmMode */; } - const useImportCondition = resolutionMode === 99 /* ESNext */ || (resolutionMode !== void 0 ? false : void 0); - const conditions = features & 8 /* Exports */ ? getConditions(options, useImportCondition) : []; + const conditions = features & 8 /* Exports */ ? getConditions(options, resolutionMode) : []; const diagnostics = []; const moduleResolutionState = { compilerOptions: options, @@ -39523,15 +39589,15 @@ ${lanes.join("\n")} affectingLocations: initializeResolutionField(affectingLocations), resolutionDiagnostics: initializeResolutionField(diagnostics) }; - if (containingDirectory) { - cache == null ? void 0 : cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set( + if (containingDirectory && cache && !cache.isReadonly) { + cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set( typeReferenceDirectiveName, /*mode*/ resolutionMode, result ); if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) { - cache == null ? void 0 : cache.getOrCreateCacheForNonRelativeName(typeReferenceDirectiveName, resolutionMode, redirectedReference).set(containingDirectory, result); + cache.getOrCreateCacheForNonRelativeName(typeReferenceDirectiveName, resolutionMode, redirectedReference).set(containingDirectory, result); } } if (traceEnabled) @@ -39649,16 +39715,16 @@ ${lanes.join("\n")} } return features; } - function getConditions(options, esmMode) { + function getConditions(options, resolutionMode) { const moduleResolution = getEmitModuleResolutionKind(options); - if (esmMode === void 0) { + if (resolutionMode === void 0) { if (moduleResolution === 100 /* Bundler */) { - esmMode ?? (esmMode = moduleResolution === 100 /* Bundler */); + resolutionMode = 99 /* ESNext */; } else if (moduleResolution === 2 /* Node10 */) { return []; } } - const conditions = esmMode ? ["import"] : ["require"]; + const conditions = resolutionMode === 99 /* ESNext */ ? ["import"] : ["require"]; if (!options.noDtsResolution) { conditions.push("types"); } @@ -39738,7 +39804,8 @@ ${lanes.join("\n")} getMapOfCacheRedirects, getOrCreateMapOfCacheRedirects, update, - clear: clear2 + clear: clear2, + getOwnMap: () => ownMap }; function getMapOfCacheRedirects(redirectedReference) { return redirectedReference ? getOrCreateMap( @@ -39845,7 +39912,8 @@ ${lanes.join("\n")} getFromDirectoryCache, getOrCreateCacheForDirectory, clear: clear2, - update + update, + directoryToModuleNameMap }; function clear2() { directoryToModuleNameMap.clear(); @@ -40105,13 +40173,13 @@ ${lanes.join("\n")} result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); break; case 2 /* Node10 */: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode === 99 /* ESNext */) : void 0); + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode) : void 0); break; case 1 /* Classic */: result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; case 100 /* Bundler */: - result = bundlerModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode === 99 /* ESNext */) : void 0); + result = bundlerModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode) : void 0); break; default: return Debug.fail(`Unexpected moduleResolution: ${moduleResolution}`); @@ -40119,9 +40187,11 @@ ${lanes.join("\n")} if (result && result.resolvedModule) (_b = perfLogger) == null ? void 0 : _b.logInfoEvent(`Module "${moduleName}" resolved to "${result.resolvedModule.resolvedFileName}"`); (_c = perfLogger) == null ? void 0 : _c.logStopResolveModule(result && result.resolvedModule ? "" + result.resolvedModule.resolvedFileName : "null"); - cache == null ? void 0 : cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result); - if (!isExternalModuleNameRelative(moduleName)) { - cache == null ? void 0 : cache.getOrCreateCacheForNonRelativeName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result); + if (cache && !cache.isReadonly) { + cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result); + if (!isExternalModuleNameRelative(moduleName)) { + cache.getOrCreateCacheForNonRelativeName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result); + } } } if (traceEnabled) { @@ -40374,7 +40444,7 @@ ${lanes.join("\n")} const moduleResolution = getEmitModuleResolutionKind(compilerOptions); conditions ?? (conditions = getConditions( compilerOptions, - moduleResolution === 100 /* Bundler */ || moduleResolution === 2 /* Node10 */ ? void 0 : !!(features & 32 /* EsmMode */) + moduleResolution === 100 /* Bundler */ || moduleResolution === 2 /* Node10 */ ? void 0 : features & 32 /* EsmMode */ ? 99 /* ESNext */ : 1 /* CommonJS */ )); const diagnostics = []; const state = { @@ -40423,6 +40493,7 @@ ${lanes.join("\n")} affectingLocations, diagnostics, state, + cache, legacyResult ); function tryResolve(extensions2, state2) { @@ -40683,15 +40754,7 @@ ${lanes.join("\n")} entrypoints = append(entrypoints, mainResolution == null ? void 0 : mainResolution.path); if (features & 8 /* Exports */ && packageJsonInfo.contents.packageJsonContent.exports) { const conditionSets = deduplicate( - [getConditions( - options, - /*esmMode*/ - true - ), getConditions( - options, - /*esmMode*/ - false - )], + [getConditions(options, 99 /* ESNext */), getConditions(options, 1 /* CommonJS */)], arrayIsEqualTo ); for (const conditions of conditionSets) { @@ -40823,7 +40886,7 @@ ${lanes.join("\n")} return packageJsonInfo.contents.versionPaths || void 0; } function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) { - var _a, _b, _c, _d, _e, _f, _g, _h; + var _a, _b, _c, _d, _e, _f; const { host, traceEnabled } = state; const packageJsonPath = combinePaths(packageDirectory, "package.json"); if (onlyRecordFailures) { @@ -40851,15 +40914,17 @@ ${lanes.join("\n")} trace(host, Diagnostics.Found_package_json_at_0, packageJsonPath); } const result = { packageDirectory, contents: { packageJsonContent, versionPaths: void 0, resolvedEntrypoints: void 0 } }; - (_e = state.packageJsonInfoCache) == null ? void 0 : _e.setPackageJsonInfo(packageJsonPath, result); - (_f = state.affectingLocations) == null ? void 0 : _f.push(packageJsonPath); + if (state.packageJsonInfoCache && !state.packageJsonInfoCache.isReadonly) + state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, result); + (_e = state.affectingLocations) == null ? void 0 : _e.push(packageJsonPath); return result; } else { if (directoryExists && traceEnabled) { trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath); } - (_g = state.packageJsonInfoCache) == null ? void 0 : _g.setPackageJsonInfo(packageJsonPath, directoryExists); - (_h = state.failedLookupLocations) == null ? void 0 : _h.push(packageJsonPath); + if (state.packageJsonInfoCache && !state.packageJsonInfoCache.isReadonly) + state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, directoryExists); + (_f = state.failedLookupLocations) == null ? void 0 : _f.push(packageJsonPath); } } function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) { @@ -41648,7 +41713,8 @@ ${lanes.join("\n")} failedLookupLocations, affectingLocations, diagnostics, - state + state, + cache ); function tryResolve(extensions) { const resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state); @@ -41767,7 +41833,9 @@ ${lanes.join("\n")} failedLookupLocations, affectingLocations, diagnostics, - state.resultFromCache + state.resultFromCache, + /*cache*/ + void 0 ); } function toSearchResult(value) { @@ -41839,7 +41907,7 @@ ${lanes.join("\n")} break; case 272 /* ImportDeclaration */: case 271 /* ImportEqualsDeclaration */: - if (!hasSyntacticModifier(node, 1 /* Export */)) { + if (!hasSyntacticModifier(node, 32 /* Export */)) { return 0 /* NonInstantiated */; } break; @@ -42116,7 +42184,7 @@ ${lanes.join("\n")} } function declareSymbol(symbolTable, parent3, node, includes, excludes, isReplaceableByMethod, isComputedName) { Debug.assert(isComputedName || !hasDynamicName(node)); - const isDefaultExport = hasSyntacticModifier(node, 1024 /* Default */) || isExportSpecifier(node) && node.name.escapedText === "default"; + const isDefaultExport = hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) && node.name.escapedText === "default"; const name = isComputedName ? "__computed" /* Computed */ : isDefaultExport && parent3 ? "default" /* Default */ : getDeclarationName(node); let symbol; if (name === void 0) { @@ -42160,7 +42228,7 @@ ${lanes.join("\n")} } } const relatedInformation = []; - if (isTypeAliasDeclaration(node) && nodeIsMissing(node.type) && hasSyntacticModifier(node, 1 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) { + if (isTypeAliasDeclaration(node) && nodeIsMissing(node.type) && hasSyntacticModifier(node, 32 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) { relatedInformation.push(createDiagnosticForNode2(node, Diagnostics.Did_you_mean_0, `export type { ${unescapeLeadingUnderscores(node.name.escapedText)} }`)); } const declarationName = getNameOfDeclaration(node) || node; @@ -42189,7 +42257,7 @@ ${lanes.join("\n")} return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - const hasExportModifier = !!(getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); + const hasExportModifier = !!(getCombinedModifierFlags(node) & 32 /* Export */) || jsdocTreatAsExported(node); if (symbolFlags & 2097152 /* Alias */) { if (node.kind === 281 /* ExportSpecifier */ || node.kind === 271 /* ImportEqualsDeclaration */ && hasExportModifier) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); @@ -42208,7 +42276,7 @@ ${lanes.join("\n")} if (isJSDocTypeAlias(node)) Debug.assert(isInJSFile(node)); if (!isAmbientModule(node) && (hasExportModifier || container.flags & 128 /* ExportContext */)) { - if (!canHaveLocals(container) || !container.locals || hasSyntacticModifier(node, 1024 /* Default */) && !getDeclarationName(node)) { + if (!canHaveLocals(container) || !container.locals || hasSyntacticModifier(node, 2048 /* Default */) && !getDeclarationName(node)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } const exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; @@ -42249,7 +42317,7 @@ ${lanes.join("\n")} return false; if (isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent)) return true; - if (isDeclaration(declName.parent) && getCombinedModifierFlags(declName.parent) & 1 /* Export */) + if (isDeclaration(declName.parent) && getCombinedModifierFlags(declName.parent) & 32 /* Export */) return true; return false; } @@ -42280,7 +42348,7 @@ ${lanes.join("\n")} const saveExceptionTarget = currentExceptionTarget; const saveActiveLabelList = activeLabelList; const saveHasExplicitReturn = hasExplicitReturn; - const isImmediatelyInvoked = containerFlags & 16 /* IsFunctionExpression */ && !hasSyntacticModifier(node, 512 /* Async */) && !node.asteriskToken && !!getImmediatelyInvokedFunctionExpression(node) || node.kind === 175 /* ClassStaticBlockDeclaration */; + const isImmediatelyInvoked = containerFlags & 16 /* IsFunctionExpression */ && !hasSyntacticModifier(node, 1024 /* Async */) && !node.asteriskToken && !!getImmediatelyInvokedFunctionExpression(node) || node.kind === 175 /* ClassStaticBlockDeclaration */; if (!isImmediatelyInvoked) { currentFlow = initFlowNode({ flags: 2 /* Start */ }); if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { @@ -43327,7 +43395,7 @@ ${lanes.join("\n")} function bindModuleDeclaration(node) { setExportContextFlag(node); if (isAmbientModule(node)) { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (isModuleAugmentationExternal(node)) { @@ -44388,7 +44456,7 @@ ${lanes.join("\n")} } if (!isBindingPattern(node.name)) { const possibleVariableDecl = node.kind === 260 /* VariableDeclaration */ ? node : node.parent.parent; - if (isInJSFile(node) && shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) { + if (isInJSFile(node) && shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 32 /* Export */)) { declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); } else if (isBlockOrCatchScoped(node)) { bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); @@ -44540,7 +44608,7 @@ ${lanes.join("\n")} case 267 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; case 266 /* EnumDeclaration */: - return hasSyntacticModifier(s, 2048 /* Const */); + return hasSyntacticModifier(s, 4096 /* Const */); default: return false; } @@ -44937,10 +45005,12 @@ ${lanes.join("\n")} importingSourceFile, host, userPreferences, - options + options, + /*forAutoImport*/ + false ).moduleSpecifiers; } - function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences, options = {}) { + function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) { let computedWithoutCache = false; const ambient = tryGetModuleNameFromAmbientModule(moduleSymbol, checker); if (ambient) @@ -44958,11 +45028,19 @@ ${lanes.join("\n")} return { moduleSpecifiers: emptyArray, computedWithoutCache }; computedWithoutCache = true; modulePaths || (modulePaths = getAllModulePathsWorker(importingSourceFile.path, moduleSourceFile.originalFileName, host)); - const result = computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options); + const result = computeModuleSpecifiers( + modulePaths, + compilerOptions, + importingSourceFile, + host, + userPreferences, + options, + forAutoImport + ); cache == null ? void 0 : cache.set(importingSourceFile.path, moduleSourceFile.path, userPreferences, options, modulePaths, result); return { moduleSpecifiers: result, computedWithoutCache }; } - function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}) { + function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) { const info = getInfo(importingSourceFile.path, host); const preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); const existingSpecifier = forEach(modulePaths, (modulePath) => forEach( @@ -45019,7 +45097,7 @@ ${lanes.join("\n")} redirectPathsSpecifiers = append(redirectPathsSpecifiers, local); } else if (pathIsBareSpecifier(local)) { pathsSpecifiers = append(pathsSpecifiers, local); - } else if (!importedFileIsInNodeModules || modulePath.isInNodeModules) { + } else if (forAutoImport || !importedFileIsInNodeModules || modulePath.isInNodeModules) { relativeSpecifiers = append(relativeSpecifiers, local); } } @@ -45410,7 +45488,7 @@ ${lanes.join("\n")} if (getResolvePackageJsonExports(options)) { const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1); const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2); - const conditions = getConditions(options, importMode === 99 /* ESNext */); + const conditions = getConditions(options, importMode); const fromExports = packageJsonContent.exports ? tryGetModuleNameFromExports(options, path, packageRootPath, packageName2, packageJsonContent.exports, conditions) : void 0; if (fromExports) { const withJsExtension = !hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) }; @@ -47601,7 +47679,7 @@ ${lanes.join("\n")} if (lastLocation && lastLocation === location.name) { return false; } - if (location.asteriskToken || hasSyntacticModifier(location, 512 /* Async */)) { + if (location.asteriskToken || hasSyntacticModifier(location, 1024 /* Async */)) { return true; } return !getImmediatelyInvokedFunctionExpression(location); @@ -47765,8 +47843,17 @@ ${lanes.join("\n")} function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { if (meaning & 111551 /* Value */) { if (isPrimitiveTypeName(name)) { - if (isExtendedByInterface(errorLocation)) { - error2(errorLocation, Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes, unescapeLeadingUnderscores(name)); + const grandparent = errorLocation.parent.parent; + if (grandparent && grandparent.parent && isHeritageClause(grandparent)) { + const heritageKind = grandparent.token; + const containerKind = grandparent.parent.kind; + if (containerKind === 264 /* InterfaceDeclaration */ && heritageKind === 96 /* ExtendsKeyword */) { + error2(errorLocation, Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_It_can_only_extend_other_named_object_types, unescapeLeadingUnderscores(name)); + } else if (containerKind === 263 /* ClassDeclaration */ && heritageKind === 96 /* ExtendsKeyword */) { + error2(errorLocation, Diagnostics.A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values, unescapeLeadingUnderscores(name)); + } else if (containerKind === 263 /* ClassDeclaration */ && heritageKind === 119 /* ImplementsKeyword */) { + error2(errorLocation, Diagnostics.A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types, unescapeLeadingUnderscores(name)); + } } else { error2(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, unescapeLeadingUnderscores(name)); } @@ -47798,16 +47885,6 @@ ${lanes.join("\n")} } return false; } - function isExtendedByInterface(node) { - const grandparent = node.parent.parent; - const parentOfGrandparent = grandparent.parent; - if (grandparent && parentOfGrandparent) { - const isExtending = isHeritageClause(grandparent) && grandparent.token === 96 /* ExtendsKeyword */; - const isInterface = isInterfaceDeclaration(parentOfGrandparent); - return isExtending && isInterface; - } - return false; - } function maybeMappedType(node, symbol) { const container = findAncestor(node.parent, (n) => isComputedPropertyName(n) || isPropertySignature(n) ? false : isTypeLiteralNode(n) || "quit"); if (container && container.members.length === 1) { @@ -47986,7 +48063,7 @@ ${lanes.join("\n")} return resolved; } function isSyntacticDefault(node) { - return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 1024 /* Default */) || isExportSpecifier(node); + return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) || isNamespaceExport(node); } function getUsageModeForExpression(usage) { return isStringLiteralLike(usage) ? getModeForUsageLocation(getSourceFileOfNode(usage), usage) : void 0; @@ -49912,20 +49989,20 @@ ${lanes.join("\n")} var _a, _b; if (!isDeclarationVisible(declaration)) { const anyImportSyntax = getAnyImportSyntax(declaration); - if (anyImportSyntax && !hasSyntacticModifier(anyImportSyntax, 1 /* Export */) && // import clause without export + if (anyImportSyntax && !hasSyntacticModifier(anyImportSyntax, 32 /* Export */) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { return addVisibleAlias(declaration, anyImportSyntax); - } else if (isVariableDeclaration(declaration) && isVariableStatement(declaration.parent.parent) && !hasSyntacticModifier(declaration.parent.parent, 1 /* Export */) && // unexported variable statement + } else if (isVariableDeclaration(declaration) && isVariableStatement(declaration.parent.parent) && !hasSyntacticModifier(declaration.parent.parent, 32 /* Export */) && // unexported variable statement isDeclarationVisible(declaration.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent); - } else if (isLateVisibilityPaintedStatement(declaration) && !hasSyntacticModifier(declaration, 1 /* Export */) && isDeclarationVisible(declaration.parent)) { + } else if (isLateVisibilityPaintedStatement(declaration) && !hasSyntacticModifier(declaration, 32 /* Export */) && isDeclarationVisible(declaration.parent)) { return addVisibleAlias(declaration, declaration); } else if (isBindingElement(declaration)) { - if (symbol.flags & 2097152 /* Alias */ && isInJSFile(declaration) && ((_a = declaration.parent) == null ? void 0 : _a.parent) && isVariableDeclaration(declaration.parent.parent) && ((_b = declaration.parent.parent.parent) == null ? void 0 : _b.parent) && isVariableStatement(declaration.parent.parent.parent.parent) && !hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */) && declaration.parent.parent.parent.parent.parent && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { + if (symbol.flags & 2097152 /* Alias */ && isInJSFile(declaration) && ((_a = declaration.parent) == null ? void 0 : _a.parent) && isVariableDeclaration(declaration.parent.parent) && ((_b = declaration.parent.parent.parent) == null ? void 0 : _b.parent) && isVariableStatement(declaration.parent.parent.parent.parent) && !hasSyntacticModifier(declaration.parent.parent.parent.parent, 32 /* Export */) && declaration.parent.parent.parent.parent.parent && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); } else if (symbol.flags & 2 /* BlockScopedVariable */) { const variableStatement = findAncestor(declaration, isVariableStatement); - if (hasSyntacticModifier(variableStatement, 1 /* Export */)) { + if (hasSyntacticModifier(variableStatement, 32 /* Export */)) { return true; } if (!isDeclarationVisible(variableStatement.parent)) { @@ -50148,7 +50225,8 @@ ${lanes.join("\n")} visitedTypes: void 0, symbolDepth: void 0, inferTypeParameters: void 0, - approximateLength: 0 + approximateLength: 0, + trackedSymbols: void 0 }; context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost); const resultingNode = cb(context); @@ -50602,7 +50680,7 @@ ${lanes.join("\n")} } } function visitAndTransformType(type2, transform2) { - var _a2, _b2; + var _a2, _b2, _c; const typeId = type2.id; const isConstructorObject = getObjectFlags(type2) & 16 /* Anonymous */ && type2.symbol && type2.symbol.flags & 32 /* Class */; const id = getObjectFlags(type2) & 4 /* Reference */ && type2.node ? "N" + getNodeId(type2.node) : type2.flags & 16777216 /* Conditional */ ? "N" + getNodeId(type2.root.node) : type2.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type2.symbol) : void 0; @@ -50619,6 +50697,13 @@ ${lanes.join("\n")} } const cachedResult = (_a2 = links == null ? void 0 : links.serializedTypes) == null ? void 0 : _a2.get(key); if (cachedResult) { + (_b2 = cachedResult.trackedSymbols) == null ? void 0 : _b2.forEach( + ([symbol, enclosingDeclaration, meaning]) => context.tracker.trackSymbol( + symbol, + enclosingDeclaration, + meaning + ) + ); if (cachedResult.truncating) { context.truncating = true; } @@ -50638,7 +50723,12 @@ ${lanes.join("\n")} const result = transform2(type2); const addedLength = context.approximateLength - startLength; if (!context.reportedDiagnostic && !context.encounteredError) { - (_b2 = links == null ? void 0 : links.serializedTypes) == null ? void 0 : _b2.set(key, { node: result, truncating: context.truncating, addedLength }); + (_c = links == null ? void 0 : links.serializedTypes) == null ? void 0 : _c.set(key, { + node: result, + truncating: context.truncating, + addedLength, + trackedSymbols: context.trackedSymbols + }); } context.visitedTypes.delete(typeId); if (id) { @@ -50880,7 +50970,7 @@ ${lanes.join("\n")} if (propertySymbol.flags & 4194304 /* Prototype */) { continue; } - if (getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* Private */ | 16 /* Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { + if (getDeclarationModifierFlagsFromSymbol(propertySymbol) & (2 /* Private */ | 4 /* Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { context.tracker.reportPrivateInBaseOfClassExpression(unescapeLeadingUnderscores(propertySymbol.escapedName)); } } @@ -50944,6 +51034,28 @@ ${lanes.join("\n")} const propertyName = getPropertyNameNodeForSymbol(propertySymbol, context); context.enclosingDeclaration = saveEnclosingDeclaration; context.approximateLength += symbolName(propertySymbol).length + 1; + if (propertySymbol.flags & 98304 /* Accessor */) { + const writeType = getWriteTypeOfSymbol(propertySymbol); + if (propertyType !== writeType) { + const getterDeclaration = getDeclarationOfKind(propertySymbol, 177 /* GetAccessor */); + const getterSignature = getSignatureFromDeclaration(getterDeclaration); + typeElements.push( + setCommentRange( + signatureToSignatureDeclarationHelper(getterSignature, 177 /* GetAccessor */, context, { name: propertyName }), + getterDeclaration + ) + ); + const setterDeclaration = getDeclarationOfKind(propertySymbol, 178 /* SetAccessor */); + const setterSignature = getSignatureFromDeclaration(setterDeclaration); + typeElements.push( + setCommentRange( + signatureToSignatureDeclarationHelper(setterSignature, 178 /* SetAccessor */, context, { name: propertyName }), + setterDeclaration + ) + ); + return; + } + } const optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags & 32768 /* Undefined */)), 0 /* Call */); @@ -50981,9 +51093,9 @@ ${lanes.join("\n")} typeElements.push(preserveCommentsOn(propertySignature)); function preserveCommentsOn(node) { var _a2; - if (some(propertySymbol.declarations, (d) => d.kind === 355 /* JSDocPropertyTag */)) { - const d = (_a2 = propertySymbol.declarations) == null ? void 0 : _a2.find((d2) => d2.kind === 355 /* JSDocPropertyTag */); - const commentText = getTextOfJSDocComment(d.comment); + const jsdocPropertyTag = (_a2 = propertySymbol.declarations) == null ? void 0 : _a2.find((d) => d.kind === 355 /* JSDocPropertyTag */); + if (jsdocPropertyTag) { + const commentText = getTextOfJSDocComment(jsdocPropertyTag.comment); if (commentText) { setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); } @@ -51161,7 +51273,7 @@ ${lanes.join("\n")} let modifiers = options == null ? void 0 : options.modifiers; if (kind === 185 /* ConstructorType */ && signature.flags & 4 /* Abstract */) { const flags = modifiersToFlags(modifiers); - modifiers = factory.createModifiersFromModifierFlags(flags | 256 /* Abstract */); + modifiers = factory.createModifiersFromModifierFlags(flags | 64 /* Abstract */); } const node = kind === 179 /* CallSignature */ ? factory.createCallSignature(typeParameters, parameters, returnTypeNode) : kind === 180 /* ConstructSignature */ ? factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : kind === 173 /* MethodSignature */ ? factory.createMethodSignature(modifiers, (options == null ? void 0 : options.name) ?? factory.createIdentifier(""), options == null ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : kind === 174 /* MethodDeclaration */ ? factory.createMethodDeclaration( modifiers, @@ -52218,7 +52330,7 @@ ${lanes.join("\n")} const nsIndex = findIndex(statements, isModuleDeclaration); let ns = nsIndex !== -1 ? statements[nsIndex] : void 0; if (ns && exportAssignment && exportAssignment.isExportEquals && isIdentifier(exportAssignment.expression) && isIdentifier(ns.name) && idText(ns.name) === idText(exportAssignment.expression) && ns.body && isModuleBlock(ns.body)) { - const excessExports = filter(statements, (s) => !!(getEffectiveModifierFlags(s) & 1 /* Export */)); + const excessExports = filter(statements, (s) => !!(getEffectiveModifierFlags(s) & 32 /* Export */)); const name = ns.name; let body = ns.body; if (length(excessExports)) { @@ -52252,9 +52364,9 @@ ${lanes.join("\n")} } if (!find(statements, (s) => s !== ns && nodeHasName(s, name))) { results = []; - const mixinExportFlag = !some(body.statements, (s) => hasSyntacticModifier(s, 1 /* Export */) || isExportAssignment(s) || isExportDeclaration(s)); + const mixinExportFlag = !some(body.statements, (s) => hasSyntacticModifier(s, 32 /* Export */) || isExportAssignment(s) || isExportDeclaration(s)); forEach(body.statements, (s) => { - addResult(s, mixinExportFlag ? 1 /* Export */ : 0 /* None */); + addResult(s, mixinExportFlag ? 32 /* Export */ : 0 /* None */); }); statements = [...filter(statements, (s) => s !== ns && s !== exportAssignment), ...results]; } @@ -52346,12 +52458,12 @@ ${lanes.join("\n")} return statements; } function addExportModifier(node) { - const flags = (getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */; - return factory.updateModifiers(node, flags); + const flags = (getEffectiveModifierFlags(node) | 32 /* Export */) & ~128 /* Ambient */; + return factory.replaceModifiers(node, flags); } function removeExportModifier(node) { - const flags = getEffectiveModifierFlags(node) & ~1 /* Export */; - return factory.updateModifiers(node, flags); + const flags = getEffectiveModifierFlags(node) & ~32 /* Export */; + return factory.replaceModifiers(node, flags); } function visitSymbolTable(symbolTable2, suppressNewPrivateContext, propertyAsAlias) { if (!suppressNewPrivateContext) { @@ -52391,6 +52503,12 @@ ${lanes.join("\n")} if (context.reportedDiagnostic) { oldcontext.reportedDiagnostic = context.reportedDiagnostic; } + if (context.trackedSymbols) { + if (!oldContext.trackedSymbols) + oldContext.trackedSymbols = context.trackedSymbols; + else + Debug.assert(context.trackedSymbols === oldContext.trackedSymbols); + } context = oldContext; } } @@ -52407,7 +52525,7 @@ ${lanes.join("\n")} if (needsPostExportDefault || needsExportDeclaration) { isPrivate = true; } - const modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 1024 /* Default */ : 0); + const modifierFlags = (!isPrivate ? 32 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 2048 /* Default */ : 0); const isConstMergedWithNS = symbol.flags & 1536 /* Module */ && symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && escapedSymbolName !== "export=" /* ExportEquals */; const isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); if (symbol.flags & (16 /* Function */ | 8192 /* Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { @@ -52477,7 +52595,7 @@ ${lanes.join("\n")} ), textRange ); - addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + addResult(statement, name !== localName ? modifierFlags & ~32 /* Export */ : modifierFlags); if (name !== localName && !isPrivate) { addResult( factory.createExportDeclaration( @@ -52582,17 +52700,17 @@ ${lanes.join("\n")} if (canHaveModifiers(node)) { let newModifierFlags = 0 /* None */; const enclosingDeclaration2 = context.enclosingDeclaration && (isJSDocTypeAlias(context.enclosingDeclaration) ? getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); - if (additionalModifierFlags & 1 /* Export */ && enclosingDeclaration2 && (isExportingScope(enclosingDeclaration2) || isModuleDeclaration(enclosingDeclaration2)) && canHaveExportModifier(node)) { - newModifierFlags |= 1 /* Export */; + if (additionalModifierFlags & 32 /* Export */ && enclosingDeclaration2 && (isExportingScope(enclosingDeclaration2) || isModuleDeclaration(enclosingDeclaration2)) && canHaveExportModifier(node)) { + newModifierFlags |= 32 /* Export */; } - if (addingDeclare && !(newModifierFlags & 1 /* Export */) && (!enclosingDeclaration2 || !(enclosingDeclaration2.flags & 33554432 /* Ambient */)) && (isEnumDeclaration(node) || isVariableStatement(node) || isFunctionDeclaration(node) || isClassDeclaration(node) || isModuleDeclaration(node))) { - newModifierFlags |= 2 /* Ambient */; + if (addingDeclare && !(newModifierFlags & 32 /* Export */) && (!enclosingDeclaration2 || !(enclosingDeclaration2.flags & 33554432 /* Ambient */)) && (isEnumDeclaration(node) || isVariableStatement(node) || isFunctionDeclaration(node) || isClassDeclaration(node) || isModuleDeclaration(node))) { + newModifierFlags |= 128 /* Ambient */; } - if (additionalModifierFlags & 1024 /* Default */ && (isClassDeclaration(node) || isInterfaceDeclaration(node) || isFunctionDeclaration(node))) { - newModifierFlags |= 1024 /* Default */; + if (additionalModifierFlags & 2048 /* Default */ && (isClassDeclaration(node) || isInterfaceDeclaration(node) || isFunctionDeclaration(node))) { + newModifierFlags |= 2048 /* Default */; } if (newModifierFlags) { - node = factory.updateModifiers(node, newModifierFlags | getEffectiveModifierFlags(node)); + node = factory.replaceModifiers(node, newModifierFlags | getEffectiveModifierFlags(node)); } } results.push(node); @@ -52711,7 +52829,7 @@ ${lanes.join("\n")} function serializeEnum(symbol, symbolName2, modifierFlags) { addResult( factory.createEnumDeclaration( - factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), + factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 4096 /* Const */ : 0), getInternalSymbolName(symbol, symbolName2), map(filter(getPropertiesOfType(getTypeOfSymbol(symbol)), (p) => !!(p.flags & 8 /* EnumMember */)), (p) => { const initializedValue = p.declarations && p.declarations[0] && isEnumMember(p.declarations[0]) ? getConstantValue2(p.declarations[0]) : void 0; @@ -52795,7 +52913,7 @@ ${lanes.join("\n")} factory.createIdentifier("default" /* Default */) )]) ) : d); - const exportModifierStripped = every(defaultReplaced, (d) => hasSyntacticModifier(d, 1 /* Export */)) ? map(defaultReplaced, removeExportModifier) : defaultReplaced; + const exportModifierStripped = every(defaultReplaced, (d) => hasSyntacticModifier(d, 32 /* Export */)) ? map(defaultReplaced, removeExportModifier) : defaultReplaced; fakespace = factory.updateModuleDeclaration( fakespace, fakespace.modifiers, @@ -52898,7 +53016,7 @@ ${lanes.join("\n")} ); const isNonConstructableClassLikeInJsFile = !isClass && !!symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && !some(getSignaturesOfType(staticType, 1 /* Construct */)); const constructors = isNonConstructableClassLikeInJsFile ? [factory.createConstructorDeclaration( - factory.createModifiersFromModifierFlags(8 /* Private */), + factory.createModifiersFromModifierFlags(2 /* Private */), [], /*body*/ void 0 @@ -53251,7 +53369,7 @@ ${lanes.join("\n")} const varName = getUnusedName(name, symbol); const typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol))); if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { - serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 1 /* Export */); + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 32 /* Export */); } else { const flags = ((_a2 = context.enclosingDeclaration) == null ? void 0 : _a2.kind) === 267 /* ModuleDeclaration */ && (!(symbol.flags & 98304 /* Accessor */) || symbol.flags & 65536 /* SetAccessor */) ? 1 /* Let */ : 2 /* Const */; const statement = factory.createVariableStatement( @@ -53268,7 +53386,7 @@ ${lanes.join("\n")} ); addResult( statement, - target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ : name === varName ? 1 /* Export */ : 0 /* None */ + target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 128 /* Ambient */ : name === varName ? 32 /* Export */ : 0 /* None */ ); } if (isExportAssignmentCompatibleSymbolName) { @@ -53290,20 +53408,28 @@ ${lanes.join("\n")} const ctxSrc = getSourceFileOfNode(context.enclosingDeclaration); return getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && !length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class !!(length(filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && !length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK - !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && some(typeToSerialize.symbol.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && !some(getPropertiesOfType(typeToSerialize), (p) => isLateBoundName(p.escapedName)) && !some(getPropertiesOfType(typeToSerialize), (p) => some(p.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && every(getPropertiesOfType(typeToSerialize), (p) => isIdentifierText(symbolName(p), languageVersion)); + !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && some(typeToSerialize.symbol.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && !some(getPropertiesOfType(typeToSerialize), (p) => isLateBoundName(p.escapedName)) && !some(getPropertiesOfType(typeToSerialize), (p) => some(p.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && every(getPropertiesOfType(typeToSerialize), (p) => { + if (!isIdentifierText(symbolName(p), languageVersion)) { + return false; + } + if (!(p.flags & 98304 /* Accessor */)) { + return true; + } + return getNonMissingTypeOfSymbol(p) === getWriteTypeOfSymbol(p); + }); } function makeSerializePropertySymbol(createProperty2, methodKind, useAccessors) { return function serializePropertySymbol(p, isStatic2, baseType) { var _a2, _b, _c, _d, _e; const modifierFlags = getDeclarationModifierFlagsFromSymbol(p); - const isPrivate = !!(modifierFlags & 8 /* Private */); + const isPrivate = !!(modifierFlags & 2 /* Private */); if (isStatic2 && p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) { return []; } if (p.flags & 4194304 /* Prototype */ || p.escapedName === "constructor" || baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName))) { return []; } - const flag = modifierFlags & ~512 /* Async */ | (isStatic2 ? 32 /* Static */ : 0); + const flag = modifierFlags & ~1024 /* Async */ | (isStatic2 ? 256 /* Static */ : 0); const name = getPropertyNameNodeForSymbol(p, context); const firstPropertyLikeDecl = (_a2 = p.declarations) == null ? void 0 : _a2.find(or(isPropertyDeclaration, isAccessor, isVariableDeclaration, isPropertySignature, isBinaryExpression, isPropertyAccessExpression)); if (p.flags & 98304 /* Accessor */ && useAccessors) { @@ -53345,7 +53471,7 @@ ${lanes.join("\n")} )); } if (p.flags & 32768 /* GetAccessor */) { - const isPrivate2 = modifierFlags & 8 /* Private */; + const isPrivate2 = modifierFlags & 2 /* Private */; result.push(setTextRange( factory.createGetAccessorDeclaration( factory.createModifiersFromModifierFlags(flag), @@ -53362,7 +53488,7 @@ ${lanes.join("\n")} } else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) { return setTextRange( createProperty2( - factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), + factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0, isPrivate ? void 0 : serializeTypeForDeclaration(context, getWriteTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), @@ -53377,10 +53503,10 @@ ${lanes.join("\n")} if (p.flags & (8192 /* Method */ | 16 /* Function */)) { const type = getTypeOfSymbol(p); const signatures = getSignaturesOfType(type, 0 /* Call */); - if (flag & 8 /* Private */) { + if (flag & 2 /* Private */) { return setTextRange( createProperty2( - factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), + factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0, /*type*/ @@ -53456,7 +53582,7 @@ ${lanes.join("\n")} let privateProtected = 0; for (const s of signatures) { if (s.declaration) { - privateProtected |= getSelectedEffectiveModifierFlags(s.declaration, 8 /* Private */ | 16 /* Protected */); + privateProtected |= getSelectedEffectiveModifierFlags(s.declaration, 2 /* Private */ | 4 /* Protected */); } } if (privateProtected) { @@ -53649,10 +53775,10 @@ ${lanes.join("\n")} return result || types; } function visibilityToString(flags) { - if (flags === 8 /* Private */) { + if (flags === 2 /* Private */) { return "private"; } - if (flags === 16 /* Protected */) { + if (flags === 4 /* Protected */) { return "protected"; } return "public"; @@ -53770,7 +53896,7 @@ ${lanes.join("\n")} return true; } const parent2 = getDeclarationContainer(node); - if (!(getCombinedModifierFlagsCached(node) & 1 /* Export */) && !(node.kind !== 271 /* ImportEqualsDeclaration */ && parent2.kind !== 312 /* SourceFile */ && parent2.flags & 33554432 /* Ambient */)) { + if (!(getCombinedModifierFlagsCached(node) & 32 /* Export */) && !(node.kind !== 271 /* ImportEqualsDeclaration */ && parent2.kind !== 312 /* SourceFile */ && parent2.flags & 33554432 /* Ambient */)) { return isGlobalSourceFile(parent2); } return isDeclarationVisible(parent2); @@ -53780,7 +53906,7 @@ ${lanes.join("\n")} case 178 /* SetAccessor */: case 174 /* MethodDeclaration */: case 173 /* MethodSignature */: - if (hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { + if (hasEffectiveModifier(node, 2 /* Private */ | 4 /* Protected */)) { return false; } case 176 /* Constructor */: @@ -53999,7 +54125,7 @@ ${lanes.join("\n")} const unspreadableToRestKeys = []; for (const prop of getPropertiesOfType(source)) { const literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */); - if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) && !(getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) && isSpreadableProperty(prop)) { + if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) && !(getDeclarationModifierFlagsFromSymbol(prop) & (2 /* Private */ | 4 /* Protected */)) && isSpreadableProperty(prop)) { spreadableProperties.push(prop); } else { unspreadableToRestKeys.push(literalTypeFromProperty); @@ -54205,7 +54331,7 @@ ${lanes.join("\n")} if (declaredType) { return addOptionality(declaredType, isProperty, isOptional); } - if ((noImplicitAny || isInJSFile(declaration)) && isVariableDeclaration(declaration) && !isBindingPattern(declaration.name) && !(getCombinedModifierFlagsCached(declaration) & 1 /* Export */) && !(declaration.flags & 33554432 /* Ambient */)) { + if ((noImplicitAny || isInJSFile(declaration)) && isVariableDeclaration(declaration) && !isBindingPattern(declaration.name) && !(getCombinedModifierFlagsCached(declaration) & 32 /* Export */) && !(declaration.flags & 33554432 /* Ambient */)) { if (!(getCombinedNodeFlagsCached(declaration) & 6 /* Constant */) && (!declaration.initializer || isNullOrUndefined3(declaration.initializer))) { return autoType; } @@ -54253,7 +54379,7 @@ ${lanes.join("\n")} if (isPropertyDeclaration(declaration) && (noImplicitAny || isInJSFile(declaration))) { if (!hasStaticModifier(declaration)) { const constructor = findConstructorDeclaration(declaration.parent); - const type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : void 0; + const type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : getEffectiveModifierFlags(declaration) & 128 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : void 0; return type && addOptionality( type, /*isProperty*/ @@ -54262,7 +54388,7 @@ ${lanes.join("\n")} ); } else { const staticBlocks = filter(declaration.parent.members, isClassStaticBlockDeclaration); - const type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) : getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : void 0; + const type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) : getEffectiveModifierFlags(declaration) & 128 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : void 0; return type && addOptionality( type, /*isProperty*/ @@ -54366,7 +54492,7 @@ ${lanes.join("\n")} return everyType(flowType, isNullableType) ? void 0 : convertAutoToAny(flowType); } function getFlowTypeOfProperty(reference, prop) { - const initialType = (prop == null ? void 0 : prop.valueDeclaration) && (!isAutoTypedProperty(prop) || getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; + const initialType = (prop == null ? void 0 : prop.valueDeclaration) && (!isAutoTypedProperty(prop) || getEffectiveModifierFlags(prop.valueDeclaration) & 128 /* Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); } function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) { @@ -54990,6 +55116,9 @@ ${lanes.join("\n")} function getTypeOfAlias(symbol) { const links = getSymbolLinks(symbol); if (!links.type) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return errorType; + } const targetSymbol = resolveAlias(symbol); const exportSymbol = symbol.declarations && getTargetOfAliasDeclaration( getDeclarationOfAliasSymbol(symbol), @@ -54998,6 +55127,10 @@ ${lanes.join("\n")} ); const declaredType = firstDefined(exportSymbol == null ? void 0 : exportSymbol.declarations, (d) => isExportAssignment(d) ? tryGetTypeFromEffectiveTypeNode(d) : void 0); links.type = (exportSymbol == null ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType : getSymbolFlags(targetSymbol) & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType; + if (!popTypeResolution()) { + reportCircularityError(exportSymbol ?? symbol); + return links.type = errorType; + } } return links.type; } @@ -55011,12 +55144,19 @@ ${lanes.join("\n")} } function reportCircularityError(symbol) { const declaration = symbol.valueDeclaration; - if (getEffectiveTypeAnnotationNode(declaration)) { - error2(symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); - return errorType; - } - if (noImplicitAny && (declaration.kind !== 169 /* Parameter */ || declaration.initializer)) { - error2(symbol.valueDeclaration, Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); + if (declaration) { + if (getEffectiveTypeAnnotationNode(declaration)) { + error2(symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); + return errorType; + } + if (noImplicitAny && (declaration.kind !== 169 /* Parameter */ || declaration.initializer)) { + error2(symbol.valueDeclaration, Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); + } + } else if (symbol.flags & 2097152 /* Alias */) { + const node = getDeclarationOfAliasSymbol(symbol); + if (node) { + error2(node, Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); + } } return anyType; } @@ -56019,7 +56159,7 @@ ${lanes.join("\n")} const baseConstructorType = getBaseConstructorTypeOfClass(classType); const baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); const declaration = getClassLikeDeclarationOfSymbol(classType.symbol); - const isAbstract = !!declaration && hasSyntacticModifier(declaration, 256 /* Abstract */); + const isAbstract = !!declaration && hasSyntacticModifier(declaration, 64 /* Abstract */); if (baseSignatures.length === 0) { return [createSignature( /*declaration*/ @@ -56795,7 +56935,7 @@ ${lanes.join("\n")} } function isConstTypeVariable(type, depth = 0) { var _a; - return depth < 5 && !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 3145728 /* UnionOrIntersection */ && some(type.types, (t) => isConstTypeVariable(t, depth)) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType, depth + 1) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type), depth + 1) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType, depth) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t, depth)) >= 0)); + return depth < 5 && !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 4096 /* Const */)) || type.flags & 3145728 /* UnionOrIntersection */ && some(type.types, (t) => isConstTypeVariable(t, depth)) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType, depth + 1) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type), depth + 1) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType, depth) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t, depth)) >= 0)); } function getConstraintOfIndexedAccess(type) { return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0; @@ -57121,7 +57261,7 @@ ${lanes.join("\n")} } else if (!isUnion && !isReadonlySymbol(prop)) { checkFlags &= ~8 /* Readonly */; } - checkFlags |= (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | (modifiers & 16 /* Protected */ ? 512 /* ContainsProtected */ : 0) | (modifiers & 8 /* Private */ ? 1024 /* ContainsPrivate */ : 0) | (modifiers & 32 /* Static */ ? 2048 /* ContainsStatic */ : 0); + checkFlags |= (!(modifiers & 6 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | (modifiers & 4 /* Protected */ ? 512 /* ContainsProtected */ : 0) | (modifiers & 2 /* Private */ ? 1024 /* ContainsPrivate */ : 0) | (modifiers & 256 /* Static */ ? 2048 /* ContainsStatic */ : 0); if (!isPrototypeProperty(prop)) { syntheticFlag = 2 /* SyntheticProperty */; } @@ -57573,7 +57713,7 @@ ${lanes.join("\n")} if (hasRestParameter(declaration) || isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { flags |= 1 /* HasRestParameter */; } - if (isConstructorTypeNode(declaration) && hasSyntacticModifier(declaration, 256 /* Abstract */) || isConstructorDeclaration(declaration) && hasSyntacticModifier(declaration.parent, 256 /* Abstract */)) { + if (isConstructorTypeNode(declaration) && hasSyntacticModifier(declaration, 64 /* Abstract */) || isConstructorDeclaration(declaration) && hasSyntacticModifier(declaration.parent, 64 /* Abstract */)) { flags |= 4 /* Abstract */; } links.resolvedSignature = createSignature( @@ -57943,7 +58083,7 @@ ${lanes.join("\n")} if (parameter.type) { forEachType(getTypeFromTypeNode(parameter.type), (keyType) => { if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos, keyType)) { - indexInfos.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, hasEffectiveModifier(declaration, 64 /* Readonly */), declaration)); + indexInfos.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, hasEffectiveModifier(declaration, 8 /* Readonly */), declaration)); } }); } @@ -59768,7 +59908,7 @@ ${lanes.join("\n")} return neverType; } function getLiteralTypeFromProperty(prop, include, includeNonPublic) { - if (includeNonPublic || !(getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { + if (includeNonPublic || !(getDeclarationModifierFlagsFromSymbol(prop) & 6 /* NonPublicAccessibilityModifier */)) { let type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; if (!type) { const name = getNameOfDeclaration(prop.valueDeclaration); @@ -60061,7 +60201,11 @@ ${lanes.join("\n")} if (indexInfo) { if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) { if (accessExpression) { - error2(accessExpression, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); + if (accessFlags & 4 /* Writing */) { + error2(accessExpression, Diagnostics.Type_0_is_generic_and_can_only_be_indexed_for_reading, typeToString(originalObjectType)); + } else { + error2(accessExpression, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); + } } return void 0; } @@ -60198,7 +60342,7 @@ ${lanes.join("\n")} } function isPatternLiteralPlaceholderType(type) { if (type.flags & 2097152 /* Intersection */) { - return some(type.types, (t) => !!(t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) || isPatternLiteralPlaceholderType(t)); + return !isGenericType(type) && some(type.types, (t) => !!(t.flags & (2944 /* Literal */ | 98304 /* Nullable */)) || isPatternLiteralPlaceholderType(t)); } return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || isPatternLiteralType(type); } @@ -60709,7 +60853,7 @@ ${lanes.join("\n")} function getAnonymousPartialType(type2) { const members = createSymbolTable(); for (const prop of getPropertiesOfType(type2)) { - if (getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) { + if (getDeclarationModifierFlagsFromSymbol(prop) & (2 /* Private */ | 4 /* Protected */)) { } else if (isSpreadableProperty(prop)) { const isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); const flags = 4 /* Property */ | 16777216 /* Optional */; @@ -60771,7 +60915,7 @@ ${lanes.join("\n")} const skippedPrivateMembers = /* @__PURE__ */ new Set(); const indexInfos = left === emptyObjectType ? getIndexInfosOfType(right) : getUnionIndexInfos([left, right]); for (const rightProp of getPropertiesOfType(right)) { - if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { + if (getDeclarationModifierFlagsFromSymbol(rightProp) & (2 /* Private */ | 4 /* Protected */)) { skippedPrivateMembers.add(rightProp.escapedName); } else if (isSpreadableProperty(rightProp)) { members.set(rightProp.escapedName, getSpreadSymbol(rightProp, readonly)); @@ -64338,25 +64482,25 @@ ${lanes.join("\n")} function propertyRelatedTo(source2, target2, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors2, intersectionState, skipOptional) { const sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); const targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); - if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 2 /* Private */ || targetPropFlags & 2 /* Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors2) { - if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 2 /* Private */ && targetPropFlags & 2 /* Private */) { reportError(Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* Private */ ? source2 : target2), typeToString(sourcePropFlags & 8 /* Private */ ? target2 : source2)); + reportError(Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 2 /* Private */ ? source2 : target2), typeToString(sourcePropFlags & 2 /* Private */ ? target2 : source2)); } } return 0 /* False */; } - } else if (targetPropFlags & 16 /* Protected */) { + } else if (targetPropFlags & 4 /* Protected */) { if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors2) { reportError(Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source2), typeToString(getDeclaringClass(targetProp) || target2)); } return 0 /* False */; } - } else if (sourcePropFlags & 16 /* Protected */) { + } else if (sourcePropFlags & 4 /* Protected */) { if (reportErrors2) { reportError(Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source2), typeToString(target2)); } @@ -64886,15 +65030,15 @@ ${lanes.join("\n")} if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - const sourceAccessibility = getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* NonPublicAccessibilityModifier */); - const targetAccessibility = getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* NonPublicAccessibilityModifier */); - if (targetAccessibility === 8 /* Private */) { + const sourceAccessibility = getSelectedEffectiveModifierFlags(sourceSignature.declaration, 6 /* NonPublicAccessibilityModifier */); + const targetAccessibility = getSelectedEffectiveModifierFlags(targetSignature.declaration, 6 /* NonPublicAccessibilityModifier */); + if (targetAccessibility === 2 /* Private */) { return true; } - if (targetAccessibility === 16 /* Protected */ && sourceAccessibility !== 8 /* Private */) { + if (targetAccessibility === 4 /* Protected */ && sourceAccessibility !== 2 /* Private */) { return true; } - if (targetAccessibility !== 16 /* Protected */ && !sourceAccessibility) { + if (targetAccessibility !== 4 /* Protected */ && !sourceAccessibility) { return true; } if (reportErrors2) { @@ -64994,7 +65138,7 @@ ${lanes.join("\n")} const variances = []; for (const tp of typeParameters) { const modifiers = getTypeParameterModifiers(tp); - let variance = modifiers & 65536 /* Out */ ? modifiers & 32768 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ : modifiers & 32768 /* In */ ? 2 /* Contravariant */ : void 0; + let variance = modifiers & 16384 /* Out */ ? modifiers & 8192 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ : modifiers & 8192 /* In */ ? 2 /* Contravariant */ : void 0; if (variance === void 0) { let unmeasurable = false; let unreliable = false; @@ -65042,7 +65186,7 @@ ${lanes.join("\n")} } function getTypeParameterModifiers(tp) { var _a; - return reduceLeft((_a = tp.symbol) == null ? void 0 : _a.declarations, (modifiers, d) => modifiers | getEffectiveModifierFlags(d), 0 /* None */) & (32768 /* In */ | 65536 /* Out */ | 2048 /* Const */); + return reduceLeft((_a = tp.symbol) == null ? void 0 : _a.declarations, (modifiers, d) => modifiers | getEffectiveModifierFlags(d), 0 /* None */) & (8192 /* In */ | 16384 /* Out */ | 4096 /* Const */); } function hasCovariantVoidArgument(typeArguments, variances) { for (let i = 0; i < variances.length; i++) { @@ -65127,13 +65271,16 @@ ${lanes.join("\n")} }); } function isValidOverrideOf(sourceProp, targetProp) { - return !forEachProperty2(targetProp, (tp) => getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ? !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false); + return !forEachProperty2(targetProp, (tp) => getDeclarationModifierFlagsFromSymbol(tp) & 4 /* Protected */ ? !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false); } function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { - return forEachProperty2(prop, (p) => getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* Protected */ ? !hasBaseType(checkClass, getDeclaringClass(p)) : false) ? void 0 : checkClass; + return forEachProperty2(prop, (p) => getDeclarationModifierFlagsFromSymbol(p, writing) & 4 /* Protected */ ? !hasBaseType(checkClass, getDeclaringClass(p)) : false) ? void 0 : checkClass; } function isDeeplyNestedType(type, stack, depth, maxDepth = 3) { if (depth >= maxDepth) { + if ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */) { + type = getMappedTargetWithSymbol(type); + } if (type.flags & 2097152 /* Intersection */) { return some(type.types, (t) => isDeeplyNestedType(t, stack, depth, maxDepth)); } @@ -65142,7 +65289,7 @@ ${lanes.join("\n")} let lastTypeId = 0; for (let i = 0; i < depth; i++) { const t = stack[i]; - if (t.flags & 2097152 /* Intersection */ ? some(t.types, (u) => getRecursionIdentity(u) === identity2) : getRecursionIdentity(t) === identity2) { + if (hasMatchingRecursionIdentity(t, identity2)) { if (t.id >= lastTypeId) { count++; if (count >= maxDepth) { @@ -65155,18 +65302,29 @@ ${lanes.join("\n")} } return false; } + function getMappedTargetWithSymbol(type) { + let target; + while ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */ && (target = getModifiersTypeFromMappedType(type)) && (target.symbol || target.flags & 2097152 /* Intersection */ && some(target.types, (t) => !!t.symbol))) { + type = target; + } + return type; + } + function hasMatchingRecursionIdentity(type, identity2) { + if ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */) { + type = getMappedTargetWithSymbol(type); + } + if (type.flags & 2097152 /* Intersection */) { + return some(type.types, (t) => hasMatchingRecursionIdentity(t, identity2)); + } + return getRecursionIdentity(type) === identity2; + } function getRecursionIdentity(type) { if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) { if (getObjectFlags(type) & 4 /* Reference */ && type.node) { return type.node; } - if (type.symbol) { - if (getObjectFlags(type) & 32 /* Mapped */) { - type = getMappedTargetWithSymbol(type); - } - if (!(getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) { - return type.symbol; - } + if (type.symbol && !(getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) { + return type.symbol; } if (isTupleType(type)) { return type.target; @@ -65186,13 +65344,6 @@ ${lanes.join("\n")} } return type; } - function getMappedTargetWithSymbol(type) { - let target = type; - while ((getObjectFlags(target) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */ && isMappedTypeWithKeyofConstraintDeclaration(target)) { - target = getModifiersTypeFromMappedType(target); - } - return target.symbol ? target : type; - } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties2(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; } @@ -65200,8 +65351,8 @@ ${lanes.join("\n")} if (sourceProp === targetProp) { return -1 /* True */; } - const sourcePropAccessibility = getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* NonPublicAccessibilityModifier */; - const targetPropAccessibility = getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* NonPublicAccessibilityModifier */; + const sourcePropAccessibility = getDeclarationModifierFlagsFromSymbol(sourceProp) & 6 /* NonPublicAccessibilityModifier */; + const targetPropAccessibility = getDeclarationModifierFlagsFromSymbol(targetProp) & 6 /* NonPublicAccessibilityModifier */; if (sourcePropAccessibility !== targetPropAccessibility) { return 0 /* False */; } @@ -68170,7 +68321,7 @@ ${lanes.join("\n")} return createFlowType(narrowedType, isIncomplete(flowType)); } function getTypeAtSwitchClause(flow) { - const expr = flow.switchStatement.expression; + const expr = skipParentheses(flow.switchStatement.expression); const flowType = getTypeAtFlowNode(flow.antecedent); let type = getTypeFromFlowType(flowType); if (isMatchingReference(reference, expr)) { @@ -68178,16 +68329,7 @@ ${lanes.join("\n")} } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else if (expr.kind === 112 /* TrueKeyword */) { - const clause = flow.switchStatement.caseBlock.clauses.find((_, index) => index === flow.clauseStart); - const clauseExpression = clause && clause.kind === 296 /* CaseClause */ ? clause.expression : void 0; - if (clauseExpression) { - type = narrowType( - type, - clauseExpression, - /*assumeTrue*/ - true - ); - } + type = narrowTypeBySwitchOnTrue(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { if (strictNullChecks) { if (optionalChainContainsReference(expr, reference)) { @@ -68347,13 +68489,15 @@ ${lanes.join("\n")} return void 0; } function getDiscriminantPropertyAccess(expr, computedType) { - const type = !(computedType.flags & 1048576 /* Union */) && declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; - if (type.flags & 1048576 /* Union */) { + if (declaredType.flags & 1048576 /* Union */ || computedType.flags & 1048576 /* Union */) { const access = getCandidateDiscriminantPropertyAccess(expr); if (access) { const name = getAccessedPropertyName(access); - if (name && isDiscriminantProperty(type, name)) { - return access; + if (name) { + const type = declaredType.flags & 1048576 /* Union */ && isTypeSubsetOf(computedType, declaredType) ? declaredType : computedType; + if (isDiscriminantProperty(type, name)) { + return access; + } } } } @@ -68733,6 +68877,42 @@ ${lanes.join("\n")} const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd); return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType)); } + function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) { + const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */); + const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd; + for (let i = 0; i < clauseStart; i++) { + const clause = switchStatement.caseBlock.clauses[i]; + if (clause.kind === 296 /* CaseClause */) { + type = narrowType( + type, + clause.expression, + /*assumeTrue*/ + false + ); + } + } + if (hasDefaultClause) { + for (let i = clauseEnd; i < switchStatement.caseBlock.clauses.length; i++) { + const clause = switchStatement.caseBlock.clauses[i]; + if (clause.kind === 296 /* CaseClause */) { + type = narrowType( + type, + clause.expression, + /*assumeTrue*/ + false + ); + } + } + return type; + } + const clauses = switchStatement.caseBlock.clauses.slice(clauseStart, clauseEnd); + return getUnionType(map(clauses, (clause) => clause.kind === 296 /* CaseClause */ ? narrowType( + type, + clause.expression, + /*assumeTrue*/ + true + ) : neverType)); + } function isMatchingConstructorReference(expr) { return (isPropertyAccessExpression(expr) && idText(expr.name) === "constructor" || isElementAccessExpression(expr) && isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") && isMatchingReference(reference, expr.expression); } @@ -69166,7 +69346,7 @@ ${lanes.join("\n")} if (languageVersion < 2 /* ES2015 */) { if (container.kind === 219 /* ArrowFunction */) { error2(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); - } else if (hasSyntacticModifier(container, 512 /* Async */)) { + } else if (hasSyntacticModifier(container, 1024 /* Async */)) { error2(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } @@ -69579,7 +69759,7 @@ ${lanes.join("\n")} let inAsyncFunction = false; if (!isCallExpression2) { while (container && container.kind === 219 /* ArrowFunction */) { - if (hasSyntacticModifier(container, 512 /* Async */)) + if (hasSyntacticModifier(container, 1024 /* Async */)) inAsyncFunction = true; container = getSuperContainer( container, @@ -69588,7 +69768,7 @@ ${lanes.join("\n")} ); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } - if (container && hasSyntacticModifier(container, 512 /* Async */)) + if (container && hasSyntacticModifier(container, 1024 /* Async */)) inAsyncFunction = true; } let nodeCheckFlag = 0; @@ -69731,7 +69911,7 @@ ${lanes.join("\n")} return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral)); } const parent2 = walkUpParenthesizedExpressions(func.parent); - if (parent2.kind === 226 /* BinaryExpression */ && parent2.operatorToken.kind === 64 /* EqualsToken */) { + if (isAssignmentExpression(parent2)) { const target = parent2.left; if (isAccessExpression(target)) { const { expression } = target; @@ -69920,7 +70100,24 @@ ${lanes.join("\n")} } const signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); if (signature && !isResolvingReturnTypeOfSignature(signature)) { - return getReturnTypeOfSignature(signature); + const returnType2 = getReturnTypeOfSignature(signature); + const functionFlags = getFunctionFlags(functionDecl); + if (functionFlags & 1 /* Generator */) { + return filterType(returnType2, (t) => { + return !!(t.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || checkGeneratorInstantiationAssignabilityToReturnType( + t, + functionFlags, + /*errorNode*/ + void 0 + ); + }); + } + if (functionFlags & 2 /* Async */) { + return filterType(returnType2, (t) => { + return !!(t.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || !!getAwaitedTypeOfPromise(t); + }); + } + return returnType2; } const iife = getImmediatelyInvokedFunctionExpression(functionDecl); if (iife) { @@ -71299,7 +71496,7 @@ ${lanes.join("\n")} } } const parent2 = openingLikeElement.parent.kind === 284 /* JsxElement */ ? openingLikeElement.parent : void 0; - if (parent2 && parent2.openingElement === openingLikeElement && parent2.children.length > 0) { + if (parent2 && parent2.openingElement === openingLikeElement && getSemanticJsxChildren(parent2.children).length > 0) { const childrenTypes = checkJsxChildren(parent2, checkMode); if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { if (explicitlySpecifyChildrenAttribute) { @@ -71776,20 +71973,20 @@ ${lanes.join("\n")} return false; } } - if (flags & 256 /* Abstract */) { + if (flags & 64 /* Abstract */) { if (errorNode) { error2(errorNode, Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); } return false; } - if (!(flags & 32 /* Static */) && ((_a = prop.declarations) == null ? void 0 : _a.some(isClassInstanceProperty))) { + if (!(flags & 256 /* Static */) && ((_a = prop.declarations) == null ? void 0 : _a.some(isClassInstanceProperty))) { if (errorNode) { error2(errorNode, Diagnostics.Class_field_0_defined_by_the_parent_class_is_not_accessible_in_the_child_class_via_super, symbolToString(prop)); } return false; } } - if (flags & 256 /* Abstract */ && symbolHasNonMethodDeclaration(prop) && (isThisProperty(location) || isThisInitializedObjectBindingExpression(location) || isObjectBindingPattern(location.parent) && isThisInitializedDeclaration(location.parent.parent))) { + if (flags & 64 /* Abstract */ && symbolHasNonMethodDeclaration(prop) && (isThisProperty(location) || isThisInitializedObjectBindingExpression(location) || isObjectBindingPattern(location.parent) && isThisInitializedDeclaration(location.parent.parent))) { const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(location)) { if (errorNode) { @@ -71798,10 +71995,10 @@ ${lanes.join("\n")} return false; } } - if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { + if (!(flags & 6 /* NonPublicAccessibilityModifier */)) { return true; } - if (flags & 8 /* Private */) { + if (flags & 2 /* Private */) { const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(location, declaringClassDeclaration)) { if (errorNode) { @@ -71821,14 +72018,14 @@ ${lanes.join("\n")} if (!enclosingClass) { enclosingClass = getEnclosingClassFromThisParameter(location); enclosingClass = enclosingClass && isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing); - if (flags & 32 /* Static */ || !enclosingClass) { + if (flags & 256 /* Static */ || !enclosingClass) { if (errorNode) { error2(errorNode, Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || containingType)); } return false; } } - if (flags & 32 /* Static */) { + if (flags & 256 /* Static */) { return true; } if (containingType.flags & 262144 /* TypeParameter */) { @@ -72248,7 +72445,7 @@ ${lanes.join("\n")} } let diagnosticMessage; const declarationName = idText(right); - if (isInPropertyInitializerOrClassStaticBlock(node) && !isOptionalPropertyDeclaration(valueDeclaration) && !(isAccessExpression(node) && isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !(isMethodDeclaration(valueDeclaration) && getCombinedModifierFlagsCached(valueDeclaration) & 32 /* Static */) && (useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { + if (isInPropertyInitializerOrClassStaticBlock(node) && !isOptionalPropertyDeclaration(valueDeclaration) && !(isAccessExpression(node) && isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !(isMethodDeclaration(valueDeclaration) && getCombinedModifierFlagsCached(valueDeclaration) & 256 /* Static */) && (useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error2(right, Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } else if (valueDeclaration.kind === 263 /* ClassDeclaration */ && node.parent.kind !== 183 /* TypeReference */ && !(valueDeclaration.flags & 33554432 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error2(right, Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -72502,7 +72699,7 @@ ${lanes.join("\n")} if (!valueDeclaration) { return; } - const hasPrivateModifier = hasEffectiveModifier(valueDeclaration, 8 /* Private */); + const hasPrivateModifier = hasEffectiveModifier(valueDeclaration, 2 /* Private */); const hasPrivateIdentifier = prop.valueDeclaration && isNamedDeclaration(prop.valueDeclaration) && isPrivateIdentifier(prop.valueDeclaration.name); if (!hasPrivateModifier && !hasPrivateIdentifier) { return; @@ -72922,9 +73119,11 @@ ${lanes.join("\n")} } if (arg.kind === 237 /* SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); + } else { + names.push(void 0); } } - return createTupleType(types, flags, inConstContext && !someType(restType, isMutableArrayLikeType), length(names) === length(types) ? names : void 0); + return createTupleType(types, flags, inConstContext && !someType(restType, isMutableArrayLikeType), names); } function checkTypeArguments(signature, typeArgumentNodes, reportErrors2, headMessage) { const isJavascript = isInJSFile(signature.declaration); @@ -73945,7 +74144,7 @@ ${lanes.join("\n")} return resolveErrorCall(node); } const valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && hasSyntacticModifier(valueDecl, 256 /* Abstract */)) { + if (valueDecl && hasSyntacticModifier(valueDecl, 64 /* Abstract */)) { error2(node, Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } @@ -74008,7 +74207,7 @@ ${lanes.join("\n")} return true; } const declaration = signature.declaration; - const modifiers = getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); + const modifiers = getSelectedEffectiveModifierFlags(declaration, 6 /* NonPublicAccessibilityModifier */); if (!modifiers || declaration.kind !== 176 /* Constructor */) { return true; } @@ -74016,16 +74215,16 @@ ${lanes.join("\n")} const declaringClass = getDeclaredTypeOfSymbol(declaration.parent.symbol); if (!isNodeWithinClass(node, declaringClassDeclaration)) { const containingClass = getContainingClass(node); - if (containingClass && modifiers & 16 /* Protected */) { + if (containingClass && modifiers & 4 /* Protected */) { const containingType = getTypeOfNode(containingClass); if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) { return true; } } - if (modifiers & 8 /* Private */) { + if (modifiers & 2 /* Private */) { error2(node, Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } - if (modifiers & 16 /* Protected */) { + if (modifiers & 4 /* Protected */) { error2(node, Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } return false; @@ -75059,12 +75258,9 @@ ${lanes.join("\n")} types.push(restType); flags.push(8 /* Variadic */); } - const name = getNameableDeclarationAtPosition(source, i); - if (name) { - names.push(name); - } + names.push(getNameableDeclarationAtPosition(source, i)); } - return createTupleType(types, flags, readonly, length(names) === length(types) ? names : void 0); + return createTupleType(types, flags, readonly, names); } function getParameterCount(signature) { const length2 = signature.parameters.length; @@ -75760,8 +75956,20 @@ ${lanes.join("\n")} let hasReturnWithNoExpression = functionHasImplicitReturn(func); let hasReturnOfTypeNever = false; forEachReturnStatement(func.body, (returnStatement) => { - const expr = returnStatement.expression; + let expr = returnStatement.expression; if (expr) { + expr = skipParentheses( + expr, + /*excludeJSDocTypeAssertions*/ + true + ); + if (functionFlags & 2 /* Async */ && expr.kind === 223 /* AwaitExpression */) { + expr = skipParentheses( + expr.expression, + /*excludeJSDocTypeAssertions*/ + true + ); + } if (expr.kind === 213 /* CallExpression */ && expr.expression.kind === 80 /* Identifier */ && checkExpressionCached(expr.expression).symbol === func.symbol) { hasReturnOfTypeNever = true; return; @@ -75993,7 +76201,7 @@ ${lanes.join("\n")} return !setProp; } function isReadonlySymbol(symbol) { - return !!(getCheckFlags(symbol) & 8 /* Readonly */ || symbol.flags & 4 /* Property */ && getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 6 /* Constant */ || symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || symbol.flags & 8 /* EnumMember */ || some(symbol.declarations, isReadonlyAssignmentDeclaration)); + return !!(getCheckFlags(symbol) & 8 /* Readonly */ || symbol.flags & 4 /* Property */ && getDeclarationModifierFlagsFromSymbol(symbol) & 8 /* Readonly */ || symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 6 /* Constant */ || symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || symbol.flags & 8 /* EnumMember */ || some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) { var _a, _b; @@ -76074,7 +76282,7 @@ ${lanes.join("\n")} return typeofType; } function checkVoidExpression(node) { - checkExpression(node.expression); + checkNodeDeferred(node); return undefinedWideningType; } function checkAwaitGrammar(node) { @@ -77110,7 +77318,15 @@ ${lanes.join("\n")} checkExternalEmitHelpers(node, 256 /* Values */); } } - const returnType = getReturnTypeFromAnnotation(func); + let returnType = getReturnTypeFromAnnotation(func); + if (returnType && returnType.flags & 1048576 /* Union */) { + returnType = filterType(returnType, (t) => checkGeneratorInstantiationAssignabilityToReturnType( + t, + functionFlags, + /*errorNode*/ + void 0 + )); + } const iterationTypes = returnType && getIterationTypesOfGeneratorFunctionReturnType(returnType, isAsync); const signatureYieldType = iterationTypes && iterationTypes.yieldType || anyType; const signatureNextType = iterationTypes && iterationTypes.nextType || anyType; @@ -77731,15 +77947,15 @@ ${lanes.join("\n")} var _a, _b; if (isInterfaceDeclaration(node.parent) || isClassLike(node.parent) || isTypeAliasDeclaration(node.parent)) { const typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfDeclaration(node)); - const modifiers = getTypeParameterModifiers(typeParameter) & (32768 /* In */ | 65536 /* Out */); + const modifiers = getTypeParameterModifiers(typeParameter) & (8192 /* In */ | 16384 /* Out */); if (modifiers) { const symbol = getSymbolOfDeclaration(node.parent); if (isTypeAliasDeclaration(node.parent) && !(getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) { error2(node, Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types); - } else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) { + } else if (modifiers === 8192 /* In */ || modifiers === 16384 /* Out */) { (_a = tracing) == null ? void 0 : _a.push(tracing.Phase.CheckTypes, "checkTypeParameterDeferred", { parent: getTypeId(getDeclaredTypeOfSymbol(symbol)), id: getTypeId(typeParameter) }); - const source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck); - const target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck); + const source = createMarkerType(symbol, typeParameter, modifiers === 16384 /* Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck); + const target = createMarkerType(symbol, typeParameter, modifiers === 16384 /* Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck); const saveVarianceTypeParameter = typeParameter; varianceTypeParameter = typeParameter; checkTypeAssignableTo(source, target, node, Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); @@ -77753,7 +77969,7 @@ ${lanes.join("\n")} checkGrammarModifiers(node); checkVariableLikeDeclaration(node); const func = getContainingFunction(node); - if (hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (hasSyntacticModifier(node, 31 /* ParameterPropertyModifier */)) { if (!(func.kind === 176 /* Constructor */ && nodeIsPresent(func.body))) { error2(node, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } @@ -77923,11 +78139,7 @@ ${lanes.join("\n")} if (returnType === voidType) { error2(returnTypeErrorLocation, Diagnostics.A_generator_cannot_have_a_void_type_annotation); } else { - const generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || anyType; - const generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || generatorYieldType; - const generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || unknownType; - const generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags2 & 2 /* Async */)); - checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeErrorLocation); + checkGeneratorInstantiationAssignabilityToReturnType(returnType, functionFlags2, returnTypeErrorLocation); } } else if ((functionFlags2 & 3 /* AsyncGenerator */) === 2 /* Async */) { checkAsyncFunctionReturnType(node, returnTypeNode, returnTypeErrorLocation); @@ -77938,6 +78150,13 @@ ${lanes.join("\n")} } } } + function checkGeneratorInstantiationAssignabilityToReturnType(returnType, functionFlags, errorNode) { + const generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags & 2 /* Async */) !== 0) || anyType; + const generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags & 2 /* Async */) !== 0) || generatorYieldType; + const generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags & 2 /* Async */) !== 0) || unknownType; + const generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags & 2 /* Async */)); + return checkTypeAssignableTo(generatorInstantiation, returnType, errorNode); + } function checkClassForDuplicateDeclarations(node) { const instanceNames = /* @__PURE__ */ new Map(); const staticNames = /* @__PURE__ */ new Map(); @@ -78085,7 +78304,7 @@ ${lanes.join("\n")} checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); setNodeLinksForPrivateIdentifierScope(node); - if (hasSyntacticModifier(node, 256 /* Abstract */) && node.kind === 172 /* PropertyDeclaration */ && node.initializer) { + if (hasSyntacticModifier(node, 64 /* Abstract */) && node.kind === 172 /* PropertyDeclaration */ && node.initializer) { error2(node, Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, declarationNameToString(node.name)); } } @@ -78102,7 +78321,7 @@ ${lanes.join("\n")} error2(node.name, Diagnostics.Class_constructor_may_not_be_a_generator); } checkFunctionOrMethodDeclaration(node); - if (hasSyntacticModifier(node, 256 /* Abstract */) && node.kind === 174 /* MethodDeclaration */ && node.body) { + if (hasSyntacticModifier(node, 64 /* Abstract */) && node.kind === 174 /* MethodDeclaration */ && node.body) { error2(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)); } if (isPrivateIdentifier(node.name) && !getContainingClass(node)) { @@ -78159,7 +78378,7 @@ ${lanes.join("\n")} if (classExtendsNull) { error2(superCall, Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); } - const superCallShouldBeRootLevel = !emitStandardClassFields && (some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || some(node.parameters, (p) => hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */))); + const superCallShouldBeRootLevel = !emitStandardClassFields && (some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || some(node.parameters, (p) => hasSyntacticModifier(p, 31 /* ParameterPropertyModifier */))); if (superCallShouldBeRootLevel) { if (!superCallIsRootLevelInConstructor(superCall, node.body)) { error2(superCall, Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers); @@ -78228,11 +78447,11 @@ ${lanes.join("\n")} getNodeLinks(getter).flags |= 1 /* TypeChecked */; const getterFlags = getEffectiveModifierFlags(getter); const setterFlags = getEffectiveModifierFlags(setter); - if ((getterFlags & 256 /* Abstract */) !== (setterFlags & 256 /* Abstract */)) { + if ((getterFlags & 64 /* Abstract */) !== (setterFlags & 64 /* Abstract */)) { error2(getter.name, Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); error2(setter.name, Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } - if (getterFlags & 16 /* Protected */ && !(setterFlags & (16 /* Protected */ | 8 /* Private */)) || getterFlags & 8 /* Private */ && !(setterFlags & 8 /* Private */)) { + if (getterFlags & 4 /* Protected */ && !(setterFlags & (4 /* Protected */ | 2 /* Private */)) || getterFlags & 2 /* Private */ && !(setterFlags & 2 /* Private */)) { error2(getter.name, Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); error2(setter.name, Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); } @@ -78412,7 +78631,7 @@ ${lanes.join("\n")} const propertyName = getPropertyNameFromIndex(indexType, accessNode); if (propertyName) { const propertySymbol = forEachType(apparentObjectType, (t) => getPropertyOfType(t, propertyName)); - if (propertySymbol && getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* NonPublicAccessibilityModifier */) { + if (propertySymbol && getDeclarationModifierFlagsFromSymbol(propertySymbol) & 6 /* NonPublicAccessibilityModifier */) { error2(accessNode, Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, unescapeLeadingUnderscores(propertyName)); return errorType; } @@ -78510,16 +78729,16 @@ ${lanes.join("\n")} getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return (hasEffectiveModifier(node, 8 /* Private */) || isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 33554432 /* Ambient */); + return (hasEffectiveModifier(node, 2 /* Private */) || isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 33554432 /* Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { let flags = getCombinedModifierFlagsCached(n); if (n.parent.kind !== 264 /* InterfaceDeclaration */ && n.parent.kind !== 263 /* ClassDeclaration */ && n.parent.kind !== 231 /* ClassExpression */ && n.flags & 33554432 /* Ambient */) { const container = getEnclosingContainer(n); - if (container && container.flags & 128 /* ExportContext */ && !(flags & 2 /* Ambient */) && !(isModuleBlock(n.parent) && isModuleDeclaration(n.parent.parent) && isGlobalScopeAugmentation(n.parent.parent))) { - flags |= 1 /* Export */; + if (container && container.flags & 128 /* ExportContext */ && !(flags & 128 /* Ambient */) && !(isModuleBlock(n.parent) && isModuleDeclaration(n.parent.parent) && isGlobalScopeAugmentation(n.parent.parent))) { + flags |= 32 /* Export */; } - flags |= 2 /* Ambient */; + flags |= 128 /* Ambient */; } return flags & flagsToCheck; } @@ -78537,13 +78756,13 @@ ${lanes.join("\n")} const canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck2); forEach(overloads, (o) => { const deviation = getEffectiveDeclarationFlags(o, flagsToCheck2) ^ canonicalFlags; - if (deviation & 1 /* Export */) { + if (deviation & 32 /* Export */) { error2(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); - } else if (deviation & 2 /* Ambient */) { + } else if (deviation & 128 /* Ambient */) { error2(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); - } else if (deviation & (8 /* Private */ | 16 /* Protected */)) { + } else if (deviation & (2 /* Private */ | 4 /* Protected */)) { error2(getNameOfDeclaration(o) || o, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); - } else if (deviation & 256 /* Abstract */) { + } else if (deviation & 64 /* Abstract */) { error2(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); @@ -78560,7 +78779,7 @@ ${lanes.join("\n")} }); } } - const flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 8 /* Private */ | 16 /* Protected */ | 256 /* Abstract */; + const flagsToCheck = 32 /* Export */ | 128 /* Ambient */ | 2 /* Private */ | 4 /* Protected */ | 64 /* Abstract */; let someNodeFlags = 0 /* None */; let allNodeFlags = flagsToCheck; let someHaveQuestionToken = false; @@ -78608,7 +78827,7 @@ ${lanes.join("\n")} if (isConstructor) { error2(errorNode, Diagnostics.Constructor_implementation_is_missing); } else { - if (hasSyntacticModifier(node, 256 /* Abstract */)) { + if (hasSyntacticModifier(node, 64 /* Abstract */)) { error2(errorNode, Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { error2(errorNode, Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); @@ -78694,7 +78913,7 @@ ${lanes.join("\n")} } }); } - if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !hasSyntacticModifier(lastSeenNonAmbientDeclaration, 256 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { + if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !hasSyntacticModifier(lastSeenNonAmbientDeclaration, 64 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -78737,9 +78956,9 @@ ${lanes.join("\n")} let defaultExportedDeclarationSpaces = 0 /* None */; for (const d of symbol.declarations) { const declarationSpaces = getDeclarationSpaces(d); - const effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 1024 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 1024 /* Default */) { + const effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 32 /* Export */ | 2048 /* Default */); + if (effectiveDeclarationFlags & 32 /* Export */) { + if (effectiveDeclarationFlags & 2048 /* Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { exportedDeclarationSpaces |= declarationSpaces; @@ -79380,6 +79599,12 @@ ${lanes.join("\n")} } } } + function checkJSDocThisTag(node) { + const host2 = getEffectiveJSDocHost(node); + if (host2 && isArrowFunction(host2)) { + error2(node.tagName, Diagnostics.An_arrow_function_cannot_have_a_this_parameter); + } + } function checkJSDocImplementsTag(node) { const classLike = getEffectiveJSDocHost(node); if (!classLike || !isClassDeclaration(classLike) && !isClassExpression(classLike)) { @@ -79542,13 +79767,13 @@ ${lanes.join("\n")} break; } const symbol = getSymbolOfDeclaration(member); - if (!symbol.isReferenced && (hasEffectiveModifier(member, 8 /* Private */) || isNamedDeclaration(member) && isPrivateIdentifier(member.name)) && !(member.flags & 33554432 /* Ambient */)) { + if (!symbol.isReferenced && (hasEffectiveModifier(member, 2 /* Private */) || isNamedDeclaration(member) && isPrivateIdentifier(member.name)) && !(member.flags & 33554432 /* Ambient */)) { addDiagnostic(member, 0 /* Local */, createDiagnosticForNode(member.name, Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; case 176 /* Constructor */: for (const parameter of member.parameters) { - if (!parameter.symbol.isReferenced && hasSyntacticModifier(parameter, 8 /* Private */)) { + if (!parameter.symbol.isReferenced && hasSyntacticModifier(parameter, 2 /* Private */)) { addDiagnostic(parameter, 0 /* Local */, createDiagnosticForNode(parameter.name, Diagnostics.Property_0_is_declared_but_its_value_is_never_read, symbolName(parameter.symbol))); } } @@ -79994,7 +80219,7 @@ ${lanes.join("\n")} } forEach(node.name.elements, checkSourceElement); } - if (isParameter(node) && node.initializer && nodeIsMissing(getContainingFunction(node).body)) { + if (node.initializer && isParameterDeclaration(node) && nodeIsMissing(getContainingFunction(node).body)) { error2(node, Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -80124,7 +80349,7 @@ ${lanes.join("\n")} if (hasQuestionToken(left) !== hasQuestionToken(right)) { return false; } - const interestingFlags = 8 /* Private */ | 16 /* Protected */ | 512 /* Async */ | 256 /* Abstract */ | 64 /* Readonly */ | 32 /* Static */; + const interestingFlags = 2 /* Private */ | 4 /* Protected */ | 1024 /* Async */ | 64 /* Abstract */ | 8 /* Readonly */ | 256 /* Static */; return getSelectedEffectiveModifierFlags(left, interestingFlags) === getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { @@ -81452,7 +81677,7 @@ ${lanes.join("\n")} if (legacyDecorators && firstDecorator && some(node.members, (p) => hasStaticModifier(p) && isPrivateIdentifierClassElementDeclaration(p))) { grammarErrorOnNode(firstDecorator, Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); } - if (!node.name && !hasSyntacticModifier(node, 1024 /* Default */)) { + if (!node.name && !hasSyntacticModifier(node, 2048 /* Default */)) { grammarErrorOnFirstToken(node, Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -81518,7 +81743,7 @@ ${lanes.join("\n")} error2(node.name || node, Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } else { const constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); - if (constructSignatures.some((signature) => signature.flags & 4 /* Abstract */) && !hasSyntacticModifier(node, 256 /* Abstract */)) { + if (constructSignatures.some((signature) => signature.flags & 4 /* Abstract */) && !hasSyntacticModifier(node, 64 /* Abstract */)) { error2(node.name || node, Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract); } } @@ -81732,7 +81957,7 @@ ${lanes.join("\n")} const signatures = getSignaturesOfType(type, 1 /* Construct */); if (signatures.length) { const declaration = signatures[0].declaration; - if (declaration && hasEffectiveModifier(declaration, 8 /* Private */)) { + if (declaration && hasEffectiveModifier(declaration, 2 /* Private */)) { const typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error2(node, Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -81752,7 +81977,7 @@ ${lanes.join("\n")} const baseTypes = baseTypeNode && getBaseTypes(type); const baseWithThis = (baseTypes == null ? void 0 : baseTypes.length) ? getTypeWithThisArgument(first(baseTypes), type.thisType) : void 0; const baseStaticType = getBaseConstructorTypeOfClass(type); - const memberHasOverrideModifier = member.parent ? hasOverrideModifier(member) : hasSyntacticModifier(member, 16384 /* Override */); + const memberHasOverrideModifier = member.parent ? hasOverrideModifier(member) : hasSyntacticModifier(member, 16 /* Override */); return checkMemberForOverrideModifier( node, staticType, @@ -81793,7 +82018,7 @@ ${lanes.join("\n")} Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived === base) { const derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); - if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !hasSyntacticModifier(derivedClassDecl, 256 /* Abstract */))) { + if (baseDeclarationFlags & 64 /* Abstract */ && (!derivedClassDecl || !hasSyntacticModifier(derivedClassDecl, 64 /* Abstract */))) { for (const otherBaseType of getBaseTypes(type)) { if (otherBaseType === baseType) continue; @@ -81836,7 +82061,7 @@ ${lanes.join("\n")} } } else { const derivedDeclarationFlags = getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + if (baseDeclarationFlags & 2 /* Private */ || derivedDeclarationFlags & 2 /* Private */) { continue; } let errorMessage; @@ -81853,7 +82078,7 @@ ${lanes.join("\n")} error2(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage2, symbolToString(base), typeToString(baseType), typeToString(type)); } else if (useDefineForClassFields) { const uninitialized = (_c = derived.declarations) == null ? void 0 : _c.find((d) => d.kind === 172 /* PropertyDeclaration */ && !d.initializer); - if (uninitialized && !(derived.flags & 33554432 /* Transient */) && !(baseDeclarationFlags & 256 /* Abstract */) && !(derivedDeclarationFlags & 256 /* Abstract */) && !((_d = derived.declarations) == null ? void 0 : _d.some((d) => !!(d.flags & 33554432 /* Ambient */)))) { + if (uninitialized && !(derived.flags & 33554432 /* Transient */) && !(baseDeclarationFlags & 64 /* Abstract */) && !(derivedDeclarationFlags & 64 /* Abstract */) && !((_d = derived.declarations) == null ? void 0 : _d.some((d) => !!(d.flags & 33554432 /* Ambient */)))) { const constructor = findConstructorDeclaration(getClassLikeDeclarationOfSymbol(type.symbol)); const propName = uninitialized.name; if (uninitialized.exclamationToken || !constructor || !isIdentifier(propName) || !strictNullChecks || !isPropertyInitializedInConstructor(propName, type, constructor)) { @@ -81880,7 +82105,7 @@ ${lanes.join("\n")} } } function isPropertyAbstractOrInterface(declaration, baseDeclarationFlags) { - return baseDeclarationFlags & 256 /* Abstract */ && (!isPropertyDeclaration(declaration) || !declaration.initializer) || isInterfaceDeclaration(declaration.parent); + return baseDeclarationFlags & 64 /* Abstract */ && (!isPropertyDeclaration(declaration) || !declaration.initializer) || isInterfaceDeclaration(declaration.parent); } function getNonInheritedProperties(type, baseTypes, properties) { if (!length(baseTypes)) { @@ -81945,7 +82170,7 @@ ${lanes.join("\n")} } const constructor = findConstructorDeclaration(node); for (const member of node.members) { - if (getEffectiveModifierFlags(member) & 2 /* Ambient */) { + if (getEffectiveModifierFlags(member) & 128 /* Ambient */) { continue; } if (!isStatic(member) && isPropertyWithoutInitializer(member)) { @@ -82532,7 +82757,7 @@ ${lanes.join("\n")} name ); } - if (isType && node.kind === 271 /* ImportEqualsDeclaration */ && hasEffectiveModifier(node, 1 /* Export */)) { + if (isType && node.kind === 271 /* ImportEqualsDeclaration */ && hasEffectiveModifier(node, 32 /* Export */)) { error2(node, Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_0_is_enabled, isolatedModulesLikeFlagName); } break; @@ -82654,7 +82879,7 @@ ${lanes.join("\n")} checkGrammarModifiers(node); if (isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { markExportAsReferenced(node); } if (node.moduleReference.kind !== 283 /* ExternalModuleReference */) { @@ -83066,6 +83291,8 @@ ${lanes.join("\n")} return checkJSDocAccessibilityModifiers(node); case 357 /* JSDocSatisfiesTag */: return checkJSDocSatisfiesTag(node); + case 350 /* JSDocThisTag */: + return checkJSDocThisTag(node); case 199 /* IndexedAccessType */: return checkIndexedAccessType(node); case 200 /* MappedType */: @@ -83270,6 +83497,9 @@ ${lanes.join("\n")} case 217 /* ParenthesizedExpression */: checkAssertionDeferred(node); break; + case 222 /* VoidExpression */: + checkExpression(node.expression); + break; case 226 /* BinaryExpression */: if (isInstanceOfExpression(node)) { resolveUntypedCall(node); @@ -84289,7 +84519,7 @@ ${lanes.join("\n")} return true; } const target = getSymbolLinks(symbol).aliasTarget; - if (target && getEffectiveModifierFlags(node) & 1 /* Export */ && getSymbolFlags(target) & 111551 /* Value */ && (shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { + if (target && getEffectiveModifierFlags(node) & 32 /* Export */ && getSymbolFlags(target) & 111551 /* Value */ && (shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { return true; } } @@ -84314,10 +84544,10 @@ ${lanes.join("\n")} return false; } function isRequiredInitializedParameter(parameter) { - return !!strictNullChecks && !isOptionalParameter(parameter) && !isJSDocParameterTag(parameter) && !!parameter.initializer && !hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + return !!strictNullChecks && !isOptionalParameter(parameter) && !isJSDocParameterTag(parameter) && !!parameter.initializer && !hasSyntacticModifier(parameter, 31 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { - return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && hasSyntacticModifier(parameter, 31 /* ParameterPropertyModifier */); } function isExpandoFunctionDeclaration(node) { const declaration = getParseTreeNode(node, isFunctionDeclaration); @@ -84738,7 +84968,16 @@ ${lanes.join("\n")} } return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); }, - isImportRequiredByAugmentation + isImportRequiredByAugmentation, + tryFindAmbientModule: (moduleReferenceExpression) => { + const node = getParseTreeNode(moduleReferenceExpression); + const moduleSpecifier = node && isStringLiteralLike(node) ? node.text : void 0; + return moduleSpecifier !== void 0 ? tryFindAmbientModule( + moduleSpecifier, + /*withAugmentations*/ + true + ) : void 0; + } }; function isImportRequiredByAugmentation(node) { const file = getSourceFileOfNode(node); @@ -85162,10 +85401,10 @@ ${lanes.join("\n")} return grammarErrorOnFirstToken(node, Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); } } - if (flags & ~(1025 /* ExportDefault */ | 131072 /* Decorator */)) { + if (flags & ~(2080 /* ExportDefault */ | 32768 /* Decorator */)) { return grammarErrorOnNode(modifier, Diagnostics.Decorators_are_not_valid_here); } - if (hasLeadingDecorators && flags & 126975 /* Modifier */) { + if (hasLeadingDecorators && flags & 98303 /* Modifier */) { Debug.assertIsDefined(firstDecorator); const sourceFile = getSourceFileOfNode(modifier); if (!hasParseDiagnostics(sourceFile)) { @@ -85177,10 +85416,10 @@ ${lanes.join("\n")} } return false; } - flags |= 131072 /* Decorator */; - if (!(flags & 126975 /* Modifier */)) { + flags |= 32768 /* Decorator */; + if (!(flags & 98303 /* Modifier */)) { hasLeadingDecorators = true; - } else if (flags & 1 /* Export */) { + } else if (flags & 32 /* Export */) { sawExportBeforeDecorators = true; } firstDecorator ?? (firstDecorator = modifier); @@ -85209,39 +85448,39 @@ ${lanes.join("\n")} } break; case 164 /* OverrideKeyword */: - if (flags & 16384 /* Override */) { + if (flags & 16 /* Override */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "override"); - } else if (flags & 2 /* Ambient */) { + } else if (flags & 128 /* Ambient */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); - } else if (flags & 64 /* Readonly */) { + } else if (flags & 8 /* Readonly */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); - } else if (flags & 128 /* Accessor */) { + } else if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "override", "accessor"); - } else if (flags & 512 /* Async */) { + } else if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); } - flags |= 16384 /* Override */; + flags |= 16 /* Override */; lastOverride = modifier; break; case 125 /* PublicKeyword */: case 124 /* ProtectedKeyword */: case 123 /* PrivateKeyword */: const text = visibilityToString(modifierToFlag(modifier.kind)); - if (flags & 28 /* AccessibilityModifier */) { + if (flags & 7 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, Diagnostics.Accessibility_modifier_already_seen); - } else if (flags & 16384 /* Override */) { + } else if (flags & 16 /* Override */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); - } else if (flags & 32 /* Static */) { + } else if (flags & 256 /* Static */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); - } else if (flags & 128 /* Accessor */) { + } else if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "accessor"); - } else if (flags & 64 /* Readonly */) { + } else if (flags & 8 /* Readonly */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly"); - } else if (flags & 512 /* Async */) { + } else if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } else if (node.parent.kind === 268 /* ModuleBlock */ || node.parent.kind === 312 /* SourceFile */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); - } else if (flags & 256 /* Abstract */) { + } else if (flags & 64 /* Abstract */) { if (modifier.kind === 123 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -85253,60 +85492,60 @@ ${lanes.join("\n")} flags |= modifierToFlag(modifier.kind); break; case 126 /* StaticKeyword */: - if (flags & 32 /* Static */) { + if (flags & 256 /* Static */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "static"); - } else if (flags & 64 /* Readonly */) { + } else if (flags & 8 /* Readonly */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly"); - } else if (flags & 512 /* Async */) { + } else if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); - } else if (flags & 128 /* Accessor */) { + } else if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "accessor"); } else if (node.parent.kind === 268 /* ModuleBlock */ || node.parent.kind === 312 /* SourceFile */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 169 /* Parameter */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); - } else if (flags & 256 /* Abstract */) { + } else if (flags & 64 /* Abstract */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); - } else if (flags & 16384 /* Override */) { + } else if (flags & 16 /* Override */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } - flags |= 32 /* Static */; + flags |= 256 /* Static */; lastStatic = modifier; break; case 129 /* AccessorKeyword */: - if (flags & 128 /* Accessor */) { + if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "accessor"); - } else if (flags & 64 /* Readonly */) { + } else if (flags & 8 /* Readonly */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "accessor", "readonly"); - } else if (flags & 2 /* Ambient */) { + } else if (flags & 128 /* Ambient */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "accessor", "declare"); } else if (node.kind !== 172 /* PropertyDeclaration */) { return grammarErrorOnNode(modifier, Diagnostics.accessor_modifier_can_only_appear_on_a_property_declaration); } - flags |= 128 /* Accessor */; + flags |= 512 /* Accessor */; break; case 148 /* ReadonlyKeyword */: - if (flags & 64 /* Readonly */) { + if (flags & 8 /* Readonly */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "readonly"); } else if (node.kind !== 172 /* PropertyDeclaration */ && node.kind !== 171 /* PropertySignature */ && node.kind !== 181 /* IndexSignature */ && node.kind !== 169 /* Parameter */) { return grammarErrorOnNode(modifier, Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); - } else if (flags & 128 /* Accessor */) { + } else if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "readonly", "accessor"); } - flags |= 64 /* Readonly */; + flags |= 8 /* Readonly */; break; case 95 /* ExportKeyword */: if (compilerOptions.verbatimModuleSyntax && !(node.flags & 33554432 /* Ambient */) && node.kind !== 265 /* TypeAliasDeclaration */ && node.kind !== 264 /* InterfaceDeclaration */ && // ModuleDeclaration needs to be checked that it is uninstantiated later node.kind !== 267 /* ModuleDeclaration */ && node.parent.kind === 312 /* SourceFile */ && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) { return grammarErrorOnNode(modifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled); } - if (flags & 1 /* Export */) { + if (flags & 32 /* Export */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "export"); - } else if (flags & 2 /* Ambient */) { + } else if (flags & 128 /* Ambient */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); - } else if (flags & 256 /* Abstract */) { + } else if (flags & 64 /* Abstract */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); - } else if (flags & 512 /* Async */) { + } else if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (isClassLike(node.parent)) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export"); @@ -85317,7 +85556,7 @@ ${lanes.join("\n")} } else if (blockScopeKind === 6 /* AwaitUsing */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_an_await_using_declaration, "export"); } - flags |= 1 /* Export */; + flags |= 32 /* Export */; break; case 90 /* DefaultKeyword */: const container = node.parent.kind === 312 /* SourceFile */ ? node.parent : node.parent.parent; @@ -85327,19 +85566,19 @@ ${lanes.join("\n")} return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_using_declaration, "default"); } else if (blockScopeKind === 6 /* AwaitUsing */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_an_await_using_declaration, "default"); - } else if (!(flags & 1 /* Export */)) { + } else if (!(flags & 32 /* Export */)) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "default"); } else if (sawExportBeforeDecorators) { return grammarErrorOnNode(firstDecorator, Diagnostics.Decorators_are_not_valid_here); } - flags |= 1024 /* Default */; + flags |= 2048 /* Default */; break; case 138 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { + if (flags & 128 /* Ambient */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "declare"); - } else if (flags & 512 /* Async */) { + } else if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); - } else if (flags & 16384 /* Override */) { + } else if (flags & 16 /* Override */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "override"); } else if (isClassLike(node.parent) && !isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare"); @@ -85353,62 +85592,62 @@ ${lanes.join("\n")} return grammarErrorOnNode(modifier, Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } else if (isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); - } else if (flags & 128 /* Accessor */) { + } else if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "declare", "accessor"); } - flags |= 2 /* Ambient */; + flags |= 128 /* Ambient */; lastDeclare = modifier; break; case 128 /* AbstractKeyword */: - if (flags & 256 /* Abstract */) { + if (flags & 64 /* Abstract */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "abstract"); } if (node.kind !== 263 /* ClassDeclaration */ && node.kind !== 185 /* ConstructorType */) { if (node.kind !== 174 /* MethodDeclaration */ && node.kind !== 172 /* PropertyDeclaration */ && node.kind !== 177 /* GetAccessor */ && node.kind !== 178 /* SetAccessor */) { return grammarErrorOnNode(modifier, Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 263 /* ClassDeclaration */ && hasSyntacticModifier(node.parent, 256 /* Abstract */))) { + if (!(node.parent.kind === 263 /* ClassDeclaration */ && hasSyntacticModifier(node.parent, 64 /* Abstract */))) { const message = node.kind === 172 /* PropertyDeclaration */ ? Diagnostics.Abstract_properties_can_only_appear_within_an_abstract_class : Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class; return grammarErrorOnNode(modifier, message); } - if (flags & 32 /* Static */) { + if (flags & 256 /* Static */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 8 /* Private */) { + if (flags & 2 /* Private */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } - if (flags & 512 /* Async */ && lastAsync) { + if (flags & 1024 /* Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - if (flags & 16384 /* Override */) { + if (flags & 16 /* Override */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); } - if (flags & 128 /* Accessor */) { + if (flags & 512 /* Accessor */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "accessor"); } } if (isNamedDeclaration(node) && node.name.kind === 81 /* PrivateIdentifier */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } - flags |= 256 /* Abstract */; + flags |= 64 /* Abstract */; break; case 134 /* AsyncKeyword */: - if (flags & 512 /* Async */) { + if (flags & 1024 /* Async */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "async"); - } else if (flags & 2 /* Ambient */ || node.parent.flags & 33554432 /* Ambient */) { + } else if (flags & 128 /* Ambient */ || node.parent.flags & 33554432 /* Ambient */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (node.kind === 169 /* Parameter */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - if (flags & 256 /* Abstract */) { + if (flags & 64 /* Abstract */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - flags |= 512 /* Async */; + flags |= 1024 /* Async */; lastAsync = modifier; break; case 103 /* InKeyword */: case 147 /* OutKeyword */: - const inOutFlag = modifier.kind === 103 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */; + const inOutFlag = modifier.kind === 103 /* InKeyword */ ? 8192 /* In */ : 16384 /* Out */; const inOutText = modifier.kind === 103 /* InKeyword */ ? "in" : "out"; if (node.kind !== 168 /* TypeParameter */ || !(isInterfaceDeclaration(node.parent) || isClassLike(node.parent) || isTypeAliasDeclaration(node.parent))) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText); @@ -85416,7 +85655,7 @@ ${lanes.join("\n")} if (flags & inOutFlag) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, inOutText); } - if (inOutFlag & 32768 /* In */ && flags & 65536 /* Out */) { + if (inOutFlag & 8192 /* In */ && flags & 16384 /* Out */) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "in", "out"); } flags |= inOutFlag; @@ -85425,24 +85664,24 @@ ${lanes.join("\n")} } } if (node.kind === 176 /* Constructor */) { - if (flags & 32 /* Static */) { + if (flags & 256 /* Static */) { return grammarErrorOnNode(lastStatic, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 16384 /* Override */) { + if (flags & 16 /* Override */) { return grammarErrorOnNode(lastOverride, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); } - if (flags & 512 /* Async */) { + if (flags & 1024 /* Async */) { return grammarErrorOnNode(lastAsync, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return false; - } else if ((node.kind === 272 /* ImportDeclaration */ || node.kind === 271 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + } else if ((node.kind === 272 /* ImportDeclaration */ || node.kind === 271 /* ImportEqualsDeclaration */) && flags & 128 /* Ambient */) { return grammarErrorOnNode(lastDeclare, Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); - } else if (node.kind === 169 /* Parameter */ && flags & 16476 /* ParameterPropertyModifier */ && isBindingPattern(node.name)) { + } else if (node.kind === 169 /* Parameter */ && flags & 31 /* ParameterPropertyModifier */ && isBindingPattern(node.name)) { return grammarErrorOnNode(node, Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); - } else if (node.kind === 169 /* Parameter */ && flags & 16476 /* ParameterPropertyModifier */ && node.dotDotDotToken) { + } else if (node.kind === 169 /* Parameter */ && flags & 31 /* ParameterPropertyModifier */ && node.dotDotDotToken) { return grammarErrorOnNode(node, Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } - if (flags & 512 /* Async */) { + if (flags & 1024 /* Async */) { return checkGrammarAsyncModifier(node, lastAsync); } return false; @@ -85962,12 +86201,12 @@ ${lanes.join("\n")} if (languageVersion < 2 /* ES2015 */ && isPrivateIdentifier(accessor.name)) { return grammarErrorOnNode(accessor.name, Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } - if (accessor.body === void 0 && !hasSyntacticModifier(accessor, 256 /* Abstract */)) { + if (accessor.body === void 0 && !hasSyntacticModifier(accessor, 64 /* Abstract */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, Diagnostics._0_expected, "{"); } } if (accessor.body) { - if (hasSyntacticModifier(accessor, 256 /* Abstract */)) { + if (hasSyntacticModifier(accessor, 64 /* Abstract */)) { return grammarErrorOnNode(accessor, Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } if (accessor.parent.kind === 187 /* TypeLiteral */ || accessor.parent.kind === 264 /* InterfaceDeclaration */) { @@ -86039,7 +86278,7 @@ ${lanes.join("\n")} } break; case 171 /* PropertySignature */: - if (!hasSyntacticModifier(parent2, 64 /* Readonly */)) { + if (!hasSyntacticModifier(parent2, 8 /* Readonly */)) { return grammarErrorOnNode(parent2.name, Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } break; @@ -86209,7 +86448,7 @@ ${lanes.join("\n")} const message = node.initializer ? Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type ? Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations : Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context; return grammarErrorOnNode(node.exclamationToken, message); } - if ((moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && moduleKind !== 4 /* System */ && !(node.parent.parent.flags & 33554432 /* Ambient */) && hasSyntacticModifier(node.parent.parent, 1 /* Export */)) { + if ((moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && moduleKind !== 4 /* System */ && !(node.parent.parent.flags & 33554432 /* Ambient */) && hasSyntacticModifier(node.parent.parent, 32 /* Export */)) { checkESModuleMarker(node.name); } return !!blockScopeKind && checkGrammarNameInLetOrConstDeclarations(node.name); @@ -86399,7 +86638,7 @@ ${lanes.join("\n")} } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 264 /* InterfaceDeclaration */ || node.kind === 265 /* TypeAliasDeclaration */ || node.kind === 272 /* ImportDeclaration */ || node.kind === 271 /* ImportEqualsDeclaration */ || node.kind === 278 /* ExportDeclaration */ || node.kind === 277 /* ExportAssignment */ || node.kind === 270 /* NamespaceExportDeclaration */ || hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 1024 /* Default */)) { + if (node.kind === 264 /* InterfaceDeclaration */ || node.kind === 265 /* TypeAliasDeclaration */ || node.kind === 272 /* ImportDeclaration */ || node.kind === 271 /* ImportEqualsDeclaration */ || node.kind === 278 /* ExportDeclaration */ || node.kind === 277 /* ExportAssignment */ || node.kind === 270 /* NamespaceExportDeclaration */ || hasSyntacticModifier(node, 128 /* Ambient */ | 32 /* Export */ | 2048 /* Default */)) { return false; } return grammarErrorOnFirstToken(node, Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier); @@ -86845,12 +87084,14 @@ ${lanes.join("\n")} this.canTrackSymbol = !!((_a = this.inner) == null ? void 0 : _a.trackSymbol); } trackSymbol(symbol, enclosingDeclaration, meaning) { - var _a; + var _a, _b; if (((_a = this.inner) == null ? void 0 : _a.trackSymbol) && !this.disableTrackSymbol) { if (this.inner.trackSymbol(symbol, enclosingDeclaration, meaning)) { this.onDiagnosticReported(); return true; } + if (!(symbol.flags & 262144 /* TypeParameter */)) + ((_b = this.context).trackedSymbols ?? (_b.trackedSymbols = [])).push([symbol, enclosingDeclaration, meaning]); } return false; } @@ -88913,15 +89154,15 @@ ${lanes.join("\n")} } break; case 243 /* VariableStatement */: - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { for (const decl of node.declarationList.declarations) { exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames, exportedBindings); } } break; case 262 /* FunctionDeclaration */: - if (hasSyntacticModifier(node, 1 /* Export */)) { - if (hasSyntacticModifier(node, 1024 /* Default */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { + if (hasSyntacticModifier(node, 2048 /* Default */)) { if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); hasExportDefault = true; @@ -88937,8 +89178,8 @@ ${lanes.join("\n")} } break; case 263 /* ClassDeclaration */: - if (hasSyntacticModifier(node, 1 /* Export */)) { - if (hasSyntacticModifier(node, 1024 /* Default */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { + if (hasSyntacticModifier(node, 2048 /* Default */)) { if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); hasExportDefault = true; @@ -89828,7 +90069,7 @@ ${lanes.join("\n")} // src/compiler/transformers/namedEvaluation.ts function getAssignedNameOfIdentifier(factory2, name, expression) { const original = getOriginalNode(skipOuterExpressions(expression)); - if ((isClassDeclaration(original) || isFunctionDeclaration(original)) && !original.name && hasSyntacticModifier(original, 1024 /* Default */)) { + if ((isClassDeclaration(original) || isFunctionDeclaration(original)) && !original.name && hasSyntacticModifier(original, 2048 /* Default */)) { return factory2.createStringLiteral("default"); } return factory2.createStringLiteralFromNode(name); @@ -90199,13 +90440,13 @@ ${lanes.join("\n")} break; case 263 /* ClassDeclaration */: case 262 /* FunctionDeclaration */: - if (hasSyntacticModifier(node, 2 /* Ambient */)) { + if (hasSyntacticModifier(node, 128 /* Ambient */)) { break; } if (node.name) { recordEmittedDeclarationInScope(node); } else { - Debug.assert(node.kind === 263 /* ClassDeclaration */ || hasSyntacticModifier(node, 1024 /* Default */)); + Debug.assert(node.kind === 263 /* ClassDeclaration */ || hasSyntacticModifier(node, 2048 /* Default */)); } break; } @@ -90260,7 +90501,7 @@ ${lanes.join("\n")} function namespaceElementVisitorWorker(node) { if (node.kind === 278 /* ExportDeclaration */ || node.kind === 272 /* ImportDeclaration */ || node.kind === 273 /* ImportClause */ || node.kind === 271 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 283 /* ExternalModuleReference */) { return void 0; - } else if (node.transformFlags & 1 /* ContainsTypeScript */ || hasSyntacticModifier(node, 1 /* Export */)) { + } else if (node.transformFlags & 1 /* ContainsTypeScript */ || hasSyntacticModifier(node, 32 /* Export */)) { return visitTypeScript(node); } return node; @@ -90318,7 +90559,7 @@ ${lanes.join("\n")} function modifierVisitor(node) { if (isDecorator(node)) return void 0; - if (modifierToFlag(node.kind) & 117086 /* TypeScriptModifier */) { + if (modifierToFlag(node.kind) & 28895 /* TypeScriptModifier */) { return void 0; } else if (currentNamespace && node.kind === 95 /* ExportKeyword */) { return void 0; @@ -90326,7 +90567,7 @@ ${lanes.join("\n")} return node; } function visitTypeScript(node) { - if (isStatement(node) && hasSyntacticModifier(node, 2 /* Ambient */)) { + if (isStatement(node) && hasSyntacticModifier(node, 128 /* Ambient */)) { return factory2.createNotEmittedStatement(node); } switch (node.kind) { @@ -90816,7 +91057,7 @@ ${lanes.join("\n")} return !nodeIsMissing(node.body); } function visitPropertyDeclaration(node, parent2) { - const isAmbient = node.flags & 33554432 /* Ambient */ || hasSyntacticModifier(node, 256 /* Abstract */); + const isAmbient = node.flags & 33554432 /* Ambient */ || hasSyntacticModifier(node, 64 /* Abstract */); if (isAmbient && !(legacyDecorators && hasDecorators(node))) { return void 0; } @@ -90825,7 +91066,7 @@ ${lanes.join("\n")} if (isAmbient) { return factory2.updatePropertyDeclaration( node, - concatenate(modifiers, factory2.createModifiersFromModifierFlags(2 /* Ambient */)), + concatenate(modifiers, factory2.createModifiersFromModifierFlags(128 /* Ambient */)), Debug.checkDefined(visitNode(node.name, visitor, isPropertyName)), /*questionOrExclamationToken*/ void 0, @@ -90988,7 +91229,7 @@ ${lanes.join("\n")} ); } function shouldEmitAccessorDeclaration(node) { - return !(nodeIsMissing(node.body) && hasSyntacticModifier(node, 256 /* Abstract */)); + return !(nodeIsMissing(node.body) && hasSyntacticModifier(node, 64 /* Abstract */)); } function visitGetAccessor(node, parent2) { if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { @@ -91721,16 +91962,16 @@ ${lanes.join("\n")} } } function isExportOfNamespace(node) { - return currentNamespace !== void 0 && hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace !== void 0 && hasSyntacticModifier(node, 32 /* Export */); } function isExternalModuleExport(node) { - return currentNamespace === void 0 && hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace === void 0 && hasSyntacticModifier(node, 32 /* Export */); } function isNamedExternalModuleExport(node) { - return isExternalModuleExport(node) && !hasSyntacticModifier(node, 1024 /* Default */); + return isExternalModuleExport(node) && !hasSyntacticModifier(node, 2048 /* Default */); } function isDefaultExternalModuleExport(node) { - return isExternalModuleExport(node) && hasSyntacticModifier(node, 1024 /* Default */); + return isExternalModuleExport(node) && hasSyntacticModifier(node, 2048 /* Default */); } function createExportMemberAssignmentStatement(node) { const expression = factory2.createAssignment( @@ -93071,8 +93312,8 @@ ${lanes.join("\n")} getClassLexicalEnvironment().classThis = node.emitNode.classThis; } const isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 262144 /* ContainsConstructorReference */; - const isExport = hasSyntacticModifier(node, 1 /* Export */); - const isDefault = hasSyntacticModifier(node, 1024 /* Default */); + const isExport = hasSyntacticModifier(node, 32 /* Export */); + const isDefault = hasSyntacticModifier(node, 2048 /* Default */); let modifiers = visitNodes2(node.modifiers, modifierVisitor, isModifier); const heritageClauses = visitNodes2(node.heritageClauses, heritageClauseVisitor, isHeritageClause); const { members, prologue } = transformClassMembers(node); @@ -93618,7 +93859,7 @@ ${lanes.join("\n")} return void 0; } const propertyOriginalNode = getOriginalNode(property); - if (hasSyntacticModifier(propertyOriginalNode, 256 /* Abstract */)) { + if (hasSyntacticModifier(propertyOriginalNode, 64 /* Abstract */)) { return void 0; } let initializer = visitNode(property.initializer, visitor, isExpression); @@ -94666,8 +94907,8 @@ ${lanes.join("\n")} return addRange([updated], decorationStatements); } function transformClassDeclarationWithClassDecorators(node, name) { - const isExport = hasSyntacticModifier(node, 1 /* Export */); - const isDefault = hasSyntacticModifier(node, 1024 /* Default */); + const isExport = hasSyntacticModifier(node, 32 /* Export */); + const isDefault = hasSyntacticModifier(node, 2048 /* Default */); const modifiers = visitNodes2(node.modifiers, (node2) => isExportOrDefaultModifier(node2) || isDecorator(node2) ? void 0 : node2, isModifierLike); const location = moveRangePastModifiers(node); const classAlias = getClassAliasIfNeeded(node); @@ -94688,7 +94929,7 @@ ${lanes.join("\n")} let members = visitNodes2(node.members, visitor, isClassElement); let decorationStatements = []; ({ members, decorationStatements } = transformDecoratorsOfClassElements(node, members)); - const assignClassAliasInStaticBlock = languageVersion >= 9 /* ES2022 */ && !!classAlias && some(members, (member) => isPropertyDeclaration(member) && hasSyntacticModifier(member, 32 /* Static */) || isClassStaticBlockDeclaration(member)); + const assignClassAliasInStaticBlock = languageVersion >= 9 /* ES2022 */ && !!classAlias && some(members, (member) => isPropertyDeclaration(member) && hasSyntacticModifier(member, 256 /* Static */) || isClassStaticBlockDeclaration(member)); if (assignClassAliasInStaticBlock) { members = setTextRange( factory2.createNodeArray([ @@ -94819,7 +95060,7 @@ ${lanes.join("\n")} ); } function visitPropertyDeclaration(node) { - if (node.flags & 33554432 /* Ambient */ || hasSyntacticModifier(node, 2 /* Ambient */)) { + if (node.flags & 33554432 /* Ambient */ || hasSyntacticModifier(node, 128 /* Ambient */)) { return void 0; } return finishClassElement( @@ -94907,7 +95148,7 @@ ${lanes.join("\n")} const memberName = getExpressionForPropertyName( member, /*generateNameForComputedPropertyName*/ - !hasSyntacticModifier(member, 2 /* Ambient */) + !hasSyntacticModifier(member, 128 /* Ambient */) ); const descriptor = languageVersion > 0 /* ES3 */ ? isPropertyDeclaration(member) && !hasAccessorModifier(member) ? factory2.createVoidZero() : factory2.createNull() : void 0; const helper = emitHelpers().createDecorateHelper( @@ -95696,8 +95937,8 @@ ${lanes.join("\n")} const statements = []; const originalClass = getOriginalNode(node, isClassLike) ?? node; const className = originalClass.name ? factory2.createStringLiteralFromNode(originalClass.name) : factory2.createStringLiteral("default"); - const isExport = hasSyntacticModifier(node, 1 /* Export */); - const isDefault = hasSyntacticModifier(node, 1024 /* Default */); + const isExport = hasSyntacticModifier(node, 32 /* Export */); + const isDefault = hasSyntacticModifier(node, 2048 /* Default */); if (!node.name) { node = injectClassNamedEvaluationHelperBlockIfMissing(context, node, className); } @@ -98020,7 +98261,7 @@ ${lanes.join("\n")} return visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { const savedExportedVariableStatement = exportedVariableStatement; exportedVariableStatement = true; const visited = visitEachChild(node, visitor, context); @@ -99256,7 +99497,7 @@ ${lanes.join("\n")} addRange(topLevelStatements, endLexicalEnvironment()); if (exportVars.length) { topLevelStatements.push(factory2.createVariableStatement( - factory2.createModifiersFromModifierFlags(1 /* Export */), + factory2.createModifiersFromModifierFlags(32 /* Export */), factory2.createVariableDeclarationList( exportVars, 1 /* Let */ @@ -99553,8 +99794,8 @@ ${lanes.join("\n")} if (!node.name && defaultExportBinding) { return node; } - const isExported2 = hasSyntacticModifier(node, 1 /* Export */); - const isDefault = hasSyntacticModifier(node, 1024 /* Default */); + const isExported2 = hasSyntacticModifier(node, 32 /* Export */); + const isDefault = hasSyntacticModifier(node, 2048 /* Default */); let expression = factory2.converters.convertToClassExpression(node); if (node.name) { hoistBindingIdentifier( @@ -99602,7 +99843,7 @@ ${lanes.join("\n")} } function hoistVariableStatement(node) { let expressions; - const isExported2 = hasSyntacticModifier(node, 1 /* Export */); + const isExported2 = hasSyntacticModifier(node, 32 /* Export */); for (const variable of node.declarationList.declarations) { hoistBindingElement(variable, isExported2, variable); if (variable.initializer) { @@ -100196,7 +100437,7 @@ ${lanes.join("\n")} } function transformJsxSpreadAttributeToProps(node) { if (isObjectLiteralExpression(node.expression) && !hasProto(node.expression)) { - return node.expression.properties; + return sameMap(node.expression.properties, (p) => Debug.checkDefined(visitNode(p, visitor, isObjectLiteralElementLike))); } return factory2.createSpreadAssignment(Debug.checkDefined(visitNode(node.expression, visitor, isExpression))); } @@ -100777,7 +101018,7 @@ ${lanes.join("\n")} hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 && node.kind === 253 /* ReturnStatement */ && !node.expression; + return (hierarchyFacts & 8192 /* ConstructorWithSuperCall */) !== 0 && node.kind === 253 /* ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { return node.transformFlags & 4194304 /* ContainsHoistedDeclarationOrCompletion */ && (isReturnStatement(node) || isIfStatement(node) || isWithStatement(node) || isSwitchStatement(node) || isCaseBlock(node) || isCaseClause(node) || isDefaultClause(node) || isTryStatement(node) || isCatchClause(node) || isLabeledStatement(node) || isIterationStatement( @@ -100787,7 +101028,7 @@ ${lanes.join("\n")} ) || isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node) || isIterationStatement( + return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /* ConstructorWithSuperCall */ && isOrMayContainReturnCompletion(node) || isIterationStatement( node, /*lookInLabeledStatements*/ false @@ -100820,7 +101061,7 @@ ${lanes.join("\n")} /*expressionResultIsUnused*/ false ); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); return result; } return visitorWorker( @@ -100834,6 +101075,7 @@ ${lanes.join("\n")} function callExpressionVisitor(node) { if (node.kind === 108 /* SuperKeyword */) { return visitSuperKeyword( + node, /*isExpressionOfCall*/ true ); @@ -100943,6 +101185,7 @@ ${lanes.join("\n")} return visitSpreadElement(node); case 108 /* SuperKeyword */: return visitSuperKeyword( + node, /*isExpressionOfCall*/ false ); @@ -101012,7 +101255,10 @@ ${lanes.join("\n")} return updated; } function returnCapturedThis(node) { - return setOriginalNode(factory2.createReturnStatement(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)), node); + return setOriginalNode(factory2.createReturnStatement(createCapturedThis()), node); + } + function createCapturedThis() { + return factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */); } function visitReturnStatement(node) { if (convertedLoopState) { @@ -101036,8 +101282,9 @@ ${lanes.join("\n")} return visitEachChild(node, visitor, context); } function visitThisKeyword(node) { + hierarchyFacts |= 65536 /* LexicalThis */; if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + hierarchyFacts |= 131072 /* CapturedLexicalThis */; } if (convertedLoopState) { if (hierarchyFacts & 2 /* ArrowFunction */) { @@ -101147,8 +101394,8 @@ ${lanes.join("\n")} setTextRange(statement, node); startOnNewLine(statement); statements.push(statement); - if (hasSyntacticModifier(node, 1 /* Export */)) { - const exportStatement = hasSyntacticModifier(node, 1024 /* Default */) ? factory2.createExportDefault(factory2.getLocalName(node)) : factory2.createExternalModuleExport(factory2.getLocalName(node)); + if (hasSyntacticModifier(node, 32 /* Export */)) { + const exportStatement = hasSyntacticModifier(node, 2048 /* Default */) ? factory2.createExportDefault(factory2.getLocalName(node)) : factory2.createExternalModuleExport(factory2.getLocalName(node)); setOriginalNode(exportStatement, statement); statements.push(exportStatement); } @@ -101176,7 +101423,7 @@ ${lanes.join("\n")} void 0, /*dotDotDotToken*/ void 0, - factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */) + createSyntheticSuper() )] : [], /*type*/ void 0, @@ -101266,7 +101513,7 @@ ${lanes.join("\n")} setEmitFlags(constructorFunction, 16 /* CapturesThis */); } statements.push(constructorFunction); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; } function transformConstructorParameters(constructor, hasSynthesizedSuper) { @@ -101290,103 +101537,35 @@ ${lanes.join("\n")} setEmitFlags(block, 3072 /* NoComments */); return block; } - function transformConstructorBodyWorker(prologueOut, statementsOut, statementsIn, statementOffset, superPath, superPathDepth, constructor, isDerivedClass, hasSynthesizedSuper, isFirstStatement) { - let mayReplaceThis = false; - const superStatementIndex = superPathDepth < superPath.length ? superPath[superPathDepth] : -1; - const leadingStatementsEnd = superStatementIndex >= 0 ? superStatementIndex : statementsIn.length; - if (isFirstStatement && superStatementIndex >= 0) { - let firstMaterialIndex = statementOffset; - while (isFirstStatement && firstMaterialIndex < superStatementIndex) { - const statement = constructor.body.statements[firstMaterialIndex]; - if (!isUninitializedVariableStatement(statement) && !isUsingDeclarationStateVariableStatement(statement)) - break; - firstMaterialIndex++; - } - isFirstStatement = superStatementIndex === firstMaterialIndex; - } - addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, statementOffset, leadingStatementsEnd - statementOffset)); - const superStatement = superStatementIndex >= 0 ? statementsIn[superStatementIndex] : void 0; - if (superStatement && isTryStatement(superStatement)) { - const tryBlockStatements = []; - mayReplaceThis = transformConstructorBodyWorker( - prologueOut, - tryBlockStatements, - superStatement.tryBlock.statements, - /*statementOffset*/ - 0, - superPath, - superPathDepth + 1, - constructor, - isDerivedClass, - hasSynthesizedSuper, - isFirstStatement - ); - const tryBlockStatementsArray = factory2.createNodeArray(tryBlockStatements); - setTextRange(tryBlockStatementsArray, superStatement.tryBlock.statements); - statementsOut.push(factory2.updateTryStatement( - superStatement, - factory2.updateBlock(superStatement.tryBlock, tryBlockStatements), - visitNode(superStatement.catchClause, visitor, isCatchClause), - visitNode(superStatement.finallyBlock, visitor, isBlock) - )); - } else { - const superCall = superStatement && getSuperCallFromStatement(superStatement); - let superCallExpression; - if (hasSynthesizedSuper) { - superCallExpression = createDefaultSuperCallOrThis(); - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; - } else if (superCall) { - superCallExpression = visitSuperCallInBody(superCall); - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; - } - if (isDerivedClass || superCallExpression) { - if (superCallExpression && superStatementIndex === statementsIn.length - 1 && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) { - const superCall2 = cast(cast(superCallExpression, isBinaryExpression).left, isCallExpression); - const returnStatement = factory2.createReturnStatement(superCallExpression); - setCommentRange(returnStatement, getCommentRange(superCall2)); - setEmitFlags(superCall2, 3072 /* NoComments */); - statementsOut.push(returnStatement); - return false; - } else { - if (isFirstStatement) { - insertCaptureThisForNode(statementsOut, constructor, superCallExpression || createActualThis()); - } else { - insertCaptureThisForNode(prologueOut, constructor, createActualThis()); - if (superCallExpression) { - addSuperThisCaptureThisForNode(statementsOut, superCallExpression); - } - } - mayReplaceThis = true; - } - } else { - insertCaptureThisForNodeIfNeeded(prologueOut, constructor); - } - } - if (superStatementIndex >= 0) { - addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, superStatementIndex + 1)); - } - return mayReplaceThis; - } function isUninitializedVariableStatement(node) { return isVariableStatement(node) && every(node.declarationList.declarations, (decl) => isIdentifier(decl.name) && !decl.initializer); } - function isUsingDeclarationStateVariableStatement(node) { - if (!isVariableStatement(node) || node.declarationList.declarations.length !== 1) - return false; - const varDecl = node.declarationList.declarations[0]; - if (!isIdentifier(varDecl.name) || !varDecl.initializer) - return false; - const initializer = varDecl.initializer; - if (!isObjectLiteralExpression(initializer) || initializer.properties.length !== 3) - return false; - const [stackProp, errorProp, hasErrorProp] = initializer.properties; - if (!isPropertyAssignment(stackProp) || !isIdentifier(stackProp.name) || idText(stackProp.name) !== "stack" || !isArrayLiteralExpression(stackProp.initializer)) - return false; - if (!isPropertyAssignment(errorProp) || !isIdentifier(errorProp.name) || idText(errorProp.name) !== "error" || !isVoidExpression(errorProp.initializer) || !isNumericLiteral(errorProp.initializer.expression)) - return false; - if (!isPropertyAssignment(hasErrorProp) || !isIdentifier(hasErrorProp.name) || idText(hasErrorProp.name) !== "hasError" || hasErrorProp.initializer.kind !== 97 /* FalseKeyword */) + function containsSuperCall(node) { + if (isSuperCall(node)) { + return true; + } + if (!(node.transformFlags & 134217728 /* ContainsLexicalSuper */)) { return false; - return true; + } + switch (node.kind) { + case 219 /* ArrowFunction */: + case 218 /* FunctionExpression */: + case 262 /* FunctionDeclaration */: + case 176 /* Constructor */: + case 175 /* ClassStaticBlockDeclaration */: + return false; + case 177 /* GetAccessor */: + case 178 /* SetAccessor */: + case 174 /* MethodDeclaration */: + case 172 /* PropertyDeclaration */: { + const named = node; + if (isComputedPropertyName(named.name)) { + return !!forEachChild(named.name, containsSuperCall); + } + return false; + } + } + return !!forEachChild(node, containsSuperCall); } function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { const isDerivedClass = !!extendsClauseElement && skipOuterExpressions(extendsClauseElement.expression).kind !== 106 /* NullKeyword */; @@ -101401,31 +101580,22 @@ ${lanes.join("\n")} /*statementOffset*/ 0 ); - const superStatementIndices = findSuperStatementIndexPath(constructor.body.statements, standardPrologueEnd); - if (hasSynthesizedSuper || superStatementIndices.length > 0) { - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; + if (hasSynthesizedSuper || containsSuperCall(constructor.body)) { + hierarchyFacts |= 8192 /* ConstructorWithSuperCall */; } - const mayReplaceThis = transformConstructorBodyWorker( - prologue, - statements, - constructor.body.statements, - standardPrologueEnd, - superStatementIndices, - /*superPathDepth*/ - 0, - constructor, - isDerivedClass, - hasSynthesizedSuper, - /*isFirstStatement*/ - true - // NOTE: this will be recalculated inside of transformConstructorBodyWorker - ); + addRange(statements, visitNodes2(constructor.body.statements, visitor, isStatement, standardPrologueEnd)); + const mayReplaceThis = isDerivedClass || hierarchyFacts & 8192 /* ConstructorWithSuperCall */; addDefaultValueAssignmentsIfNeeded2(prologue, constructor); addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper); insertCaptureNewTargetIfNeeded(prologue, constructor); + if (mayReplaceThis) { + insertCaptureThisForNode(prologue, constructor, createActualThis()); + } else { + insertCaptureThisForNodeIfNeeded(prologue, constructor); + } factory2.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); if (mayReplaceThis && !isSufficientlyCoveredByReturnStatements(constructor.body)) { - statements.push(factory2.createReturnStatement(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */))); + statements.push(factory2.createReturnStatement(createCapturedThis())); } const body = factory2.createBlock( setTextRange( @@ -101442,6 +101612,230 @@ ${lanes.join("\n")} true ); setTextRange(body, constructor.body); + return simplifyConstructor(body, constructor.body, hasSynthesizedSuper); + } + function isCapturedThis(node) { + return isGeneratedIdentifier(node) && idText(node) === "_this"; + } + function isSyntheticSuper(node) { + return isGeneratedIdentifier(node) && idText(node) === "_super"; + } + function isThisCapturingVariableStatement(node) { + return isVariableStatement(node) && node.declarationList.declarations.length === 1 && isThisCapturingVariableDeclaration(node.declarationList.declarations[0]); + } + function isThisCapturingVariableDeclaration(node) { + return isVariableDeclaration(node) && isCapturedThis(node.name) && !!node.initializer; + } + function isThisCapturingAssignment(node) { + return isAssignmentExpression( + node, + /*excludeCompoundAssignment*/ + true + ) && isCapturedThis(node.left); + } + function isTransformedSuperCall(node) { + return isCallExpression(node) && isPropertyAccessExpression(node.expression) && isSyntheticSuper(node.expression.expression) && isIdentifier(node.expression.name) && (idText(node.expression.name) === "call" || idText(node.expression.name) === "apply") && node.arguments.length >= 1 && node.arguments[0].kind === 110 /* ThisKeyword */; + } + function isTransformedSuperCallWithFallback(node) { + return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isTransformedSuperCall(node.left); + } + function isImplicitSuperCall(node) { + return isBinaryExpression(node) && node.operatorToken.kind === 56 /* AmpersandAmpersandToken */ && isBinaryExpression(node.left) && node.left.operatorToken.kind === 38 /* ExclamationEqualsEqualsToken */ && isSyntheticSuper(node.left.left) && node.left.right.kind === 106 /* NullKeyword */ && isTransformedSuperCall(node.right) && idText(node.right.expression.name) === "apply"; + } + function isImplicitSuperCallWithFallback(node) { + return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isImplicitSuperCall(node.left); + } + function isThisCapturingTransformedSuperCallWithFallback(node) { + return isThisCapturingAssignment(node) && isTransformedSuperCallWithFallback(node.right); + } + function isThisCapturingImplicitSuperCallWithFallback(node) { + return isThisCapturingAssignment(node) && isImplicitSuperCallWithFallback(node.right); + } + function isTransformedSuperCallLike(node) { + return isTransformedSuperCall(node) || isTransformedSuperCallWithFallback(node) || isThisCapturingTransformedSuperCallWithFallback(node) || isImplicitSuperCall(node) || isImplicitSuperCallWithFallback(node) || isThisCapturingImplicitSuperCallWithFallback(node); + } + function simplifyConstructorInlineSuperInThisCaptureVariable(body) { + for (let i = 0; i < body.statements.length - 1; i++) { + const statement = body.statements[i]; + if (!isThisCapturingVariableStatement(statement)) { + continue; + } + const varDecl = statement.declarationList.declarations[0]; + if (varDecl.initializer.kind !== 110 /* ThisKeyword */) { + continue; + } + const thisCaptureStatementIndex = i; + let superCallIndex = i + 1; + while (superCallIndex < body.statements.length) { + const statement2 = body.statements[superCallIndex]; + if (isExpressionStatement(statement2)) { + if (isTransformedSuperCallLike(skipOuterExpressions(statement2.expression))) { + break; + } + } + if (isUninitializedVariableStatement(statement2)) { + superCallIndex++; + continue; + } + return body; + } + const following = body.statements[superCallIndex]; + let expression = following.expression; + if (isThisCapturingAssignment(expression)) { + expression = expression.right; + } + const newVarDecl = factory2.updateVariableDeclaration( + varDecl, + varDecl.name, + /*exclamationToken*/ + void 0, + /*type*/ + void 0, + expression + ); + const newDeclList = factory2.updateVariableDeclarationList(statement.declarationList, [newVarDecl]); + const newVarStatement = factory2.createVariableStatement(statement.modifiers, newDeclList); + setOriginalNode(newVarStatement, following); + setTextRange(newVarStatement, following); + const newStatements = factory2.createNodeArray([ + ...body.statements.slice(0, thisCaptureStatementIndex), + // copy statements preceding to `var _this` + ...body.statements.slice(thisCaptureStatementIndex + 1, superCallIndex), + // copy intervening temp variables + newVarStatement, + ...body.statements.slice(superCallIndex + 1) + // copy statements following `super.call(this, ...)` + ]); + setTextRange(newStatements, body.statements); + return factory2.updateBlock(body, newStatements); + } + return body; + } + function simplifyConstructorInlineSuperReturn(body, original) { + for (const statement of original.statements) { + if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) { + return body; + } + } + const canElideThisCapturingVariable = !(original.transformFlags & 16384 /* ContainsLexicalThis */) && !(hierarchyFacts & 65536 /* LexicalThis */) && !(hierarchyFacts & 131072 /* CapturedLexicalThis */); + for (let i = body.statements.length - 1; i > 0; i--) { + const statement = body.statements[i]; + if (isReturnStatement(statement) && statement.expression && isCapturedThis(statement.expression)) { + const preceding = body.statements[i - 1]; + let expression; + if (isExpressionStatement(preceding) && isThisCapturingTransformedSuperCallWithFallback(skipOuterExpressions(preceding.expression))) { + expression = preceding.expression; + } else if (canElideThisCapturingVariable && isThisCapturingVariableStatement(preceding)) { + const varDecl = preceding.declarationList.declarations[0]; + if (isTransformedSuperCallLike(skipOuterExpressions(varDecl.initializer))) { + expression = factory2.createAssignment( + createCapturedThis(), + varDecl.initializer + ); + } + } + if (!expression) { + break; + } + const newReturnStatement = factory2.createReturnStatement(expression); + setOriginalNode(newReturnStatement, preceding); + setTextRange(newReturnStatement, preceding); + const newStatements = factory2.createNodeArray([ + ...body.statements.slice(0, i - 1), + // copy all statements preceding `_super.call(this, ...)` + newReturnStatement, + ...body.statements.slice(i + 1) + // copy all statements following `return _this;` + ]); + setTextRange(newStatements, body.statements); + return factory2.updateBlock(body, newStatements); + } + } + return body; + } + function elideUnusedThisCaptureWorker(node) { + if (isThisCapturingVariableStatement(node)) { + const varDecl = node.declarationList.declarations[0]; + if (varDecl.initializer.kind === 110 /* ThisKeyword */) { + return void 0; + } + } else if (isThisCapturingAssignment(node)) { + return factory2.createPartiallyEmittedExpression(node.right, node); + } + switch (node.kind) { + case 219 /* ArrowFunction */: + case 218 /* FunctionExpression */: + case 262 /* FunctionDeclaration */: + case 176 /* Constructor */: + case 175 /* ClassStaticBlockDeclaration */: + return node; + case 177 /* GetAccessor */: + case 178 /* SetAccessor */: + case 174 /* MethodDeclaration */: + case 172 /* PropertyDeclaration */: { + const named = node; + if (isComputedPropertyName(named.name)) { + return factory2.replacePropertyName(named, visitEachChild(named.name, elideUnusedThisCaptureWorker, nullTransformationContext)); + } + return node; + } + } + return visitEachChild(node, elideUnusedThisCaptureWorker, nullTransformationContext); + } + function simplifyConstructorElideUnusedThisCapture(body, original) { + if (original.transformFlags & 16384 /* ContainsLexicalThis */ || hierarchyFacts & 65536 /* LexicalThis */ || hierarchyFacts & 131072 /* CapturedLexicalThis */) { + return body; + } + for (const statement of original.statements) { + if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) { + return body; + } + } + return factory2.updateBlock(body, visitNodes2(body.statements, elideUnusedThisCaptureWorker, isStatement)); + } + function injectSuperPresenceCheckWorker(node) { + if (isTransformedSuperCall(node) && node.arguments.length === 2 && isIdentifier(node.arguments[1]) && idText(node.arguments[1]) === "arguments") { + return factory2.createLogicalAnd( + factory2.createStrictInequality( + createSyntheticSuper(), + factory2.createNull() + ), + node + ); + } + switch (node.kind) { + case 219 /* ArrowFunction */: + case 218 /* FunctionExpression */: + case 262 /* FunctionDeclaration */: + case 176 /* Constructor */: + case 175 /* ClassStaticBlockDeclaration */: + return node; + case 177 /* GetAccessor */: + case 178 /* SetAccessor */: + case 174 /* MethodDeclaration */: + case 172 /* PropertyDeclaration */: { + const named = node; + if (isComputedPropertyName(named.name)) { + return factory2.replacePropertyName(named, visitEachChild(named.name, injectSuperPresenceCheckWorker, nullTransformationContext)); + } + return node; + } + } + return visitEachChild(node, injectSuperPresenceCheckWorker, nullTransformationContext); + } + function complicateConstructorInjectSuperPresenceCheck(body) { + return factory2.updateBlock(body, visitNodes2(body.statements, injectSuperPresenceCheckWorker, isStatement)); + } + function simplifyConstructor(body, original, hasSynthesizedSuper) { + const inputBody = body; + body = simplifyConstructorInlineSuperInThisCaptureVariable(body); + body = simplifyConstructorInlineSuperReturn(body, original); + if (body !== inputBody) { + body = simplifyConstructorElideUnusedThisCapture(body, original); + } + if (hasSynthesizedSuper) { + body = complicateConstructorInjectSuperPresenceCheck(body); + } return body; } function isSufficientlyCoveredByReturnStatements(statement) { @@ -101467,11 +101861,11 @@ ${lanes.join("\n")} return factory2.createLogicalOr( factory2.createLogicalAnd( factory2.createStrictInequality( - factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), + createSyntheticSuper(), factory2.createNull() ), factory2.createFunctionApplyCall( - factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), + createSyntheticSuper(), createActualThis(), factory2.createIdentifier("arguments") ) @@ -101726,24 +102120,12 @@ ${lanes.join("\n")} return true; } function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 219 /* ArrowFunction */) { + if (hierarchyFacts & 131072 /* CapturedLexicalThis */ && node.kind !== 219 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, factory2.createThis()); return true; } return false; } - function addSuperThisCaptureThisForNode(statements, superExpression) { - enableSubstitutionsForCapturedThis(); - const assignSuperExpression = factory2.createExpressionStatement( - factory2.createBinaryExpression( - factory2.createThis(), - 64 /* EqualsToken */, - superExpression - ) - ); - statements.push(assignSuperExpression); - setCommentRange(assignSuperExpression, getOriginalNode(superExpression).parent); - } function insertCaptureThisForNode(statements, node, initializer) { enableSubstitutionsForCapturedThis(); const captureThisStatement = factory2.createVariableStatement( @@ -101751,7 +102133,7 @@ ${lanes.join("\n")} void 0, factory2.createVariableDeclarationList([ factory2.createVariableDeclaration( - factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), + createCapturedThis(), /*exclamationToken*/ void 0, /*type*/ @@ -101972,7 +102354,7 @@ ${lanes.join("\n")} } function visitArrowFunction(node) { if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + hierarchyFacts |= 131072 /* CapturedLexicalThis */; } const savedConvertedLoopState = convertedLoopState; convertedLoopState = void 0; @@ -102005,7 +102387,7 @@ ${lanes.join("\n")} const parameters = visitParameterList(node.parameters, visitor, context); const body = transformFunctionBody2(node); const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return factory2.updateFunctionExpression( node, @@ -102028,7 +102410,7 @@ ${lanes.join("\n")} const parameters = visitParameterList(node.parameters, visitor, context); const body = transformFunctionBody2(node); const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return factory2.updateFunctionDeclaration( node, @@ -102052,7 +102434,7 @@ ${lanes.join("\n")} if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 262 /* FunctionDeclaration */ || node.kind === 218 /* FunctionExpression */)) { name = factory2.getGeneratedNameForNode(node); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return setOriginalNode( setTextRange( @@ -102205,7 +102587,7 @@ ${lanes.join("\n")} return node.declarationList.declarations.length === 1 && !!node.declarationList.declarations[0].initializer && !!(getInternalEmitFlags(node.declarationList.declarations[0].initializer) & 1 /* TypeScriptClassWrapper */); } function visitVariableStatement(node) { - const ancestorFacts = enterSubtree(0 /* None */, hasSyntacticModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + const ancestorFacts = enterSubtree(0 /* None */, hasSyntacticModifier(node, 32 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); let updated; if (convertedLoopState && (node.declarationList.flags & 7 /* BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { let assignments; @@ -103461,7 +103843,7 @@ ${lanes.join("\n")} } else { updated = factory2.updateSetAccessorDeclaration(node, node.modifiers, node.name, parameters, body); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return updated; } @@ -103611,13 +103993,6 @@ ${lanes.join("\n")} ) ); } - function visitSuperCallInBody(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment( - node, - /*assignToCapturedThis*/ - false - ); - } function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { if (node.transformFlags & 32768 /* ContainsRestOrSpread */ || node.expression.kind === 108 /* SuperKeyword */ || isSuperProperty(skipOuterExpressions(node.expression))) { const { target, thisArg } = factory2.createCallBinding(node.expression, hoistVariableDeclaration); @@ -103654,10 +104029,13 @@ ${lanes.join("\n")} resultingCall, createActualThis() ); - resultingCall = assignToCapturedThis ? factory2.createAssignment(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) : initializer; + resultingCall = assignToCapturedThis ? factory2.createAssignment(createCapturedThis(), initializer) : initializer; } return setOriginalNode(resultingCall, node); } + if (isSuperCall(node)) { + hierarchyFacts |= 131072 /* CapturedLexicalThis */; + } return visitEachChild(node, visitor, context); } function visitNewExpression(node) { @@ -103784,8 +104162,15 @@ ${lanes.join("\n")} } return setTextRange(expression, node); } - function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? factory2.createPropertyAccessExpression(factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), "prototype") : factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); + function createSyntheticSuper() { + return factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); + } + function visitSuperKeyword(node, isExpressionOfCall) { + const expression = hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? factory2.createPropertyAccessExpression(setOriginalNode(createSyntheticSuper(), node), "prototype") : createSyntheticSuper(); + setOriginalNode(expression, node); + setCommentRange(expression, node); + setSourceMapRange(expression, node); + return expression; } function visitMetaProperty(node) { if (node.keywordToken === 105 /* NewKeyword */ && node.name.escapedText === "target") { @@ -103891,7 +104276,7 @@ ${lanes.join("\n")} } function substituteThisKeyword(node) { if (enabledSubstitutions & 1 /* CapturedThis */ && hierarchyFacts & 16 /* CapturesThis */) { - return setTextRange(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), node); + return setTextRange(createCapturedThis(), node); } return node; } @@ -107169,7 +107554,7 @@ ${lanes.join("\n")} Debug.assert(isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); let statements; if (moduleKind !== 2 /* AMD */) { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { statements = append( statements, setOriginalNode( @@ -107215,7 +107600,7 @@ ${lanes.join("\n")} ); } } else { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { statements = append( statements, setOriginalNode( @@ -107353,7 +107738,7 @@ ${lanes.join("\n")} } function visitFunctionDeclaration(node) { let statements; - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { statements = append( statements, setOriginalNode( @@ -107390,7 +107775,7 @@ ${lanes.join("\n")} } function visitClassDeclaration(node) { let statements; - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { statements = append( statements, setOriginalNode( @@ -107424,7 +107809,7 @@ ${lanes.join("\n")} let statements; let variables; let expressions; - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { let modifiers; let removeCommentsOnExpressions = false; for (const variable of node.declarationList.declarations) { @@ -107610,8 +107995,8 @@ ${lanes.join("\n")} return statements; } const seen = new IdentifierNameMap(); - if (hasSyntacticModifier(decl, 1 /* Export */)) { - const exportName = hasSyntacticModifier(decl, 1024 /* Default */) ? factory2.createIdentifier("default") : factory2.getDeclarationName(decl); + if (hasSyntacticModifier(decl, 32 /* Export */)) { + const exportName = hasSyntacticModifier(decl, 2048 /* Default */) ? factory2.createIdentifier("default") : factory2.getDeclarationName(decl); statements = appendExportStatement( statements, seen, @@ -108105,7 +108490,7 @@ ${lanes.join("\n")} addRange(statements, hoistedStatements); insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); const exportStarFunction = addExportStarIfNeeded(statements); - const modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ? factory2.createModifiersFromModifierFlags(512 /* Async */) : void 0; + const modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ? factory2.createModifiersFromModifierFlags(1024 /* Async */) : void 0; const moduleObject = factory2.createObjectLiteralExpression( [ factory2.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), @@ -108307,7 +108692,7 @@ ${lanes.join("\n")} factory2.createAssignment(importVariableName, parameterName) ) ); - if (hasSyntacticModifier(entry, 1 /* Export */)) { + if (hasSyntacticModifier(entry, 32 /* Export */)) { statements.push( factory2.createExpressionStatement( factory2.createCallExpression( @@ -108460,7 +108845,7 @@ ${lanes.join("\n")} ); } function visitFunctionDeclaration(node) { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { hoistedStatements = append( hoistedStatements, factory2.updateFunctionDeclaration( @@ -108547,7 +108932,7 @@ ${lanes.join("\n")} statements = append(statements, factory2.updateVariableStatement(node, modifiers, declarationList)); } else { let expressions; - const isExportedDeclaration = hasSyntacticModifier(node, 1 /* Export */); + const isExportedDeclaration = hasSyntacticModifier(node, 32 /* Export */); for (const variable of node.declarationList.declarations) { if (variable.initializer) { expressions = append(expressions, transformInitializedVariable(variable, isExportedDeclaration)); @@ -108683,8 +109068,8 @@ ${lanes.join("\n")} return statements; } let excludeName; - if (hasSyntacticModifier(decl, 1 /* Export */)) { - const exportName = hasSyntacticModifier(decl, 1024 /* Default */) ? factory2.createStringLiteral("default") : decl.name; + if (hasSyntacticModifier(decl, 32 /* Export */)) { + const exportName = hasSyntacticModifier(decl, 2048 /* Default */) ? factory2.createStringLiteral("default") : decl.name; statements = appendExportStatement(statements, exportName, factory2.getLocalName(decl)); excludeName = getTextOfIdentifierOrLiteral(exportName); } @@ -109435,7 +109820,7 @@ ${lanes.join("\n")} return singleOrMany(statements); } function appendExportsOfImportEqualsDeclaration(statements, node) { - if (hasSyntacticModifier(node, 1 /* Export */)) { + if (hasSyntacticModifier(node, 32 /* Export */)) { statements = append( statements, factory2.createExportDeclaration( @@ -109657,7 +110042,7 @@ ${lanes.join("\n")} } else if (isConstructSignatureDeclaration(node) || isCallSignatureDeclaration(node) || isMethodDeclaration(node) || isMethodSignature(node) || isFunctionDeclaration(node) || isIndexSignatureDeclaration(node)) { return getReturnTypeVisibilityError; } else if (isParameter(node)) { - if (isParameterPropertyDeclaration(node, node.parent) && hasSyntacticModifier(node.parent, 8 /* Private */)) { + if (isParameterPropertyDeclaration(node, node.parent) && hasSyntacticModifier(node.parent, 2 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -109675,7 +110060,7 @@ ${lanes.join("\n")} function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (node.kind === 260 /* VariableDeclaration */ || node.kind === 208 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; - } else if (node.kind === 172 /* PropertyDeclaration */ || node.kind === 211 /* PropertyAccessExpression */ || node.kind === 212 /* ElementAccessExpression */ || node.kind === 226 /* BinaryExpression */ || node.kind === 171 /* PropertySignature */ || node.kind === 169 /* Parameter */ && hasSyntacticModifier(node.parent, 8 /* Private */)) { + } else if (node.kind === 172 /* PropertyDeclaration */ || node.kind === 211 /* PropertyAccessExpression */ || node.kind === 212 /* ElementAccessExpression */ || node.kind === 226 /* BinaryExpression */ || node.kind === 171 /* PropertySignature */ || node.kind === 169 /* Parameter */ && hasSyntacticModifier(node.parent, 2 /* Private */)) { if (isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } else if (node.parent.kind === 263 /* ClassDeclaration */ || node.kind === 169 /* Parameter */) { @@ -109978,6 +110363,17 @@ ${lanes.join("\n")} const container = getSourceFileOfNode(node); refs.set(getOriginalNodeId(container), container); } + function trackReferencedAmbientModuleFromImport(node) { + const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(node); + const symbol = moduleSpecifier && resolver.tryFindAmbientModule(moduleSpecifier); + if (symbol == null ? void 0 : symbol.declarations) { + for (const decl of symbol.declarations) { + if (isAmbientModule(decl) && getSourceFileOfNode(decl) !== currentSourceFile) { + trackReferencedAmbientModule(decl, symbol); + } + } + } + } function handleSymbolAccessibilityError(symbolAccessibilityResult) { if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) { if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { @@ -110390,7 +110786,7 @@ ${lanes.join("\n")} return void 0; } function ensureType(node, type, ignorePrivate) { - if (!ignorePrivate && hasEffectiveModifier(node, 8 /* Private */)) { + if (!ignorePrivate && hasEffectiveModifier(node, 2 /* Private */)) { return; } if (shouldPrintWithInitializer(node)) { @@ -110470,7 +110866,7 @@ ${lanes.join("\n")} } } function updateParamsList(node, params, modifierMask) { - if (hasEffectiveModifier(node, 8 /* Private */)) { + if (hasEffectiveModifier(node, 2 /* Private */)) { return factory2.createNodeArray(); } const newParams = map(params, (p) => ensureParameter(p, modifierMask)); @@ -110515,7 +110911,7 @@ ${lanes.join("\n")} return factory2.createNodeArray(newParams || emptyArray); } function ensureTypeParams(node, params) { - return hasEffectiveModifier(node, 8 /* Private */) ? void 0 : visitNodes2(params, visitDeclarationSubtree, isTypeParameterDeclaration); + return hasEffectiveModifier(node, 2 /* Private */) ? void 0 : visitNodes2(params, visitDeclarationSubtree, isTypeParameterDeclaration); } function isEnclosingDeclaration(node) { return isSourceFile(node) || isTypeAliasDeclaration(node) || isModuleDeclaration(node) || isClassDeclaration(node) || isInterfaceDeclaration(node) || isFunctionLike(node) || isIndexSignatureDeclaration(node) || isMappedTypeNode(node); @@ -110701,7 +111097,7 @@ ${lanes.join("\n")} const oldWithinObjectLiteralType = suppressNewDiagnosticContexts; let shouldEnterSuppressNewDiagnosticsContextContext = (input.kind === 187 /* TypeLiteral */ || input.kind === 200 /* MappedType */) && input.parent.kind !== 265 /* TypeAliasDeclaration */; if (isMethodDeclaration(input) || isMethodSignature(input)) { - if (hasEffectiveModifier(input, 8 /* Private */)) { + if (hasEffectiveModifier(input, 2 /* Private */)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; return cleanup(factory2.createPropertyDeclaration( @@ -110789,7 +111185,7 @@ ${lanes.join("\n")} input, ensureModifiers(input), input.name, - updateAccessorParamsList(input, hasEffectiveModifier(input, 8 /* Private */)), + updateAccessorParamsList(input, hasEffectiveModifier(input, 2 /* Private */)), ensureType(input, accessorType), /*body*/ void 0 @@ -110806,7 +111202,7 @@ ${lanes.join("\n")} input, ensureModifiers(input), input.name, - updateAccessorParamsList(input, hasEffectiveModifier(input, 8 /* Private */)), + updateAccessorParamsList(input, hasEffectiveModifier(input, 2 /* Private */)), /*body*/ void 0 )); @@ -110925,6 +111321,7 @@ ${lanes.join("\n")} case 205 /* ImportType */: { if (!isLiteralImportTypeNode(input)) return cleanup(input); + trackReferencedAmbientModuleFromImport(input); return cleanup(factory2.updateImportTypeNode( input, factory2.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), @@ -110962,7 +111359,7 @@ ${lanes.join("\n")} } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 174 /* MethodDeclaration */ && hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 174 /* MethodDeclaration */ && hasEffectiveModifier(node.parent, 2 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -110976,6 +111373,7 @@ ${lanes.join("\n")} resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; + trackReferencedAmbientModuleFromImport(input); return factory2.updateExportDeclaration( input, input.modifiers, @@ -111020,11 +111418,11 @@ ${lanes.join("\n")} return input; } function stripExportModifiers(statement) { - if (isImportEqualsDeclaration(statement) || hasEffectiveModifier(statement, 1024 /* Default */) || !canHaveModifiers(statement)) { + if (isImportEqualsDeclaration(statement) || hasEffectiveModifier(statement, 2048 /* Default */) || !canHaveModifiers(statement)) { return statement; } - const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (258047 /* All */ ^ 1 /* Export */)); - return factory2.updateModifiers(statement, modifiers); + const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (131071 /* All */ ^ 32 /* Export */)); + return factory2.replaceModifiers(statement, modifiers); } function updateModuleDeclarationAndKeyword(node, modifiers, name, body) { const updated = factory2.updateModuleDeclaration(node, modifiers, name, body); @@ -111050,10 +111448,18 @@ ${lanes.join("\n")} return; switch (input.kind) { case 271 /* ImportEqualsDeclaration */: { - return transformImportEqualsDeclaration(input); + const transformed = transformImportEqualsDeclaration(input); + if (transformed) { + trackReferencedAmbientModuleFromImport(input); + } + return transformed; } case 272 /* ImportDeclaration */: { - return transformImportDeclaration(input); + const transformed = transformImportDeclaration(input); + if (transformed) { + trackReferencedAmbientModuleFromImport(input); + } + return transformed; } } if (isDeclaration(input) && isDeclarationAndNotVisible(input)) @@ -111147,7 +111553,7 @@ ${lanes.join("\n")} return factory2.createVariableStatement(isNonContextualKeywordName ? void 0 : [factory2.createToken(95 /* ExportKeyword */)], factory2.createVariableDeclarationList([varDecl])); }); if (!exportMappings.length) { - declarations = mapDefined(declarations, (declaration) => factory2.updateModifiers(declaration, 0 /* None */)); + declarations = mapDefined(declarations, (declaration) => factory2.replaceModifiers(declaration, 0 /* None */)); } else { declarations.push(factory2.createExportDeclaration( /*modifiers*/ @@ -111165,10 +111571,10 @@ ${lanes.join("\n")} )); } const namespaceDecl = factory2.createModuleDeclaration(ensureModifiers(input), input.name, factory2.createModuleBlock(declarations), 32 /* Namespace */); - if (!hasEffectiveModifier(clean2, 1024 /* Default */)) { + if (!hasEffectiveModifier(clean2, 2048 /* Default */)) { return [clean2, namespaceDecl]; } - const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(clean2) & ~1025 /* ExportDefault */ | 2 /* Ambient */); + const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(clean2) & ~2080 /* ExportDefault */ | 128 /* Ambient */); const cleanDeclaration = factory2.updateFunctionDeclaration( clean2, modifiers, @@ -111260,7 +111666,7 @@ ${lanes.join("\n")} if (ctor) { const oldDiag2 = getSymbolAccessibilityDiagnostic; parameterProperties = compact(flatMap(ctor.parameters, (param) => { - if (!hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!hasSyntacticModifier(param, 31 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(param); if (param.name.kind === 80 /* Identifier */) { @@ -111489,11 +111895,11 @@ ${lanes.join("\n")} return factory2.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - let mask2 = 258047 /* All */ ^ (4 /* Public */ | 512 /* Async */ | 16384 /* Override */); - let additions = needsDeclare && !isAlwaysType(node) ? 2 /* Ambient */ : 0 /* None */; + let mask2 = 131071 /* All */ ^ (1 /* Public */ | 1024 /* Async */ | 16 /* Override */); + let additions = needsDeclare && !isAlwaysType(node) ? 128 /* Ambient */ : 0 /* None */; const parentIsFile = node.parent.kind === 312 /* SourceFile */; if (!parentIsFile || isBundledEmit && parentIsFile && isExternalModule(node.parent)) { - mask2 ^= 2 /* Ambient */; + mask2 ^= 128 /* Ambient */; additions = 0 /* None */; } return maskModifierFlags(node, mask2, additions); @@ -111535,13 +111941,13 @@ ${lanes.join("\n")} function maskModifiers(factory2, node, modifierMask, modifierAdditions) { return factory2.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } - function maskModifierFlags(node, modifierMask = 258047 /* All */ ^ 4 /* Public */, modifierAdditions = 0 /* None */) { + function maskModifierFlags(node, modifierMask = 131071 /* All */ ^ 1 /* Public */, modifierAdditions = 0 /* None */) { let flags = getEffectiveModifierFlags(node) & modifierMask | modifierAdditions; - if (flags & 1024 /* Default */ && !(flags & 1 /* Export */)) { - flags ^= 1 /* Export */; + if (flags & 2048 /* Default */ && !(flags & 32 /* Export */)) { + flags ^= 32 /* Export */; } - if (flags & 1024 /* Default */ && flags & 2 /* Ambient */) { - flags ^= 2 /* Ambient */; + if (flags & 2048 /* Default */ && flags & 128 /* Ambient */) { + flags ^= 128 /* Ambient */; } return flags; } @@ -111554,7 +111960,7 @@ ${lanes.join("\n")} switch (node.kind) { case 172 /* PropertyDeclaration */: case 171 /* PropertySignature */: - return !hasEffectiveModifier(node, 8 /* Private */); + return !hasEffectiveModifier(node, 2 /* Private */); case 169 /* Parameter */: case 260 /* VariableDeclaration */: return true; @@ -117540,7 +117946,8 @@ ${lanes.join("\n")} getSymbolOfExternalModuleSpecifier: notImplemented, isBindingCapturedByNode: notImplemented, getDeclarationStatementsForSourceFile: notImplemented, - isImportRequiredByAugmentation: notImplemented + isImportRequiredByAugmentation: notImplemented, + tryFindAmbientModule: notImplemented }; createPrinterWithDefaults = /* @__PURE__ */ memoize(() => createPrinter({})); createPrinterWithRemoveComments = /* @__PURE__ */ memoize(() => createPrinter({ removeComments: true })); @@ -118052,17 +118459,17 @@ ${lanes.join("\n")} function closeFileWatcherOf(objWithWatcher) { objWithWatcher.watcher.close(); } - var ConfigFileProgramReloadLevel, WatchLogLevel; + var ProgramUpdateLevel, WatchLogLevel; var init_watchUtilities = __esm({ "src/compiler/watchUtilities.ts"() { "use strict"; init_ts2(); - ConfigFileProgramReloadLevel = /* @__PURE__ */ ((ConfigFileProgramReloadLevel2) => { - ConfigFileProgramReloadLevel2[ConfigFileProgramReloadLevel2["None"] = 0] = "None"; - ConfigFileProgramReloadLevel2[ConfigFileProgramReloadLevel2["Partial"] = 1] = "Partial"; - ConfigFileProgramReloadLevel2[ConfigFileProgramReloadLevel2["Full"] = 2] = "Full"; - return ConfigFileProgramReloadLevel2; - })(ConfigFileProgramReloadLevel || {}); + ProgramUpdateLevel = /* @__PURE__ */ ((ProgramUpdateLevel2) => { + ProgramUpdateLevel2[ProgramUpdateLevel2["Update"] = 0] = "Update"; + ProgramUpdateLevel2[ProgramUpdateLevel2["RootNamesAndUpdate"] = 1] = "RootNamesAndUpdate"; + ProgramUpdateLevel2[ProgramUpdateLevel2["Full"] = 2] = "Full"; + return ProgramUpdateLevel2; + })(ProgramUpdateLevel || {}); WatchLogLevel = /* @__PURE__ */ ((WatchLogLevel2) => { WatchLogLevel2[WatchLogLevel2["None"] = 0] = "None"; WatchLogLevel2[WatchLogLevel2["TriggerOnly"] = 1] = "TriggerOnly"; @@ -120286,7 +120693,7 @@ ${lanes.join("\n")} } } } else if (isModuleDeclaration(node)) { - if (isAmbientModule(node) && (inAmbientModule || hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) { + if (isAmbientModule(node) && (inAmbientModule || hasSyntacticModifier(node, 128 /* Ambient */) || file.isDeclarationFile)) { node.name.parent = node; const nameText = getTextOfIdentifierOrLiteral(node.name); if (isExternalModuleFile || inAmbientModule && !isExternalModuleNameRelative(nameText)) { @@ -124025,6 +124432,10 @@ ${lanes.join("\n")} function getRootPathSplitLength(rootPath) { return rootPath.split(directorySeparator).length - (hasTrailingDirectorySeparator(rootPath) ? 1 : 0); } + function getModuleResolutionHost(resolutionHost) { + var _a; + return ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost; + } function createModuleResolutionLoaderUsingGlobalCache(containingFile, redirectedReference, options, resolutionHost, moduleResolutionCache) { return { nameAndMode: moduleResolutionNameAndModeGetter, @@ -124040,8 +124451,7 @@ ${lanes.join("\n")} }; } function resolveModuleNameUsingGlobalCache(resolutionHost, moduleResolutionCache, moduleName, containingFile, compilerOptions, redirectedReference, mode) { - var _a; - const host = ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost; + const host = getModuleResolutionHost(resolutionHost); const primaryResult = resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode); if (!resolutionHost.getGlobalCache) { return primaryResult; @@ -124212,6 +124622,10 @@ ${lanes.join("\n")} }; } function startCachingPerDirectoryResolution() { + moduleResolutionCache.isReadonly = void 0; + typeReferenceDirectiveResolutionCache.isReadonly = void 0; + libraryResolutionCache.isReadonly = void 0; + moduleResolutionCache.getPackageJsonInfoCache().isReadonly = void 0; moduleResolutionCache.clearAllExceptPackageJsonInfoCache(); typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache(); libraryResolutionCache.clearAllExceptPackageJsonInfoCache(); @@ -124269,6 +124683,10 @@ ${lanes.join("\n")} directoryWatchesOfFailedLookups.forEach(closeDirectoryWatchesOfFailedLookup); fileWatchesOfAffectingLocations.forEach(closeFileWatcherOfAffectingLocation); hasChangedAutomaticTypeDirectiveNames = false; + moduleResolutionCache.isReadonly = true; + typeReferenceDirectiveResolutionCache.isReadonly = true; + libraryResolutionCache.isReadonly = true; + moduleResolutionCache.getPackageJsonInfoCache().isReadonly = true; } function closeDirectoryWatchesOfFailedLookup(watcher, path) { if (watcher.refCount === 0) { @@ -124297,7 +124715,6 @@ ${lanes.join("\n")} shouldRetryResolution, logChanges }) { - var _a; const path = resolutionHost.toPath(containingFile); const resolutionsInFile = perFileCache.get(path) || perFileCache.set(path, createModeAwareCache()).get(path); const resolvedModules = []; @@ -124329,7 +124746,7 @@ ${lanes.join("\n")} logChanges = false; } } else { - const host = ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost; + const host = getModuleResolutionHost(resolutionHost); if (isTraceEnabled(options, host) && !seenNamesInFile.has(name, mode)) { const resolved = getResolutionWithResolvedFileName(resolution); trace( @@ -124381,7 +124798,6 @@ ${lanes.join("\n")} } } function resolveTypeReferenceDirectiveReferences(typeDirectiveReferences, containingFile, redirectedReference, options, containingSourceFile, reusedNames) { - var _a; return resolveNamesWithLocalCache({ entries: typeDirectiveReferences, containingFile, @@ -124394,7 +124810,7 @@ ${lanes.join("\n")} containingFile, redirectedReference, options, - ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost, + getModuleResolutionHost(resolutionHost), typeReferenceDirectiveResolutionCache ), getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective, @@ -124426,8 +124842,7 @@ ${lanes.join("\n")} }); } function resolveLibrary2(libraryName, resolveFrom, options, libFileName) { - var _a; - const host = ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost; + const host = getModuleResolutionHost(resolutionHost); let resolution = resolvedLibraries == null ? void 0 : resolvedLibraries.get(libFileName); if (!resolution || resolution.isInvalidated) { const existingResolution = resolution; @@ -124461,6 +124876,7 @@ ${lanes.join("\n")} return resolution; } function resolveSingleModuleNameWithoutWatching(moduleName, containingFile) { + var _a, _b; const path = resolutionHost.toPath(containingFile); const resolutionsInFile = resolvedModuleNames.get(path); const resolution = resolutionsInFile == null ? void 0 : resolutionsInFile.get( @@ -124470,7 +124886,17 @@ ${lanes.join("\n")} ); if (resolution && !resolution.isInvalidated) return resolution; - return resolveModuleNameUsingGlobalCache(resolutionHost, moduleResolutionCache, moduleName, containingFile, resolutionHost.getCompilationSettings()); + const data = (_a = resolutionHost.beforeResolveSingleModuleNameWithoutWatching) == null ? void 0 : _a.call(resolutionHost, moduleResolutionCache); + const host = getModuleResolutionHost(resolutionHost); + const result = resolveModuleName( + moduleName, + containingFile, + resolutionHost.getCompilationSettings(), + host, + moduleResolutionCache + ); + (_b = resolutionHost.afterResolveSingleModuleNameWithoutWatching) == null ? void 0 : _b.call(resolutionHost, moduleResolutionCache, moduleName, containingFile, result, data); + return result; } function isNodeModulesAtTypesDirectory(dirPath) { return endsWith(dirPath, "/node_modules/@types"); @@ -125654,7 +126080,7 @@ ${lanes.join("\n")} } function createWatchProgram(host) { let builderProgram; - let reloadLevel; + let updateLevel; let missingFilesMap; let watchedWildcardDirectories; let timerToUpdateProgram; @@ -126013,7 +126439,7 @@ ${lanes.join("\n")} } function scheduleProgramReload() { Debug.assert(!!configFileName); - reloadLevel = 2 /* Full */; + updateLevel = 2 /* Full */; scheduleProgramUpdate(); } function updateProgramWithWatchStatus() { @@ -126023,8 +126449,8 @@ ${lanes.join("\n")} } function updateProgram() { var _a, _b, _c, _d; - switch (reloadLevel) { - case 1 /* Partial */: + switch (updateLevel) { + case 1 /* RootNamesAndUpdate */: (_a = perfLogger) == null ? void 0 : _a.logStartUpdateProgram("PartialConfigReload"); reloadFileNamesFromConfigFile(); break; @@ -126044,7 +126470,7 @@ ${lanes.join("\n")} writeLog("Reloading new file names and options"); Debug.assert(compilerOptions); Debug.assert(configFileName); - reloadLevel = 0 /* None */; + updateLevel = 0 /* Update */; rootFileNames = getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, getNormalizedAbsolutePath(getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions); if (updateErrorForNoInputFiles(rootFileNames, getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) { hasChangedConfigFileParsingErrors = true; @@ -126054,7 +126480,7 @@ ${lanes.join("\n")} function reloadConfigFile() { Debug.assert(configFileName); writeLog(`Reloading config file: ${configFileName}`); - reloadLevel = 0 /* None */; + updateLevel = 0 /* Update */; if (cachedDirectoryStructureHost) { cachedDirectoryStructureHost.clearCache(); } @@ -126091,9 +126517,9 @@ ${lanes.join("\n")} const configPath = toPath3(configFileName2); let config = parsedConfigs == null ? void 0 : parsedConfigs.get(configPath); if (config) { - if (!config.reloadLevel) + if (!config.updateLevel) return config.parsedCommandLine; - if (config.parsedCommandLine && config.reloadLevel === 1 /* Partial */ && !host.getParsedCommandLine) { + if (config.parsedCommandLine && config.updateLevel === 1 /* RootNamesAndUpdate */ && !host.getParsedCommandLine) { writeLog("Reloading new file names and options"); Debug.assert(compilerOptions); const fileNames = getFileNamesFromConfigSpecs( @@ -126103,7 +126529,7 @@ ${lanes.join("\n")} parseConfigFileHost ); config.parsedCommandLine = { ...config.parsedCommandLine, fileNames }; - config.reloadLevel = void 0; + config.updateLevel = void 0; return config.parsedCommandLine; } } @@ -126111,7 +126537,7 @@ ${lanes.join("\n")} const parsedCommandLine = host.getParsedCommandLine ? host.getParsedCommandLine(configFileName2) : getParsedCommandLineFromConfigFileHost(configFileName2); if (config) { config.parsedCommandLine = parsedCommandLine; - config.reloadLevel = void 0; + config.updateLevel = void 0; } else { (parsedConfigs || (parsedConfigs = /* @__PURE__ */ new Map())).set(configPath, config = { parsedCommandLine }); } @@ -126208,8 +126634,8 @@ ${lanes.join("\n")} toPath: toPath3 })) return; - if (reloadLevel !== 2 /* Full */) { - reloadLevel = 1 /* Partial */; + if (updateLevel !== 2 /* Full */) { + updateLevel = 1 /* RootNamesAndUpdate */; scheduleProgramUpdate(); } }, @@ -126235,11 +126661,11 @@ ${lanes.join("\n")} return; projects.forEach((projectPath) => { if (configFileName && toPath3(configFileName) === projectPath) { - reloadLevel = 2 /* Full */; + updateLevel = 2 /* Full */; } else { const config = parsedConfigs == null ? void 0 : parsedConfigs.get(projectPath); if (config) - config.reloadLevel = 2 /* Full */; + config.updateLevel = 2 /* Full */; resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath); } scheduleProgramUpdate(); @@ -126260,7 +126686,7 @@ ${lanes.join("\n")} updateCachedSystemWithFile(configFileName2, configPath, eventKind); const config = parsedConfigs == null ? void 0 : parsedConfigs.get(configPath); if (config) - config.reloadLevel = 2 /* Full */; + config.updateLevel = 2 /* Full */; resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath); scheduleProgramUpdate(); }, @@ -126298,8 +126724,8 @@ ${lanes.join("\n")} toPath: toPath3 })) return; - if (config.reloadLevel !== 2 /* Full */) { - config.reloadLevel = 1 /* Partial */; + if (config.updateLevel !== 2 /* Full */) { + config.updateLevel = 1 /* RootNamesAndUpdate */; scheduleProgramUpdate(); } }, @@ -126773,12 +127199,12 @@ ${lanes.join("\n")} state.projectStatus.delete(resolved); state.diagnostics.delete(resolved); } - function addProjToQueue({ projectPendingBuild }, proj, reloadLevel) { + function addProjToQueue({ projectPendingBuild }, proj, updateLevel) { const value = projectPendingBuild.get(proj); if (value === void 0) { - projectPendingBuild.set(proj, reloadLevel); - } else if (value < reloadLevel) { - projectPendingBuild.set(proj, reloadLevel); + projectPendingBuild.set(proj, updateLevel); + } else if (value < updateLevel) { + projectPendingBuild.set(proj, updateLevel); } } function setupInitialBuild(state, cancellationToken) { @@ -126792,7 +127218,7 @@ ${lanes.join("\n")} buildOrder.forEach( (configFileName) => state.projectPendingBuild.set( toResolvedConfigFilePath(state, configFileName), - 0 /* None */ + 0 /* Update */ ) ); if (cancellationToken) { @@ -127228,8 +127654,8 @@ ${lanes.join("\n")} for (let projectIndex = 0; projectIndex < buildOrder.length; projectIndex++) { const project = buildOrder[projectIndex]; const projectPath = toResolvedConfigFilePath(state, project); - const reloadLevel = state.projectPendingBuild.get(projectPath); - if (reloadLevel === void 0) + const updateLevel = state.projectPendingBuild.get(projectPath); + if (updateLevel === void 0) continue; if (reportQueue) { reportQueue = false; @@ -127241,13 +127667,13 @@ ${lanes.join("\n")} projectPendingBuild.delete(projectPath); continue; } - if (reloadLevel === 2 /* Full */) { + if (updateLevel === 2 /* Full */) { watchConfigFile(state, project, projectPath, config); watchExtendedConfigFiles(state, projectPath, config); watchWildCardDirectories(state, project, projectPath, config); watchInputFiles(state, project, projectPath, config); watchPackageJsonFiles(state, project, projectPath, config); - } else if (reloadLevel === 1 /* Partial */) { + } else if (updateLevel === 1 /* RootNamesAndUpdate */) { config.fileNames = getFileNamesFromConfigSpecs(config.options.configFile.configFileSpecs, getDirectoryPath(project), config.options, state.parseConfigFileHost); updateErrorForNoInputFiles(config.fileNames, project, config.options.configFile.configFileSpecs, config.errors, canJsonReportNoInputFiles(config.raw)); watchInputFiles(state, project, projectPath, config); @@ -127834,7 +128260,7 @@ ${lanes.join("\n")} break; } } - addProjToQueue(state, nextProjectPath, 0 /* None */); + addProjToQueue(state, nextProjectPath, 0 /* Update */); break; } } @@ -127903,7 +128329,7 @@ ${lanes.join("\n")} filesToDelete.push(output); } else { host.deleteFile(output); - invalidateProject(state, resolvedPath, 0 /* None */); + invalidateProject(state, resolvedPath, 0 /* Update */); } } } @@ -127914,22 +128340,22 @@ ${lanes.join("\n")} } return 0 /* Success */; } - function invalidateProject(state, resolved, reloadLevel) { - if (state.host.getParsedCommandLine && reloadLevel === 1 /* Partial */) { - reloadLevel = 2 /* Full */; + function invalidateProject(state, resolved, updateLevel) { + if (state.host.getParsedCommandLine && updateLevel === 1 /* RootNamesAndUpdate */) { + updateLevel = 2 /* Full */; } - if (reloadLevel === 2 /* Full */) { + if (updateLevel === 2 /* Full */) { state.configFileCache.delete(resolved); state.buildOrder = void 0; } state.needsSummary = true; clearProjectStatus(state, resolved); - addProjToQueue(state, resolved, reloadLevel); + addProjToQueue(state, resolved, updateLevel); enableCache(state); } - function invalidateProjectAndScheduleBuilds(state, resolvedPath, reloadLevel) { + function invalidateProjectAndScheduleBuilds(state, resolvedPath, updateLevel) { state.reportFileChangeDetected = true; - invalidateProject(state, resolvedPath, reloadLevel); + invalidateProject(state, resolvedPath, updateLevel); scheduleBuildInvalidatedProject( state, 250, @@ -128060,7 +128486,7 @@ ${lanes.join("\n")} toPath: (fileName) => toPath2(state, fileName) })) return; - invalidateProjectAndScheduleBuilds(state, resolvedPath, 1 /* Partial */); + invalidateProjectAndScheduleBuilds(state, resolvedPath, 1 /* RootNamesAndUpdate */); }, flags, parsed == null ? void 0 : parsed.watchOptions, @@ -128079,7 +128505,7 @@ ${lanes.join("\n")} createNewValue: (_path, input) => watchFile( state, input, - () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* None */), + () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* Update */), 250 /* Low */, parsed == null ? void 0 : parsed.watchOptions, WatchType.SourceFile, @@ -128099,7 +128525,7 @@ ${lanes.join("\n")} createNewValue: (path, _input) => watchFile( state, path, - () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* None */), + () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* Update */), 2e3 /* High */, parsed == null ? void 0 : parsed.watchOptions, WatchType.PackageJson, @@ -128170,7 +128596,7 @@ ${lanes.join("\n")} const configFilePath = toResolvedConfigFilePath(state, configFileName); return getUpToDateStatus(state, parseConfigFile(state, configFileName, configFilePath), configFilePath); }, - invalidateProject: (configFilePath, reloadLevel) => invalidateProject(state, configFilePath, reloadLevel || 0 /* None */), + invalidateProject: (configFilePath, updateLevel) => invalidateProject(state, configFilePath, updateLevel || 0 /* Update */), close: () => stopWatching(state) }; } @@ -128463,6 +128889,66 @@ ${lanes.join("\n")} } }); + // src/jsTyping/shared.ts + function hasArgument(argumentName) { + return sys.args.includes(argumentName); + } + function findArgument(argumentName) { + const index = sys.args.indexOf(argumentName); + return index >= 0 && index < sys.args.length - 1 ? sys.args[index + 1] : void 0; + } + function nowString() { + const d = /* @__PURE__ */ new Date(); + return `${d.getHours().toString().padStart(2, "0")}:${d.getMinutes().toString().padStart(2, "0")}:${d.getSeconds().toString().padStart(2, "0")}.${d.getMilliseconds().toString().padStart(3, "0")}`; + } + function indent2(str) { + return indentStr + str.replace(/\n/g, indentStr); + } + function stringifyIndented(json) { + return indent2(JSON.stringify(json, void 0, 2)); + } + var ActionSet, ActionInvalidate, ActionPackageInstalled, EventTypesRegistry, EventBeginInstallTypes, EventEndInstallTypes, EventInitializationFailed, ActionWatchTypingLocations, Arguments, indentStr; + var init_shared = __esm({ + "src/jsTyping/shared.ts"() { + "use strict"; + init_ts3(); + ActionSet = "action::set"; + ActionInvalidate = "action::invalidate"; + ActionPackageInstalled = "action::packageInstalled"; + EventTypesRegistry = "event::typesRegistry"; + EventBeginInstallTypes = "event::beginInstallTypes"; + EventEndInstallTypes = "event::endInstallTypes"; + EventInitializationFailed = "event::initializationFailed"; + ActionWatchTypingLocations = "action::watchTypingLocations"; + ((Arguments2) => { + Arguments2.GlobalCacheLocation = "--globalTypingsCacheLocation"; + Arguments2.LogFile = "--logFile"; + Arguments2.EnableTelemetry = "--enableTelemetry"; + Arguments2.TypingSafeListLocation = "--typingSafeListLocation"; + Arguments2.TypesMapLocation = "--typesMapLocation"; + Arguments2.NpmLocation = "--npmLocation"; + Arguments2.ValidateDefaultNpmLocation = "--validateDefaultNpmLocation"; + })(Arguments || (Arguments = {})); + indentStr = "\n "; + } + }); + + // src/jsTyping/types.ts + var init_types2 = __esm({ + "src/jsTyping/types.ts"() { + "use strict"; + } + }); + + // src/jsTyping/_namespaces/ts.server.ts + var init_ts_server = __esm({ + "src/jsTyping/_namespaces/ts.server.ts"() { + "use strict"; + init_shared(); + init_types2(); + } + }); + // src/jsTyping/jsTyping.ts function isTypingUpToDate(cachedTyping, availableTypingVersions) { const availableVersion = new Version(getProperty(availableTypingVersions, `ts${versionMajorMinor}`) || getProperty(availableTypingVersions, "latest")); @@ -128517,21 +129003,21 @@ ${lanes.join("\n")} ); addInferredTypings(module2, "Inferred typings from unresolved imports"); } - packageNameToTypingLocation.forEach((typing, name) => { - const registryEntry = typesRegistry.get(name); - if (inferredTypings.has(name) && inferredTypings.get(name) === void 0 && registryEntry !== void 0 && isTypingUpToDate(typing, registryEntry)) { - inferredTypings.set(name, typing.typingLocation); - } - }); for (const excludeTypingName of exclude) { const didDelete = inferredTypings.delete(excludeTypingName); if (didDelete && log) log(`Typing for ${excludeTypingName} is in exclude list, will be ignored.`); } + packageNameToTypingLocation.forEach((typing, name) => { + const registryEntry = typesRegistry.get(name); + if (inferredTypings.get(name) === false && registryEntry !== void 0 && isTypingUpToDate(typing, registryEntry)) { + inferredTypings.set(name, typing.typingLocation); + } + }); const newTypingNames = []; const cachedTypingPaths = []; inferredTypings.forEach((inferred, typing) => { - if (inferred !== void 0) { + if (inferred) { cachedTypingPaths.push(inferred); } else { newTypingNames.push(typing); @@ -128539,11 +129025,11 @@ ${lanes.join("\n")} }); const result = { cachedTypingPaths, newTypingNames, filesToWatch }; if (log) - log(`Result: ${JSON.stringify(result)}`); + log(`Finished typings discovery:${stringifyIndented(result)}`); return result; function addInferredTyping(typingName) { if (!inferredTypings.has(typingName)) { - inferredTypings.set(typingName, void 0); + inferredTypings.set(typingName, false); } } function addInferredTypings(typingNames, message) { @@ -128710,6 +129196,7 @@ ${lanes.join("\n")} "src/jsTyping/jsTyping.ts"() { "use strict"; init_ts3(); + init_ts_server(); unprefixedNodeCoreModuleList = [ "assert", "assert/strict", @@ -128797,59 +129284,6 @@ ${lanes.join("\n")} } }); - // src/jsTyping/shared.ts - function hasArgument(argumentName) { - return sys.args.includes(argumentName); - } - function findArgument(argumentName) { - const index = sys.args.indexOf(argumentName); - return index >= 0 && index < sys.args.length - 1 ? sys.args[index + 1] : void 0; - } - function nowString() { - const d = /* @__PURE__ */ new Date(); - return `${d.getHours().toString().padStart(2, "0")}:${d.getMinutes().toString().padStart(2, "0")}:${d.getSeconds().toString().padStart(2, "0")}.${d.getMilliseconds().toString().padStart(3, "0")}`; - } - var ActionSet, ActionInvalidate, ActionPackageInstalled, EventTypesRegistry, EventBeginInstallTypes, EventEndInstallTypes, EventInitializationFailed, ActionWatchTypingLocations, Arguments; - var init_shared = __esm({ - "src/jsTyping/shared.ts"() { - "use strict"; - init_ts3(); - ActionSet = "action::set"; - ActionInvalidate = "action::invalidate"; - ActionPackageInstalled = "action::packageInstalled"; - EventTypesRegistry = "event::typesRegistry"; - EventBeginInstallTypes = "event::beginInstallTypes"; - EventEndInstallTypes = "event::endInstallTypes"; - EventInitializationFailed = "event::initializationFailed"; - ActionWatchTypingLocations = "action::watchTypingLocations"; - ((Arguments2) => { - Arguments2.GlobalCacheLocation = "--globalTypingsCacheLocation"; - Arguments2.LogFile = "--logFile"; - Arguments2.EnableTelemetry = "--enableTelemetry"; - Arguments2.TypingSafeListLocation = "--typingSafeListLocation"; - Arguments2.TypesMapLocation = "--typesMapLocation"; - Arguments2.NpmLocation = "--npmLocation"; - Arguments2.ValidateDefaultNpmLocation = "--validateDefaultNpmLocation"; - })(Arguments || (Arguments = {})); - } - }); - - // src/jsTyping/types.ts - var init_types2 = __esm({ - "src/jsTyping/types.ts"() { - "use strict"; - } - }); - - // src/jsTyping/_namespaces/ts.server.ts - var init_ts_server = __esm({ - "src/jsTyping/_namespaces/ts.server.ts"() { - "use strict"; - init_shared(); - init_types2(); - } - }); - // src/jsTyping/_namespaces/ts.ts var init_ts3 = __esm({ "src/jsTyping/_namespaces/ts.ts"() { @@ -129507,7 +129941,7 @@ ${lanes.join("\n")} case 306 /* EnumMember */: return "enum member" /* enumMemberElement */; case 169 /* Parameter */: - return hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + return hasSyntacticModifier(node, 31 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; case 271 /* ImportEqualsDeclaration */: case 276 /* ImportSpecifier */: case 281 /* ExportSpecifier */: @@ -130410,19 +130844,19 @@ ${lanes.join("\n")} function getNodeModifiers(node, excludeFlags = 0 /* None */) { const result = []; const flags = isDeclaration(node) ? getCombinedNodeFlagsAlwaysIncludeJSDoc(node) & ~excludeFlags : 0 /* None */; - if (flags & 8 /* Private */) + if (flags & 2 /* Private */) result.push("private" /* privateMemberModifier */); - if (flags & 16 /* Protected */) + if (flags & 4 /* Protected */) result.push("protected" /* protectedMemberModifier */); - if (flags & 4 /* Public */) + if (flags & 1 /* Public */) result.push("public" /* publicMemberModifier */); - if (flags & 32 /* Static */ || isClassStaticBlockDeclaration(node)) + if (flags & 256 /* Static */ || isClassStaticBlockDeclaration(node)) result.push("static" /* staticModifier */); - if (flags & 256 /* Abstract */) + if (flags & 64 /* Abstract */) result.push("abstract" /* abstractModifier */); - if (flags & 1 /* Export */) + if (flags & 32 /* Export */) result.push("export" /* exportedModifier */); - if (flags & 8192 /* Deprecated */) + if (flags & 65536 /* Deprecated */) result.push("deprecated" /* deprecatedModifier */); if (node.flags & 33554432 /* Ambient */) result.push("declare" /* ambientModifier */); @@ -131800,7 +132234,7 @@ ${lanes.join("\n")} return isInJSFile(declaration) || !findAncestor(declaration, (d) => isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); } function isDeprecatedDeclaration(decl) { - return !!(getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); + return !!(getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 65536 /* Deprecated */); } function shouldUseUriStyleNodeCoreModules(file, program) { const decisionFromFile = firstDefined(file.imports, (node) => { @@ -133484,7 +133918,7 @@ ${lanes.join("\n")} case 241 /* Block */: case 296 /* CaseClause */: case 297 /* DefaultClause */: - if (modifierFlag & 256 /* Abstract */ && isClassDeclaration(declaration)) { + if (modifierFlag & 64 /* Abstract */ && isClassDeclaration(declaration)) { return [...declaration.members, declaration]; } else { return container.statements; @@ -133498,12 +133932,12 @@ ${lanes.join("\n")} case 264 /* InterfaceDeclaration */: case 187 /* TypeLiteral */: const nodes = container.members; - if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { + if (modifierFlag & (7 /* AccessibilityModifier */ | 8 /* Readonly */)) { const constructor = find(container.members, isConstructorDeclaration); if (constructor) { return [...nodes, ...constructor.parameters]; } - } else if (modifierFlag & 256 /* Abstract */) { + } else if (modifierFlag & 64 /* Abstract */) { return [...nodes, container]; } return nodes; @@ -135997,7 +136431,7 @@ ${lanes.join("\n")} case 218 /* FunctionExpression */: case 263 /* ClassDeclaration */: case 231 /* ClassExpression */: - if (getSyntacticModifierFlags(node) & 1024 /* Default */) { + if (getSyntacticModifierFlags(node) & 2048 /* Default */) { return "default"; } return getFunctionOrClassName(node); @@ -136147,7 +136581,7 @@ ${lanes.join("\n")} return nodeText(parent2.left).replace(whiteSpaceRegex, ""); } else if (isPropertyAssignment(parent2)) { return nodeText(parent2.name); - } else if (getSyntacticModifierFlags(node) & 1024 /* Default */) { + } else if (getSyntacticModifierFlags(node) & 2048 /* Default */) { return "default"; } else if (isClassLike(node)) { return ""; @@ -136256,15 +136690,15 @@ ${lanes.join("\n")} const { file, program } = context; const span = getRefactorContextSpan(context); const token = getTokenAtPosition(file, span.start); - const exportNode = !!(token.parent && getSyntacticModifierFlags(token.parent) & 1 /* Export */) && considerPartialSpans ? token.parent : getParentNodeInSpan(token, file, span); + const exportNode = !!(token.parent && getSyntacticModifierFlags(token.parent) & 32 /* Export */) && considerPartialSpans ? token.parent : getParentNodeInSpan(token, file, span); if (!exportNode || !isSourceFile(exportNode.parent) && !(isModuleBlock(exportNode.parent) && isAmbientModule(exportNode.parent.parent))) { return { error: getLocaleSpecificMessage(Diagnostics.Could_not_find_export_statement) }; } const checker = program.getTypeChecker(); const exportingModuleSymbol = getExportingModuleSymbol(exportNode.parent, checker); - const flags = getSyntacticModifierFlags(exportNode) || (isExportAssignment(exportNode) && !exportNode.isExportEquals ? 1025 /* ExportDefault */ : 0 /* None */); - const wasDefault = !!(flags & 1024 /* Default */); - if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { + const flags = getSyntacticModifierFlags(exportNode) || (isExportAssignment(exportNode) && !exportNode.isExportEquals ? 2080 /* ExportDefault */ : 0 /* None */); + const wasDefault = !!(flags & 2048 /* Default */); + if (!(flags & 32 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { return { error: getLocaleSpecificMessage(Diagnostics.This_file_already_has_a_default_export) }; } const noSymbolError = (id) => isIdentifier(id) && checker.getSymbolAtLocation(id) ? void 0 : { error: getLocaleSpecificMessage(Diagnostics.Can_only_convert_named_export) }; @@ -136746,26 +137180,50 @@ ${lanes.join("\n")} const current = getTokenAtPosition(file, startPosition); const range = createTextRangeFromSpan(getRefactorContextSpan(context)); const cursorRequest = range.pos === range.end && considerEmptySpans; - const selection = findAncestor(current, (node) => node.parent && isTypeNode(node) && !rangeContainsSkipTrivia(range, node.parent, file) && (cursorRequest || nodeOverlapsWithStartEnd(current, file, range.pos, range.end))); - if (!selection || !isTypeNode(selection)) + const overlappingRange = nodeOverlapsWithStartEnd(current, file, range.pos, range.end); + const firstType = findAncestor(current, (node) => node.parent && isTypeNode(node) && !rangeContainsSkipTrivia(range, node.parent, file) && (cursorRequest || overlappingRange)); + if (!firstType || !isTypeNode(firstType)) return { error: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_type_node) }; const checker = context.program.getTypeChecker(); - const enclosingNode = getEnclosingNode(selection, isJS); + const enclosingNode = getEnclosingNode(firstType, isJS); if (enclosingNode === void 0) return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) }; + const expandedFirstType = getExpandedSelectionNode(firstType, enclosingNode); + if (!isTypeNode(expandedFirstType)) + return { error: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_type_node) }; + const typeList = []; + if ((isUnionTypeNode(expandedFirstType.parent) || isIntersectionTypeNode(expandedFirstType.parent)) && range.end > firstType.end) { + addRange( + typeList, + expandedFirstType.parent.types.filter((type) => { + return nodeOverlapsWithStartEnd(type, file, range.pos, range.end); + }) + ); + } + const selection = typeList.length > 1 ? typeList : expandedFirstType; const typeParameters = collectTypeParameters(checker, selection, enclosingNode, file); if (!typeParameters) return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) }; const typeElements = flattenTypeLiteralNodeReference(checker, selection); return { isJS, selection, enclosingNode, typeParameters, typeElements }; } - function flattenTypeLiteralNodeReference(checker, node) { - if (!node) + function flattenTypeLiteralNodeReference(checker, selection) { + if (!selection) return void 0; - if (isIntersectionTypeNode(node)) { + if (isArray(selection)) { + const result = []; + for (const type of selection) { + const flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type); + if (!flattenedTypeMembers) + return void 0; + addRange(result, flattenedTypeMembers); + } + return result; + } + if (isIntersectionTypeNode(selection)) { const result = []; const seen = /* @__PURE__ */ new Map(); - for (const type of node.types) { + for (const type of selection.types) { const flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type); if (!flattenedTypeMembers || !flattenedTypeMembers.every((type2) => type2.name && addToSeen(seen, getNameFromPropertyName(type2.name)))) { return void 0; @@ -136773,10 +137231,10 @@ ${lanes.join("\n")} addRange(result, flattenedTypeMembers); } return result; - } else if (isParenthesizedTypeNode(node)) { - return flattenTypeLiteralNodeReference(checker, node.type); - } else if (isTypeLiteralNode(node)) { - return node.members; + } else if (isParenthesizedTypeNode(selection)) { + return flattenTypeLiteralNodeReference(checker, selection.type); + } else if (isTypeLiteralNode(selection)) { + return selection.members; } return void 0; } @@ -136785,7 +137243,13 @@ ${lanes.join("\n")} } function collectTypeParameters(checker, selection, enclosingNode, file) { const result = []; - return visitor(selection) ? void 0 : result; + const selectionArray = toArray(selection); + const selectionRange = { pos: selectionArray[0].pos, end: selectionArray[selectionArray.length - 1].end }; + for (const t of selectionArray) { + if (visitor(t)) + return void 0; + } + return result; function visitor(node) { if (isTypeReferenceNode(node)) { if (isIdentifier(node.typeName)) { @@ -136799,10 +137263,10 @@ ${lanes.join("\n")} ); for (const decl of (symbol == null ? void 0 : symbol.declarations) || emptyArray) { if (isTypeParameterDeclaration(decl) && decl.getSourceFile() === file) { - if (decl.name.escapedText === typeName.escapedText && rangeContainsSkipTrivia(decl, selection, file)) { + if (decl.name.escapedText === typeName.escapedText && rangeContainsSkipTrivia(decl, selectionRange, file)) { return true; } - if (rangeContainsSkipTrivia(enclosingNode, decl, file) && !rangeContainsSkipTrivia(selection, decl, file)) { + if (rangeContainsSkipTrivia(enclosingNode, decl, file) && !rangeContainsSkipTrivia(selectionRange, decl, file)) { pushIfUnique(result, decl); break; } @@ -136811,12 +137275,12 @@ ${lanes.join("\n")} } } else if (isInferTypeNode(node)) { const conditionalTypeNode = findAncestor(node, (n) => isConditionalTypeNode(n) && rangeContainsSkipTrivia(n.extendsType, node, file)); - if (!conditionalTypeNode || !rangeContainsSkipTrivia(selection, conditionalTypeNode, file)) { + if (!conditionalTypeNode || !rangeContainsSkipTrivia(selectionRange, conditionalTypeNode, file)) { return true; } } else if (isTypePredicateNode(node) || isThisTypeNode(node)) { const functionLikeNode = findAncestor(node.parent, isFunctionLike); - if (functionLikeNode && functionLikeNode.type && rangeContainsSkipTrivia(functionLikeNode.type, node, file) && !rangeContainsSkipTrivia(selection, functionLikeNode, file)) { + if (functionLikeNode && functionLikeNode.type && rangeContainsSkipTrivia(functionLikeNode.type, node, file) && !rangeContainsSkipTrivia(selectionRange, functionLikeNode, file)) { return true; } } else if (isTypeQueryNode(node)) { @@ -136828,11 +137292,11 @@ ${lanes.join("\n")} /*excludeGlobals*/ false ); - if ((symbol == null ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(enclosingNode, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { + if ((symbol == null ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(enclosingNode, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selectionRange, symbol.valueDeclaration, file)) { return true; } } else { - if (isThisIdentifier(node.exprName.left) && !rangeContainsSkipTrivia(selection, node.parent, file)) { + if (isThisIdentifier(node.exprName.left) && !rangeContainsSkipTrivia(selectionRange, node.parent, file)) { return true; } } @@ -136844,8 +137308,9 @@ ${lanes.join("\n")} } } function doTypeAliasChange(changes, file, name, info) { - const { enclosingNode, selection, typeParameters } = info; - const newTypeNode = factory.createTypeAliasDeclaration( + const { enclosingNode, typeParameters } = info; + const { firstTypeNode, lastTypeNode, newTypeNode } = getNodesToEdit(info); + const newTypeDeclaration = factory.createTypeAliasDeclaration( /*modifiers*/ void 0, name, @@ -136857,16 +137322,16 @@ ${lanes.join("\n")} /*defaultType*/ void 0 )), - selection + newTypeNode ); changes.insertNodeBefore( file, enclosingNode, - ignoreSourceNewlines(newTypeNode), + ignoreSourceNewlines(newTypeDeclaration), /*blankLineBetween*/ true ); - changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode( + changes.replaceNodeRange(file, firstTypeNode, lastTypeNode, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode( id.name, /*typeArguments*/ void 0 @@ -136874,7 +137339,7 @@ ${lanes.join("\n")} } function doInterfaceChange(changes, file, name, info) { var _a; - const { enclosingNode, selection, typeParameters, typeElements } = info; + const { enclosingNode, typeParameters, typeElements } = info; const newTypeNode = factory.createInterfaceDeclaration( /*modifiers*/ void 0, @@ -136892,7 +137357,8 @@ ${lanes.join("\n")} /*blankLineBetween*/ true ); - changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode( + const { firstTypeNode, lastTypeNode } = getNodesToEdit(info); + changes.replaceNodeRange(file, firstTypeNode, lastTypeNode, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode( id.name, /*typeArguments*/ void 0 @@ -136900,11 +137366,14 @@ ${lanes.join("\n")} } function doTypedefChange(changes, context, file, name, info) { var _a; - const { enclosingNode, selection, typeParameters } = info; - setEmitFlags(selection, 3072 /* NoComments */ | 4096 /* NoNestedComments */); + toArray(info.selection).forEach((typeNode) => { + setEmitFlags(typeNode, 3072 /* NoComments */ | 4096 /* NoNestedComments */); + }); + const { enclosingNode, typeParameters } = info; + const { firstTypeNode, lastTypeNode, newTypeNode } = getNodesToEdit(info); const node = factory.createJSDocTypedefTag( factory.createIdentifier("typedef"), - factory.createJSDocTypeExpression(selection), + factory.createJSDocTypeExpression(newTypeNode), factory.createIdentifier(name) ); const templates = []; @@ -136942,15 +137411,39 @@ ${lanes.join("\n")} true ); } - changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode( + changes.replaceNodeRange(file, firstTypeNode, lastTypeNode, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode( id.name, /*typeArguments*/ void 0 )))); } + function getNodesToEdit(info) { + if (isArray(info.selection)) { + return { + firstTypeNode: info.selection[0], + lastTypeNode: info.selection[info.selection.length - 1], + newTypeNode: isUnionTypeNode(info.selection[0].parent) ? factory.createUnionTypeNode(info.selection) : factory.createIntersectionTypeNode(info.selection) + }; + } + return { + firstTypeNode: info.selection, + lastTypeNode: info.selection, + newTypeNode: info.selection + }; + } function getEnclosingNode(node, isJS) { return findAncestor(node, isStatement) || (isJS ? findAncestor(node, isJSDoc) : void 0); } + function getExpandedSelectionNode(firstType, enclosingNode) { + return findAncestor(firstType, (node) => { + if (node === enclosingNode) + return "quit"; + if (isUnionTypeNode(node.parent) || isIntersectionTypeNode(node.parent)) { + return true; + } + return false; + }) ?? firstType; + } var refactorName3, extractToTypeAliasAction, extractToInterfaceAction, extractToTypeDefAction; var init_extractType = __esm({ "src/services/refactors/extractType.ts"() { @@ -137275,7 +137768,7 @@ ${lanes.join("\n")} if (markSeenTop(top)) { addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax); } - if (hasSyntacticModifier(decl, 1024 /* Default */)) { + if (hasSyntacticModifier(decl, 2048 /* Default */)) { oldFileDefault = name; } else { oldFileNamedImports.push(name.text); @@ -137326,14 +137819,13 @@ ${lanes.join("\n")} } function doChange4(context, oldFile, targetFile, program, toMove, changes, host, preferences) { const checker = program.getTypeChecker(); - const usage = getUsageInfo(oldFile, toMove.all, checker); if (!host.fileExists(targetFile)) { - changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences)); + changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, getUsageInfo(oldFile, toMove.all, checker), changes, toMove, program, host, preferences)); addNewFileToTsconfig(program, changes, oldFile.fileName, targetFile, hostGetCanonicalFileName(host)); } else { const targetSourceFile = Debug.checkDefined(program.getSourceFile(targetFile)); const importAdder = ts_codefix_exports.createImportAdder(targetSourceFile, context.program, context.preferences, context.host); - getNewStatementsAndRemoveFromOldFile2(oldFile, targetSourceFile, usage, changes, toMove, program, host, preferences, importAdder); + getNewStatementsAndRemoveFromOldFile2(oldFile, targetSourceFile, getUsageInfo(oldFile, toMove.all, checker, getExistingImports(targetSourceFile, checker)), changes, toMove, program, host, preferences, importAdder); } } function getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences, importAdder) { @@ -137453,7 +137945,7 @@ ${lanes.join("\n")} if (importAdder && checker.isUnknownSymbol(symbol)) { importAdder.addImportFromExportedSymbol(skipAlias(symbol, checker)); } else { - if (hasSyntacticModifier(decl, 1024 /* Default */)) { + if (hasSyntacticModifier(decl, 2048 /* Default */)) { oldFileDefault = name; } else { oldFileNamedImports.push(name.text); @@ -137693,7 +138185,7 @@ ${lanes.join("\n")} function isExported(sourceFile, decl, useEs6Exports, name) { var _a; if (useEs6Exports) { - return !isExpressionStatement(decl) && hasSyntacticModifier(decl, 1 /* Export */) || !!(name && sourceFile.symbol && ((_a = sourceFile.symbol.exports) == null ? void 0 : _a.has(name.escapedText))); + return !isExpressionStatement(decl) && hasSyntacticModifier(decl, 32 /* Export */) || !!(name && sourceFile.symbol && ((_a = sourceFile.symbol.exports) == null ? void 0 : _a.has(name.escapedText))); } return !!sourceFile.symbol && !!sourceFile.symbol.exports && getNamesToExportInCommonJS(decl).some((name2) => sourceFile.symbol.exports.has(escapeLeadingUnderscores(name2))); } @@ -137988,7 +138480,7 @@ ${lanes.join("\n")} case 272 /* ImportDeclaration */: return true; case 271 /* ImportEqualsDeclaration */: - return !hasSyntacticModifier(node, 1 /* Export */); + return !hasSyntacticModifier(node, 32 /* Export */); case 243 /* VariableStatement */: return node.declarationList.declarations.every((d) => !!d.initializer && isRequireCall( d.initializer, @@ -137999,7 +138491,7 @@ ${lanes.join("\n")} return false; } } - function getUsageInfo(oldFile, toMove, checker) { + function getUsageInfo(oldFile, toMove, checker, existingTargetImports = /* @__PURE__ */ new Set()) { const movedSymbols = /* @__PURE__ */ new Set(); const oldImportsNeededByTargetFile = /* @__PURE__ */ new Map(); const targetFileImportsFromOldFile = /* @__PURE__ */ new Set(); @@ -138013,10 +138505,16 @@ ${lanes.join("\n")} movedSymbols.add(Debug.checkDefined(isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here")); }); } + const unusedImportsFromOldFile = /* @__PURE__ */ new Set(); for (const statement of toMove) { forEachReference(statement, checker, (symbol, isValidTypeOnlyUseSite) => { - if (!symbol.declarations) + if (!symbol.declarations) { + return; + } + if (existingTargetImports.has(skipAlias(symbol, checker))) { + unusedImportsFromOldFile.add(symbol); return; + } for (const decl of symbol.declarations) { if (isInImport(decl)) { const prevIsTypeOnly = oldImportsNeededByTargetFile.get(symbol); @@ -138027,7 +138525,9 @@ ${lanes.join("\n")} } }); } - const unusedImportsFromOldFile = new Set(oldImportsNeededByTargetFile.keys()); + for (const unusedImport of oldImportsNeededByTargetFile.keys()) { + unusedImportsFromOldFile.add(unusedImport); + } const oldFileImportsFromTargetFile = /* @__PURE__ */ new Set(); for (const statement of oldFile.statements) { if (contains(toMove, statement)) @@ -138159,7 +138659,7 @@ ${lanes.join("\n")} const checker = program.getTypeChecker(); const targetToSourceExports = /* @__PURE__ */ new Map(); for (const node of toMove.all) { - if (isTopLevelDeclarationStatement(node) && hasSyntacticModifier(node, 1 /* Export */)) { + if (isTopLevelDeclarationStatement(node) && hasSyntacticModifier(node, 32 /* Export */)) { forEachTopLevelDeclaration(node, (declaration) => { var _a2; const targetDeclarations = canHaveSymbol(declaration) ? (_a2 = targetExports.get(declaration.symbol.escapedName)) == null ? void 0 : _a2.declarations : void 0; @@ -138213,6 +138713,29 @@ ${lanes.join("\n")} } return void 0; } + function getExistingImports(sourceFile, checker) { + const imports = /* @__PURE__ */ new Set(); + for (const moduleSpecifier of sourceFile.imports) { + const declaration = importFromModuleSpecifier(moduleSpecifier); + if (isImportDeclaration(declaration) && declaration.importClause && declaration.importClause.namedBindings && isNamedImports(declaration.importClause.namedBindings)) { + for (const e of declaration.importClause.namedBindings.elements) { + const symbol = checker.getSymbolAtLocation(e.propertyName || e.name); + if (symbol) { + imports.add(skipAlias(symbol, checker)); + } + } + } + if (isVariableDeclarationInitializedToRequire(declaration.parent) && isObjectBindingPattern(declaration.parent.name)) { + for (const e of declaration.parent.name.elements) { + const symbol = checker.getSymbolAtLocation(e.propertyName || e.name); + if (symbol) { + imports.add(skipAlias(symbol, checker)); + } + } + } + } + return imports; + } var refactorNameForMoveToFile, description2, moveToFileAction; var init_moveToFile = __esm({ "src/services/refactors/moveToFile.ts"() { @@ -138796,7 +139319,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} const body = convertToBlock(func.body); const { variableDeclaration, variableDeclarationList, statement, name } = variableInfo; suppressLeadingTrivia(statement); - const modifiersFlags = getCombinedModifierFlags(variableDeclaration) & 1 /* Export */ | getEffectiveModifierFlags(func); + const modifiersFlags = getCombinedModifierFlags(variableDeclaration) & 32 /* Export */ | getEffectiveModifierFlags(func); const modifiers = factory.createModifiersFromModifierFlags(modifiersFlags); const newNode = factory.createFunctionDeclaration(length(modifiers) ? modifiers : void 0, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); if (variableDeclarationList.declarations.length === 1) { @@ -140170,7 +140693,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} } if (isDeclaration(node2)) { const declaringNode = node2.kind === 260 /* VariableDeclaration */ ? node2.parent.parent : node2; - if (hasSyntacticModifier(declaringNode, 1 /* Export */)) { + if (hasSyntacticModifier(declaringNode, 32 /* Export */)) { (errors2 || (errors2 = [])).push(createDiagnosticForNode(node2, Messages.cannotExtractExportedEntity)); return true; } @@ -141178,7 +141701,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} usagesPerScope[i].usages.forEach((value) => { if (value.usage === 2 /* Write */) { hasWrite = true; - if (value.symbol.flags & 106500 /* ClassMember */ && value.symbol.valueDeclaration && hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* Readonly */)) { + if (value.symbol.flags & 106500 /* ClassMember */ && value.symbol.valueDeclaration && hasEffectiveModifier(value.symbol.valueDeclaration, 8 /* Readonly */)) { readonlyClassPropertyWrite = value.symbol.valueDeclaration; } } @@ -141597,7 +142120,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} function getInfo4(context) { if (isInJSFile(context.file) || !refactorKindBeginsWith(inferReturnTypeAction.kind, context.kind)) return; - const token = getTokenAtPosition(context.file, context.startPosition); + const token = getTouchingPropertyName(context.file, context.startPosition); const declaration = findAncestor(token, (n) => isBlock(n) || n.parent && isArrowFunction(n.parent) && (n.kind === 39 /* EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : isConvertibleDeclaration(n)); if (!declaration || !declaration.body || declaration.type) { return { error: getLocaleSpecificMessage(Diagnostics.Return_type_must_be_inferred_from_a_function) }; @@ -141800,14 +142323,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} if (decl) { const modifiers = getCombinedModifierFlags(decl); const nodeFlags = getCombinedNodeFlags(decl); - if (modifiers & 32 /* Static */) { + if (modifiers & 256 /* Static */) { modifierSet |= 1 << 1 /* static */; } - if (modifiers & 512 /* Async */) { + if (modifiers & 1024 /* Async */) { modifierSet |= 1 << 2 /* async */; } if (typeIdx !== 0 /* class */ && typeIdx !== 2 /* interface */) { - if (modifiers & 64 /* Readonly */ || nodeFlags & 2 /* Const */ || symbol.getFlags() & 8 /* EnumMember */) { + if (modifiers & 8 /* Readonly */ || nodeFlags & 2 /* Const */ || symbol.getFlags() & 8 /* EnumMember */) { modifierSet |= 1 << 3 /* readonly */; } } @@ -143939,7 +144462,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} forEachChild(node, visit); break; case 169 /* Parameter */: - if (!hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (!hasSyntacticModifier(node, 31 /* ParameterPropertyModifier */)) { break; } case 260 /* VariableDeclaration */: @@ -144426,7 +144949,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} if (isBindingPattern(variableDeclaration.name)) { return spanInBindingPattern(variableDeclaration.name); } - if (hasOnlyExpressionInitializer(variableDeclaration) && variableDeclaration.initializer || hasSyntacticModifier(variableDeclaration, 1 /* Export */) || parent2.parent.kind === 250 /* ForOfStatement */) { + if (hasOnlyExpressionInitializer(variableDeclaration) && variableDeclaration.initializer || hasSyntacticModifier(variableDeclaration, 32 /* Export */) || parent2.parent.kind === 250 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (isVariableDeclarationList(variableDeclaration.parent) && variableDeclaration.parent.declarations[0] !== variableDeclaration) { @@ -144434,7 +144957,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} } } function canHaveSpanInParameterDeclaration(parameter) { - return !!parameter.initializer || parameter.dotDotDotToken !== void 0 || hasSyntacticModifier(parameter, 4 /* Public */ | 8 /* Private */); + return !!parameter.initializer || parameter.dotDotDotToken !== void 0 || hasSyntacticModifier(parameter, 1 /* Public */ | 2 /* Private */); } function spanInParameterDeclaration(parameter) { if (isBindingPattern(parameter.name)) { @@ -144453,7 +144976,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return hasSyntacticModifier(functionDeclaration, 1 /* Export */) || functionDeclaration.parent.kind === 263 /* ClassDeclaration */ && functionDeclaration.kind !== 176 /* Constructor */; + return hasSyntacticModifier(functionDeclaration, 32 /* Export */) || functionDeclaration.parent.kind === 263 /* ClassDeclaration */ && functionDeclaration.kind !== 176 /* Constructor */; } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -145024,7 +145547,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} forEach(node.statements, collect); } function collectCallSitesOfModuleDeclaration(node, collect) { - if (!hasSyntacticModifier(node, 2 /* Ambient */) && node.body && isModuleBlock(node.body)) { + if (!hasSyntacticModifier(node, 128 /* Ambient */) && node.body && isModuleBlock(node.body)) { forEach(node.body.statements, collect); } } @@ -145325,13 +145848,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} } } fixedDeclarations == null ? void 0 : fixedDeclarations.add(getNodeId(insertionSite)); - const cloneWithModifier = factory.updateModifiers( + const cloneWithModifier = factory.replaceModifiers( getSynthesizedDeepClone( insertionSite, /*includeTrivia*/ true ), - factory.createNodeArray(factory.createModifiersFromModifierFlags(getSyntacticModifierFlags(insertionSite) | 512 /* Async */)) + factory.createNodeArray(factory.createModifiersFromModifierFlags(getSyntacticModifierFlags(insertionSite) | 1024 /* Async */)) ); changeTracker.replaceNode( sourceFile, @@ -145443,7 +145966,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} const declaration = tryCast(symbol.valueDeclaration, isVariableDeclaration); const variableName = declaration && tryCast(declaration.name, isIdentifier); const variableStatement = getAncestor(declaration, 243 /* VariableStatement */); - if (!declaration || !variableStatement || declaration.type || !declaration.initializer || variableStatement.getSourceFile() !== sourceFile || hasSyntacticModifier(variableStatement, 1 /* Export */) || !variableName || !isInsideAwaitableBody(declaration.initializer)) { + if (!declaration || !variableStatement || declaration.type || !declaration.initializer || variableStatement.getSourceFile() !== sourceFile || hasSyntacticModifier(variableStatement, 32 /* Export */) || !variableName || !isInsideAwaitableBody(declaration.initializer)) { isCompleteFix = false; continue; } @@ -148233,7 +148756,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} return Debug.checkDefined(getContainingClass(getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { - return !symbol.valueDeclaration || !(getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* Private */); + return !symbol.valueDeclaration || !(getEffectiveModifierFlags(symbol.valueDeclaration) & 2 /* Private */); } function addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, changeTracker, preferences) { const checker = context.program.getTypeChecker(); @@ -148504,7 +149027,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} defaultImport, namedImports && arrayFrom(namedImports.entries(), ([name, addAsTypeOnly]) => ({ addAsTypeOnly, name })), namespaceLikeImport, - compilerOptions + compilerOptions, + preferences ); newDeclarations = combine(newDeclarations, declarations); }); @@ -148811,7 +149335,18 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} const getChecker = createGetChecker(program, host); const moduleResolution = getEmitModuleResolutionKind(compilerOptions); const rejectNodeModulesRelativePaths = moduleResolutionUsesNodeModules(moduleResolution); - const getModuleSpecifiers2 = fromCacheOnly ? (moduleSymbol) => ({ moduleSpecifiers: ts_moduleSpecifiers_exports.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }) : (moduleSymbol, checker) => ts_moduleSpecifiers_exports.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); + const getModuleSpecifiers2 = fromCacheOnly ? (moduleSymbol) => ({ moduleSpecifiers: ts_moduleSpecifiers_exports.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }) : (moduleSymbol, checker) => ts_moduleSpecifiers_exports.getModuleSpecifiersWithCacheInfo( + moduleSymbol, + checker, + compilerOptions, + sourceFile, + moduleSpecifierResolutionHost, + preferences, + /*options*/ + void 0, + /*forAutoImport*/ + true + ); let computedWithoutCacheCount = 0; const fixes = flatMap(exportInfo, (exportInfo2, i) => { const checker = getChecker(exportInfo2.isFromPackageJson); @@ -149198,7 +149733,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} defaultImport, namedImports, namespaceLikeImport, - program.getCompilerOptions() + program.getCompilerOptions(), + preferences ), /*blankLineBetween*/ true, @@ -149330,7 +149866,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} const newSpecifiers = stableSort( namedImports.map( (namedImport) => factory.createImportSpecifier( - (!clause.isTypeOnly || promoteFromTypeOnly2) && needsTypeOnly(namedImport), + (!clause.isTypeOnly || promoteFromTypeOnly2) && shouldUseTypeOnly(namedImport, preferences), /*propertyName*/ void 0, factory.createIdentifier(namedImport.name) @@ -149394,21 +149930,24 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} function needsTypeOnly({ addAsTypeOnly }) { return addAsTypeOnly === 2 /* Required */; } - function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport, compilerOptions) { + function shouldUseTypeOnly(info, preferences) { + return needsTypeOnly(info) || !!preferences.preferTypeOnlyAutoImports && info.addAsTypeOnly !== 4 /* NotAllowed */; + } + function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport, compilerOptions, preferences) { const quotedModuleSpecifier = makeStringLiteral(moduleSpecifier, quotePreference); let statements; if (defaultImport !== void 0 || (namedImports == null ? void 0 : namedImports.length)) { - const topLevelTypeOnly = (!defaultImport || needsTypeOnly(defaultImport)) && every(namedImports, needsTypeOnly) || compilerOptions.verbatimModuleSyntax && (defaultImport == null ? void 0 : defaultImport.addAsTypeOnly) !== 4 /* NotAllowed */ && !some(namedImports, (i) => i.addAsTypeOnly === 4 /* NotAllowed */); + const topLevelTypeOnly = (!defaultImport || needsTypeOnly(defaultImport)) && every(namedImports, needsTypeOnly) || (compilerOptions.verbatimModuleSyntax || preferences.preferTypeOnlyAutoImports) && (defaultImport == null ? void 0 : defaultImport.addAsTypeOnly) !== 4 /* NotAllowed */ && !some(namedImports, (i) => i.addAsTypeOnly === 4 /* NotAllowed */); statements = combine( statements, makeImport( defaultImport && factory.createIdentifier(defaultImport.name), namedImports == null ? void 0 : namedImports.map( - ({ addAsTypeOnly, name }) => factory.createImportSpecifier( - !topLevelTypeOnly && addAsTypeOnly === 2 /* Required */, + (namedImport) => factory.createImportSpecifier( + !topLevelTypeOnly && shouldUseTypeOnly(namedImport, preferences), /*propertyName*/ void 0, - factory.createIdentifier(name) + factory.createIdentifier(namedImport.name) ) ), moduleSpecifier, @@ -149421,14 +149960,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} const declaration = namespaceLikeImport.importKind === 3 /* CommonJS */ ? factory.createImportEqualsDeclaration( /*modifiers*/ void 0, - needsTypeOnly(namespaceLikeImport), + shouldUseTypeOnly(namespaceLikeImport, preferences), factory.createIdentifier(namespaceLikeImport.name), factory.createExternalModuleReference(quotedModuleSpecifier) ) : factory.createImportDeclaration( /*modifiers*/ void 0, factory.createImportClause( - needsTypeOnly(namespaceLikeImport), + shouldUseTypeOnly(namespaceLikeImport, preferences), /*name*/ void 0, factory.createNamespaceImport(factory.createIdentifier(namespaceLikeImport.name)) @@ -150245,7 +150784,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} const tag = findAncestor(node, isJsxOpeningLikeElement); const props = checker.getContextualTypeForArgumentAtIndex(tag, 0); suggestedSymbol = checker.getSuggestedSymbolForNonexistentJSXAttribute(node, props); - } else if (hasSyntacticModifier(parent2, 16384 /* Override */) && isClassElement(parent2) && parent2.name === node) { + } else if (hasOverrideModifier(parent2) && isClassElement(parent2) && parent2.name === node) { const baseDeclaration = findAncestor(node, isClassLike); const baseTypeNode = baseDeclaration ? getEffectiveBaseTypeNode(baseDeclaration) : void 0; const baseType = baseTypeNode ? checker.getTypeAtLocation(baseTypeNode) : void 0; @@ -150407,7 +150946,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} if (isFunctionType) { const sig = checker.getSignatureFromDeclaration(declaration); if (sig) { - if (hasSyntacticModifier(declaration, 512 /* Async */)) { + if (hasSyntacticModifier(declaration, 1024 /* Async */)) { exprType = checker.createPromiseType(exprType); } const newSig = checker.createSignature( @@ -150679,13 +151218,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} const moduleDeclaration = find(symbol.declarations, isModuleDeclaration); const moduleDeclarationSourceFile = moduleDeclaration == null ? void 0 : moduleDeclaration.getSourceFile(); if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) { - return { kind: 2 /* Function */, token, call: parent2.parent, sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration }; + return { kind: 2 /* Function */, token, call: parent2.parent, sourceFile, modifierFlags: 32 /* Export */, parentDeclaration: moduleDeclaration }; } const moduleSourceFile = find(symbol.declarations, isSourceFile); if (sourceFile.commonJsModuleIndicator) return void 0; if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) { - return { kind: 2 /* Function */, token, call: parent2.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile }; + return { kind: 2 /* Function */, token, call: parent2.parent, sourceFile: moduleSourceFile, modifierFlags: 32 /* Export */, parentDeclaration: moduleSourceFile }; } } const classDeclaration = find(symbol.declarations, isClassLike); @@ -150697,7 +151236,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} if (makeStatic && (isPrivateIdentifier(token) || isInterfaceDeclaration(declaration))) return void 0; const declSourceFile = declaration.getSourceFile(); - const modifierFlags = isTypeLiteralNode(declaration) ? 0 /* None */ : (makeStatic ? 32 /* Static */ : 0 /* None */) | (startsWithUnderscore(token.text) ? 8 /* Private */ : 0 /* None */); + const modifierFlags = isTypeLiteralNode(declaration) ? 0 /* None */ : (makeStatic ? 256 /* Static */ : 0 /* None */) | (startsWithUnderscore(token.text) ? 2 /* Private */ : 0 /* None */); const isJSFile = isSourceFileJS(declSourceFile); const call = tryCast(parent2.parent, isCallExpression); return { kind: 0 /* TypeLikeDeclaration */, token, call, modifierFlags, parentDeclaration: declaration, declSourceFile, isJSFile }; @@ -150715,11 +151254,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} if (isInterfaceDeclaration(parentDeclaration) || isTypeLiteralNode(parentDeclaration)) { return void 0; } - const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */))); + const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 256 /* Static */))); if (changes.length === 0) { return void 0; } - const diagnostic = modifierFlags & 32 /* Static */ ? Diagnostics.Initialize_static_property_0 : isPrivateIdentifier(token) ? Diagnostics.Declare_a_private_field_named_0 : Diagnostics.Initialize_property_0_in_the_constructor; + const diagnostic = modifierFlags & 256 /* Static */ ? Diagnostics.Initialize_static_property_0 : isPrivateIdentifier(token) ? Diagnostics.Declare_a_private_field_named_0 : Diagnostics.Initialize_property_0_in_the_constructor; return createCodeFixAction(fixMissingMember, changes, [diagnostic, token.text], fixMissingMember, Diagnostics.Add_all_missing_members); } function addMissingMemberInJs(changeTracker, sourceFile, classDeclaration, token, makeStatic) { @@ -150763,15 +151302,15 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} } function createActionsForAddMissingMemberInTypeScriptFile(context, { parentDeclaration, declSourceFile, modifierFlags, token }) { const memberName = token.text; - const isStatic2 = modifierFlags & 32 /* Static */; + const isStatic2 = modifierFlags & 256 /* Static */; const typeNode = getTypeNode2(context.program.getTypeChecker(), parentDeclaration, token); const addPropertyDeclarationChanges = (modifierFlags2) => ts_textChanges_exports.ChangeTracker.with(context, (t) => addPropertyDeclaration(t, declSourceFile, parentDeclaration, memberName, typeNode, modifierFlags2)); - const actions2 = [createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* Static */), [isStatic2 ? Diagnostics.Declare_static_property_0 : Diagnostics.Declare_property_0, memberName], fixMissingMember, Diagnostics.Add_all_missing_members)]; + const actions2 = [createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 256 /* Static */), [isStatic2 ? Diagnostics.Declare_static_property_0 : Diagnostics.Declare_property_0, memberName], fixMissingMember, Diagnostics.Add_all_missing_members)]; if (isStatic2 || isPrivateIdentifier(token)) { return actions2; } - if (modifierFlags & 8 /* Private */) { - actions2.unshift(createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* Private */), [Diagnostics.Declare_private_property_0, memberName])); + if (modifierFlags & 2 /* Private */) { + actions2.unshift(createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(2 /* Private */), [Diagnostics.Declare_private_property_0, memberName])); } actions2.push(createAddIndexSignatureAction(context, declSourceFile, parentDeclaration, token.text, typeNode)); return actions2; @@ -150858,9 +151397,9 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} } const methodName = token.text; const addMethodDeclarationChanges = (modifierFlags2) => ts_textChanges_exports.ChangeTracker.with(context, (t) => addMethodDeclaration(context, t, call, token, modifierFlags2, parentDeclaration, declSourceFile)); - const actions2 = [createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* Static */), [modifierFlags & 32 /* Static */ ? Diagnostics.Declare_static_method_0 : Diagnostics.Declare_method_0, methodName], fixMissingMember, Diagnostics.Add_all_missing_members)]; - if (modifierFlags & 8 /* Private */) { - actions2.unshift(createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* Private */), [Diagnostics.Declare_private_method_0, methodName])); + const actions2 = [createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 256 /* Static */), [modifierFlags & 256 /* Static */ ? Diagnostics.Declare_static_method_0 : Diagnostics.Declare_method_0, methodName], fixMissingMember, Diagnostics.Add_all_missing_members)]; + if (modifierFlags & 2 /* Private */) { + actions2.unshift(createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(2 /* Private */), [Diagnostics.Declare_private_method_0, methodName])); } return actions2; } @@ -151234,13 +151773,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} continue; const { parentDeclaration, declSourceFile, modifierFlags, token, call, isJSFile } = info; if (call && !isPrivateIdentifier(token)) { - addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* Static */, parentDeclaration, declSourceFile); + addMethodDeclaration(context, changes, call, token, modifierFlags & 256 /* Static */, parentDeclaration, declSourceFile); } else { if (isJSFile && !isInterfaceDeclaration(parentDeclaration) && !isTypeLiteralNode(parentDeclaration)) { - addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); + addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 256 /* Static */)); } else { const typeNode = getTypeNode2(checker, parentDeclaration, token); - addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* Static */); + addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 256 /* Static */); } } } @@ -151372,7 +151911,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} } function symbolPointsToNonPrivateAndAbstractMember(symbol) { const flags = getSyntacticModifierFlags(first(symbol.getDeclarations())); - return !(flags & 8 /* Private */) && !!(flags & 256 /* Abstract */); + return !(flags & 2 /* Private */) && !!(flags & 64 /* Abstract */); } var errorCodes30, fixId25; var init_fixClassDoesntImplementInheritedAbstractMember = __esm({ @@ -153897,10 +154436,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} const kind = (declaration == null ? void 0 : declaration.kind) ?? 171 /* PropertySignature */; const declarationName = createDeclarationName(symbol, declaration); const effectiveModifierFlags = declaration ? getEffectiveModifierFlags(declaration) : 0 /* None */; - let modifierFlags = effectiveModifierFlags & 32 /* Static */; - modifierFlags |= effectiveModifierFlags & 4 /* Public */ ? 4 /* Public */ : effectiveModifierFlags & 16 /* Protected */ ? 16 /* Protected */ : 0 /* None */; + let modifierFlags = effectiveModifierFlags & 256 /* Static */; + modifierFlags |= effectiveModifierFlags & 1 /* Public */ ? 1 /* Public */ : effectiveModifierFlags & 4 /* Protected */ ? 4 /* Protected */ : 0 /* None */; if (declaration && isAutoAccessorPropertyDeclaration(declaration)) { - modifierFlags |= 128 /* Accessor */; + modifierFlags |= 512 /* Accessor */; } const modifiers = createModifiers(); const type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); @@ -154579,24 +155118,24 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} return isIdentifier(fieldName) ? factory.createPropertyAccessExpression(leftHead, fieldName) : factory.createElementAccessExpression(leftHead, factory.createStringLiteralFromNode(fieldName)); } function prepareModifierFlagsForAccessor(modifierFlags) { - modifierFlags &= ~64 /* Readonly */; - modifierFlags &= ~8 /* Private */; - if (!(modifierFlags & 16 /* Protected */)) { - modifierFlags |= 4 /* Public */; + modifierFlags &= ~8 /* Readonly */; + modifierFlags &= ~2 /* Private */; + if (!(modifierFlags & 4 /* Protected */)) { + modifierFlags |= 1 /* Public */; } return modifierFlags; } function prepareModifierFlagsForField(modifierFlags) { - modifierFlags &= ~4 /* Public */; - modifierFlags &= ~16 /* Protected */; - modifierFlags |= 8 /* Private */; + modifierFlags &= ~1 /* Public */; + modifierFlags &= ~4 /* Protected */; + modifierFlags |= 2 /* Private */; return modifierFlags; } function getAccessorConvertiblePropertyAtPosition(file, program, start, end, considerEmptySpans = true) { const node = getTokenAtPosition(file, start); const cursorRequest = start === end && considerEmptySpans; const declaration = findAncestor(node.parent, isAcceptedDeclaration); - const meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */; + const meaning = 7 /* AccessibilityModifier */ | 256 /* Static */ | 8 /* Readonly */; if (!declaration || !(nodeOverlapsWithStartEnd(declaration.name, file, start, end) || cursorRequest)) { return { error: getLocaleSpecificMessage(Diagnostics.Could_not_find_property_for_which_to_generate_accessor) @@ -154607,7 +155146,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} error: getLocaleSpecificMessage(Diagnostics.Name_is_not_valid) }; } - if ((getEffectiveModifierFlags(declaration) & 126975 /* Modifier */ | meaning) !== meaning) { + if ((getEffectiveModifierFlags(declaration) & 98303 /* Modifier */ | meaning) !== meaning) { return { error: getLocaleSpecificMessage(Diagnostics.Can_only_convert_property_with_modifier) }; @@ -154948,7 +155487,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} return firstDefined(type.types, (t) => getDefaultValueFromType(checker, t)); } else if (type.isClass()) { const classDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); - if (!classDeclaration || hasSyntacticModifier(classDeclaration, 256 /* Abstract */)) + if (!classDeclaration || hasSyntacticModifier(classDeclaration, 64 /* Abstract */)) return void 0; const constructorDeclaration = getFirstConstructorWithBody(classDeclaration); if (constructorDeclaration && constructorDeclaration.parameters.length) @@ -156438,7 +156977,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} ); if (keywordFilters !== 0 /* None */) { for (const keywordEntry of getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && isSourceFileJS(sourceFile))) { - if (isTypeOnlyLocation && isTypeKeyword(stringToToken(keywordEntry.name)) || !uniqueNames.has(keywordEntry.name)) { + if (isTypeOnlyLocation && isTypeKeyword(stringToToken(keywordEntry.name)) || !isTypeOnlyLocation && isContextualKeywordInAutoImportableExpressionSpace(keywordEntry.name) || !uniqueNames.has(keywordEntry.name)) { uniqueNames.add(keywordEntry.name); insertSorted( entries, @@ -156865,7 +157404,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} } let modifiers = 0 /* None */; const { modifiers: presentModifiers, range: eraseRange, decorators: presentDecorators } = getPresentModifiers(contextToken, sourceFile, position); - const isAbstract = presentModifiers & 256 /* Abstract */ && classLikeDeclaration.modifierFlagsCache & 256 /* Abstract */; + const isAbstract = presentModifiers & 64 /* Abstract */ && classLikeDeclaration.modifierFlagsCache & 64 /* Abstract */; let completionNodes = []; ts_codefix_exports.addNewNodeForMemberSymbol( symbol, @@ -156884,15 +157423,15 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} (node) => { let requiredModifiers = 0 /* None */; if (isAbstract) { - requiredModifiers |= 256 /* Abstract */; + requiredModifiers |= 64 /* Abstract */; } if (isClassElement(node) && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node, symbol) === 1 /* NeedsOverride */) { - requiredModifiers |= 16384 /* Override */; + requiredModifiers |= 16 /* Override */; } if (!completionNodes.length) { modifiers = node.modifierFlagsCache | requiredModifiers; } - node = factory.updateModifiers(node, modifiers); + node = factory.replaceModifiers(node, modifiers); completionNodes.push(node); }, body, @@ -156901,28 +157440,28 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} ); if (completionNodes.length) { const isMethod = symbol.flags & 8192 /* Method */; - let allowedModifiers = modifiers | 16384 /* Override */ | 4 /* Public */; + let allowedModifiers = modifiers | 16 /* Override */ | 1 /* Public */; if (!isMethod) { - allowedModifiers |= 2 /* Ambient */ | 64 /* Readonly */; + allowedModifiers |= 128 /* Ambient */ | 8 /* Readonly */; } else { - allowedModifiers |= 512 /* Async */; + allowedModifiers |= 1024 /* Async */; } const allowedAndPresent = presentModifiers & allowedModifiers; if (presentModifiers & ~allowedModifiers) { return void 0; } - if (modifiers & 16 /* Protected */ && allowedAndPresent & 4 /* Public */) { - modifiers &= ~16 /* Protected */; + if (modifiers & 4 /* Protected */ && allowedAndPresent & 1 /* Public */) { + modifiers &= ~4 /* Protected */; } - if (allowedAndPresent !== 0 /* None */ && !(allowedAndPresent & 4 /* Public */)) { - modifiers &= ~4 /* Public */; + if (allowedAndPresent !== 0 /* None */ && !(allowedAndPresent & 1 /* Public */)) { + modifiers &= ~1 /* Public */; } modifiers |= allowedAndPresent; - completionNodes = completionNodes.map((node) => factory.updateModifiers(node, modifiers)); + completionNodes = completionNodes.map((node) => factory.replaceModifiers(node, modifiers)); if (presentDecorators == null ? void 0 : presentDecorators.length) { const lastNode = completionNodes[completionNodes.length - 1]; if (canHaveDecorators(lastNode)) { - completionNodes[completionNodes.length - 1] = factory.updateModifierLike(lastNode, presentDecorators.concat(getModifiers(lastNode) || [])); + completionNodes[completionNodes.length - 1] = factory.replaceDecoratorsAndModifiers(lastNode, presentDecorators.concat(getModifiers(lastNode) || [])); } } const format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */; @@ -156952,7 +157491,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} let contextMod; const range = { pos: position, end: position }; if (isPropertyDeclaration(contextToken.parent) && contextToken.parent.modifiers) { - modifiers |= modifiersToFlags(contextToken.parent.modifiers) & 126975 /* Modifier */; + modifiers |= modifiersToFlags(contextToken.parent.modifiers) & 98303 /* Modifier */; decorators = contextToken.parent.modifiers.filter(isDecorator) || []; range.pos = Math.min(range.pos, contextToken.parent.modifiers.pos); } @@ -157527,7 +158066,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* string */, typeof literal === "string" ? 8 /* stringLiteral */ : 7 /* numericLiteral */); } case "cases": { - const { entry, importAdder } = getExhaustiveCaseSnippets( + const snippets = getExhaustiveCaseSnippets( contextToken.parent, sourceFile, preferences, @@ -157537,7 +158076,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} /*formatContext*/ void 0 ); - if (importAdder.hasFixes()) { + if (snippets == null ? void 0 : snippets.importAdder.hasFixes()) { + const { entry, importAdder } = snippets; const changes = ts_textChanges_exports.ChangeTracker.with( { host, formatContext, preferences }, importAdder.writeFixes @@ -157555,7 +158095,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} }; } return { - name: entry.name, + name, kind: "" /* unknown */, kindModifiers: "", displayParts: [], @@ -158692,24 +159232,24 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} if (contextToken.kind === 80 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": - classElementModifierFlags = classElementModifierFlags | 8 /* Private */; + classElementModifierFlags = classElementModifierFlags | 2 /* Private */; break; case "static": - classElementModifierFlags = classElementModifierFlags | 32 /* Static */; + classElementModifierFlags = classElementModifierFlags | 256 /* Static */; break; case "override": - classElementModifierFlags = classElementModifierFlags | 16384 /* Override */; + classElementModifierFlags = classElementModifierFlags | 16 /* Override */; break; } } if (isClassStaticBlockDeclaration(classElement)) { - classElementModifierFlags |= 32 /* Static */; + classElementModifierFlags |= 256 /* Static */; } - if (!(classElementModifierFlags & 8 /* Private */)) { - const baseTypeNodes = isClassLike(decl) && classElementModifierFlags & 16384 /* Override */ ? singleElementArray(getEffectiveBaseTypeNode(decl)) : getAllSuperTypeNodes(decl); + if (!(classElementModifierFlags & 2 /* Private */)) { + const baseTypeNodes = isClassLike(decl) && classElementModifierFlags & 16 /* Override */ ? singleElementArray(getEffectiveBaseTypeNode(decl)) : getAllSuperTypeNodes(decl); const baseSymbols = flatMap(baseTypeNodes, (baseTypeNode) => { const type = typeChecker.getTypeAtLocation(baseTypeNode); - return classElementModifierFlags & 32 /* Static */ ? (type == null ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : type && typeChecker.getPropertiesOfType(type); + return classElementModifierFlags & 256 /* Static */ ? (type == null ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : type && typeChecker.getPropertiesOfType(type); }); symbols = concatenate(symbols, filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags)); forEach(symbols, (symbol, index) => { @@ -159012,10 +159552,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} if (isCurrentlyEditingNode(m)) { continue; } - if (hasEffectiveModifier(m, 8 /* Private */)) { + if (hasEffectiveModifier(m, 2 /* Private */)) { continue; } - if (isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* Static */)) { + if (isStatic(m) !== !!(currentClassElementModifierFlags & 256 /* Static */)) { continue; } const existingName = getPropertyNameForPropertyNameNode(m.name); @@ -159024,7 +159564,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} } } return baseSymbols.filter( - (propertySymbol) => !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && !(getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) && !(propertySymbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration)) + (propertySymbol) => !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && !(getDeclarationModifierFlagsFromSymbol(propertySymbol) & 2 /* Private */) && !(propertySymbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration)) ); } function filterJsxAttributes(symbols2, attributes) { @@ -159273,7 +159813,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} return checker.getAllPossiblePropertiesOfTypes(filter(type.types, (memberType) => !(memberType.flags & 402784252 /* Primitive */ || checker.isArrayLikeType(memberType) || checker.isTypeInvalidDueToUnionDiscriminant(memberType, node) || checker.typeHasCallOrConstructSignatures(memberType) || memberType.isClass() && containsNonPublicProperties(memberType.getApparentProperties())))); } function containsNonPublicProperties(props) { - return some(props, (p) => !!(getDeclarationModifierFlagsFromSymbol(p) & 24 /* NonPublicAccessibilityModifier */)); + return some(props, (p) => !!(getDeclarationModifierFlagsFromSymbol(p) & 6 /* NonPublicAccessibilityModifier */)); } function getPropertiesForCompletion(type, checker) { return type.isUnion() ? Debug.checkEachDefined(checker.getAllPossiblePropertiesOfTypes(type.types), "getAllPossiblePropertiesOfTypes() should all be defined") : Debug.checkEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); @@ -159433,7 +159973,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} return false; } function isStaticProperty(symbol) { - return !!(symbol.valueDeclaration && getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* Static */ && isClassLike(symbol.valueDeclaration.parent)); + return !!(symbol.valueDeclaration && getEffectiveModifierFlags(symbol.valueDeclaration) & 256 /* Static */ && isClassLike(symbol.valueDeclaration.parent)); } function tryGetObjectLiteralContextualType(node, typeChecker) { const type = typeChecker.getContextualType(node); @@ -159604,6 +160144,9 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} } return charCode; } + function isContextualKeywordInAutoImportableExpressionSpace(keyword) { + return keyword === "abstract" || keyword === "async" || keyword === "await" || keyword === "declare" || keyword === "module" || keyword === "namespace" || keyword === "type"; + } var moduleSpecifierResolutionLimit, moduleSpecifierResolutionCacheAttemptLimit, SortText, CompletionSource, SymbolOriginInfoKind, CompletionKind, _keywordCompletions, allKeywordsCompletions; var init_completions = __esm({ "src/services/completions.ts"() { @@ -160296,7 +160839,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} } const keys = getOwnKeys(exports); const fragmentSubpath = components.join("/") + (components.length && hasTrailingDirectorySeparator(fragment) ? "/" : ""); - const conditions = getConditions(compilerOptions, mode === 99 /* ESNext */); + const conditions = getConditions(compilerOptions, mode); addCompletionEntriesFromPathsOrExports( result, fragmentSubpath, @@ -160641,7 +161184,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} handleNamespaceImport( direct, direct.name, - hasSyntacticModifier(direct, 1 /* Export */), + hasSyntacticModifier(direct, 32 /* Export */), /*alreadyAddedDirect*/ false ); @@ -160956,7 +161499,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} } } else { const exportNode = getExportNode(parent2, node); - if (exportNode && hasSyntacticModifier(exportNode, 1 /* Export */)) { + if (exportNode && hasSyntacticModifier(exportNode, 32 /* Export */)) { if (isImportEqualsDeclaration(exportNode) && exportNode.moduleReference === node) { if (comingFromExport) { return void 0; @@ -161033,7 +161576,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} return exportInfo2 && { kind: 1 /* Export */, symbol: symbol2, exportInfo: exportInfo2 }; } function getExportKindForDeclaration(node2) { - return hasSyntacticModifier(node2, 1024 /* Default */) ? 1 /* Default */ : 0 /* Named */; + return hasSyntacticModifier(node2, 2048 /* Default */) ? 1 /* Default */ : 0 /* Named */; } } function getExportEqualsLocalSymbol(importedSymbol, checker) { @@ -161177,7 +161720,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} if (node.parent.name === node || // node is name of declaration, use parent isConstructorDeclaration(node.parent) || isExportAssignment(node.parent) || // Property name of the import export specifier or binding pattern, use parent (isImportOrExportSpecifier(node.parent) || isBindingElement(node.parent)) && node.parent.propertyName === node || // Is default export - node.kind === 90 /* DefaultKeyword */ && hasSyntacticModifier(node.parent, 1025 /* ExportDefault */)) { + node.kind === 90 /* DefaultKeyword */ && hasSyntacticModifier(node.parent, 2080 /* ExportDefault */)) { return getContextNode(node.parent); } return void 0; @@ -162160,7 +162703,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} return void 0; } if (flags & (4 /* Property */ | 8192 /* Method */)) { - const privateDeclaration = find(declarations, (d) => hasEffectiveModifier(d, 8 /* Private */) || isPrivateIdentifierClassElementDeclaration(d)); + const privateDeclaration = find(declarations, (d) => hasEffectiveModifier(d, 2 /* Private */) || isPrivateIdentifierClassElementDeclaration(d)); if (privateDeclaration) { return getAncestor(privateDeclaration, 263 /* ClassDeclaration */); } @@ -162670,7 +163213,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} if (!searchSpaceNode) { return void 0; } - let staticFlag = 32 /* Static */; + let staticFlag = 256 /* Static */; switch (searchSpaceNode.kind) { case 172 /* PropertyDeclaration */: case 171 /* PropertySignature */: @@ -162710,7 +163253,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} /*includeClassComputedPropertyName*/ false ); - let staticFlag = 32 /* Static */; + let staticFlag = 256 /* Static */; switch (searchSpaceNode.kind) { case 174 /* MethodDeclaration */: case 173 /* MethodSignature */: @@ -162952,7 +163495,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} if (!symbol.valueDeclaration) return false; const modifierFlags = getEffectiveModifierFlags(symbol.valueDeclaration); - return !!(modifierFlags & 32 /* Static */); + return !!(modifierFlags & 256 /* Static */); } function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { const { checker } = state; @@ -163508,7 +164051,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} case 177 /* GetAccessor */: case 178 /* SetAccessor */: case 174 /* MethodDeclaration */: - if (hasEffectiveModifier(declaration, 8 /* Private */)) + if (hasEffectiveModifier(declaration, 2 /* Private */)) return false; case 176 /* Constructor */: case 303 /* PropertyAssignment */: @@ -163628,6 +164171,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} const { file, program, span, cancellationToken, preferences } = context; const sourceFileText = file.text; const compilerOptions = program.getCompilerOptions(); + const quotePreference = getQuotePreference(file, preferences); const checker = program.getTypeChecker(); const result = []; visitor(file); @@ -163935,6 +164479,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} parts.push({ text: tokenString }); return; } + if (isLiteralExpression(node)) { + parts.push({ text: getLiteralText2(node) }); + return; + } switch (node.kind) { case 80 /* Identifier */: const identifier = node; @@ -163946,12 +164494,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} parts.push({ text: identifierText }); } break; - case 9 /* NumericLiteral */: - parts.push({ text: node.text }); - break; - case 11 /* StringLiteral */: - parts.push({ text: `"${node.text}"` }); - break; case 166 /* QualifiedName */: const qualifiedName = node; visitForDisplayParts(qualifiedName.left); @@ -164207,6 +164749,12 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} visitForDisplayParts(node); }); } + function getLiteralText2(node) { + if (isStringLiteral(node)) { + return quotePreference === 0 /* Single */ ? `'${escapeString(node.text, 39 /* singleQuote */)}'` : `"${escapeString(node.text, 34 /* doubleQuote */)}"`; + } + return node.text; + } } function isUndefined(name) { return name === "undefined"; @@ -164281,6 +164829,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} case 345 /* JSDocCallbackTag */: case 353 /* JSDocTypedefTag */: return [declaration, declaration.parent]; + case 330 /* JSDocSignature */: + if (isJSDocOverloadTag(declaration.parent)) { + return [declaration.parent.parent]; + } default: return getJSDocCommentsAndTags(declaration); } @@ -165539,7 +166091,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} case 275 /* NamedImports */: case 279 /* NamedExports */: case 300 /* ImportAttributes */: - case 300 /* AssertClause */: return spanForImportExportElements(n); } function spanForImportExportElements(node) { @@ -166704,7 +167255,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} function getNormalizedSymbolModifiers(symbol) { if (symbol.declarations && symbol.declarations.length) { const [declaration, ...declarations] = symbol.declarations; - const excludeFlags = length(declarations) && isDeprecatedDeclaration(declaration) && some(declarations, (d) => !isDeprecatedDeclaration(d)) ? 8192 /* Deprecated */ : 0 /* None */; + const excludeFlags = length(declarations) && isDeprecatedDeclaration(declaration) && some(declarations, (d) => !isDeprecatedDeclaration(d)) ? 65536 /* Deprecated */ : 0 /* None */; const modifiers = getNodeModifiers(declaration, excludeFlags); if (modifiers) { return modifiers.split(","); @@ -166980,7 +167531,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")} const resolvedNode = resolvedSymbol.declarations[0]; const declarationName = getNameOfDeclaration(resolvedNode); if (declarationName && !hasAddedSymbolInfo) { - const isExternalModuleDeclaration = isModuleWithStringLiteralName(resolvedNode) && hasSyntacticModifier(resolvedNode, 2 /* Ambient */); + const isExternalModuleDeclaration = isModuleWithStringLiteralName(resolvedNode) && hasSyntacticModifier(resolvedNode, 128 /* Ambient */); const shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration; const resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKindWorker( typeChecker, @@ -171747,7 +172298,7 @@ ${options.prefix}` : "\n" : options.prefix } install(req) { if (this.log.isEnabled()) { - this.log.writeLine(`Got install request ${JSON.stringify(req)}`); + this.log.writeLine(`Got install request${stringifyIndented(req)}`); } if (req.cachePath) { if (this.log.isEnabled()) { @@ -171770,9 +172321,6 @@ ${options.prefix}` : "\n" : options.prefix this.typesRegistry, req.compilerOptions ); - if (this.log.isEnabled()) { - this.log.writeLine(`Finished typings discovery: ${JSON.stringify(discoverTypingsResult)}`); - } this.watchFiles(req.projectName, discoverTypingsResult.filesToWatch); if (discoverTypingsResult.newTypingNames.length) { this.installTypings(req, req.cachePath || this.globalCachePath, discoverTypingsResult.cachedTypingPaths, discoverTypingsResult.newTypingNames); @@ -171814,8 +172362,8 @@ ${options.prefix}` : "\n" : options.prefix const npmConfig = JSON.parse(this.installTypingHost.readFile(packageJson)); const npmLock = JSON.parse(this.installTypingHost.readFile(packageLockJson)); if (this.log.isEnabled()) { - this.log.writeLine(`Loaded content of '${packageJson}': ${JSON.stringify(npmConfig)}`); - this.log.writeLine(`Loaded content of '${packageLockJson}'`); + this.log.writeLine(`Loaded content of '${packageJson}':${stringifyIndented(npmConfig)}`); + this.log.writeLine(`Loaded content of '${packageLockJson}':${stringifyIndented(npmLock)}`); } if (npmConfig.devDependencies && npmLock.dependencies) { for (const key in npmConfig.devDependencies) { @@ -172162,13 +172710,7 @@ ${options.prefix}` : "\n" : options.prefix array.splice(removeIndex, 1); } } - function indent2(str) { - return indentStr + str.replace(/\n/g, indentStr); - } - function stringifyIndented(json) { - return indentStr + JSON.stringify(json); - } - var ThrottledOperations, GcTimer, indentStr; + var ThrottledOperations, GcTimer; var init_utilities5 = __esm({ "src/server/utilities.ts"() { "use strict"; @@ -172240,7 +172782,6 @@ ${options.prefix}` : "\n" : options.prefix (_b = perfLogger) == null ? void 0 : _b.logStopScheduledOperation(); } }; - indentStr = "\n "; } }); @@ -172513,7 +173054,7 @@ ${options.prefix}` : "\n" : options.prefix return fileName[0] === "^" || (fileName.includes("walkThroughSnippet:/") || fileName.includes("untitled:/")) && getBaseFileName(fileName)[0] === "^" || fileName.includes(":^") && !fileName.includes(directorySeparator); } function ensurePrimaryProjectKind(project) { - if (!project || project.projectKind === 3 /* AutoImportProvider */ || project.projectKind === 4 /* Auxiliary */) { + if (!project || isBackgroundProject(project)) { return Errors.ThrowNoProject(); } return project; @@ -172975,7 +173516,7 @@ ${options.prefix}` : "\n" : options.prefix isContainedByBackgroundProject() { return some( this.containingProjects, - (p) => p.projectKind === 3 /* AutoImportProvider */ || p.projectKind === 4 /* Auxiliary */ + isBackgroundProject ); } /** @@ -173211,6 +173752,9 @@ ${options.prefix}` : "\n" : options.prefix function isExternalProject(project) { return project.projectKind === 2 /* External */; } + function isBackgroundProject(project) { + return project.projectKind === 3 /* AutoImportProvider */ || project.projectKind === 4 /* Auxiliary */; + } var ProjectKind, Project3, InferredProject2, AuxiliaryProject, _AutoImportProviderProject, AutoImportProviderProject, ConfiguredProject2, ExternalProject2; var init_project = __esm({ "src/server/project.ts"() { @@ -173327,9 +173871,10 @@ ${options.prefix}` : "\n" : options.prefix this.disableLanguageService(lastFileExceededProgramSize); } this.markAsDirty(); - if (projectKind !== 3 /* AutoImportProvider */) { + if (!isBackgroundProject(this)) { this.projectService.pendingEnsureProjectForOpenFiles = true; } + this.projectService.onProjectCreation(this); } /** @internal */ getResolvedProjectReferenceToRedirect(_fileName) { @@ -173499,6 +174044,7 @@ ${options.prefix}` : "\n" : options.prefix resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames) { return this.resolutionCache.resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames); } + /** @internal */ getModuleResolutionCache() { return this.resolutionCache.getModuleResolutionCache(); } @@ -173764,12 +174310,12 @@ ${options.prefix}` : "\n" : options.prefix } return { ...newTypeAcquisition, include: this.removeExistingTypings(newTypeAcquisition.include) }; } - getExternalFiles() { + getExternalFiles(updateLevel) { return sort(flatMap(this.plugins, (plugin) => { if (typeof plugin.module.getExternalFiles !== "function") return; try { - return plugin.module.getExternalFiles(this); + return plugin.module.getExternalFiles(this, updateLevel || 0 /* Update */); } catch (e) { this.projectService.logger.info(`A plugin threw an exception in getExternalFiles: ${e}`); if (e.stack) { @@ -174504,6 +175050,7 @@ ${options.prefix}` : "\n" : options.prefix } /** @internal */ getChangesSinceVersion(lastKnownVersion, includeProjectReferenceRedirectInfo) { + var _a, _b; const includeProjectReferenceRedirectInfoIfRequested = includeProjectReferenceRedirectInfo ? (files) => arrayFrom(files.entries(), ([fileName, isSourceOfProjectReferenceRedirect]) => ({ fileName, isSourceOfProjectReferenceRedirect @@ -174526,10 +175073,10 @@ ${options.prefix}` : "\n" : options.prefix return { info, projectErrors: this.getGlobalProjectErrors() }; } const lastReportedFileNames = this.lastReportedFileNames; - const externalFiles = this.getExternalFiles().map((f) => ({ + const externalFiles = ((_a = this.externalFiles) == null ? void 0 : _a.map((f) => ({ fileName: toNormalizedPath(f), isSourceOfProjectReferenceRedirect: false - })); + }))) || emptyArray2; const currentFiles = arrayToMap( this.getFileNamesWithRedirectInfo(!!includeProjectReferenceRedirectInfo).concat(externalFiles), (info2) => info2.fileName, @@ -174571,10 +175118,10 @@ ${options.prefix}` : "\n" : options.prefix }; } else { const projectFileNames = this.getFileNamesWithRedirectInfo(!!includeProjectReferenceRedirectInfo); - const externalFiles = this.getExternalFiles().map((f) => ({ + const externalFiles = ((_b = this.externalFiles) == null ? void 0 : _b.map((f) => ({ fileName: toNormalizedPath(f), isSourceOfProjectReferenceRedirect: false - })); + }))) || emptyArray2; const allFiles = projectFileNames.concat(externalFiles); this.lastReportedFileNames = arrayToMap( allFiles, @@ -174776,32 +175323,15 @@ ${options.prefix}` : "\n" : options.prefix return this.projectService.getIncompleteCompletionsCache(); } /** @internal */ - getNoDtsResolutionProject(rootFileNames) { + getNoDtsResolutionProject(rootFile) { Debug.assert(this.projectService.serverMode === 0 /* Semantic */); if (!this.noDtsResolutionProject) { this.noDtsResolutionProject = new AuxiliaryProject(this.projectService, this.documentRegistry, this.getCompilerOptionsForNoDtsResolutionProject(), this.currentDirectory); } - enumerateInsertsAndDeletes( - rootFileNames.map(toNormalizedPath), - this.noDtsResolutionProject.getRootFiles(), - getStringComparer(!this.useCaseSensitiveFileNames()), - (pathToAdd) => { - const info = this.projectService.getOrCreateScriptInfoNotOpenedByClient( - pathToAdd, - this.currentDirectory, - this.noDtsResolutionProject.directoryStructureHost - ); - if (info) { - this.noDtsResolutionProject.addRoot(info, pathToAdd); - } - }, - (pathToRemove) => { - const info = this.noDtsResolutionProject.getScriptInfo(pathToRemove); - if (info) { - this.noDtsResolutionProject.removeRoot(info); - } - } - ); + if (this.noDtsResolutionProject.rootFile !== rootFile) { + this.projectService.setFileNamesOfAutpImportProviderOrAuxillaryProject(this.noDtsResolutionProject, [rootFile]); + this.noDtsResolutionProject.rootFile = rootFile; + } return this.noDtsResolutionProject; } /** @internal */ @@ -175108,7 +175638,7 @@ ${options.prefix}` : "\n" : options.prefix this.getCompilationSettings() ); } - this.projectService.setFileNamesOfAutoImportProviderProject(this, rootFileNames); + this.projectService.setFileNamesOfAutpImportProviderOrAuxillaryProject(this, rootFileNames); this.rootFileNames = rootFileNames; const oldProgram = this.getCurrentProgram(); const hasSameSetOfFiles = super.updateGraph(); @@ -175153,9 +175683,6 @@ ${options.prefix}` : "\n" : options.prefix includePackageJsonAutoImports() { return 0 /* Off */; } - getTypeAcquisition() { - return { enable: false }; - } /** @internal */ getSymlinkCache() { return this.hostProject.getSymlinkCache(); @@ -175253,18 +175780,18 @@ ${options.prefix}` : "\n" : options.prefix updateGraph() { const isInitialLoad = this.isInitialLoadPending(); this.isInitialLoadPending = returnFalse; - const reloadLevel = this.pendingReload; - this.pendingReload = 0 /* None */; + const updateLevel = this.pendingUpdateLevel; + this.pendingUpdateLevel = 0 /* Update */; let result; - switch (reloadLevel) { - case 1 /* Partial */: + switch (updateLevel) { + case 1 /* RootNamesAndUpdate */: this.openFileWatchTriggered.clear(); result = this.projectService.reloadFileNamesOfConfiguredProject(this); break; case 2 /* Full */: this.openFileWatchTriggered.clear(); - const reason = Debug.checkDefined(this.pendingReloadReason); - this.pendingReloadReason = void 0; + const reason = Debug.checkDefined(this.pendingUpdateReason); + this.pendingUpdateReason = void 0; this.projectService.reloadConfiguredProject( this, reason, @@ -175931,6 +176458,8 @@ ${options.prefix}` : "\n" : options.prefix this.verifyDocumentRegistry = noop; /** @internal */ this.verifyProgram = noop; + /** @internal */ + this.onProjectCreation = noop; var _a; this.host = opts.host; this.logger = opts.logger; @@ -176098,20 +176627,20 @@ ${options.prefix}` : "\n" : options.prefix } delayUpdateProjectGraph(project) { project.markAsDirty(); - if (project.projectKind !== 3 /* AutoImportProvider */ && project.projectKind !== 4 /* Auxiliary */) { - const projectName = project.getProjectName(); - this.pendingProjectUpdates.set(projectName, project); - this.throttledOperations.schedule( - projectName, - /*delay*/ - 250, - () => { - if (this.pendingProjectUpdates.delete(projectName)) { - updateProjectIfDirty(project); - } + if (isBackgroundProject(project)) + return; + const projectName = project.getProjectName(); + this.pendingProjectUpdates.set(projectName, project); + this.throttledOperations.schedule( + projectName, + /*delay*/ + 250, + () => { + if (this.pendingProjectUpdates.delete(projectName)) { + updateProjectIfDirty(project); } - ); - } + } + ); } /** @internal */ hasPendingProjectUpdate(project) { @@ -176387,28 +176916,28 @@ ${options.prefix}` : "\n" : options.prefix getScriptKind: configuredProjectForConfig ? (fileName) => configuredProjectForConfig.getScriptKind(fileName) : void 0 })) return; - if (config.reloadLevel !== 2 /* Full */) - config.reloadLevel = 1 /* Partial */; + if (config.updateLevel !== 2 /* Full */) + config.updateLevel = 1 /* RootNamesAndUpdate */; config.projects.forEach((watchWildcardDirectories, projectCanonicalPath) => { if (!watchWildcardDirectories) return; const project = this.getConfiguredProjectByCanonicalConfigFilePath(projectCanonicalPath); if (!project) return; - const reloadLevel = configuredProjectForConfig === project ? 1 /* Partial */ : 0 /* None */; - if (project.pendingReload !== void 0 && project.pendingReload > reloadLevel) + const updateLevel = configuredProjectForConfig === project ? 1 /* RootNamesAndUpdate */ : 0 /* Update */; + if (project.pendingUpdateLevel !== void 0 && project.pendingUpdateLevel > updateLevel) return; if (this.openFiles.has(fileOrDirectoryPath)) { const info = Debug.checkDefined(this.getScriptInfoForPath(fileOrDirectoryPath)); if (info.isAttached(project)) { - const loadLevelToSet = Math.max(reloadLevel, project.openFileWatchTriggered.get(fileOrDirectoryPath) || 0 /* None */); + const loadLevelToSet = Math.max(updateLevel, project.openFileWatchTriggered.get(fileOrDirectoryPath) || 0 /* Update */); project.openFileWatchTriggered.set(fileOrDirectoryPath, loadLevelToSet); } else { - project.pendingReload = reloadLevel; + project.pendingUpdateLevel = updateLevel; this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project); } } else { - project.pendingReload = reloadLevel; + project.pendingUpdateLevel = updateLevel; this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project); } }); @@ -176420,12 +176949,12 @@ ${options.prefix}` : "\n" : options.prefix ); } /** @internal */ - delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalConfigFilePath, reloadReason) { + delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalConfigFilePath, loadReason) { const configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (!(configFileExistenceInfo == null ? void 0 : configFileExistenceInfo.config)) return false; let scheduledAnyProjectUpdate = false; - configFileExistenceInfo.config.reloadLevel = 2 /* Full */; + configFileExistenceInfo.config.updateLevel = 2 /* Full */; configFileExistenceInfo.config.projects.forEach((_watchWildcardDirectories, projectCanonicalPath) => { const project = this.getConfiguredProjectByCanonicalConfigFilePath(projectCanonicalPath); if (!project) @@ -176434,8 +176963,8 @@ ${options.prefix}` : "\n" : options.prefix if (projectCanonicalPath === canonicalConfigFilePath) { if (project.isInitialLoadPending()) return; - project.pendingReload = 2 /* Full */; - project.pendingReloadReason = reloadReason; + project.pendingUpdateLevel = 2 /* Full */; + project.pendingUpdateReason = loadReason; this.delayUpdateProjectGraph(project); } else { project.resolutionCache.removeResolutionsFromProjectReferenceRedirects(this.toPath(canonicalConfigFilePath)); @@ -176584,11 +177113,11 @@ ${options.prefix}` : "\n" : options.prefix if (info.hasMixedContent) { info.registerFileUpdate(); } - const reloadLevel = p.openFileWatchTriggered.get(info.path); - if (reloadLevel !== void 0) { + const updateLevel = p.openFileWatchTriggered.get(info.path); + if (updateLevel !== void 0) { p.openFileWatchTriggered.delete(info.path); - if (p.pendingReload !== void 0 && p.pendingReload < reloadLevel) { - p.pendingReload = reloadLevel; + if (p.pendingUpdateLevel !== void 0 && p.pendingUpdateLevel < updateLevel) { + p.pendingUpdateLevel = updateLevel; p.markFileAsDirty(info.path); } } @@ -176968,6 +177497,7 @@ ${options.prefix}` : "\n" : options.prefix addFilesToNonInferredProject(project, files, propertyReader, typeAcquisition) { this.updateNonInferredProjectFiles(project, files, propertyReader); project.setTypeAcquisition(typeAcquisition); + project.markAsDirty(); } /** @internal */ createConfiguredProject(configFileName) { @@ -176985,7 +177515,7 @@ ${options.prefix}` : "\n" : options.prefix configFileExistenceInfo.config = { cachedDirectoryStructureHost: createCachedDirectoryStructureHost(this.host, this.host.getCurrentDirectory(), this.host.useCaseSensitiveFileNames), projects: /* @__PURE__ */ new Map(), - reloadLevel: 2 /* Full */ + updateLevel: 2 /* Full */ }; } const project = new ConfiguredProject2( @@ -177002,8 +177532,8 @@ ${options.prefix}` : "\n" : options.prefix /** @internal */ createConfiguredProjectWithDelayLoad(configFileName, reason) { const project = this.createConfiguredProject(configFileName); - project.pendingReload = 2 /* Full */; - project.pendingReloadReason = reason; + project.pendingUpdateLevel = 2 /* Full */; + project.pendingUpdateReason = reason; return project; } /** @internal */ @@ -177059,7 +177589,7 @@ ${options.prefix}` : "\n" : options.prefix this.watchWildcards(configFilename, configFileExistenceInfo, project); } project.enablePluginsWithOptions(compilerOptions); - const filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles()); + const filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles(2 /* Full */)); this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave, parsedCommandLine.watchOptions); (_b = tracing) == null ? void 0 : _b.pop(); } @@ -177067,9 +177597,9 @@ ${options.prefix}` : "\n" : options.prefix ensureParsedConfigUptoDate(configFilename, canonicalConfigFilePath, configFileExistenceInfo, forProject) { var _a, _b, _c; if (configFileExistenceInfo.config) { - if (!configFileExistenceInfo.config.reloadLevel) + if (!configFileExistenceInfo.config.updateLevel) return configFileExistenceInfo; - if (configFileExistenceInfo.config.reloadLevel === 1 /* Partial */) { + if (configFileExistenceInfo.config.updateLevel === 1 /* RootNamesAndUpdate */) { this.reloadFileNamesOfParsedConfig(configFilename, configFileExistenceInfo.config); return configFileExistenceInfo; } @@ -177112,7 +177642,7 @@ ${options.prefix}` : "\n" : options.prefix } else { configFileExistenceInfo.config.parsedCommandLine = parsedCommandLine; configFileExistenceInfo.config.watchedDirectoriesStale = true; - configFileExistenceInfo.config.reloadLevel = void 0; + configFileExistenceInfo.config.updateLevel = void 0; } if (!oldCommandLine && !isJsonEqual( // Old options @@ -177253,7 +177783,6 @@ ${options.prefix}` : "\n" : options.prefix } }); } - project.markAsDirty(); } updateRootAndOptionsOfNonInferredProject(project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave, watchOptions) { project.setCompilerOptions(newOptions); @@ -177271,14 +177800,15 @@ ${options.prefix}` : "\n" : options.prefix reloadFileNamesOfConfiguredProject(project) { const fileNames = this.reloadFileNamesOfParsedConfig(project.getConfigFilePath(), this.configFileExistenceInfoCache.get(project.canonicalConfigFilePath).config); project.updateErrorOnNoInputFiles(fileNames); - this.updateNonInferredProjectFiles(project, fileNames.concat(project.getExternalFiles()), fileNamePropertyReader); + this.updateNonInferredProjectFiles(project, fileNames.concat(project.getExternalFiles(1 /* RootNamesAndUpdate */)), fileNamePropertyReader); + project.markAsDirty(); return project.updateGraph(); } /** @internal */ reloadFileNamesOfParsedConfig(configFileName, config) { - if (config.reloadLevel === void 0) + if (config.updateLevel === void 0) return config.parsedCommandLine.fileNames; - Debug.assert(config.reloadLevel === 1 /* Partial */); + Debug.assert(config.updateLevel === 1 /* RootNamesAndUpdate */); const configFileSpecs = config.parsedCommandLine.options.configFile.configFileSpecs; const fileNames = getFileNamesFromConfigSpecs( configFileSpecs, @@ -177291,7 +177821,7 @@ ${options.prefix}` : "\n" : options.prefix return fileNames; } /** @internal */ - setFileNamesOfAutoImportProviderProject(project, fileNames) { + setFileNamesOfAutpImportProviderOrAuxillaryProject(project, fileNames) { this.updateNonInferredProjectFiles(project, fileNames, fileNamePropertyReader); } /** @@ -177820,7 +178350,7 @@ Dynamic files must always be opened with service's current directory or service this.hostConfiguration.preferences = { ...this.hostConfiguration.preferences, ...args.preferences }; if (lazyConfiguredProjectsFromExternalProject && !this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject) { this.configuredProjects.forEach((project) => { - if (project.hasExternalProjectRef() && project.pendingReload === 2 /* Full */ && !this.pendingProjectUpdates.has(project.getProjectName())) { + if (project.hasExternalProjectRef() && project.pendingUpdateLevel === 2 /* Full */ && !this.pendingProjectUpdates.has(project.getProjectName())) { project.updateGraph(); } }); @@ -177875,7 +178405,7 @@ Dynamic files must always be opened with service's current directory or service this.pendingEnsureProjectForOpenFiles = false; this.configFileExistenceInfoCache.forEach((info) => { if (info.config) - info.config.reloadLevel = 2 /* Full */; + info.config.updateLevel = 2 /* Full */; }); this.reloadConfiguredProjectForFiles( this.openFiles, @@ -177927,8 +178457,8 @@ Dynamic files must always be opened with service's current directory or service if (!updatedProjects.has(project.canonicalConfigFilePath)) { updatedProjects.set(project.canonicalConfigFilePath, true); if (delayReload) { - project.pendingReload = 2 /* Full */; - project.pendingReloadReason = reason; + project.pendingUpdateLevel = 2 /* Full */; + project.pendingUpdateReason = reason; if (clearSemanticCache) this.clearSemanticCache(project); this.delayUpdateProjectGraph(project); @@ -179081,7 +179611,7 @@ Dynamic files must always be opened with service's current directory or service const verboseLogging = logger.hasLevel(3 /* verbose */); const json = JSON.stringify(msg); if (verboseLogging) { - logger.info(`${msg.type}:${indent2(JSON.stringify(msg, void 0, " "))}`); + logger.info(`${msg.type}:${stringifyIndented(msg)}`); } const len = byteLength(json, "utf8"); return `Content-Length: ${1 + len}\r @@ -180756,7 +181286,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter if (needsJsResolution) { const definitionSet = createSet((d) => d.textSpan.start, documentSpansEqual); definitions == null ? void 0 : definitions.forEach((d) => definitionSet.add(d)); - const noDtsProject = project.getNoDtsResolutionProject([file]); + const noDtsProject = project.getNoDtsResolutionProject(file); const ls = noDtsProject.getLanguageService(); const jsDefinitions = (_a = ls.getDefinitionAtPosition( file, @@ -180783,8 +181313,18 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter const ambientCandidates = definitions.filter((d) => toNormalizedPath(d.fileName) !== file && d.isAmbient); for (const candidate of some(ambientCandidates) ? ambientCandidates : getAmbientCandidatesByClimbingAccessChain()) { const fileNameToSearch = findImplementationFileFromDtsFileName(candidate.fileName, file, noDtsProject); - if (!fileNameToSearch || !ensureRoot(noDtsProject, fileNameToSearch)) { + if (!fileNameToSearch) + continue; + const info = this.projectService.getOrCreateScriptInfoNotOpenedByClient( + fileNameToSearch, + noDtsProject.currentDirectory, + noDtsProject.directoryStructureHost + ); + if (!info) continue; + if (!noDtsProject.containsScriptInfo(info)) { + noDtsProject.addRoot(info); + noDtsProject.updateGraph(); } const noDtsProgram = ls.getProgram(); const fileToSearch = Debug.checkDefined(noDtsProgram.getSourceFile(fileNameToSearch)); @@ -180887,16 +181427,6 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter } }); } - function ensureRoot(project2, fileName) { - const info = project2.getScriptInfo(fileName); - if (!info) - return false; - if (!project2.containsScriptInfo(info)) { - project2.addRoot(info); - project2.updateGraph(); - } - return true; - } } getEmitOutput(args) { const { file, project } = this.getFileAndProject(args); @@ -183156,6 +183686,7 @@ ${e.message}`; hasArgument: () => hasArgument, hasNoTypeScriptSource: () => hasNoTypeScriptSource, indent: () => indent2, + isBackgroundProject: () => isBackgroundProject, isConfigFile: () => isConfigFile, isConfiguredProject: () => isConfiguredProject, isDynamicFileName: () => isDynamicFileName, @@ -183226,7 +183757,6 @@ ${e.message}`; CompletionInfoFlags: () => CompletionInfoFlags, CompletionTriggerKind: () => CompletionTriggerKind, Completions: () => ts_Completions_exports, - ConfigFileProgramReloadLevel: () => ConfigFileProgramReloadLevel, ContainerFlags: () => ContainerFlags, ContextFlags: () => ContextFlags, Debug: () => Debug, @@ -183313,6 +183843,7 @@ ${e.message}`; PragmaKindFlags: () => PragmaKindFlags, PrivateIdentifierKind: () => PrivateIdentifierKind, ProcessLevel: () => ProcessLevel, + ProgramUpdateLevel: () => ProgramUpdateLevel, QuotePreference: () => QuotePreference, RelationComparisonResult: () => RelationComparisonResult, Rename: () => ts_Rename_exports, @@ -185575,6 +186106,7 @@ ${e.message}`; hasArgument: () => hasArgument, hasNoTypeScriptSource: () => hasNoTypeScriptSource, indent: () => indent2, + isBackgroundProject: () => isBackgroundProject, isConfigFile: () => isConfigFile, isConfiguredProject: () => isConfiguredProject, isDynamicFileName: () => isDynamicFileName, @@ -185633,7 +186165,6 @@ ${e.message}`; CompletionInfoFlags: () => CompletionInfoFlags, CompletionTriggerKind: () => CompletionTriggerKind, Completions: () => ts_Completions_exports, - ConfigFileProgramReloadLevel: () => ConfigFileProgramReloadLevel, ContainerFlags: () => ContainerFlags, ContextFlags: () => ContextFlags, Debug: () => Debug, @@ -185720,6 +186251,7 @@ ${e.message}`; PragmaKindFlags: () => PragmaKindFlags, PrivateIdentifierKind: () => PrivateIdentifierKind, ProcessLevel: () => ProcessLevel, + ProgramUpdateLevel: () => ProgramUpdateLevel, QuotePreference: () => QuotePreference, RelationComparisonResult: () => RelationComparisonResult, Rename: () => ts_Rename_exports, diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 6d41c54b5ed0d..722eb2eae2683 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -2921,32 +2921,43 @@ var NodeFlags = /* @__PURE__ */ ((NodeFlags3) => { })(NodeFlags || {}); var ModifierFlags = /* @__PURE__ */ ((ModifierFlags3) => { ModifierFlags3[ModifierFlags3["None"] = 0] = "None"; - ModifierFlags3[ModifierFlags3["Export"] = 1] = "Export"; - ModifierFlags3[ModifierFlags3["Ambient"] = 2] = "Ambient"; - ModifierFlags3[ModifierFlags3["Public"] = 4] = "Public"; - ModifierFlags3[ModifierFlags3["Private"] = 8] = "Private"; - ModifierFlags3[ModifierFlags3["Protected"] = 16] = "Protected"; - ModifierFlags3[ModifierFlags3["Static"] = 32] = "Static"; - ModifierFlags3[ModifierFlags3["Readonly"] = 64] = "Readonly"; - ModifierFlags3[ModifierFlags3["Accessor"] = 128] = "Accessor"; - ModifierFlags3[ModifierFlags3["Abstract"] = 256] = "Abstract"; - ModifierFlags3[ModifierFlags3["Async"] = 512] = "Async"; - ModifierFlags3[ModifierFlags3["Default"] = 1024] = "Default"; - ModifierFlags3[ModifierFlags3["Const"] = 2048] = "Const"; - ModifierFlags3[ModifierFlags3["HasComputedJSDocModifiers"] = 4096] = "HasComputedJSDocModifiers"; - ModifierFlags3[ModifierFlags3["Deprecated"] = 8192] = "Deprecated"; - ModifierFlags3[ModifierFlags3["Override"] = 16384] = "Override"; - ModifierFlags3[ModifierFlags3["In"] = 32768] = "In"; - ModifierFlags3[ModifierFlags3["Out"] = 65536] = "Out"; - ModifierFlags3[ModifierFlags3["Decorator"] = 131072] = "Decorator"; + ModifierFlags3[ModifierFlags3["Public"] = 1] = "Public"; + ModifierFlags3[ModifierFlags3["Private"] = 2] = "Private"; + ModifierFlags3[ModifierFlags3["Protected"] = 4] = "Protected"; + ModifierFlags3[ModifierFlags3["Readonly"] = 8] = "Readonly"; + ModifierFlags3[ModifierFlags3["Override"] = 16] = "Override"; + ModifierFlags3[ModifierFlags3["Export"] = 32] = "Export"; + ModifierFlags3[ModifierFlags3["Abstract"] = 64] = "Abstract"; + ModifierFlags3[ModifierFlags3["Ambient"] = 128] = "Ambient"; + ModifierFlags3[ModifierFlags3["Static"] = 256] = "Static"; + ModifierFlags3[ModifierFlags3["Accessor"] = 512] = "Accessor"; + ModifierFlags3[ModifierFlags3["Async"] = 1024] = "Async"; + ModifierFlags3[ModifierFlags3["Default"] = 2048] = "Default"; + ModifierFlags3[ModifierFlags3["Const"] = 4096] = "Const"; + ModifierFlags3[ModifierFlags3["In"] = 8192] = "In"; + ModifierFlags3[ModifierFlags3["Out"] = 16384] = "Out"; + ModifierFlags3[ModifierFlags3["Decorator"] = 32768] = "Decorator"; + ModifierFlags3[ModifierFlags3["Deprecated"] = 65536] = "Deprecated"; + ModifierFlags3[ModifierFlags3["JSDocPublic"] = 8388608] = "JSDocPublic"; + ModifierFlags3[ModifierFlags3["JSDocPrivate"] = 16777216] = "JSDocPrivate"; + ModifierFlags3[ModifierFlags3["JSDocProtected"] = 33554432] = "JSDocProtected"; + ModifierFlags3[ModifierFlags3["JSDocReadonly"] = 67108864] = "JSDocReadonly"; + ModifierFlags3[ModifierFlags3["JSDocOverride"] = 134217728] = "JSDocOverride"; + ModifierFlags3[ModifierFlags3["SyntacticOrJSDocModifiers"] = 31] = "SyntacticOrJSDocModifiers"; + ModifierFlags3[ModifierFlags3["SyntacticOnlyModifiers"] = 65504] = "SyntacticOnlyModifiers"; + ModifierFlags3[ModifierFlags3["SyntacticModifiers"] = 65535] = "SyntacticModifiers"; + ModifierFlags3[ModifierFlags3["JSDocCacheOnlyModifiers"] = 260046848] = "JSDocCacheOnlyModifiers"; + ModifierFlags3[ModifierFlags3["JSDocOnlyModifiers"] = 65536 /* Deprecated */] = "JSDocOnlyModifiers"; + ModifierFlags3[ModifierFlags3["NonCacheOnlyModifiers"] = 131071] = "NonCacheOnlyModifiers"; + ModifierFlags3[ModifierFlags3["HasComputedJSDocModifiers"] = 268435456] = "HasComputedJSDocModifiers"; ModifierFlags3[ModifierFlags3["HasComputedFlags"] = 536870912] = "HasComputedFlags"; - ModifierFlags3[ModifierFlags3["AccessibilityModifier"] = 28] = "AccessibilityModifier"; - ModifierFlags3[ModifierFlags3["ParameterPropertyModifier"] = 16476] = "ParameterPropertyModifier"; - ModifierFlags3[ModifierFlags3["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; - ModifierFlags3[ModifierFlags3["TypeScriptModifier"] = 117086] = "TypeScriptModifier"; - ModifierFlags3[ModifierFlags3["ExportDefault"] = 1025] = "ExportDefault"; - ModifierFlags3[ModifierFlags3["All"] = 258047] = "All"; - ModifierFlags3[ModifierFlags3["Modifier"] = 126975] = "Modifier"; + ModifierFlags3[ModifierFlags3["AccessibilityModifier"] = 7] = "AccessibilityModifier"; + ModifierFlags3[ModifierFlags3["ParameterPropertyModifier"] = 31] = "ParameterPropertyModifier"; + ModifierFlags3[ModifierFlags3["NonPublicAccessibilityModifier"] = 6] = "NonPublicAccessibilityModifier"; + ModifierFlags3[ModifierFlags3["TypeScriptModifier"] = 28895] = "TypeScriptModifier"; + ModifierFlags3[ModifierFlags3["ExportDefault"] = 2080] = "ExportDefault"; + ModifierFlags3[ModifierFlags3["All"] = 131071] = "All"; + ModifierFlags3[ModifierFlags3["Modifier"] = 98303] = "Modifier"; return ModifierFlags3; })(ModifierFlags || {}); var RelationComparisonResult = /* @__PURE__ */ ((RelationComparisonResult3) => { @@ -6010,7 +6021,7 @@ var Diagnostics = { Import_assertion_values_must_be_string_literal_expressions: diag(2837, 1 /* Error */, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."), All_declarations_of_0_must_have_identical_constraints: diag(2838, 1 /* Error */, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."), This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, 1 /* Error */, "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839", "This condition will always return '{0}' since JavaScript compares objects by reference, not value."), - An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes: diag(2840, 1 /* Error */, "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840", "An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes"), + An_interface_cannot_extend_a_primitive_type_like_0_It_can_only_extend_other_named_object_types: diag(2840, 1 /* Error */, "An_interface_cannot_extend_a_primitive_type_like_0_It_can_only_extend_other_named_object_types_2840", "An interface cannot extend a primitive type like '{0}'. It can only extend other named object types."), _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, 1 /* Error */, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"), We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, 1 /* Error */, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."), Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, 1 /* Error */, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), @@ -6030,6 +6041,9 @@ var Diagnostics = { Excessive_complexity_comparing_types_0_and_1: diag(2859, 1 /* Error */, "Excessive_complexity_comparing_types_0_and_1_2859", "Excessive complexity comparing types '{0}' and '{1}'."), The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_hand_side_s_Symbol_hasInstance_method: diag(2860, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_2860", "The left-hand side of an 'instanceof' expression must be assignable to the first argument of the right-hand side's '[Symbol.hasInstance]' method."), An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_hand_side_of_an_instanceof_expression: diag(2861, 1 /* Error */, "An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_han_2861", "An object's '[Symbol.hasInstance]' method must return a boolean value for it to be used on the right-hand side of an 'instanceof' expression."), + Type_0_is_generic_and_can_only_be_indexed_for_reading: diag(2862, 1 /* Error */, "Type_0_is_generic_and_can_only_be_indexed_for_reading_2862", "Type '{0}' is generic and can only be indexed for reading."), + A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values: diag(2863, 1 /* Error */, "A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values_2863", "A class cannot extend a primitive type like '{0}'. Classes can only extend constructable values."), + A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types: diag(2864, 1 /* Error */, "A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types_2864", "A class cannot implement a primitive type like '{0}'. It can only implement other named object types."), Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* 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, 1 /* 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, 1 /* 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}'."), @@ -9514,7 +9528,7 @@ function getAssignedName(node) { } } function getModifiers(node) { - if (hasSyntacticModifier(node, 126975 /* Modifier */)) { + if (hasSyntacticModifier(node, 98303 /* Modifier */)) { return filter(node.modifiers, isModifier); } } @@ -9720,7 +9734,7 @@ function isModifierKind(token) { return false; } function isParameterPropertyModifier(kind) { - return !!(modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); + return !!(modifierToFlag(kind) & 31 /* ParameterPropertyModifier */); } function isClassMemberModifier(idToken) { return isParameterPropertyModifier(idToken) || idToken === 126 /* StaticKeyword */ || idToken === 164 /* OverrideKeyword */ || idToken === 129 /* AccessorKeyword */; @@ -10593,9 +10607,9 @@ function ownsJSDocTag(hostNode, tag) { } function getNextJSDocCommentLocation(node) { const parent = node.parent; - if (parent.kind === 303 /* PropertyAssignment */ || parent.kind === 277 /* ExportAssignment */ || parent.kind === 172 /* PropertyDeclaration */ || parent.kind === 244 /* ExpressionStatement */ && node.kind === 211 /* PropertyAccessExpression */ || parent.kind === 253 /* ReturnStatement */ || getNestedModuleDeclaration(parent) || isBinaryExpression(node) && node.operatorToken.kind === 64 /* EqualsToken */) { + if (parent.kind === 303 /* PropertyAssignment */ || parent.kind === 277 /* ExportAssignment */ || parent.kind === 172 /* PropertyDeclaration */ || parent.kind === 244 /* ExpressionStatement */ && node.kind === 211 /* PropertyAccessExpression */ || parent.kind === 253 /* ReturnStatement */ || getNestedModuleDeclaration(parent) || isAssignmentExpression(node)) { return parent; - } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || isBinaryExpression(parent) && parent.operatorToken.kind === 64 /* EqualsToken */)) { + } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || isAssignmentExpression(parent))) { return parent.parent; } else if (parent.parent && parent.parent.parent && (getSingleVariableOfVariableStatement(parent.parent.parent) || getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || getSourceOfDefaultedAssignment(parent.parent.parent))) { return parent.parent.parent; @@ -10898,10 +10912,13 @@ function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */; } - if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { - node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* HasComputedJSDocModifiers */; + if (alwaysIncludeJSDoc || includeJSDoc && isInJSFile(node)) { + if (!(node.modifierFlagsCache & 268435456 /* HasComputedJSDocModifiers */) && node.parent) { + node.modifierFlagsCache |= getRawJSDocModifierFlagsNoCache(node) | 268435456 /* HasComputedJSDocModifiers */; + } + return selectEffectiveModifierFlags(node.modifierFlagsCache); } - return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */); + return selectSyntacticModifierFlags(node.modifierFlagsCache); } function getSyntacticModifierFlags(node) { return getModifierFlagsWorker( @@ -10910,33 +10927,42 @@ function getSyntacticModifierFlags(node) { false ); } -function getJSDocModifierFlagsNoCache(node) { +function getRawJSDocModifierFlagsNoCache(node) { let flags = 0 /* None */; if (!!node.parent && !isParameter(node)) { if (isInJSFile(node)) { if (getJSDocPublicTagNoCache(node)) - flags |= 4 /* Public */; + flags |= 8388608 /* JSDocPublic */; if (getJSDocPrivateTagNoCache(node)) - flags |= 8 /* Private */; + flags |= 16777216 /* JSDocPrivate */; if (getJSDocProtectedTagNoCache(node)) - flags |= 16 /* Protected */; + flags |= 33554432 /* JSDocProtected */; if (getJSDocReadonlyTagNoCache(node)) - flags |= 64 /* Readonly */; + flags |= 67108864 /* JSDocReadonly */; if (getJSDocOverrideTagNoCache(node)) - flags |= 16384 /* Override */; + flags |= 134217728 /* JSDocOverride */; } if (getJSDocDeprecatedTagNoCache(node)) - flags |= 8192 /* Deprecated */; + flags |= 65536 /* Deprecated */; } return flags; } +function selectSyntacticModifierFlags(flags) { + return flags & 65535 /* SyntacticModifiers */; +} +function selectEffectiveModifierFlags(flags) { + return flags & 131071 /* NonCacheOnlyModifiers */ | (flags & 260046848 /* JSDocCacheOnlyModifiers */) >>> 23; +} +function getJSDocModifierFlagsNoCache(node) { + return selectEffectiveModifierFlags(getRawJSDocModifierFlagsNoCache(node)); +} function getEffectiveModifierFlagsNoCache(node) { return getSyntacticModifierFlagsNoCache(node) | getJSDocModifierFlagsNoCache(node); } function getSyntacticModifierFlagsNoCache(node) { let flags = canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : 0 /* None */; if (node.flags & 8 /* NestedNamespace */ || node.kind === 80 /* Identifier */ && node.flags & 4096 /* IdentifierIsInJSDocNamespace */) { - flags |= 1 /* Export */; + flags |= 32 /* Export */; } return flags; } @@ -10952,37 +10978,37 @@ function modifiersToFlags(modifiers) { function modifierToFlag(token) { switch (token) { case 126 /* StaticKeyword */: - return 32 /* Static */; + return 256 /* Static */; case 125 /* PublicKeyword */: - return 4 /* Public */; + return 1 /* Public */; case 124 /* ProtectedKeyword */: - return 16 /* Protected */; + return 4 /* Protected */; case 123 /* PrivateKeyword */: - return 8 /* Private */; + return 2 /* Private */; case 128 /* AbstractKeyword */: - return 256 /* Abstract */; + return 64 /* Abstract */; case 129 /* AccessorKeyword */: - return 128 /* Accessor */; + return 512 /* Accessor */; case 95 /* ExportKeyword */: - return 1 /* Export */; + return 32 /* Export */; case 138 /* DeclareKeyword */: - return 2 /* Ambient */; + return 128 /* Ambient */; case 87 /* ConstKeyword */: - return 2048 /* Const */; + return 4096 /* Const */; case 90 /* DefaultKeyword */: - return 1024 /* Default */; + return 2048 /* Default */; case 134 /* AsyncKeyword */: - return 512 /* Async */; + return 1024 /* Async */; case 148 /* ReadonlyKeyword */: - return 64 /* Readonly */; + return 8 /* Readonly */; case 164 /* OverrideKeyword */: - return 16384 /* Override */; + return 16 /* Override */; case 103 /* InKeyword */: - return 32768 /* In */; + return 8192 /* In */; case 147 /* OutKeyword */: - return 65536 /* Out */; + return 16384 /* Out */; case 170 /* Decorator */: - return 131072 /* Decorator */; + return 32768 /* Decorator */; } return 0 /* None */; } @@ -12964,8 +12990,9 @@ function createNodeFactory(flags, baseFactory2) { ensureUseStrict, liftToBlock, mergeLexicalEnvironment, - updateModifiers, - updateModifierLike + replaceModifiers, + replaceDecoratorsAndModifiers, + replacePropertyName }; forEach(nodeFactoryPatchers, (fn) => fn(factory2)); return factory2; @@ -13300,35 +13327,35 @@ function createNodeFactory(flags, baseFactory2) { } function createModifiersFromModifierFlags(flags2) { const result = []; - if (flags2 & 1 /* Export */) + if (flags2 & 32 /* Export */) result.push(createModifier(95 /* ExportKeyword */)); - if (flags2 & 2 /* Ambient */) + if (flags2 & 128 /* Ambient */) result.push(createModifier(138 /* DeclareKeyword */)); - if (flags2 & 1024 /* Default */) + if (flags2 & 2048 /* Default */) result.push(createModifier(90 /* DefaultKeyword */)); - if (flags2 & 2048 /* Const */) + if (flags2 & 4096 /* Const */) result.push(createModifier(87 /* ConstKeyword */)); - if (flags2 & 4 /* Public */) + if (flags2 & 1 /* Public */) result.push(createModifier(125 /* PublicKeyword */)); - if (flags2 & 8 /* Private */) + if (flags2 & 2 /* Private */) result.push(createModifier(123 /* PrivateKeyword */)); - if (flags2 & 16 /* Protected */) + if (flags2 & 4 /* Protected */) result.push(createModifier(124 /* ProtectedKeyword */)); - if (flags2 & 256 /* Abstract */) + if (flags2 & 64 /* Abstract */) result.push(createModifier(128 /* AbstractKeyword */)); - if (flags2 & 32 /* Static */) + if (flags2 & 256 /* Static */) result.push(createModifier(126 /* StaticKeyword */)); - if (flags2 & 16384 /* Override */) + if (flags2 & 16 /* Override */) result.push(createModifier(164 /* OverrideKeyword */)); - if (flags2 & 64 /* Readonly */) + if (flags2 & 8 /* Readonly */) result.push(createModifier(148 /* ReadonlyKeyword */)); - if (flags2 & 128 /* Accessor */) + if (flags2 & 512 /* Accessor */) result.push(createModifier(129 /* AccessorKeyword */)); - if (flags2 & 512 /* Async */) + if (flags2 & 1024 /* Async */) result.push(createModifier(134 /* AsyncKeyword */)); - if (flags2 & 32768 /* In */) + if (flags2 & 8192 /* In */) result.push(createModifier(103 /* InKeyword */)); - if (flags2 & 65536 /* Out */) + if (flags2 & 16384 /* Out */) result.push(createModifier(147 /* OutKeyword */)); return result.length ? result : void 0; } @@ -13377,7 +13404,7 @@ function createNodeFactory(flags, baseFactory2) { if (isThisIdentifier(node.name)) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.dotDotDotToken) | propagateNameFlags(node.name) | propagateChildFlags(node.questionToken) | propagateChildFlags(node.initializer) | (node.questionToken ?? node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (node.dotDotDotToken ?? node.initializer ? 1024 /* ContainsES2015 */ : 0 /* None */) | (modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */ ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */); + node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.dotDotDotToken) | propagateNameFlags(node.name) | propagateChildFlags(node.questionToken) | propagateChildFlags(node.initializer) | (node.questionToken ?? node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (node.dotDotDotToken ?? node.initializer ? 1024 /* ContainsES2015 */ : 0 /* None */) | (modifiersToFlags(node.modifiers) & 31 /* ParameterPropertyModifier */ ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */); } node.jsDoc = void 0; return node; @@ -13426,8 +13453,8 @@ function createNodeFactory(flags, baseFactory2) { node.exclamationToken = questionOrExclamationToken && isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : void 0; node.type = type; node.initializer = asInitializer(initializer); - const isAmbient = node.flags & 33554432 /* Ambient */ || modifiersToFlags(node.modifiers) & 2 /* Ambient */; - node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateNameFlags(node.name) | propagateChildFlags(node.initializer) | (isAmbient || node.questionToken || node.exclamationToken || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (isComputedPropertyName(node.name) || modifiersToFlags(node.modifiers) & 32 /* Static */ && node.initializer ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */) | 16777216 /* ContainsClassFields */; + const isAmbient = node.flags & 33554432 /* Ambient */ || modifiersToFlags(node.modifiers) & 128 /* Ambient */; + node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateNameFlags(node.name) | propagateChildFlags(node.initializer) | (isAmbient || node.questionToken || node.exclamationToken || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (isComputedPropertyName(node.name) || modifiersToFlags(node.modifiers) & 256 /* Static */ && node.initializer ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */) | 16777216 /* ContainsClassFields */; node.jsDoc = void 0; return node; } @@ -13466,7 +13493,7 @@ function createNodeFactory(flags, baseFactory2) { if (!node.body) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - const isAsync = modifiersToFlags(node.modifiers) & 512 /* Async */; + const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */; const isGenerator = !!node.asteriskToken; const isAsyncGenerator = isAsync && isGenerator; node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.asteriskToken) | propagateNameFlags(node.name) | propagateChildFlags(node.questionToken) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (isAsyncGenerator ? 128 /* ContainsES2018 */ : isAsync ? 256 /* ContainsES2017 */ : isGenerator ? 2048 /* ContainsGenerator */ : 0 /* None */) | (node.questionToken || node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | 1024 /* ContainsES2015 */; @@ -14209,7 +14236,7 @@ function createNodeFactory(flags, baseFactory2) { node.parameters = createNodeArray(parameters); node.type = type; node.body = body; - const isAsync = modifiersToFlags(node.modifiers) & 512 /* Async */; + const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */; const isGenerator = !!node.asteriskToken; const isAsyncGenerator = isAsync && isGenerator; node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.asteriskToken) | propagateNameFlags(node.name) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (isAsyncGenerator ? 128 /* ContainsES2018 */ : isAsync ? 256 /* ContainsES2017 */ : isGenerator ? 2048 /* ContainsGenerator */ : 0 /* None */) | (node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | 4194304 /* ContainsHoistedDeclarationOrCompletion */; @@ -14233,7 +14260,7 @@ function createNodeFactory(flags, baseFactory2) { node.type = type; node.equalsGreaterThanToken = equalsGreaterThanToken ?? createToken(39 /* EqualsGreaterThanToken */); node.body = parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body); - const isAsync = modifiersToFlags(node.modifiers) & 512 /* Async */; + const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */; node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.equalsGreaterThanToken) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (isAsync ? 256 /* ContainsES2017 */ | 16384 /* ContainsLexicalThis */ : 0 /* None */) | 1024 /* ContainsES2015 */; node.typeArguments = void 0; node.jsDoc = void 0; @@ -14585,7 +14612,7 @@ function createNodeFactory(flags, baseFactory2) { node.modifiers = asNodeArray(modifiers); node.declarationList = isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.declarationList); - if (modifiersToFlags(node.modifiers) & 2 /* Ambient */) { + if (modifiersToFlags(node.modifiers) & 128 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } node.jsDoc = void 0; @@ -14835,10 +14862,10 @@ function createNodeFactory(flags, baseFactory2) { node.parameters = createNodeArray(parameters); node.type = type; node.body = body; - if (!node.body || modifiersToFlags(node.modifiers) & 2 /* Ambient */) { + if (!node.body || modifiersToFlags(node.modifiers) & 128 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - const isAsync = modifiersToFlags(node.modifiers) & 512 /* Async */; + const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */; const isGenerator = !!node.asteriskToken; const isAsyncGenerator = isAsync && isGenerator; node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.asteriskToken) | propagateNameFlags(node.name) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (isAsyncGenerator ? 128 /* ContainsES2018 */ : isAsync ? 256 /* ContainsES2017 */ : isGenerator ? 2048 /* ContainsGenerator */ : 0 /* None */) | (node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | 4194304 /* ContainsHoistedDeclarationOrCompletion */; @@ -14869,7 +14896,7 @@ function createNodeFactory(flags, baseFactory2) { node.typeParameters = asNodeArray(typeParameters); node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); - if (modifiersToFlags(node.modifiers) & 2 /* Ambient */) { + if (modifiersToFlags(node.modifiers) & 128 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateNameFlags(node.name) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.heritageClauses) | propagateChildrenFlags(node.members) | (node.typeParameters ? 1 /* ContainsTypeScript */ : 0 /* None */) | 1024 /* ContainsES2015 */; @@ -14931,7 +14958,7 @@ function createNodeFactory(flags, baseFactory2) { node.flags |= flags2 & (32 /* Namespace */ | 8 /* NestedNamespace */ | 2048 /* GlobalAugmentation */); node.name = name; node.body = body; - if (modifiersToFlags(node.modifiers) & 2 /* Ambient */) { + if (modifiersToFlags(node.modifiers) & 128 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.name) | propagateChildFlags(node.body) | 1 /* ContainsTypeScript */; @@ -16362,7 +16389,7 @@ function createNodeFactory(flags, baseFactory2) { return qualifiedName; } function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && hasSyntacticModifier(node, 1 /* Export */)) { + if (ns && hasSyntacticModifier(node, 32 /* Export */)) { return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); } return getExportName(node, allowComments, allowSourceMaps); @@ -16473,7 +16500,7 @@ function createNodeFactory(flags, baseFactory2) { } return statements; } - function updateModifiers(node, modifiers) { + function replaceModifiers(node, modifiers) { let modifierArray; if (typeof modifiers === "number") { modifierArray = createModifiersFromModifierFlags(modifiers); @@ -16482,9 +16509,27 @@ function createNodeFactory(flags, baseFactory2) { } return isTypeParameterDeclaration(node) ? updateTypeParameterDeclaration(node, modifierArray, node.name, node.constraint, node.default) : isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isConstructorTypeNode(node) ? updateConstructorTypeNode1(node, modifierArray, node.typeParameters, node.parameters, node.type) : isPropertySignature(node) ? updatePropertySignature(node, modifierArray, node.name, node.questionToken, node.type) : isPropertyDeclaration(node) ? updatePropertyDeclaration(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : isMethodSignature(node) ? updateMethodSignature(node, modifierArray, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) : isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : isConstructorDeclaration(node) ? updateConstructorDeclaration(node, modifierArray, node.parameters, node.body) : isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) : isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.body) : isIndexSignatureDeclaration(node) ? updateIndexSignature(node, modifierArray, node.parameters, node.type) : isFunctionExpression(node) ? updateFunctionExpression(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : isArrowFunction(node) ? updateArrowFunction(node, modifierArray, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) : isClassExpression(node) ? updateClassExpression(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isVariableStatement(node) ? updateVariableStatement(node, modifierArray, node.declarationList) : isFunctionDeclaration(node) ? updateFunctionDeclaration(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : isClassDeclaration(node) ? updateClassDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, modifierArray, node.name, node.typeParameters, node.type) : isEnumDeclaration(node) ? updateEnumDeclaration(node, modifierArray, node.name, node.members) : isModuleDeclaration(node) ? updateModuleDeclaration(node, modifierArray, node.name, node.body) : isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, modifierArray, node.isTypeOnly, node.name, node.moduleReference) : isImportDeclaration(node) ? updateImportDeclaration(node, modifierArray, node.importClause, node.moduleSpecifier, node.attributes) : isExportAssignment(node) ? updateExportAssignment(node, modifierArray, node.expression) : isExportDeclaration(node) ? updateExportDeclaration(node, modifierArray, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.attributes) : Debug.assertNever(node); } - function updateModifierLike(node, modifierArray) { + function replaceDecoratorsAndModifiers(node, modifierArray) { return isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isPropertyDeclaration(node) ? updatePropertyDeclaration(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) : isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.body) : isClassExpression(node) ? updateClassExpression(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isClassDeclaration(node) ? updateClassDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : Debug.assertNever(node); } + function replacePropertyName(node, name) { + switch (node.kind) { + case 177 /* GetAccessor */: + return updateGetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.type, node.body); + case 178 /* SetAccessor */: + return updateSetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.body); + case 174 /* MethodDeclaration */: + return updateMethodDeclaration(node, node.modifiers, node.asteriskToken, name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body); + case 173 /* MethodSignature */: + return updateMethodSignature(node, node.modifiers, name, node.questionToken, node.typeParameters, node.parameters, node.type); + case 172 /* PropertyDeclaration */: + return updatePropertyDeclaration(node, node.modifiers, name, node.questionToken ?? node.exclamationToken, node.type, node.initializer); + case 171 /* PropertySignature */: + return updatePropertySignature(node, node.modifiers, name, node.questionToken, node.type); + case 303 /* PropertyAssignment */: + return updatePropertyAssignment(node, name, node.initializer); + } + } function asNodeArray(array) { return array ? createNodeArray(array) : void 0; } @@ -23140,11 +23185,11 @@ var Parser; const modifierFlags = modifiersToFlags(modifiers); parseExpected(100 /* FunctionKeyword */); const asteriskToken = parseOptionalToken(42 /* AsteriskToken */); - const name = modifierFlags & 1024 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); + const name = modifierFlags & 2048 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); const isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - const isAsync = modifierFlags & 512 /* Async */ ? 2 /* Await */ : 0 /* None */; + const isAsync = modifierFlags & 1024 /* Async */ ? 2 /* Await */ : 0 /* None */; const typeParameters = parseTypeParameters(); - if (modifierFlags & 1 /* Export */) + if (modifierFlags & 32 /* Export */) setAwaitContext( /*value*/ true @@ -24111,20 +24156,20 @@ var Parser; function doJSDocScan() { let state = 1 /* SawAsterisk */; let margin; - let indent2 = start - (content.lastIndexOf("\n", start) + 1) + 4; + let indent3 = start - (content.lastIndexOf("\n", start) + 1) + 4; function pushComment(text) { if (!margin) { - margin = indent2; + margin = indent3; } comments.push(text); - indent2 += text.length; + indent3 += text.length; } nextTokenJSDoc(); while (parseOptionalJsdoc(5 /* WhitespaceTrivia */)) ; if (parseOptionalJsdoc(4 /* NewLineTrivia */)) { state = 0 /* BeginningOfLine */; - indent2 = 0; + indent3 = 0; } loop: while (true) { @@ -24133,14 +24178,14 @@ var Parser; removeTrailingWhitespace(comments); if (!commentsPos) commentsPos = getNodePos(); - addTag(parseTag(indent2)); + addTag(parseTag(indent3)); state = 0 /* BeginningOfLine */; margin = void 0; break; case 4 /* NewLineTrivia */: comments.push(scanner.getTokenText()); state = 0 /* BeginningOfLine */; - indent2 = 0; + indent3 = 0; break; case 42 /* AsteriskToken */: const asterisk = scanner.getTokenText(); @@ -24150,16 +24195,16 @@ var Parser; } else { Debug.assert(state === 0 /* BeginningOfLine */); state = 1 /* SawAsterisk */; - indent2 += asterisk.length; + indent3 += asterisk.length; } break; case 5 /* WhitespaceTrivia */: Debug.assert(state !== 2 /* SavingComments */, "whitespace shouldn't come from the scanner while saving top-level comment text"); const whitespace = scanner.getTokenText(); - if (margin !== void 0 && indent2 + whitespace.length > margin) { - comments.push(whitespace.slice(margin - indent2)); + if (margin !== void 0 && indent3 + whitespace.length > margin) { + comments.push(whitespace.slice(margin - indent3)); } - indent2 += whitespace.length; + indent3 += whitespace.length; break; case 1 /* EndOfFileToken */: break loop; @@ -24361,7 +24406,7 @@ var Parser; } return parseTagComments(margin, indentText.slice(margin)); } - function parseTagComments(indent2, initialMargin) { + function parseTagComments(indent3, initialMargin) { const commentsPos2 = getNodePos(); let comments2 = []; const parts2 = []; @@ -24370,10 +24415,10 @@ var Parser; let margin; function pushComment(text) { if (!margin) { - margin = indent2; + margin = indent3; } comments2.push(text); - indent2 += text.length; + indent3 += text.length; } if (initialMargin !== void 0) { if (initialMargin !== "") { @@ -24388,7 +24433,7 @@ var Parser; case 4 /* NewLineTrivia */: state = 0 /* BeginningOfLine */; comments2.push(scanner.getTokenText()); - indent2 = 0; + indent3 = 0; break; case 60 /* AtToken */: scanner.resetTokenState(scanner.getTokenEnd() - 1); @@ -24398,11 +24443,11 @@ var Parser; case 5 /* WhitespaceTrivia */: Debug.assert(state !== 2 /* SavingComments */ && state !== 3 /* SavingBackticks */, "whitespace shouldn't come from the scanner while saving comment text"); const whitespace = scanner.getTokenText(); - if (margin !== void 0 && indent2 + whitespace.length > margin) { - comments2.push(whitespace.slice(margin - indent2)); + if (margin !== void 0 && indent3 + whitespace.length > margin) { + comments2.push(whitespace.slice(margin - indent3)); state = 2 /* SavingComments */; } - indent2 += whitespace.length; + indent3 += whitespace.length; break; case 19 /* OpenBraceToken */: state = 2 /* SavingComments */; @@ -24435,7 +24480,7 @@ var Parser; case 42 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { state = 1 /* SawAsterisk */; - indent2 += 1; + indent3 += 1; break; } default: @@ -24500,8 +24545,8 @@ var Parser; function isJSDocLinkTag(kind) { return kind === "link" || kind === "linkcode" || kind === "linkplain"; } - function parseUnknownTag(start2, tagName, indent2, indentText) { - return finishNode(factory2.createJSDocUnknownTag(tagName, parseTrailingTagComments(start2, getNodePos(), indent2, indentText)), start2); + function parseUnknownTag(start2, tagName, indent3, indentText) { + return finishNode(factory2.createJSDocUnknownTag(tagName, parseTrailingTagComments(start2, getNodePos(), indent3, indentText)), start2); } function addTag(tag) { if (!tag) { @@ -24548,7 +24593,7 @@ var Parser; return isTypeReferenceNode(node) && isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; } } - function parseParameterOrPropertyTag(start2, tagName, target, indent2) { + function parseParameterOrPropertyTag(start2, tagName, target, indent3) { let typeExpression = tryParseTypeExpression(); let isNameFirst = !typeExpression; skipWhitespaceOrAsterisk(); @@ -24557,8 +24602,8 @@ var Parser; if (isNameFirst && !lookAhead(parseJSDocLinkPrefix)) { typeExpression = tryParseTypeExpression(); } - const comment = parseTrailingTagComments(start2, getNodePos(), indent2, indentText); - const nestedTypeLiteral = parseNestedTypeLiteral(typeExpression, name, target, indent2); + const comment = parseTrailingTagComments(start2, getNodePos(), indent3, indentText); + const nestedTypeLiteral = parseNestedTypeLiteral(typeExpression, name, target, indent3); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; @@ -24566,12 +24611,12 @@ var Parser; const result2 = target === 1 /* Property */ ? factory2.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) : factory2.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment); return finishNode(result2, start2); } - function parseNestedTypeLiteral(typeExpression, name, target, indent2) { + function parseNestedTypeLiteral(typeExpression, name, target, indent3) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { const pos = getNodePos(); let child; let children; - while (child = tryParse(() => parseChildParameterOrPropertyTag(target, indent2, name))) { + while (child = tryParse(() => parseChildParameterOrPropertyTag(target, indent3, name))) { if (child.kind === 348 /* JSDocParameterTag */ || child.kind === 355 /* JSDocPropertyTag */) { children = append(children, child); } else if (child.kind === 352 /* JSDocTemplateTag */) { @@ -24584,14 +24629,14 @@ var Parser; } } } - function parseReturnTag(start2, tagName, indent2, indentText) { + function parseReturnTag(start2, tagName, indent3, indentText) { if (some(tags, isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenStart(), Diagnostics._0_tag_already_specified, unescapeLeadingUnderscores(tagName.escapedText)); } const typeExpression = tryParseTypeExpression(); - return finishNode(factory2.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start2, getNodePos(), indent2, indentText)), start2); + return finishNode(factory2.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start2, getNodePos(), indent3, indentText)), start2); } - function parseTypeTag(start2, tagName, indent2, indentText) { + function parseTypeTag(start2, tagName, indent3, indentText) { if (some(tags, isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenStart(), Diagnostics._0_tag_already_specified, unescapeLeadingUnderscores(tagName.escapedText)); } @@ -24599,25 +24644,25 @@ var Parser; /*mayOmitBraces*/ true ); - const comments2 = indent2 !== void 0 && indentText !== void 0 ? parseTrailingTagComments(start2, getNodePos(), indent2, indentText) : void 0; + const comments2 = indent3 !== void 0 && indentText !== void 0 ? parseTrailingTagComments(start2, getNodePos(), indent3, indentText) : void 0; return finishNode(factory2.createJSDocTypeTag(tagName, typeExpression, comments2), start2); } - function parseSeeTag(start2, tagName, indent2, indentText) { + function parseSeeTag(start2, tagName, indent3, indentText) { const isMarkdownOrJSDocLink = token() === 23 /* OpenBracketToken */ || lookAhead(() => nextTokenJSDoc() === 60 /* AtToken */ && tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue())); const nameExpression = isMarkdownOrJSDocLink ? void 0 : parseJSDocNameReference(); - const comments2 = indent2 !== void 0 && indentText !== void 0 ? parseTrailingTagComments(start2, getNodePos(), indent2, indentText) : void 0; + const comments2 = indent3 !== void 0 && indentText !== void 0 ? parseTrailingTagComments(start2, getNodePos(), indent3, indentText) : void 0; return finishNode(factory2.createJSDocSeeTag(tagName, nameExpression, comments2), start2); } - function parseThrowsTag(start2, tagName, indent2, indentText) { + function parseThrowsTag(start2, tagName, indent3, indentText) { const typeExpression = tryParseTypeExpression(); - const comment = parseTrailingTagComments(start2, getNodePos(), indent2, indentText); + const comment = parseTrailingTagComments(start2, getNodePos(), indent3, indentText); return finishNode(factory2.createJSDocThrowsTag(tagName, typeExpression, comment), start2); } - function parseAuthorTag(start2, tagName, indent2, indentText) { + function parseAuthorTag(start2, tagName, indent3, indentText) { const commentStart = getNodePos(); const textOnly = parseAuthorNameAndEmail(); let commentEnd = scanner.getTokenFullStart(); - const comments2 = parseTrailingTagComments(start2, commentEnd, indent2, indentText); + const comments2 = parseTrailingTagComments(start2, commentEnd, indent3, indentText); if (!comments2) { commentEnd = scanner.getTokenFullStart(); } @@ -24701,19 +24746,19 @@ var Parser; skipWhitespace(); return finishNode(factory2.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start2, getNodePos(), margin, indentText)), start2); } - function parseTypedefTag(start2, tagName, indent2, indentText) { + function parseTypedefTag(start2, tagName, indent3, indentText) { let typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); const fullName = parseJSDocTypeNameWithNamespace(); skipWhitespace(); - let comment = parseTagComments(indent2); + let comment = parseTagComments(indent3); let end2; if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) { let child; let childTypeTag; let jsDocPropertyTags; let hasChildren = false; - while (child = tryParse(() => parseChildPropertyTag(indent2))) { + while (child = tryParse(() => parseChildPropertyTag(indent3))) { if (child.kind === 352 /* JSDocTemplateTag */) { break; } @@ -24741,7 +24786,7 @@ var Parser; } end2 = end2 || comment !== void 0 ? getNodePos() : (fullName ?? typeExpression ?? tagName).end; if (!comment) { - comment = parseTrailingTagComments(start2, end2, indent2, indentText); + comment = parseTrailingTagComments(start2, end2, indent3, indentText); } const typedefTag = factory2.createJSDocTypedefTag(tagName, typeExpression, fullName, comment); return finishNode(typedefTag, start2, end2); @@ -24771,11 +24816,11 @@ var Parser; } return typeNameOrNamespaceName; } - function parseCallbackTagParameters(indent2) { + function parseCallbackTagParameters(indent3) { const pos = getNodePos(); let child; let parameters; - while (child = tryParse(() => parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent2))) { + while (child = tryParse(() => parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent3))) { if (child.kind === 352 /* JSDocTemplateTag */) { parseErrorAtRange(child.tagName, Diagnostics.A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag); break; @@ -24784,11 +24829,11 @@ var Parser; } return createNodeArray(parameters || [], pos); } - function parseJSDocSignature(start2, indent2) { - const parameters = parseCallbackTagParameters(indent2); + function parseJSDocSignature(start2, indent3) { + const parameters = parseCallbackTagParameters(indent3); const returnTag = tryParse(() => { if (parseOptionalJsdoc(60 /* AtToken */)) { - const tag = parseTag(indent2); + const tag = parseTag(indent3); if (tag && tag.kind === 349 /* JSDocReturnTag */) { return tag; } @@ -24801,23 +24846,23 @@ var Parser; returnTag ), start2); } - function parseCallbackTag(start2, tagName, indent2, indentText) { + function parseCallbackTag(start2, tagName, indent3, indentText) { const fullName = parseJSDocTypeNameWithNamespace(); skipWhitespace(); - let comment = parseTagComments(indent2); - const typeExpression = parseJSDocSignature(start2, indent2); + let comment = parseTagComments(indent3); + const typeExpression = parseJSDocSignature(start2, indent3); if (!comment) { - comment = parseTrailingTagComments(start2, getNodePos(), indent2, indentText); + comment = parseTrailingTagComments(start2, getNodePos(), indent3, indentText); } const end2 = comment !== void 0 ? getNodePos() : typeExpression.end; return finishNode(factory2.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start2, end2); } - function parseOverloadTag(start2, tagName, indent2, indentText) { + function parseOverloadTag(start2, tagName, indent3, indentText) { skipWhitespace(); - let comment = parseTagComments(indent2); - const typeExpression = parseJSDocSignature(start2, indent2); + let comment = parseTagComments(indent3); + const typeExpression = parseJSDocSignature(start2, indent3); if (!comment) { - comment = parseTrailingTagComments(start2, getNodePos(), indent2, indentText); + comment = parseTrailingTagComments(start2, getNodePos(), indent3, indentText); } const end2 = comment !== void 0 ? getNodePos() : typeExpression.end; return finishNode(factory2.createJSDocOverloadTag(tagName, typeExpression, comment), start2, end2); @@ -24833,17 +24878,17 @@ var Parser; } return a.escapedText === b.escapedText; } - function parseChildPropertyTag(indent2) { - return parseChildParameterOrPropertyTag(1 /* Property */, indent2); + function parseChildPropertyTag(indent3) { + return parseChildParameterOrPropertyTag(1 /* Property */, indent3); } - function parseChildParameterOrPropertyTag(target, indent2, name) { + function parseChildParameterOrPropertyTag(target, indent3, name) { let canParseTag = true; let seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { case 60 /* AtToken */: if (canParseTag) { - const child = tryParseChildTag(target, indent2); + const child = tryParseChildTag(target, indent3); if (child && (child.kind === 348 /* JSDocParameterTag */ || child.kind === 355 /* JSDocPropertyTag */) && name && (isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } @@ -24869,7 +24914,7 @@ var Parser; } } } - function tryParseChildTag(target, indent2) { + function tryParseChildTag(target, indent3) { Debug.assert(token() === 60 /* AtToken */); const start2 = scanner.getTokenFullStart(); nextTokenJSDoc(); @@ -24889,14 +24934,14 @@ var Parser; t = 2 /* Parameter */ | 4 /* CallbackParameter */; break; case "template": - return parseTemplateTag(start2, tagName, indent2, indentText); + return parseTemplateTag(start2, tagName, indent3, indentText); default: return false; } if (!(target & t)) { return false; } - return parseParameterOrPropertyTag(start2, tagName, target, indent2); + return parseParameterOrPropertyTag(start2, tagName, target, indent3); } function parseTemplateTagTypeParameter() { const typeParameterPos = getNodePos(); @@ -24937,10 +24982,10 @@ var Parser; } while (parseOptionalJsdoc(28 /* CommaToken */)); return createNodeArray(typeParameters, pos); } - function parseTemplateTag(start2, tagName, indent2, indentText) { + function parseTemplateTag(start2, tagName, indent3, indentText) { const constraint = token() === 19 /* OpenBraceToken */ ? parseJSDocTypeExpression() : void 0; const typeParameters = parseTemplateTagTypeParameters(); - return finishNode(factory2.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start2, getNodePos(), indent2, indentText)), start2); + return finishNode(factory2.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start2, getNodePos(), indent3, indentText)), start2); } function parseOptionalJsdoc(t) { if (token() === t) { @@ -26652,7 +26697,7 @@ var commandOptionsWithoutBuild = [ affectsBuildInfo: true, affectsDeclarationPath: true, isFilePath: false, - // This is intentionally broken to support compatability with existing tsconfig files + // This is intentionally broken to support compatibility with existing tsconfig files // for correct behaviour, please use outFile category: Diagnostics.Backwards_Compatibility, paramType: Diagnostics.FILE, @@ -27367,7 +27412,7 @@ function formatExtensions(extensions) { result.push("JSON"); return result.join(", "); } -function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state, legacyResult) { +function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state, cache, legacyResult) { if (!state.resultFromCache && !state.compilerOptions.preserveSymlinks && resolved && isExternalLibraryImport && !resolved.originalPath && !isExternalModuleNameRelative(moduleName)) { const { resolvedFileName, originalPath } = getOriginalAndResolvedFileName(resolved.path, state.host, state.traceEnabled); if (originalPath) @@ -27380,15 +27425,25 @@ function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName affectingLocations, diagnostics, state.resultFromCache, + cache, legacyResult ); } -function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, legacyResult) { +function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, cache, legacyResult) { if (resultFromCache) { - resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations); - resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations); - resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics); - return resultFromCache; + if (!(cache == null ? void 0 : cache.isReadonly)) { + resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations); + resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations); + resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics); + return resultFromCache; + } else { + return { + ...resultFromCache, + failedLookupLocations: initializeResolutionFieldForReadonlyCache(resultFromCache.failedLookupLocations, failedLookupLocations), + affectingLocations: initializeResolutionFieldForReadonlyCache(resultFromCache.affectingLocations, affectingLocations), + resolutionDiagnostics: initializeResolutionFieldForReadonlyCache(resultFromCache.resolutionDiagnostics, diagnostics) + }; + } } return { resolvedModule: resolved && { @@ -27416,6 +27471,13 @@ function updateResolutionField(to, value) { to.push(...value); return to; } +function initializeResolutionFieldForReadonlyCache(fromCache, value) { + if (!(fromCache == null ? void 0 : fromCache.length)) + return initializeResolutionField(value); + if (!value.length) + return fromCache.slice(); + return [...fromCache, ...value]; +} function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) { if (!hasProperty(jsonContent, fieldName)) { if (state.traceEnabled) { @@ -27553,16 +27615,16 @@ function getNodeResolutionFeatures(options) { } return features; } -function getConditions(options, esmMode) { +function getConditions(options, resolutionMode) { const moduleResolution = getEmitModuleResolutionKind(options); - if (esmMode === void 0) { + if (resolutionMode === void 0) { if (moduleResolution === 100 /* Bundler */) { - esmMode ?? (esmMode = moduleResolution === 100 /* Bundler */); + resolutionMode = 99 /* ESNext */; } else if (moduleResolution === 2 /* Node10 */) { return []; } } - const conditions = esmMode ? ["import"] : ["require"]; + const conditions = resolutionMode === 99 /* ESNext */ ? ["import"] : ["require"]; if (!options.noDtsResolution) { conditions.push("types"); } @@ -27623,13 +27685,13 @@ function resolveModuleName(moduleName, containingFile, compilerOptions, host, ca result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); break; case 2 /* Node10 */: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode === 99 /* ESNext */) : void 0); + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode) : void 0); break; case 1 /* Classic */: result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; case 100 /* Bundler */: - result = bundlerModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode === 99 /* ESNext */) : void 0); + result = bundlerModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode) : void 0); break; default: return Debug.fail(`Unexpected moduleResolution: ${moduleResolution}`); @@ -27637,9 +27699,11 @@ function resolveModuleName(moduleName, containingFile, compilerOptions, host, ca if (result && result.resolvedModule) (_b = perfLogger) == null ? void 0 : _b.logInfoEvent(`Module "${moduleName}" resolved to "${result.resolvedModule.resolvedFileName}"`); (_c = perfLogger) == null ? void 0 : _c.logStopResolveModule(result && result.resolvedModule ? "" + result.resolvedModule.resolvedFileName : "null"); - cache == null ? void 0 : cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result); - if (!isExternalModuleNameRelative(moduleName)) { - cache == null ? void 0 : cache.getOrCreateCacheForNonRelativeName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result); + if (cache && !cache.isReadonly) { + cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result); + if (!isExternalModuleNameRelative(moduleName)) { + cache.getOrCreateCacheForNonRelativeName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result); + } } } if (traceEnabled) { @@ -27874,7 +27938,7 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, const moduleResolution = getEmitModuleResolutionKind(compilerOptions); conditions ?? (conditions = getConditions( compilerOptions, - moduleResolution === 100 /* Bundler */ || moduleResolution === 2 /* Node10 */ ? void 0 : !!(features & 32 /* EsmMode */) + moduleResolution === 100 /* Bundler */ || moduleResolution === 2 /* Node10 */ ? void 0 : features & 32 /* EsmMode */ ? 99 /* ESNext */ : 1 /* CommonJS */ )); const diagnostics = []; const state = { @@ -27923,6 +27987,7 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, affectingLocations, diagnostics, state, + cache, legacyResult ); function tryResolve(extensions2, state2) { @@ -28186,7 +28251,7 @@ function getVersionPathsOfPackageJsonInfo(packageJsonInfo, state) { return packageJsonInfo.contents.versionPaths || void 0; } function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) { - var _a, _b, _c, _d, _e, _f, _g, _h; + var _a, _b, _c, _d, _e, _f; const { host, traceEnabled } = state; const packageJsonPath = combinePaths(packageDirectory, "package.json"); if (onlyRecordFailures) { @@ -28214,15 +28279,17 @@ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) { trace(host, Diagnostics.Found_package_json_at_0, packageJsonPath); } const result = { packageDirectory, contents: { packageJsonContent, versionPaths: void 0, resolvedEntrypoints: void 0 } }; - (_e = state.packageJsonInfoCache) == null ? void 0 : _e.setPackageJsonInfo(packageJsonPath, result); - (_f = state.affectingLocations) == null ? void 0 : _f.push(packageJsonPath); + if (state.packageJsonInfoCache && !state.packageJsonInfoCache.isReadonly) + state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, result); + (_e = state.affectingLocations) == null ? void 0 : _e.push(packageJsonPath); return result; } else { if (directoryExists && traceEnabled) { trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath); } - (_g = state.packageJsonInfoCache) == null ? void 0 : _g.setPackageJsonInfo(packageJsonPath, directoryExists); - (_h = state.failedLookupLocations) == null ? void 0 : _h.push(packageJsonPath); + if (state.packageJsonInfoCache && !state.packageJsonInfoCache.isReadonly) + state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, directoryExists); + (_f = state.failedLookupLocations) == null ? void 0 : _f.push(packageJsonPath); } } function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) { @@ -28999,7 +29066,8 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host, failedLookupLocations, affectingLocations, diagnostics, - state + state, + cache ); function tryResolve(extensions) { const resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state); @@ -31381,6 +31449,42 @@ __export(ts_JsTyping_exports, { validatePackageName: () => validatePackageName }); +// src/jsTyping/shared.ts +var ActionSet = "action::set"; +var ActionPackageInstalled = "action::packageInstalled"; +var EventTypesRegistry = "event::typesRegistry"; +var EventBeginInstallTypes = "event::beginInstallTypes"; +var EventEndInstallTypes = "event::endInstallTypes"; +var ActionWatchTypingLocations = "action::watchTypingLocations"; +var Arguments; +((Arguments2) => { + Arguments2.GlobalCacheLocation = "--globalTypingsCacheLocation"; + Arguments2.LogFile = "--logFile"; + Arguments2.EnableTelemetry = "--enableTelemetry"; + Arguments2.TypingSafeListLocation = "--typingSafeListLocation"; + Arguments2.TypesMapLocation = "--typesMapLocation"; + Arguments2.NpmLocation = "--npmLocation"; + Arguments2.ValidateDefaultNpmLocation = "--validateDefaultNpmLocation"; +})(Arguments || (Arguments = {})); +function hasArgument(argumentName) { + return sys.args.includes(argumentName); +} +function findArgument(argumentName) { + const index = sys.args.indexOf(argumentName); + return index >= 0 && index < sys.args.length - 1 ? sys.args[index + 1] : void 0; +} +function nowString() { + const d = /* @__PURE__ */ new Date(); + return `${d.getHours().toString().padStart(2, "0")}:${d.getMinutes().toString().padStart(2, "0")}:${d.getSeconds().toString().padStart(2, "0")}.${d.getMilliseconds().toString().padStart(3, "0")}`; +} +var indentStr = "\n "; +function indent(str) { + return indentStr + str.replace(/\n/g, indentStr); +} +function stringifyIndented(json) { + return indent(JSON.stringify(json, void 0, 2)); +} + // src/jsTyping/jsTyping.ts function isTypingUpToDate(cachedTyping, availableTypingVersions) { const availableVersion = new Version(getProperty(availableTypingVersions, `ts${versionMajorMinor}`) || getProperty(availableTypingVersions, "latest")); @@ -31487,21 +31591,21 @@ function discoverTypings(host, log2, fileNames, projectRootPath, safeList, packa ); addInferredTypings(module2, "Inferred typings from unresolved imports"); } - packageNameToTypingLocation.forEach((typing, name) => { - const registryEntry = typesRegistry.get(name); - if (inferredTypings.has(name) && inferredTypings.get(name) === void 0 && registryEntry !== void 0 && isTypingUpToDate(typing, registryEntry)) { - inferredTypings.set(name, typing.typingLocation); - } - }); for (const excludeTypingName of exclude) { const didDelete = inferredTypings.delete(excludeTypingName); if (didDelete && log2) log2(`Typing for ${excludeTypingName} is in exclude list, will be ignored.`); } + packageNameToTypingLocation.forEach((typing, name) => { + const registryEntry = typesRegistry.get(name); + if (inferredTypings.get(name) === false && registryEntry !== void 0 && isTypingUpToDate(typing, registryEntry)) { + inferredTypings.set(name, typing.typingLocation); + } + }); const newTypingNames = []; const cachedTypingPaths = []; inferredTypings.forEach((inferred, typing) => { - if (inferred !== void 0) { + if (inferred) { cachedTypingPaths.push(inferred); } else { newTypingNames.push(typing); @@ -31509,11 +31613,11 @@ function discoverTypings(host, log2, fileNames, projectRootPath, safeList, packa }); const result = { cachedTypingPaths, newTypingNames, filesToWatch }; if (log2) - log2(`Result: ${JSON.stringify(result)}`); + log2(`Finished typings discovery:${stringifyIndented(result)}`); return result; function addInferredTyping(typingName) { if (!inferredTypings.has(typingName)) { - inferredTypings.set(typingName, void 0); + inferredTypings.set(typingName, false); } } function addInferredTypings(typingNames, message) { @@ -31686,35 +31790,6 @@ function renderPackageNameValidationFailureWorker(typing, result, name, isScopeN } } -// src/jsTyping/shared.ts -var ActionSet = "action::set"; -var ActionPackageInstalled = "action::packageInstalled"; -var EventTypesRegistry = "event::typesRegistry"; -var EventBeginInstallTypes = "event::beginInstallTypes"; -var EventEndInstallTypes = "event::endInstallTypes"; -var ActionWatchTypingLocations = "action::watchTypingLocations"; -var Arguments; -((Arguments2) => { - Arguments2.GlobalCacheLocation = "--globalTypingsCacheLocation"; - Arguments2.LogFile = "--logFile"; - Arguments2.EnableTelemetry = "--enableTelemetry"; - Arguments2.TypingSafeListLocation = "--typingSafeListLocation"; - Arguments2.TypesMapLocation = "--typesMapLocation"; - Arguments2.NpmLocation = "--npmLocation"; - Arguments2.ValidateDefaultNpmLocation = "--validateDefaultNpmLocation"; -})(Arguments || (Arguments = {})); -function hasArgument(argumentName) { - return sys.args.includes(argumentName); -} -function findArgument(argumentName) { - const index = sys.args.indexOf(argumentName); - return index >= 0 && index < sys.args.length - 1 ? sys.args[index + 1] : void 0; -} -function nowString() { - const d = /* @__PURE__ */ new Date(); - return `${d.getHours().toString().padStart(2, "0")}:${d.getMinutes().toString().padStart(2, "0")}:${d.getSeconds().toString().padStart(2, "0")}.${d.getMilliseconds().toString().padStart(3, "0")}`; -} - // src/typingsInstallerCore/typingsInstaller.ts var nullLog = { isEnabled: () => false, @@ -31797,7 +31872,7 @@ var TypingsInstaller = class { } install(req) { if (this.log.isEnabled()) { - this.log.writeLine(`Got install request ${JSON.stringify(req)}`); + this.log.writeLine(`Got install request${stringifyIndented(req)}`); } if (req.cachePath) { if (this.log.isEnabled()) { @@ -31820,9 +31895,6 @@ var TypingsInstaller = class { this.typesRegistry, req.compilerOptions ); - if (this.log.isEnabled()) { - this.log.writeLine(`Finished typings discovery: ${JSON.stringify(discoverTypingsResult)}`); - } this.watchFiles(req.projectName, discoverTypingsResult.filesToWatch); if (discoverTypingsResult.newTypingNames.length) { this.installTypings(req, req.cachePath || this.globalCachePath, discoverTypingsResult.cachedTypingPaths, discoverTypingsResult.newTypingNames); @@ -31864,8 +31936,8 @@ var TypingsInstaller = class { const npmConfig = JSON.parse(this.installTypingHost.readFile(packageJson)); const npmLock = JSON.parse(this.installTypingHost.readFile(packageLockJson)); if (this.log.isEnabled()) { - this.log.writeLine(`Loaded content of '${packageJson}': ${JSON.stringify(npmConfig)}`); - this.log.writeLine(`Loaded content of '${packageLockJson}'`); + this.log.writeLine(`Loaded content of '${packageJson}':${stringifyIndented(npmConfig)}`); + this.log.writeLine(`Loaded content of '${packageLockJson}':${stringifyIndented(npmLock)}`); } if (npmConfig.devDependencies && npmLock.dependencies) { for (const key in npmConfig.devDependencies) { @@ -32203,8 +32275,7 @@ var NodeTypingsInstaller = class extends TypingsInstaller { } sendResponse(response) { if (this.log.isEnabled()) { - this.log.writeLine(`Sending response: - ${JSON.stringify(response)}`); + this.log.writeLine(`Sending response:${stringifyIndented(response)}`); } process.send(response); if (this.log.isEnabled()) { @@ -32230,12 +32301,12 @@ var NodeTypingsInstaller = class extends TypingsInstaller { try { const stdout = this.nodeExecSync(command, { ...options, encoding: "utf-8" }); if (this.log.isEnabled()) { - this.log.writeLine(` Succeeded. stdout:${indent(sys.newLine, stdout)}`); + this.log.writeLine(` Succeeded. stdout:${indent2(sys.newLine, stdout)}`); } return false; } catch (error) { const { stdout, stderr } = error; - this.log.writeLine(` Failed. stdout:${indent(sys.newLine, stdout)}${sys.newLine} stderr:${indent(sys.newLine, stderr)}`); + this.log.writeLine(` Failed. stdout:${indent2(sys.newLine, stdout)}${sys.newLine} stderr:${indent2(sys.newLine, stderr)}`); return true; } } @@ -32279,7 +32350,7 @@ process.on("message", (req) => { )); installer.handleRequest(req); }); -function indent(newline, str) { +function indent2(newline, str) { return str && str.length ? `${newline} ` + str.replace(/\r?\n/, `${newline} `) : ""; } // Annotate the CommonJS export names for ESM import in node: