'Type alias circularly references itself - parsing expressions

I was writing a parser parsing expressions and defined these types:

export type ExpressionType = AdditiveExpressionType;

export type AdditiveExpressionType =
  | MultiplicativeExpressionType
  | {
      type: string;
      operator: string;
      left: AdditiveExpressionType | MultiplicativeExpressionType;
      right: MultiplicativeExpressionType;
    };

export type MultiplicativeExpressionType =
  | PrimaryExpressionType
  | {
      type: string;
      operator: string;
      left: MultiplicativeExpressionType | PrimaryExpressionType;
      right: PrimaryExpressionType;
    };

export type PrimaryExpressionType = LiteralType | ParenthesizedExpressionType;

export type ParenthesizedExpressionType = LiteralType | ExpressionType;

export type LiteralType = StringLiteralType | NumericLiteralType;

export type StringLiteralType = { type: string; value: string };

export type NumericLiteralType = { type: string; value: number };

However I got errors: Type alias circularly references itself because ParenthesizedExpressionType can be another ExpressionType. How should avoid this circular reference error?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source