In my Angular 2 project, I am working on creating an interface for a complex object. Here is the code snippet of the object:
// Defining the render state object
this.aRenderState = {
model: "",
colour: false,
showWireframe: false,
showGrid: true,
clipping: {
enabled: false,
visible: false,
planes: [
{
name: 'X',
plane: new THREE.Plane(new THREE.Vector3(1, 0, 0), 0),
object: null,
enabled: true,
flip: false,
size: [this.aDomain.getSize().z, this.aDomain.getSize().y],
},
{
name: 'Y',
plane: new THREE.Plane(new THREE.Vector3(0, 1, 0), 0),
object: null,
enabled: false,
flip: false,
size: [this.aDomain.getSize().x, this.aDomain.getSize().z]
},
{
name: 'Z',
plane: new THREE.Plane(new THREE.Vector3(0, 0, -1), 0),
object: null,
enabled: false,
flip: false,
size: [this.aDomain.getSize().x, this.aDomain.getSize().y]
},
]
}
}
Here's my attempt at defining interfaces for the above object:
export interface IPlane {
name: string;
plane: THREE.Plane;
object: {};
enabled: boolean;
flip: boolean;
size: number[];
}
export interface IClipping {
enabled: boolean;
visible: boolean;
planes: IPlane[];
}
export interface IRenderState {
model: string;
colour: boolean;
showWireframe: boolean;
showGrid: boolean;
clipping: IClipping;
}
However, when I try to run the project, I encounter the following error message:
Type '{ model: string; colour: false; showWireframe: false; showGrid: true; clipping: { enabled: false;...' is not assignable to type 'IRenderState'. Types of property 'clipping' are incompatible. Type '{ enabled: false; visible: false; planes: [{ name: string; plane: Plane; object: null; enabled: t...' is not assignable to type '{ enabled: boolean; visible: boolean; planes: [IPlane, IPlane, IPlane]; }'. Types of property 'planes' are incompatible. Type '[{ name: string; plane: Plane; object: null; enabled: true; flip: false; size: [number, number]; ...' is not assignable to type '[IPlane, IPlane, IPlane]'. Type '{ name: string; plane: Plane; object: null; enabled: true; flip: false; size: [number, number]; }' is not assignable to type 'IPlane'. Types of property 'size' are incompatible. Type '[number, number]' is not assignable to type '[0, 0]'. Type 'number' is not assignable to type '0'.)
I'm struggling to understand where I have made a mistake in my code.