I want to override property in Typescript class, which is also a constructor parameter. The property is shaped by the interface, which is also extended. Because of the verbal description is complicated, better see this minimal code example:
interface IA
{
x: boolean;
}
class CA
{
constructor(protected readonly o: IA)
{
}
}
type Modify<T, R> = Omit<T, keyof R> & R;
interface IB extends Modify<IA, {x: number}>
{
y: string;
}
class CB extends CA // <--- Class 'CB' incorrectly extends base class 'CA'.
{
constructor(protected readonly o: IB)
{
super(Object.assign(o, {x: !!o.x}));
}
}
I read How do I override a property in typescript? but there are only interfaces involved, I need this for a class property.