@typescript-deploys/pr-build 4.8.0-pr-49091-7 → 4.8.0-pr-49086-10

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/tsc.js CHANGED
@@ -6079,6 +6079,7 @@ var ts;
6079
6079
  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."),
6080
6080
  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."),
6081
6081
  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."),
6082
+ This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, ts.DiagnosticCategory.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."),
6082
6083
  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}'."),
6083
6084
  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}'."),
6084
6085
  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}'."),
@@ -9904,6 +9905,18 @@ var ts;
9904
9905
  return isLiteralKind(node.kind);
9905
9906
  }
9906
9907
  ts.isLiteralExpression = isLiteralExpression;
9908
+ function isLiteralExpressionOfObject(node) {
9909
+ switch (node.kind) {
9910
+ case 205:
9911
+ case 204:
9912
+ case 13:
9913
+ case 213:
9914
+ case 226:
9915
+ return true;
9916
+ }
9917
+ return false;
9918
+ }
9919
+ ts.isLiteralExpressionOfObject = isLiteralExpressionOfObject;
9907
9920
  function isTemplateLiteralKind(kind) {
9908
9921
  return 14 <= kind && kind <= 17;
9909
9922
  }
@@ -54439,18 +54452,6 @@ var ts;
54439
54452
  }
54440
54453
  return result;
54441
54454
  }
54442
- function removeIntersectionMembersWithoutKeys(type) {
54443
- if (!(type.flags & 2097152)) {
54444
- return type;
54445
- }
54446
- return getIntersectionType(ts.filter(type.types, function (t) { return !isKeylessType(t); }));
54447
- }
54448
- function isKeylessType(type) {
54449
- return !!(getIndexType(type).flags & 131072);
54450
- }
54451
- function isConditionalFilteringKeylessTypes(type) {
54452
- return !!(type.flags & 16777216) && type.root.isDistributive && everyType(type.extendsType, isKeylessType);
54453
- }
54454
54455
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
54455
54456
  if (intersectionState & 4) {
54456
54457
  return propertiesRelatedTo(source, target, reportErrors, undefined, 0);
@@ -54559,28 +54560,9 @@ var ts;
54559
54560
  else if (targetFlags & 4194304) {
54560
54561
  var targetType_1 = target.type;
54561
54562
  if (sourceFlags & 4194304) {
54562
- var sourceType = source.type;
54563
- if (result = isRelatedTo(targetType_1, sourceType, 3, false)) {
54563
+ if (result = isRelatedTo(targetType_1, source.type, 3, false)) {
54564
54564
  return result;
54565
54565
  }
54566
- while (isConditionalFilteringKeylessTypes(sourceType)) {
54567
- var lastSource = sourceType;
54568
- sourceType = getDefaultConstraintOfConditionalType(sourceType);
54569
- if (sourceType === lastSource) {
54570
- break;
54571
- }
54572
- if (result = isRelatedTo(targetType_1, sourceType, 3, false)) {
54573
- return result;
54574
- }
54575
- var simplifiedSource = sourceType;
54576
- sourceType = removeIntersectionMembersWithoutKeys(sourceType);
54577
- if (sourceType === simplifiedSource) {
54578
- continue;
54579
- }
54580
- if (result = isRelatedTo(targetType_1, sourceType, 3, false)) {
54581
- return result;
54582
- }
54583
- }
54584
54566
  }
54585
54567
  if (isTupleType(targetType_1)) {
54586
54568
  if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2, reportErrors)) {
@@ -56104,11 +56086,15 @@ var ts;
56104
56086
  type.flags & 1048576 ? mapType(type, getWidenedUniqueESSymbolType) :
56105
56087
  type;
56106
56088
  }
56107
- function getWidenedLiteralLikeTypeForContextualType(type, contextualType) {
56108
- if (!isLiteralOfContextualType(type, contextualType)) {
56109
- type = getWidenedUniqueESSymbolType(getWidenedLiteralType(type));
56089
+ function getWidenedLiteralLikeTypeForContextualType(type, contextualType, node) {
56090
+ if (isLiteralOfContextualType(type, contextualType)) {
56091
+ return type;
56110
56092
  }
56111
- return type;
56093
+ var instantiatedContextualType = node && instantiateContextualType(contextualType, node) || contextualType;
56094
+ if (instantiatedContextualType !== contextualType && isLiteralOfContextualType(type, instantiatedContextualType)) {
56095
+ return type;
56096
+ }
56097
+ return getWidenedUniqueESSymbolType(getWidenedLiteralType(type));
56112
56098
  }
56113
56099
  function getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(type, contextualSignatureReturnType, isAsync) {
56114
56100
  if (type && isUnitType(type)) {
@@ -56174,21 +56160,13 @@ var ts;
56174
56160
  }
56175
56161
  return result;
56176
56162
  }
56177
- function getApparentIntersectionTypes(type) {
56178
- var apparent = getApparentType(type);
56179
- if (apparent.flags & 2097152) {
56180
- return apparent.types;
56181
- }
56182
- return [apparent];
56183
- }
56184
56163
  function getFalsyFlags(type) {
56185
56164
  return type.flags & 1048576 ? getFalsyFlagsOfTypes(type.types) :
56186
- type.flags & 2097152 ? ts.reduceLeft(getApparentIntersectionTypes(type), function (memo, type) { return memo | getFalsyFlags(type); }, 0) :
56187
- type.flags & 128 ? type.value === "" ? 128 : 0 :
56188
- type.flags & 256 ? type.value === 0 ? 256 : 0 :
56189
- type.flags & 2048 ? isZeroBigInt(type) ? 2048 : 0 :
56190
- type.flags & 512 ? (type === falseType || type === regularFalseType) ? 512 : 0 :
56191
- type.flags & 117724;
56165
+ type.flags & 128 ? type.value === "" ? 128 : 0 :
56166
+ type.flags & 256 ? type.value === 0 ? 256 : 0 :
56167
+ type.flags & 2048 ? isZeroBigInt(type) ? 2048 : 0 :
56168
+ type.flags & 512 ? (type === falseType || type === regularFalseType) ? 512 : 0 :
56169
+ type.flags & 117724;
56192
56170
  }
56193
56171
  function removeDefinitelyFalsyTypes(type) {
56194
56172
  return getFalsyFlags(type) & 117632 ?
@@ -59276,9 +59254,7 @@ var ts;
59276
59254
  case "function":
59277
59255
  return type.flags & 1 ? type : globalFunctionType;
59278
59256
  case "object":
59279
- var isUnknownish = type.flags & 2 ||
59280
- (type.flags & 58982400 && (getBaseConstraintOfType(type) || unknownType).flags & 2);
59281
- return isUnknownish ? getUnionType([nonPrimitiveType, nullType]) : type;
59257
+ return type.flags & 2 ? getUnionType([nonPrimitiveType, nullType]) : type;
59282
59258
  default:
59283
59259
  return typeofTypesByName.get(text);
59284
59260
  }
@@ -60762,16 +60738,16 @@ var ts;
60762
60738
  function instantiateContextualType(contextualType, node, contextFlags) {
60763
60739
  if (contextualType && maybeTypeOfKind(contextualType, 465829888)) {
60764
60740
  var inferenceContext = getInferenceContext(node);
60765
- if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
60766
- if (contextFlags && contextFlags & 1) {
60767
- return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
60768
- }
60769
- if (inferenceContext.returnMapper) {
60770
- var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
60771
- return type.flags & 1048576 && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
60772
- filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
60773
- type;
60774
- }
60741
+ if (inferenceContext && contextFlags & 1 && (inferenceContext.returnMapper || ts.some(inferenceContext.inferences, hasInferenceCandidates))) {
60742
+ return instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper
60743
+ ? combineTypeMappers(inferenceContext.nonFixingMapper, inferenceContext.returnMapper)
60744
+ : inferenceContext.nonFixingMapper);
60745
+ }
60746
+ if (inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.returnMapper) {
60747
+ var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
60748
+ return type.flags & 1048576 && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
60749
+ filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
60750
+ type;
60775
60751
  }
60776
60752
  }
60777
60753
  return contextualType;
@@ -62925,18 +62901,22 @@ var ts;
62925
62901
  return inferJsxTypeArguments(node, signature, checkMode, context);
62926
62902
  }
62927
62903
  if (node.kind !== 165) {
62928
- var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 : 0);
62904
+ var skipBindingPatterns = ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); });
62905
+ var contextualType = getContextualType(node, skipBindingPatterns ? 8 : 0);
62929
62906
  if (contextualType) {
62930
62907
  var inferenceTargetType = getReturnTypeOfSignature(signature);
62931
62908
  if (couldContainTypeVariables(inferenceTargetType)) {
62932
62909
  var outerContext = getInferenceContext(node);
62933
- var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1));
62934
- var instantiatedType = instantiateType(contextualType, outerMapper);
62935
- var contextualSignature = getSingleCallSignature(instantiatedType);
62936
- var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
62937
- getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
62938
- instantiatedType;
62939
- inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128);
62910
+ var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8) !== contextualType;
62911
+ if (!isFromBindingPattern) {
62912
+ var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1));
62913
+ var instantiatedType = instantiateType(contextualType, outerMapper);
62914
+ var contextualSignature = getSingleCallSignature(instantiatedType);
62915
+ var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
62916
+ getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
62917
+ instantiatedType;
62918
+ inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128);
62919
+ }
62940
62920
  var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
62941
62921
  var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
62942
62922
  inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
@@ -66140,6 +66120,10 @@ var ts;
66140
66120
  case 35:
66141
66121
  case 36:
66142
66122
  case 37:
66123
+ if (ts.isLiteralExpressionOfObject(left) || ts.isLiteralExpressionOfObject(right)) {
66124
+ var eqType = operator === 34 || operator === 36;
66125
+ error(errorNode, ts.Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
66126
+ }
66143
66127
  reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); });
66144
66128
  return booleanType;
66145
66129
  case 102:
@@ -66560,7 +66544,7 @@ var ts;
66560
66544
  var type = checkExpression(node, checkMode, forceTuple);
66561
66545
  return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) :
66562
66546
  isTypeAssertion(node) ? type :
66563
- getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
66547
+ getWidenedLiteralLikeTypeForContextualType(type, arguments.length === 2 ? getContextualType(node) : contextualType, node);
66564
66548
  }
66565
66549
  function checkPropertyAssignment(node, checkMode) {
66566
66550
  if (node.name.kind === 162) {
package/lib/tsserver.js CHANGED
@@ -8895,6 +8895,7 @@ var ts;
8895
8895
  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."),
8896
8896
  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."),
8897
8897
  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."),
8898
+ This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, ts.DiagnosticCategory.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."),
8898
8899
  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}'."),
8899
8900
  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}'."),
8900
8901
  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}'."),
@@ -13205,6 +13206,19 @@ var ts;
13205
13206
  return isLiteralKind(node.kind);
13206
13207
  }
13207
13208
  ts.isLiteralExpression = isLiteralExpression;
13209
+ /** @internal */
13210
+ function isLiteralExpressionOfObject(node) {
13211
+ switch (node.kind) {
13212
+ case 205 /* ObjectLiteralExpression */:
13213
+ case 204 /* ArrayLiteralExpression */:
13214
+ case 13 /* RegularExpressionLiteral */:
13215
+ case 213 /* FunctionExpression */:
13216
+ case 226 /* ClassExpression */:
13217
+ return true;
13218
+ }
13219
+ return false;
13220
+ }
13221
+ ts.isLiteralExpressionOfObject = isLiteralExpressionOfObject;
13208
13222
  // Pseudo-literals
13209
13223
  /* @internal */
13210
13224
  function isTemplateLiteralKind(kind) {
@@ -65371,18 +65385,6 @@ var ts;
65371
65385
  }
65372
65386
  return result;
65373
65387
  }
