9
In languages with C#, for example, it is possible to use constructor overload as shown below:
public class Teste{
public Teste(bool a, int b, string c){ }
public Teste(bool a, int b){ }
public Teste(bool a){ }
}
After some time searching I managed to carry out the constructor overload in Typescript this way:
export class Telefone {
constructor(a: boolean);
constructor(a: boolean, b: number);
constructor(a: boolean, b: number, c: string);
constructor(public a?: boolean, public b?: number, c?: string){ }
}
Is there another way to accomplish this? This way above does not solve overloads like this:
public Teste(bool a){}
public Teste(int b){}