-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Description
The old compiler was permissive with both of the following code snippets:
function foo(): number {
return;
}
class C {
public foo() {
return;
}
}
as per the 1.0 spec (6.3):
An explicitly typed function whose return type isn't the Void or the Any type must have at least one
return
statement somewhere in its body. An exception to this rule is if the function implementation consists of a singlethrow
statement.
I believe we should change this to
An explicitly typed function whose return type isn't the Void or the Any type must have at least one
return
expression somewhere in its body. An exception to this rule is if the function implementation consists of a singlethrow
statement.
It seems weird that we allow implicit return of undefined
through return
statements with no explicit expression, but we don't allow the implicit return of undefined
through by omitting return
statements entirely.