typescript 5.1.0-dev.20230317 → 5.1.0-dev.20230318

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-dev.20230317`;
26
+ var version = `${versionMajorMinor}.0-dev.20230318`;
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) => {
@@ -6656,6 +6656,8 @@ var Diagnostics = {
6656
6656
  Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, 1 /* Error */, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
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
+ 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."),
6659
6661
  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}'."),
6660
6662
  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}'."),
6661
6663
  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}'."),
@@ -56000,7 +56002,7 @@ function createTypeChecker(host) {
56000
56002
  origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
56001
56003
  }
56002
56004
  }
56003
- const objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
56005
+ const objectFlags = (includes & 36323331 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
56004
56006
  return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
56005
56007
  }
56006
56008
  function getUnionOrIntersectionTypePredicate(signatures, kind) {
@@ -56125,7 +56127,7 @@ function createTypeChecker(host) {
56125
56127
  function eachUnionContains(unionTypes2, type) {
56126
56128
  for (const u of unionTypes2) {
56127
56129
  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;
56130
+ 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
56131
  if (!primitive || !containsType(u.types, primitive)) {
56130
56132
  return false;
56131
56133
  }
@@ -56152,9 +56154,6 @@ function createTypeChecker(host) {
56152
56154
  }
56153
56155
  return false;
56154
56156
  }
56155
- function eachIsUnionContaining(types, flag) {
56156
- return every(types, (t) => !!(t.flags & 1048576 /* Union */) && some(t.types, (tt) => !!(tt.flags & flag)));
56157
- }
56158
56157
  function removeFromEach(types, flag) {
56159
56158
  for (let i = 0; i < types.length; i++) {
56160
56159
  types[i] = filterType(types[i], (t) => !(t.flags & flag));
@@ -56243,11 +56242,11 @@ function createTypeChecker(host) {
56243
56242
  if (includes & 1048576 /* Union */) {
56244
56243
  if (intersectUnionsOfPrimitiveTypes(typeSet)) {
56245
56244
  result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
56246
- } else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
56245
+ } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags & 32768 /* Undefined */))) {
56247
56246
  const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
56248
56247
  removeFromEach(typeSet, 32768 /* Undefined */);
56249
56248
  result = getUnionType([getIntersectionType(typeSet), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
56250
- } else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
56249
+ } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
56251
56250
  removeFromEach(typeSet, 65536 /* Null */);
56252
56251
  result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
56253
56252
  } else {
@@ -59772,6 +59771,11 @@ function createTypeChecker(host) {
59772
59771
  if (containsType(targetTypes, source2)) {
59773
59772
  return -1 /* True */;
59774
59773
  }
59774
+ 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 */)) {
59775
+ const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
59776
+ const primitive = source2.flags & 128 /* StringLiteral */ ? stringType : source2.flags & 256 /* NumberLiteral */ ? numberType : source2.flags & 2048 /* BigIntLiteral */ ? bigintType : void 0;
59777
+ return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
59778
+ }
59775
59779
  const match = getMatchingUnionConstituentForType(target2, source2);
59776
59780
  if (match) {
59777
59781
  const related = isRelatedTo(
@@ -71129,6 +71133,12 @@ function createTypeChecker(host) {
71129
71133
  function checkExpressionWithTypeArguments(node) {
71130
71134
  checkGrammarExpressionWithTypeArguments(node);
71131
71135
  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
+ }
71132
71142
  const exprType = node.kind === 231 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName);
71133
71143
  return getInstantiationExpressionType(exprType, node);
71134
71144
  }
@@ -72086,7 +72096,7 @@ function createTypeChecker(host) {
72086
72096
  function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
72087
72097
  const functionFlags = getFunctionFlags(func);
72088
72098
  const type = returnType && unwrapReturnType(returnType, functionFlags);
72089
- if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) {
72099
+ if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */)) {
72090
72100
  return;
72091
72101
  }
72092
72102
  if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
@@ -72097,8 +72107,12 @@ function createTypeChecker(host) {
72097
72107
  if (type && type.flags & 131072 /* Never */) {
72098
72108
  error(errorNode, Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
72099
72109
  } else if (type && !hasExplicitReturn) {
72100
- error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
72101
- } else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
72110
+ if (strictNullChecks) {
72111
+ error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
72112
+ } else {
72113
+ error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
72114
+ }
72115
+ } else if (type && strictNullChecks) {
72102
72116
  error(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
72103
72117
  } else if (compilerOptions.noImplicitReturns) {
72104
72118
  if (!type) {
@@ -79790,12 +79804,35 @@ function createTypeChecker(host) {
79790
79804
  }
79791
79805
  return void 0;
79792
79806
  }
79807
+ function isThisPropertyAndThisTyped(node) {
79808
+ if (node.expression.kind === 109 /* ThisKeyword */) {
79809
+ const container = getThisContainer(
79810
+ node,
79811
+ /*includeArrowFunctions*/
79812
+ false,
79813
+ /*includeClassComputedPropertyName*/
79814
+ false
79815
+ );
79816
+ if (isFunctionLike(container)) {
79817
+ const containingLiteral = getContainingObjectLiteral(container);
79818
+ if (containingLiteral) {
79819
+ const contextualType = getApparentTypeOfContextualType(
79820
+ containingLiteral,
79821
+ /*contextFlags*/
79822
+ void 0
79823
+ );
79824
+ const type = contextualType && getThisTypeFromContextualType(contextualType);
79825
+ return type && !isTypeAny(type);
79826
+ }
79827
+ }
79828
+ }
79829
+ }
79793
79830
  function getSymbolOfNameOrPropertyAccessExpression(name) {
79794
79831
  if (isDeclarationName(name)) {
79795
79832
  return getSymbolOfNode(name.parent);
79796
79833
  }
79797
79834
  if (isInJSFile(name) && name.parent.kind === 209 /* PropertyAccessExpression */ && name.parent === name.parent.parent.left) {
79798
- if (!isPrivateIdentifier(name) && !isJSDocMemberName(name)) {
79835
+ if (!isPrivateIdentifier(name) && !isJSDocMemberName(name) && !isThisPropertyAndThisTyped(name.parent)) {
79799
79836
  const specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name);
79800
79837
  if (specialPropertyAssignmentSymbol) {
79801
79838
  return specialPropertyAssignmentSymbol;
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-dev.20230317`;
2288
+ var version = `${versionMajorMinor}.0-dev.20230318`;
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) => {
@@ -10118,6 +10118,8 @@ var Diagnostics = {
10118
10118
  Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, 1 /* Error */, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
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
+ 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."),
10121
10123
  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}'."),
10122
10124
  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}'."),
10123
10125
  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}'."),
@@ -60597,7 +60599,7 @@ function createTypeChecker(host) {
60597
60599
  origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
60598
60600
  }
60599
60601
  }
60600
- const objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
60602
+ const objectFlags = (includes & 36323331 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
60601
60603
  return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
60602
60604
  }
60603
60605
  function getUnionOrIntersectionTypePredicate(signatures, kind) {
@@ -60722,7 +60724,7 @@ function createTypeChecker(host) {
60722
60724
  function eachUnionContains(unionTypes2, type) {
60723
60725
  for (const u of unionTypes2) {
60724
60726
  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;
60727
+ 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
60728
  if (!primitive || !containsType(u.types, primitive)) {
60727
60729
  return false;
60728
60730
  }
@@ -60749,9 +60751,6 @@ function createTypeChecker(host) {
60749
60751
  }
60750
60752
  return false;
60751
60753
  }
60752
- function eachIsUnionContaining(types, flag) {
60753
- return every(types, (t) => !!(t.flags & 1048576 /* Union */) && some(t.types, (tt) => !!(tt.flags & flag)));
60754
- }
60755
60754
  function removeFromEach(types, flag) {
60756
60755
  for (let i = 0; i < types.length; i++) {
60757
60756
  types[i] = filterType(types[i], (t) => !(t.flags & flag));
@@ -60840,11 +60839,11 @@ function createTypeChecker(host) {
60840
60839
  if (includes & 1048576 /* Union */) {
60841
60840
  if (intersectUnionsOfPrimitiveTypes(typeSet)) {
60842
60841
  result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
60843
- } else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
60842
+ } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags & 32768 /* Undefined */))) {
60844
60843
  const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
60845
60844
  removeFromEach(typeSet, 32768 /* Undefined */);
60846
60845
  result = getUnionType([getIntersectionType(typeSet), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
60847
- } else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
60846
+ } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
60848
60847
  removeFromEach(typeSet, 65536 /* Null */);
60849
60848
  result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
60850
60849
  } else {
@@ -64369,6 +64368,11 @@ function createTypeChecker(host) {
64369
64368
  if (containsType(targetTypes, source2)) {
64370
64369
  return -1 /* True */;
64371
64370
  }
64371
+ 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 */)) {
64372
+ const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
64373
+ const primitive = source2.flags & 128 /* StringLiteral */ ? stringType : source2.flags & 256 /* NumberLiteral */ ? numberType : source2.flags & 2048 /* BigIntLiteral */ ? bigintType : void 0;
64374
+ return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
64375
+ }
64372
64376
  const match = getMatchingUnionConstituentForType(target2, source2);
64373
64377
  if (match) {
64374
64378
  const related = isRelatedTo(
@@ -75726,6 +75730,12 @@ function createTypeChecker(host) {
75726
75730
  function checkExpressionWithTypeArguments(node) {
75727
75731
  checkGrammarExpressionWithTypeArguments(node);
75728
75732
  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
+ }
75729
75739
  const exprType = node.kind === 231 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName);
75730
75740
  return getInstantiationExpressionType(exprType, node);
75731
75741
  }
@@ -76683,7 +76693,7 @@ function createTypeChecker(host) {
76683
76693
  function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
76684
76694
  const functionFlags = getFunctionFlags(func);
76685
76695
  const type = returnType && unwrapReturnType(returnType, functionFlags);
76686
- if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) {
76696
+ if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */)) {
76687
76697
  return;
76688
76698
  }
76689
76699
  if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
@@ -76694,8 +76704,12 @@ function createTypeChecker(host) {
76694
76704
  if (type && type.flags & 131072 /* Never */) {
76695
76705
  error(errorNode, Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
76696
76706
  } else if (type && !hasExplicitReturn) {
76697
- error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
76698
- } else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
76707
+ if (strictNullChecks) {
76708
+ error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
76709
+ } else {
76710
+ error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
76711
+ }
76712
+ } else if (type && strictNullChecks) {
76699
76713
  error(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
76700
76714
  } else if (compilerOptions.noImplicitReturns) {
76701
76715
  if (!type) {
@@ -84387,12 +84401,35 @@ function createTypeChecker(host) {
84387
84401
  }
84388
84402
  return void 0;
84389
84403
  }
84404
+ function isThisPropertyAndThisTyped(node) {
84405
+ if (node.expression.kind === 109 /* ThisKeyword */) {
84406
+ const container = getThisContainer(
84407
+ node,
84408
+ /*includeArrowFunctions*/
84409
+ false,
84410
+ /*includeClassComputedPropertyName*/
84411
+ false
84412
+ );
84413
+ if (isFunctionLike(container)) {
84414
+ const containingLiteral = getContainingObjectLiteral(container);
84415
+ if (containingLiteral) {
84416
+ const contextualType = getApparentTypeOfContextualType(
84417
+ containingLiteral,
84418
+ /*contextFlags*/
84419
+ void 0
84420
+ );
84421
+ const type = contextualType && getThisTypeFromContextualType(contextualType);
84422
+ return type && !isTypeAny(type);
84423
+ }
84424
+ }
84425
+ }
84426
+ }
84390
84427
  function getSymbolOfNameOrPropertyAccessExpression(name) {
84391
84428
  if (isDeclarationName(name)) {
84392
84429
  return getSymbolOfNode(name.parent);
84393
84430
  }
84394
84431
  if (isInJSFile(name) && name.parent.kind === 209 /* PropertyAccessExpression */ && name.parent === name.parent.parent.left) {
84395
- if (!isPrivateIdentifier(name) && !isJSDocMemberName(name)) {
84432
+ if (!isPrivateIdentifier(name) && !isJSDocMemberName(name) && !isThisPropertyAndThisTyped(name.parent)) {
84396
84433
  const specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name);
84397
84434
  if (specialPropertyAssignmentSymbol) {
84398
84435
  return specialPropertyAssignmentSymbol;
@@ -143623,6 +143660,7 @@ var fixRemoveBracesFromArrowFunctionBody = "fixRemoveBracesFromArrowFunctionBody
143623
143660
  var fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
143624
143661
  var errorCodes26 = [
143625
143662
  Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
143663
+ Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code,
143626
143664
  Diagnostics.Type_0_is_not_assignable_to_type_1.code,
143627
143665
  Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
143628
143666
  ];
@@ -143774,6 +143812,7 @@ function getInfo6(checker, sourceFile, position, errorCode) {
143774
143812
  const declaration = findAncestor(node.parent, isFunctionLikeDeclaration);
143775
143813
  switch (errorCode) {
143776
143814
  case Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code:
143815
+ case Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code:
143777
143816
  if (!declaration || !declaration.body || !declaration.type || !rangeContainsRange(declaration.type, node))
143778
143817
  return void 0;
143779
143818
  return getFixInfo(
@@ -170479,6 +170518,7 @@ __export(ts_server_exports2, {
170479
170518
  emptyArray: () => emptyArray2,
170480
170519
  findArgument: () => findArgument,
170481
170520
  forEachResolvedProjectReferenceProject: () => forEachResolvedProjectReferenceProject,
170521
+ formatDiagnosticToProtocol: () => formatDiagnosticToProtocol,
170482
170522
  formatMessage: () => formatMessage2,
170483
170523
  getBaseConfigFileName: () => getBaseConfigFileName,
170484
170524
  getLocationInNewDocument: () => getLocationInNewDocument,
@@ -181215,6 +181255,7 @@ __export(ts_server_exports3, {
181215
181255
  emptyArray: () => emptyArray2,
181216
181256
  findArgument: () => findArgument,
181217
181257
  forEachResolvedProjectReferenceProject: () => forEachResolvedProjectReferenceProject,
181258
+ formatDiagnosticToProtocol: () => formatDiagnosticToProtocol,
181218
181259
  formatMessage: () => formatMessage2,
181219
181260
  getBaseConfigFileName: () => getBaseConfigFileName,
181220
181261
  getLocationInNewDocument: () => getLocationInNewDocument,
@@ -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-dev.20230317`;
38
+ version = `${versionMajorMinor}.0-dev.20230318`;
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) => {
@@ -7942,6 +7942,8 @@ ${lanes.join("\n")}
7942
7942
  Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, 1 /* Error */, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
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
+ 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."),
7945
7947
  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}'."),
7946
7948
  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}'."),
7947
7949
  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}'."),
@@ -58407,7 +58409,7 @@ ${lanes.join("\n")}
58407
58409
  origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
58408
58410
  }
58409
58411
  }
58410
- const objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
58412
+ const objectFlags = (includes & 36323331 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
58411
58413
  return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
58412
58414
  }
58413
58415
  function getUnionOrIntersectionTypePredicate(signatures, kind) {
@@ -58532,7 +58534,7 @@ ${lanes.join("\n")}
58532
58534
  function eachUnionContains(unionTypes2, type) {
58533
58535
  for (const u of unionTypes2) {
58534
58536
  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;
58537
+ 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
58538
  if (!primitive || !containsType(u.types, primitive)) {
58537
58539
  return false;
58538
58540
  }
@@ -58559,9 +58561,6 @@ ${lanes.join("\n")}
58559
58561
  }
58560
58562
  return false;
58561
58563
  }
58562
- function eachIsUnionContaining(types, flag) {
58563
- return every(types, (t) => !!(t.flags & 1048576 /* Union */) && some(t.types, (tt) => !!(tt.flags & flag)));
58564
- }
58565
58564
  function removeFromEach(types, flag) {
58566
58565
  for (let i = 0; i < types.length; i++) {
58567
58566
  types[i] = filterType(types[i], (t) => !(t.flags & flag));
@@ -58650,11 +58649,11 @@ ${lanes.join("\n")}
58650
58649
  if (includes & 1048576 /* Union */) {
58651
58650
  if (intersectUnionsOfPrimitiveTypes(typeSet)) {
58652
58651
  result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
58653
- } else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
58652
+ } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags & 32768 /* Undefined */))) {
58654
58653
  const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
58655
58654
  removeFromEach(typeSet, 32768 /* Undefined */);
58656
58655
  result = getUnionType([getIntersectionType(typeSet), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
58657
- } else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
58656
+ } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
58658
58657
  removeFromEach(typeSet, 65536 /* Null */);
58659
58658
  result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
58660
58659
  } else {
@@ -62179,6 +62178,11 @@ ${lanes.join("\n")}
62179
62178
  if (containsType(targetTypes, source2)) {
62180
62179
  return -1 /* True */;
62181
62180
  }
62181
+ 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 */)) {
62182
+ const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
62183
+ const primitive = source2.flags & 128 /* StringLiteral */ ? stringType : source2.flags & 256 /* NumberLiteral */ ? numberType : source2.flags & 2048 /* BigIntLiteral */ ? bigintType : void 0;
62184
+ return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
62185
+ }
62182
62186
  const match = getMatchingUnionConstituentForType(target2, source2);
62183
62187
  if (match) {
62184
62188
  const related = isRelatedTo(
@@ -73536,6 +73540,12 @@ ${lanes.join("\n")}
73536
73540
  function checkExpressionWithTypeArguments(node) {
73537
73541
  checkGrammarExpressionWithTypeArguments(node);
73538
73542
  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
+ }
73539
73549
  const exprType = node.kind === 231 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName);
73540
73550
  return getInstantiationExpressionType(exprType, node);
73541
73551
  }
@@ -74493,7 +74503,7 @@ ${lanes.join("\n")}
74493
74503
  function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
74494
74504
  const functionFlags = getFunctionFlags(func);
74495
74505
  const type = returnType && unwrapReturnType(returnType, functionFlags);
74496
- if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) {
74506
+ if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */)) {
74497
74507
  return;
74498
74508
  }
74499
74509
  if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
@@ -74504,8 +74514,12 @@ ${lanes.join("\n")}
74504
74514
  if (type && type.flags & 131072 /* Never */) {
74505
74515
  error(errorNode, Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
74506
74516
  } else if (type && !hasExplicitReturn) {
74507
- error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
74508
- } else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
74517
+ if (strictNullChecks) {
74518
+ error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
74519
+ } else {
74520
+ error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
74521
+ }
74522
+ } else if (type && strictNullChecks) {
74509
74523
  error(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
74510
74524
  } else if (compilerOptions.noImplicitReturns) {
74511
74525
  if (!type) {
@@ -82197,12 +82211,35 @@ ${lanes.join("\n")}
82197
82211
  }
82198
82212
  return void 0;
82199
82213
  }
82214
+ function isThisPropertyAndThisTyped(node) {
82215
+ if (node.expression.kind === 109 /* ThisKeyword */) {
82216
+ const container = getThisContainer(
82217
+ node,
82218
+ /*includeArrowFunctions*/
82219
+ false,
82220
+ /*includeClassComputedPropertyName*/
82221
+ false
82222
+ );
82223
+ if (isFunctionLike(container)) {
82224
+ const containingLiteral = getContainingObjectLiteral(container);
82225
+ if (containingLiteral) {
82226
+ const contextualType = getApparentTypeOfContextualType(
82227
+ containingLiteral,
82228
+ /*contextFlags*/
82229
+ void 0
82230
+ );
82231
+ const type = contextualType && getThisTypeFromContextualType(contextualType);
82232
+ return type && !isTypeAny(type);
82233
+ }
82234
+ }
82235
+ }
82236
+ }
82200
82237
  function getSymbolOfNameOrPropertyAccessExpression(name) {
82201
82238
  if (isDeclarationName(name)) {
82202
82239
  return getSymbolOfNode(name.parent);
82203
82240
  }
82204
82241
  if (isInJSFile(name) && name.parent.kind === 209 /* PropertyAccessExpression */ && name.parent === name.parent.parent.left) {
82205
- if (!isPrivateIdentifier(name) && !isJSDocMemberName(name)) {
82242
+ if (!isPrivateIdentifier(name) && !isJSDocMemberName(name) && !isThisPropertyAndThisTyped(name.parent)) {
82206
82243
  const specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name);
82207
82244
  if (specialPropertyAssignmentSymbol) {
82208
82245
  return specialPropertyAssignmentSymbol;
@@ -142393,6 +142430,7 @@ ${lanes.join("\n")}
142393
142430
  const declaration = findAncestor(node.parent, isFunctionLikeDeclaration);
142394
142431
  switch (errorCode) {
142395
142432
  case Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code:
142433
+ case Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code:
142396
142434
  if (!declaration || !declaration.body || !declaration.type || !rangeContainsRange(declaration.type, node))
142397
142435
  return void 0;
142398
142436
  return getFixInfo(
@@ -142500,6 +142538,7 @@ ${lanes.join("\n")}
142500
142538
  fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
142501
142539
  errorCodes26 = [
142502
142540
  Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
142541
+ Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code,
142503
142542
  Diagnostics.Type_0_is_not_assignable_to_type_1.code,
142504
142543
  Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
142505
142544
  ];
@@ -178591,6 +178630,7 @@ ${e.message}`;
178591
178630
  emptyArray: () => emptyArray2,
178592
178631
  findArgument: () => findArgument,
178593
178632
  forEachResolvedProjectReferenceProject: () => forEachResolvedProjectReferenceProject,
178633
+ formatDiagnosticToProtocol: () => formatDiagnosticToProtocol,
178594
178634
  formatMessage: () => formatMessage2,
178595
178635
  getBaseConfigFileName: () => getBaseConfigFileName,
178596
178636
  getLocationInNewDocument: () => getLocationInNewDocument,
@@ -180959,6 +180999,7 @@ ${e.message}`;
180959
180999
  emptyArray: () => emptyArray2,
180960
181000
  findArgument: () => findArgument,
180961
181001
  forEachResolvedProjectReferenceProject: () => forEachResolvedProjectReferenceProject,
181002
+ formatDiagnosticToProtocol: () => formatDiagnosticToProtocol,
180962
181003
  formatMessage: () => formatMessage2,
180963
181004
  getBaseConfigFileName: () => getBaseConfigFileName,
180964
181005
  getLocationInNewDocument: () => getLocationInNewDocument,
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-dev.20230317`;
38
+ version = `${versionMajorMinor}.0-dev.20230318`;
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) => {
@@ -7942,6 +7942,8 @@ ${lanes.join("\n")}
7942
7942
  Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, 1 /* Error */, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
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
+ 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."),
7945
7947
  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}'."),
7946
7948
  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}'."),
7947
7949
  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}'."),
@@ -58407,7 +58409,7 @@ ${lanes.join("\n")}
58407
58409
  origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
58408
58410
  }
58409
58411
  }
58410
- const objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
58412
+ const objectFlags = (includes & 36323331 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
58411
58413
  return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
58412
58414
  }
58413
58415
  function getUnionOrIntersectionTypePredicate(signatures, kind) {
@@ -58532,7 +58534,7 @@ ${lanes.join("\n")}
58532
58534
  function eachUnionContains(unionTypes2, type) {
58533
58535
  for (const u of unionTypes2) {
58534
58536
  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;
58537
+ 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
58538
  if (!primitive || !containsType(u.types, primitive)) {
58537
58539
  return false;
58538
58540
  }
@@ -58559,9 +58561,6 @@ ${lanes.join("\n")}
58559
58561
  }
58560
58562
  return false;
58561
58563
  }
58562
- function eachIsUnionContaining(types, flag) {
58563
- return every(types, (t) => !!(t.flags & 1048576 /* Union */) && some(t.types, (tt) => !!(tt.flags & flag)));
58564
- }
58565
58564
  function removeFromEach(types, flag) {
58566
58565
  for (let i = 0; i < types.length; i++) {
58567
58566
  types[i] = filterType(types[i], (t) => !(t.flags & flag));
@@ -58650,11 +58649,11 @@ ${lanes.join("\n")}
58650
58649
  if (includes & 1048576 /* Union */) {
58651
58650
  if (intersectUnionsOfPrimitiveTypes(typeSet)) {
58652
58651
  result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
58653
- } else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
58652
+ } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags & 32768 /* Undefined */))) {
58654
58653
  const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
58655
58654
  removeFromEach(typeSet, 32768 /* Undefined */);
58656
58655
  result = getUnionType([getIntersectionType(typeSet), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
58657
- } else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
58656
+ } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
58658
58657
  removeFromEach(typeSet, 65536 /* Null */);
58659
58658
  result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
58660
58659
  } else {
@@ -62179,6 +62178,11 @@ ${lanes.join("\n")}
62179
62178
  if (containsType(targetTypes, source2)) {
62180
62179
  return -1 /* True */;
62181
62180
  }
62181
+ 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 */)) {
62182
+ const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
62183
+ const primitive = source2.flags & 128 /* StringLiteral */ ? stringType : source2.flags & 256 /* NumberLiteral */ ? numberType : source2.flags & 2048 /* BigIntLiteral */ ? bigintType : void 0;
62184
+ return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
62185
+ }
62182
62186
  const match = getMatchingUnionConstituentForType(target2, source2);
62183
62187
  if (match) {
62184
62188
  const related = isRelatedTo(
@@ -73536,6 +73540,12 @@ ${lanes.join("\n")}
73536
73540
  function checkExpressionWithTypeArguments(node) {
73537
73541
  checkGrammarExpressionWithTypeArguments(node);
73538
73542
  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
+ }
73539
73549
  const exprType = node.kind === 231 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName);
73540
73550
  return getInstantiationExpressionType(exprType, node);
73541
73551
  }
@@ -74493,7 +74503,7 @@ ${lanes.join("\n")}
74493
74503
  function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
74494
74504
  const functionFlags = getFunctionFlags(func);
74495
74505
  const type = returnType && unwrapReturnType(returnType, functionFlags);
74496
- if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) {
74506
+ if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */)) {
74497
74507
  return;
74498
74508
  }
74499
74509
  if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
@@ -74504,8 +74514,12 @@ ${lanes.join("\n")}
74504
74514
  if (type && type.flags & 131072 /* Never */) {
74505
74515
  error(errorNode, Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
74506
74516
  } else if (type && !hasExplicitReturn) {
74507
- error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
74508
- } else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
74517
+ if (strictNullChecks) {
74518
+ error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
74519
+ } else {
74520
+ error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
74521
+ }
74522
+ } else if (type && strictNullChecks) {
74509
74523
  error(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
74510
74524
  } else if (compilerOptions.noImplicitReturns) {
74511
74525
  if (!type) {
@@ -82197,12 +82211,35 @@ ${lanes.join("\n")}
82197
82211
  }
82198
82212
  return void 0;
82199
82213
  }
82214
+ function isThisPropertyAndThisTyped(node) {
82215
+ if (node.expression.kind === 109 /* ThisKeyword */) {
82216
+ const container = getThisContainer(
82217
+ node,
82218
+ /*includeArrowFunctions*/
82219
+ false,
82220
+ /*includeClassComputedPropertyName*/
82221
+ false
82222
+ );
82223
+ if (isFunctionLike(container)) {
82224
+ const containingLiteral = getContainingObjectLiteral(container);
82225
+ if (containingLiteral) {
82226
+ const contextualType = getApparentTypeOfContextualType(
82227
+ containingLiteral,
82228
+ /*contextFlags*/
82229
+ void 0
82230
+ );
82231
+ const type = contextualType && getThisTypeFromContextualType(contextualType);
82232
+ return type && !isTypeAny(type);
82233
+ }
82234
+ }
82235
+ }
82236
+ }
82200
82237
  function getSymbolOfNameOrPropertyAccessExpression(name) {
82201
82238
  if (isDeclarationName(name)) {
82202
82239
  return getSymbolOfNode(name.parent);
82203
82240
  }
82204
82241
  if (isInJSFile(name) && name.parent.kind === 209 /* PropertyAccessExpression */ && name.parent === name.parent.parent.left) {
82205
- if (!isPrivateIdentifier(name) && !isJSDocMemberName(name)) {
82242
+ if (!isPrivateIdentifier(name) && !isJSDocMemberName(name) && !isThisPropertyAndThisTyped(name.parent)) {
82206
82243
  const specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name);
82207
82244
  if (specialPropertyAssignmentSymbol) {
82208
82245
  return specialPropertyAssignmentSymbol;
@@ -142407,6 +142444,7 @@ ${lanes.join("\n")}
142407
142444
  const declaration = findAncestor(node.parent, isFunctionLikeDeclaration);
142408
142445
  switch (errorCode) {
142409
142446
  case Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code:
142447
+ case Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code:
142410
142448
  if (!declaration || !declaration.body || !declaration.type || !rangeContainsRange(declaration.type, node))
142411
142449
  return void 0;
142412
142450
  return getFixInfo(
@@ -142514,6 +142552,7 @@ ${lanes.join("\n")}
142514
142552
  fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
142515
142553
  errorCodes26 = [
142516
142554
  Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
142555
+ Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code,
142517
142556
  Diagnostics.Type_0_is_not_assignable_to_type_1.code,
142518
142557
  Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
142519
142558
  ];
@@ -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-dev.20230317`;
57
+ var version = `${versionMajorMinor}.0-dev.20230318`;
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) => {
@@ -6012,6 +6012,8 @@ var Diagnostics = {
6012
6012
  Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, 1 /* Error */, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
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
+ 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."),
6015
6017
  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}'."),
6016
6018
  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}'."),
6017
6019
  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}'."),
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.1.0-dev.20230317",
5
+ "version": "5.1.0-dev.20230318",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -113,5 +113,5 @@
113
113
  "node": "14.21.1",
114
114
  "npm": "8.19.3"
115
115
  },
116
- "gitHead": "ba42ad36467506f81a4f77d536354c4cb90c32d9"
116
+ "gitHead": "905a0b4e693e8cc13a726ad650b908fee4f75408"
117
117
  }