reactjs / reactjs/react-docgen
Types from `*.d.ts` files are not parsed in node_modules
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
If an installed package would deliver type informations with d.ts files, it won't parse these files and interface informations are missing in the props.
It could be fixed in the makeFsImporter.ts file with a simple addition:
if (!nextFile) {
// Customization: try to read from a "d.ts" file instead, if it exists
if (resolvedSource.includes("node_modules")) {
const dtsPath = resolvedSource.replace(".js", ".d.ts");
if (fs.existsSync(dtsPath)) {
resolvedSource = dtsPath;
}
}
// Customization: end
// Read and parse the code
const src = fs.readFileSync(resolvedSource, "utf8");
nextFile = file.parse(src, resolvedSource);
parseCache.set(resolvedSource, nextFile);
}
But i didn't want to make another pull request because i'm not sure if this is a nice way to solve it.
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 in makeFsImporter.ts und verfolge, wie nicht aufgelöste Dateien unter node_modules gelesen und geparst werden. Prüfe die bestehende Behandlung rund um resolvedSource und parseCache und verifiziere anschließend, dass installierte Pakete, die .d.ts-Dateien bereitstellen, die erwarteten Schnittstelleninformationen in den Component-Props liefern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- documentation, tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100