kripod / kripod/react-polymorphic-box

Incorrect work with Unions Types

オープン
#23 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
TypeScript
スター
346
フォーク
14
PR マージ指標
30日以内にマージされた PR はありません

説明

## Description

Polymorphic box has partialized props if "as" component has unioned props.

## Reproduction

```
import React from 'react';
import { Box } from 'react-polymorphic-box';

interface ITestA {
value: 'a';
}

interface ITestB {
value: 'b';
extra: string;
}

type Test = ITestA | ITestB;

const Test: React.FC = (props) => {
return <>;
};

function App() {
return (
<>



);
}
```

## Expected behavior

Polymorphic box has correct props types.

## Actual behavior

>`Type '{ as: FC; value: "b"; extra: string; }' is not assignable to type 'IntrinsicAttributes & BoxOwnProps> & Pick, "value" | "children">'.
Property 'extra' does not exist on type 'IntrinsicAttributes & BoxOwnProps> & Pick, "value" | "children">'`

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

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

調査の方向性

まず、issue に示されている Box コンポーネントと結合された Test の props を使って TypeScript の再現コードをコンパイルします。Test が直接受け付ける props と、Box 経由で受け付ける props を比較します。Box の使用で value="b" と extra="extra" が正しい TypeScript 型で受け付けられれば作業完了です。

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

評価

技術スタック
react, typescript
領域
frontend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

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

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