microsoft / microsoft/TypeScript
Better error message when a module declaration is not found, but a module augmentation is?
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
🔎 Search Terms
declaration, augmentation
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about module augmentation and declaration files
⏯ Playground Link
Can't be shown on Playground, since it requires two files
💻 Code
// declaration.d.ts
import { ComponentType } from "react";
declare module "a/b" {
const B: ComponentType<any>;
// const B: import("react").ComponentType<any>;
export default B;
}
// file.ts
import B from "a/b";
🙁 Actual behavior
The error message is "Cannot find module 'a/b' or its corresponding type declarations (2307)". I know this works as indended from https://github.com/microsoft/TypeScript/issues/49043#issuecomment-1124047244, so my proposal is only about changing the error message.
🙂 Expected behavior
In the case where TypeScript can't find a declaration of a module but can find its augmentation, it seems very likely the user intended to make it a declaration, but didn't know top-level import/export change the meaning (like I didn't yesterday). It would be nice to have the message tell the user about the problem and guide to fixing it.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
示されている2つのファイル、declaration.d.ts と file.ts を使って動作を再現し、モジュール宣言がない一方でその拡張が見つかる場合の診断を比較します。モジュール解決の診断パスを追跡し、トップレベルの import/export の違いを説明するようにメッセージを更新します。この例と関連する診断テストに対して、更新したガイダンスを検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100