Skip to content

Incorrect diagnostic message in TS2814Β #63628

Description

@bvanjoi

πŸ”Ž 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions