#class User implements IUser

3 messages · Page 1 of 1 (latest)

cinder hull
#

Is there any benefit to doing this? or am I just typing 1 thing twice now? What's a good use case for implements?

export interface User {
    id: string;
}

export default class User extends Base implements IUser {
    constructor(id: string) {
        super();

        this.id;
    }
}
icy nebula
#

it can be useful if you have a bunch of classes that need to share a common interface

#

but yeah otherwise don't go out of your way to declare an interface like that where the class type would work just as well