TypeScript Syntax References

TypeScript syntax quick reference for types, interfaces and generics, from the official TypeScript Handbook. Every item below is clearly marked as a shortcut, command, or syntax reference.

Most Useful TypeScript Syntax References

TypeScriptSyntax

Annotate a Variable Type

Code example
let name: string = "Ada";

Declares the type of a variable.

Learn More
TypeScriptSyntax

Typed Function

Code example
function add(a: number, b: number): number { return a + b; }

Types a function's parameters and return value.

Learn More
TypeScriptSyntax

Define an Interface

Code example
interface User { id: number; name: string; }

Describes the shape of an object.

Learn More
TypeScriptSyntax

Array Type

Code example
const nums: number[] = [1, 2, 3];

Types an array of values.

Learn More
TypeScriptSyntax

Define a Type Alias

Code example
type ID = string | number;

Names a type so it can be reused.

Learn More
TypeScriptSyntax

Union Type

Code example
let id: string | number;

Allows a value to be one of several types.

Learn More
TypeScriptSyntax

Basic Primitive Types

Code example
string, number, boolean, bigint, symbol, null, undefined

The built-in primitive types.

Learn More
TypeScriptSyntax

Typed Arrow Function

Code example
const add = (a: number, b: number): number => a + b;

Types an arrow function.

Learn More

More TypeScript Syntax References

Frequently Asked Questions

What does this TypeScript syntax reference cover?

It covers 36 common TypeScript patterns and examples, including Annotate a Variable Type, Typed Function, Define an Interface, Array Type, Define a Type Alias.

Can I copy the TypeScript examples?

Yes. Each reference page includes a copyable code example.

What affects these TypeScript examples?

Check the linked documentation for language or runtime version requirements. Libraries, file paths, terminal quoting and environment settings can differ across systems; no blanket platform compatibility is implied.