Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardTypeScriptpolymorphic thisSingle-choice MCQ

Why does the `map` implementation need the `as this` assertion to satisfy the interface?

interface Box<T> { value: T; map(fn: (v: T) => T): this; } class NumBox implements Box<number> { constructor(public value: number) {} map(fn: (v: number) => number): this { return new NumBox(fn(this.value)) as this; } }