Comments (7)
@artfiedler can you please check what exactly is used in exports from testProperties
class in your case? I see that the tool doesn't rename salad
in Object.defineProperty(testProperties.prototype, "salad", {
, but other issues it seems that come from you export something like that from your entry point: export const foo = testPropertiesInstance.salad + 1
, is it right? It'd be awesome if you'll adopt your code to avoid your specifics.
I'll try to fix the issue with defining property and with detecting whether a property is exported property (currently the tool cover cases like I mentioned above incorrectly), but I'm not sure whether it'll fix your cases.
So, right now I see the following issue:
input.ts
class TestProperties {
private _salad: number = 0;
public dressing: number = 0;
public get salad(): number { return this._salad; }
public set salad(val: number) { this._salad = val; }
}
const test1 = new TestProperties();
test1.salad = 0;
test1.dressing = 0;
export const totalSalad = test1.salad + 1; // the problem is here
export const totalDressing = test1.dressing + 0; // and here - the tool treats accessing to test1.dressing here as dressing in "public"
output.js
Object.defineProperty(exports, "__esModule", { value: true });
var TestProperties = /** @class */ (function () {
function TestProperties() {
this._private__salad = 0;
- this.dressing = 0;
+ this._internal_dressing = 0;
}
- Object.defineProperty(TestProperties.prototype, "salad", {
+ Object.defineProperty(TestProperties.prototype, "_internal_salad", {
get: function () { return this._private__salad; },
set: function (val) { this._private__salad = val; },
enumerable: true,
configurable: true
});
return TestProperties;
}());
var test1 = new TestProperties();
-test1.salad = 0;
-test1.dressing = 0;
-exports.totalSalad = test1.salad + 1;
-exports.totalDressing = test1.dressing + 0;
+test1._internal_salad = 0;
+test1._internal_dressing = 0;
+exports.totalSalad = test1._internal_salad + 1;
+exports.totalDressing = test1._internal_dressing + 0;
from ts-transformer-properties-rename.
Honestly, in my case, I just created a dummy testProperties.ts inside my existing larger project, with that typescript code mentioned above, my project has no references to it or includes etc in my project to that class. I'm new to your transform and I'm testing potential problems I might run into and seeing what is renaming and not renaming etc.
In general I hate adopting specific coding patterns to work around a potential issue because I'll have existing code already that I dont remember it all, and then a year from now maybe I wont remember why I coded it that way LOL. I try to keep everything pretty plain.
from ts-transformer-properties-rename.
I'll publish the new version with fixes for this soon, so you can test it and say whether it fixes your case or not.
from ts-transformer-properties-rename.
@artfiedler just published v0.4.0. Can you please install and check it?
from ts-transformer-properties-rename.
from ts-transformer-properties-rename.
Reading over both outputs from transpile and terser mangle it looks like it works perfect. Also you may want to get the link on ttypescript project updated to properties-rename transform, I saw your old repo for the minifier listed there and decided to check what other repo's you had and found this one :)
from ts-transformer-properties-rename.
I already created PR for that cevek/ttypescript#97, but it isn't merged yet :)
from ts-transformer-properties-rename.
Related Issues (20)
- Add errors/warning where we're sure that an error could be HOT 7
- Enums are not renamed causing runtime error
- Constructor parameters in internal classes get prefixed. HOT 2
- Add loose mode
- Mapped types do not respect @public jsdoc HOT 4
- Incorrect handling mapped types
- [feature] Lazily resolve TS Program HOT 9
- Handle object literals with "erased" type HOT 1
- Error: Cannot find source file HOT 5
- Wrong code for indexed generic in returned type
- Incorrect handling unknown/any casting
- Return type of public function is marked as internal HOT 1
- An object with quoted keys is not minified
- Properly handle class members with decorators HOT 2
- Fields declared with `declare` keyword are renamed but shouldn't
- Improvde DX and migration from `ts-transformer-minify-privates`
- Incorrect handing `in` operator with string literal
- Handle Internal Class renames HOT 7
- Computed or Invalid property names HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ts-transformer-properties-rename.