microsoft / microsoft/TypeScript
@ts-ignore on an import that gets redefined strips the import from output
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.7.5 and 3.8.0
Search Terms:
- ts-ignore remove import
- ts-ignore strip import
Code
// @ts-ignore: Local Foo override
import Foo from "foo";
declare const Foo: {
bar(): number;
}
Foo.bar();
Expected behavior:
JS output should probably be:
import Foo from "foo";
Foo.bar();
Actual behavior:
JS output is:
Foo.bar();
Related Issues: None so far
Additional remarks: We are aware of other ways to type the foo module but in this particular case the foo override needs to be done in the file using it. As far as we tried, adding a ts-ignore is the only way to make ts understand that we want to redefine the module.
Now, this seems to move the declaration site from the import to the the declare statement and that has the effect to mark the import site as unused, since the import is unused, ts strips 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
Riproduci il comportamento del codice TypeScript 3.7.5/3.8.0 fornito e del link al Playground, quindi traccia la decisione del compilatore sull'eliminazione degli import per un import seguito da una ridichiarazione. Il lavoro è completo quando il JavaScript emesso mantiene l'import come mostrato nell'output previsto e questo caso è coperto dai test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100