scope() how to bypass circular reference error?
I've implemented with Scope() successfully circular references, but somehow, I hit a limitation as this one still throws a circular reference error:
Error:
9 Replies
Hmm, seems like a limitation of TypeScript. That type is quite hard to wrap my head around though, maybe worth seeing if it's possible to find another approach
This is the working equivalent in typescript:
Yeah I'm not saying it's impossible in native TS, but even with all the optimizations, there are still limitations on what TS will be able to resolve when having to parse and compare everything
My guess is that it gets stuck trying to resolve the type of
queryValueObject
as a constraint since it has to be parsed in the key of the objectDo you think this is solvable, and should I create a GitHub issue, or is it a general limitation?
It's unlikely it is solvable with that syntax, although maybe with an alternate syntax it could work
There are other limitations of TS though when it comes to inferring certain cyclic scopes. Frankly it's amazing as much works as it does, but it's unlikely there's much more I can do at least with the primary syntax in that regard
Sound like you should consider writing your own compiler to get beyond such problems 😛
Yeah I'll get right on that 😅
In the meantime you can remove the constraint as a workaround:
I guess that is the only place in the type it even uses the scope though haha
I think I go for now with this one:
Glad you found that something to tide you over while I finish that new compiler 😛