Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Align AST for TSEnumDeclaration with TSInterfaceDeclaration, TSModuleDeclaration, etc #1305

Closed
@bradzacher

Description

@bradzacher

For each TSEnumDeclaration, we place its members directly on this AST node.

export interface TSEnumDeclaration extends BaseNode {
  type: AST_NODE_TYPES.TSEnumDeclaration;
  id: Identifier;
  members: TSEnumMember[];
  const?: boolean;
  declare?: boolean;
  modifiers?: Modifier[];
  decorators?: Decorator[];
}

For each TSInterfaceDeclaration, we have a separate TSInterfaceBody node, upon which we place the members.

export interface TSInterfaceDeclaration extends BaseNode {
  type: AST_NODE_TYPES.TSInterfaceDeclaration;
  body: TSInterfaceBody;
  id: Identifier;
  typeParameters?: TSTypeParameterDeclaration;
  extends?: ExpressionWithTypeArguments[];
  implements?: ExpressionWithTypeArguments[];
  decorators?: Decorator[];
  abstract?: boolean;
  declare?: boolean;
}

export interface TSInterfaceBody extends BaseNode {
  type: AST_NODE_TYPES.TSInterfaceBody;
  body: TypeElement[];
}

I'm not sure why there's this inconsistency between the two, but I think we should consider aligning the two.

I'm not sure why TSEnumDeclaration was created without a body, but I think that creating a TSEnumBody node seems like the correct thing to do.
Doing so would align it with not only TSInterfaceDeclaration, but also TSModuleDeclaration, ClassDeclaration and FunctionDeclaration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebreaking changeThis change will require a new major version to be releasedenhancementNew feature or requestlocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: typescript-estreeIssues related to @typescript-eslint/typescript-estree

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions