microsoft / microsoft/TypeScript
Allow augmentation of re-exported module
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
I've sadly discovered that it not possible to augment a ES2015 module that is being re-exported. At least not without specifying the full path to the ES2015 that is then being re-exported.
This has significant implications, particularly for library authors and consumers.
An example would probably help clarify.
Suppose as an authored of a library I want to expose a simple surface area from which consumers should import from. I do this by creating an index.ts file that re-exports modules from nested sub-folders like so:
// index.ts
export { AClass } from './path/to/class-a';
export { BClass } from './path/to/class-b';
export { CClass } from './path/to/class-c';
Now a consumer can import like so:
import { AClass, BClass } from 'some-library';
The benefits of the above:
- As library author I am free to reorganise the modules into sub-folders as the library code base grows without breaking consumers
- As library consumer I don't need to have intimate knowledge of how the library organises it's file on disk - instead I have one path to import modules and this is the name of the npm package itself.
Once augmentation enters the picture all of the above benefits are now gone.
This is really bad for everyone.
What can be done about the situation?
Thanks
Christian
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 con il pattern di riesportazione mostrato in index.ts e confronta l’augmentation tramite il punto di ingresso del pacchetto con l’augmentation tramite il percorso completo del modulo annidato. L’issue non indica file del compilatore né test; il lavoro sarà completo quando i consumer potranno effettuare l’augmentation di un modulo riesportato senza dipendere dalla struttura interna dei file della libreria.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 25/100