-
Notifications
You must be signed in to change notification settings - Fork 135
Closed
Labels
Description
threeversion: 0.139.2@types/threeversion: 0.139.0three-stdlibversion: 2.28.0
Problem description:
In a project that has three-stdlib as a dependency I see these errors when running TypeScript:
node_modules/.pnpm/three-stdlib@2.28.0_three@0.139.2/node_modules/three-stdlib/objects/BatchedMesh.d.ts:37:5 - error TS2425: Class 'Mesh<BufferGeometry, Material>' defines instance member property 'onBeforeRender', but extended class 'BatchedMesh' defines it as instance member function.
37 onBeforeRender(): void;
~~~~~~~~~~~~~~
node_modules/.pnpm/three-stdlib@2.28.0_three@0.139.2/node_modules/three-stdlib/objects/BatchedMesh.d.ts:38:5 - error TS2425: Class 'Mesh<BufferGeometry, Material>' defines instance member property 'onAfterRender', but extended class 'BatchedMesh' defines it as instance member function.
38 onAfterRender(): void;
~~~~~~~~~~~~~
Relevant code:
I'm just importing the library, not using it yet. That is enough to trigger the tsc error.
Suggested solution:
I noticed you have @ts-ignore above onBeforeRender in BatchedMesh. In the generated BatchedMesh.d.ts these @ts-ignore comments get stripped:
import { Matrix4, Mesh, BufferGeometry, Material, DataTexture, IUniform } from 'three';
declare class BatchedMesh extends Mesh<BufferGeometry, Material> {
// ... (other methods omitted)
onBeforeRender(): void;
onAfterRender(): void;
}
export { BatchedMesh };
Since the @ts-ignore comment isn't helping here, we have to actually fix the original type error. To fix it we could either make onBeforeRender a property in three-stdlib or make it a method in @types/three. It would be nice to know why @types/three defined onBeforeRender as a property in the first place though.