What are TypeScript utility types?
Answer
TypeScript ships with built-in utility types that perform common type transformations. Key ones: Partial<T> — makes all properties of T optional (useful for update operations). Required<T> — makes all properties required (opposite of Partial). Readonly<T> — makes all properties readonly. Record<K, V> — creates an object type with keys of type K and values of type V. Pick<T, K> — creates a type with only the specified properties K from T. Omit<T, K> — creates a type excluding the specified properties K from T. Exclude<T, U> — removes types from T that are assignable to U. Extract<T, U> — keeps only types from T that are assignable to U. NonNullable<T> — removes null and undefined from T. ReturnType<T> — extracts the return type of a function type. Parameters<T> — extracts parameter types as a tuple. These utility types are built using TypeScript's advanced type features (mapped types, conditional types) and are essential tools for type manipulation.
Previous
What are generic constraints in TypeScript?
Next
What is the difference between Partial and Required utility types?