Skip to content

Commit 12f3116

Browse files
committed
chore: use type instead of interface
1 parent 9f383cd commit 12f3116

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

src/ast.ts

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export type UnicodeSetsCharacterClassElement =
7373
/**
7474
* The type which defines common properties for all node types.
7575
*/
76-
export interface NodeBase {
76+
export type NodeBase = {
7777
/** The node type. */
7878
type: Node["type"]
7979
/** The parent node. */
@@ -89,7 +89,7 @@ export interface NodeBase {
8989
/**
9090
* The root node.
9191
*/
92-
export interface RegExpLiteral extends NodeBase {
92+
export type RegExpLiteral = NodeBase & {
9393
type: "RegExpLiteral"
9494
parent: null
9595
pattern: Pattern
@@ -99,7 +99,7 @@ export interface RegExpLiteral extends NodeBase {
9999
/**
100100
* The pattern.
101101
*/
102-
export interface Pattern extends NodeBase {
102+
export type Pattern = NodeBase & {
103103
type: "Pattern"
104104
parent: RegExpLiteral | null
105105
alternatives: Alternative[]
@@ -109,7 +109,7 @@ export interface Pattern extends NodeBase {
109109
* The alternative.
110110
* E.g. `a|b`
111111
*/
112-
export interface Alternative extends NodeBase {
112+
export type Alternative = NodeBase & {
113113
type: "Alternative"
114114
parent: CapturingGroup | Group | LookaroundAssertion | Pattern
115115
elements: Element[]
@@ -119,7 +119,7 @@ export interface Alternative extends NodeBase {
119119
* The uncapturing group.
120120
* E.g. `(?:ab)`
121121
*/
122-
export interface Group extends NodeBase {
122+
export type Group = NodeBase & {
123123
type: "Group"
124124
parent: Alternative | Quantifier
125125
alternatives: Alternative[]
@@ -129,7 +129,7 @@ export interface Group extends NodeBase {
129129
* The capturing group.
130130
* E.g. `(ab)`, `(?<name>ab)`
131131
*/
132-
export interface CapturingGroup extends NodeBase {
132+
export type CapturingGroup = NodeBase & {
133133
type: "CapturingGroup"
134134
parent: Alternative | Quantifier
135135
name: string | null
@@ -146,7 +146,7 @@ export type LookaroundAssertion = LookaheadAssertion | LookbehindAssertion
146146
* The lookahead assertion.
147147
* E.g. `(?=ab)`, `(?!ab)`
148148
*/
149-
export interface LookaheadAssertion extends NodeBase {
149+
export type LookaheadAssertion = NodeBase & {
150150
type: "Assertion"
151151
parent: Alternative | Quantifier
152152
kind: "lookahead"
@@ -158,7 +158,7 @@ export interface LookaheadAssertion extends NodeBase {
158158
* The lookbehind assertion.
159159
* E.g. `(?<=ab)`, `(?<!ab)`
160160
*/
161-
export interface LookbehindAssertion extends NodeBase {
161+
export type LookbehindAssertion = NodeBase & {
162162
type: "Assertion"
163163
parent: Alternative
164164
kind: "lookbehind"
@@ -170,7 +170,7 @@ export interface LookbehindAssertion extends NodeBase {
170170
* The quantifier.
171171
* E.g. `a?`, `a*`, `a+`, `a{1,2}`, `a??`, `a*?`, `a+?`, `a{1,2}?`
172172
*/
173-
export interface Quantifier extends NodeBase {
173+
export type Quantifier = NodeBase & {
174174
type: "Quantifier"
175175
parent: Alternative
176176
min: number
@@ -186,7 +186,7 @@ export interface Quantifier extends NodeBase {
186186
export type CharacterClass =
187187
| ClassRangesCharacterClass
188188
| UnicodeSetsCharacterClass
189-
interface BaseCharacterClass extends NodeBase {
189+
type BaseCharacterClass = NodeBase & {
190190
type: "CharacterClass"
191191
parent:
192192
| Alternative
@@ -204,7 +204,7 @@ interface BaseCharacterClass extends NodeBase {
204204
*
205205
* In Unicode sets mode (`v` flag), {@link UnicodeSetsCharacterClass} is used.
206206
*/
207-
export interface ClassRangesCharacterClass extends BaseCharacterClass {
207+
export type ClassRangesCharacterClass = BaseCharacterClass & {
208208
parent: Alternative | Quantifier
209209
unicodeSets: false
210210
elements: ClassRangesCharacterClassElement[]
@@ -214,7 +214,7 @@ export interface ClassRangesCharacterClass extends BaseCharacterClass {
214214
*
215215
* This character class may contain strings.
216216
*/
217-
export interface UnicodeSetsCharacterClass extends BaseCharacterClass {
217+
export type UnicodeSetsCharacterClass = BaseCharacterClass & {
218218
parent:
219219
| Alternative
220220
| ExpressionCharacterClass
@@ -228,7 +228,7 @@ export interface UnicodeSetsCharacterClass extends BaseCharacterClass {
228228
* The character class.
229229
* E.g. `[a-b]`
230230
*/
231-
export interface CharacterClassRange extends NodeBase {
231+
export type CharacterClassRange = NodeBase & {
232232
type: "CharacterClassRange"
233233
parent: CharacterClass
234234
min: Character
@@ -249,7 +249,7 @@ export type BoundaryAssertion = EdgeAssertion | WordBoundaryAssertion
249249
* The edge boundary assertion.
250250
* E.g. `^`, `$`
251251
*/
252-
export interface EdgeAssertion extends NodeBase {
252+
export type EdgeAssertion = NodeBase & {
253253
type: "Assertion"
254254
parent: Alternative | Quantifier
255255
kind: "end" | "start"
@@ -259,7 +259,7 @@ export interface EdgeAssertion extends NodeBase {
259259
* The word bondary assertion.
260260
* E.g. `\b`, `\B`
261261
*/
262-
export interface WordBoundaryAssertion extends NodeBase {
262+
export type WordBoundaryAssertion = NodeBase & {
263263
type: "Assertion"
264264
parent: Alternative | Quantifier
265265
kind: "word"
@@ -278,7 +278,7 @@ export type CharacterSet =
278278
* The dot.
279279
* E.g. `.`
280280
*/
281-
export interface AnyCharacterSet extends NodeBase {
281+
export type AnyCharacterSet = NodeBase & {
282282
type: "CharacterSet"
283283
parent: Alternative | Quantifier
284284
kind: "any"
@@ -288,7 +288,7 @@ export interface AnyCharacterSet extends NodeBase {
288288
* The character class escape.
289289
* E.g. `\d`, `\s`, `\w`, `\D`, `\S`, `\W`
290290
*/
291-
export interface EscapeCharacterSet extends NodeBase {
291+
export type EscapeCharacterSet = NodeBase & {
292292
type: "CharacterSet"
293293
parent:
294294
| Alternative
@@ -307,7 +307,7 @@ export interface EscapeCharacterSet extends NodeBase {
307307
export type UnicodePropertyCharacterSet =
308308
| CharacterUnicodePropertyCharacterSet
309309
| StringsUnicodePropertyCharacterSet
310-
interface BaseUnicodePropertyCharacterSet extends NodeBase {
310+
type BaseUnicodePropertyCharacterSet = NodeBase & {
311311
type: "CharacterSet"
312312
parent:
313313
| Alternative
@@ -321,31 +321,31 @@ interface BaseUnicodePropertyCharacterSet extends NodeBase {
321321
value: string | null
322322
negate: boolean
323323
}
324-
export interface CharacterUnicodePropertyCharacterSet
325-
extends BaseUnicodePropertyCharacterSet {
326-
strings: false
327-
value: string | null
328-
negate: boolean
329-
}
324+
export type CharacterUnicodePropertyCharacterSet =
325+
BaseUnicodePropertyCharacterSet & {
326+
strings: false
327+
value: string | null
328+
negate: boolean
329+
}
330330
/** StringsUnicodePropertyCharacterSet is Unicode property escape with property of strings. */
331-
export interface StringsUnicodePropertyCharacterSet
332-
extends BaseUnicodePropertyCharacterSet {
333-
parent:
334-
| Alternative
335-
| ClassIntersection
336-
| ClassSubtraction
337-
| Quantifier
338-
| UnicodeSetsCharacterClass
339-
strings: true
340-
value: null
341-
negate: false
342-
}
331+
export type StringsUnicodePropertyCharacterSet =
332+
BaseUnicodePropertyCharacterSet & {
333+
parent:
334+
| Alternative
335+
| ClassIntersection
336+
| ClassSubtraction
337+
| Quantifier
338+
| UnicodeSetsCharacterClass
339+
strings: true
340+
value: null
341+
negate: false
342+
}
343343

344344
/**
345345
* The expression character class.
346346
* E.g. `[a--b]`, `[a&&b]`,`[^a--b]`, `[^a&&b]`
347347
*/
348-
export interface ExpressionCharacterClass extends NodeBase {
348+
export type ExpressionCharacterClass = NodeBase & {
349349
type: "ExpressionCharacterClass"
350350
parent:
351351
| Alternative
@@ -368,7 +368,7 @@ export type ClassSetOperand =
368368
* The character class intersection.
369369
* E.g. `a&&b`
370370
*/
371-
export interface ClassIntersection extends NodeBase {
371+
export type ClassIntersection = NodeBase & {
372372
type: "ClassIntersection"
373373
parent: ClassIntersection | ExpressionCharacterClass
374374
left: ClassIntersection | ClassSetOperand
@@ -379,7 +379,7 @@ export interface ClassIntersection extends NodeBase {
379379
* The character class subtraction.
380380
* E.g. `a--b`
381381
*/
382-
export interface ClassSubtraction extends NodeBase {
382+
export type ClassSubtraction = NodeBase & {
383383
type: "ClassSubtraction"
384384
parent: ClassSubtraction | ExpressionCharacterClass
385385
left: ClassSetOperand | ClassSubtraction
@@ -390,14 +390,14 @@ export interface ClassSubtraction extends NodeBase {
390390
* The character class string disjunction.
391391
* E.g. `\q{a|b}`
392392
*/
393-
export interface ClassStringDisjunction extends NodeBase {
393+
export type ClassStringDisjunction = NodeBase & {
394394
type: "ClassStringDisjunction"
395395
parent: ClassIntersection | ClassSubtraction | UnicodeSetsCharacterClass
396396
alternatives: StringAlternative[]
397397
}
398398

399399
/** StringAlternative is only used for `\q{alt}`({@link ClassStringDisjunction}). */
400-
export interface StringAlternative extends NodeBase {
400+
export type StringAlternative = NodeBase & {
401401
type: "StringAlternative"
402402
parent: ClassStringDisjunction
403403
elements: Character[]
@@ -408,7 +408,7 @@ export interface StringAlternative extends NodeBase {
408408
* This includes escape sequences which mean a character.
409409
* E.g. `a`, `あ`, `✿`, `\x65`, `\u0065`, `\u{65}`, `\/`
410410
*/
411-
export interface Character extends NodeBase {
411+
export type Character = NodeBase & {
412412
type: "Character"
413413
parent:
414414
| Alternative
@@ -425,7 +425,7 @@ export interface Character extends NodeBase {
425425
* The backreference.
426426
* E.g. `\1`, `\k<name>`
427427
*/
428-
export interface Backreference extends NodeBase {
428+
export type Backreference = NodeBase & {
429429
type: "Backreference"
430430
parent: Alternative | Quantifier
431431
ref: number | string
@@ -435,7 +435,7 @@ export interface Backreference extends NodeBase {
435435
/**
436436
* The flags.
437437
*/
438-
export interface Flags extends NodeBase {
438+
export type Flags = NodeBase & {
439439
type: "Flags"
440440
parent: RegExpLiteral | null
441441
dotAll: boolean

0 commit comments

Comments
 (0)