80%
DefinitionTypeScript = JavaScript + a static type system.
Catches typos, wrong arguments and null bugs before running.
Better editor autocomplete and safe refactors across a big codebase.
Types document APIs (props, responses, DB models).
Common mistakeTypes don't validate data at runtime.
Objects and classes; can be extended with extends: Anything: unions, tuples, primitives, mapped types
Declaration merging (re-open to add fields): Cannot be re-opened
Good default for object shapes and public APIs: Needed for unions and computed types
any turns type checking off — avoid it.unknown is the safe "anything": you must narrow it before use.never = a value that can't exist (exhaustive checks, functions that throw).Narrow with
typeof, instanceof, in, equality and truthiness checks.A user-defined type guard:
function isUser(x: unknown): x is User { … }.DefinitionGenerics are type parameters: write one function or type that works for many types while keeping them linked.
Partial<T>: every property optional (PATCH bodies)
Required<T>: every property required
Readonly<T>: every property readonly
Pick<T, "a" | "b">: only those keys
ReviseTypes are erased at runtime → validate external data.