hyperweb-io / hyperweb-io/ts-codegen

Don't add typescript index signatures on enum unions

Offen
#119 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
126
Forks
31
Ø Merge
19 Min.
Gemergte PRs (30 T.)
2

Beschreibung

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.

```ts
export type GovernanceDetailsForString =
| {
Monarchy: {
monarch: string
[k: string]: unknown
}
}
| {
External: {
governance_address: string
governance_type: string
[k: string]: unknown
}
}
```

```rs
/// Governance types
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[non_exhaustive]
pub enum GovernanceDetails {
/// 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,
},
}
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

No source file or test is named. Start by tracing the generator path that produces TypeScript enum union interfaces from the shown Rust enum, then compare generated output before and after the change. Done means enum union members no longer include the `[k: string]: unknown` index signature.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
rust, typescript
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.