Skip to content

Ugly formatting of ternary inside a TS as assertion #8840

@bradzacher

Description

@bradzacher

Prettier 2.0.5
Playground link

# Options (if any):
--parser=typescript

Input:

{ { {
const inputExample = (callNode.parent?.type === AST_NODE_TYPES.ChainExpression ? callNode.parent.parent : callNode.parent) as TSESTree.BinaryExpression
} } }

Output:

{
  {
    {
      const inputExample = (callNode.parent?.type ===
      AST_NODE_TYPES.ChainExpression
        ? callNode.parent.parent
        : callNode.parent) as TSESTree.BinaryExpression;
    }
  }
}

Expected behavior:

{
  {
    {      
      const expectedOutput1 = (
        callNode.parent?.type === AST_NODE_TYPES.ChainExpression
          ? callNode.parent.parent
          : callNode.parent
      ) as TSESTree.BinaryExpression;

      const expectedOutput2 = (callNode.parent?.type ===
        AST_NODE_TYPES.ChainExpression
          ? callNode.parent.parent
          : callNode.parent) as TSESTree.BinaryExpression;
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions