microsoft / microsoft/TypeScript
export as namespace doesn't support nesting namespaces
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
最小限の declaration.d.ts と app.ts の再現から始め、tsc .\test.d.ts .\main.ts を実行して export as namespace foo.bar に対する TS1005 エラーを確認します。export as namespace がどのように解析および検証されるかを追跡します。ネストされた namespace がコンパイルされ、想定される foo.bar.baz の使用方法が維持されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 25/100