Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
adairrr opened this issue Jun 20, 2023 · 0 comments
Open

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

adairrr opened this issue Jun 20, 2023 · 0 comments

Comments

@adairrr
Copy link
Contributor

adairrr commented Jun 20, 2023

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,
    },
}
@adairrr adairrr changed the title Don't add index signatures on type unions Don't add typescript index signatures on enum unions Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant