I’ve been working on a node.js package that generates typescript types from API responses. I would love to know what you think and would appreciate any feedback!
It would be interesting to know how it works for you in a real project. I often have to create types for undocumented endpoints, but it's always a guessing game. Without a proper spec or reading the source code, it's impossible to know if a field is nullable or not, or to distinguish a real text field from a string based enum
Yeah I agree that it is impossible to know exactly what the fields are without a real documented source, but I figured this could be a decent option when there are no other alternatives available. While it's not perfect, it can provide a starting point for creating types based on sample data, which can then be refined as you work with the API and gain more understanding.
Tbh, there is no benefit of using this package if the API you are working with has an openapi spec, as there are other great libraries to help you generate accurate types such as https://github.com/openapi-ts/openapi-typescript. But I made this package to use when working with external apis that don't have an available spec.