microsoft / microsoft/TypeScript
Allow type-only named re-exports along with assigned export in the same file
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
Search Terms
allow export types assigned =
Suggestion
The suggestion is to allow compilation of files that do both export = and export type {}.
Use Cases
For modules that target both TypeScript and CommonJS usage it would allow consolidating all exports for both module systems in one file (albeit with the requirement of esModuleInterop being true).
Currently, in order to do that I would have to utilize @ts-ignore (see parzh/xrange#69 for details).
Examples
/person.ts:
import personValue from "./person-value";
export = personValue;
export type { default as PersonType } from "./person-type";
/person-type.ts:
export default interface Person { name: string; }
/person-value.ts:
export default { name: "John Doe" } as import("./person-type").default;
Usage:
/usage.ts:
import personValue from "./person";
import personValue, { PersonType } from "./person";
import type { PersonType } from "./person";
import personValue = require("./person");
/usage.js:
const personValue = require("./person");
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
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
Das Issue nennt die Beispieldateien person.ts, person-type.ts, person-value.ts und usage.ts, aber keine Compilerdateien oder Tests. Beginne damit zu ermitteln, wie der Compiler export = zusammen mit nur für Typen bestimmten benannten Exporten verarbeitet. Überprüfe anschließend, dass das Beispiel kompiliert und dass Exporte, die nur für Typen bestimmt sind, das erzeugte JavaScript nicht verändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 30/100