Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>The Real Doctest TSNew to Visual Studio Code? Get it now.
The Real Doctest TS

The Real Doctest TS

Kanso

|
115 installs
| (0) | Free
Extension to run TSDoc examples
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

The Real Doctest TS

Run TSDoc @example tags like unit tests. All equality expression statements are checked like a unit test

Example Usage

/**
 * @param n
 * @returns the sum of the n first integers
 * @example
 * const n = 5
 * const expected = 1 + 2 + 3 + 4 + 5
 * const actual = nsum(n)
 * actual == expected
 * @example nsum(3) == 1 + 2 + 3
 * @example nsum(8) == 42 // This should fail
 */
function nsum(n: number): number {
  return n * (n + 1) / 2
}

Setup

Run npm i -D the-real-doctest tsx in your typescript project root

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft