clojurescript

danielneal 2025-06-13T09:48:08.704609Z

We have a cljs lib which is consumed by our frontend typescript team to handle a bit of complex domain logic. I’d like to make it a bit more friendly for the frontend team. What could I do - e.g. is there a way to make our cljs docstrings appear for them where the use it in typescript? I don’t mind adding some extra annotations, but not sure where or how, or what format.

Jonas Östlund 2025-06-13T10:03:05.471219Z

You might consider writing and including type declarations files with the cljs lib: https://www.typescriptlang.org/docs/handbook/2/type-declarations.html#your-own-definitions https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-d-ts.html https://stackoverflow.com/questions/48952313/what-to-put-in-package-json-types-field-for-typescript-based-libs and somewhere in the package.json file of the cljs library you would include the type defintions, maybe a line like "types": "./dist/index.d.ts", I haven't tried it myself though, just experimented a bit.

Jonas Östlund 2025-06-13T10:05:18.270209Z

BTW, if the Cljs library is not too complicated, you may consider building it with Squint instead: That way, all the vectors and maps are in fact standard JavaScript arrays and maps which may facilitate consumption from TypeScript even more.

danielneal 2025-06-13T10:06:20.576329Z

Ooh squint sounds like something worth exploring, thank you

Jonas Östlund 2025-06-13T10:10:21.577749Z

I haven't adopted AI coding assistance myself but maybe writing the Typescript type definition file based on the Clojure code would be a tedious task that it could do for you in case you follow that route 😄

danielneal 2025-06-13T10:11:35.891439Z

🙂 actually a good use of AI :)

liebs 2025-06-13T13:34:29.059329Z

shouldn't @jsdoc annotations be passed through the Closure Compiler and hence be visible?