Skip to content

Function declarations break inheritance of ambient class declarations #46503

@zOadT

Description

@zOadT

Bug Report

🔎 Search Terms

  • Inheritance
  • Function declaration
  • Ambient class declaration

🕗 Version & Regression Information

  • This seems to be the behaviour since Typescript 3.6 (the version that introduced merging ambient function and class declarations)
  • I tried my best to find this issue, I hope this is no duplicate

⏯ Playground Link

Playground link with relevant code

💻 Code

declare class A {
    a: number;
}

declare function B(): B; // (a)
declare class B extends A {
    constructor();
    b: number;
}

let b = new B("Hey")
console.log(b.a) // Property 'a' does not exist on type 'B'.

🙁 Actual behavior

Line (a) breaks inheritance of class B.

🙂 Expected behavior

B should inherit all properties of A as it does when you remove line (a).

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".FixedA PR has been merged for this issueHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions