cosmology-tech / telescope

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

generating map types with uint64 keys yields uncompilable typescript #633

Open technicallyty opened 2 weeks ago

technicallyty commented 2 weeks ago

when generating proto code that has type of

map<uint64, someotherType> telescope generates uncompilable typescript. map key types can only be a Number type.

example here:

https://github.com/technicallyty/telescope-test/blob/4a69452e6587c1a0de70069dd774a227cf4adfde/src/codegen/cosmos/auth/v1beta1/auth.ts#L124

that line produces an error: image

this is the message it generated from:

message Foo {
  map<uint64, string> bar = 1;
}

docs here say we can use long or bigint for 64 bit integer types, however neither type is valid when used in a map as key.

Zetazzz commented 6 days ago

if both bigint or long's not valid key type, then we need to fix this using string as the key type and do the converting in this case:

https://github.com/technicallyty/telescope-test/blob/4a69452e6587c1a0de70069dd774a227cf4adfde/src/codegen/cosmos/auth/v1beta1/auth.ts#L124