typescript 5.1.0-dev.20230401 → 5.1.0-dev.20230402

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
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.1";
21
- var version = `${versionMajorMinor}.0-dev.20230401`;
21
+ var version = `${versionMajorMinor}.0-dev.20230402`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -6193,7 +6193,7 @@ var Diagnostics = {
6193
6193
  Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first: diag(2352, 1 /* Error */, "Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the__2352", "Conversion of type '{0}' to type '{1}' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first."),
6194
6194
  Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, 1 /* Error */, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."),
6195
6195
  This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, 1 /* Error */, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."),
6196
- A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, 1 /* Error */, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."),
6196
+ A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2355, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
6197
6197
  An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, 1 /* Error */, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."),
6198
6198
  The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, 1 /* Error */, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
6199
6199
  The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
@@ -6633,7 +6633,6 @@ var Diagnostics = {
6633
6633
  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."),
6634
6634
  This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
6635
6635
  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?"),
6636
- 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."),
6637
6636
  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."),
6638
6637
  Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1: diag(2849, 1 /* Error */, "Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1_2849", "Target signature provides too few arguments. Expected {0} or more, but got {1}."),
6639
6638
  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}'."),
@@ -53493,7 +53492,7 @@ function createTypeChecker(host) {
53493
53492
  }
53494
53493
  function isConstTypeVariable(type) {
53495
53494
  var _a2;
53496
- return !!(type.flags & 262144 /* TypeParameter */ && some((_a2 = type.symbol) == null ? void 0 : _a2.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || isGenericTupleType(type) && findIndex(getTypeArguments(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t)) >= 0 || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType));
53495
+ return !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a2 = type.symbol) == null ? void 0 : _a2.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 1048576 /* Union */ && some(type.types, isConstTypeVariable) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type)) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType) || isGenericTupleType(type) && findIndex(getTypeArguments(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t)) >= 0));
53497
53496
  }
53498
53497
  function getConstraintOfIndexedAccess(type) {
53499
53498
  return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
@@ -72016,7 +72015,16 @@ function createTypeChecker(host) {
72016
72015
  return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, neverType) : neverType;
72017
72016
  }
72018
72017
  if (types.length === 0) {
72019
- return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, voidType) : voidType;
72018
+ const contextualReturnType = getContextualReturnType(
72019
+ func,
72020
+ /*contextFlags*/
72021
+ void 0
72022
+ );
72023
+ const returnType2 = contextualReturnType && (unwrapReturnType(contextualReturnType, functionFlags) || voidType).flags & 32768 /* Undefined */ ? undefinedType : voidType;
72024
+ return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, returnType2) : (
72025
+ // Async function
72026
+ returnType2
72027
+ );
72020
72028
  }
72021
72029
  returnType = getUnionType(types, 2 /* Subtype */);
72022
72030
  }
@@ -72238,7 +72246,7 @@ function createTypeChecker(host) {
72238
72246
  function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
72239
72247
  const functionFlags = getFunctionFlags(func);
72240
72248
  const type = returnType && unwrapReturnType(returnType, functionFlags);
72241
- if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */ | 2 /* Unknown */)) {
72249
+ if (type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */))) {
72242
72250
  return;
72243
72251
  }
72244
72252
  if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
@@ -72249,12 +72257,8 @@ function createTypeChecker(host) {
72249
72257
  if (type && type.flags & 131072 /* Never */) {
72250
72258
  error(errorNode, Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
72251
72259
  } else if (type && !hasExplicitReturn) {
72252
- if (strictNullChecks) {
72253
- error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
72254
- } else {
72255
- error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
72256
- }
72257
- } else if (type && strictNullChecks) {
72260
+ error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
72261
+ } else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
72258
72262
  error(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
72259
72263
  } else if (compilerOptions.noImplicitReturns) {
72260
72264
  if (!type) {
@@ -72262,7 +72266,7 @@ function createTypeChecker(host) {
72262
72266
  return;
72263
72267
  }
72264
72268
  const inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
72265
- if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
72269
+ if (isUnwrappedReturnTypeUndefinedVoidOrAny(func, inferredReturnType)) {
72266
72270
  return;
72267
72271
  }
72268
72272
  }
@@ -73728,11 +73732,7 @@ function createTypeChecker(host) {
73728
73732
  }
73729
73733
  function isConstContext(node) {
73730
73734
  const parent = node.parent;
73731
- return isAssertionExpression(parent) && isConstTypeReference(parent.type) || isJSDocTypeAssertion(parent) && isConstTypeReference(getJSDocTypeAssertionType(parent)) || isValidConstAssertionArgument(node) && isConstTypeParameterContext(node) || (isParenthesizedExpression(parent) || isArrayLiteralExpression(parent) || isSpreadElement(parent)) && isConstContext(parent) || (isPropertyAssignment(parent) || isShorthandPropertyAssignment(parent) || isTemplateSpan(parent)) && isConstContext(parent.parent);
73732
- }
73733
- function isConstTypeParameterContext(node) {
73734
- const contextualType = getContextualType(node, 0 /* None */);
73735
- return !!contextualType && someType(contextualType, isConstTypeVariable);
73735
+ return isAssertionExpression(parent) && isConstTypeReference(parent.type) || isJSDocTypeAssertion(parent) && isConstTypeReference(getJSDocTypeAssertionType(parent)) || isValidConstAssertionArgument(node) && isConstTypeVariable(getContextualType(node, 0 /* None */)) || (isParenthesizedExpression(parent) || isArrayLiteralExpression(parent) || isSpreadElement(parent)) && isConstContext(parent) || (isPropertyAssignment(parent) || isShorthandPropertyAssignment(parent) || isTemplateSpan(parent)) && isConstContext(parent.parent);
73736
73736
  }
73737
73737
  function checkExpressionForMutableLocation(node, checkMode, forceTuple) {
73738
73738
  const type = checkExpression(node, checkMode, forceTuple);
@@ -77415,9 +77415,9 @@ function createTypeChecker(host) {
77415
77415
  }
77416
77416
  return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType;
77417
77417
  }
77418
- function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
77419
- const unwrappedReturnType = unwrapReturnType(returnType, getFunctionFlags(func));
77420
- return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */);
77418
+ function isUnwrappedReturnTypeUndefinedVoidOrAny(func, returnType) {
77419
+ const type = unwrapReturnType(returnType, getFunctionFlags(func));
77420
+ return !!(type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */)));
77421
77421
  }
77422
77422
  function checkReturnStatement(node) {
77423
77423
  var _a2;
@@ -77459,7 +77459,7 @@ function createTypeChecker(host) {
77459
77459
  checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
77460
77460
  }
77461
77461
  }
77462
- } else if (container.kind !== 174 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) {
77462
+ } else if (container.kind !== 174 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeUndefinedVoidOrAny(container, returnType)) {
77463
77463
  error(node, Diagnostics.Not_all_code_paths_return_a_value);
77464
77464
  }
77465
77465
  }
package/lib/tsserver.js CHANGED
@@ -2292,7 +2292,7 @@ module.exports = __toCommonJS(server_exports);
2292
2292
 
2293
2293
  // src/compiler/corePublic.ts
2294
2294
  var versionMajorMinor = "5.1";
2295
- var version = `${versionMajorMinor}.0-dev.20230401`;
2295
+ var version = `${versionMajorMinor}.0-dev.20230402`;
2296
2296
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2297
2297
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2298
2298
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -9692,7 +9692,7 @@ var Diagnostics = {
9692
9692
  Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first: diag(2352, 1 /* Error */, "Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the__2352", "Conversion of type '{0}' to type '{1}' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first."),
9693
9693
  Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, 1 /* Error */, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."),
9694
9694
  This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, 1 /* Error */, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."),
9695
- A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, 1 /* Error */, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."),
9695
+ A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2355, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
9696
9696
  An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, 1 /* Error */, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."),
9697
9697
  The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, 1 /* Error */, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
9698
9698
  The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
@@ -10132,7 +10132,6 @@ var Diagnostics = {
10132
10132
  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."),
10133
10133
  This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
10134
10134
  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?"),
10135
- 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."),
10136
10135
  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."),
10137
10136
  Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1: diag(2849, 1 /* Error */, "Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1_2849", "Target signature provides too few arguments. Expected {0} or more, but got {1}."),
10138
10137
  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}'."),
@@ -58141,7 +58140,7 @@ function createTypeChecker(host) {
58141
58140
  }
58142
58141
  function isConstTypeVariable(type) {
58143
58142
  var _a2;
58144
- return !!(type.flags & 262144 /* TypeParameter */ && some((_a2 = type.symbol) == null ? void 0 : _a2.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || isGenericTupleType(type) && findIndex(getTypeArguments(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t)) >= 0 || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType));
58143
+ return !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a2 = type.symbol) == null ? void 0 : _a2.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 1048576 /* Union */ && some(type.types, isConstTypeVariable) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type)) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType) || isGenericTupleType(type) && findIndex(getTypeArguments(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t)) >= 0));
58145
58144
  }
58146
58145
  function getConstraintOfIndexedAccess(type) {
58147
58146
  return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
@@ -76664,7 +76663,16 @@ function createTypeChecker(host) {
76664
76663
  return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, neverType) : neverType;
76665
76664
  }
76666
76665
  if (types.length === 0) {
76667
- return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, voidType) : voidType;
76666
+ const contextualReturnType = getContextualReturnType(
76667
+ func,
76668
+ /*contextFlags*/
76669
+ void 0
76670
+ );
76671
+ const returnType2 = contextualReturnType && (unwrapReturnType(contextualReturnType, functionFlags) || voidType).flags & 32768 /* Undefined */ ? undefinedType : voidType;
76672
+ return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, returnType2) : (
76673
+ // Async function
76674
+ returnType2
76675
+ );
76668
76676
  }
76669
76677
  returnType = getUnionType(types, 2 /* Subtype */);
76670
76678
  }
@@ -76886,7 +76894,7 @@ function createTypeChecker(host) {
76886
76894
  function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
76887
76895
  const functionFlags = getFunctionFlags(func);
76888
76896
  const type = returnType && unwrapReturnType(returnType, functionFlags);
76889
- if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */ | 2 /* Unknown */)) {
76897
+ if (type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */))) {
76890
76898
  return;
76891
76899
  }
76892
76900
  if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
@@ -76897,12 +76905,8 @@ function createTypeChecker(host) {
76897
76905
  if (type && type.flags & 131072 /* Never */) {
76898
76906
  error(errorNode, Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
76899
76907
  } else if (type && !hasExplicitReturn) {
76900
- if (strictNullChecks) {
76901
- error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
76902
- } else {
76903
- error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
76904
- }
76905
- } else if (type && strictNullChecks) {
76908
+ error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
76909
+ } else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
76906
76910
  error(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
76907
76911
  } else if (compilerOptions.noImplicitReturns) {
76908
76912
  if (!type) {
@@ -76910,7 +76914,7 @@ function createTypeChecker(host) {
76910
76914
  return;
76911
76915
  }
76912
76916
  const inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
76913
- if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
76917
+ if (isUnwrappedReturnTypeUndefinedVoidOrAny(func, inferredReturnType)) {
76914
76918
  return;
76915
76919
  }
76916
76920
  }
@@ -78376,11 +78380,7 @@ function createTypeChecker(host) {
78376
78380
  }
78377
78381
  function isConstContext(node) {
78378
78382
  const parent2 = node.parent;
78379
- return isAssertionExpression(parent2) && isConstTypeReference(parent2.type) || isJSDocTypeAssertion(parent2) && isConstTypeReference(getJSDocTypeAssertionType(parent2)) || isValidConstAssertionArgument(node) && isConstTypeParameterContext(node) || (isParenthesizedExpression(parent2) || isArrayLiteralExpression(parent2) || isSpreadElement(parent2)) && isConstContext(parent2) || (isPropertyAssignment(parent2) || isShorthandPropertyAssignment(parent2) || isTemplateSpan(parent2)) && isConstContext(parent2.parent);
78380
- }
78381
- function isConstTypeParameterContext(node) {
78382
- const contextualType = getContextualType2(node, 0 /* None */);
78383
- return !!contextualType && someType(contextualType, isConstTypeVariable);
78383
+ return isAssertionExpression(parent2) && isConstTypeReference(parent2.type) || isJSDocTypeAssertion(parent2) && isConstTypeReference(getJSDocTypeAssertionType(parent2)) || isValidConstAssertionArgument(node) && isConstTypeVariable(getContextualType2(node, 0 /* None */)) || (isParenthesizedExpression(parent2) || isArrayLiteralExpression(parent2) || isSpreadElement(parent2)) && isConstContext(parent2) || (isPropertyAssignment(parent2) || isShorthandPropertyAssignment(parent2) || isTemplateSpan(parent2)) && isConstContext(parent2.parent);
78384
78384
  }
78385
78385
  function checkExpressionForMutableLocation(node, checkMode, forceTuple) {
78386
78386
  const type = checkExpression(node, checkMode, forceTuple);
@@ -82063,9 +82063,9 @@ function createTypeChecker(host) {
82063
82063
  }
82064
82064
  return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType;
82065
82065
  }
82066
- function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
82067
- const unwrappedReturnType = unwrapReturnType(returnType, getFunctionFlags(func));
82068
- return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */);
82066
+ function isUnwrappedReturnTypeUndefinedVoidOrAny(func, returnType) {
82067
+ const type = unwrapReturnType(returnType, getFunctionFlags(func));
82068
+ return !!(type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */)));
82069
82069
  }
82070
82070
  function checkReturnStatement(node) {
82071
82071
  var _a2;
@@ -82107,7 +82107,7 @@ function createTypeChecker(host) {
82107
82107
  checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
82108
82108
  }
82109
82109
  }
82110
- } else if (container.kind !== 174 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) {
82110
+ } else if (container.kind !== 174 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeUndefinedVoidOrAny(container, returnType)) {
82111
82111
  error(node, Diagnostics.Not_all_code_paths_return_a_value);
82112
82112
  }
82113
82113
  }
@@ -143921,7 +143921,6 @@ var fixIdAddReturnStatement = "fixAddReturnStatement";
143921
143921
  var fixRemoveBracesFromArrowFunctionBody = "fixRemoveBracesFromArrowFunctionBody";
143922
143922
  var fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
143923
143923
  var errorCodes26 = [
143924
- Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
143925
143924
  Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code,
143926
143925
  Diagnostics.Type_0_is_not_assignable_to_type_1.code,
143927
143926
  Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
@@ -144073,7 +144072,6 @@ function getInfo6(checker, sourceFile, position, errorCode) {
144073
144072
  return void 0;
144074
144073
  const declaration = findAncestor(node.parent, isFunctionLikeDeclaration);
144075
144074
  switch (errorCode) {
144076
- case Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code:
144077
144075
  case Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code:
144078
144076
  if (!declaration || !declaration.body || !declaration.type || !rangeContainsRange(declaration.type, node))
144079
144077
  return void 0;
@@ -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.20230401`;
38
+ version = `${versionMajorMinor}.0-dev.20230402`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -7509,7 +7509,7 @@ ${lanes.join("\n")}
7509
7509
  Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first: diag(2352, 1 /* Error */, "Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the__2352", "Conversion of type '{0}' to type '{1}' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first."),
7510
7510
  Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, 1 /* Error */, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."),
7511
7511
  This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, 1 /* Error */, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."),
7512
- A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, 1 /* Error */, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."),
7512
+ A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2355, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
7513
7513
  An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, 1 /* Error */, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."),
7514
7514
  The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, 1 /* Error */, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
7515
7515
  The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
@@ -7949,7 +7949,6 @@ ${lanes.join("\n")}
7949
7949
  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."),
7950
7950
  This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
7951
7951
  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?"),
7952
- 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."),
7953
7952
  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."),
7954
7953
  Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1: diag(2849, 1 /* Error */, "Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1_2849", "Target signature provides too few arguments. Expected {0} or more, but got {1}."),
7955
7954
  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}'."),
@@ -55943,7 +55942,7 @@ ${lanes.join("\n")}
55943
55942
  }
55944
55943
  function isConstTypeVariable(type) {
55945
55944
  var _a2;
55946
- return !!(type.flags & 262144 /* TypeParameter */ && some((_a2 = type.symbol) == null ? void 0 : _a2.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || isGenericTupleType(type) && findIndex(getTypeArguments(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t)) >= 0 || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType));
55945
+ return !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a2 = type.symbol) == null ? void 0 : _a2.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 1048576 /* Union */ && some(type.types, isConstTypeVariable) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type)) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType) || isGenericTupleType(type) && findIndex(getTypeArguments(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t)) >= 0));
55947
55946
  }
55948
55947
  function getConstraintOfIndexedAccess(type) {
55949
55948
  return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
@@ -74466,7 +74465,16 @@ ${lanes.join("\n")}
74466
74465
  return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, neverType) : neverType;
74467
74466
  }
74468
74467
  if (types.length === 0) {
74469
- return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, voidType) : voidType;
74468
+ const contextualReturnType = getContextualReturnType(
74469
+ func,
74470
+ /*contextFlags*/
74471
+ void 0
74472
+ );
74473
+ const returnType2 = contextualReturnType && (unwrapReturnType(contextualReturnType, functionFlags) || voidType).flags & 32768 /* Undefined */ ? undefinedType : voidType;
74474
+ return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, returnType2) : (
74475
+ // Async function
74476
+ returnType2
74477
+ );
74470
74478
  }
74471
74479
  returnType = getUnionType(types, 2 /* Subtype */);
74472
74480
  }
@@ -74688,7 +74696,7 @@ ${lanes.join("\n")}
74688
74696
  function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
74689
74697
  const functionFlags = getFunctionFlags(func);
74690
74698
  const type = returnType && unwrapReturnType(returnType, functionFlags);
74691
- if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */ | 2 /* Unknown */)) {
74699
+ if (type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */))) {
74692
74700
  return;
74693
74701
  }
74694
74702
  if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
@@ -74699,12 +74707,8 @@ ${lanes.join("\n")}
74699
74707
  if (type && type.flags & 131072 /* Never */) {
74700
74708
  error(errorNode, Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
74701
74709
  } else if (type && !hasExplicitReturn) {
74702
- if (strictNullChecks) {
74703
- error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
74704
- } else {
74705
- error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
74706
- }
74707
- } else if (type && strictNullChecks) {
74710
+ error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
74711
+ } else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
74708
74712
  error(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
74709
74713
  } else if (compilerOptions.noImplicitReturns) {
74710
74714
  if (!type) {
@@ -74712,7 +74716,7 @@ ${lanes.join("\n")}
74712
74716
  return;
74713
74717
  }
74714
74718
  const inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
74715
- if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
74719
+ if (isUnwrappedReturnTypeUndefinedVoidOrAny(func, inferredReturnType)) {
74716
74720
  return;
74717
74721
  }
74718
74722
  }
@@ -76178,11 +76182,7 @@ ${lanes.join("\n")}
76178
76182
  }
76179
76183
  function isConstContext(node) {
76180
76184
  const parent2 = node.parent;
76181
- return isAssertionExpression(parent2) && isConstTypeReference(parent2.type) || isJSDocTypeAssertion(parent2) && isConstTypeReference(getJSDocTypeAssertionType(parent2)) || isValidConstAssertionArgument(node) && isConstTypeParameterContext(node) || (isParenthesizedExpression(parent2) || isArrayLiteralExpression(parent2) || isSpreadElement(parent2)) && isConstContext(parent2) || (isPropertyAssignment(parent2) || isShorthandPropertyAssignment(parent2) || isTemplateSpan(parent2)) && isConstContext(parent2.parent);
76182
- }
76183
- function isConstTypeParameterContext(node) {
76184
- const contextualType = getContextualType2(node, 0 /* None */);
76185
- return !!contextualType && someType(contextualType, isConstTypeVariable);
76185
+ return isAssertionExpression(parent2) && isConstTypeReference(parent2.type) || isJSDocTypeAssertion(parent2) && isConstTypeReference(getJSDocTypeAssertionType(parent2)) || isValidConstAssertionArgument(node) && isConstTypeVariable(getContextualType2(node, 0 /* None */)) || (isParenthesizedExpression(parent2) || isArrayLiteralExpression(parent2) || isSpreadElement(parent2)) && isConstContext(parent2) || (isPropertyAssignment(parent2) || isShorthandPropertyAssignment(parent2) || isTemplateSpan(parent2)) && isConstContext(parent2.parent);
76186
76186
  }
76187
76187
  function checkExpressionForMutableLocation(node, checkMode, forceTuple) {
76188
76188
  const type = checkExpression(node, checkMode, forceTuple);
@@ -79865,9 +79865,9 @@ ${lanes.join("\n")}
79865
79865
  }
79866
79866
  return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType;
79867
79867
  }
79868
- function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
79869
- const unwrappedReturnType = unwrapReturnType(returnType, getFunctionFlags(func));
79870
- return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */);
79868
+ function isUnwrappedReturnTypeUndefinedVoidOrAny(func, returnType) {
79869
+ const type = unwrapReturnType(returnType, getFunctionFlags(func));
79870
+ return !!(type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */)));
79871
79871
  }
79872
79872
  function checkReturnStatement(node) {
79873
79873
  var _a2;
@@ -79909,7 +79909,7 @@ ${lanes.join("\n")}
79909
79909
  checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
79910
79910
  }
79911
79911
  }
79912
- } else if (container.kind !== 174 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) {
79912
+ } else if (container.kind !== 174 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeUndefinedVoidOrAny(container, returnType)) {
79913
79913
  error(node, Diagnostics.Not_all_code_paths_return_a_value);
79914
79914
  }
79915
79915
  }
@@ -142677,7 +142677,6 @@ ${lanes.join("\n")}
142677
142677
  return void 0;
142678
142678
  const declaration = findAncestor(node.parent, isFunctionLikeDeclaration);
142679
142679
  switch (errorCode) {
142680
- case Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code:
142681
142680
  case Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code:
142682
142681
  if (!declaration || !declaration.body || !declaration.type || !rangeContainsRange(declaration.type, node))
142683
142682
  return void 0;
@@ -142785,7 +142784,6 @@ ${lanes.join("\n")}
142785
142784
  fixRemoveBracesFromArrowFunctionBody = "fixRemoveBracesFromArrowFunctionBody";
142786
142785
  fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
142787
142786
  errorCodes26 = [
142788
- Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
142789
142787
  Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code,
142790
142788
  Diagnostics.Type_0_is_not_assignable_to_type_1.code,
142791
142789
  Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
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.20230401`;
38
+ version = `${versionMajorMinor}.0-dev.20230402`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -7509,7 +7509,7 @@ ${lanes.join("\n")}
7509
7509
  Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first: diag(2352, 1 /* Error */, "Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the__2352", "Conversion of type '{0}' to type '{1}' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first."),
7510
7510
  Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, 1 /* Error */, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."),
7511
7511
  This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, 1 /* Error */, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."),
7512
- A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, 1 /* Error */, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."),
7512
+ A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2355, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
7513
7513
  An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, 1 /* Error */, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."),
7514
7514
  The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, 1 /* Error */, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
7515
7515
  The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
@@ -7949,7 +7949,6 @@ ${lanes.join("\n")}
7949
7949
  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."),
7950
7950
  This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
7951
7951
  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?"),
7952
- 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."),
7953
7952
  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."),
7954
7953
  Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1: diag(2849, 1 /* Error */, "Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1_2849", "Target signature provides too few arguments. Expected {0} or more, but got {1}."),
7955
7954
  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}'."),
@@ -55943,7 +55942,7 @@ ${lanes.join("\n")}
55943
55942
  }
55944
55943
  function isConstTypeVariable(type) {
55945
55944
  var _a2;
55946
- return !!(type.flags & 262144 /* TypeParameter */ && some((_a2 = type.symbol) == null ? void 0 : _a2.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || isGenericTupleType(type) && findIndex(getTypeArguments(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t)) >= 0 || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType));
55945
+ return !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a2 = type.symbol) == null ? void 0 : _a2.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 1048576 /* Union */ && some(type.types, isConstTypeVariable) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type)) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType) || isGenericTupleType(type) && findIndex(getTypeArguments(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t)) >= 0));
55947
55946
  }
55948
55947
  function getConstraintOfIndexedAccess(type) {
55949
55948
  return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
@@ -74466,7 +74465,16 @@ ${lanes.join("\n")}
74466
74465
  return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, neverType) : neverType;
74467
74466
  }
74468
74467
  if (types.length === 0) {
74469
- return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, voidType) : voidType;
74468
+ const contextualReturnType = getContextualReturnType(
74469
+ func,
74470
+ /*contextFlags*/
74471
+ void 0
74472
+ );
74473
+ const returnType2 = contextualReturnType && (unwrapReturnType(contextualReturnType, functionFlags) || voidType).flags & 32768 /* Undefined */ ? undefinedType : voidType;
74474
+ return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, returnType2) : (
74475
+ // Async function
74476
+ returnType2
74477
+ );
74470
74478
  }
74471
74479
  returnType = getUnionType(types, 2 /* Subtype */);
74472
74480
  }
@@ -74688,7 +74696,7 @@ ${lanes.join("\n")}
74688
74696
  function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
74689
74697
  const functionFlags = getFunctionFlags(func);
74690
74698
  const type = returnType && unwrapReturnType(returnType, functionFlags);
74691
- if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */ | 2 /* Unknown */)) {
74699
+ if (type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */))) {
74692
74700
  return;
74693
74701
  }
74694
74702
  if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
@@ -74699,12 +74707,8 @@ ${lanes.join("\n")}
74699
74707
  if (type && type.flags & 131072 /* Never */) {
74700
74708
  error(errorNode, Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
74701
74709
  } else if (type && !hasExplicitReturn) {
74702
- if (strictNullChecks) {
74703
- error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
74704
- } else {
74705
- error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
74706
- }
74707
- } else if (type && strictNullChecks) {
74710
+ error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
74711
+ } else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
74708
74712
  error(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
74709
74713
  } else if (compilerOptions.noImplicitReturns) {
74710
74714
  if (!type) {
@@ -74712,7 +74716,7 @@ ${lanes.join("\n")}
74712
74716
  return;
74713
74717
  }
74714
74718
  const inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
74715
- if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
74719
+ if (isUnwrappedReturnTypeUndefinedVoidOrAny(func, inferredReturnType)) {
74716
74720
  return;
74717
74721
  }
74718
74722
  }
@@ -76178,11 +76182,7 @@ ${lanes.join("\n")}
76178
76182
  }
76179
76183
  function isConstContext(node) {
76180
76184
  const parent2 = node.parent;
76181
- return isAssertionExpression(parent2) && isConstTypeReference(parent2.type) || isJSDocTypeAssertion(parent2) && isConstTypeReference(getJSDocTypeAssertionType(parent2)) || isValidConstAssertionArgument(node) && isConstTypeParameterContext(node) || (isParenthesizedExpression(parent2) || isArrayLiteralExpression(parent2) || isSpreadElement(parent2)) && isConstContext(parent2) || (isPropertyAssignment(parent2) || isShorthandPropertyAssignment(parent2) || isTemplateSpan(parent2)) && isConstContext(parent2.parent);
76182
- }
76183
- function isConstTypeParameterContext(node) {
76184
- const contextualType = getContextualType2(node, 0 /* None */);
76185
- return !!contextualType && someType(contextualType, isConstTypeVariable);
76185
+ return isAssertionExpression(parent2) && isConstTypeReference(parent2.type) || isJSDocTypeAssertion(parent2) && isConstTypeReference(getJSDocTypeAssertionType(parent2)) || isValidConstAssertionArgument(node) && isConstTypeVariable(getContextualType2(node, 0 /* None */)) || (isParenthesizedExpression(parent2) || isArrayLiteralExpression(parent2) || isSpreadElement(parent2)) && isConstContext(parent2) || (isPropertyAssignment(parent2) || isShorthandPropertyAssignment(parent2) || isTemplateSpan(parent2)) && isConstContext(parent2.parent);
76186
76186
  }
