microsoft / microsoft/TypeScript
No ways to do an alias of an exported type inside a namespace
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
TypeScript Version: 3.9.7
Search Terms:
export type alias namespace
Code
With import type, in case of long namespaces encapsulation, there's no way to do an alias of the namespaces.
We are forced to alias the final types / interfaces
file types.ts
type A = {}
type B = {}
type C = {}
export type {
A,
B,
C
};
file namespace1.ts
import type * as namespace1 from 'types';
export type {namespace1}
file namespace2.ts
import type * as namespace2 from 'namespace1';
export type {namespace2}
file finalUsage.ts
import type {namespace2} from 'namespace2';
type A = namespace2.namespace1.A; // this is working
namespace aliasNamespaces2 {
export import namespace1 = namespace2.namespace1; // fails with message 'An import alias cannot reference a declaration that was imported using 'import type'. '
}
Expected behavior:
we need a way to make a shortcut of namespaces2.namespace1
Actual behavior:
Cannot do it: we are forced to aliasthe final types namespaces2.namespace1.A
Playground Link:
Related Issues:
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 riproducendo il comportamento nei file di esempio types.ts, namespace1.ts, namespace2.ts e finalUsage.ts con la configurazione TypeScript 3.9.7 segnalata. Traccia la gestione di import type aliases e namespace references, quindi definisci e testa un modo supportato per abbreviare namespace2.namespace1 senza l’import-type error attuale.
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
- 30/100