65374
- function removeIntersectionMembersWithoutKeys(type) {
65375
- if (!(type.flags & 2097152 /* Intersection */)) {
65376
- return type;
65377
- }
65378
- return getIntersectionType(ts.filter(type.types, function (t) { return !isKeylessType(t); }));
65379
- }
65380
- function isKeylessType(type) {
65381
- return !!(getIndexType(type).flags & 131072 /* Never */);
65382
- }
65383
- function isConditionalFilteringKeylessTypes(type) {
65384
- return !!(type.flags & 16777216 /* Conditional */) && type.root.isDistributive && everyType(type.extendsType, isKeylessType);
65385
- }
65386
65388
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
65387
65389
  if (intersectionState & 4 /* PropertyCheck */) {
65388
65390
  return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
@@ -65521,34 +65523,9 @@ var ts;
65521
65523
  var targetType_1 = target.type;
65522
65524
  // A keyof S is related to a keyof T if T is related to S.
65523
65525
  if (sourceFlags & 4194304 /* Index */) {
65524
- var sourceType = source.type;
65525
- if (result = isRelatedTo(targetType_1, sourceType, 3 /* Both */, /*reportErrors*/ false)) {
65526
+ if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) {
65526
65527
  return result;
65527
65528
  }
65528
- // If the source is a filtering conditional that removes only keyless sources, eg, `NonNullable<T>`,
65529
- // then it doesn't affect the `keyof` query, and we can unwrap the conditional and relate the unwrapped source and target.
65530
- // There may be multiple stacked conditionals, such as `T extends null ? never : T extends undefined ? never : T : T`, so
65531
- // we need to repeat the unwrapping process.
65532
- while (isConditionalFilteringKeylessTypes(sourceType)) {
65533
- var lastSource = sourceType;
65534
- sourceType = getDefaultConstraintOfConditionalType(sourceType);
65535
- if (sourceType === lastSource) {
65536
- break;
65537
- }
65538
- if (result = isRelatedTo(targetType_1, sourceType, 3 /* Both */, /*reportErrors*/ false)) {
65539
- return result;
65540
- }
65541
- var simplifiedSource = sourceType;
65542
- // In addition, `keyof (T & U)` is equivalent to `keyof T | keyof U`, so if `keyof U` is always `never`, we can omit
65543
- // it from the relationship. This allows, eg, `keyof (T & object)` to be related to `keyof T`.
65544
- sourceType = removeIntersectionMembersWithoutKeys(sourceType);
65545
- if (sourceType === simplifiedSource) {
65546
- continue;
65547
- }
65548
- if (result = isRelatedTo(targetType_1, sourceType, 3 /* Both */, /*reportErrors*/ false)) {
65549
- return result;
65550
- }
65551
- }
65552
65529
  }
65553
65530
  if (isTupleType(targetType_1)) {
65554
65531
  // An index type can have a tuple type target when the tuple type contains variadic elements.
@@ -67348,11 +67325,15 @@ var ts;
67348
67325
  type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) :
67349
67326
  type;
67350
67327
  }
67351
- function getWidenedLiteralLikeTypeForContextualType(type, contextualType) {
67352
- if (!isLiteralOfContextualType(type, contextualType)) {
67353
- type = getWidenedUniqueESSymbolType(getWidenedLiteralType(type));
67328
+ function getWidenedLiteralLikeTypeForContextualType(type, contextualType, node) {
67329
+ if (isLiteralOfContextualType(type, contextualType)) {
67330
+ return type;
67354
67331
  }
67355
- return type;
67332
+ var instantiatedContextualType = node && instantiateContextualType(contextualType, node) || contextualType;
67333
+ if (instantiatedContextualType !== contextualType && isLiteralOfContextualType(type, instantiatedContextualType)) {
67334
+ return type;
67335
+ }
67336
+ return getWidenedUniqueESSymbolType(getWidenedLiteralType(type));
67356
67337
  }
67357
67338
  function getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(type, contextualSignatureReturnType, isAsync) {
67358
67339
  if (type && isUnitType(type)) {
@@ -67422,24 +67403,16 @@ var ts;
67422
67403
  }
67423
67404
  return result;
67424
67405
  }
67425
- function getApparentIntersectionTypes(type) {
67426
- var apparent = getApparentType(type);
67427
- if (apparent.flags & 2097152 /* Intersection */) {
67428
- return apparent.types;
67429
- }
67430
- return [apparent];
67431
- }
67432
67406
  // Returns the String, Number, Boolean, StringLiteral, NumberLiteral, BooleanLiteral, Void, Undefined, or Null
67433
67407
  // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
67434
67408
  // no flags for all other types (including non-falsy literal types).
67435
67409
  function getFalsyFlags(type) {
67436
67410
  return type.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(type.types) :
67437
- type.flags & 2097152 /* Intersection */ ? ts.reduceLeft(getApparentIntersectionTypes(type), function (memo, type) { return memo | getFalsyFlags(type); }, 0) :
67438
- type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 :
67439
- type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 :
67440
- type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 :
67441
- type.flags & 512 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
67442
- type.flags & 117724 /* PossiblyFalsy */;
67411
+ type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 :
67412
+ type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 :
67413
+ type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 :
67414
+ type.flags & 512 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
67415
+ type.flags & 117724 /* PossiblyFalsy */;
67443
67416
  }
67444
67417
  function removeDefinitelyFalsyTypes(type) {
67445
67418
  return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ?
@@ -70948,9 +70921,7 @@ var ts;
70948
70921
  case "function":
70949
70922
  return type.flags & 1 /* Any */ ? type : globalFunctionType;
70950
70923
  case "object":
70951
- var isUnknownish = type.flags & 2 /* Unknown */ ||
70952
- (type.flags & 58982400 /* InstantiableNonPrimitive */ && (getBaseConstraintOfType(type) || unknownType).flags & 2 /* Unknown */);
70953
- return isUnknownish ? getUnionType([nonPrimitiveType, nullType]) : type;
70924
+ return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type;
70954
70925
  default:
70955
70926
  return typeofTypesByName.get(text);
70956
70927
  }
@@ -72795,22 +72766,22 @@ var ts;
72795
72766
  var inferenceContext = getInferenceContext(node);
72796
72767
  // If no inferences have been made, nothing is gained from instantiating as type parameters
72797
72768
  // would just be replaced with their defaults similar to the apparent type.
72798
- if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
72769
+ if (inferenceContext && contextFlags & 1 /* Signature */ && (inferenceContext.returnMapper || ts.some(inferenceContext.inferences, hasInferenceCandidates))) {
72799
72770
  // For contextual signatures we incorporate all inferences made so far, e.g. from return
72800
72771
  // types as well as arguments to the left in a function call.
72801
- if (contextFlags && contextFlags & 1 /* Signature */) {
72802
- return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
72803
- }
72772
+ return instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper
72773
+ ? combineTypeMappers(inferenceContext.nonFixingMapper, inferenceContext.returnMapper)
72774
+ : inferenceContext.nonFixingMapper);
72775
+ }
72776
+ if (inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.returnMapper) {
72804
72777
  // For other purposes (e.g. determining whether to produce literal types) we only
72805
72778
  // incorporate inferences made from the return type in a function call. We remove
72806
72779
  // the 'boolean' type from the contextual type such that contextually typed boolean
72807
72780
  // literals actually end up widening to 'boolean' (see #48363).
72808
- if (inferenceContext.returnMapper) {
72809
- var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
72810
- return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
72811
- filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
72812
- type;
72813
- }
72781
+ var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
72782
+ return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
72783
+ filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
72784
+ type;
72814
72785
  }
72815
72786
  }
72816
72787
  return contextualType;
@@ -75344,29 +75315,43 @@ var ts;
75344
75315
  // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
75345
75316
  // return type of 'wrap'.
75346
75317
  if (node.kind !== 165 /* Decorator */) {
75347
- var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */);
75318
+ var skipBindingPatterns = ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); });
75319
+ var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */);
75348
75320
  if (contextualType) {
75349
75321
  var inferenceTargetType = getReturnTypeOfSignature(signature);
75350
75322
  if (couldContainTypeVariables(inferenceTargetType)) {
75351
- // We clone the inference context to avoid disturbing a resolution in progress for an
75352
- // outer call expression. Effectively we just want a snapshot of whatever has been
75353
- // inferred for any outer call expression so far.
75354
75323
  var outerContext = getInferenceContext(node);
75355
- var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
75356
- var instantiatedType = instantiateType(contextualType, outerMapper);
75357
- // If the contextual type is a generic function type with a single call signature, we
75358
- // instantiate the type with its own type parameters and type arguments. This ensures that
75359
- // the type parameters are not erased to type any during type inference such that they can
75360
- // be inferred as actual types from the contextual type. For example:
75361
- // declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
75362
- // const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
75363
- // Above, the type of the 'value' parameter is inferred to be 'A'.
75364
- var contextualSignature = getSingleCallSignature(instantiatedType);
75365
- var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
75366
- getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
75367
- instantiatedType;
75368
- // Inferences made from return types have lower priority than all other inferences.
75369
- inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
75324
+ var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* SkipBindingPatterns */) !== contextualType;
75325
+ // A return type inference from a binding pattern can be used in instantiating the contextual
75326
+ // type of an argument later in inference, but cannot stand on its own as the final return type.
75327
+ // It is incorporated into `context.returnMapper` which is used in `instantiateContextualType`,
75328
+ // but doesn't need to go into `context.inferences`. This allows a an array binding pattern to
75329
+ // produce a tuple for `T` in
75330
+ // declare function f<T>(cb: () => T): T;
75331
+ // const [e1, e2, e3] = f(() => [1, "hi", true]);
75332
+ // but does not produce any inference for `T` in
75333
+ // declare function f<T>(): T;
75334
+ // const [e1, e2, e3] = f();
75335
+ if (!isFromBindingPattern) {
75336
+ // We clone the inference context to avoid disturbing a resolution in progress for an
75337
+ // outer call expression. Effectively we just want a snapshot of whatever has been
75338
+ // inferred for any outer call expression so far.
75339
+ var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
75340
+ var instantiatedType = instantiateType(contextualType, outerMapper);
75341
+ // If the contextual type is a generic function type with a single call signature, we
75342
+ // instantiate the type with its own type parameters and type arguments. This ensures that
75343
+ // the type parameters are not erased to type any during type inference such that they can
75344
+ // be inferred as actual types from the contextual type. For example:
75345
+ // declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
75346
+ // const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
75347
+ // Above, the type of the 'value' parameter is inferred to be 'A'.
75348
+ var contextualSignature = getSingleCallSignature(instantiatedType);
75349
+ var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
75350
+ getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
75351
+ instantiatedType;
75352
+ // Inferences made from return types have lower priority than all other inferences.
75353
+ inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
75354
+ }
75370
75355
  // Create a type mapper for instantiating generic contextual types using the inferences made
75371
75356
  // from the return type. We need a separate inference pass here because (a) instantiation of
75372
75357
  // the source type uses the outer context's return mapper (which excludes inferences made from
@@ -79024,6 +79009,10 @@ var ts;
79024
79009
  case 35 /* ExclamationEqualsToken */:
79025
79010
  case 36 /* EqualsEqualsEqualsToken */:
79026
79011
  case 37 /* ExclamationEqualsEqualsToken */:
79012
+ if (ts.isLiteralExpressionOfObject(left) || ts.isLiteralExpressionOfObject(right)) {
79013
+ var eqType = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */;
79014
+ error(errorNode, ts.Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
79015
+ }
79027
79016
  reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); });
79028
79017
  return booleanType;
79029
79018
  case 102 /* InstanceOfKeyword */:
@@ -79479,7 +79468,7 @@ var ts;
79479
79468
  var type = checkExpression(node, checkMode, forceTuple);
79480
79469
  return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) :
79481
79470
  isTypeAssertion(node) ? type :
79482
- getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
79471
+ getWidenedLiteralLikeTypeForContextualType(type, arguments.length === 2 ? getContextualType(node) : contextualType, node);
79483
79472
  }
79484
79473
  function checkPropertyAssignment(node, checkMode) {
79485
79474
  // Do not use hasDynamicName here, because that returns false for well known symbols.