import { BaseNode } from "./base.js"; import { Literal, VariableNameLiteral } from "./literals.js"; import type { Expression, VariableType } from "../types.js"; export type ObjectPatternProperty = { type: "objectPatternProperty"; key: string; value: BindingPattern | Literal | ResultPattern | TypePattern; }; export type ObjectPatternShorthand = { type: "objectPatternShorthand"; name: string; }; export type ObjectPattern = BaseNode & { type: "objectPattern"; properties: (ObjectPatternProperty | ObjectPatternShorthand | RestPattern)[]; }; export type ArrayPattern = BaseNode & { type: "arrayPattern"; elements: (BindingPattern | Literal | WildcardPattern | RestPattern | ResultPattern | TypePattern)[]; }; export type RestPattern = BaseNode & { type: "restPattern"; identifier: string; }; export type WildcardPattern = BaseNode & { type: "wildcardPattern"; }; export type IsExpression = BaseNode & { type: "isExpression"; expression: Expression; pattern: MatchPattern; }; export type ResultPattern = BaseNode & { type: "resultPattern"; kind: "success" | "failure"; binding: string | null; }; export type TypePattern = BaseNode & { type: "typePattern"; pattern: BindingPattern | null; typeHint: VariableType; }; export type TypeTestExpression = BaseNode & { type: "typeTestExpression"; expression: Expression; typeHint: VariableType; }; export type BindingPattern = ObjectPattern | ArrayPattern | RestPattern | WildcardPattern | VariableNameLiteral; export type MatchPattern = BindingPattern | Literal | ResultPattern | TypePattern; export type Pattern = MatchPattern;