I'm trying to define a set of types that can refer to the whole set (the union of all those types), in a way that the set can be changed without having to rewrite each type.
See the piece of code which follows to understand what I mean.
The other day I tried something more or less similar, but I ran into weird issues: TS was arbitrarily reporting errors in some cases but not others.
By "arbitrarily" I mean that by looking at the code, I can't tell when or why it would report errors.
I learned that it's due to https://github.com/microsoft/TypeScript/issues/37426: apparently only some recursion approaches are supported by TS. The others may work or may not work depending on the TS' internals, in a way that one can't predict.
I wonder whether the approach I'm using in the following snippet is guaranteed to work.
In case some approach might fail in some cases (due to not being supported by TS), I'd like to know and I'd like to find ways to make it always work.
How can I tell?