Don't error when function has an implicit return but its return type is assignable to undefined (#53490)

This commit is contained in:
Maria José Solano
2023-03-27 13:21:07 -07:00
committed by GitHub
parent 437fd059be
commit c5b288487a
10 changed files with 663 additions and 6 deletions

View File

@@ -35658,8 +35658,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
const functionFlags = getFunctionFlags(func);
const type = returnType && unwrapReturnType(returnType, functionFlags);
// Functions with an explicitly specified 'undefined, 'void' or 'any' return type don't need any return expressions.
if (type && maybeTypeOfKind(type, TypeFlags.Undefined | TypeFlags.Void | TypeFlags.Any)) {
// Functions with an explicitly specified 'undefined, 'void', 'any' or 'unknown' return type don't need any return expressions.
if (type && maybeTypeOfKind(type, TypeFlags.Undefined | TypeFlags.Void | TypeFlags.Any | TypeFlags.Unknown)) {
return;
}