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

A factory method should return an instance of whatever subclass it was called on. Which signature achieves this, and why can't the instance `this` *type* be used instead?

class Model { /* ??? */ create(/* ??? */) { return new this(); } } class User extends Model { name = "x"; } const u = User.create(); // want: typed as User