diff --git a/src/ast.ts b/src/ast.ts index 361a4fc..45ed514 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -73,7 +73,7 @@ export type UnicodeSetsCharacterClassElement = /** * The type which defines common properties for all node types. */ -export interface NodeBase { +export type NodeBase = { /** The node type. */ type: Node["type"] /** The parent node. */ @@ -89,7 +89,7 @@ export interface NodeBase { /** * The root node. */ -export interface RegExpLiteral extends NodeBase { +export type RegExpLiteral = NodeBase & { type: "RegExpLiteral" parent: null pattern: Pattern @@ -99,7 +99,7 @@ export interface RegExpLiteral extends NodeBase { /** * The pattern. */ -export interface Pattern extends NodeBase { +export type Pattern = NodeBase & { type: "Pattern" parent: RegExpLiteral | null alternatives: Alternative[] @@ -109,7 +109,7 @@ export interface Pattern extends NodeBase { * The alternative. * E.g. `a|b` */ -export interface Alternative extends NodeBase { +export type Alternative = NodeBase & { type: "Alternative" parent: CapturingGroup | Group | LookaroundAssertion | Pattern elements: Element[] @@ -119,7 +119,7 @@ export interface Alternative extends NodeBase { * The uncapturing group. * E.g. `(?:ab)` */ -export interface Group extends NodeBase { +export type Group = NodeBase & { type: "Group" parent: Alternative | Quantifier alternatives: Alternative[] @@ -129,7 +129,7 @@ export interface Group extends NodeBase { * The capturing group. * E.g. `(ab)`, `(?ab)` */ -export interface CapturingGroup extends NodeBase { +export type CapturingGroup = NodeBase & { type: "CapturingGroup" parent: Alternative | Quantifier name: string | null @@ -146,7 +146,7 @@ export type LookaroundAssertion = LookaheadAssertion | LookbehindAssertion * The lookahead assertion. * E.g. `(?=ab)`, `(?!ab)` */ -export interface LookaheadAssertion extends NodeBase { +export type LookaheadAssertion = NodeBase & { type: "Assertion" parent: Alternative | Quantifier kind: "lookahead" @@ -158,7 +158,7 @@ export interface LookaheadAssertion extends NodeBase { * The lookbehind assertion. * E.g. `(?<=ab)`, `(?` */ -export interface Backreference extends NodeBase { +export type Backreference = NodeBase & { type: "Backreference" parent: Alternative | Quantifier ref: number | string @@ -435,7 +435,7 @@ export interface Backreference extends NodeBase { /** * The flags. */ -export interface Flags extends NodeBase { +export type Flags = NodeBase & { type: "Flags" parent: RegExpLiteral | null dotAll: boolean