Skip to content

Commit c2949e2

Browse files
authored
Reuse existing initializer field in EnumValueDeclaration (#1220)
1 parent e785a23 commit c2949e2

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

Diff for: src/ast.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ export abstract class Node {
685685

686686
static createEnumValueDeclaration(
687687
name: IdentifierExpression,
688-
value: Expression | null,
688+
initializer: Expression | null,
689689
flags: CommonFlags,
690690
range: Range
691691
): EnumValueDeclaration {
@@ -694,7 +694,7 @@ export abstract class Node {
694694
node.range = range;
695695
node.flags = flags;
696696
node.name = name;
697-
node.value = value;
697+
node.initializer = initializer;
698698
return node;
699699
}
700700

@@ -1848,8 +1848,6 @@ export class EnumDeclaration extends DeclarationStatement {
18481848

18491849
/** Represents a value of an `enum` declaration. */
18501850
export class EnumValueDeclaration extends VariableLikeDeclarationStatement {
1851-
/** Value expression. */
1852-
value: Expression | null;
18531851
}
18541852

18551853
/** Represents an `export import` statement of an interface. */

Diff for: src/extra/ast.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1000,9 +1000,9 @@ export class ASTBuilder {
10001000

10011001
visitEnumValueDeclaration(node: EnumValueDeclaration): void {
10021002
this.visitIdentifierExpression(node.name);
1003-
if (node.value) {
1003+
if (node.initializer) {
10041004
this.sb.push(" = ");
1005-
this.visitNode(node.value);
1005+
this.visitNode(node.initializer);
10061006
}
10071007
}
10081008

Diff for: src/program.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2789,7 +2789,7 @@ export class EnumValue extends VariableLikeElement {
27892789

27902790
/** Gets the associated value node. */
27912791
get valueNode(): Expression | null {
2792-
return (<EnumValueDeclaration>this.declaration).value;
2792+
return (<EnumValueDeclaration>this.declaration).initializer;
27932793
}
27942794

27952795
/* @override */

0 commit comments

Comments
 (0)