@typescript-deploys/pr-build 5.1.0-pr-53323-7 → 5.1.0-pr-49863-30

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
@@ -6657,7 +6657,6 @@ var Diagnostics = {
6657
6657
  This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
6658
6658
  A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead: diag(2846, 1 /* Error */, "A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_f_2846", "A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '{0}' instead?"),
6659
6659
  A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2847, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2847", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
6660
- The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression: diag(2848, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression_2848", "The right-hand side of an 'instanceof' expression must not be an instantiation expression."),
6661
6660
  Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
6662
6661
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
6663
6662
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -7335,6 +7334,7 @@ var Diagnostics = {
7335
7334
  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."),
7336
7335
  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'."),
7337
7336
  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."),
7337
+ 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."),
7338
7338
  one_of_Colon: diag(6900, 3 /* Message */, "one_of_Colon_6900", "one of:"),
7339
7339
  one_or_more_Colon: diag(6901, 3 /* Message */, "one_or_more_Colon_6901", "one or more:"),
7340
7340
  type_Colon: diag(6902, 3 /* Message */, "type_Colon_6902", "type:"),
@@ -33860,6 +33860,16 @@ var commandOptionsWithoutBuild = [
33860
33860
  description: Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
33861
33861
  defaultValueDescription: false
33862
33862
  },
33863
+ {
33864
+ name: "strictInstanceOfTypeParameters",
33865
+ type: "boolean",
33866
+ affectsSemanticDiagnostics: true,
33867
+ affectsBuildInfo: true,
33868
+ strictFlag: true,
33869
+ category: Diagnostics.Type_Checking,
33870
+ description: Diagnostics.Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks,
33871
+ defaultValueDescription: false
33872
+ },
33863
33873
  {
33864
33874
  name: "alwaysStrict",
33865
33875
  type: "boolean",
@@ -42663,6 +42673,7 @@ function createTypeChecker(host) {
42663
42673
  var noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny");
42664
42674
  var noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
42665
42675
  var useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
42676
+ var strictInstanceOfTypeParameters = getStrictOptionValue(compilerOptions, "strictInstanceOfTypeParameters");
42666
42677
  var keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
42667
42678
  var defaultIndexFlags = keyofStringsOnly ? 1 /* StringsOnly */ : 0 /* None */;
42668
42679
  var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */;
@@ -50629,9 +50640,30 @@ function createTypeChecker(host) {
50629
50640
  }
50630
50641
  }).parent;
50631
50642
  }
50643
+ function getInstanceTypeOfClassSymbol(classSymbol) {
50644
+ const classType = getDeclaredTypeOfSymbol(classSymbol);
50645
+ const objectFlags = getObjectFlags(classType);
50646
+ if (!(objectFlags & 3 /* ClassOrInterface */) || !classType.typeParameters) {
50647
+ return classType;
50648
+ }
50649
+ const variances = getVariances(classType);
50650
+ const typeArguments = map(classType.typeParameters, (typeParameter, i) => {
50651
+ if (!strictInstanceOfTypeParameters) {
50652
+ return anyType;
50653
+ }
50654
+ const variance = variances[i];
50655
+ switch (variance & 7 /* VarianceMask */) {
50656
+ case 2 /* Contravariant */:
50657
+ case 3 /* Bivariant */:
50658
+ return neverType;
50659
+ }
50660
+ return getBaseConstraintOfType(typeParameter) || unknownType;
50661
+ });
50662
+ return createTypeReference(classType, typeArguments);
50663
+ }
50632
50664
  function getTypeOfPrototypeProperty(prototype) {
50633
- const classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype));
50634
- return classType.typeParameters ? createTypeReference(classType, map(classType.typeParameters, (_) => anyType)) : classType;
50665
+ const classSymbol = getParentOfSymbol(prototype);
50666
+ return getInstanceTypeOfClassSymbol(classSymbol);
50635
50667
  }
50636
50668
  function getTypeOfPropertyOfType(type, name) {
50637
50669
  const prop = getPropertyOfType(type, name);
@@ -65077,8 +65109,8 @@ function createTypeChecker(host) {
65077
65109
  if (symbol === void 0) {
65078
65110
  return type;
65079
65111
  }
65080
- const classSymbol = symbol.parent;
65081
- const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol);
65112
+ const classSymbol = getParentOfSymbol(symbol);
65113
+ const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getInstanceTypeOfClassSymbol(classSymbol);
65082
65114
  return getNarrowedType(
65083
65115
  type,
65084
65116
  targetType,
@@ -71133,12 +71165,6 @@ function createTypeChecker(host) {
71133
71165
  function checkExpressionWithTypeArguments(node) {
71134
71166
  checkGrammarExpressionWithTypeArguments(node);
71135
71167
  forEach(node.typeArguments, checkSourceElement);
71136
- if (node.kind === 231 /* ExpressionWithTypeArguments */) {
71137
- const parent = walkUpParenthesizedExpressions(node.parent);
71138
- if (parent.kind === 224 /* BinaryExpression */ && parent.operatorToken.kind === 103 /* InstanceOfKeyword */ && isNodeDescendantOf(node, parent.right)) {
71139
- error(node, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression);
71140
- }
71141
- }
71142
71168
  const exprType = node.kind === 231 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName);
71143
71169
  return getInstantiationExpressionType(exprType, node);
71144
71170
  }
package/lib/tsserver.js CHANGED
@@ -10119,7 +10119,6 @@ var Diagnostics = {
10119
10119
  This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
10120
10120
  A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead: diag(2846, 1 /* Error */, "A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_f_2846", "A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '{0}' instead?"),
10121
10121
  A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2847, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2847", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
10122
- The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression: diag(2848, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression_2848", "The right-hand side of an 'instanceof' expression must not be an instantiation expression."),
10123
10122
  Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
10124
10123
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
10125
10124
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -10797,6 +10796,7 @@ var Diagnostics = {
10797
10796
  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."),
10798
10797
  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'."),
10799
10798
  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."),
10799
+ 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."),
10800
10800
  one_of_Colon: diag(6900, 3 /* Message */, "one_of_Colon_6900", "one of:"),
10801
10801
  one_or_more_Colon: diag(6901, 3 /* Message */, "one_or_more_Colon_6901", "one or more:"),
10802
10802
  type_Colon: diag(6902, 3 /* Message */, "type_Colon_6902", "type:"),
@@ -38196,6 +38196,16 @@ var commandOptionsWithoutBuild = [
38196
38196
  description: Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
38197
38197
  defaultValueDescription: false
38198
38198
  },
38199
+ {
38200
+ name: "strictInstanceOfTypeParameters",
38201
+ type: "boolean",
38202
+ affectsSemanticDiagnostics: true,
38203
+ affectsBuildInfo: true,
38204
+ strictFlag: true,
38205
+ category: Diagnostics.Type_Checking,
38206
+ description: Diagnostics.Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks,
38207
+ defaultValueDescription: false
38208
+ },
38199
38209
  {
38200
38210
  name: "alwaysStrict",
38201
38211
  type: "boolean",
@@ -47260,6 +47270,7 @@ function createTypeChecker(host) {
47260
47270
  var noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny");
47261
47271
  var noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
47262
47272
  var useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
47273
+ var strictInstanceOfTypeParameters = getStrictOptionValue(compilerOptions, "strictInstanceOfTypeParameters");
47263
47274
  var keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
47264
47275
  var defaultIndexFlags = keyofStringsOnly ? 1 /* StringsOnly */ : 0 /* None */;
47265
47276
  var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */;
@@ -55226,9 +55237,30 @@ function createTypeChecker(host) {
55226
55237
  }
55227
55238
  }).parent;
55228
55239
  }
55240
+ function getInstanceTypeOfClassSymbol(classSymbol) {
55241
+ const classType = getDeclaredTypeOfSymbol(classSymbol);
55242
+ const objectFlags = getObjectFlags(classType);
55243
+ if (!(objectFlags & 3 /* ClassOrInterface */) || !classType.typeParameters) {
55244
+ return classType;
55245
+ }
55246
+ const variances = getVariances(classType);
55247
+ const typeArguments = map(classType.typeParameters, (typeParameter, i) => {
55248
+ if (!strictInstanceOfTypeParameters) {
55249
+ return anyType;
55250
+ }
55251
+ const variance = variances[i];
55252
+ switch (variance & 7 /* VarianceMask */) {
55253
+ case 2 /* Contravariant */:
55254
+ case 3 /* Bivariant */:
55255
+ return neverType;
55256
+ }
55257
+ return getBaseConstraintOfType(typeParameter) || unknownType;
55258
+ });
55259
+ return createTypeReference(classType, typeArguments);
55260
+ }
55229
55261
  function getTypeOfPrototypeProperty(prototype) {
55230
- const classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype));
55231
- return classType.typeParameters ? createTypeReference(classType, map(classType.typeParameters, (_) => anyType)) : classType;
55262
+ const classSymbol = getParentOfSymbol(prototype);
55263
+ return getInstanceTypeOfClassSymbol(classSymbol);
55232
55264
  }
55233
55265
  function getTypeOfPropertyOfType(type, name) {
55234
55266
  const prop = getPropertyOfType(type, name);
@@ -69674,8 +69706,8 @@ function createTypeChecker(host) {
69674
69706
  if (symbol === void 0) {
69675
69707
  return type;
69676
69708
  }
69677
- const classSymbol = symbol.parent;
69678
- const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol);
69709
+ const classSymbol = getParentOfSymbol(symbol);
69710
+ const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getInstanceTypeOfClassSymbol(classSymbol);
69679
69711
  return getNarrowedType(
69680
69712
  type,
69681
69713
  targetType,
@@ -75730,12 +75762,6 @@ function createTypeChecker(host) {
75730
75762
  function checkExpressionWithTypeArguments(node) {
75731
75763
  checkGrammarExpressionWithTypeArguments(node);
75732
75764
  forEach(node.typeArguments, checkSourceElement);
75733
- if (node.kind === 231 /* ExpressionWithTypeArguments */) {
75734
- const parent2 = walkUpParenthesizedExpressions(node.parent);
75735
- if (parent2.kind === 224 /* BinaryExpression */ && parent2.operatorToken.kind === 103 /* InstanceOfKeyword */ && isNodeDescendantOf(node, parent2.right)) {
75736
- error(node, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression);
75737
- }
75738
- }
75739
75765
  const exprType = node.kind === 231 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName);
75740
75766
  return getInstantiationExpressionType(exprType, node);
75741
75767
  }
@@ -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;
@@ -7943,7 +7943,6 @@ ${lanes.join("\n")}
7943
7943
  This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
7944
7944
  A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead: diag(2846, 1 /* Error */, "A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_f_2846", "A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '{0}' instead?"),
7945
7945
  A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2847, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2847", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
7946
- The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression: diag(2848, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression_2848", "The right-hand side of an 'instanceof' expression must not be an instantiation expression."),
7947
7946
  Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
7948
7947
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
7949
7948
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -8621,6 +8620,7 @@ ${lanes.join("\n")}
8621
8620
  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."),
8622
8621
  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'."),
8623
8622
  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."),
8623
+ 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."),
8624
8624
  one_of_Colon: diag(6900, 3 /* Message */, "one_of_Colon_6900", "one of:"),
8625
8625
  one_or_more_Colon: diag(6901, 3 /* Message */, "one_or_more_Colon_6901", "one or more:"),
8626
8626
  type_Colon: diag(6902, 3 /* Message */, "type_Colon_6902", "type:"),
@@ -37850,6 +37850,16 @@ ${lanes.join("\n")}
37850
37850
  description: Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
37851
37851
  defaultValueDescription: false
37852
37852
  },
37853
+ {
37854
+ name: "strictInstanceOfTypeParameters",
37855
+ type: "boolean",
37856
+ affectsSemanticDiagnostics: true,
37857
+ affectsBuildInfo: true,
37858
+ strictFlag: true,
37859
+ category: Diagnostics.Type_Checking,
37860
+ description: Diagnostics.Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks,
37861
+ defaultValueDescription: false
37862
+ },
37853
37863
  {
37854
37864
  name: "alwaysStrict",
37855
37865
  type: "boolean",
@@ -45070,6 +45080,7 @@ ${lanes.join("\n")}
45070
45080
  var noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny");
45071
45081
  var noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
45072
45082
  var useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
45083
+ var strictInstanceOfTypeParameters = getStrictOptionValue(compilerOptions, "strictInstanceOfTypeParameters");
45073
45084
  var keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
45074
45085
  var defaultIndexFlags = keyofStringsOnly ? 1 /* StringsOnly */ : 0 /* None */;
45075
45086
  var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */;
@@ -53036,9 +53047,30 @@ ${lanes.join("\n")}
53036
53047
  }
53037
53048
  }).parent;
53038
53049
  }
53050
+ function getInstanceTypeOfClassSymbol(classSymbol) {
53051
+ const classType = getDeclaredTypeOfSymbol(classSymbol);
53052
+ const objectFlags = getObjectFlags(classType);
53053
+ if (!(objectFlags & 3 /* ClassOrInterface */) || !classType.typeParameters) {
53054
+ return classType;
53055
+ }
53056
+ const variances = getVariances(classType);
53057
+ const typeArguments = map(classType.typeParameters, (typeParameter, i) => {
53058
+ if (!strictInstanceOfTypeParameters) {
53059
+ return anyType;
53060
+ }
53061
+ const variance = variances[i];
53062
+ switch (variance & 7 /* VarianceMask */) {
53063
+ case 2 /* Contravariant */:
53064
+ case 3 /* Bivariant */:
53065
+ return neverType;
53066
+ }
53067
+ return getBaseConstraintOfType(typeParameter) || unknownType;
53068
+ });
53069
+ return createTypeReference(classType, typeArguments);
53070
+ }
53039
53071
  function getTypeOfPrototypeProperty(prototype) {
53040
- const classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype));
53041
- return classType.typeParameters ? createTypeReference(classType, map(classType.typeParameters, (_) => anyType)) : classType;
53072
+ const classSymbol = getParentOfSymbol(prototype);
53073
+ return getInstanceTypeOfClassSymbol(classSymbol);
53042
53074
  }
53043
53075
  function getTypeOfPropertyOfType(type, name) {
53044
53076
  const prop = getPropertyOfType(type, name);
@@ -67484,8 +67516,8 @@ ${lanes.join("\n")}
67484
67516
  if (symbol === void 0) {
67485
67517
  return type;
67486
67518
  }
67487
- const classSymbol = symbol.parent;
67488
- const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol);
67519
+ const classSymbol = getParentOfSymbol(symbol);
67520
+ const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getInstanceTypeOfClassSymbol(classSymbol);
67489
67521
  return getNarrowedType(
67490
67522
  type,
67491
67523
  targetType,
@@ -73540,12 +73572,6 @@ ${lanes.join("\n")}
73540
73572
  function checkExpressionWithTypeArguments(node) {
73541
73573
  checkGrammarExpressionWithTypeArguments(node);
73542
73574
  forEach(node.typeArguments, checkSourceElement);
73543
- if (node.kind === 231 /* ExpressionWithTypeArguments */) {
73544
- const parent2 = walkUpParenthesizedExpressions(node.parent);
73545
- if (parent2.kind === 224 /* BinaryExpression */ && parent2.operatorToken.kind === 103 /* InstanceOfKeyword */ && isNodeDescendantOf(node, parent2.right)) {
73546
- error(node, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression);
73547
- }
73548
- }
73549
73575
  const exprType = node.kind === 231 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName);
73550
73576
  return getInstantiationExpressionType(exprType, node);
73551
73577
  }
@@ -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
@@ -7943,7 +7943,6 @@ ${lanes.join("\n")}
7943
7943
  This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
7944
7944
  A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead: diag(2846, 1 /* Error */, "A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_f_2846", "A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '{0}' instead?"),
7945
7945
  A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2847, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2847", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
7946
- The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression: diag(2848, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression_2848", "The right-hand side of an 'instanceof' expression must not be an instantiation expression."),
7947
7946
  Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
7948
7947
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
7949
7948
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -8621,6 +8620,7 @@ ${lanes.join("\n")}
8621
8620
  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."),
8622
8621
  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'."),
8623
8622
  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."),
8623
+ 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."),
8624
8624
  one_of_Colon: diag(6900, 3 /* Message */, "one_of_Colon_6900", "one of:"),
8625
8625
  one_or_more_Colon: diag(6901, 3 /* Message */, "one_or_more_Colon_6901", "one or more:"),
8626
8626
  type_Colon: diag(6902, 3 /* Message */, "type_Colon_6902", "type:"),
@@ -37850,6 +37850,16 @@ ${lanes.join("\n")}
37850
37850
  description: Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
37851
37851
  defaultValueDescription: false
37852
37852
  },
37853
+ {
37854
+ name: "strictInstanceOfTypeParameters",
37855
+ type: "boolean",
37856
+ affectsSemanticDiagnostics: true,
37857
+ affectsBuildInfo: true,
37858
+ strictFlag: true,
37859
+ category: Diagnostics.Type_Checking,
37860
+ description: Diagnostics.Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks,
37861
+ defaultValueDescription: false
37862
+ },
37853
37863
  {
37854
37864
  name: "alwaysStrict",
37855
37865
  type: "boolean",
@@ -45070,6 +45080,7 @@ ${lanes.join("\n")}
45070
45080
  var noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny");
45071
45081
  var noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
45072
45082
  var useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
45083
+ var strictInstanceOfTypeParameters = getStrictOptionValue(compilerOptions, "strictInstanceOfTypeParameters");
45073
45084
  var keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
45074
45085
  var defaultIndexFlags = keyofStringsOnly ? 1 /* StringsOnly */ : 0 /* None */;
45075
45086
  var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */;
@@ -53036,9 +53047,30 @@ ${lanes.join("\n")}
53036
53047
  }
53037
53048
  }).parent;
53038
53049
  }
53050
+ function getInstanceTypeOfClassSymbol(classSymbol) {
53051
+ const classType = getDeclaredTypeOfSymbol(classSymbol);
53052
+ const objectFlags = getObjectFlags(classType);
53053
+ if (!(objectFlags & 3 /* ClassOrInterface */) || !classType.typeParameters) {
53054
+ return classType;
53055
+ }
53056
+ const variances = getVariances(classType);
53057
+ const typeArguments = map(classType.typeParameters, (typeParameter, i) => {
53058
+ if (!strictInstanceOfTypeParameters) {
53059
+ return anyType;
53060
+ }
53061
+ const variance = variances[i];
53062
+ switch (variance & 7 /* VarianceMask */) {
53063
+ case 2 /* Contravariant */:
53064
+ case 3 /* Bivariant */:
53065
+ return neverType;
53066
+ }
53067
+ return getBaseConstraintOfType(typeParameter) || unknownType;
53068
+ });
53069
+ return createTypeReference(classType, typeArguments);
53070
+ }
53039
53071
  function getTypeOfPrototypeProperty(prototype) {
53040
- const classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype));
53041
- return classType.typeParameters ? createTypeReference(classType, map(classType.typeParameters, (_) => anyType)) : classType;
53072
+ const classSymbol = getParentOfSymbol(prototype);
53073
+ return getInstanceTypeOfClassSymbol(classSymbol);
53042
53074
  }
