Skip to content

fix(2814): correct misleading error message for functions without bodies#63631

Open
Nabeel-akk wants to merge 1 commit into
microsoft:mainfrom
Nabeel-akk:fix/ts2814-error-message
Open

fix(2814): correct misleading error message for functions without bodies#63631
Nabeel-akk wants to merge 1 commit into
microsoft:mainfrom
Nabeel-akk:fix/ts2814-error-message

Conversation

@Nabeel-akk

Copy link
Copy Markdown

Closes #63628

The TS2814 error currently says 'Function with bodies can only merge with classes that are ambient.' but the function in question (an overload declaration like unction Foo();) doesn't have a body. This makes the message confusing.

The fix removes the incorrect 'with bodies' qualifier since the error can fire for any function declaration regardless of whether it has a body.

Copilot AI review requested due to automatic review settings July 7, 2026 14:53
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Jul 7, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jul 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the TS2814 diagnostic wording to remove the misleading “with bodies” qualifier, since the error can also be reported for body-less function declarations (e.g. overload signatures).

Changes:

  • Update the TS2814 message text in src/compiler/diagnosticMessages.json to remove “with bodies”.

Comment on lines +3793 to 3796
"Functions can only merge with classes that are ambient.": {
"category": "Error",
"code": 2814
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Incorrect diagnostic message in TS2814

2 participants