microsoft / microsoft/TypeScript
export as namespace doesn't support nesting namespaces
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
I'm using rollup to generate a UMD module from my TypeScript source. It's part of a bigger product, so one component exports to a root namespace (e.g. mylib) and another exports to a namespace nested under that (e.g. mylib.plugins.myplugin). Rollup is generating the necessary UMD logic to walk down from the global scope creating namespaces as needed, but I can't model that in my TypeScript d.ts file.
The export as namespace syntax is working great in the first case, but not the second. It looks like TypeScript doesn't support nested namespaces for this purpose. Is this by design or just an omission?
TypeScript Version: 2.7.0-dev.20180103
Code: Two files, a d.ts containing an export as namespace foo.bar declaration and a script that references it.
declaration.d.ts
export var baz;
export as namespace foo.bar;
app.ts
console.log(foo.bar.baz);
Compile with: tsc .\test.d.ts .\main.ts
Expected behavior: The file compiles correctly to the following JS:
console.log(foo.bar.baz);
Actual behavior: Error
declaration.d.ts(3,24): error TS1005: ';' expected.
If I change declaration.d.ts to use export as namespace foo (and update app.ts as needed), the compilation succeeds.
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 minimalen Reproduktion aus declaration.d.ts und app.ts und führe dann tsc .\test.d.ts .\main.ts aus, um den TS1005-Fehler für export as namespace foo.bar zu bestätigen. Verfolge, wie export as namespace geparst und validiert wird; abgeschlossen ist die Aufgabe, wenn verschachtelte Namespaces kompiliert werden und die erwartete Verwendung von foo.bar.baz erhalten bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 25/100