CosmWasm / ts-codegen

Convert your CosmWasm smart contracts into dev-friendly TypeScript classes so you can focus on shipping code.
https://cosmology.zone/products/ts-codegen
Apache License 2.0
116 stars 27 forks source link

Don't add typescript index signatures on enum unions #119

Open adairrr opened 1 year ago

adairrr commented 1 year ago

In the generated types we often see the index signature: [k: string]: unknown on the enum union types, which in TS essentially allows for any additional property in the interfaces.

export type GovernanceDetailsForString =
  | {
      Monarchy: {
        monarch: string
        [k: string]: unknown
      }
    }
  | {
      External: {
        governance_address: string
        governance_type: string
        [k: string]: unknown
      }
    }
/// Governance types
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[non_exhaustive]
pub enum GovernanceDetails<T: AddressLike> {
    /// A single address is admin
    Monarchy {
        /// The monarch's address
        monarch: T,
    },
    /// An external governance source
    External {
        /// The external contract address
        governance_address: T,
        /// Governance type used for doing extra off-chain queries depending on the type.
        governance_type: String,
    },
}