Is it possible to have optional constructor arguments with default value, like this
export class Test {
constructor(private foo?: string="foo", private bar?: string="bar") {}
}
This gives me the following error:
Parameter cannot have question mark and initializer.
I would like to create instances like
x = new Test(); // x.foo === 'foo'
x = new Test('foo1'); // x.foo === 'foo1'
x = new Test('foo1', 'bar1');
What is the correct typescript way to achieve this?