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
/** @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);jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.js"]
} /** @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'.jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.js"]
} 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");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 Tand@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
- JSDoc Reference: @extends · TypeScript handbook
- @augments · JSDoc
Last reviewed 20 October 2026.