microsoft / microsoft/TypeScript
Named import for 'any'-typed module doesn't work
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
Bug Report
🔎 Search Terms
any module export assignment named import
🕗 Version & Regression Information
TypeScript v4.1.2
💻 Code
mock.d.ts
declare const _: any;
export = _;
example.ts
import { a } from "./mock";
import * as b from "./mock";
const { c } = b;
const { d } = await import("./mock");
console.log(a, c, d);
tsconfig.json
{
"compilerOptions": {
"module": "ESNext",
"strict": true,
"target": "ESNext",
},
"include": [
"./**/*.ts"
]
}
🙁 Actual behavior
The first import returns the diagnostic:
error TS2305: Module '"./mock"' has no exported member 'a'.
While c and d do not error.
🙂 Expected behavior
With an export being effectively any, I would expect default, namespace, dynamic and named imports to all behave as if the module was any. I cannot find any other way to declare a module in a fashion where the compiler treats any import from that module as any and does not issue diagnostics.
As implied in the above, there are certain situations where there is a need to "mock" a module where its shape cannot be statically determined at compile time.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
mock.d.ts、example.ts、tsconfig.jsonを使って報告内容を再現し、その後、TypeScriptコンパイラーがanyとして型付けされたexport-assignmentモジュールからの名前付きインポートをどのように処理するかを追跡します。名前付きインポートでTS2305が報告されなくなり、namespaceインポートとdynamicインポートについて示されている動作が維持されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100