reactjs / reactjs/react-docgen

How to generate correct prop types when the prop-types package is not explicitly imported?

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

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

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

説明

Is there a recommended way to generate prop types when the prop-types package is not explicitly imported into each component? For example, in my project, PropTypes is provided as a global through webpack's providePlugin:

config: {
    plugins: [
        new ProvidePlugin({
               PropTypes: 'prop-types',
        }),
    ]
};

So PropTypes is available to any react component—even when it is not imported.

I see the resolveToModule util looks for the prop-types import, and if it is not found, we end up with custom prop types rather than their actual type, like string or bool. It seems I can create a handler to generate prop types even when the prop-types package is not explicitly imported, but is there an already existing handler or other way to do this that addresses this case?

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

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

はじめの一歩

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

調査の方向性

まず resolveToModule util と prop-types の既存の handler を読みます。webpack ProvidePlugin が明示的な prop-types の import なしで PropTypes を提供するケースを再現し、その後、既存の handler がそれをサポートしているか判断します。生成された出力が custom ではなく string や bool などの具体的な型を報告すれば完了です。

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

評価

技術スタック
react, webpack
領域
documentation, tooling
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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