@typescript-deploys/pr-build 5.1.0-pr-53292-2 → 5.1.0-pr-49863-27

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
@@ -23,7 +23,7 @@ var __export = (target, all) => {
23
23
 
24
24
  // src/compiler/corePublic.ts
25
25
  var versionMajorMinor = "5.1";
26
- var version = `${versionMajorMinor}.0-insiders.20230316`;
26
+ var version = `${versionMajorMinor}.0-insiders.20230317`;
27
27
 
28
28
  // src/compiler/core.ts
29
29
  var emptyArray = [];
@@ -3721,7 +3721,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
3721
3721
  TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard";
3722
3722
  TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
3723
3723
  TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
3724
- TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323363] = "NotPrimitiveUnion";
3724
+ TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
3725
3725
  return TypeFlags2;
3726
3726
  })(TypeFlags || {});
3727
3727
  var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
@@ -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 = getStrictOptionValue(compilerOptions, "strictInstanceOfTypeParameters");
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 2 /* Contravariant */:
50659
+ return neverType;
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);
@@ -56000,7 +56035,7 @@ function createTypeChecker(host) {
56000
56035
  origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
56001
56036
  }
56002
56037
  }
56003
- const objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
56038
+ const objectFlags = (includes & 36323331 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
56004
56039
  return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
56005
56040
  }
56006
56041
  function getUnionOrIntersectionTypePredicate(signatures, kind) {
@@ -56125,7 +56160,7 @@ function createTypeChecker(host) {
56125
56160
  function eachUnionContains(unionTypes2, type) {
56126
56161
  for (const u of unionTypes2) {
56127
56162
  if (!containsType(u.types, type)) {
56128
- const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & 256 /* NumberLiteral */ ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
56163
+ const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & (32 /* Enum */ | 256 /* NumberLiteral */) ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
56129
56164
  if (!primitive || !containsType(u.types, primitive)) {
56130
56165
  return false;
56131
56166
  }
@@ -56152,9 +56187,6 @@ function createTypeChecker(host) {
56152
56187
  }
56153
56188
  return false;
56154
56189
  }
56155
- function eachIsUnionContaining(types, flag) {
56156
- return every(types, (t) => !!(t.flags & 1048576 /* Union */) && some(t.types, (tt) => !!(tt.flags & flag)));
56157
- }
56158
56190
  function removeFromEach(types, flag) {
56159
56191
  for (let i = 0; i < types.length; i++) {
56160
56192
  types[i] = filterType(types[i], (t) => !(t.flags & flag));
@@ -56243,11 +56275,11 @@ function createTypeChecker(host) {
56243
56275
  if (includes & 1048576 /* Union */) {
56244
56276
  if (intersectUnionsOfPrimitiveTypes(typeSet)) {
56245
56277
  result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
56246
- } else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
56278
+ } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags & 32768 /* Undefined */))) {
56247
56279
  const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
56248
56280
  removeFromEach(typeSet, 32768 /* Undefined */);
56249
56281
  result = getUnionType([getIntersectionType(typeSet), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
56250
- } else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
56282
+ } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
56251
56283
  removeFromEach(typeSet, 65536 /* Null */);
56252
56284
  result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
56253
56285
  } else {
@@ -59772,6 +59804,11 @@ function createTypeChecker(host) {
59772
59804
  if (containsType(targetTypes, source2)) {
59773
59805
  return -1 /* True */;
59774
59806
  }
59807
+ if (getObjectFlags(target2) & 32768 /* PrimitiveUnion */ && !(source2.flags & 1024 /* EnumLiteral */) && (source2.flags & (128 /* StringLiteral */ | 512 /* BooleanLiteral */ | 2048 /* BigIntLiteral */) || (relation === subtypeRelation || relation === strictSubtypeRelation) && source2.flags & 256 /* NumberLiteral */)) {
59808
+ const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
59809
+ const primitive = source2.flags & 128 /* StringLiteral */ ? stringType : source2.flags & 256 /* NumberLiteral */ ? numberType : source2.flags & 2048 /* BigIntLiteral */ ? bigintType : void 0;
59810
+ return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
59811
+ }
59775
59812
  const match = getMatchingUnionConstituentForType(target2, source2);
59776
59813
  if (match) {
59777
59814
  const related = isRelatedTo(
@@ -65073,8 +65110,8 @@ function createTypeChecker(host) {
65073
65110
  if (symbol === void 0) {
65074
65111
  return type;
65075
65112
  }
65076
- const classSymbol = symbol.parent;
65077
- const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol);
65113
+ const classSymbol = getParentOfSymbol(symbol);
65114
+ const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getInstanceTypeOfClassSymbol(classSymbol);
65078
65115
  return getNarrowedType(
65079
65116
  type,
65080
65117
  targetType,
@@ -66525,7 +66562,7 @@ function createTypeChecker(host) {
66525
66562
  return void 0;
66526
66563
  }
66527
66564
  }
66528
- return isInJSFile(decl2) ? void 0 : getTypeOfExpression(binaryExpression.left);
66565
+ return isInJSFile(decl2) || decl2 === binaryExpression.left ? void 0 : getTypeOfExpression(binaryExpression.left);
66529
66566
  }
66530
66567
  case 1 /* ExportsProperty */:
66531
66568
  case 6 /* Prototype */:
@@ -67423,7 +67460,7 @@ function createTypeChecker(host) {
67423
67460
  const inConstContext = isConstContext(node);
67424
67461
  const checkFlags = inConstContext ? 8 /* Readonly */ : 0;
67425
67462
  const isInJavascript = isInJSFile(node) && !isInJsonFile(node);
67426
- const enumTag = getJSDocEnumTag(node);
67463
+ const enumTag = isInJavascript ? getJSDocEnumTag(node) : void 0;
67427
67464
  const isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
67428
67465
  let objectFlags = freshObjectLiteralFlag;
67429
67466
  let patternWithComputedProperties = false;
@@ -72180,6 +72217,11 @@ function createTypeChecker(host) {
72180
72217
  } else {
72181
72218
  assignNonContextualParameterTypes(signature);
72182
72219
  }
72220
+ } else if (contextualSignature && !node.typeParameters && contextualSignature.parameters.length > node.parameters.length) {
72221
+ const inferenceContext = getInferenceContext(node);
72222
+ if (checkMode && checkMode & 2 /* Inferential */) {
72223
+ inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
72224
+ }
72183
72225
  }
72184
72226
  if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
72185
72227
  const returnType = getReturnTypeFromBody(node, checkMode);
package/lib/tsserver.js CHANGED
@@ -2285,7 +2285,7 @@ module.exports = __toCommonJS(server_exports);
2285
2285
 
2286
2286
  // src/compiler/corePublic.ts
2287
2287
  var versionMajorMinor = "5.1";
2288
- var version = `${versionMajorMinor}.0-insiders.20230316`;
2288
+ var version = `${versionMajorMinor}.0-insiders.20230317`;
2289
2289
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2290
2290
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2291
2291
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -6642,7 +6642,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
6642
6642
  TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard";
6643
6643
  TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
6644
6644
  TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
6645
- TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323363] = "NotPrimitiveUnion";
6645
+ TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
6646
6646
  return TypeFlags2;
6647
6647
  })(TypeFlags || {});
6648
6648
  var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
@@ -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 = getStrictOptionValue(compilerOptions, "strictInstanceOfTypeParameters");
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 2 /* Contravariant */:
55256
+ return neverType;
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);
@@ -60597,7 +60632,7 @@ function createTypeChecker(host) {
60597
60632
  origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
60598
60633
  }
60599
60634
  }
60600
- const objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
60635
+ const objectFlags = (includes & 36323331 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
60601
60636
  return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
60602
60637
  }
60603
60638
  function getUnionOrIntersectionTypePredicate(signatures, kind) {
@@ -60722,7 +60757,7 @@ function createTypeChecker(host) {
60722
60757
  function eachUnionContains(unionTypes2, type) {
60723
60758
  for (const u of unionTypes2) {
60724
60759
  if (!containsType(u.types, type)) {
60725
- const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & 256 /* NumberLiteral */ ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
60760
+ const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & (32 /* Enum */ | 256 /* NumberLiteral */) ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
60726
60761
  if (!primitive || !containsType(u.types, primitive)) {
60727
60762
  return false;
60728
60763
  }
@@ -60749,9 +60784,6 @@ function createTypeChecker(host) {
60749
60784
  }
60750
60785
  return false;
60751
60786
  }
60752
- function eachIsUnionContaining(types, flag) {
60753
- return every(types, (t) => !!(t.flags & 1048576 /* Union */) && some(t.types, (tt) => !!(tt.flags & flag)));
60754
- }
60755
60787
  function removeFromEach(types, flag) {
60756
60788
  for (let i = 0; i < types.length; i++) {
60757
60789
  types[i] = filterType(types[i], (t) => !(t.flags & flag));
@@ -60840,11 +60872,11 @@ function createTypeChecker(host) {
60840
60872
  if (includes & 1048576 /* Union */) {
60841
60873
  if (intersectUnionsOfPrimitiveTypes(typeSet)) {
60842
60874
  result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
60843
- } else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
60875
+ } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags & 32768 /* Undefined */))) {
60844
60876
  const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
60845
60877
  removeFromEach(typeSet, 32768 /* Undefined */);
60846
60878
  result = getUnionType([getIntersectionType(typeSet), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
60847
- } else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
60879
+ } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
60848
60880
  removeFromEach(typeSet, 65536 /* Null */);
60849
60881
  result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
60850
60882
  } else {
@@ -64369,6 +64401,11 @@ function createTypeChecker(host) {
64369
64401
  if (containsType(targetTypes, source2)) {
64370
64402
  return -1 /* True */;
64371
64403
  }
64404
+ if (getObjectFlags(target2) & 32768 /* PrimitiveUnion */ && !(source2.flags & 1024 /* EnumLiteral */) && (source2.flags & (128 /* StringLiteral */ | 512 /* BooleanLiteral */ | 2048 /* BigIntLiteral */) || (relation === subtypeRelation || relation === strictSubtypeRelation) && source2.flags & 256 /* NumberLiteral */)) {
64405
+ const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
64406
+ const primitive = source2.flags & 128 /* StringLiteral */ ? stringType : source2.flags & 256 /* NumberLiteral */ ? numberType : source2.flags & 2048 /* BigIntLiteral */ ? bigintType : void 0;
64407
+ return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
64408
+ }
64372
64409
  const match = getMatchingUnionConstituentForType(target2, source2);
64373
64410
  if (match) {
64374
64411
  const related = isRelatedTo(
@@ -69670,8 +69707,8 @@ function createTypeChecker(host) {
69670
69707
  if (symbol === void 0) {
69671
69708
  return type;
69672
69709
  }
69673
- const classSymbol = symbol.parent;
69674
- const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol);
69710
+ const classSymbol = getParentOfSymbol(symbol);
69711
+ const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getInstanceTypeOfClassSymbol(classSymbol);
69675
69712
  return getNarrowedType(
69676
69713
  type,
69677
69714
  targetType,
@@ -71122,7 +71159,7 @@ function createTypeChecker(host) {
71122
71159
  return void 0;
71123
71160
  }
71124
71161
  }
71125
- return isInJSFile(decl2) ? void 0 : getTypeOfExpression(binaryExpression.left);
71162
+ return isInJSFile(decl2) || decl2 === binaryExpression.left ? void 0 : getTypeOfExpression(binaryExpression.left);
71126
71163
  }
71127
71164
  case 1 /* ExportsProperty */:
71128
71165
  case 6 /* Prototype */:
@@ -72020,7 +72057,7 @@ function createTypeChecker(host) {
72020
72057
  const inConstContext = isConstContext(node);
72021
72058
  const checkFlags = inConstContext ? 8 /* Readonly */ : 0;
72022
72059
  const isInJavascript = isInJSFile(node) && !isInJsonFile(node);
72023
- const enumTag = getJSDocEnumTag(node);
72060
+ const enumTag = isInJavascript ? getJSDocEnumTag(node) : void 0;
72024
72061
  const isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
72025
72062
  let objectFlags = freshObjectLiteralFlag;
72026
72063
  let patternWithComputedProperties = false;
@@ -76777,6 +76814,11 @@ function createTypeChecker(host) {
76777
76814
  } else {
76778
76815
  assignNonContextualParameterTypes(signature);
76779
76816
  }
76817
+ } else if (contextualSignature && !node.typeParameters && contextualSignature.parameters.length > node.parameters.length) {
76818
+ const inferenceContext = getInferenceContext(node);
76819
+ if (checkMode && checkMode & 2 /* Inferential */) {
76820
+ inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
76821
+ }
76780
76822
  }
76781
76823
  if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
76782
76824
  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;
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.1";
38
- version = `${versionMajorMinor}.0-insiders.20230316`;
38
+ version = `${versionMajorMinor}.0-insiders.20230317`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -4449,7 +4449,7 @@ ${lanes.join("\n")}
4449
4449
  TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard";
4450
4450
  TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
4451
4451
  TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
4452
- TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323363] = "NotPrimitiveUnion";
4452
+ TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
4453
4453
  return TypeFlags2;
4454
4454
  })(TypeFlags || {});
4455
4455
  ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
@@ -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 = getStrictOptionValue(compilerOptions, "strictInstanceOfTypeParameters");
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 2 /* Contravariant */:
53066
+ return neverType;
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);
@@ -58407,7 +58442,7 @@ ${lanes.join("\n")}
58407
58442
  origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
58408
58443
  }
58409
58444
  }
58410
- const objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
58445
+ const objectFlags = (includes & 36323331 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
58411
58446
  return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
58412
58447
  }
58413
58448
  function getUnionOrIntersectionTypePredicate(signatures, kind) {
@@ -58532,7 +58567,7 @@ ${lanes.join("\n")}
58532
58567
  function eachUnionContains(unionTypes2, type) {
58533
58568
  for (const u of unionTypes2) {
58534
58569
  if (!containsType(u.types, type)) {
58535
- const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & 256 /* NumberLiteral */ ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
58570
+ const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & (32 /* Enum */ | 256 /* NumberLiteral */) ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
58536
58571
  if (!primitive || !containsType(u.types, primitive)) {
58537
58572
  return false;
58538
58573
  }
@@ -58559,9 +58594,6 @@ ${lanes.join("\n")}
58559
58594
  }
58560
58595
  return false;
58561
58596
  }
58562
- function eachIsUnionContaining(types, flag) {
58563
- return every(types, (t) => !!(t.flags & 1048576 /* Union */) && some(t.types, (tt) => !!(tt.flags & flag)));
58564
- }
58565
58597
  function removeFromEach(types, flag) {
58566
58598
  for (let i = 0; i < types.length; i++) {
58567
58599
  types[i] = filterType(types[i], (t) => !(t.flags & flag));
@@ -58650,11 +58682,11 @@ ${lanes.join("\n")}
58650
58682
  if (includes & 1048576 /* Union */) {
58651
58683
  if (intersectUnionsOfPrimitiveTypes(typeSet)) {
58652
58684
  result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
58653
- } else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
58685
+ } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags & 32768 /* Undefined */))) {
58654
58686
  const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
58655
58687
  removeFromEach(typeSet, 32768 /* Undefined */);
58656
58688
  result = getUnionType([getIntersectionType(typeSet), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
58657
- } else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
58689
+ } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
58658
58690
  removeFromEach(typeSet, 65536 /* Null */);
58659
58691
  result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
58660
58692
  } else {
@@ -62179,6 +62211,11 @@ ${lanes.join("\n")}
62179
62211
  if (containsType(targetTypes, source2)) {
62180
62212
  return -1 /* True */;
62181
62213
  }
62214
+ if (getObjectFlags(target2) & 32768 /* PrimitiveUnion */ && !(source2.flags & 1024 /* EnumLiteral */) && (source2.flags & (128 /* StringLiteral */ | 512 /* BooleanLiteral */ | 2048 /* BigIntLiteral */) || (relation === subtypeRelation || relation === strictSubtypeRelation) && source2.flags & 256 /* NumberLiteral */)) {
62215
+ const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
62216
+ const primitive = source2.flags & 128 /* StringLiteral */ ? stringType : source2.flags & 256 /* NumberLiteral */ ? numberType : source2.flags & 2048 /* BigIntLiteral */ ? bigintType : void 0;
62217
+ return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
62218
+ }
62182
62219
  const match = getMatchingUnionConstituentForType(target2, source2);
62183
62220
  if (match) {
62184
62221
  const related = isRelatedTo(
@@ -67480,8 +67517,8 @@ ${lanes.join("\n")}
67480
67517
  if (symbol === void 0) {
67481
67518
  return type;
67482
67519
  }
67483
- const classSymbol = symbol.parent;
67484
- const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol);
67520
+ const classSymbol = getParentOfSymbol(symbol);
67521
+ const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getInstanceTypeOfClassSymbol(classSymbol);
67485
67522
  return getNarrowedType(
67486
67523
  type,
67487
67524
  targetType,
@@ -68932,7 +68969,7 @@ ${lanes.join("\n")}
68932
68969
  return void 0;
68933
68970
  }
68934
68971
  }
68935
- return isInJSFile(decl2) ? void 0 : getTypeOfExpression(binaryExpression.left);
68972
+ return isInJSFile(decl2) || decl2 === binaryExpression.left ? void 0 : getTypeOfExpression(binaryExpression.left);
68936
68973
  }
68937
68974
  case 1 /* ExportsProperty */:
68938
68975
  case 6 /* Prototype */:
@@ -69830,7 +69867,7 @@ ${lanes.join("\n")}
69830
69867
  const inConstContext = isConstContext(node);
69831
69868
  const checkFlags = inConstContext ? 8 /* Readonly */ : 0;
69832
69869
  const isInJavascript = isInJSFile(node) && !isInJsonFile(node);
69833
- const enumTag = getJSDocEnumTag(node);
69870
+ const enumTag = isInJavascript ? getJSDocEnumTag(node) : void 0;
69834
69871
  const isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
69835
69872
  let objectFlags = freshObjectLiteralFlag;
69836
69873
  let patternWithComputedProperties = false;
@@ -74587,6 +74624,11 @@ ${lanes.join("\n")}
74587
74624
  } else {
74588
74625
  assignNonContextualParameterTypes(signature);
74589
74626
  }
74627
+ } else if (contextualSignature && !node.typeParameters && contextualSignature.parameters.length > node.parameters.length) {
74628
+ const inferenceContext = getInferenceContext(node);
74629
+ if (checkMode && checkMode & 2 /* Inferential */) {
74630
+ inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
74631
+ }
74590
74632
  }
74591
74633
  if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
74592
74634
  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
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.1";
38
- version = `${versionMajorMinor}.0-insiders.20230316`;
38
+ version = `${versionMajorMinor}.0-insiders.20230317`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -4449,7 +4449,7 @@ ${lanes.join("\n")}
4449
4449
  TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard";
4450
4450
  TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
4451
4451
  TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
4452
- TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323363] = "NotPrimitiveUnion";
4452
+ TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
4453
4453
  return TypeFlags2;
4454
4454
  })(TypeFlags || {});
