betwixt-labs / bebop

🎷No ceremony, just code. Blazing fast, typesafe binary serialization.
https://bebop.sh/
Apache License 2.0
1.93k stars 40 forks source link

Use `as const` in TypeScript generator #357

Closed lynn closed 5 days ago

lynn commented 5 days ago

It looks like discriminator = 3 as const lets tsc make somewhat more correct type inferences than discriminator: number = 3 as 3.

andrewmd5 commented 5 days ago

LGTM. Thanks - let me know if you want me to push a new release that uses this.

lynn commented 5 days ago

Thanks! It matters a little less than I originally thought; I should have just been using the Enum.fromBranch() API instead of making my own { discriminator: Branch.discriminator } objects. So I'm doing that now, and I'm not blocked on having this in a release.