Export your Crystal types to Typescript?

If you’re using Crystal and Typescript, probably you have some structs/classes/enums that would benefit from a matching typescript definition file. Has anymore made anything for this? Maybe automatically generate a typescript definition file? The benefit being that you don’t want to maintain a file that is just a copy of information in your crystal files and would need to be synced.

https://app.quicktype.io/ Is something that comes to mind, but not exactly what you’re thinking of.


Sounds like you might be thinking along the lines of Crystal objects that you serialize into a JSON response and the TypeScript app on the other end of the request needs to be able to deserialize them in a type-safe way.

If that’s your use case, you may want to define the abstract type using something like OpenAPI and generate both Crystal and TypeScript types from that. You might be able to use this Crystal code generator for OpenAPI.