TypeScript Syntax and Type Operators

Polymorphic this — subtype-preserving return

A this type in a class member refers to the receiving instance type, including a derived subtype. Returning this from a fluent base method therefore keeps subclass-specific members available in chained calls. It differs from an explicit receiver parameter and from returning the fixed base-class type. A method with return type this cannot generally return a freshly constructed base instance. Example output: "ready". Tested in the strict TypeScript 5.8.3 / ES2022 baseline; the example is not a runtime type validator.

Formal Syntax & Structure

typescript syntaxtypescript
class Builder { reset(): this { return this; } }

Working Example

Example Snippettypescript
class Builder { reset(): this { return this; } }class Report extends Builder { title = "ready"; }console.log(new Report().reset().title);
TypeScript Reference