Closed TimUnderhay closed 3 years ago
No need to apologize. :-)
Your request and use-case makes total sense, and has been on my radar. The best option I think you have at the immediate moment is to use the jtd-infer tool: https://github.com/jsontypedef/json-typedef-infer -- this would require that you can somehow, for each of the TypeScript types you're interested in, get a stream of JSON instances of that type. jtd-infer
can determine a schema from that information.
I realize that's not what you're asking for. The sort of tool you're asking for is, in a way, the inverse of what the tool in this repo is doing. I suspect it would be better situated in a new, different tool. We can maybe take inspiration from other tools which generate code from TypeScript source code; I fully admit that I've never used typescript
as a library before, so I'm not actually sure how I'd start.
Would you be willing to help develop such a tool?
Just for triage purposes, I'm going to close this ticket out. Please feel free to re-open at any time. :-)
Hi, just letting you know this might be a deal breaker for some people. I think it's definitely worth doing if you want higher adoption rate.
In my case, I have TypeScript interfaces for config and yaml files with config. I wanted to make some validation of these yamls against TypeScript interfaces. I was considering JSON Schema and JTD... but since there is no tool to generate JTD from TS types (afaik), I guess I'll use JSON Schema.
Anyway, thanks for your work, I'll definitely keep an eye on this project.
Apologies as this is more of a feature request than an issue. As a developer with apps that already have a number of Typescript types / interfaces written, I would like the ability to convert these into JTD via the codegen, so that I may be able to perform JSON “schema” validation against these without having to rewrite the apps to make the JTD defs authoritative.
Thanks for your consideration!