microsoft / microsoft/TypeScript
symbolToName does handle exports of namespaces
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript Version: 3.2.2
Search Terms: symbolToName, exports, declaration, .d.ts
TypeScript cannot emit the name for a symbol that's declared in an inner namespace but re-exported in the outer namespace. That is, emitting the type name of a symbol does not take an alias created by an export {x as y} statement into account.
This comes up when trying to use the chrome.debugger declaration file. Because debugger is a reserved keyword, the .d.ts is defined using a fake, unexported inner namespace called _debugger, and re-exports it using export {_debugger as debugger};. TypeScript then cannot produce .d.ts files when trying to generate the name for a symbol.
Code
// decl.d.ts
declare module chrome {
namespace _debugger {
export class Foo {}
}
export function getFoo(): debugger.Foo;
export {_debugger as debugger};
}
// user.ts
export const x = chrome.getFoo();
Run tsc --declaration.
Expected behavior:
// user.d.ts
export declare const x: chrome.debugger.Foo;
Actual behavior:
test.ts:1:14 - error TS4025: Exported variable 'x' has or is using private name '_debugger.Foo'.
1 export const x = chrome.getFoo();
~
Playground Link: n/a
Related Issues:
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
tsc --declaration を実行して decl.d.ts と user.ts の問題を再現し、その後、再エクスポートされた _debugger 名前空間に対するコンパイラーの symbolToName の処理を追跡します。生成された宣言を期待される chrome.debugger.Foo という名前と比較し、利用可能であれば、宣言出力に関する既存のコンパイラーテストを使って fix を検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 45/100