Misunderstanding threejs with typescript

Description of the problem

I have an interface, which is inherited.


        let edges:THREE.EdgesHelper;
        edges = new THREE.EdgesHelper(elem, 0x0a541a);
        edges.material.linewidth = 24;

Here its class is – http://joxi.ru/812M0O0TNoyymJ

    class EdgesHelper extends LineSegments {
        constructor(object: Object3D, hex?: number, thresholdAngle?: number);
    }

Here its extension is- http://joxi.ru/JMAjXyXH9gNlme


    export class LineSegments extends Line {
        constructor(
            geometry?: Geometry | BufferGeometry,
            material?: LineDashedMaterial | LineBasicMaterial | ShaderMaterial,
            mode?: number
        );
    }

One more extension with class LineBasicMaterial – http://joxi.ru/wRmzl0ltgnxPAO


    export class LineBasicMaterial extends Material {
        constructor(parameters?: LineBasicMaterialParameters);

        color: Color;
        linewidth: number;
        linecap: string;
        linejoin: string;

        setValues(parameters: LineBasicMaterialParameters): void;
    }

As result typescript didn’t see linewidth – http://joxi.ru/lJ2bLRLHNRaXr6


error TS2345: Argument of type 'BufferGeometry | Geometry' is not assignable to parameter of type 'Geometry'.
  Type 'BufferGeometry' is not assignable to type 'Geometry'.
    Property 'vertices' is missing in type 'BufferGeometry'.

Three.js version
  • r83
    -“@types/three”: “^0.83.1”,

Author: Fantashit

2 thoughts on “Misunderstanding threejs with typescript

  1. @WahlbergRu This sounds like an issue with the typescript definition file, not with Three.js. Seeing as how you’re using @types/three, I recommend you 1: update your definitions to 0.84 (latest as of March 20th) and see if this issue has been fixed. If not, you could bring this issue up with in the DefinitelyTyped github page

  2. Besides @types/three, there is also a Object3D.d.ts in three.js’ package. Which overrides @types/three.

Comments are closed.