mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-29 16:29:19 -05:00
Explicit undefined return type checked similar to explicit void return type (#53607)
This commit is contained in:
@@ -51,7 +51,6 @@ const fixIdAddReturnStatement = "fixAddReturnStatement";
|
||||
const fixRemoveBracesFromArrowFunctionBody = "fixRemoveBracesFromArrowFunctionBody";
|
||||
const fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
|
||||
const errorCodes = [
|
||||
Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
|
||||
Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code,
|
||||
Diagnostics.Type_0_is_not_assignable_to_type_1.code,
|
||||
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
|
||||
@@ -214,7 +213,6 @@ function getInfo(checker: TypeChecker, sourceFile: SourceFile, position: number,
|
||||
|
||||
const declaration = findAncestor(node.parent, isFunctionLikeDeclaration);
|
||||
switch (errorCode) {
|
||||
case Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code:
|
||||
case Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code:
|
||||
if (!declaration || !declaration.body || !declaration.type || !rangeContainsRange(declaration.type, node)) return undefined;
|
||||
return getFixInfo(checker, declaration, checker.getTypeFromTypeNode(declaration.type), /*isFunctionType*/ false);
|
||||
|
||||
Reference in New Issue
Block a user