-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
(Apologies if this is known, but I search a bunch of places and didn't find anything.)
Is there a good way to deal with a constructor of a derived class that is getting an options kind of value that needs to be merged with a defaults value? I started with something like this:
export class Foo extends Bar {
...
private options: any = {};
...
constructor(x: Something, y: SomethingElse, options: any = {}) {
this.options = $.extend({}, defaults, options);
super(this.options.blah);
...
}
}
This failed and I eventually resorted to:
constructor(x: Something, y: SomethingElse, options: any = {}) {
super(options.blah || defaults.blah);
this.options = $.extend({}, defaults, options);
...
}
which is duplicating functionality (and sloppy).
Hopefully I'm not the only one who ran into this problem and there's good way to do that?
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code