Skip to content

Commit

Permalink
feat: align class property representation with ESTree
Browse files Browse the repository at this point in the history
Half of #3430
Closes #3077
  • Loading branch information
bradzacher committed Aug 28, 2021
1 parent ea6a97c commit 143d4fa
Show file tree
Hide file tree
Showing 81 changed files with 744 additions and 356 deletions.
4 changes: 2 additions & 2 deletions packages/ast-spec/src/ast-node-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export enum AST_NODE_TYPES {
ClassBody = 'ClassBody',
ClassDeclaration = 'ClassDeclaration',
ClassExpression = 'ClassExpression',
ClassProperty = 'ClassProperty',
ConditionalExpression = 'ConditionalExpression',
ContinueStatement = 'ContinueStatement',
DebuggerStatement = 'DebuggerStatement',
Expand Down Expand Up @@ -64,6 +63,7 @@ export enum AST_NODE_TYPES {
ObjectPattern = 'ObjectPattern',
Program = 'Program',
Property = 'Property',
PropertyDefinition = 'PropertyDefinition',
RestElement = 'RestElement',
ReturnStatement = 'ReturnStatement',
SequenceExpression = 'SequenceExpression',
Expand All @@ -88,9 +88,9 @@ export enum AST_NODE_TYPES {
/**
* TS-prefixed nodes
*/
TSAbstractClassProperty = 'TSAbstractClassProperty',
TSAbstractKeyword = 'TSAbstractKeyword',
TSAbstractMethodDefinition = 'TSAbstractMethodDefinition',
TSAbstractPropertyDefinition = 'TSAbstractPropertyDefinition',
TSAnyKeyword = 'TSAnyKeyword',
TSArrayType = 'TSArrayType',
TSAsExpression = 'TSAsExpression',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
import type { Accessibility } from './Accessibility';
import type { BaseNode } from './BaseNode';

interface ClassPropertyBase extends BaseNode {
interface PropertyDefinitionBase extends BaseNode {
key: PropertyName;
value: Expression | null;
computed: boolean;
Expand All @@ -24,12 +24,14 @@ interface ClassPropertyBase extends BaseNode {
override?: boolean;
}

export interface ClassPropertyComputedNameBase extends ClassPropertyBase {
export interface PropertyDefinitionComputedNameBase
extends PropertyDefinitionBase {
key: PropertyNameComputed;
computed: true;
}

export interface ClassPropertyNonComputedNameBase extends ClassPropertyBase {
export interface PropertyDefinitionNonComputedNameBase
extends PropertyDefinitionBase {
key: PropertyNameNonComputed;
computed: false;
}
19 changes: 0 additions & 19 deletions packages/ast-spec/src/element/ClassProperty/spec.ts

This file was deleted.

19 changes: 19 additions & 0 deletions packages/ast-spec/src/element/PropertyDefinition/spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { AST_NODE_TYPES } from '../../ast-node-types';
import type {
PropertyDefinitionComputedNameBase,
PropertyDefinitionNonComputedNameBase,
} from '../../base/PropertyDefinitionBase';

export interface PropertyDefinitionComputedName
extends PropertyDefinitionComputedNameBase {
type: AST_NODE_TYPES.PropertyDefinition;
}

export interface PropertyDefinitionNonComputedName
extends PropertyDefinitionNonComputedNameBase {
type: AST_NODE_TYPES.PropertyDefinition;
}

export type PropertyDefinition =
| PropertyDefinitionComputedName
| PropertyDefinitionNonComputedName;
19 changes: 0 additions & 19 deletions packages/ast-spec/src/element/TSAbstractClassProperty/spec.ts

This file was deleted.

19 changes: 19 additions & 0 deletions packages/ast-spec/src/element/TSAbstractPropertyDefinition/spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { AST_NODE_TYPES } from '../../ast-node-types';
import type {
PropertyDefinitionComputedNameBase,
PropertyDefinitionNonComputedNameBase,
} from '../../base/PropertyDefinitionBase';

export interface TSAbstractPropertyDefinitionComputedName
extends PropertyDefinitionComputedNameBase {
type: AST_NODE_TYPES.TSAbstractPropertyDefinition;
}

export interface TSAbstractPropertyDefinitionNonComputedName
extends PropertyDefinitionNonComputedNameBase {
type: AST_NODE_TYPES.TSAbstractPropertyDefinition;
}

export type TSAbstractPropertyDefinition =
| TSAbstractPropertyDefinitionComputedName
| TSAbstractPropertyDefinitionNonComputedName;
4 changes: 2 additions & 2 deletions packages/ast-spec/src/element/spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export * from './ClassProperty/spec';
export * from './PropertyDefinition/spec';
export * from './MethodDefinition/spec';
export * from './Property/spec';
export * from './SpreadElement/spec';
export * from './StaticBlock/spec';
export * from './TSAbstractClassProperty/spec';
export * from './TSAbstractPropertyDefinition/spec';
export * from './TSAbstractMethodDefinition/spec';
export * from './TSCallSignatureDeclaration/spec';
export * from './TSConstructSignatureDeclaration/spec';
Expand Down
8 changes: 4 additions & 4 deletions packages/ast-spec/src/unions/ClassElement.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { ClassProperty } from '../element/ClassProperty/spec';
import type { PropertyDefinition } from '../element/PropertyDefinition/spec';
import type { MethodDefinition } from '../element/MethodDefinition/spec';
import type { StaticBlock } from '../element/StaticBlock/spec';
import type { TSAbstractClassProperty } from '../element/TSAbstractClassProperty/spec';
import type { TSAbstractPropertyDefinition } from '../element/TSAbstractPropertyDefinition/spec';
import type { TSAbstractMethodDefinition } from '../element/TSAbstractMethodDefinition/spec';
import type { TSIndexSignature } from '../element/TSIndexSignature/spec';

export type ClassElement =
| ClassProperty
| PropertyDefinition
| MethodDefinition
| StaticBlock
| TSAbstractClassProperty
| TSAbstractPropertyDefinition
| TSAbstractMethodDefinition
| TSIndexSignature;

0 comments on commit 143d4fa

Please sign in to comment.