angular / ts-minify

A tool to aid minification of Typescript code, using Typescript's type information.
Apache License 2.0
121 stars 7 forks source link

Rename parameters declared in constructor inside constructor body if used in the body #39

Open dariajung opened 9 years ago

dariajung commented 9 years ago

Example illustrating this example:

class Foo {
  constructor(public bar: string) { // bar is correctly renamed
    this.bar = bar; // bar is correctly renamed
    console.log(bar); // bar will not be renamed, we would have to rename bar here as well
  }
}
dariajung commented 9 years ago

Another example:

Parameter properties need to be desguared, or handled otherwise:

class Animal {
    constructor(private name: string) { 
        console.log(name);
    }
}

is sugar for

class Animal {
    private name: string;
    constructor(name: string) { 
        this.name = name;
    }
}

name is a property that, if renamed in the parameter property declaration, also needs to be renamed in the constructor body if used.