microsoft / microsoft/TypeScript
"Import assignment cannot be used when targeting ECMAScript modules." should come with a codefix
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript Version: 3.2.0-dev.20181030
Code
a.ts
import abs = require("abs");
tsconfig.json
{
"compilerOptions": {
"target": "esnext"
}
}
The error message is Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.. This indicates that we could provide a code fix.
Expected behavior:
There is a codefix that offers to change this to import abs from "abs";, or import * as abs from "abs";. If --esModuleInterop is set and the imported value is not used only as a namespace, we should prefer a default import.
Actual behavior:
No codefix.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
a.ts と示されている tsconfig.json を使って診断を再現し、このエラーに対するコンパイラの codefix 処理を追跡します。修正では default import と namespace import の形式を提示し、esModuleInterop が有効で、値が namespace としてのみ使用されていない場合は default import を優先する必要があります。提案された両方の編集と、それらの適用可能性を確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100