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

Extend object classes in TypeScript with generic types #20133

Merged
merged 1 commit into from
Aug 20, 2020

Conversation

Berthur
Copy link

@Berthur Berthur commented Aug 20, 2020

I propose these changes to make it possible to use generics for inherited three.js object types.

An example:

function getMesh(): Mesh<BufferGeometry> {
  /* Do stuff */
  return new InstancedMesh(geometry, material, n);
}

This will currently give the TS error Type 'InstancedMesh<BufferGeometry, Material>' is not assignable to type 'Mesh<BufferGeometry, Material | Material[]>'.

@mrdoob mrdoob added this to the r120 milestone Aug 20, 2020
@mrdoob mrdoob merged commit c631aff into mrdoob:dev Aug 20, 2020
@mrdoob
Copy link
Owner

mrdoob commented Aug 20, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants