Reference

Programming languages

Choose TypeScript, Go, Rust or C++ and find syntax, everyday APIs, standard libraries and tools in one place.

Scope and conventions

TypeScript/Node, Go 1.23+, Rust 2024 and C++23: from a first CLI to files, JSON, HTTP, concurrency and testing. Complete programs are labeled; other examples identify their surrounding code/imports. Optional libraries and version requirements are named in each entry.

Libraries: tools & testing

The toolchain around the code: building and packaging, testing, formatting and linting, debugging and profiling, and documentation.

Toolchain: node/npm/tsc, the go command, cargo, compilers + CMake

TypeScript

The TypeScript toolchain is several tools: node runs JavaScript, npm installs the packages listed in package.json and runs its scripts, npx runs a package's command without a global install, and tsc (the TypeScript compiler) type-checks and emits JavaScript. Newer Node versions can run .ts files by stripping types (enums, namespaces and parameter properties are rejected, and relative imports need .ts extensions), but only tsc checks them; tsx is the common development runner. Use npm ci in CI to install exactly what the lockfile says. pnpm, yarn and bun are alternative package managers.

Fragment

Terminal commands, run from the project folder.

terminal
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
node --version              # the runtime that executes JavaScript
npm init -y                 # create package.json
npm install zod             # add a dependency (package.json + package-lock.json)
npm install -D typescript   # add a development-only tool
npx tsc --init              # run a locally installed tool: create tsconfig.json
npx tsc                     # type-check and compile .ts to .js
node dist/main.js           # run the compiled output
npm test                    # run the "test" script from package.json

Most used: npm install, npm run <script>, npx, tsc --noEmit for type-checking only, package.json scripts, tsconfig.json.

Testing: node:test, testing, #[test], GoogleTest

TypeScript

node:test is Node's built-in test runner (test, describe and it, mocks, hooks), and node:assert supplies assertions; use node:assert/strict so equal compares with Object.is (like ===, except NaN equals NaN and +0 differs from -0). node --test finds and runs test files. Many projects use Vitest or Jest instead, which add watch mode and richer matchers but follow the same describe/it shape.

Complete file

A test file. Running .ts files directly needs a Node version with type stripping; otherwise compile with tsc first.

total.test.ts
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
// total.test.ts, run with: node --test
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';

function total(prices: number[]): number {
  return prices.reduce((sum, price) => sum + price, 0);
}

describe('total', () => {
  it('adds prices', () => {
    assert.equal(total([40, 15]), 55);
  });

  it('is zero for no prices', () => {
    assert.equal(total([]), 0);
  });
});

Most used: describe, it/test, assert.equal, assert.deepEqual, assert.throws, assert.rejects, mock.fn, node --test.

Formatting & linting: Prettier/ESLint, gofmt/vet, rustfmt/Clippy, clang-format/tidy

TypeScript

TypeScript projects usually combine three tools: tsc --noEmit for type errors, Prettier for formatting, and ESLint with typescript-eslint for lint rules such as unused variables, unsafe any and floating promises. Biome is a single, faster tool that formats and lints. All are installed per project as dev dependencies and run through npx or package.json scripts, usually in CI and pre-commit hooks.

Fragment

Terminal commands, run from the project folder.

terminal
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
npx tsc --noEmit            # type-check without writing files
npx prettier --check .      # report unformatted files (--write fixes them)
npx eslint .                # lint with typescript-eslint rules
npx eslint . --fix          # apply automatic fixes
npx biome check --write .   # one fast tool for formatting and linting

Most used: tsc --noEmit, prettier --check and --write, eslint . --fix, eslint.config.js, typescript-eslint, biome check, .editorconfig.

Debugging & profiling tools: inspector, Delve + pprof, LLDB + flamegraph, sanitizers

TypeScript

Node includes the V8 inspector: --inspect (or --inspect-brk to pause on the first line) lets Chrome DevTools or VS Code set breakpoints, step through code and inspect values, and a debugger statement pauses at that line. --enable-source-maps maps stack traces back to TypeScript lines when tsconfig emits source maps ("sourceMap": true). --cpu-prof and --heap-prof write profiles that DevTools opens, and 0x produces flame graphs.

Fragment

Terminal commands, run from the project folder.

terminal
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
node --inspect-brk dist/main.js          # pause at start; attach Chrome DevTools or VS Code
node --enable-source-maps dist/main.js   # stack traces point at .ts lines
node --cpu-prof dist/main.js             # write a .cpuprofile to open in DevTools
node --heap-prof dist/main.js            # sample allocations to find memory growth
node --watch dist/main.js                # restart on changes (run tsc --watch alongside)

Most used: node --inspect and --inspect-brk, debugger;, chrome://inspect, VS Code launch.json, --enable-source-maps, --cpu-prof, --heap-prof, console.time.

Documentation tools: TSDoc/TypeDoc, go doc, rustdoc, Doxygen

TypeScript

JSDoc and TSDoc comments (/** ... */) above declarations document parameters, return values and examples. Editors show them on hover and in autocomplete, so they are the main way TypeScript code is documented. TypeDoc generates a website from them, and API Extractor produces reviewed API reports for libraries. Package-level documentation usually lives in the README shown on npm.

Complete program

Complete program. Built in: globals need no import; node: modules ship with Node.

main.ts
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
/**
 * Adds tax to a price in cents.
 *
 * @param cents - Price before tax, in cents.
 * @param rate - Tax rate as a fraction, for example 0.2 for 20%.
 * @returns The price including tax, rounded to whole cents.
 * @example
 * withTax(1000, 0.2); // 1200
 */
export function withTax(cents: number, rate: number): number {
  return Math.round(cents * (1 + rate));
}

console.log(withTax(1000, 0.2));

Most used: /** ... */, @param, @returns, @example, @deprecated, @see, {@link Name}, TypeDoc (npx typedoc src/index.ts).