You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Non-void functions can omit return expressions #162
The old compiler was permissive with both of the following code snippets:
functionfoo(): number{return;}
classC{publicfoo(){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 single throw 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 returnexpression somewhere in its body. An exception to this rule is if the function implementation consists of a single throw 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.
changed the title [-]Functions with annotated return types, and get accessors, can lack a return expressions[/-][+]Functions with annotated return types, and get accessors, can omit return expressions[/+]on Jul 20, 2014
changed the title [-]Functions with annotated return types, and get accessors, can omit return expressions[/-][+]Non-void functions can omit return expressions[/+]on Jul 22, 2014
Activity
[-]Functions with annotated return types, and get accessors, can lack a return expressions[/-][+]Functions with annotated return types, and get accessors, can omit return expressions[/+][-]Functions with annotated return types, and get accessors, can omit return expressions[/-][+]Non-void functions can omit return expressions[/+]RyanCavanaugh commentedon Jul 29, 2014
Forward-duping to #228