microsoft / microsoft/TypeScript
@ts-ignore on an import that gets redefined strips the import from output
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript Version: 3.7.5 and 3.8.0
Search Terms:
- ts-ignore remove import
- ts-ignore strip import
Code
// @ts-ignore: Local Foo override
import Foo from "foo";
declare const Foo: {
bar(): number;
}
Foo.bar();
Expected behavior:
JS output should probably be:
import Foo from "foo";
Foo.bar();
Actual behavior:
JS output is:
Foo.bar();
Related Issues: None so far
Additional remarks: We are aware of other ways to type the foo module but in this particular case the foo override needs to be done in the file using it. As far as we tried, adding a ts-ignore is the only way to make ts understand that we want to redefine the module.
Now, this seems to move the declaration site from the import to the the declare statement and that has the effect to mark the import site as unused, since the import is unused, ts strips it.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供された TypeScript 3.7.5/3.8.0 のコードと Playground リンクから動作を再現し、その後、import に続いて再宣言がある場合の import 消去に関するコンパイラーの判断を追跡します。期待される出力に示されているとおり、出力された JavaScript に import が保持され、このケースのテストカバレッジがある状態を完了とします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100