Closed alendit closed 7 years ago
@alendit oh that's a nasty one. I'll have a think about what we can do to handle this more gracefully.
Two ideas:
_checked
and check for this property in the child's checker before executing a recursive type check. The problem here would be that a dynamic property would greatly mess with V8's ability to optimize the codeHi, 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
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 functionaddBsToA
takes an object of typeA
and a list ofB
s and 'connects' them.When I add a return type check in the
line 11
typecheck
breaks with an error about an infinite recursion. aflow 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.