tslint-lines-between-class-members icon indicating copy to clipboard operation
tslint-lines-between-class-members copied to clipboard

Bug: Expects blank line at overloading

Open Xenya0815 opened this issue 6 years ago • 3 comments

Used versions

Code

class X {
  foo(x: number, y: string): string;
  foo( y: string): number;
  foo(...args: any): string | number {
    return 42;
  }
}

Expected behavior No error

Actual behavior It wants to have a blank line between the function declarations.

fix changes it to

class X {
  foo(x: number, y: string): string;
  
  foo( y: string): number;
  
  foo(...args: any): string | number {
    return 42;
  }
}

Xenya0815 avatar Feb 01 '19 15:02 Xenya0815

Hi @Xenya0815 , sorry for the late reply... If this is still an issue for you, can I ask if you have configured the rule to have 0 lines?

chinchiheather avatar Jun 16 '19 01:06 chinchiheather

hi @chinchiheather yes it is still a blocker why we can't use that rule :-(

I configured it to 1 line. I want to have 1 line between different members but between the different declarations of an overloaded method I want to have 0 lines. I think my example from the topic is easier to understand if I add an additional class member:

expected behavior with configuration "lines-between-class-members": [true, 1]

class X {
  bar() {
    return 'hello world';
  }

  foo(x: number, y: string): string;
  foo( y: string): number;
  foo(...args: any): string | number {
    return 42;
  }
}

Xenya0815 avatar Jun 17 '19 06:06 Xenya0815

Hmm okay, yeah I understand what you are after now.

I think this might be a bit too niche for me to implement right now, but I will be open to accepting pull requests if anyone else wants to work on it.

chinchiheather avatar Jun 23 '19 02:06 chinchiheather