-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Ambient class can merge with concrete function #32897
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
Comments
Intentional and tested. |
(This is analogous to how a concrete class can merge with an interface that adds more behavior that isn't implemented) |
Feel free to add to the release notes if you'd like~ |
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. |
Seems reasonable. |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
@wemeetagain your example code is no longer working in the TypeScript 3.9, is it a regression? Cannot redeclare exported variable 'Point2D'.(2323) |
The text was updated successfully, but these errors were encountered: