diff --git a/src/nodes/__tests__/property-shorthand.spec-d.ts b/src/nodes/__tests__/property-shorthand.spec-d.ts index 1e60c78..5410e3f 100644 --- a/src/nodes/__tests__/property-shorthand.spec-d.ts +++ b/src/nodes/__tests__/property-shorthand.spec-d.ts @@ -17,10 +17,6 @@ describe('unit-d:nodes/ShorthandProperty', () => { expectTypeOf().toHaveProperty('assignment').toEqualTypeOf() }) - it('should match [computed: false]', () => { - expectTypeOf().toHaveProperty('computed').toEqualTypeOf() - }) - it('should match [kind: Extract]', () => { expectTypeOf() .toHaveProperty('kind') diff --git a/src/nodes/definition-method.ts b/src/nodes/definition-method.ts index 5bbfb3b..acb1576 100644 --- a/src/nodes/definition-method.ts +++ b/src/nodes/definition-method.ts @@ -11,7 +11,8 @@ import type { FunctionExpression, MethodKind, ModifierList, - Parent + Parent, + PropertyName } from '@flex-development/esast' /** @@ -38,6 +39,7 @@ interface MethodDefinition extends Parent { * @see {@linkcode Expression} * @see {@linkcode FunctionExpression} * @see {@linkcode ModifierList} + * @see {@linkcode PropertyName} */ children: | [ @@ -53,7 +55,7 @@ interface MethodDefinition extends Parent { ...comments: InternalComments, value: FunctionExpression ] - | [name: Expression, ...comments: Comments, value: FunctionExpression] + | [name: PropertyName, ...comments: Comments, value: FunctionExpression] /** * Boolean indicating if method name is computed. @@ -85,4 +87,4 @@ interface MethodDefinition extends Parent { type: 'methodDefinition' } -export type { MethodDefinitionData, MethodDefinition as default } +export type { MethodDefinition as default, MethodDefinitionData } diff --git a/src/nodes/expression-object.ts b/src/nodes/expression-object.ts index 56d9679..34b3d2d 100644 --- a/src/nodes/expression-object.ts +++ b/src/nodes/expression-object.ts @@ -6,10 +6,8 @@ import type { Comment, Data, - MethodProperty, Parent, - ShorthandProperty, - SimpleProperty, + Property, SpreadElement } from '@flex-development/esast' @@ -34,18 +32,10 @@ interface ObjectExpression extends Parent { * List of children. * * @see {@linkcode Comment} - * @see {@linkcode MethodProperty} - * @see {@linkcode ShorthandProperty} - * @see {@linkcode SimpleProperty} + * @see {@linkcode Property} * @see {@linkcode SpreadElement} */ - children: ( - | Comment - | MethodProperty - | ShorthandProperty - | SimpleProperty - | SpreadElement - )[] + children: (Comment | Property | SpreadElement)[] /** * Info from the ecosystem. @@ -60,4 +50,4 @@ interface ObjectExpression extends Parent { type: 'objectExpression' } -export type { ObjectExpressionData, ObjectExpression as default } +export type { ObjectExpression as default, ObjectExpressionData } diff --git a/src/nodes/pattern-object.ts b/src/nodes/pattern-object.ts index b2a6e1d..13e549e 100644 --- a/src/nodes/pattern-object.ts +++ b/src/nodes/pattern-object.ts @@ -4,13 +4,11 @@ */ import type { - AssignmentProperty, Comment, Data, Parent, - RenamedProperty, - RestElement, - ShorthandProperty + Property, + RestElement } from '@flex-development/esast' /** @@ -33,19 +31,11 @@ interface ObjectPattern extends Parent { /** * List of children. * - * @see {@linkcode AssignmentProperty} * @see {@linkcode Comment} - * @see {@linkcode RenamedProperty} + * @see {@linkcode Property} * @see {@linkcode RestElement} - * @see {@linkcode ShorthandProperty} */ - children: ( - | AssignmentProperty - | Comment - | RenamedProperty - | RestElement - | ShorthandProperty - )[] + children: (Comment | Property | RestElement)[] /** * Info from the ecosystem. @@ -60,4 +50,4 @@ interface ObjectPattern extends Parent { type: 'objectPattern' } -export type { ObjectPatternData, ObjectPattern as default } +export type { ObjectPattern as default, ObjectPatternData } diff --git a/src/nodes/property-method.ts b/src/nodes/property-method.ts index 70d9cbd..557b9d5 100644 --- a/src/nodes/property-method.ts +++ b/src/nodes/property-method.ts @@ -3,15 +3,7 @@ * @module esast/nodes/MethodProperty */ -import type { InternalComments } from '#internal' -import type { - Comments, - Expression, - FunctionExpression, - ModifierList, - Property, - PropertyName -} from '@flex-development/esast' +import type { MethodDefinition, Property } from '@flex-development/esast' /** * A method property. @@ -29,27 +21,9 @@ interface MethodProperty extends Property { /** * List of children. * - * @see {@linkcode Comments} - * @see {@linkcode Expression} - * @see {@linkcode FunctionExpression} - * @see {@linkcode PropertyName} - * @see {@linkcode ModifierList} + * @see {@linkcode MethodDefinition} */ - children: - | [ - ...comments: Comments, - key: Expression, - ...comments: InternalComments, - value: FunctionExpression - ] - | [ - modifiers: ModifierList, - ...comments: Comments, - key: Expression, - ...comments: InternalComments, - value: FunctionExpression - ] - | [key: PropertyName, ...comments: Comments, value: FunctionExpression] + children: [MethodDefinition] /** * Boolean indicating if property value is a method. diff --git a/src/nodes/property-shorthand.ts b/src/nodes/property-shorthand.ts index 303529b..ecb9416 100644 --- a/src/nodes/property-shorthand.ts +++ b/src/nodes/property-shorthand.ts @@ -4,9 +4,9 @@ */ import type { - Identifier, Property, - PropertyKind + PropertyKind, + PropertyName } from '@flex-development/esast' /** @@ -25,14 +25,9 @@ interface ShorthandProperty extends Property { /** * List of children. * - * @see {@linkcode Identifier} + * @see {@linkcode PropertyName} */ - children: [key: Identifier] - - /** - * Boolean indicating if property is computed. - */ - computed: false + children: [key: PropertyName] /** * Property kind. diff --git a/src/nodes/property-simple.ts b/src/nodes/property-simple.ts index 9769be2..80700dd 100644 --- a/src/nodes/property-simple.ts +++ b/src/nodes/property-simple.ts @@ -7,7 +7,6 @@ import type { InternalComments } from '#internal' import type { Comments, Expression, - FunctionExpression, Property, PropertyKind, PropertyName @@ -38,13 +37,9 @@ interface SimpleProperty extends Property { ...comments: Comments, key: Expression, ...comments: InternalComments, - value: Exclude - ] - | [ - key: PropertyName, - ...comments: Comments, - value: Exclude + value: Expression ] + | [key: PropertyName, ...comments: Comments, value: Expression] /** * Property kind. diff --git a/src/nodes/property.ts b/src/nodes/property.ts index 7d0a2fc..800ad37 100644 --- a/src/nodes/property.ts +++ b/src/nodes/property.ts @@ -10,12 +10,11 @@ import type { Comments, Data, Expression, - FunctionExpression, - Identifier, - ModifierList, + MethodDefinition, ObjectPattern, Parent, - PropertyKind + PropertyKind, + PropertyName } from '@flex-development/esast' /** @@ -47,10 +46,9 @@ interface Property extends Parent { * @see {@linkcode AssignmentPattern} * @see {@linkcode Comments} * @see {@linkcode Expression} - * @see {@linkcode FunctionExpression} - * @see {@linkcode Identifier} - * @see {@linkcode ModifierList} + * @see {@linkcode MethodDefinition} * @see {@linkcode ObjectPattern} + * @see {@linkcode PropertyName} */ children: | [ @@ -60,19 +58,13 @@ interface Property extends Parent { value: ArrayPattern | AssignmentPattern | Expression | ObjectPattern ] | [ - key: Expression, + key: PropertyName, ...comments: Comments, value: ArrayPattern | AssignmentPattern | Expression | ObjectPattern ] - | [ - modifiers: ModifierList, - ...comments: Comments, - key: Expression, - ...comments: InternalComments, - value: FunctionExpression - ] | [assignment: AssignmentPattern] - | [key: Identifier] + | [method: MethodDefinition] + | [shorthand: PropertyName] /** * Boolean indicating if property is computed. @@ -109,4 +101,4 @@ interface Property extends Parent { type: 'property' } -export type { PropertyData, Property as default } +export type { Property as default, PropertyData }