microsoft / microsoft/TypeScript

Import ellision emit bug: usage of imports only in keys of interfaces does not result in those imports being elided as type-only

Aperta
#58,081 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Bug Domain: JS Emit Help Wanted
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔎 Search Terms

import ellision emit

🕗 Version & Regression Information
  • This is the behavior in every version I tried - I saw it in typescript 4.9 and in the playground in typescript 5.4.3.
⏯ Playground Link

https://www.typescriptlang.org/play?importHelpers=true&target=99&module=2#code/JYWwDg9gTgLgBAbwEIEEBKBfOAzKERwDkARgIZSEDcAsAFCiSxwBUcpAzjhBDngYdm5U6dAKYAPRvGAA7GKKjZSAY1Fw03GAGUYpeYjpw4AbVRoAugC447GFFkBzGrSPHBEAHRkoVm3cfOGHRAA

💻 Code
import {BAR} from 'bar';
import * as foo from 'foo';

export interface RootState {
  [BAR]: string;
  [foo.bar]: string;
}
🙁 Actual behavior

When compiled to ESNext module:

import { BAR } from 'bar';
import * as foo from 'foo';

when compiled to AMD with importHelpers it's interesting that __importStar appears

define(["require", "exports", "tslib", "bar", "foo"], function (require, exports, tslib_1, bar_1, foo) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    foo = tslib_1.__importStar(foo);
});
🙂 Expected behavior

output should be an entirely empty module, e.g. AMD should be

define(["require", "exports"], function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
});

ESNext should be

export {}
Additional information about the issue

No response

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con il TypeScript Playground collegato e l'esempio minimo di imports/interfaces, quindi confronta gli output ESNext e AMD con il comportamento segnalato. Il lavoro è completato quando gli imports usati solo nelle chiavi delle interfacce vengono omessi, producendo export {} per ESNext e un modulo AMD contenente solo require e exports.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
compilers
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.