reactjs / reactjs/react-docgen
Missing support for Flow Unions
まだ誰も着手していません。
- 主要言語
- TypeScript
- スター
- 3.8k
- フォーク
- 316
- 平均マージ
- 5時間 7分
- マージ済み PR(30日)
- 4
説明
react-docgen doesn't recognize the props if it's an union type:
type BaseProps = {|
label: string,
|};
type LinkButtonProps = {|
...BaseProps,
href: string,
target?: string,
rel?: string,
|};
type ButtonProps = {|
...BaseProps,
type?: 'button' | 'submit',
|};
type Props = ButtonProps | LinkButtonProps;
class MyButton extends React.Component<Props> {
render() {
// conditionally render `<a>` or `<button>` based on props...
}
}
I don't want users to pass props that are specific to <a> at the same time as some props that are specific to <button> - I know this kind of pattern of having a single component render to <a> or <button> is "weird", but some of our legacy components use it...
For now I need to define a single type that includes all the props and mark them all as optional - which is "fine", I guess..
More info about unions here: https://flow.org/en/docs/types/unions/
tested on v3.0.0-beta10
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
react-docgen v3.0.0-beta10 を使用して issue の例を再現し、結果を union に対して期待される props と比較します。リンクされている Flow の unions のドキュメントを読み、component props を処理する parser のエントリポイントを追跡します。ユーザーにすべての props を 1 つのオプショナル型にフラット化することを要求せずに union のメンバーが認識されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, react
- 領域
- devtools, documentation
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100