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
Have you had a chance to think about expressing 'base' types as discriminated unions rather than just the straight inheritance model? So for example:
type Expression = EmptyExpression | ArrowFunctionExpression | ...
This would make it amazing for using the types for working with ASTs.
The basic task of working out the relationships shouldn't be too tricky, using interface extensions. But working out which types to express as a union seems like a hard problem. For example, no one is creating a raw Node instance, so that would be fine to express as a union type, but 'middle tier' types might be a bit trickier.
The other piece to it is that any type that is part of a union, needs to define their type parameter as a the explicit type name string, not just of type 'string'. For example,
Have you had a chance to think about expressing 'base' types as discriminated unions rather than just the straight inheritance model? So for example:
type Expression = EmptyExpression | ArrowFunctionExpression | ...
This would make it amazing for using the types for working with ASTs.
The basic task of working out the relationships shouldn't be too tricky, using interface extensions. But working out which types to express as a union seems like a hard problem. For example, no one is creating a raw
Node
instance, so that would be fine to express as a union type, but 'middle tier' types might be a bit trickier.The other piece to it is that any type that is part of a union, needs to define their type parameter as a the explicit type name string, not just of type 'string'. For example,
The text was updated successfully, but these errors were encountered: