a2ui-project / a2ui-project/a2ui

Strict Type Coercion in DataContext

オープン
#846 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る
P2 type: feature/enhancement
主要言語
TypeScript
スター
16.4k
フォーク
1.3k
平均マージ
2日 13時間
マージ済み PR(30日)
134

説明

# Proposal: Strict Type Coercion in DataContext

## Reason
The A2UI protocol defines standard coercion rules (e.g., `null` resolving to `""` for strings). Without central enforcement, component authors must manually handle these edge cases, leading to bugs like `[object Object]` appearing in text labels.

## Design
1. **Coercion Utils**: Implement the coercion table from the `renderer_guide.md` in a shared utility.
2. **Context Integration**: Update `DataContext.resolveDynamicValue` and `resolveSignal` to apply these rules.
3. **Primitive Safety**:
- String targets: Convert any non-string to localized string; map `null/undefined` to `""`.
- Number targets: Parse strings; map `null/undefined` to `0`.
- Boolean targets: Map `"true"` (case-insensitive) and non-zero numbers to `true`.
4. **GenericBinder Alignment**: Ensure the `GenericBinder` uses these coerced values when populating `ResolvedProps`.

## Key Files
- `renderers/web_core/src/v0_9/rendering/data-context.ts`
- `renderers/web_core/src/v0_9/rendering/generic-binder.ts`

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

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

評価

この issue はまだ評価されていません。

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

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