JSDoc tag

@extends and @augments

  • Checked by TypeScript
  • Tested with TypeScript 5.9
  • Alias @augments

In JavaScript you cannot write class Tally extends Map<string, number>. @extends {Map<string, number>} above the class says the same thing, and TypeScript checks every inherited method with those types. @augments is another name for the same tag.

The tag only supplies type arguments. The class still needs its own extends Map clause; the tag never creates inheritance.

At a glance

Use JSDoc in a .js file TypeScript in a .ts file
A generic base class /** @extends {Map<string, number>} */ class Tally extends Map {} class Tally extends Map<string, number> {}

Examples

tally.js tally.ts TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026: No errors. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. No errors. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. No errors. checked 21 October 2026
/** @extends {Map<string, number>} */
export class Tally extends Map {
  /** @param {string} key */
  bump(key) {
    this.set(key, (this.get(key) ?? 0) + 1);
    return this;
  }
}

const views = new Tally();
views.bump("home").bump("cart");
views.get("home")?.toFixed(0);
export class Tally extends Map<string, number> {
  bump(key: string) {
    this.set(key, (this.get(key) ?? 0) + 1);
    return this;
  }
}

const views = new Tally();
views.bump("home").bump("cart");
views.get("home")?.toFixed(0);
Giving a generic base class its type argument with @extends.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": ["*.js"]
}
tags.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: tags.js(11,10): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. tags.js(11,10): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. tags.js(11,10): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. checked 21 October 2026
/** @augments {Set<string>} */
export class TagSet extends Set {
  /** @returns {string} */
  toLabel() {
    return [...this].sort().join(", ");
  }
}

const tags = new TagSet(["cotton", "summer"]);
tags.add(42);error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
The type argument from @augments (the other name for @extends) is checked on every call.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": ["*.js"]
}
tally.js TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026: No errors. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. No errors. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. No errors. checked 21 October 2026
export class Tally extends Map {
  /** @param {string} key */
  bump(key) {
    this.set(key, (this.get(key) ?? 0) + 1);
    return this;
  }
}

// No error: the base class is Map<any, any>, so a number key and a string value pass.
new Tally().set(1, "one");
Without @extends, a generic base class gets any for its types.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": ["*.js"]
}

When you need it

Only when the base class is generic. Extending Map, Set, Array or your own generic class leaves the type parameters as any unless you supply them, as the third example shows: new Tally().set(1, "one") passes because the base is Map<any, any>.

A class that extends a non-generic class needs no tag at all; extends Base is enough.

Rules TypeScript applies

The type in the tag must name the same class as the extends clause; @extends {Set<string>} on extends Map is TS8023 ("JSDoc '@extends Set' does not match the 'extends Map' clause"). The tag works only on classes; the handbook notes that a constructor function cannot extend a class this way.

A class with @extends and no extends clause gets no error and no base class either: TypeScript 5.9 ignores the tag in that case, so make sure the clause is there.

Gotchas

  • Give the type arguments in the order the base class declares its type parameters: Map<K, V> takes the key type first.
  • To type a subclass's own generic parameter, combine the tags: @template T and @extends {Set<T>}.

Questions

What is the difference between @extends and @augments?

None. TypeScript and the JSDoc documentation tool treat them as the same tag.

Sources

Last reviewed 20 October 2026.