Skip to content

suboptimal formatting with nested async function calls and type assertions #10340

@dcermak

Description

@dcermak

Prettier 2.2.1
Playground link

--parser typescript

Input:

const getAccountCount = async () =>
  (await 
    ((await (
      await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME)
    ).findItem("My bookmarks")) as TreeItem
  ).getChildren()
  ).length

Output:

const getAccountCount = async () =>
  (
    await ((await (
      await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME)
    ).findItem("My bookmarks")) as TreeItem).getChildren()
  ).length;

Expected behavior:

I would expect something more akin to the input, albeit I don't really like that one either. However, I find the output of prettier a bit worse, because it puts two awaits on a single line and that makes it harder to read imho.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:javascriptIssues affecting JSlang: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