microsoft / microsoft/TypeScript

Don't include full paths in module names in error messages

オープン
#41,398 コメント 8 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Experience Enhancement Suggestion
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

TypeScript Version: 4.0.5 (also tested with typescript@next)

Search Terms: namespace has no exported member error

Description

Currently certain error messages shows full file paths. For example:

Namespace '"y:/projects/opf/portal/OPF.Portal.Web/Content/Scripts/DinSide/App/Store/index"' has no exported member 'All'. ts(2694)

Could not find a declaration file for module 'shortid'. 'y:/projects/opf/portal/OPF.Portal.Web/node_modules/shortid/index.js' implicitly has an 'any' type.
Try npm install @types/shortid if it exists or add a new declaration (.d.ts) file containing declare module 'shortid'; ts(7016)

Our project was started without strict: true (and few @typescript-eslint rules), so the code base includes several thousand errors. To be able to gradually fix them, we have started to use betterer, which includes committing a snapshot of all the current errors. Snapshot is then used to report report when we fix errors, and fail our build if we add new errors. But because of certain Typescript errors using full file paths, we're getting unnecessary diffs in this snapshot.

Would it be possible to use file paths relative to the project/tsconfig.json root in the error messages instead?

So, with tsconfig.json in y:/projects/opf/portal/OPF.Portal.Web/, the error message would instead be:

Namespace '"Content/Scripts/DinSide/App/Store/index"' has no exported member 'All'. ts(2694)

An alternative solution could be to change betterer instead, make it auto-replace file paths with relative paths, or something like that. But figured I could at least ask here, especially since it could maybe be an issue for other tools as well.

Related Issues: Couldn't find any

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

例と tsconfig.json root を使って診断コード 2694 と 7016 を再現し、その後、モジュール名と宣言ファイルのパスがどこでフォーマットされているかを追跡します。これらのメッセージがプロジェクトルートからの相対パスを使用し、既存の診断や提案された npm 宣言テキストを壊さなければ完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
compilers
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。