Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ambient class can merge with concrete function #32897

Closed
DanielRosenwasser opened this issue Aug 14, 2019 · 7 comments
Closed

Ambient class can merge with concrete function #32897

DanielRosenwasser opened this issue Aug 14, 2019 · 7 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@DanielRosenwasser
Copy link
Member

declare class C {

}

function C() {

}
@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label Aug 14, 2019
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.6.2 milestone Aug 14, 2019
@weswigham
Copy link
Member

Intentional and tested.

@weswigham
Copy link
Member

(This is analogous to how a concrete class can merge with an interface that adds more behavior that isn't implemented)

@weswigham
Copy link
Member

Feel free to add to the release notes if you'd like~

@weswigham weswigham added Working as Intended The behavior described is the intended behavior; this is not a bug and removed Bug A bug in TypeScript labels Aug 15, 2019
@weswigham
Copy link
Member

Yes, this means you can actually declare callable constructors in proper TS implementation code now.

export declare class Point2D {
    x: number;
    y: number;
    constructor(x: number, y: number);
}
export function Point2D(this: Point2D | undefined, x: number, y: number) {
    if (!(this instanceof Point2D)) {
        return new Point2D(x, y);
    }
    this.x = x;
    this.y = y;
}

That's why it closed out ole issue #183.

@DanielRosenwasser
Copy link
Member Author

Seems reasonable.

@typescript-bot
Copy link
Collaborator

This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@Jack-Works
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

4 participants