mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Check return type includes 'undefined' in function with implicit return
This commit is contained in:
parent
d0e4b4ae35
commit
129a4f1908
@ -11095,6 +11095,9 @@ namespace ts {
|
||||
// NOTE: having returnType !== undefined is a precondition for entering this branch so func.type will always be present
|
||||
error(func.type, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
|
||||
}
|
||||
else if (returnType && strictNullChecks && !isTypeAssignableTo(undefinedType, returnType)) {
|
||||
error(func.type, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
|
||||
}
|
||||
else if (compilerOptions.noImplicitReturns) {
|
||||
if (!returnType) {
|
||||
// If return type annotation is omitted check if function has any explicit return statements.
|
||||
|
||||
@ -1091,6 +1091,10 @@
|
||||
"category": "Error",
|
||||
"code": 2365
|
||||
},
|
||||
"Function lacks ending return statement and return type does not include 'undefined'.": {
|
||||
"category": "Error",
|
||||
"code": 2366
|
||||
},
|
||||
"Type parameter name cannot be '{0}'": {
|
||||
"category": "Error",
|
||||
"code": 2368
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user