Skip to content

ts/fast-strip: ECMAScript private method overloads are not stripped #10884

@davecardwell

Description

@davecardwell

Describe the bug

The overloads for private ECMAScript methods are not stripped, causing a syntax error when trying to run the resulting JavaScript.

Input code

class Private {
  #foo(bar: string): string;
  #foo(bar: number): number;
  #foo(bar: string | number): string | number;
  #foo(bar: string | number): string | number {
    return bar;
  }
}

Config

Link to the code that reproduces this issue

https://play.swc.rs/?version=1.12.14&code=H4sIAAAAAAAAA0vOSSwuVggoTcrJTFao5lJQSMvP10hKLLJSKC4pysxL14QxrJHl8kpzk1KLNGEMa0x9CjUIRWgipKkGO0pBoSi1pLQoTwGoB6S9lquWiysZ4vSizLLEklSwMmV8jlfG53p0nQScT4JyXO4HAKJCLZZ5AQAA&config=H4sIAAAAAAAAA1WOvQ6DMAyE9zwF8sxQMXbryGNE4FahJI5sI4EQ745DS382%2Bz7f%2BVZXVTBIB9dqtdEWnDNyiJjUjx%2FV9CdibmMm1psIsgZKYlx5wuNkq1%2F%2B7Nnwr1MWy5pNAV0ySschK9QnVSno7kf5z1HPD9TiQmkuTQPuzSBSP434bRyOVm1SZMrFkKhHOGPsZdE6ipHSIEeM29wOxse8CvkAAAA%3D&strip-types=

SWC Info output

No response

Expected behavior

class Private {
                           
                           
                                             
  #foo(bar                 )                  {
    return bar;
  }
}

Actual behavior

class Private {
  #foo(bar        )        ;
  #foo(bar        )        ;
  #foo(bar                 )                 ;
  #foo(bar                 )                  {
    return bar;
  }
}

Version

1.12.14

Additional context

First reported in nodejs/node#59102.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions