phillipdupuis / pydantic-to-typescript

CLI Tool for converting pydantic models into typescript definitions
MIT License
285 stars 48 forks source link

Check whether json2ts exited without any errors before processing the generated ts file #14

Closed qwyt closed 2 years ago

qwyt commented 2 years ago

json2ts started failing on my machine due to some hard to reproduce issue related running x86 binaries on an m1 mac. However since the output file was still there (it previously worked fine) pydantic-to-typescript still attempted to call 'remove_master_model_from_output' on it and failed with this message as a result:

line 111, in remove_master_model_from_output new_lines = lines[:start] + lines[(end + 1) :] TypeError: unsupported operand type(s) for +: ‘NoneType’ and ‘int’

(the error is the same as in https://github.com/phillipdupuis/pydantic-to-typescript/issues/5, not sure if it's caused by the same issue)

because obviously the master model was already stripped. This was confusing and it took me some time to figure out that json2ts was failling.