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

Mixin classes don't allow constructors of 'object' types #13805

Closed
DanielRosenwasser opened this issue Feb 1, 2017 · 3 comments
Closed

Mixin classes don't allow constructors of 'object' types #13805

DanielRosenwasser opened this issue Feb 1, 2017 · 3 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Feb 1, 2017

type Constructor<T> = new (...args: any[]) => T;

export const Timestamped = <CT extends Constructor<object>>(Base: CT) => {
    return class extends Base {
        timestamp = new Date();
    };
}

Expected: It just works
Actual: It doesn't work - I get an error on Base in the extends clause stating that object is not a class or interface type.

This makes little sense given that this is a better restriction than {}.

@DanielRosenwasser
Copy link
Member Author

@ahejlsberg can you merge this into release-2.2?

@ahejlsberg
Copy link
Member

@DanielRosenwasser Can you get @mhegazy or someone else to do it?

@mhegazy
Copy link
Contributor

mhegazy commented Feb 14, 2017

it is already merged.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants