timocov / ts-transformer-properties-rename

TypeScript custom transformer to rename properties
MIT License
70 stars 3 forks source link

Constructor parameters in internal classes get prefixed. #13

Closed zbynek closed 4 years ago

zbynek commented 4 years ago

Bug report

Input code

class Measure {
    height: number;

    constructor(public width: number, public ascent: number, public descent: number) {
        this.height = ascent + descent;
    }
}

export class Foo {}

Expected output

class Measure {
      constructor(width, ascent, descent) {
              this._internal_width = width;
              this._internal_ascent = ascent;
              this._internal_descent = descent;
              this._internal_height = ascent + descent;
       }
}

export class Foo {
}

Actual output

class Measure {
      constructor(_internal_width, _internal_ascent, _internal_descent) {
              this._internal_width = _internal_width;
              this._internal_ascent = _internal_ascent;
              this._internal_descent = _internal_descent;
              this._internal_height = ascent + descent;
       }
}

export class Foo {
}

Additional context Reproducible if the code above is added as input.ts to the test directory in this repo and npm run test is started.

timocov commented 4 years ago

I confirm it's a bug.

timocov commented 4 years ago

The fix is just published in 0.7.0 version.