Skip to content

TSDoc Comments

A TSDoc comment is a multiline comment that documents the purpose and usage of your code.

/**
* Adds two numbers together.
* @example
* myFunction(1, 2);
* // Will return 3
*/
const myFunction = (a: number, b: number) => {
return a + b;
};

Now whenever you hover over this function, the signature of the function along with the comment and full syntax highlighting for anything below the @example tag:

myFunction(3, 4);
// hovering over myFunction shows:
const myFunction: (a: number, b: number) => number
Adds two numbers together.
@example
myFunction(1, 2);
// Will return 3