You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
T becomes the AST category. You pass union types of chosen ASTs, so that ExprWithSugar could be a Unary with SugaredExpr inside, but Expr could not.
Expected behavior: It compiles
Actual behavior: Type alias 'ExprWithSugar' circularly references itself.ts(2456) Type alias 'Expr' circularly references itself.ts(2456)
Obviously both ExprWithSugar and Expr should correct, because Stop ensures that the recursion is not infinite.
Related Issues: This is about recursive type alias. I searched and see some issues, but all of them seems incorrect. And I believe I am making a valid one.
The text was updated successfully, but these errors were encountered:
If you search "recursive type aliases" you get this PR in first few hits: #33050. It was merged recently and enables this scenario for 3.7. You can try it out in the beta here.
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms:
Code
Before pasting the code that makes tsc prompt compiler errors, please allow me to explain my scenario.
I am making an AST for a language, let's say it looks like this:
Before compiling the code, I have a function called
desugar
, which transformsSugaredExpr
to the combination of others, so the output looks like this:Now I want to describe the type of
desugar
in an accurate way without violating the DRY principal, so I write the following code:T
becomes the AST category. You pass union types of chosen ASTs, so thatExprWithSugar
could be aUnary
withSugaredExpr
inside, butExpr
could not.Expected behavior: It compiles
Actual behavior:
Type alias 'ExprWithSugar' circularly references itself.ts(2456)
Type alias 'Expr' circularly references itself.ts(2456)
Obviously both
ExprWithSugar
andExpr
should correct, becauseStop
ensures that the recursion is not infinite.Related Issues: This is about recursive type alias. I searched and see some issues, but all of them seems incorrect. And I believe I am making a valid one.
The text was updated successfully, but these errors were encountered: