cf.completefrontend

Write the codeHard

Type the Tagged mixin so the class it returns keeps the base class's members and constructor.

Tagged(Base) returns a subclass of Base with a tags array and a chainable tag(name) method. With Base: any, every instance is effectively any. Type it so the result has the base class's members and constructor parameters plus tags and tag, and so passing something that isn't a class is an error.

Write this
function Tagged(Base: any) {  return class extends Base {    tags: string[] = [];     tag(name: string) {      this.tags.push(name);      return this;    }  };} // class Photo { constructor(public url: string) {} }// const TaggedPhoto = Tagged(Photo);// const photo = new TaggedPhoto("cat.png").tag("cute");// photo.url;  // string// photo.tags; // string[]

Solve it in the editor

The answer

Write it yourself first. Then compare it with a reference solution and the checks it passes.

Checking your sign-in…