TypeScript Reference

Last updated: 2026-10-22

TypeScript Reference

Alphabetical list of 70 TypeScript type entries: basic types, composition, functions & classes, generics, narrowing & assertions, utility types and engineering.

#
!The non-null assertion (postfix !) tells the compiler "this value is definitely not null/u...
"a" | "b"Literal types promote a value into a type: "up", 1 and true are all types. Alone they are ...
(arg) => RArrow functions have built-in annotation syntax: a colon after parameters, and the express...
(arg: T) => RA function type expression describes the shape of a class of functions: parameters, =>, re...
...rest: T[]Rest parameters (...scores: number[]) collect all remaining arguments into a real array, l...
.d.tsDeclaration files (.d.ts) describe what a library looks like without containing any implem...
?: / readonly? marks a property optional (it may be absent); readonly marks it read-only (cannot be rea...
@decoratorA decorator is special syntax (@name) placed before classes, methods, properties or parame...
[K in keyof T]A mapped type walks keys and transforms values: [K in keyof T]: boolean generates a same-n...
[key: string]: TIndex signatures describe objects with arbitrary keys but a uniform value type — dictionar...
[T, U]A tuple is an array type with fixed length and per-position types — ideal for coordinates,...
`${T}`Template literal types concatenate at the type level: `${A}-${B}` enumerates every combina...
A
A & BAn intersection A & B merges several types: the value must satisfy A and B simultaneously....
A | BA union A | B means "the value is A or B". You must narrow it first (typeof, in, ...) so t...
abstract classAn abstract class is a half-finished base class: it can carry real implementation while de...
anyany means "opt out of type checking": anything is assignable to it and it is assignable to...
arg?: T? marks an optional parameter (may be omitted), = gives one a default (used when omitted)....
Array<T>Array types describe "a list of same-typed elements", written either T[] or Array<T> — ful...
asA type assertion (as) tells the compiler "I know this value's type better than you do — tr...
as constas const freezes a literal into its deepest constant type: every property becomes readonly...
assertNeverExhaustiveness checking is compile-time insurance that every member of a union has been ha...
Awaited<T>Awaited<T> mirrors the type effect of await: unwrapping Promise<T> into T, recursively exp...
B
booleanboolean has exactly two values, true and false. Use it for feature flags, conditions and c...
C
classA class bundles data and behavior: fields hold state, the constructor initializes, methods...
class<T>A generic class (class Stack<T>) binds the class structure to the stored data type: a Stac...
contextualContextual typing: when a function literal sits in a position whose type is already known ...
E
enumEnums group related constants under one namespace, where members are both types and values...
Exclude<T, U>Exclude<T, U> removes members of union T that are assignable to U — typically trimming bra...
F
function <T>Generic functions use a type parameter <T> to turn "types" into arguments: one piece of lo...
H
HTMLElement/EventAll DOM types come from TypeScript's built-in DOM lib: elements form an inheritance chain ...
I
implementsimplements makes a class claim an interface: the compiler verifies the class provides ever...
import/exportES Modules is the official JavaScript module standard. TypeScript reuses export/import syn...
inThe in operator checks whether a property name exists on an object, and TypeScript narrows...
in / outVariance describes how a type parameter inside a composite type affects overall compatibil...
inferinfer captures a type inside a conditional's true branch: T extends Array<infer U> ? U : n...
instanceofThe instanceof guard works on unions of classes: it checks whether a value is an instance ...
interfaceAn interface gives an object shape a name: it declares which properties and methods exist ...
interface<T>A generic interface takes type parameters (interface ApiResult<T>), decoupling the contain...
K
keyofkeyof T collects every key of an object type T into a literal union: keyof Settings is "vo...
kindA discriminated union (also called a tagged union) ties a group of types together with a c...
N
name(arg: T): RFunction annotations declare parameter and return types: callers see at a glance what to p...
narrowingA union type packs several possibilities into one variable, so before using it you must fi...
nevernever means "no value ever": functions that throw or loop forever return it. At the type l...
new () => TA construct signature new (name: string) => T describes "this value can be new-ed into a T...
NonNullable<T>NonNullable<T> strips null and undefined from T. It fits cases where a field may be empty ...
null / undefinednull means "intentionally empty"; undefined means "not assigned / missing". With strictNul...
numbernumber covers both integers and decimals — JS has only one numeric type. Counts, prices, c...
O
object typeObject types describe an object via "property: type" pairs: inline them for one-off use, n...
Omit<T, K>Omit<T, K> drops the properties named by K from T and keeps the rest as a new type. Typica...
overloadsOverload declarations give one function several signature sheets: callers get a precise re...
P
Parameters<T>Parameters<T> extracts the parameter list of a function type T as a tuple type. With it yo...
Partial<T>Partial<T> makes every property of T optional: perfect for "partial updates" (form drafts,...
Pick<T, K>Pick<T, K> plucks the properties named by K out of T into a new type. When you only need a...
Promise<T>Async types revolve around Promise<T>: an async function's return type is automatically wr...
public / private / protectedAccess modifiers control member visibility: public (default, accessible everywhere), priva...
R
Readonly<T>Readonly<T> makes every property of T read-only: reassigning a property after creation is ...
Record<K, V>Record<K, V> builds an object type with keys K and values V. K can be a literal union (enu...
ReturnType<T>ReturnType<T> extracts the return type of a function type T. The idiom is ReturnType<typeo...
S
stringstring represents text. Use it for names, messages, IDs — any data that lives as character...
symbol / bigintsymbol creates globally unique, unrepeatable values — good for object keys and constant to...
T
T = DefaultType parameters can have defaults (<T = string>): omitted means the default applies, speci...
T extends UA constraint (extends) bounds a type parameter: <T extends HasId> promises "T has at least...
T extends U ? X : YConditional types let types take an exam: T extends U ? X : Y — pick X if the condition ho...
try / catchTypeScript error handling has two pain points: the catch variable is unknown under strict ...
tsconfig.jsontsconfig.json is the master switch of a TypeScript project: placed at the project root, it...
typetype names any type — objects, unions, tuples, functions, literals — making it the most ge...
typeofThe typeof guard is the most common type guard: at runtime typeof returns a type string fo...
U
unknownunknown is the safe any: any value is assignable to it, but it must be narrowed or asserte...
V
voidvoid means "no meaningful return value". Use it for loggers and event callbacks to tell ca...
X
x is TWhen built-in guards (typeof/instanceof/in) fall short, write your own guard function: dec...
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