seniorTypeScript
Explain 'Polymorphic this' and its impact on class inheritance.
Updated May 4, 2026
Short answer
The 'this' type allows a method to return the type of the current class instance, even if it is a subclass.
Deep explanation
When a base class method returns this, TypeScript dynamically resolves that type to the actual instance at the call site. This is essential for 'Fluent APIs' or 'Builder Patterns' where a method is defined in a base class but must return the derived type to keep derived methods accessible in a chain[cite: 1].
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro