Adding extra field to abstract class

In the TerminalWidget abstract class, i want to add one more field “abstract xyz”.
So I’ve done something like this:

export abstract class CustomTerminalWidget extends TerminalWidget {
    abstract xyz: number | undefined;
}

Now, how do i bind CustomTerminalWidget, or is there any better way to do so?

Hi @vivek9patel,

to extend the actual terminal widget, You’ll want to extend the TerminalWidgetImpl and then rebind as following:

rebind(TerminalWidget).to(CustomTerminalWidgetImpl).inTransientScope();

Like in every object oriented language, you can’t really change the inheritance chain of existing classes, so you need to add your own on top of the existing chain.

Yes, i’ve done the same thing, but in terminalService.onDidChangeCurrentTerminal((e: TerminalWidget) => {}) event, i want to add one more extra field e.xyz.

Since every implementation of TerminalWidget will be of type CustomTerminalWidgetImpl, you can simply do this:

terminalService.onDidChangeCurrentTerminal((e: CustomTerminalWidgetImpl) => {})