reactjs / reactjs/react-docgen
How to generate correct prop types when the prop-types package is not explicitly imported?
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 3.8k
- Forks
- 316
- Ø Merge
- 5 Std. 7 Min.
- Gemergte PRs (30 T.)
- 4
Beschreibung
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?
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem Lesen des resolveToModule util und der vorhandenen Handler für prop-types. Reproduziere den Fall, in dem webpack ProvidePlugin PropTypes ohne einen expliziten prop-types-Import bereitstellt, und ermittle dann, ob ein vorhandener Handler dies unterstützt; abgeschlossen, wenn die generierte Ausgabe konkrete Typen wie string oder bool statt custom meldet.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- react, webpack
- Bereich
- documentation, tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100