timocov / ts-transformer-minify-privates

A TypeScript custom transformer which renames private class members
MIT License
52 stars 5 forks source link

Invalid declarations #23

Open darrachequesne opened 1 year ago

darrachequesne commented 1 year ago

Hi! It seems the private attributes are not updated in the declaration file. Do you know if it's possible?

input.ts:

export class Class {
    public publicField: number = 123;
    private privateField: string = 'string-value';

    public constructor() {
        this.privateMethod(this.privateField);
        this.privateMethod(this.publicField);

        this['privateMethod'](this.privateField);
    }

    private privateMethod(a: string | number): void { }
}

output.js:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Class = void 0;
var Class = /** @class */ (function () {
    function Class() {
        this.publicField = 123;
        this._private_privateField = 'string-value';
        this._private_privateMethod(this._private_privateField);
        this._private_privateMethod(this.publicField);
        this["_private_privateMethod"](this._private_privateField);
    }
    Class.prototype._private_privateMethod = function (a) { };
    return Class;
}());
exports.Class = Class;

input.d.ts:

export declare class Class {
    publicField: number;
    private privateField;
    constructor();
    private privateMethod;
}
timocov commented 1 year ago

Hi there,

Not sure if it is possible (I hope it should?) but at least we should be able to generate source maps for declaration files https://github.com/timocov/ts-transformer-properties-rename/issues/2.

May I ask you why are you using this package over https://github.com/timocov/ts-transformer-properties-rename that can handle more cases than just privates? No pressure, I'm just trying to understand why a reason could be behind :)

darrachequesne commented 1 year ago

May I ask you why are you using this package over https://github.com/timocov/ts-transformer-properties-rename that can handle more cases than just privates?

That's a good question! I will check whether it covers our use case, thanks :+1: