@typescript-deploys/pr-build 4.7.0-pr-48112-6 → 4.7.0-pr-47172-7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-insiders.20220304";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220305";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -8901,7 +8901,6 @@ var ts;
8901
8901
  Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"),
8902
8902
  Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."),
8903
8903
  Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."),
8904
- All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."),
8905
8904
  Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
8906
8905
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
8907
8906
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -21208,7 +21207,6 @@ var ts;
21208
21207
  parenthesizeExpressionForDisallowedComma: parenthesizeExpressionForDisallowedComma,
21209
21208
  parenthesizeExpressionOfExpressionStatement: parenthesizeExpressionOfExpressionStatement,
21210
21209
  parenthesizeConciseBodyOfArrowFunction: parenthesizeConciseBodyOfArrowFunction,
21211
- parenthesizeCheckTypeOfConditionalType: parenthesizeCheckTypeOfConditionalType,
21212
21210
  parenthesizeMemberOfConditionalType: parenthesizeMemberOfConditionalType,
21213
21211
  parenthesizeMemberOfElementType: parenthesizeMemberOfElementType,
21214
21212
  parenthesizeElementTypeOfArrayType: parenthesizeElementTypeOfArrayType,
@@ -21525,10 +21523,6 @@ var ts;
21525
21523
  }
21526
21524
  return body;
21527
21525
  }
21528
- function parenthesizeCheckTypeOfConditionalType(member) {
21529
- return ts.isInferTypeNode(member) ? factory.createParenthesizedType(member) :
21530
- parenthesizeMemberOfConditionalType(member);
21531
- }
21532
21526
  function parenthesizeMemberOfConditionalType(member) {
21533
21527
  return member.kind === 188 /* ConditionalType */ ? factory.createParenthesizedType(member) : member;
21534
21528
  }
@@ -21581,7 +21575,6 @@ var ts;
21581
21575
  parenthesizeExpressionForDisallowedComma: ts.identity,
21582
21576
  parenthesizeExpressionOfExpressionStatement: ts.identity,
21583
21577
  parenthesizeConciseBodyOfArrowFunction: ts.identity,
21584
- parenthesizeCheckTypeOfConditionalType: ts.identity,
21585
21578
  parenthesizeMemberOfConditionalType: ts.identity,
21586
21579
  parenthesizeMemberOfElementType: ts.identity,
21587
21580
  parenthesizeElementTypeOfArrayType: ts.identity,
@@ -23198,7 +23191,7 @@ var ts;
23198
23191
  // @api
23199
23192
  function createConditionalTypeNode(checkType, extendsType, trueType, falseType) {
23200
23193
  var node = createBaseNode(188 /* ConditionalType */);
23201
- node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType);
23194
+ node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType);
23202
23195
  node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType);
23203
23196
  node.trueType = trueType;
23204
23197
  node.falseType = falseType;
@@ -32772,9 +32765,6 @@ var ts;
32772
32765
  return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos);
32773
32766
  }
32774
32767
  function parseTypeParameter() {
32775
- return parseTypeParameterWorker(/*canHaveDefault*/ true);
32776
- }
32777
- function parseTypeParameterWorker(canHaveDefault) {
32778
32768
  var pos = getNodePos();
32779
32769
  var name = parseIdentifier();
32780
32770
  var constraint;
@@ -32798,7 +32788,7 @@ var ts;
32798
32788
  expression = parseUnaryExpressionOrHigher();
32799
32789
  }
32800
32790
  }
32801
- var defaultType = canHaveDefault && parseOptional(63 /* EqualsToken */) ? parseType() : undefined;
32791
+ var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined;
32802
32792
  var node = factory.createTypeParameterDeclaration(name, constraint, defaultType);
32803
32793
  node.expression = expression;
32804
32794
  return finishNode(node, pos);
@@ -33463,10 +33453,16 @@ var ts;
33463
33453
  parseExpected(operator);
33464
33454
  return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos);
33465
33455
  }
33456
+ function parseTypeParameterOfInferType() {
33457
+ var pos = getNodePos();
33458
+ return finishNode(factory.createTypeParameterDeclaration(parseIdentifier(),
33459
+ /*constraint*/ undefined,
33460
+ /*defaultType*/ undefined), pos);
33461
+ }
33466
33462
  function parseInferType() {
33467
33463
  var pos = getNodePos();
33468
33464
  parseExpected(137 /* InferKeyword */);
33469
- return finishNode(factory.createInferTypeNode(parseTypeParameterWorker(/*canHaveDefault*/ false)), pos);
33465
+ return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos);
33470
33466
  }
33471
33467
  function parseTypeOperatorOrHigher() {
33472
33468
  var operator = token();
@@ -39434,7 +39430,8 @@ var ts;
39434
39430
  name: "jsxFragmentFactory",
39435
39431
  type: "string",
39436
39432
  category: ts.Diagnostics.Language_and_Environment,
39437
- description: ts.Diagnostics.Specify_the_JSX_Fragment_reference_used_for_fragments_when_targeting_React_JSX_emit_e_g_React_Fragment_or_Fragment
39433
+ description: ts.Diagnostics.Specify_the_JSX_Fragment_reference_used_for_fragments_when_targeting_React_JSX_emit_e_g_React_Fragment_or_Fragment,
39434
+ defaultValueDescription: "React.Fragment",
39438
39435
  },
39439
39436
  {
39440
39437
  name: "jsxImportSource",
@@ -44523,7 +44520,7 @@ var ts;
44523
44520
  return ts.isDottedName(expr)
44524
44521
  || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression)
44525
44522
  || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right)
44526
- || ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression)
44523
+ || ts.isElementAccessExpression(expr) && (ts.isStringOrNumericLiteralLike(expr.argumentExpression) || ts.isEntityNameExpression(expr.argumentExpression)) && isNarrowableReference(expr.expression)
44527
44524
  || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left);
44528
44525
  }
44529
44526
  function containsNarrowableReference(expr) {
@@ -52759,7 +52756,15 @@ var ts;
52759
52756
  });
52760
52757
  }
52761
52758
  }
52762
- if (!symbolName) {
52759
+ if (symbolName === undefined) {
52760
+ var name = ts.firstDefined(symbol.declarations, ts.getNameOfDeclaration);
52761
+ if (name && ts.isComputedPropertyName(name) && ts.isEntityName(name.expression)) {
52762
+ var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
52763
+ if (ts.isEntityName(LHS)) {
52764
+ return ts.factory.createIndexedAccessTypeNode(ts.factory.createParenthesizedType(ts.factory.createTypeQueryNode(LHS)), ts.factory.createTypeQueryNode(name.expression));
52765
+ }
52766
+ return LHS;
52767
+ }
52763
52768
  symbolName = getNameOfSymbolAsWritten(symbol, context);
52764
52769
  }
52765
52770
  context.approximateLength += symbolName.length + 1;
@@ -65499,7 +65504,7 @@ var ts;
65499
65504
  var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source);
65500
65505
  var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties, /*matchDiscriminantProperties*/ false);
65501
65506
  if (unmatchedProperty) {
65502
- if (reportErrors) {
65507
+ if (reportErrors && shouldReportUnmatchedPropertyError(source, target)) {
65503
65508
  reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties);
65504
65509
  }
65505
65510
  return 0 /* False */;
@@ -65655,6 +65660,19 @@ var ts;
65655
65660
  }
65656
65661
  return result;
65657
65662
  }
65663
+ function shouldReportUnmatchedPropertyError(source, target) {
65664
+ var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* Call */);
65665
+ var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* Construct */);
65666
+ var typeProperties = getPropertiesOfObjectType(source);
65667
+ if ((typeCallSignatures.length || typeConstructSignatures.length) && !typeProperties.length) {
65668
+ if ((getSignaturesOfType(target, 0 /* Call */).length && typeCallSignatures.length) ||
65669
+ (getSignaturesOfType(target, 1 /* Construct */).length && typeConstructSignatures.length)) {
65670
+ return true; // target has similar signature kinds to source, still focus on the unmatched property
65671
+ }
65672
+ return false;
65673
+ }
65674
+ return true;
65675
+ }
65658
65676
  function reportIncompatibleCallSignatureReturn(siga, sigb) {
65659
65677
  if (siga.parameters.length === 0 && sigb.parameters.length === 0) {
65660
65678
  return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); };
@@ -68230,8 +68248,9 @@ var ts;
68230
68248
  return isMatchingReference(source.expression, target);
68231
68249
  case 205 /* PropertyAccessExpression */:
68232
68250
  case 206 /* ElementAccessExpression */:
68233
- return ts.isAccessExpression(target) &&
68234
- getAccessedPropertyName(source) === getAccessedPropertyName(target) &&
68251
+ var sourcePropertyName = getAccessedPropertyName(source);
68252
+ var targetPropertyName = ts.isAccessExpression(target) ? getAccessedPropertyName(target) : undefined;
68253
+ return sourcePropertyName !== undefined && targetPropertyName !== undefined && targetPropertyName === sourcePropertyName &&
68235
68254
  isMatchingReference(source.expression, target.expression);
68236
68255
  case 160 /* QualifiedName */:
68237
68256
  return ts.isAccessExpression(target) &&
@@ -68243,12 +68262,49 @@ var ts;
68243
68262
  return false;
68244
68263
  }
68245
68264
  function getAccessedPropertyName(access) {
68246
- var propertyName;
68247
- return access.kind === 205 /* PropertyAccessExpression */ ? access.name.escapedText :
68248
- access.kind === 206 /* ElementAccessExpression */ && ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) :
68249
- access.kind === 202 /* BindingElement */ && (propertyName = getDestructuringPropertyName(access)) ? ts.escapeLeadingUnderscores(propertyName) :
68250
- access.kind === 163 /* Parameter */ ? ("" + access.parent.parameters.indexOf(access)) :
68251
- undefined;
68265
+ if (ts.isPropertyAccessExpression(access)) {
68266
+ return access.name.escapedText;
68267
+ }
68268
+ if (ts.isElementAccessExpression(access)) {
68269
+ return tryGetElementAccessExpressionName(access);
68270
+ }
68271
+ if (ts.isBindingElement(access)) {
68272
+ var name = getDestructuringPropertyName(access);
68273
+ return name ? ts.escapeLeadingUnderscores(name) : undefined;
68274
+ }
68275
+ if (ts.isParameter(access)) {
68276
+ return ("" + access.parent.parameters.indexOf(access));
68277
+ }
68278
+ return undefined;
68279
+ }
68280
+ function tryGetNameFromType(type) {
68281
+ return type.flags & 8192 /* UniqueESSymbol */ ? type.escapedName :
68282
+ type.flags & 384 /* StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined;
68283
+ }
68284
+ function tryGetElementAccessExpressionName(node) {
68285
+ if (ts.isStringOrNumericLiteralLike(node.argumentExpression)) {
68286
+ return ts.escapeLeadingUnderscores(node.argumentExpression.text);
68287
+ }
68288
+ if (ts.isEntityNameExpression(node.argumentExpression)) {
68289
+ var symbol = resolveEntityName(node.argumentExpression, 111551 /* Value */, /*ignoreErrors*/ true);
68290
+ if (!symbol || !isConstVariable(symbol))
68291
+ return undefined;
68292
+ var declaration = symbol.valueDeclaration;
68293
+ if (declaration === undefined)
68294
+ return undefined;
68295
+ var type = tryGetTypeFromEffectiveTypeNode(declaration);
68296
+ if (type) {
68297
+ var name = tryGetNameFromType(type);
68298
+ if (name !== undefined) {
68299
+ return name;
68300
+ }
68301
+ }
68302
+ if (ts.hasOnlyExpressionInitializer(declaration)) {
68303
+ var initializer = ts.getEffectiveInitializer(declaration);
68304
+ return initializer && tryGetNameFromType(getTypeOfExpression(initializer));
68305
+ }
68306
+ }
68307
+ return undefined;
68252
68308
  }
68253
68309
  function containsMatchingReference(source, target) {
68254
68310
  while (ts.isAccessExpression(source)) {
@@ -70142,6 +70198,14 @@ var ts;
70142
70198
  // the candidate type. If one or more constituents remain, return a union of those.
70143
70199
  if (type.flags & 1048576 /* Union */) {
70144
70200
  var assignableType = filterType(type, function (t) { return isRelated(t, candidate); });
70201
+ if (candidate.flags & 1048576 /* Union */) {
70202
+ var unionAssignableType = mapType(type, function (type) {
70203
+ return filterType(candidate, function (candidate) { return isRelated(candidate, type); });
70204
+ });
70205
+ if (!isTypeSubtypeOf(unionAssignableType, assignableType)) {
70206
+ assignableType = unionAssignableType;
70207
+ }
70208
+ }
70145
70209
  if (!(assignableType.flags & 131072 /* Never */)) {
70146
70210
  return assignableType;
70147
70211
  }
@@ -71754,11 +71818,21 @@ var ts;
71754
71818
  }
71755
71819
  return false;
71756
71820
  }
71821
+ function uniqueStrings(strings) {
71822
+ var unique = new ts.Set(strings);
71823
+ var result = [];
71824
+ unique.forEach(function (str) { return result.push(str); });
71825
+ return result;
71826
+ }
71757
71827
  function discriminateContextualTypeByObjectMembers(node, contextualType) {
71758
- return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 295 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType);
71828
+ return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 295 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(uniqueStrings(ts.flatMap(contextualType.types, function (memberType) {
71829
+ return ts.map(ts.filter(getPropertiesOfType(memberType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return s.escapedName; });
71830
+ })), function (name) { return [function () { return undefinedType; }, name]; })), isTypeAssignableTo, contextualType);
71759
71831
  }
71760
71832
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
71761
- return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 284 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType);
71833
+ return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 284 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(uniqueStrings(ts.flatMap(contextualType.types, function (memberType) {
71834
+ return ts.map(ts.filter(getPropertiesOfType(memberType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return s.escapedName; });
71835
+ })), function (name) { return [function () { return undefinedType; }, name]; })), isTypeAssignableTo, contextualType);
71762
71836
  }
71763
71837
  // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily
71764
71838
  // be "pushed" onto a node using the contextualType property.
@@ -73253,21 +73327,20 @@ var ts;
73253
73327
  // of the property as base classes
73254
73328
  var enclosingClass = forEachEnclosingClass(location, function (enclosingDeclaration) {
73255
73329
  var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration));
73256
- return isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing) ? enclosingClass : undefined;
73330
+ return isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing);
73257
73331
  });
73258
73332
  // A protected property is accessible if the property is within the declaring class or classes derived from it
73259
73333
  if (!enclosingClass) {
73260
73334
  // allow PropertyAccessibility if context is in function with this parameter
73261
- // static member access is disallow
73262
- var thisParameter = void 0;
73263
- if (flags & 32 /* Static */ || !(thisParameter = getThisParameterFromNodeContext(location)) || !thisParameter.type) {
73335
+ // static member access is disallowed
73336
+ enclosingClass = getEnclosingClassFromThisParameter(location);
73337
+ enclosingClass = enclosingClass && isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing);
73338
+ if (flags & 32 /* Static */ || !enclosingClass) {
73264
73339
  if (errorNode) {
73265
73340
  error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || containingType));
73266
73341
  }
73267
73342
  return false;
73268
73343
  }
73269
- var thisType = getTypeFromTypeNode(thisParameter.type);
73270
- enclosingClass = ((thisType.flags & 262144 /* TypeParameter */) ? getConstraintOfTypeParameter(thisType) : thisType).target;
73271
73344
  }
73272
73345
  // No further restrictions for static properties
73273
73346
  if (flags & 32 /* Static */) {
@@ -73285,6 +73358,17 @@ var ts;
73285
73358
  }
73286
73359
  return true;
73287
73360
  }
73361
+ function getEnclosingClassFromThisParameter(node) {
73362
+ var thisParameter = getThisParameterFromNodeContext(node);
73363
+ var thisType = (thisParameter === null || thisParameter === void 0 ? void 0 : thisParameter.type) && getTypeFromTypeNode(thisParameter.type);
73364
+ if (thisType && thisType.flags & 262144 /* TypeParameter */) {
73365
+ thisType = getConstraintOfTypeParameter(thisType);
73366
+ }
73367
+ if (thisType && ts.getObjectFlags(thisType) & (3 /* ClassOrInterface */ | 4 /* Reference */)) {
73368
+ return getTargetType(thisType);
73369
+ }
73370
+ return undefined;
73371
+ }
73288
73372
  function getThisParameterFromNodeContext(node) {
73289
73373
  var thisContainer = ts.getThisContainer(node, /* includeArrowFunctions */ false);
73290
73374
  return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined;
@@ -77266,7 +77350,7 @@ var ts;
77266
77350
  case 40 /* MinusToken */:
77267
77351
  case 54 /* TildeToken */:
77268
77352
  checkNonNullType(operandType, node.operand);
77269
- if (maybeTypeOfKind(operandType, 12288 /* ESSymbolLike */)) {
77353
+ if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* ESSymbolLike */)) {
77270
77354
  error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator));
77271
77355
  }
77272
77356
  if (node.operator === 39 /* PlusToken */) {
@@ -77314,6 +77398,13 @@ var ts;
77314
77398
  // If it's not a bigint type, implicit coercion will result in a number
77315
77399
  return numberType;
77316
77400
  }
77401
+ function maybeTypeOfKindConsideringBaseConstraint(type, kind) {
77402
+ if (maybeTypeOfKind(type, kind)) {
77403
+ return true;
77404
+ }
77405
+ var baseConstraint = getBaseConstraintOrType(type);
77406
+ return !!baseConstraint && maybeTypeOfKind(baseConstraint, kind);
77407
+ }
77317
77408
  // Return true if type might be of the given kind. A union or intersection type might be of a given
77318
77409
  // kind if at least one constituent type is of the given kind.
77319
77410
  function maybeTypeOfKind(type, kind) {
@@ -78023,8 +78114,8 @@ var ts;
78023
78114
  }
78024
78115
  // Return true if there was no error, false if there was an error.
78025
78116
  function checkForDisallowedESSymbolOperand(operator) {
78026
- var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288 /* ESSymbolLike */) ? left :
78027
- maybeTypeOfKind(rightType, 12288 /* ESSymbolLike */) ? right :
78117
+ var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left :
78118
+ maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right :
78028
78119
  undefined;
78029
78120
  if (offendingSymbolOperand) {
78030
78121
  error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator));
@@ -78228,7 +78319,7 @@ var ts;
78228
78319
  for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
78229
78320
  var span = _a[_i];
78230
78321
  var type = checkExpression(span.expression);
78231
- if (maybeTypeOfKind(type, 12288 /* ESSymbolLike */)) {
78322
+ if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* ESSymbolLike */)) {
78232
78323
  error(span.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String);
78233
78324
  }
78234
78325
  texts.push(span.literal.text);
@@ -79574,23 +79665,6 @@ var ts;
79574
79665
  grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type);
79575
79666
  }
79576
79667
  checkSourceElement(node.typeParameter);
79577
- var symbol = getSymbolOfNode(node.typeParameter);
79578
- if (symbol.declarations && symbol.declarations.length > 1) {
79579
- var links = getSymbolLinks(symbol);
79580
- if (!links.typeParametersChecked) {
79581
- links.typeParametersChecked = true;
79582
- var typeParameter = getDeclaredTypeOfTypeParameter(symbol);
79583
- var declarations = ts.getDeclarationsOfKind(symbol, 162 /* TypeParameter */);
79584
- if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) {
79585
- // Report an error on every conflicting declaration.
79586
- var name = symbolToString(symbol);
79587
- for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
79588
- var declaration = declarations_4[_i];
79589
- error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_constraints, name);
79590
- }
79591
- }
79592
- }
79593
- }
79594
79668
  registerForUnusedIdentifiersCheck(node);
79595
79669
  }
79596
79670
  function checkTemplateLiteralType(node) {
@@ -79770,8 +79844,8 @@ var ts;
79770
79844
  var hasNonAmbientClass = false;
79771
79845
  var functionDeclarations = [];
79772
79846
  if (declarations) {
79773
- for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
79774
- var current = declarations_5[_i];
79847
+ for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
79848
+ var current = declarations_4[_i];
79775
79849
  var node = current;
79776
79850
  var inAmbientContext = node.flags & 8388608 /* Ambient */;
79777
79851
  var inAmbientContextOrInterface = node.parent && (node.parent.kind === 257 /* InterfaceDeclaration */ || node.parent.kind === 181 /* TypeLiteral */) || inAmbientContext;
@@ -80918,8 +80992,8 @@ var ts;
80918
80992
  : ts.createDiagnosticForNode(declarationList.parent.kind === 236 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
80919
80993
  }
80920
80994
  else {
80921
- for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
80922
- var decl = declarations_6[_i];
80995
+ for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
80996
+ var decl = declarations_5[_i];
80923
80997
  addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
80924
80998
  }
80925
80999
  }
@@ -82712,23 +82786,23 @@ var ts;
82712
82786
  return;
82713
82787
  }
82714
82788
  var type = getDeclaredTypeOfSymbol(symbol);
82715
- if (!areTypeParametersIdentical(declarations, type.localTypeParameters, ts.getEffectiveTypeParameterDeclarations)) {
82789
+ if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
82716
82790
  // Report an error on every conflicting declaration.
82717
82791
  var name = symbolToString(symbol);
82718
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
82719
- var declaration = declarations_7[_i];
82792
+ for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
82793
+ var declaration = declarations_6[_i];
82720
82794
  error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
82721
82795
  }
82722
82796
  }
82723
82797
  }
82724
82798
  }
82725
- function areTypeParametersIdentical(declarations, targetParameters, getTypeParameterDeclarations) {
82799
+ function areTypeParametersIdentical(declarations, targetParameters) {
82726
82800
  var maxTypeArgumentCount = ts.length(targetParameters);
82727
82801
  var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
82728
- for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
82729
- var declaration = declarations_8[_i];
82802
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
82803
+ var declaration = declarations_7[_i];
82730
82804
  // If this declaration has too few or too many type parameters, we report an error
82731
- var sourceParameters = getTypeParameterDeclarations(declaration);
82805
+ var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
82732
82806
  var numTypeParameters = sourceParameters.length;
82733
82807
  if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
82734
82808
  return false;
@@ -83272,7 +83346,7 @@ var ts;
83272
83346
  }
83273
83347
  if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) {
83274
83348
  var propName = member.name;
83275
- if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName)) {
83349
+ if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) {
83276
83350
  var type = getTypeOfSymbol(getSymbolOfNode(member));
83277
83351
  if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* Undefined */)) {
83278
83352
  if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
@@ -83307,7 +83381,9 @@ var ts;
83307
83381
  return false;
83308
83382
  }
83309
83383
  function isPropertyInitializedInConstructor(propName, propType, constructor) {
83310
- var reference = ts.factory.createPropertyAccessExpression(ts.factory.createThis(), propName);
83384
+ var reference = ts.isComputedPropertyName(propName)
83385
+ ? ts.factory.createElementAccessExpression(ts.factory.createThis(), propName.expression)
83386
+ : ts.factory.createPropertyAccessExpression(ts.factory.createThis(), propName);
83311
83387
  ts.setParent(reference.expression, reference);
83312
83388
  ts.setParent(reference, constructor);
83313
83389
  reference.flowNode = constructor.returnFlowNode;
@@ -83596,8 +83672,8 @@ var ts;
83596
83672
  function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
83597
83673
  var declarations = symbol.declarations;
83598
83674
  if (declarations) {
83599
- for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
83600
- var declaration = declarations_9[_i];
83675
+ for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
83676
+ var declaration = declarations_8[_i];
83601
83677
  if ((declaration.kind === 256 /* ClassDeclaration */ ||
83602
83678
  (declaration.kind === 255 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) &&
83603
83679
  !(declaration.flags & 8388608 /* Ambient */)) {
@@ -92864,10 +92940,7 @@ var ts;
92864
92940
  var substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue);
92865
92941
  if (!compilerOptions.removeComments) {
92866
92942
  var originalNode = ts.getOriginalNode(node, ts.isAccessExpression);
92867
- var propertyName = ts.isPropertyAccessExpression(originalNode)
92868
- ? ts.declarationNameToString(originalNode.name)
92869
- : safeMultiLineComment(ts.getTextOfNode(originalNode.argumentExpression));
92870
- ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + propertyName + " ");
92943
+ ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + safeMultiLineComment(ts.getTextOfNode(originalNode)) + " ");
92871
92944
  }
92872
92945
  return substitute;
92873
92946
  }
@@ -98666,8 +98739,8 @@ var ts;
98666
98739
  // declarations may not be sorted by position.
98667
98740
  // pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes.
98668
98741
  var pos = -1, end = -1;
98669
- for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
98670
- var node = declarations_10[_i];
98742
+ for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
98743
+ var node = declarations_9[_i];
98671
98744
  pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos);
98672
98745
  end = Math.max(end, node.end);
98673
98746
  }
@@ -151485,8 +151558,10 @@ var ts;
151485
151558
  var checker = program.getTypeChecker();
151486
151559
  var compilerOptions = program.getCompilerOptions();
151487
151560
  var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions);
151488
- // "default" is a keyword and not a legal identifier for the import, so we don't expect it here
151489
- ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
151561
+ // "default" is a keyword and not a legal identifier for the import, but appears as an identifier.
151562
+ if (symbolName === "default" /* Default */) {
151563
+ return undefined;
151564
+ }
151490
151565
  var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
151491
151566
  var useRequire = shouldUseRequire(sourceFile, program);
151492
151567
  var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);