gzuidhof / tygo

Generate Typescript types from Golang source code
MIT License
597 stars 40 forks source link

Add ability to emit literal Typescript from with Go file #52

Closed pdhammond42 closed 7 months ago

pdhammond42 commented 7 months ago

This implements a feature to allow a Go file to contain Typescript definitions that can't be expressed through tstype tags.

There are actually two ways of doing it implemented. I think both have their uses but perhaps only one should be included, in which case I would say the var string literal one should be preferred.

Motivating Example: We have a struct that is marshalled into JSON, and therefore exposed to TS, as a tuple of values, to minimise size on the wire. (it saves about 30% after gzip compression)

Prior art: There are of course already ways to handle this.

I hope you find this change acceptable and thanks for reading.

gzuidhof commented 7 months ago

Let me know when you are happy for me to merge this

pdhammond42 commented 7 months ago

Let me know when you are happy for me to merge this

I'm happy if you are happy with not handling const.