Skip to content

Regression cased by switching printInterface to printClass #18216

@fisker

Description

@fisker

Prettier pr-18091
Playground link

--parser typescript

Input:

export interface TSAbstractMethodDefinitionNonComputedName
  // this does not extend ClassMethodDefinitionNonComputedNameBase because abstract private names are not allowed
  extends MethodDefinitionNonComputedNameBase {
  type: AST_NODE_TYPES.TSAbstractMethodDefinition;
}

Output:

export interface TSAbstractMethodDefinitionNonComputedName
// this does not extend ClassMethodDefinitionNonComputedNameBase because abstract private names are not allowed
  extends MethodDefinitionNonComputedNameBase {
  type: AST_NODE_TYPES.TSAbstractMethodDefinition;
}

Expected output:

export interface TSAbstractMethodDefinitionNonComputedName
  // this does not extend ClassMethodDefinitionNonComputedNameBase because abstract private names are not allowed
  extends MethodDefinitionNonComputedNameBase {
  type: AST_NODE_TYPES.TSAbstractMethodDefinition;
}

Why?

The previous version does look nice.

This is a real-world case https://github.com/typescript-eslint/typescript-eslint/blob/bb451a1d342f169bc9b697ad97db5dfe2eb288c3/packages/ast-spec/src/element/TSAbstractMethodDefinition/spec.ts#L12C1-L16C2

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions