Native API: formatDiagnosticsWithColorAndContext drops related information without a file location
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
- #65112 @timurzvural による — マージされずにクローズ
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 75/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- node.js, typescript
- 領域
- api
調査の方向性
バグは packages/typescript/src/api/diagnosticFormatter.ts にあり、flattenDiagnosticMessage(related, ...) の呼び出しが if (related.fileName && related.startPosition) の分岐の中にあります。issue の再現スクリプトを実行し、関連テキストが欠落していることを確認してください。位置情報のない診断で関連テキストが表示され、位置の見出しとソースコンテキストはファイルがある場合にのみ表示される状態になれば完了です。既存のフォーマッターのテストの近くに回帰テストを追加してください。
索引モデルが issue の本文から書いたものです。
説明
🔎 Search Terms
formatDiagnosticsWithColorAndContext, relatedInformation, fileless diagnostic, missing related diagnostic text, diagnosticFormatter
🕗 Version & Regression Information
Reproduced against main at 6161772c1370bdd4a82f808e6823bd755eb1870d using Node.js v24.14.0. The same conditional is still present on current main.
The TypeScript 6.0.3 implementation outputs related diagnostic text outside the if (file) branch; the native API implementation only outputs it inside the location branch.
⏯ Playground Link
Not applicable: this exercises the diagnostic formatting API.
💻 Code
Save as repro.mts at the repository root and run node repro.mts with Node.js 24. This calls the formatter directly with a diagnostic containing a related message without a file location.
import { formatDiagnosticsWithColorAndContext } from "./packages/typescript/src/api/diagnosticFormatter.ts";
const host = {
getCurrentDirectory: () => "/project",
getCanonicalFileName: (name: string) => name,
getNewLine: () => "\n",
};
const output = formatDiagnosticsWithColorAndContext([{
category: 1,
code: 2322,
pos: 0,
end: 0,
text: "Primary error.",
relatedInformation: [{
category: 3,
code: 9999,
pos: 0,
end: 0,
text: "This related explanation must remain visible.",
}],
}], host);
console.log(JSON.stringify(output.replace(/\x1b\[[0-9;]*m/g, "")));
🙁 Actual behavior
The related explanation disappears:
"error TS2322: Primary error.\n"
Adding fileName: "/project/a.ts" and startPosition: { line: 0, character: 0 } to the related diagnostic makes its text appear.
🙂 Expected behavior
The related explanation should be included even when it has no file location. Only the location heading and source context depend on a location.
Additional information about the issue
In diagnosticFormatter.ts, the call to flattenDiagnosticMessage(related, ...) is inside if (related.fileName && related.startPosition). This also drops message chains on locationless related diagnostics.
The diagnostic response type permits omitted file names and positions. In the 6.0.3 formatter, related message text is emitted independently of the file check.
The reproduction uses constructed diagnostic objects to isolate the formatter behavior. Existing formatter tests cover related information with a location.
I would be happy to submit a focused fix and regression tests once this is triaged.
- 主要言語
- Go
- スター
- 112k
- フォーク
- 15.4k
- 平均マージ
- 3日 1時間
- マージ済み PR(30日)
- 136
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/TypeScript のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
microsoft/TypeScript#65290 ·
メンテナーはふだん 1 日以内に返信
-
TS7 LSP: documentHighlight returns nothing when the file path contains '@'再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンBug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/TypeScript#64758 ·
メンテナーはふだん 1 日以内に返信
-
Language server (tsc --lsp) exits with code 1 after `shutdown` and `exit`対応中かも @rajnish-verma-22172 が 13 日前に担当しました。 オープンBug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
microsoft/TypeScript#64742 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Non-enum CLI options with multiple values separated by comma and space aren't whitespace trimmed対応中かも @RyanCavanaugh が 28 日前に担当しました。 オープンBug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
microsoft/TypeScript#64618 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
TypeScript 7 VS Code extension: a workspace "typescript" 7.x package is not detected, only "@typescript/native-preview", which is no longer published再び着手できるかも @jakebailey が 28 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンNeeds Investigation
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
microsoft/TypeScript#64565 · リアクション 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
microsoft/TypeScript の issue をすべて見る
似ている issue
-
area:sampler tech-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
jmbarzee/temporal-architect#302 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
riverqueue/river#1576 ·
メンテナーはふだん 1 日以内に返信
-
NFS StorageProvider renders a missing nfsSubDir as "<no value>"対応中かも @ldming が今日担当しました。 オープンkind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apecloud/kubeblocks#11067 ·
メンテナーはふだん 1 日以内に返信
-
area:ui bug priority:low
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
RTX payload type is not found when the RTX fmtp line has rtx-time対応中かも @RaphaelFakhri が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信