microsoft / microsoft/TypeScript
Incorrect diagnostic message in TS2814
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
### 🔎 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
```ts
// 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_
Contributor guide
Research direction
Start with tests/cases/compiler/callOverloads1.ts and reproduce the TS2814 diagnostic using the provided Playground example. Trace the diagnostic for a function declaration merged with a class, then choose and validate the reported-message or suppression behavior described in the issue. Update the compiler test expectations so the incorrect wording is no longer accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100