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
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.
The text was updated successfully, but these errors were encountered:
DanielRosenwasser
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
Jul 20, 2014
DanielRosenwasser
changed the title
Functions with annotated return types, and get accessors, can omit return expressions
Non-void functions can omit return expressions
Jul 22, 2014
The old compiler was permissive with both of the following code snippets:
as per the 1.0 spec (6.3):
I believe we should change this to
It seems weird that we allow implicit return of
undefined
throughreturn
statements with no explicit expression, but we don't allow the implicit return ofundefined
through by omittingreturn
statements entirely.The text was updated successfully, but these errors were encountered: