Type annotation
Explicitly writing a type for a variable/param/return. Example: let x: number = 3;
Type inference
TypeScript infers a type when you don’t annotate. Example: let x = 3; // x: number
Structural typing
Compatibility is based on shape (members), not “named” types. Example: {id:string} is assignable to any type requiring id:string
Assignability
Whether a value of type A can be used where type B is expected (A “assignable to” B). Example: “hi” assignable to string; string not assignable to “hi”
Literal type
A type that is a specific value. Example: “open” (not string), 1 (not number), true (not boolean).
Widening
When a literal becomes a broader primitive type in inference. Example: let s = “a”; // s: string (widened from “a”)
Const assertion (as const)
Freezes values to literal types + readonly. Example: const a = [“x”, 1] as const; // readonly [“x”, 1]
Type assertion (cast)
Telling TS “treat this as X” without runtime conversion. Example: value as SomeType
satisfies operator
Checks a value matches a type without changing the value’s inferred type. Example: const x = {a:1} satisfies Record<string, number>
any
Opt-out of type checking; anything goes. Example: let x: any = 1; x.foo.bar(); // allowed
unknown
Top type you must narrow before use. Example: let x: unknown; x.toFixed() // error until narrowed
never
Type of values that never occur (impossible) or functions that never return. Example: function fail(): never { throw new Error() }
void
Function returns nothing meaningful. Example: function log(): void { console.log(“hi”) }
Union type
Either/or type. Example: string | number
Intersection type
Combine requirements of both types. Example: A & B requires all members from A and B
Optional property
Property may be missing. Example: type U = { flags?: {admin:boolean} } // flags can be absent
Nullable / undefined union
When a type explicitly includes null/undefined. Example: {admin:boolean} | undefined
Narrowing
Refining a broader type to a more specific type along a control-flow path. Example: if (typeof x === “string”) { x.toUpperCase() }
Type guard
A runtime check TS recognizes to narrow types. Example: typeof x === “string”, x instanceof Date, “prop” in obj
User-defined type guard
A function returning a predicate like x is T. Example: function isFoo(x:any): x is Foo { return “foo” in x }
Discriminated union (tagged union)
Union of objects with a common literal “tag” property used for narrowing. Example: {kind:”a”,…}|{kind:”b”,…}
Control-flow analysis
TS tracks possible execution paths to compute narrowed types in each branch. Example: after if (x) { /* x non-null */ }
keyof operator
Produces a union of property names. Example: type K = keyof User // “id” | “name” | “flags”
Indexed access type
Access a property’s type via indexing. Example: type Name = User[“name”]