Closed bruceborrett closed 1 month ago
It looks like you found a bug, but your suggested fix is backwards. The return type of entitiesFromSolids
should actually be an array of entities, not an array of geometries. So the bug is in entitiesFromSolids.d.ts
, whereas zoomToFit
looks correct.
If you look at how it's used in practice, the data type is a list of entities, which contain geometry as one of the properties:
Would you be willing to make a PR with a type definition fix?
Has the entity type been defined anywhere yet?
I don't believe so. The closest is the inline type definition here for zoomToFit
:
https://github.com/jscad/OpenJSCAD.org/blob/4c1f37271764649e192300c66d263a1fee52303c/packages/utils/regl-renderer/types/controls/orbitControls.d.ts#L100
But I think it would be nicer if we defined the Entity type explicitly.
https://github.com/bruceborrett/OpenJSCAD.org/commit/5e6a792e374fed5c3c88f03b558c1231da2f206d
Is something like this ok? Im not great with typescript and dont really understand the way that you have structured the types, perhaps you can guide me if Im way off.
Yes that's looking very nice, pretty much the same way I would have done it. Notes:
OrbitControls.d.ts
needs to go to ../geometry-utils-V2/entity
since its in an adjacent directory.entity.d.ts
so that Entity
is not all one long line.Thanks for looking into this!
@bruceborrett I believer those changes have been released. If satisfied then please close this issue.
zoomToFit causes a typescript error saying that Geometry[] is not the correct type for the entities argument.
The return type of the function entitiesFromSolids is Geometry[] and zoomToFit is expecting this as input, so I assume this is a bug in the type declarations. If I change the zoomToFit function to expect Geometry[] then everything works as expected.