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

Problem with cyclic type definition #106

Closed alendit closed 7 years ago

alendit commented 8 years ago

Hello, please see https://github.com/alendit/babel-typecheck-circular-types for an example.

In main.js I define 2 types which reference each other. The function addBsToA takes an object of type A and a list of Bs and 'connects' them.

When I add a return type check in the line 11 typecheck breaks with an error about an infinite recursion. a flow check doesn't find any errors in main.js inself.

I realize that it's quite hard to check for circular dependencies at runtime and I'm not sure if you aim to support it. Since I haven't found any information about it in the docs and normal flow does seem to support this case, I think the difference should either be mentioned in the docs or the case should be supported.

phpnode commented 8 years ago

@alendit oh that's a nasty one. I'll have a think about what we can do to handle this more gracefully.

alendit commented 8 years ago

Two ideas:

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.

flow-runtime can deal with cyclic objects properly