Skip to content

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

Closed
@DanielRosenwasser

Description

@DanielRosenwasser
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 {}.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions