codemix / babel-plugin-typecheck

Static and runtime type checking for JavaScript in the form of a Babel plugin.
MIT License
886 stars 44 forks source link

Expecting type alias for function return value does not throw an error when no value is returned. #152

Closed taylorstine closed 7 years ago

taylorstine commented 8 years ago

Sample code:

import type {MyType} from './types.js'

const obj = {
  theFunction: ():MyType=> {//note nothing is returned here}
};

Output:

var obj = {
  theFunction: function theFunction() {}
};

Without a type alias:

  const obj = {
    theFunction: ():string=> {//note nothing is returned here}
  };

This throws a syntax error on compile. I would expect the former code to do the same, am I missing something?

phpnode commented 7 years ago

Hi, sorry for taking so long to respond to this, this project is now deprecated in favour of https://codemix.github.io/flow-runtime which aims for full compatibility with Flow.

babel-plugin-flow-runtime doesn't yet support this either, but I opened an issue here: https://github.com/codemix/flow-runtime/issues/2