Skip to content

inconsistent formatting of nested arrow functions, when one of the function headers spans multiple lines #756

@adrian-gierakowski

Description

@adrian-gierakowski

Describe the bug

dprint-plugin-typescript version: x.x.x

config:

{ "lineWidth": 80, "memberExpression.linePerExpression": true, "semiColons": "asi", "indentWidth": 2 }

Input Code

const func =  
  () =>
  (arg1: {
    a: number; 
    b: number;
  }) =>
  (arg2: { c: number }) =>
  (arg3: undefined): undefined => arg3

Expected Output

const func =  
  () =>
  (arg1: {
    a: number; 
    b: number;
  }) =>
  (arg2: { c: number }) =>
  (arg3: undefined): undefined => arg3

Actual Output

const func = () =>
  (arg1: {
    a: number
    b: number
  }) =>
  (arg2: { c: number }) =>
  (arg3: undefined): undefined => arg3

Notice the first arrow head not starting on it's own line.

If the second arrow header is put on a single line, the following is formatted correctly (unchanged):

const func =
  () =>
  (arg1: { a: number; b: number }) =>
  (arg2: { c: number }) =>
  (arg3: undefined): undefined => arg3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions