microsoft / microsoft/TypeScript
Recursively Resolving Modules
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
TypeScript Version: 2.1.0
I'm using ts-loader and Webpack to compile my .ts files. In My Webpack config I have the following configuration:
resolve: {
modulesDirectories: ['shared', 'node_modules']
}
This allows me to import a component that lives in the shared directory without spelling out the full relative path. Example:
import Button from 'components/Button'
Webpack will walk up the directory tree and use the first shared directory it finds (the same way it does with the node_modules directories). This way, the component can live in the ../../shared/components/Buttton.tsx and Webpack will find it and bundle it.
My files compile fine because I am using ts-loader but I am getting can not find module errors in my editor.
Is there a way to tell the TS compiler to recursively look for the component in the shared directories?
I noticed the new baseUrl and paths configuration option but to my knowledge you can not use paths to recursively look for a directory.
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
Das Issue nennt keine Quelldateien oder Tests. Beginne damit, das Verhalten der TypeScript-Modulauflösung rund um baseUrl und paths zu lesen, und vergleiche es anschließend mit Webpacks modulesDirectories-Suche. Erledigt ist die Aufgabe, wenn Compiler und Editor Importe wie components/Button über zutreffende gemeinsame Verzeichnisse auflösen können, ohne Fehler wegen nicht gefundener Module.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript, webpack
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100