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.

Files & dependencies

Read imports and qualified names

TypeScript

Named imports use braces. node: identifies a Node built-in module. Imports make this file a module; export exposes a declaration to other modules.

Fragment

Complete Node module.

main.ts
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
import { stdin, stdout } from "node:process";

stdout.write("north\n");

Read public and private boundaries

TypeScript

export exposes a module name; it is distinct from class member visibility. TypeScript private is a checker restriction; JavaScript # fields enforce private access at runtime. Type-only exports are erased.

Fragment

Fragment: imports and type/function declarations at file scope; usage statements inside a function.

main.ts
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
export interface Named {
  name: string;
}

export const defaultName = "north";
const internalName = "west";

Split code across local files

TypeScript

Relative module specifiers depend on the execution/build workflow. This example targets emitted JavaScript in Node ESM, so it names .js in the TypeScript import. Direct Node TypeScript execution instead requires the actual .ts path.

Fragment

Two file fragments; Node ESM package. Direct-source and emitted workflows use different extensions.

main.ts
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
// names.ts
export const name = "north";

// main.ts — compiled Node ESM workflow
import { name } from "./names.js";
console.log(name);

Recognize manifests and compiler configuration

TypeScript

package.json describes a package and scripts/dependencies; tsconfig.json configures TypeScript. A lockfile records resolved dependencies for its package manager. Node type stripping does not use tsconfig to type-check the program.

Fragment

Comment-labeled configuration fragment, not TypeScript source. Strict null checking is enabled by strict.

main.ts
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
// tsconfig.json fragment
{
  "compilerOptions": {
    "strict": true,
    "target": "ES2023"
  }
}

Recognize dependency commands

TypeScript

Node built-ins such as node:fs need no npm install. npm install adds a dependency to a package; --save-dev records development tooling. Installing a package and importing a name from it are separate steps.

Fragment

Illustrative shell commands only; no package is installed by this reference. Type declarations may be separate.

main.ts
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
# In an initialized npm package:
npm install lodash
npm install --save-dev typescript