76187
76187
  function checkExpressionForMutableLocation(node, checkMode, forceTuple) {
76188
76188
  const type = checkExpression(node, checkMode, forceTuple);
@@ -79865,9 +79865,9 @@ ${lanes.join("\n")}
79865
79865
  }
79866
79866
  return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType;
79867
79867
  }
79868
- function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
79869
- const unwrappedReturnType = unwrapReturnType(returnType, getFunctionFlags(func));
79870
- return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */);
79868
+ function isUnwrappedReturnTypeUndefinedVoidOrAny(func, returnType) {
79869
+ const type = unwrapReturnType(returnType, getFunctionFlags(func));
79870
+ return !!(type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */)));
79871
79871
  }
79872
79872
  function checkReturnStatement(node) {
79873
79873
  var _a2;
@@ -79909,7 +79909,7 @@ ${lanes.join("\n")}
79909
79909
  checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
79910
79910
  }
79911
79911
  }
79912
- } else if (container.kind !== 174 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) {
79912
+ } else if (container.kind !== 174 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeUndefinedVoidOrAny(container, returnType)) {
79913
79913
  error(node, Diagnostics.Not_all_code_paths_return_a_value);
79914
79914
  }
79915
79915
  }
@@ -142691,7 +142691,6 @@ ${lanes.join("\n")}
142691
142691
  return void 0;
142692
142692
  const declaration = findAncestor(node.parent, isFunctionLikeDeclaration);
142693
142693
  switch (errorCode) {
142694
- case Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code:
142695
142694
  case Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code:
142696
142695
  if (!declaration || !declaration.body || !declaration.type || !rangeContainsRange(declaration.type, node))
142697
142696
  return void 0;
@@ -142799,7 +142798,6 @@ ${lanes.join("\n")}
142799
142798
  fixRemoveBracesFromArrowFunctionBody = "fixRemoveBracesFromArrowFunctionBody";
142800
142799
  fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
142801
142800
  errorCodes26 = [
142802
- Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
142803
142801
  Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code,
142804
142802
  Diagnostics.Type_0_is_not_assignable_to_type_1.code,
142805
142803
  Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
@@ -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.20230401`;
57
+ var version = `${versionMajorMinor}.0-dev.20230402`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -5573,7 +5573,7 @@ var Diagnostics = {
5573
5573
  Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first: diag(2352, 1 /* Error */, "Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the__2352", "Conversion of type '{0}' to type '{1}' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first."),
5574
5574
  Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, 1 /* Error */, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."),
5575
5575
  This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, 1 /* Error */, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."),
5576
- A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, 1 /* Error */, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."),
5576
+ A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2355, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
5577
5577
  An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, 1 /* Error */, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."),
5578
5578
  The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, 1 /* Error */, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
5579
5579
  The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
@@ -6013,7 +6013,6 @@ var Diagnostics = {
6013
6013
  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."),
6014
6014
  This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
6015
6015
  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?"),
6016
- 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."),
6017
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."),
6018
6017
  Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1: diag(2849, 1 /* Error */, "Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1_2849", "Target signature provides too few arguments. Expected {0} or more, but got {1}."),
6019
6018
  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}'."),
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.20230401",
5
+ "version": "5.1.0-dev.20230402",
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": "27d3454f07cb41a24275d7f1de07621b8217f739"
116
+ "gitHead": "21db2ae9a2cb8ba88f9b10ac11d3bbd928bde3b1"
117
117
  }