microsoft / microsoft/TypeScript
`export { _void as void }` leads to exporting duplicate identifiers
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
🔎 Search Terms
export void export reserved export null
🕗 Version & Regression Information
- Reproducible since typescript v4. In older releases, it doesn't export anything. I also tried the latest dev release (5.9.0-dev.20250716)
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
exports
⏯ Playground Link
Playground (important: lang:javascript)
💻 Code
Using the following tsconfig.json:
{
"compilerOptions": {
"target": "esnext",
"lib": ["esnext"],
"module": "esnext",
"allowJs": true,
"checkJs": true,
"declaration": true,
"declarationMap": true,
"outDir": "./dist",
"emitDeclarationOnly": true,
"strict": true,
"noImplicitAny": true,
"moduleResolution": "bundler"
}
}
I compile declaration files for this code ${project}/schema.js (only happens when compiling javascript):
const _null = {}
const $void = {}
export { _null as null, $void as void }
🙁 Actual behavior
The produced declaration file schema.d.ts is erroneous. It has duplicate identifiers:
declare const _null: {};
declare const $void: {};
export { _null as null, _null as null, $void as void, _void as void };
🙂 Expected behavior
No duplicate identifiers:
declare const _null: {};
declare const $void: {};
export { _null as null, $void as void };
Additional information about the issue
For any reserved keyword, tsc always exports _{reserved} as {reserved}, whenever {reserved} is exported. Even though the variable _{reserved} does not exist.
It is only reproducible when compiling javascript.
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
Beginne mit der bereitgestellten tsconfig.json und der Reproduktion von schema.js und untersuche anschließend den reinen Deklarations-Emit von JavaScript für die Exportliste. Vergleiche die generierte schema.d.ts mit den erwarteten Exportanweisungen; abgeschlossen ist die Aufgabe, wenn Exporte reservierter Schlüsselwörter genau einmal erscheinen und keine nicht vorhandenen Bezeichner emittiert werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 45/100