RecipesChapter 11: Classes

Working with this Types in Classes

Recipe 11.8 from The TypeScript Cookbook

class OptionBuilder<T = string | number | boolean> {
  // ...

  add(name: string, value: T): this {
    this.#options.set(name, value);
    return this;
  }
}
Open in TypeScript Playground →