103 terms across 10 categories
private is a TypeScript visibility modifier that exists only in the type system. #field is a JavaScript private field that the engine actually hides. They can be used together, but they are not the same feature.
An abstract class is a class you cannot new. It can include real method bodies and abstract method stubs that subclasses must implement. The abstract pieces are erased; the rest is a normal JavaScript class.
Access modifiers (public, protected, private, plus readonly) restrict who may read or write a class member in the type system. public is the default. Only # fields are private at runtime.
A TypeScript class is a JavaScript class plus types for its fields, constructor, and methods. The type of an instance is the public instance shape; the class itself also has a construct signature.
implements asks the compiler to check that a class's public instance shape matches one or more interfaces (or object types). It does not exist at runtime and it is not required for assignability.
A class inherits with extends. The subclass gets the parent's instance members, may override methods, and must call super() if it has its own constructor. Types flow the same way: a subclass instance is assignable to the parent type.
override marks a class member that is meant to replace a member of a superclass. If the superclass has no such member, the compiler errors. noImplicitOverride requires the keyword on every override.
A parameter property is a constructor parameter with public, private, protected, or readonly that also declares and assigns a class field of the same name. It is TypeScript syntax and erases to an ordinary assignment.
public, private, and protected are the three visibility keywords on class members. public is open, private is the declaring class only, protected is the class and its subclasses. All three are type-system checks.
A static member belongs to the class constructor, not to an instance. You write static and call it as User.create(...). Its type lives on typeof User, not on User.
this as a type means "the type of the current instance," including subclasses. A method that returns this stays fluent: a subclass call returns the subclass, not the base.
An adapter converts one type into another so a foreign API can satisfy your interface. In TypeScript that conversion is a pair of functions (or a class) whose parameter and return types are the two shapes.
A builder is an object that collects configuration through fluent methods and then produces a value. In TypeScript the type of the builder can grow as you set fields, so a missing required field is a compile error on build().
Dependency injection means a type receives its collaborators as constructor arguments (or parameters) instead of importing concrete instances. TypeScript types those collaborators as interfaces so tests can pass fakes.
As a design pattern, a discriminated union is how you model a closed set of states in TypeScript instead of a class hierarchy or a pile of optional fields. One tag field, one object type per state, one switch.
A facade is a narrow type in front of a messy subsystem. Callers import one module and one interface. The implementations, overloads, and third-party types stay behind that door.
A factory is a function (or static method) that returns a new object without the caller using new on a concrete class. In TypeScript you type the input as a discriminant or a map of constructors, and the return type follows the input.
A mixin is a function that takes a class and returns a new class with extra methods. In TypeScript you type that as a generic constructor in and an intersection (or a subclass) out.
A repository is a type that hides how a collection of entities is stored. In TypeScript it is usually a generic interface, Repo, plus one implementation per storage engine.
any turns the type checker off for a value. unknown means "a value is here, but you may not use it until you narrow it." Prefer unknown whenever you do not yet know the type.
as const is a const assertion. It tells the compiler to infer the narrowest literal types and to treat properties and array elements as readonly.
A conditional type picks one of two types by testing assignability, written T extends U ? A : B. It is a type-level if.
A const enum is an enum that emits no runtime object. The compiler replaces every use with the member's literal value. It is faster and smaller than a regular enum, and it breaks under any build tool that compiles one file at a time.
A declaration file (.d.ts) is TypeScript that describes types and stops there. It has no runtime code. The compiler uses it to type-check imports of JavaScript that has already been compiled or that was written by hand.
Declaration merging is TypeScript's rule that two or more declarations with the same name in the same scope combine into a single type. Interfaces, namespaces, and enums merge; type aliases do not.
A default type parameter fills a generic hole when the caller does not specify it and inference cannot either. You write it as T = Fallback after any constraints.
A discriminated union is a union of object types that all carry the same property, where that property holds a different literal value in each member. Checking that one property tells the compiler exactly which member you are holding.
An enum declares a named set of related constants, such as the statuses an order can have. It is one of the few TypeScript features that is not erased — an enum compiles into a real JavaScript object that exists at runtime.
esModuleInterop changes how TypeScript types and emits default imports from CommonJS modules. With it on, import fs from "fs" matches the way many runtimes actually expose module.exports.
Exhaustiveness checking is making the compiler prove that you handled every member of a union. Add a new case to the union and the build fails in each place that forgot it, instead of failing in production.
A generic constraint limits what types may fill a type parameter, written T extends Shape. Inside the generic, you may use the members Shape guarantees.
A generic is a type parameter: a placeholder you fill in later with a real type. One function or type can then work on many types without falling back to any.
An indexed access type reads the type of a property, written T[K]. K must be a key of T, and the result is the type stored at that key.
infer declares a new type variable inside a conditional type's extends clause. If the match succeeds, that variable is bound to the matched piece and can be used in the true branch.
An interface names an object shape: the properties, optional fields, and call signatures a value must have. Two interfaces with the same name in the same scope merge into one.
An intersection type, written A & B, describes a value that satisfies both types at once. For object types this means the result has every member of both.
keyof T is the union of T's public property names as string or number literal types. For { id: string; name: string } it is "id" | "name".
A literal type allows exactly one value. "GET" is a type containing only the string "GET", and 200 is a type containing only that number. Combined with unions, literal types describe a fixed set of allowed values.
A mapped type builds a new object type by walking the keys of an existing type, written `{
Module resolution is the algorithm TypeScript uses to turn an import specifier into a file on disk (and into that file's types). It is controlled by moduleResolution and must match how your runtime or bundler resolves the same specifier.
A namespace is TypeScript's older way to group values and types under one name, written namespace App { ... }. New code should use ES modules instead. Namespaces still appear in .d.ts files and in declaration merging.
never is the type of a value that cannot exist. A function that always throws or loops forever returns never. A union member that has been fully narrowed away becomes never.
noImplicitAny is the compiler flag that errors when TypeScript would otherwise silently give a value the any type. It does not ban any you wrote on purpose.
Nominal typing decides compatibility by declared identity: a value fits a type only if it was declared to be that type. Structural typing decides by shape. TypeScript is structural, with a few deliberate exceptions.
The non-null assertion is a postfix ! that removes null and undefined from a value's type. It is a promise to the compiler, checked by nobody, and it disappears when the code is compiled.
Partial, Required, Pick, and Omit are built-in mapped types that reshape an object type: make every field optional or required, or keep or drop a set of keys.
Project references split a TypeScript codebase into smaller tsconfig projects that declare dependencies on each other. The compiler builds them in order and uses each project's .d.ts output as the types for its dependents.
readonly is a type-level modifier that removes writes from a property, array, or tuple. It does not freeze the value at runtime.
satisfies checks that an expression matches a type without changing the type the compiler inferred for it. You get validation against a contract and the precise literal type of what you actually wrote.
strict is a single tsconfig.json option that switches on the whole family of strict type-checking flags at once. It is unrelated to JavaScript's "use strict" directive, which is a runtime feature.
strictNullChecks is the compiler flag that removes null and undefined from every other type. Absence becomes a union you have to handle before you read a property.
Structural typing means TypeScript decides whether two types are compatible by comparing their shapes, not their names. If a value has the members a type requires, it is accepted as that type.
A template literal type builds a string literal type from other string types, using the same ${...} syntax as a JavaScript template string. The result is a type, not a runtime string.
A triple-slash directive is a comment of the form /// at the top of a file. It tells the compiler to include another file, a lib, or a set of types before type-checking the current file.
tsconfig.json is the file that tells the TypeScript compiler which files to include and which checks and emit settings to use. tsc looks for it starting from the current directory and walking up.
A tuple is an array type with a fixed length and a type for each position, written [string, number]. Index 0 and index 1 are different types, unlike a normal array.
A type alias gives a name to a type with the type keyword. The name is an alias, not a new type: anything assignable to the right-hand side is assignable to the name.
A type annotation is a note you attach to a variable, parameter, or return value that tells the TypeScript compiler what kind of value belongs there. The compiler checks your code against that note, then deletes it before the JavaScript runs.
A type assertion tells the compiler to treat a value as a different type than it inferred. It changes nothing about the value at runtime; it only changes what the type checker believes.
A type guard is a runtime check the compiler understands, so it can narrow a union or unknown inside a block. Built-in checks include typeof, instanceof, and in. You can also write your own predicate functions.
Type inference is TypeScript working out the type of a value from code you already wrote, so you do not have to state it. Most types in a well-written TypeScript file are inferred rather than annotated.
For describing the shape of an object, type and interface are close to interchangeable. They differ in what else each can do: interfaces merge and are built for extension, while type aliases can name unions, tuples, and computed types.
undefined means a value was never set. null means a value was deliberately emptied. Under strictNullChecks, neither is assignable to an ordinary type unless you write it into the union.
A union type describes a value that is one of several types, written A | B. Until you narrow it, you may only use the members that every branch of the union has in common.
Utility types are generic types shipped with TypeScript that transform other types. They live in the compiler's standard library and are erased at compile time.
void is the type of a function whose return value the caller is not allowed to use. It is not the same as undefined, and it is not the same as never.
An array type describes a list whose elements all share one type, written T[] or Array. Adding readonly gives you the same list seen through a narrower type that has no mutating methods on it.
A branded type is a type alias intersected with a unique phantom property so the compiler will not mix it with the underlying type. UserId and OrderId can both be strings at runtime and stay distinct in TypeScript.
An index signature states the type of properties accessed by a dynamic key, written `
Map and Set are the standard ES collections, typed with generics. .get returns V | undefined. .has is a boolean and does not narrow the map's value type by itself.
Record is the built-in mapped type for "an object whose keys are K and whose values are V." K is usually a string-literal union or string.
A tuple can stand in for a small record: a fixed list of fields identified by position (and, optionally, by a label). Use it when order is the API. Prefer a named object when the fields have independent meaning.
A typed object is a value described by an object type: a list of properties, each with a type, optionality, and maybe readonly. Assignability is structural. Fresh literals get extra excess-property checks.
An async function always returns a Promise. await unwraps a Promise to T (and recursively unwraps nested thenables). The syntax is JavaScript; TypeScript types the unwrap.
The event loop is the JavaScript runtime's scheduler: call stack, then microtasks (promise jobs), then macrotasks (timers, I/O). TypeScript does not replace it. Types describe callbacks; they do not change when those callbacks run.
Promise is the generic interface for a thenable that fulfills with T. T is the success value. Rejections are not modeled as a second type parameter.
A promise is typed as Promise, where T is the value it fulfills with. TypeScript follows then, catch, and await and unwraps T. It does not run the promise.
Web Workers and Node worker threads talk through messages. TypeScript does not type postMessage by default beyond any. You add a protocol: a discriminated union for messages, and a typed wrapper around onmessage.
DOM types are the TypeScript interfaces for the browser platform: Document, HTMLElement, HTMLInputElement, Event, NodeListOf. They come from lib.dom and describe the real objects the engine gives you.
Event types are the TypeScript interfaces for platform and framework events: MouseEvent, KeyboardEvent, InputEvent, and React's ChangeEvent. The listener's parameter type comes from the event name.
JSX types are how TypeScript checks ` syntax. The jsx compiler option picks the emit, and the JSX namespace (usually from @types/react`) maps tag names to prop types.
lib.dom is the built-in declaration bundle for the browser: window, document, fetch, HTMLElement, and the rest of the web IDL as TypeScript sees it. You opt in with "lib": ["DOM", ...] or a target that includes it.
React props are the object passed to a function component. In TypeScript you type that object, and JSX checks attributes against it. Extra attributes on a component are errors; missing required ones are errors.
fetch is typed in lib.dom as returning Promise. Response.json() is Promise. Your job is to treat the body as unknown and validate it into a type.
Type erasure means every type annotation, interface, and generic is removed when TypeScript emits JavaScript. The running program has values, not types. Nothing is allocated for a type.
Garbage collection is the JavaScript engine's job: unreachable objects are reclaimed. TypeScript types do not keep objects alive and do not free them. A type can only hide a reference you still hold in the JavaScript.
WeakMap, WeakSet, and WeakRef hold references that do not keep the target object alive. TypeScript types them as generics whose keys or targets must be objects (or symbols, for WeakMap).
A generic algorithm is a function whose implementation does not depend on one element type. You write it once with a type parameter, and the compiler keeps the element type through the result.
Recursion is a function (or a type) that refers to itself. At runtime, a recursive function walks a value. At the type level, a recursive type describes that value, and a recursive conditional type transforms it.
A sliding window maintains a contiguous slice of an array as two indices move. TypeScript's job is to type the source, the window, and the aggregate so the slice is not an any[].
Space complexity is how an algorithm's extra memory grows with input size. TypeScript types do not occupy runtime memory. The collections you choose — and whether you copy them to satisfy a type — do.
Time complexity is how an algorithm's runtime grows with input size. TypeScript does not change that growth: types are erased. What it does change is how you type the inputs so the compiler cannot hide a linear scan behind a wrong collection type.
Two pointers is an array technique that moves a pair of indices toward a goal. In TypeScript the interesting part is typing the array, the indices, and the pair you return, so an out-of-bounds read is visible.
A recursive type mentions its own name in its definition. It is how you type trees, linked lists, nested comments, and JSON. The recursion must go through an object or array member.
Jest runs tests. TypeScript types those tests if you compile them with ts-jest, babel-jest plus a preset, or by emitting first. Jest's own types (jest.fn, expect) live in @types/jest or in the jest package.
Mock typing is giving a fake the same type as the real collaborator so the test cannot call methods that do not exist or return the wrong shape. Untyped mocks are any.
tsd is a tool that type-checks *.test-d.ts files and asserts about types: expectType, expectError, expectAssignable. It does not run your functions. It runs the type checker on purpose.
Typing tests means using TypeScript inside unit tests (so mocks and fixtures are checked) and writing tests of types (so a utility's result is the type you intended). They are different jobs.
Vitest is a Vite-native test runner with first-class TypeScript. It transpiles tests through Vite (esbuild / rolldown) and types its APIs. It can also assert types with expectTypeOf when you turn that on.
An ORM model is the TypeScript type (and often class) that stands for a database table. It is a claim about columns. It is not the table. Generated models stay accurate; hand-written ones drift.
Prisma generates a TypeScript client from your schema: a PrismaClient instance and types for each model, input, and query variant. The types match the schema at generate time, not at query time.
SQL injection is building a query string with untrusted text so the engine runs attacker SQL. TypeScript's types will not stop this. Parameterized queries and tagged templates will.
A typed query result is a TypeScript type for the rows a database driver returns. Drivers usually give any or a generic Row. You map that into a named type after you know the columns.