flow-runtime icon indicating copy to clipboard operation
flow-runtime copied to clipboard

Add assertions when implicitly returning from a function

Open phpnode opened this issue 8 years ago • 2 comments

Issuehunt badges

Currently if a function implicitly returns undefined (by leaving the function without an explicit return statement) we won't generate a check for it, e.g:

function foo (): string {
  // no return
}

currently compiles to:

function foo () {
  const _returnType = t.return(t.string()); 
  // no return
}

We should insert a call to _returnType.assert(undefined) at these points.


IssueHunt Summary

Backers (Total: $20.00)

Submitted pull Requests


Become a backer now!

Or submit a pull request to get the deposits!

Tips

phpnode avatar Jan 04 '17 18:01 phpnode

marking as low priority because Flow already catches this.

phpnode avatar Jan 06 '17 17:01 phpnode

@issuehunt has funded $20.00 to this issue.


issuehunt-oss[bot] avatar Jul 24 '19 13:07 issuehunt-oss[bot]