microsoft / microsoft/TypeScript

Incorrect diagnostic message in TS2814

未关闭
#63,628 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Bug Domain: Error Messages
主要语言
Go
星标
111k
派生
14.3k
平均合并
2 天 4 小时
30 天内合并 PR
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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 tests/cases/compiler/callOverloads1.ts 开始,并使用提供的 Playground 示例重现 TS2814 诊断。跟踪与类合并的函数声明的诊断,然后选择并验证 issue 中所描述的报告消息或抑制行为。更新编译器测试的预期结果,使其不再接受不正确的措辞。

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
compilers
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
68/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。