Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onBeforeRender in BatchedMesh causes TS error #310

Closed
tehwalris opened this issue Oct 23, 2023 · 2 comments · Fixed by #311
Closed

onBeforeRender in BatchedMesh causes TS error #310

tehwalris opened this issue Oct 23, 2023 · 2 comments · Fixed by #311
Labels
bug Something isn't working released typescript All things TS

Comments

@tehwalris
Copy link

  • three version: 0.139.2
  • @types/three version: 0.139.0
  • three-stdlib version: 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.

@tehwalris tehwalris added the bug Something isn't working label Oct 23, 2023
@tehwalris
Copy link
Author

This issue was introduced in #307.

@github-actions
Copy link

🎉 This issue has been resolved in version 2.28.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released typescript All things TS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants