reactjs / reactjs/react-docgen

wrong `composes` for propType objects that are wrapped

オープン
#283 コメント 0 件 リアクション 5 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
TypeScript
スター
3.8k
フォーク
316
平均マージ
5時間 7分
マージ済み PR(30日)
4

説明

Hello!

when defining prop types people do all sorts of things, for example:

import omit from 'lodash/omit';
import OtherComponent from 'important/path';

export default class Component extends React.PureComponent {
  propTypes = {
    ...omit(OtherComponent.propTypes, ['exclude', 'us']),
    something: bool
  };

  // ...
}
Expected

composes array is ['important/path']

Actual

composes array is ['lodash/omit']


i'm not even sure how this should be handled.
In example above it seems that extracting first argument from function
should be enough. But what if the composed prop types are not first
argument?

Should react-docgen support such cases at all? It seems valid to do so
from JS perspective but generated documentation is incomplete.

Recently https://github.com/reactjs/react-docgen/issues/248 was closed, so perhaps this issue should be considered too.

Thanks for the library!

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

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

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

ラップされた prop-type 式から react-docgen がどのように composes 配列を導出するかを、omit(OtherComponent.propTypes, ...) の例を再現ケースとして使って、まず追跡します。期待される important/path の結果と実際の lodash/omit の結果を比較し、先頭以外の合成引数をどのように扱うべきかを判断します。サポートされるラップされた式のケースについて動作が定義され、テストでカバーされれば完了です。

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

評価

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

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

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