Skip to content

Inline comments within parameters moved before previous comma #650

@jakebailey

Description

@jakebailey

Describe the bug

dprint-plugin-typescript version: 0.91.3

Input Code

function foo(arg: number, /** @deferred */ cb: () => void): void {}

interface Foo {
  method<T>(
    arg: { new(...args: any[]): T }, // This is a comment
    arg2: (instance: T) => HTMLElement | undefined,
  ): Disposable;

  method2<T>(
    arg: { new(...args: any[]): T },
    arg2: (instance: T) => HTMLElement | undefined, // This is a comment
  ): Disposable;
}

Expected Output

function foo(arg: number, /** @deferred */ cb: () => void): void {}

interface Foo {
  method<T>(
    arg: { new(...args: any[]): T }, // This is a comment
    arg2: (instance: T) => HTMLElement | undefined,
  ): Disposable;

  method2<T>(
    arg: { new(...args: any[]): T },
    arg2: (instance: T) => HTMLElement | undefined, // This is a comment
  ): Disposable;
}

Actual Output

function foo(arg: number /** @deferred */, cb: () => void): void {}

interface Foo {
  method<T>(
    arg: { new(...args: any[]): T } // This is a comment
    ,
    arg2: (instance: T) => HTMLElement | undefined,
  ): Disposable;

  method2<T>(
    arg: { new(...args: any[]): T },
    arg2: (instance: T) => HTMLElement | undefined // This is a comment
    ,
  ): Disposable;
}

Noticed this when updating DT; 30 some files had instances of this.

This is particularly scary because microsoft/TypeScript#58729 introduces a parameter JSDoc comment that shouldn't be moved around.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions