Is it possible to conditionally load the super class based on a parameter in TypeScript? I am facing an issue where I need to send a parameter in super() based on a specific condition, but placing an if statement before super() results in a compilation error. Is there a workaround for this?
Below is the code snippet that I have tried, but it's not working as expected. I need to pass or block the dependencies parameter (ENGINE_MODEL) in super() depending on a certain condition.
Any suggestions on how to achieve this functionality?
export class CreateChrStructureNodeControlComponent extends StructureNodeControl {
constructor(private changeRequestCreateService: CreateChangeRequestService) {
if(some condition = 'SF')
super(changeRequestCreateService,
PLANT,
ENGINE_MODEL);
else
super(changeRequestCreateService,
PLANT)
;
}
}
Superclass :
export class StructureNodeControl extends BaseTypeaheadControl<TypeahaedLookupTableItem> {
constructor(changeRequestCreateService: CreateChangeRequestService, ...dependencies: string[]) {
super(STRUCTURE_NODE,
changeRequestCreateService.getStructureNodes,
TypeahaedLookupTableItem,
...dependencies);
}