53043
53075
  function getTypeOfPropertyOfType(type, name) {
53044
53076
  const prop = getPropertyOfType(type, name);
@@ -67484,8 +67516,8 @@ ${lanes.join("\n")}
67484
67516
  if (symbol === void 0) {
67485
67517
  return type;
67486
67518
  }
67487
- const classSymbol = symbol.parent;
67488
- const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol);
67519
+ const classSymbol = getParentOfSymbol(symbol);
67520
+ const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getInstanceTypeOfClassSymbol(classSymbol);
67489
67521
  return getNarrowedType(
67490
67522
  type,
67491
67523
  targetType,
@@ -73540,12 +73572,6 @@ ${lanes.join("\n")}
73540
73572
  function checkExpressionWithTypeArguments(node) {
73541
73573
  checkGrammarExpressionWithTypeArguments(node);
73542
73574
  forEach(node.typeArguments, checkSourceElement);
73543
- if (node.kind === 231 /* ExpressionWithTypeArguments */) {
73544
- const parent2 = walkUpParenthesizedExpressions(node.parent);
73545
- if (parent2.kind === 224 /* BinaryExpression */ && parent2.operatorToken.kind === 103 /* InstanceOfKeyword */ && isNodeDescendantOf(node, parent2.right)) {
73546
- error(node, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression);
73547
- }
73548
- }
73549
73575
  const exprType = node.kind === 231 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName);
73550
73576
  return getInstantiationExpressionType(exprType, node);
73551
73577
  }
@@ -6013,7 +6013,6 @@ var Diagnostics = {
6013
6013
  This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
6014
6014
  A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead: diag(2846, 1 /* Error */, "A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_f_2846", "A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '{0}' instead?"),
6015
6015
  A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2847, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2847", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
6016
- The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression: diag(2848, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression_2848", "The right-hand side of an 'instanceof' expression must not be an instantiation expression."),
6017
6016
  Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
6018
6017
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
6019
6018
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -6691,6 +6690,7 @@ var Diagnostics = {
6691
6690
  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."),
6692
6691
  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'."),
6693
6692
  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."),
6693
+ 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."),
6694
6694
  one_of_Colon: diag(6900, 3 /* Message */, "one_of_Colon_6900", "one of:"),
6695
6695
  one_or_more_Colon: diag(6901, 3 /* Message */, "one_or_more_Colon_6901", "one or more:"),
6696
6696
  type_Colon: diag(6902, 3 /* Message */, "type_Colon_6902", "type:"),
@@ -25899,6 +25899,16 @@ var commandOptionsWithoutBuild = [
25899
25899
  description: Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
25900
25900
  defaultValueDescription: false
25901
25901
  },
25902
+ {
25903
+ name: "strictInstanceOfTypeParameters",
25904
+ type: "boolean",
25905
+ affectsSemanticDiagnostics: true,
25906
+ affectsBuildInfo: true,
25907
+ strictFlag: true,
25908
+ category: Diagnostics.Type_Checking,
25909
+ description: Diagnostics.Default_type_arguments_to_parameter_constraint_or_unknown_instead_of_any_for_instance_checks,
25910
+ defaultValueDescription: false
25911
+ },
25902
25912
  {
25903
25913
  name: "alwaysStrict",
25904
25914
  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-53323-7",
5
+ "version": "5.1.0-pr-49863-30",
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": "3d60ad2cd19401f448daf69a3403fbdb7fdfb4c8"
117
+ "gitHead": "d7bc48b2c37340e8455e02112a20d6fca773bbe7"
118
118
  }