microsoft / microsoft/TypeScript

Incorrect diagnostic message in TS2814

オープン
#63,628 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

Bug Domain: Error Messages
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

🔎 Search Terms

2814, function body

🕗 Version & Regression Information
  • regression at v4.4.4.
⏯ Playground Link

https://www.typescriptlang.org/play/?ts=4.4.4#code/MYGwhgzhAEBiD29oG9oChqegIzAJwEYAKAShWgF80q0AzAVwDtgAXAS3kbkVIG40A9AIB+APWgBRAEpSA8lIBccJqw5cA7mxYALHPAAmbAKYxgYLpxABPaAFsjeAOZHomndFCQIJ6DrAtofBcwW2xjRhYAOiA

💻 Code
// tests/cases/compiler/callOverloads1.ts

class Foo { 
    bar1() { }
}

function Foo();
//~^ error report: Function with bodies can only merge with classes that are ambient.
🙁 Actual behavior

The function Foo actually has no body (it's just a declaration), yet the error message says "Function with bodies...", which may be a bit confusing.

🙂 Expected behavior

Either show a hint like "Only functions can merge with ambient classes," or suppress the error report for functions without a body because class Foo will report Class declaration cannot implement overload list for 'Foo'.

Additional information about the issue

No response

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

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

はじめの一歩

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

調査の方向性

tests/cases/compiler/callOverloads1.ts から始め、提供された Playground の例を使って TS2814 診断を再現します。クラスとマージされた関数宣言の診断を追跡し、issue で説明されている報告メッセージまたは抑制の動作を選択して検証します。誤った文言が受け入れられなくなるように、コンパイラーテストの期待値を更新します。

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

評価

技術スタック
typescript
領域
compilers
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
68/100

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

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