Skip to content

Base constructor return type 'object' is not a class or interface type. #13975

Closed
@kikar

Description

@kikar

TypeScript Version: 2.2.0

Got this example from the 2.2 announcement

Code

export type Constructable = new (...args: any[]) => object;

export function Timestamped<BC extends Constructable>(Base: BC) {
    return class extends Base {
        timestamp = new Date();
    };
}

Expected behavior:
Extend my class with a timestamp.

Actual behavior:
Not compiling with error: "Base constructor return type 'object' is not a class or interface type."

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions