@typescript-deploys/pr-build 5.1.0-pr-52062-4 → 5.1.0-pr-53300-9

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
@@ -7333,6 +7333,7 @@ var Diagnostics = {
7333
7333
  Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(6718, 3 /* Message */, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_6718", "Specify emit/checking behavior for imports that are only used for types."),
7334
7334
  Default_catch_clause_variables_as_unknown_instead_of_any: diag(6803, 3 /* Message */, "Default_catch_clause_variables_as_unknown_instead_of_any_6803", "Default catch clause variables as 'unknown' instead of 'any'."),
7335
7335
  Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_in_the_output_file_s_format_based_on_the_module_setting: diag(6804, 3 /* Message */, "Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_i_6804", "Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting."),
7336
+ Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks: diag(6805, 3 /* Message */, "Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks_6805", "Default type arguments to parameter constraint or 'unknown' instead of 'any' for instance checks."),
7336
7337
  one_of_Colon: diag(6900, 3 /* Message */, "one_of_Colon_6900", "one of:"),
7337
7338
  one_or_more_Colon: diag(6901, 3 /* Message */, "one_or_more_Colon_6901", "one or more:"),
7338
7339
  type_Colon: diag(6902, 3 /* Message */, "type_Colon_6902", "type:"),
@@ -33858,6 +33859,16 @@ var commandOptionsWithoutBuild = [
33858
33859
  description: Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
33859
33860
  defaultValueDescription: false
33860
33861
  },
33862
+ {
33863
+ name: "strictInstanceOfTypeParameters",
33864
+ type: "boolean",
33865
+ affectsSemanticDiagnostics: true,
33866
+ affectsBuildInfo: true,
33867
+ strictFlag: true,
33868
+ category: Diagnostics.Type_Checking,
33869
+ description: Diagnostics.Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks,
33870
+ defaultValueDescription: false
33871
+ },
33861
33872
  {
33862
33873
  name: "alwaysStrict",
33863
33874
  type: "boolean",
@@ -42661,6 +42672,7 @@ function createTypeChecker(host) {
42661
42672
  var noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny");
42662
42673
  var noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
42663
42674
  var useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
42675
+ var strictInstanceOfTypeParameters = true;
42664
42676
  var keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
42665
42677
  var defaultIndexFlags = keyofStringsOnly ? 1 /* StringsOnly */ : 0 /* None */;
42666
42678
  var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */;
@@ -50627,9 +50639,32 @@ function createTypeChecker(host) {
50627
50639
  }
50628
50640
  }).parent;
50629
50641
  }
50642
+ function getInstanceTypeOfClassSymbol(classSymbol) {
50643
+ const classType = getDeclaredTypeOfSymbol(classSymbol);
50644
+ const objectFlags = getObjectFlags(classType);
50645
+ if (!(objectFlags & 3 /* ClassOrInterface */) || !classType.typeParameters) {
50646
+ return classType;
50647
+ }
50648
+ const variances = getVariances(classType);
50649
+ const typeArguments = map(classType.typeParameters, (typeParameter, i) => {
50650
+ if (!strictInstanceOfTypeParameters) {
50651
+ return anyType;
50652
+ }
50653
+ const variance = variances[i];
50654
+ switch (variance & 7 /* VarianceMask */) {
50655
+ case 4 /* Independent */:
50656
+ case 3 /* Bivariant */:
50657
+ return anyType;
50658
+ case 0 /* Invariant */:
50659
+ return unknownType;
50660
+ }
50661
+ return getBaseConstraintOfType(typeParameter) || unknownType;
50662
+ });
50663
+ return createTypeReference(classType, typeArguments);
50664
+ }
50630
50665
  function getTypeOfPrototypeProperty(prototype) {
50631
- const classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype));
50632
- return classType.typeParameters ? createTypeReference(classType, map(classType.typeParameters, (_) => anyType)) : classType;
50666
+ const classSymbol = getParentOfSymbol(prototype);
50667
+ return getInstanceTypeOfClassSymbol(classSymbol);
50633
50668
  }
50634
50669
  function getTypeOfPropertyOfType(type, name) {
50635
50670
  const prop = getPropertyOfType(type, name);
@@ -55721,7 +55756,7 @@ function createTypeChecker(host) {
55721
55756
  const type = elementTypes[i];
55722
55757
  const flags = target.elementFlags[i];
55723
55758
  if (flags & 8 /* Variadic */) {
55724
- if (type.flags & 58982400 /* InstantiableNonPrimitive */ || everyContainedType(type, isGenericMappedType)) {
55759
+ if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) {
55725
55760
  addElement(type, 8 /* Variadic */, (_a2 = target.labeledElementDeclarations) == null ? void 0 : _a2[i]);
55726
55761
  } else if (isTupleType(type)) {
55727
55762
  const elements = getTypeArguments(type);
@@ -58635,8 +58670,20 @@ function createTypeChecker(host) {
58635
58670
  return result;
58636
58671
  }
58637
58672
  const moreThanOneRealChildren = length(validChildren) > 1;
58638
- const arrayLikeTargetParts = filterType(childrenTargetType, isAssignableToAvailableAnyIterable);
58639
- const nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isAssignableToAvailableAnyIterable(t));
58673
+ let arrayLikeTargetParts;
58674
+ let nonArrayLikeTargetParts;
58675
+ const iterableType = getGlobalIterableType(
58676
+ /*reportErrors*/
58677
+ false
58678
+ );
58679
+ if (iterableType !== emptyGenericType) {
58680
+ const anyIterable = createIterableType(anyType);
58681
+ arrayLikeTargetParts = filterType(childrenTargetType, (t) => isTypeAssignableTo(t, anyIterable));
58682
+ nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isTypeAssignableTo(t, anyIterable));
58683
+ } else {
58684
+ arrayLikeTargetParts = filterType(childrenTargetType, isArrayOrTupleLikeType);
58685
+ nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isArrayOrTupleLikeType(t));
58686
+ }
58640
58687
  if (moreThanOneRealChildren) {
58641
58688
  if (arrayLikeTargetParts !== neverType) {
58642
58689
  const realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */));
@@ -61916,13 +61963,6 @@ function createTypeChecker(host) {
61916
61963
  function isArrayOrTupleLikeType(type) {
61917
61964
  return isArrayLikeType(type) || isTupleLikeType(type);
61918
61965
  }
61919
- function isAssignableToAvailableAnyIterable(type) {
61920
- const anyIterable = getGlobalIterableType(
61921
- /*reportErrors*/
61922
- false
61923
- ) !== emptyGenericType && createIterableType(anyType);
61924
- return anyIterable ? isTypeAssignableTo(type, anyIterable) : isArrayOrTupleLikeType(type);
61925
- }
61926
61966
  function getTupleElementType(type, index) {
61927
61967
  const propType = getTypeOfPropertyOfType(type, "" + index);
61928
61968
  if (propType) {
@@ -65068,8 +65108,8 @@ function createTypeChecker(host) {
65068
65108
  if (symbol === void 0) {
65069
65109
  return type;
65070
65110
  }
65071
- const classSymbol = symbol.parent;
65072
- const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol);
65111
+ const classSymbol = getParentOfSymbol(symbol);
65112
+ const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getInstanceTypeOfClassSymbol(classSymbol);
65073
65113
  return getNarrowedType(
65074
65114
  type,
65075
65115
  targetType,
@@ -66520,7 +66560,7 @@ function createTypeChecker(host) {
66520
66560
  return void 0;
66521
66561
  }
66522
66562
  }
66523
- return isInJSFile(decl2) ? void 0 : getTypeOfExpression(binaryExpression.left);
66563
+ return isInJSFile(decl2) || decl2 === binaryExpression.left ? void 0 : getTypeOfExpression(binaryExpression.left);
66524
66564
  }
66525
66565
  case 1 /* ExportsProperty */:
66526
66566
  case 6 /* Prototype */:
@@ -66596,17 +66636,13 @@ function createTypeChecker(host) {
66596
66636
  type,
66597
66637
  (t) => {
66598
66638
  var _a2;
66599
- if (everyContainedType(t, (t2) => isGenericMappedType(t2) && !t2.declaration.nameType)) {
66600
- const newTypes = mapDefined(t.flags & 2097152 /* Intersection */ ? t.types : [t], (t2) => {
66601
- const mappedType = t2;
66602
- const constraint = getConstraintTypeFromMappedType(mappedType);
66603
- const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
66604
- const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
66605
- if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
66606
- return substituteIndexedMappedType(mappedType, propertyNameType);
66607
- }
66608
- });
66609
- return newTypes.length ? getIntersectionType(newTypes) : void 0;
66639
+ if (isGenericMappedType(t) && !t.declaration.nameType) {
66640
+ const constraint = getConstraintTypeFromMappedType(t);
66641
+ const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
66642
+ const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
66643
+ if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
66644
+ return substituteIndexedMappedType(t, propertyNameType);
66645
+ }
66610
66646
  } else if (t.flags & 3670016 /* StructuredType */) {
66611
66647
  const prop = getPropertyOfType(t, name);
66612
66648
  if (prop) {
@@ -66680,7 +66716,7 @@ function createTypeChecker(host) {
66680
66716
  return void 0;
66681
66717
  }
66682
66718
  function getContextualTypeForElementExpression(arrayContextualType, index) {
66683
- return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(filterType(arrayContextualType, (t) => !!getIndexTypeOfType(t, numberType) || isAssignableToAvailableAnyIterable(t)), "" + index) || mapType(
66719
+ return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) || mapType(
66684
66720
  arrayContextualType,
66685
66721
  (t) => isTupleType(t) ? getElementTypeOfSliceOfTupleType(
66686
66722
  t,
@@ -67422,7 +67458,7 @@ function createTypeChecker(host) {
67422
67458
  const inConstContext = isConstContext(node);
67423
67459
  const checkFlags = inConstContext ? 8 /* Readonly */ : 0;
67424
67460
  const isInJavascript = isInJSFile(node) && !isInJsonFile(node);
67425
- const enumTag = getJSDocEnumTag(node);
67461
+ const enumTag = isInJavascript ? getJSDocEnumTag(node) : void 0;
67426
67462
  const isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
67427
67463
  let objectFlags = freshObjectLiteralFlag;
67428
67464
  let patternWithComputedProperties = false;
@@ -72179,6 +72215,11 @@ function createTypeChecker(host) {
72179
72215
  } else {
72180
72216
  assignNonContextualParameterTypes(signature);
72181
72217
  }
72218
+ } else if (contextualSignature && !node.typeParameters && contextualSignature.parameters.length > node.parameters.length) {
72219
+ const inferenceContext = getInferenceContext(node);
72220
+ if (checkMode && checkMode & 2 /* Inferential */) {
72221
+ inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
72222
+ }
72182
72223
  }
72183
72224
  if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
72184
72225
  const returnType = getReturnTypeFromBody(node, checkMode);
package/lib/tsserver.js CHANGED
@@ -10795,6 +10795,7 @@ var Diagnostics = {
10795
10795
  Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(6718, 3 /* Message */, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_6718", "Specify emit/checking behavior for imports that are only used for types."),
10796
10796
  Default_catch_clause_variables_as_unknown_instead_of_any: diag(6803, 3 /* Message */, "Default_catch_clause_variables_as_unknown_instead_of_any_6803", "Default catch clause variables as 'unknown' instead of 'any'."),
10797
10797
  Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_in_the_output_file_s_format_based_on_the_module_setting: diag(6804, 3 /* Message */, "Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_i_6804", "Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting."),
10798
+ Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks: diag(6805, 3 /* Message */, "Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks_6805", "Default type arguments to parameter constraint or 'unknown' instead of 'any' for instance checks."),
10798
10799
  one_of_Colon: diag(6900, 3 /* Message */, "one_of_Colon_6900", "one of:"),
10799
10800
  one_or_more_Colon: diag(6901, 3 /* Message */, "one_or_more_Colon_6901", "one or more:"),
10800
10801
  type_Colon: diag(6902, 3 /* Message */, "type_Colon_6902", "type:"),
@@ -38194,6 +38195,16 @@ var commandOptionsWithoutBuild = [
38194
38195
  description: Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
38195
38196
  defaultValueDescription: false
38196
38197
  },
38198
+ {
38199
+ name: "strictInstanceOfTypeParameters",
38200
+ type: "boolean",
38201
+ affectsSemanticDiagnostics: true,
38202
+ affectsBuildInfo: true,
38203
+ strictFlag: true,
38204
+ category: Diagnostics.Type_Checking,
38205
+ description: Diagnostics.Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks,
38206
+ defaultValueDescription: false
38207
+ },
38197
38208
  {
38198
38209
  name: "alwaysStrict",
38199
38210
  type: "boolean",
@@ -47258,6 +47269,7 @@ function createTypeChecker(host) {
47258
47269
  var noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny");
47259
47270
  var noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
47260
47271
  var useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
47272
+ var strictInstanceOfTypeParameters = true;
47261
47273
  var keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
47262
47274
  var defaultIndexFlags = keyofStringsOnly ? 1 /* StringsOnly */ : 0 /* None */;
47263
47275
  var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */;
@@ -55224,9 +55236,32 @@ function createTypeChecker(host) {
55224
55236
  }
55225
55237
  }).parent;
55226
55238
  }
55239
+ function getInstanceTypeOfClassSymbol(classSymbol) {
55240
+ const classType = getDeclaredTypeOfSymbol(classSymbol);
55241
+ const objectFlags = getObjectFlags(classType);
55242
+ if (!(objectFlags & 3 /* ClassOrInterface */) || !classType.typeParameters) {
55243
+ return classType;
55244
+ }
55245
+ const variances = getVariances(classType);
55246
+ const typeArguments = map(classType.typeParameters, (typeParameter, i) => {
55247
+ if (!strictInstanceOfTypeParameters) {
55248
+ return anyType;
55249
+ }
55250
+ const variance = variances[i];
55251
+ switch (variance & 7 /* VarianceMask */) {
55252
+ case 4 /* Independent */:
55253
+ case 3 /* Bivariant */:
55254
+ return anyType;
55255
+ case 0 /* Invariant */:
55256
+ return unknownType;
55257
+ }
55258
+ return getBaseConstraintOfType(typeParameter) || unknownType;
55259
+ });
55260
+ return createTypeReference(classType, typeArguments);
55261
+ }
55227
55262
  function getTypeOfPrototypeProperty(prototype) {
55228
- const classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype));
55229
- return classType.typeParameters ? createTypeReference(classType, map(classType.typeParameters, (_) => anyType)) : classType;
55263
+ const classSymbol = getParentOfSymbol(prototype);
55264
+ return getInstanceTypeOfClassSymbol(classSymbol);
55230
55265
  }
55231
55266
  function getTypeOfPropertyOfType(type, name) {
55232
55267
  const prop = getPropertyOfType(type, name);
@@ -60318,7 +60353,7 @@ function createTypeChecker(host) {
60318
60353
  const type = elementTypes[i];
60319
60354
  const flags = target.elementFlags[i];
60320
60355
  if (flags & 8 /* Variadic */) {
60321
- if (type.flags & 58982400 /* InstantiableNonPrimitive */ || everyContainedType(type, isGenericMappedType)) {
60356
+ if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) {
60322
60357
  addElement(type, 8 /* Variadic */, (_a2 = target.labeledElementDeclarations) == null ? void 0 : _a2[i]);
60323
60358
  } else if (isTupleType(type)) {
60324
60359
  const elements = getTypeArguments(type);
@@ -63232,8 +63267,20 @@ function createTypeChecker(host) {
63232
63267
  return result;
63233
63268
  }
63234
63269
  const moreThanOneRealChildren = length(validChildren) > 1;
63235
- const arrayLikeTargetParts = filterType(childrenTargetType, isAssignableToAvailableAnyIterable);
63236
- const nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isAssignableToAvailableAnyIterable(t));
63270
+ let arrayLikeTargetParts;
63271
+ let nonArrayLikeTargetParts;
63272
+ const iterableType = getGlobalIterableType(
63273
+ /*reportErrors*/
63274
+ false
63275
+ );
63276
+ if (iterableType !== emptyGenericType) {
63277
+ const anyIterable = createIterableType(anyType);
63278
+ arrayLikeTargetParts = filterType(childrenTargetType, (t) => isTypeAssignableTo(t, anyIterable));
63279
+ nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isTypeAssignableTo(t, anyIterable));
63280
+ } else {
63281
+ arrayLikeTargetParts = filterType(childrenTargetType, isArrayOrTupleLikeType);
63282
+ nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isArrayOrTupleLikeType(t));
63283
+ }
63237
63284
  if (moreThanOneRealChildren) {
63238
63285
  if (arrayLikeTargetParts !== neverType) {
63239
63286
  const realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */));
@@ -66513,13 +66560,6 @@ function createTypeChecker(host) {
66513
66560
  function isArrayOrTupleLikeType(type) {
66514
66561
  return isArrayLikeType(type) || isTupleLikeType(type);
66515
66562
  }
66516
- function isAssignableToAvailableAnyIterable(type) {
66517
- const anyIterable = getGlobalIterableType(
66518
- /*reportErrors*/
66519
- false
66520
- ) !== emptyGenericType && createIterableType(anyType);
66521
- return anyIterable ? isTypeAssignableTo(type, anyIterable) : isArrayOrTupleLikeType(type);
66522
- }
66523
66563
  function getTupleElementType(type, index) {
66524
66564
  const propType = getTypeOfPropertyOfType(type, "" + index);
66525
66565
  if (propType) {
@@ -69665,8 +69705,8 @@ function createTypeChecker(host) {
69665
69705
  if (symbol === void 0) {
69666
69706
  return type;
69667
69707
  }
69668
- const classSymbol = symbol.parent;
69669
- const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol);
69708
+ const classSymbol = getParentOfSymbol(symbol);
69709
+ const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getInstanceTypeOfClassSymbol(classSymbol);
69670
69710
  return getNarrowedType(
69671
69711
  type,
69672
69712
  targetType,
@@ -71117,7 +71157,7 @@ function createTypeChecker(host) {
71117
71157
  return void 0;
71118
71158
  }
71119
71159
  }
71120
- return isInJSFile(decl2) ? void 0 : getTypeOfExpression(binaryExpression.left);
71160
+ return isInJSFile(decl2) || decl2 === binaryExpression.left ? void 0 : getTypeOfExpression(binaryExpression.left);
71121
71161
  }
71122
71162
  case 1 /* ExportsProperty */:
71123
71163
  case 6 /* Prototype */:
@@ -71193,17 +71233,13 @@ function createTypeChecker(host) {
71193
71233
  type,
71194
71234
  (t) => {
71195
71235
  var _a2;
71196
- if (everyContainedType(t, (t2) => isGenericMappedType(t2) && !t2.declaration.nameType)) {
71197
- const newTypes = mapDefined(t.flags & 2097152 /* Intersection */ ? t.types : [t], (t2) => {
71198
- const mappedType = t2;
71199
- const constraint = getConstraintTypeFromMappedType(mappedType);
71200
- const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
71201
- const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
71202
- if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
71203
- return substituteIndexedMappedType(mappedType, propertyNameType);
71204
- }
71205
- });
71206
- return newTypes.length ? getIntersectionType(newTypes) : void 0;
71236
+ if (isGenericMappedType(t) && !t.declaration.nameType) {
71237
+ const constraint = getConstraintTypeFromMappedType(t);
71238
+ const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
71239
+ const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
71240
+ if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
71241
+ return substituteIndexedMappedType(t, propertyNameType);
71242
+ }
71207
71243
  } else if (t.flags & 3670016 /* StructuredType */) {
71208
71244
  const prop = getPropertyOfType(t, name);
71209
71245
  if (prop) {
@@ -71277,7 +71313,7 @@ function createTypeChecker(host) {
71277
71313
  return void 0;
71278
71314
  }
71279
71315
  function getContextualTypeForElementExpression(arrayContextualType, index) {
71280
- return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(filterType(arrayContextualType, (t) => !!getIndexTypeOfType(t, numberType) || isAssignableToAvailableAnyIterable(t)), "" + index) || mapType(
71316
+ return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) || mapType(
71281
71317
  arrayContextualType,
71282
71318
  (t) => isTupleType(t) ? getElementTypeOfSliceOfTupleType(
71283
71319
  t,
@@ -72019,7 +72055,7 @@ function createTypeChecker(host) {
72019
72055
  const inConstContext = isConstContext(node);
72020
72056
  const checkFlags = inConstContext ? 8 /* Readonly */ : 0;
72021
72057
  const isInJavascript = isInJSFile(node) && !isInJsonFile(node);
72022
- const enumTag = getJSDocEnumTag(node);
72058
+ const enumTag = isInJavascript ? getJSDocEnumTag(node) : void 0;
72023
72059
  const isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
72024
72060
  let objectFlags = freshObjectLiteralFlag;
72025
72061
  let patternWithComputedProperties = false;
@@ -76776,6 +76812,11 @@ function createTypeChecker(host) {
76776
76812
  } else {
76777
76813
  assignNonContextualParameterTypes(signature);
76778
76814
  }
76815
+ } else if (contextualSignature && !node.typeParameters && contextualSignature.parameters.length > node.parameters.length) {
76816
+ const inferenceContext = getInferenceContext(node);
76817
+ if (checkMode && checkMode & 2 /* Inferential */) {
76818
+ inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
76819
+ }
76779
76820
  }
76780
76821
  if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
76781
76822
  const returnType = getReturnTypeFromBody(node, checkMode);
@@ -7141,6 +7141,7 @@ declare namespace ts {
7141
7141
  strictBindCallApply?: boolean;
7142
7142
  strictNullChecks?: boolean;
7143
7143
  strictPropertyInitialization?: boolean;
7144
+ strictInstanceOfTypeParameters?: boolean;
7144
7145
  stripInternal?: boolean;
7145
7146
  suppressExcessPropertyErrors?: boolean;
7146
7147
  suppressImplicitAnyIndexErrors?: boolean;
@@ -8619,6 +8619,7 @@ ${lanes.join("\n")}
8619
8619
  Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(6718, 3 /* Message */, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_6718", "Specify emit/checking behavior for imports that are only used for types."),
8620
8620
  Default_catch_clause_variables_as_unknown_instead_of_any: diag(6803, 3 /* Message */, "Default_catch_clause_variables_as_unknown_instead_of_any_6803", "Default catch clause variables as 'unknown' instead of 'any'."),
8621
8621
  Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_in_the_output_file_s_format_based_on_the_module_setting: diag(6804, 3 /* Message */, "Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_i_6804", "Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting."),
8622
+ Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks: diag(6805, 3 /* Message */, "Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks_6805", "Default type arguments to parameter constraint or 'unknown' instead of 'any' for instance checks."),
8622
8623
  one_of_Colon: diag(6900, 3 /* Message */, "one_of_Colon_6900", "one of:"),
8623
8624
  one_or_more_Colon: diag(6901, 3 /* Message */, "one_or_more_Colon_6901", "one or more:"),
8624
8625
  type_Colon: diag(6902, 3 /* Message */, "type_Colon_6902", "type:"),
@@ -37848,6 +37849,16 @@ ${lanes.join("\n")}
37848
37849
  description: Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
37849
37850
  defaultValueDescription: false
37850
37851
  },
37852
+ {
37853
+ name: "strictInstanceOfTypeParameters",
37854
+ type: "boolean",
37855
+ affectsSemanticDiagnostics: true,
37856
+ affectsBuildInfo: true,
37857
+ strictFlag: true,
37858
+ category: Diagnostics.Type_Checking,
37859
+ description: Diagnostics.Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks,
37860
+ defaultValueDescription: false
37861
+ },
37851
37862
  {
37852
37863
  name: "alwaysStrict",
37853
37864
  type: "boolean",
@@ -45068,6 +45079,7 @@ ${lanes.join("\n")}
45068
45079
  var noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny");
45069
45080
  var noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
45070
45081
  var useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
45082
+ var strictInstanceOfTypeParameters = true;
45071
45083
  var keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
45072
45084
  var defaultIndexFlags = keyofStringsOnly ? 1 /* StringsOnly */ : 0 /* None */;
45073
45085
  var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */;
@@ -53034,9 +53046,32 @@ ${lanes.join("\n")}
53034
53046
  }
53035
53047
  }).parent;
53036
53048
  }
53049
+ function getInstanceTypeOfClassSymbol(classSymbol) {
53050
+ const classType = getDeclaredTypeOfSymbol(classSymbol);
53051
+ const objectFlags = getObjectFlags(classType);
53052
+ if (!(objectFlags & 3 /* ClassOrInterface */) || !classType.typeParameters) {
53053
+ return classType;
53054
+ }
53055
+ const variances = getVariances(classType);
53056
+ const typeArguments = map(classType.typeParameters, (typeParameter, i) => {
53057
+ if (!strictInstanceOfTypeParameters) {
53058
+ return anyType;
53059
+ }
53060
+ const variance = variances[i];
53061
+ switch (variance & 7 /* VarianceMask */) {
53062
+ case 4 /* Independent */:
53063
+ case 3 /* Bivariant */:
53064
+ return anyType;
53065
+ case 0 /* Invariant */:
53066
+ return unknownType;
53067
+ }
53068
+ return getBaseConstraintOfType(typeParameter) || unknownType;
53069
+ });
53070
+ return createTypeReference(classType, typeArguments);
53071
+ }
53037
53072
  function getTypeOfPrototypeProperty(prototype) {
53038
- const classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype));
53039
- return classType.typeParameters ? createTypeReference(classType, map(classType.typeParameters, (_) => anyType)) : classType;
53073
+ const classSymbol = getParentOfSymbol(prototype);
53074
+ return getInstanceTypeOfClassSymbol(classSymbol);
53040
53075
  }
53041
53076
  function getTypeOfPropertyOfType(type, name) {
53042
53077
  const prop = getPropertyOfType(type, name);
@@ -58128,7 +58163,7 @@ ${lanes.join("\n")}
58128
58163
  const type = elementTypes[i];
58129
58164
  const flags = target.elementFlags[i];
58130
58165
  if (flags & 8 /* Variadic */) {
58131
- if (type.flags & 58982400 /* InstantiableNonPrimitive */ || everyContainedType(type, isGenericMappedType)) {
58166
+ if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) {
58132
58167
  addElement(type, 8 /* Variadic */, (_a2 = target.labeledElementDeclarations) == null ? void 0 : _a2[i]);
58133
58168
  } else if (isTupleType(type)) {
58134
58169
  const elements = getTypeArguments(type);
@@ -61042,8 +61077,20 @@ ${lanes.join("\n")}
61042
61077
  return result;
61043
61078
  }
61044
61079
  const moreThanOneRealChildren = length(validChildren) > 1;
61045
- const arrayLikeTargetParts = filterType(childrenTargetType, isAssignableToAvailableAnyIterable);
61046
- const nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isAssignableToAvailableAnyIterable(t));
61080
+ let arrayLikeTargetParts;
61081
+ let nonArrayLikeTargetParts;
61082
+ const iterableType = getGlobalIterableType(
61083
+ /*reportErrors*/
61084
+ false
61085
+ );
61086
+ if (iterableType !== emptyGenericType) {
61087
+ const anyIterable = createIterableType(anyType);
61088
+ arrayLikeTargetParts = filterType(childrenTargetType, (t) => isTypeAssignableTo(t, anyIterable));
61089
+ nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isTypeAssignableTo(t, anyIterable));
61090
+ } else {
61091
+ arrayLikeTargetParts = filterType(childrenTargetType, isArrayOrTupleLikeType);
61092
+ nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isArrayOrTupleLikeType(t));
61093
+ }
61047
61094
  if (moreThanOneRealChildren) {
61048
61095
  if (arrayLikeTargetParts !== neverType) {
61049
61096
  const realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */));
@@ -64323,13 +64370,6 @@ ${lanes.join("\n")}
64323
64370
  function isArrayOrTupleLikeType(type) {
64324
64371
  return isArrayLikeType(type) || isTupleLikeType(type);
64325
64372
  }
64326
- function isAssignableToAvailableAnyIterable(type) {
64327
- const anyIterable = getGlobalIterableType(
64328
- /*reportErrors*/
64329
- false
64330
- ) !== emptyGenericType && createIterableType(anyType);
64331
- return anyIterable ? isTypeAssignableTo(type, anyIterable) : isArrayOrTupleLikeType(type);
64332
- }
64333
64373
  function getTupleElementType(type, index) {
64334
64374
  const propType = getTypeOfPropertyOfType(type, "" + index);
64335
64375
  if (propType) {
@@ -67475,8 +67515,8 @@ ${lanes.join("\n")}
67475
67515
  if (symbol === void 0) {
67476
67516
  return type;
67477
67517
  }
67478
- const classSymbol = symbol.parent;
67479
- const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol);
67518
+ const classSymbol = getParentOfSymbol(symbol);
67519
+ const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getInstanceTypeOfClassSymbol(classSymbol);
67480
67520
  return getNarrowedType(
67481
67521
  type,
67482
67522
  targetType,
@@ -68927,7 +68967,7 @@ ${lanes.join("\n")}
68927
68967
  return void 0;
68928
68968
  }
68929
68969
  }
68930
- return isInJSFile(decl2) ? void 0 : getTypeOfExpression(binaryExpression.left);
68970
+ return isInJSFile(decl2) || decl2 === binaryExpression.left ? void 0 : getTypeOfExpression(binaryExpression.left);
68931
68971
  }
68932
68972
  case 1 /* ExportsProperty */:
68933
68973
  case 6 /* Prototype */:
@@ -69003,17 +69043,13 @@ ${lanes.join("\n")}
69003
69043
  type,
69004
69044
  (t) => {
69005
69045
  var _a2;
69006
- if (everyContainedType(t, (t2) => isGenericMappedType(t2) && !t2.declaration.nameType)) {
69007
- const newTypes = mapDefined(t.flags & 2097152 /* Intersection */ ? t.types : [t], (t2) => {
69008
- const mappedType = t2;
69009
- const constraint = getConstraintTypeFromMappedType(mappedType);
69010
- const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
69011
- const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
69012
- if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
69013
- return substituteIndexedMappedType(mappedType, propertyNameType);
69014
- }
69015
- });
69016
- return newTypes.length ? getIntersectionType(newTypes) : void 0;
69046
+ if (isGenericMappedType(t) && !t.declaration.nameType) {
69047
+ const constraint = getConstraintTypeFromMappedType(t);
69048
+ const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
69049
+ const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
69050
+ if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
69051
+ return substituteIndexedMappedType(t, propertyNameType);
69052
+ }
69017
69053
  } else if (t.flags & 3670016 /* StructuredType */) {
69018
69054
  const prop = getPropertyOfType(t, name);
69019
69055
  if (prop) {
@@ -69087,7 +69123,7 @@ ${lanes.join("\n")}
69087
69123
  return void 0;
69088
69124
  }
69089
69125
  function getContextualTypeForElementExpression(arrayContextualType, index) {
69090
- return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(filterType(arrayContextualType, (t) => !!getIndexTypeOfType(t, numberType) || isAssignableToAvailableAnyIterable(t)), "" + index) || mapType(
69126
+ return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) || mapType(
69091
69127
  arrayContextualType,
69092
69128
  (t) => isTupleType(t) ? getElementTypeOfSliceOfTupleType(
69093
69129
  t,
@@ -69829,7 +69865,7 @@ ${lanes.join("\n")}
69829
69865
  const inConstContext = isConstContext(node);
69830
69866
  const checkFlags = inConstContext ? 8 /* Readonly */ : 0;
69831
69867
  const isInJavascript = isInJSFile(node) && !isInJsonFile(node);
69832
- const enumTag = getJSDocEnumTag(node);
69868
+ const enumTag = isInJavascript ? getJSDocEnumTag(node) : void 0;
69833
69869
  const isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
69834
69870
  let objectFlags = freshObjectLiteralFlag;
69835
69871
  let patternWithComputedProperties = false;
@@ -74586,6 +74622,11 @@ ${lanes.join("\n")}
74586
74622
  } else {
74587
74623
  assignNonContextualParameterTypes(signature);
74588
74624
  }
74625
+ } else if (contextualSignature && !node.typeParameters && contextualSignature.parameters.length > node.parameters.length) {
74626
+ const inferenceContext = getInferenceContext(node);
74627
+ if (checkMode && checkMode & 2 /* Inferential */) {
74628
+ inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
74629
+ }
74589
74630
  }
74590
74631
  if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
74591
74632
  const returnType = getReturnTypeFromBody(node, checkMode);
@@ -3198,6 +3198,7 @@ declare namespace ts {
3198
3198
  strictBindCallApply?: boolean;
3199
3199
  strictNullChecks?: boolean;
3200
3200
  strictPropertyInitialization?: boolean;
3201
+ strictInstanceOfTypeParameters?: boolean;
3201
3202
  stripInternal?: boolean;
3202
3203
  suppressExcessPropertyErrors?: boolean;
3203
3204
  suppressImplicitAnyIndexErrors?: boolean;
package/lib/typescript.js CHANGED
@@ -8619,6 +8619,7 @@ ${lanes.join("\n")}
8619
8619
  Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(6718, 3 /* Message */, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_6718", "Specify emit/checking behavior for imports that are only used for types."),
8620
8620
  Default_catch_clause_variables_as_unknown_instead_of_any: diag(6803, 3 /* Message */, "Default_catch_clause_variables_as_unknown_instead_of_any_6803", "Default catch clause variables as 'unknown' instead of 'any'."),
8621
8621
  Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_in_the_output_file_s_format_based_on_the_module_setting: diag(6804, 3 /* Message */, "Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_i_6804", "Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting."),
8622
+ Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks: diag(6805, 3 /* Message */, "Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks_6805", "Default type arguments to parameter constraint or 'unknown' instead of 'any' for instance checks."),
8622
8623
  one_of_Colon: diag(6900, 3 /* Message */, "one_of_Colon_6900", "one of:"),
8623
8624
  one_or_more_Colon: diag(6901, 3 /* Message */, "one_or_more_Colon_6901", "one or more:"),
8624
8625
  type_Colon: diag(6902, 3 /* Message */, "type_Colon_6902", "type:"),
@@ -37848,6 +37849,16 @@ ${lanes.join("\n")}
37848
37849
  description: Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
37849
37850
  defaultValueDescription: false
37850
37851
  },
37852
+ {
37853
+ name: "strictInstanceOfTypeParameters",
37854
+ type: "boolean",
37855
+ affectsSemanticDiagnostics: true,
37856
+ affectsBuildInfo: true,
37857
+ strictFlag: true,
37858
+ category: Diagnostics.Type_Checking,
37859
+ description: Diagnostics.Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks,
37860
+ defaultValueDescription: false
37861
+ },
37851
37862
  {
37852
37863
  name: "alwaysStrict",
37853
37864
  type: "boolean",
@@ -45068,6 +45079,7 @@ ${lanes.join("\n")}
45068
45079
  var noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny");
45069
45080
  var noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
45070
45081
  var useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
45082
+ var strictInstanceOfTypeParameters = true;
45071
45083
  var keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
45072
45084
  var defaultIndexFlags = keyofStringsOnly ? 1 /* StringsOnly */ : 0 /* None */;
45073
45085
  var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */;
@@ -53034,9 +53046,32 @@ ${lanes.join("\n")}
53034
53046
  }
53035
53047
  }).parent;
53036
53048
  }
53049
+ function getInstanceTypeOfClassSymbol(classSymbol) {
53050
+ const classType = getDeclaredTypeOfSymbol(classSymbol);
53051
+ const objectFlags = getObjectFlags(classType);
53052
+ if (!(objectFlags & 3 /* ClassOrInterface */) || !classType.typeParameters) {
53053
+ return classType;
53054
+ }
53055
+ const variances = getVariances(classType);
53056
+ const typeArguments = map(classType.typeParameters, (typeParameter, i) => {
53057
+ if (!strictInstanceOfTypeParameters) {
53058
+ return anyType;
53059
+ }
53060
+ const variance = variances[i];
53061
+ switch (variance & 7 /* VarianceMask */) {
53062
+ case 4 /* Independent */:
53063
+ case 3 /* Bivariant */:
53064
+ return anyType;
53065
+ case 0 /* Invariant */:
53066
+ return unknownType;
53067
+ }
53068
+ return getBaseConstraintOfType(typeParameter) || unknownType;
53069
+ });
53070
+ return createTypeReference(classType, typeArguments);
53071
+ }
53037
53072
  function getTypeOfPrototypeProperty(prototype) {
53038
- const classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype));
53039
- return classType.typeParameters ? createTypeReference(classType, map(classType.typeParameters, (_) => anyType)) : classType;
53073
+ const classSymbol = getParentOfSymbol(prototype);
53074
+ return getInstanceTypeOfClassSymbol(classSymbol);
53040
53075
  }
53041
53076
  function getTypeOfPropertyOfType(type, name) {
53042
53077
  const prop = getPropertyOfType(type, name);
@@ -58128,7 +58163,7 @@ ${lanes.join("\n")}
58128
58163
  const type = elementTypes[i];
58129
58164
  const flags = target.elementFlags[i];
58130
58165
  if (flags & 8 /* Variadic */) {
58131
- if (type.flags & 58982400 /* InstantiableNonPrimitive */ || everyContainedType(type, isGenericMappedType)) {
58166
+ if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) {
58132
58167
  addElement(type, 8 /* Variadic */, (_a2 = target.labeledElementDeclarations) == null ? void 0 : _a2[i]);
58133
58168
  } else if (isTupleType(type)) {
58134
58169
  const elements = getTypeArguments(type);
@@ -61042,8 +61077,20 @@ ${lanes.join("\n")}
61042
61077
  return result;
61043
61078
  }
61044
61079
  const moreThanOneRealChildren = length(validChildren) > 1;
61045
- const arrayLikeTargetParts = filterType(childrenTargetType, isAssignableToAvailableAnyIterable);
61046
- const nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isAssignableToAvailableAnyIterable(t));
61080
+ let arrayLikeTargetParts;
61081
+ let nonArrayLikeTargetParts;
61082
+ const iterableType = getGlobalIterableType(
61083
+ /*reportErrors*/
61084
+ false
61085
+ );
61086
+ if (iterableType !== emptyGenericType) {
61087
+ const anyIterable = createIterableType(anyType);
61088
+ arrayLikeTargetParts = filterType(childrenTargetType, (t) => isTypeAssignableTo(t, anyIterable));
61089
+ nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isTypeAssignableTo(t, anyIterable));
61090
+ } else {
61091
+ arrayLikeTargetParts = filterType(childrenTargetType, isArrayOrTupleLikeType);
61092
+ nonArrayLikeTargetParts = filterType(childrenTargetType, (t) => !isArrayOrTupleLikeType(t));
61093
+ }
61047
61094
  if (moreThanOneRealChildren) {
61048
61095
  if (arrayLikeTargetParts !== neverType) {
61049
61096
  const realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */));
@@ -64323,13 +64370,6 @@ ${lanes.join("\n")}
64323
64370
  function isArrayOrTupleLikeType(type) {
64324
64371
  return isArrayLikeType(type) || isTupleLikeType(type);
64325
64372
  }
64326
- function isAssignableToAvailableAnyIterable(type) {
64327
- const anyIterable = getGlobalIterableType(
64328
- /*reportErrors*/
64329
- false
64330
- ) !== emptyGenericType && createIterableType(anyType);
64331
- return anyIterable ? isTypeAssignableTo(type, anyIterable) : isArrayOrTupleLikeType(type);
64332
- }
64333
64373
  function getTupleElementType(type, index) {
64334
64374
  const propType = getTypeOfPropertyOfType(type, "" + index);
64335
64375
  if (propType) {
@@ -67475,8 +67515,8 @@ ${lanes.join("\n")}
67475
67515
  if (symbol === void 0) {
67476
67516
  return type;
67477
67517
  }
67478
- const classSymbol = symbol.parent;
67479
- const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol);
67518
+ const classSymbol = getParentOfSymbol(symbol);
67519
+ const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getInstanceTypeOfClassSymbol(classSymbol);
67480
67520
  return getNarrowedType(
67481
67521
  type,
67482
67522
  targetType,
@@ -68927,7 +68967,7 @@ ${lanes.join("\n")}
68927
68967
  return void 0;
68928
68968
  }
68929
68969
  }
68930
- return isInJSFile(decl2) ? void 0 : getTypeOfExpression(binaryExpression.left);
68970
+ return isInJSFile(decl2) || decl2 === binaryExpression.left ? void 0 : getTypeOfExpression(binaryExpression.left);
68931
68971
  }
68932
68972
  case 1 /* ExportsProperty */:
68933
68973
  case 6 /* Prototype */:
@@ -69003,17 +69043,13 @@ ${lanes.join("\n")}
69003
69043
  type,
69004
69044
  (t) => {
69005
69045
  var _a2;
69006
- if (everyContainedType(t, (t2) => isGenericMappedType(t2) && !t2.declaration.nameType)) {
69007
- const newTypes = mapDefined(t.flags & 2097152 /* Intersection */ ? t.types : [t], (t2) => {
69008
- const mappedType = t2;
69009
- const constraint = getConstraintTypeFromMappedType(mappedType);
69010
- const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
69011
- const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
69012
- if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
69013
- return substituteIndexedMappedType(mappedType, propertyNameType);
69014
- }
69015
- });
69016
- return newTypes.length ? getIntersectionType(newTypes) : void 0;
69046
+ if (isGenericMappedType(t) && !t.declaration.nameType) {
69047
+ const constraint = getConstraintTypeFromMappedType(t);
69048
+ const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
69049
+ const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
69050
+ if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
69051
+ return substituteIndexedMappedType(t, propertyNameType);
69052
+ }
69017
69053
  } else if (t.flags & 3670016 /* StructuredType */) {
69018
69054
  const prop = getPropertyOfType(t, name);
69019
69055
  if (prop) {
@@ -69087,7 +69123,7 @@ ${lanes.join("\n")}
69087
69123
  return void 0;
69088
69124
  }
69089
69125
  function getContextualTypeForElementExpression(arrayContextualType, index) {
69090
- return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(filterType(arrayContextualType, (t) => !!getIndexTypeOfType(t, numberType) || isAssignableToAvailableAnyIterable(t)), "" + index) || mapType(
69126
+ return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) || mapType(
69091
69127
  arrayContextualType,
69092
69128
  (t) => isTupleType(t) ? getElementTypeOfSliceOfTupleType(
69093
69129
  t,
@@ -69829,7 +69865,7 @@ ${lanes.join("\n")}
69829
69865
  const inConstContext = isConstContext(node);
69830
69866
  const checkFlags = inConstContext ? 8 /* Readonly */ : 0;
69831
69867
  const isInJavascript = isInJSFile(node) && !isInJsonFile(node);
69832
- const enumTag = getJSDocEnumTag(node);
69868
+ const enumTag = isInJavascript ? getJSDocEnumTag(node) : void 0;
69833
69869
  const isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
69834
69870
  let objectFlags = freshObjectLiteralFlag;
69835
69871
  let patternWithComputedProperties = false;
@@ -74586,6 +74622,11 @@ ${lanes.join("\n")}
74586
74622
  } else {
74587
74623
  assignNonContextualParameterTypes(signature);
74588
74624
  }
74625
+ } else if (contextualSignature && !node.typeParameters && contextualSignature.parameters.length > node.parameters.length) {
74626
+ const inferenceContext = getInferenceContext(node);
74627
+ if (checkMode && checkMode & 2 /* Inferential */) {
74628
+ inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
74629
+ }
74589
74630
  }
74590
74631
  if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
74591
74632
  const returnType = getReturnTypeFromBody(node, checkMode);
@@ -6689,6 +6689,7 @@ var Diagnostics = {
6689
6689
  Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(6718, 3 /* Message */, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_6718", "Specify emit/checking behavior for imports that are only used for types."),
6690
6690
  Default_catch_clause_variables_as_unknown_instead_of_any: diag(6803, 3 /* Message */, "Default_catch_clause_variables_as_unknown_instead_of_any_6803", "Default catch clause variables as 'unknown' instead of 'any'."),
6691
6691
  Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_in_the_output_file_s_format_based_on_the_module_setting: diag(6804, 3 /* Message */, "Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_i_6804", "Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting."),
6692
+ Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks: diag(6805, 3 /* Message */, "Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks_6805", "Default type arguments to parameter constraint or 'unknown' instead of 'any' for instance checks."),
6692
6693
  one_of_Colon: diag(6900, 3 /* Message */, "one_of_Colon_6900", "one of:"),
6693
6694
  one_or_more_Colon: diag(6901, 3 /* Message */, "one_or_more_Colon_6901", "one or more:"),
6694
6695
  type_Colon: diag(6902, 3 /* Message */, "type_Colon_6902", "type:"),
@@ -25897,6 +25898,16 @@ var commandOptionsWithoutBuild = [
25897
25898
  description: Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
25898
25899
  defaultValueDescription: false
25899
25900
  },
25901
+ {
25902
+ name: "strictInstanceOfTypeParameters",
25903
+ type: "boolean",
25904
+ affectsSemanticDiagnostics: true,
25905
+ affectsBuildInfo: true,
25906
+ strictFlag: true,
25907
+ category: Diagnostics.Type_Checking,
25908
+ description: Diagnostics.Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks,
25909
+ defaultValueDescription: false
25910
+ },
25900
25911
  {
25901
25912
  name: "alwaysStrict",
25902
25913
  type: "boolean",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typescript-deploys/pr-build",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.1.0-pr-52062-4",
5
+ "version": "5.1.0-pr-53300-9",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -114,5 +114,5 @@
114
114
  "node": "14.21.1",
115
115
  "npm": "8.19.3"
116
116
  },
117
- "gitHead": "fec434c9c2e6e099b6887aa0986abf354b0c05c5"
117
+ "gitHead": "9d11a451a9b7cee2223e23f50f997867a03547ec"
118
118
  }