cosmology-tech / telescope

A TypeScript Transpiler for Cosmos Protobufs ⚛️
https://cosmology.zone/products/telescope
Apache License 2.0
146 stars 43 forks source link

Json safe #620

Closed pyramation closed 4 months ago

pyramation commented 4 months ago

should close #605

cc @turadg

turadg commented 4 months ago

Looks like it does the job, but the option could be more clear. JsonSafe is a utility type, but doesn't really express the intent for the person setting the option.

Consider, prototypes.typingsFormat.returnKnown. That contracts with theunknown` default.

Though if it were me I'd always return the typed value and not have an option. I can't think of why anyone would prefer to get unknown to the true value. It also shouldn't be considered a breaking change since the change improves accuracy. (i.e. any type check that breaks with this is revealing a bug)

pyramation commented 4 months ago

great feedback @turadg

The reason we use options (for any feature) is so developers that upgrade can choose to have few code changes as possible since a large amount of code is generated.

I would suggest we do two phases. One smaller release (patch) with the option defaulting to unknown, and then a minor release to make it the default to have types