reactjs / reactjs/react-docgen
Types from `*.d.ts` files are not parsed in node_modules
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 3.8k
- Fork
- 316
- Merge medio
- 5h 7m
- PR unite (30g)
- 4
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da makeFsImporter.ts e segui il modo in cui i file non risolti sotto node_modules vengono letti e analizzati. Controlla la gestione esistente relativa a resolvedSource e parseCache, quindi verifica che i pacchetti installati che espongono file .d.ts producano le informazioni sull’interfaccia previste nelle props dei componenti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- documentation, tooling
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 48/100