镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Incorrect formatting in fluent API call  #14675

Description

TypeScript Version: 2.2.1

Code

Format the following code snippet using VS Code or typescript-formatter:

someVar
  .chain(
    'arg1',
    'arg2',
  )
  .chain(
    3,
    4,
  );

Expected behavior:

someVar
  .chain(
    'arg1',
    'arg2',
  )
  .chain(
    3,
    4,
  );

Actual behavior:

someVar
  .chain(
  'arg1',
  'arg2',
)
  .chain(
  3,
  4,
);

This is a common occurrence with fluent APIs (test frameworks, ORMs, etc) and tslint rules requiring trailing comma.

Activity

  1. magnushiie commented on Mar 15, 2017

    @magnushiie
    ContributorAuthor

    Note also that even without the trailing comma, the formatting is not correct:

    someVar
      .chain(
      'arg1',
      'arg2'
      )
      .chain(
      3,
      4
      );
  2. added a commit that references this issue on Mar 29, 2017
    4ce4e47
  3. saschanaz commented on Apr 11, 2017

    @saschanaz
    Contributor

    Duplicate of #5830

  4. magnushiie commented on Aug 13, 2017

    @magnushiie
    ContributorAuthor

    Indeed it's a duplicate of #5830, although the trailing comma here causes different formatting currently, so the fix should work with both with and without trailing comma - I will make a note on the other issue about this.

  5. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: FormatterThe issue relates to the built-in formatter

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions