The Glossary of TypeScript
Core Concepts
Superset — TypeScript is a strict syntactic superset of JavaScript, meaning any valid JavaScript file is also valid TypeScript; the language adds optional static typing on top rather than replacing anything underneath.
Static Typing — The practice of checking types at compile time rather than at runtime, letting TypeScript catch a whole class of bugs (wrong argument types, typos in property names, undefined access) before the code ever executes.
Transpilation — The process of converting TypeScript source into plain JavaScript, handled by the TypeScript Compiler (tsc) or a build tool; type annotations are stripped out entirely, since JavaScript engines have no concept of types.
Type Inference — TypeScript's ability to determine a variable's type automatically from its initial value or usage, without an explicit annotation — the reason most idiomatic TypeScript looks nearly identical to plain JavaScript.
Type Annotation — Explicit syntax (let age: number) for declaring a variable, parameter, or return value's type, used when inference isn't possible or when being explicit improves clarity.
Structural Typing — TypeScript's "duck typing" approach to type compatibility: two types are considered compatible if their shapes (the properties and methods they expose) match, regardless of their declared names — unlike nominal typing in languages like Java or C#.
tsconfig.json — The configuration file that controls how the TypeScript compiler behaves for a project: which files to include, which JavaScript version to target, and how strict the type checking should be.
strict Mode — A tsconfig.json flag that bundles together TypeScript's strongest type-safety checks (including strictNullChecks and noImplicitAny), widely considered best practice for any serious TypeScript codebase.
Type Erasure — The principle that TypeScript's types exist only during compilation and leave no trace in the emitted JavaScript, meaning types can never be inspected or relied upon at runtime.
The Type System
Primitive Types — TypeScript's basic building-block types, mirroring JavaScript's own: string, number, boolean, null, undefined, symbol, and bigint.
any — A type that opts a value out of type checking entirely, effectively telling the compiler to trust the developer; useful for gradual migration from JavaScript, but its overuse defeats the purpose of using TypeScript at all.
unknown — A type-safe counterpart to any: a value can be assigned to unknown, but the compiler forces a type check or assertion before it can be used, making it the safer default for genuinely uncertain values.
void — The return type for functions that don't return a meaningful value, distinct from undefined, which is an actual value a variable can hold.
never — The type representing values that never occur — used for functions that always throw or never return (like infinite loops), and useful for exhaustiveness checks in conditional and union type logic.
Union Type (|) — A type formed by combining multiple types with |, indicating a value can be one of several types (string | number), forcing code to narrow the type before using type-specific behavior.
Intersection Type (&) — A type formed by combining multiple types with &, producing a new type that has all the members of each combined type — commonly used to merge object shapes together.
Literal Type — A type that narrows a primitive down to one specific value ("success" as a type, not just string), often used in unions to model a fixed set of allowed values, like a state machine's states.
Type Alias (type) — A way to give a name to any type — primitive, union, object shape, or otherwise — via the type keyword, improving readability and letting complex types be reused.
Interface — A way to describe the shape of an object using the interface keyword; functionally similar to a type alias for object shapes, but interfaces support declaration merging and are generally preferred for defining public object and class contracts.
Type Narrowing — The process by which TypeScript refines a broader type (like a union) to a more specific one within a block of code, based on runtime checks like typeof, instanceof, or truthiness tests.
Type Guard — A function or expression that performs a runtime check and tells TypeScript how to narrow a type afterward, including custom user-defined guards written with an is return type predicate (function isCat(a: Animal): a is Cat).
Discriminated Union — A pattern combining a union of object types with a shared literal-type property (a "discriminant," often called kind or type), letting TypeScript narrow the exact variant based on that one property's value.
Generics & Advanced Types
Generics — A way to write reusable functions, classes, and types that work over a range of types rather than one specific type, using type parameters (function identity<T>(arg: T): T) filled in at the point of use.
Type Parameter — The placeholder (conventionally T, U, K, V) declared in angle brackets on a generic function, class, or type, standing in for whatever concrete type is supplied when it's actually used.
Generic Constraint (extends) — Syntax that restricts a generic type parameter to types matching a certain shape (<T extends { id: number }>), letting generic code safely access properties it knows will exist.
Utility Types — A set of built-in generic types TypeScript ships with for common type transformations, including Partial<T> (all properties optional), Required<T>, Readonly<T>, Pick<T, K>, Omit<T, K>, and Record<K, V>.
Mapped Type — A type that programmatically transforms every property of an existing type according to a rule ({ [K in keyof T]: T[K] }) — the mechanism most utility types are built from.
Conditional Type — A type-level if/else, written with extends ? : syntax (T extends U ? X : Y), that resolves to different types depending on whether one type is assignable to another.
infer — A keyword used inside conditional types to extract and name a type from within a larger type being matched against, commonly used to pull out a function's return type or an array's element type.
keyof — An operator that produces a union of literal string types representing all the property keys of a given type, commonly paired with generics and mapped types to write type-safe property access.
Template Literal Type — A type-level counterpart to JavaScript's template strings, allowing string types to be built and validated from combinations of literal and other types on${Capitalize<Event>}).
Type Assertion (as) — Syntax telling the compiler to treat a value as a specific type, overriding its inferred type without any runtime conversion — the developer asserting knowledge the compiler doesn't have, used sparingly since it bypasses safety checks.
Non-Null Assertion (!) — An operator that tells the compiler a value is definitely not null or undefined, suppressing the related type error without any runtime check — effectively a narrower, riskier cousin of as.
Functions, Classes & Modules
Function Type — A type describing a function's parameter and return types ((a: number, b: number) => number), used to type callbacks, variables holding functions, and interface methods.
Optional Parameter (?) — A function parameter or object property marked with ? that may be omitted, typed internally as a union with undefined.
Default Parameter — A function parameter that falls back to a specified value if no argument (or undefined) is passed for it, with TypeScript inferring the parameter's type from that default when no annotation is given.
Overload — Multiple function signatures declared for a single implementation, letting TypeScript report more precise parameter and return types depending on how the function is called.
Access Modifiers — Keywords (public, private, protected) that control the visibility of class members: public (the default) is accessible anywhere, private only within the declaring class, and protected within the class and its subclasses.
readonly — A modifier that prevents a property from being reassigned after initial assignment, enforced by the compiler — TypeScript's equivalent of a shallow immutability guarantee.
Abstract Class — A class marked abstract that cannot be instantiated directly and may declare abstract methods without implementations, meant to be extended by concrete subclasses that fill them in.
Enum — A construct for defining a named set of related constants (enum Color { Red, Green, Blue }), compiled into a real JavaScript object unlike most other TypeScript type constructs, which vanish at compile time.
Namespace — TypeScript's original construct (predating ES Modules) for organizing code into named, nested scopes; largely superseded by ES Modules in modern codebases but still found in older code and some declaration files.
Declaration File (.d.ts) — A file containing only type information, no implementation, used to describe the shape of existing JavaScript code — either hand-written for a library or auto-generated by the compiler — so TypeScript projects can type-check against it.
DefinitelyTyped / @types — A massive community-maintained repository of declaration files for JavaScript libraries that don't ship their own types, installed as @types/<package-name> packages from npm.
Tooling & Ecosystem
tsc (TypeScript Compiler) — The official command-line compiler that type-checks TypeScript code and emits plain JavaScript, the tool every other TypeScript-aware build system ultimately relies on or reimplements.
Type Checking vs. Transpiling — A distinction that matters in practice: fast bundlers like esbuild and swc transpile TypeScript to JavaScript by simply stripping types, without actually verifying them, so many setups run tsc --noEmit separately just for type checking.
ts-node — A tool that lets Node.js execute TypeScript files directly, compiling them on the fly, without a separate build step — convenient for scripts and development, though slower than pre-compiling for production.
ESLint + typescript-eslint — The standard linting setup for TypeScript, extending ESLint with rules aware of TypeScript's type system, catching issues plain JavaScript linting can't see.
Zod / io-ts — Runtime validation libraries that address a gap TypeScript's type erasure leaves open: since types disappear at runtime, these libraries let developers define a schema once and get both a runtime validator and an inferred static type from it.
JSDoc + // @ts-check — A way to get TypeScript's type checking on plain JavaScript files using comment-based type annotations, without converting the file to .ts — often a stepping stone for gradually adopting TypeScript in an existing codebase.
Type Coverage — A rough measure of how much of a codebase is meaningfully typed versus relying on any or implicit fallbacks, tracked by tools like type-coverage as a proxy for how much real safety a "TypeScript" project actually has.
Taken together, this glossary tells the story of a language built to answer one specific complaint: that JavaScript, at scale, lets mistakes hide until runtime. Structural typing and inference exist so that safety doesn't have to come at the cost of JavaScript's flexibility; generics and conditional types exist because real-world code needed to describe relationships between types, not just the types themselves; and the whole ecosystem of declaration files and @types exists to pull the vast, untyped world of existing JavaScript into that same safety net. Each term here marks a place where TypeScript chose to model something JavaScript left implicit — which is, in the end, the entire premise of the language.
*written with Claude Sonnet 5