-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
returnstatement somewhere in its body. An exception to this rule is if the function implementation consists of a singlethrowstatement.
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
returnexpression somewhere in its body. An exception to this rule is if the function implementation consists of a singlethrowstatement.
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.