4455
4455
  ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
@@ -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 = getStrictOptionValue(compilerOptions, "strictInstanceOfTypeParameters");
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 2 /* Contravariant */:
53066
+ return neverType;
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);
@@ -58407,7 +58442,7 @@ ${lanes.join("\n")}
58407
58442
  origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
58408
58443
  }
58409
58444
  }
58410
- const objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
58445
+ const objectFlags = (includes & 36323331 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
58411
58446
  return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
58412
58447
  }
58413
58448
  function getUnionOrIntersectionTypePredicate(signatures, kind) {
@@ -58532,7 +58567,7 @@ ${lanes.join("\n")}
58532
58567
  function eachUnionContains(unionTypes2, type) {
58533
58568
  for (const u of unionTypes2) {
58534
58569
  if (!containsType(u.types, type)) {
58535
- const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & 256 /* NumberLiteral */ ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
58570
+ const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & (32 /* Enum */ | 256 /* NumberLiteral */) ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
58536
58571
  if (!primitive || !containsType(u.types, primitive)) {
58537
58572
  return false;
58538
58573
  }
@@ -58559,9 +58594,6 @@ ${lanes.join("\n")}
58559
58594
  }
58560
58595
  return false;
58561
58596
  }
58562
- function eachIsUnionContaining(types, flag) {
58563
- return every(types, (t) => !!(t.flags & 1048576 /* Union */) && some(t.types, (tt) => !!(tt.flags & flag)));
58564
- }
58565
58597
  function removeFromEach(types, flag) {
58566
58598
  for (let i = 0; i < types.length; i++) {
58567
58599
  types[i] = filterType(types[i], (t) => !(t.flags & flag));
@@ -58650,11 +58682,11 @@ ${lanes.join("\n")}
58650
58682
  if (includes & 1048576 /* Union */) {
58651
58683
  if (intersectUnionsOfPrimitiveTypes(typeSet)) {
58652
58684
  result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
58653
- } else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
58685
+ } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags & 32768 /* Undefined */))) {
58654
58686
  const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
58655
58687
  removeFromEach(typeSet, 32768 /* Undefined */);
58656
58688
  result = getUnionType([getIntersectionType(typeSet), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
58657
- } else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
58689
+ } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
58658
58690
  removeFromEach(typeSet, 65536 /* Null */);
58659
58691
  result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
58660
58692
  } else {
@@ -62179,6 +62211,11 @@ ${lanes.join("\n")}
62179
62211
  if (containsType(targetTypes, source2)) {
62180
62212
  return -1 /* True */;
62181
62213
  }
62214
+ if (getObjectFlags(target2) & 32768 /* PrimitiveUnion */ && !(source2.flags & 1024 /* EnumLiteral */) && (source2.flags & (128 /* StringLiteral */ | 512 /* BooleanLiteral */ | 2048 /* BigIntLiteral */) || (relation === subtypeRelation || relation === strictSubtypeRelation) && source2.flags & 256 /* NumberLiteral */)) {
62215
+ const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
62216
+ const primitive = source2.flags & 128 /* StringLiteral */ ? stringType : source2.flags & 256 /* NumberLiteral */ ? numberType : source2.flags & 2048 /* BigIntLiteral */ ? bigintType : void 0;
62217
+ return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
62218
+ }
62182
62219
  const match = getMatchingUnionConstituentForType(target2, source2);
62183
62220
  if (match) {
62184
62221
  const related = isRelatedTo(
@@ -67480,8 +67517,8 @@ ${lanes.join("\n")}
67480
67517
  if (symbol === void 0) {
67481
67518
  return type;
67482
67519
  }
67483
- const classSymbol = symbol.parent;
67484
- const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol);
67520
+ const classSymbol = getParentOfSymbol(symbol);
67521
+ const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getInstanceTypeOfClassSymbol(classSymbol);
67485
67522
  return getNarrowedType(
67486
67523
  type,
67487
67524
  targetType,
@@ -68932,7 +68969,7 @@ ${lanes.join("\n")}
68932
68969
  return void 0;
68933
68970
  }
68934
68971
  }
68935
- return isInJSFile(decl2) ? void 0 : getTypeOfExpression(binaryExpression.left);
68972
+ return isInJSFile(decl2) || decl2 === binaryExpression.left ? void 0 : getTypeOfExpression(binaryExpression.left);
68936
68973
  }
68937
68974
  case 1 /* ExportsProperty */:
68938
68975
  case 6 /* Prototype */:
@@ -69830,7 +69867,7 @@ ${lanes.join("\n")}
69830
69867
  const inConstContext = isConstContext(node);
69831
69868
  const checkFlags = inConstContext ? 8 /* Readonly */ : 0;
69832
69869
  const isInJavascript = isInJSFile(node) && !isInJsonFile(node);
69833
- const enumTag = getJSDocEnumTag(node);
69870
+ const enumTag = isInJavascript ? getJSDocEnumTag(node) : void 0;
69834
69871
  const isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
69835
69872
  let objectFlags = freshObjectLiteralFlag;
69836
69873
  let patternWithComputedProperties = false;
@@ -74587,6 +74624,11 @@ ${lanes.join("\n")}
74587
74624
  } else {
74588
74625
  assignNonContextualParameterTypes(signature);
74589
74626
  }
74627
+ } else if (contextualSignature && !node.typeParameters && contextualSignature.parameters.length > node.parameters.length) {
74628
+ const inferenceContext = getInferenceContext(node);
74629
+ if (checkMode && checkMode & 2 /* Inferential */) {
74630
+ inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
74631
+ }
74590
74632
  }
74591
74633
  if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
74592
74634
  const returnType = getReturnTypeFromBody(node, checkMode);
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.1";
57
- var version = `${versionMajorMinor}.0-insiders.20230316`;
57
+ var version = `${versionMajorMinor}.0-insiders.20230317`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -3127,7 +3127,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
3127
3127
  TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard";
3128
3128
  TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
3129
3129
  TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
3130
- TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323363] = "NotPrimitiveUnion";
3130
+ TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
3131
3131
  return TypeFlags2;
3132
3132
  })(TypeFlags || {});
3133
3133
  var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
@@ -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",
@@ -31585,24 +31596,21 @@ function installNpmPackages(npmPath, tsVersion, packageNames, install) {
31585
31596
  for (let remaining = packageNames.length; remaining > 0; ) {
31586
31597
  const result = getNpmCommandForInstallation(npmPath, tsVersion, packageNames, remaining);
31587
31598
  remaining = result.remaining;
31588
- hasError = install(result.command, result.args) || hasError;
31599
+ hasError = install(result.command) || hasError;
31589
31600
  }
31590
31601
  return hasError;
31591
31602
  }
31592
31603
  function getNpmCommandForInstallation(npmPath, tsVersion, packageNames, remaining) {
31593
31604
  const sliceStart = packageNames.length - remaining;
31594
- let toSlice = remaining;
31595
- let args;
31605
+ let command, toSlice = remaining;
31596
31606
  while (true) {
31597
- const slice = toSlice === packageNames.length ? packageNames : packageNames.slice(sliceStart, sliceStart + toSlice);
31598
- const length2 = reduceLeft(slice, (total, pkg) => total + pkg.length, 0);
31599
- if (length2 < 8e3) {
31600
- args = ["install", "--ignore-scripts", ...slice, "--save-dev", `--user-agent=typesInstaller/${tsVersion}`];
31607
+ command = `${npmPath} install --ignore-scripts ${(toSlice === packageNames.length ? packageNames : packageNames.slice(sliceStart, sliceStart + toSlice)).join(" ")} --save-dev --user-agent="typesInstaller/${tsVersion}"`;
31608
+ if (command.length < 8e3) {
31601
31609
  break;
31602
31610
  }
31603
31611
  toSlice = toSlice - Math.floor(toSlice / 2);
31604
31612
  }
31605
- return { command: npmPath, args, remaining: remaining - toSlice };
31613
+ return { command, remaining: remaining - toSlice };
31606
31614
  }
31607
31615
  function endsWith2(str, suffix, caseSensitive) {
31608
31616
  const expectedPos = str.length - suffix.length;
@@ -32062,13 +32070,13 @@ var NodeTypingsInstaller = class extends TypingsInstaller {
32062
32070
  this.log.writeLine(`NPM location: ${this.npmPath} (explicit '${Arguments.NpmLocation}' ${npmLocation2 === void 0 ? "not " : ""} provided)`);
32063
32071
  this.log.writeLine(`validateDefaultNpmLocation: ${validateDefaultNpmLocation2}`);
32064
32072
  }
32065
- ({ execSync: this.nodeExecFileSync } = require("child_process"));
32073
+ ({ execSync: this.nodeExecSync } = require("child_process"));
32066
32074
  this.ensurePackageDirectoryExists(globalTypingsCacheLocation2);
32067
32075
  try {
32068
32076
  if (this.log.isEnabled()) {
32069
32077
  this.log.writeLine(`Updating ${typesRegistryPackageName} npm package...`);
32070
32078
  }
32071
- this.execFileSyncAndLog(this.npmPath, ["install", "--ignore-scripts", `${typesRegistryPackageName}@${this.latestDistTag}`], { cwd: globalTypingsCacheLocation2 });
32079
+ this.execSyncAndLog(`${this.npmPath} install --ignore-scripts ${typesRegistryPackageName}@${this.latestDistTag}`, { cwd: globalTypingsCacheLocation2 });
32072
32080
  if (this.log.isEnabled()) {
32073
32081
  this.log.writeLine(`Updated ${typesRegistryPackageName} npm package`);
32074
32082
  }
@@ -32139,19 +32147,19 @@ var NodeTypingsInstaller = class extends TypingsInstaller {
32139
32147
  this.log.writeLine(`#${requestId} with arguments'${JSON.stringify(packageNames)}'.`);
32140
32148
  }
32141
32149
  const start = Date.now();
32142
- const hasError = installNpmPackages(this.npmPath, version, packageNames, (command, args) => this.execFileSyncAndLog(command, args, { cwd }));
32150
+ const hasError = installNpmPackages(this.npmPath, version, packageNames, (command) => this.execSyncAndLog(command, { cwd }));
32143
32151
  if (this.log.isEnabled()) {
32144
32152
  this.log.writeLine(`npm install #${requestId} took: ${Date.now() - start} ms`);
32145
32153
  }
32146
32154
  onRequestCompleted(!hasError);
32147
32155
  }
32148
32156
  /** Returns 'true' in case of error. */
32149
- execFileSyncAndLog(command, args, options) {
32157
+ execSyncAndLog(command, options) {
32150
32158
  if (this.log.isEnabled()) {
32151
32159
  this.log.writeLine(`Exec: ${command}`);
32152
32160
  }
32153
32161
  try {
32154
- const stdout = this.nodeExecFileSync(command, args, { ...options, encoding: "utf-8", timeout: 1e4 });
32162
+ const stdout = this.nodeExecSync(command, { ...options, encoding: "utf-8" });
32155
32163
  if (this.log.isEnabled()) {
32156
32164
  this.log.writeLine(` Succeeded. stdout:${indent(sys.newLine, stdout)}`);
32157
32165
  }
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-53292-2",
5
+ "version": "5.1.0-pr-49863-27",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -79,7 +79,7 @@
79
79
  "node-fetch": "^3.2.10",
80
80
  "source-map-support": "^0.5.21",
81
81
  "tslib": "^2.5.0",
82
- "typescript": "5.0.1-rc",
82
+ "typescript": "^5.0.2",
83
83
  "which": "^2.0.2"
84
84
  },
85
85
  "overrides": {
@@ -114,5 +114,5 @@
114
114
  "node": "14.21.1",
115
115
  "npm": "8.19.3"
116
116
  },
117
- "gitHead": "d914d6c336c9c603779e8e9001e3be829e54b878"
117
+ "gitHead": "a6ea599f1c25108b1745bc28aef501251ff356b9"
118
118
  }