hyperweb-io / hyperweb-io/ts-codegen

Don't add typescript index signatures on enum unions

オープン
#119 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
126
フォーク
31
平均マージ
19分
マージ済み PR(30日)
2

説明

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,
},
}
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

ソースファイルもテストも指定されていません。まず、示された Rust enum から TypeScript の enum union interfaces を生成するジェネレーターパスをたどり、変更前後の生成出力を比較してください。enum union のメンバーにインデックスシグネチャ `[k: string]: unknown` が含まれなくなれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
rust, typescript
領域
tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。