A class constructor can automatically create and initialize class properties by using parameter property declarations .
public class Foo
{
constructor(public bar: string, private baz: number, protected qux: boolean) {}
}
That is the equivalent of this:
public class Foo
{
public bar: string;
private baz: number;
protected qux: boolean;
constructor(bar: string, baz: number, qux: boolean) {
this.bar = bar;
this.baz = baz;
this.qux = qux;
}
}