I have a class that looks like this:
export class Block {
protected structure: Structure;
public constructor() {
this.structure = {
...
};
}
}
Now I need to extend Block where I override the "structure" type to something more compatible for that structure, essentially, just adds extra properties that are irrelevant to Block but may be needed by the extending class, so I have tweaked it so that it is:
export class Block<StructureType extends IBlock = IBlock> {
protected structure: StructureType;
public constructor() {
this.structure = {
...
};
}
}
This works correctly, and allows me to extend it like so:
import { Block } from '../some/loc';
export class Field extends Block<IField> {
public constructor() {
super();
this.structure = { ... };
}
}
The issue I am seeing is that, in the "Block" class, when I do this.structure = { ... } I am seeing the attached screenshot.
It's worth noting the IField type extends IBlock by:
export type IField = IBlock & { ... }
I'd appreciate any thoughts or pointers of stupid stuff I am doing.