jscad / OpenJSCAD.org

JSCAD is an open source set of modular, browser and command line tools for creating parametric 2D and 3D designs with JavaScript code. It provides a quick, precise and reproducible method for generating 3D models, and is especially useful for 3D printing applications.
https://openjscad.xyz/
MIT License
2.58k stars 505 forks source link

Declare Typescript modules in IO packages #1298

Open bruceborrett opened 9 months ago

bruceborrett commented 9 months ago

All Submissions:

Note: please do NOT include build files (those generate by the build-xxx commands) with your PR,

Thank you for your help in advance, much appreciated !

bruceborrett commented 9 months ago

Sorry for the lack of information in this PR.

The issue I was having was when I tried to import an IO package in my project I would get the following error:

Could not find a declaration file for module '@jscad/stl-serializer'. Try npm i --save-dev @types/jscad__stl-serializer if it exists or add a new declaration (.d.ts) file containing declare module '@jscad/stl-serializer';

Simply adding the module declaration resolved the error, Im not sure if this is the best way to solve this but may be a good enough interim solution until proper Typescript support is added?

I added a seperate types directory as I noticed that is the way it was done in the regl-renderer package, did not check the other packages, I can move it to src/index.d.ts if you prefer?

z3dev commented 8 months ago

Simply adding the module declaration resolved the error, Im not sure if this is the best way to solve this but may be a good enough interim solution until proper Typescript support is added.

After adding this interim solution, was there any typing available for the deserialize / serialize functions? Were you able to use the exports of the IO packages?

z3dev commented 7 months ago

@bruceborrett sorry. that was a question for you. Were you able to import and use the IO libraries after these definitions were added?

Also, please move the type definitions into src/index.d.ts

z3dev commented 1 month ago

@bruceborrett Sorry. Can you move the changes to src/index.d.ts ?