any: Disables the type-checking. Use only when necessary.
unknown: Marks as type is not known, but type needs to be narrowed before using the variable.
never: Represents a value that never occurs. A function that throws error for edge cases. So ideally / programmatically it should not occur. But, in case something fails, the function is called, and a custom error is thrown.
void: Used for functions that do not return.
null and undefined: Can be used explicitly, ( in strict mode ). Config might not allow null.
object: Any non-primitive object. Excludes all the primitives, and includes all the non-primitives like arrays, functions, etc.
{}: Allows everything including primitives, just excluding - null or undefined.
Record: Use this to specify plain objects with key value pairs. Record<string, number> a plain object that can only have string type keys and number type values.
Utility Types
🔹 1. Type Transformation Utilities
Utility Type
Description
Partial<T>
Makes all properties in T optional.
Required<T>
Makes all properties in T required.
Readonly<T>
Makes all properties in T read-only.
Mutable<T>
(from TS 5.2+ with lib.esnext) Makes all properties writable.
Pick<T, K>
Picks a set of properties K from T.
Omit<T, K>
Removes properties K from T.
Record<K, T>
Constructs an object type with keys of type K and values of type T.
🔹 2. Type Filtering / Conditional Utilities
Utility Type
Description
Exclude<T, U>
Excludes from T those types that are assignable to U.
Extract<T, U>
Extracts from T those types that are assignable to U.
NonNullable<T>
Removes null and undefined from T.
🔹 3. Function Type Utilities
Utility Type
Description
Parameters<T>
Extracts the parameter types of a function type T.
ConstructorParameters<T>
Extracts constructor parameter types.
ReturnType<T>
Gets the return type of a function type.
InstanceType<T>
Gets the instance type of a constructor function type.
ThisParameterType<T>
Gets the type of the this parameter for a function.
OmitThisParameter<T>
Removes the this parameter from a function type.
ThisType<T>
A marker for this type in object literals (used with noImplicitThis).
🔹 4. Promise & Async Utilities
Utility Type
Description
Awaited<T>
Gets the resolved type of a Promise<T>. Useful for async/await.
🔹 5. New Utility Types (TypeScript 5.x)
Some newer utility types are available when targeting lib.esnext or lib.dom:
Utility Type
Description
Writable<T>
(TS 5.2+) Removes readonly from properties. (Similar to custom Mutable)
ReadonlyDeep<T>
(Community libs) Deep-readonly version (not built-in yet).
🔹 Bonus: Useful Custom Utility Types (You can write)
Name
Description
DeepPartial<T>
Makes all nested properties optional.
UnionToIntersection<U>
Converts union type to intersection.
These are not built-in but very commonly used in advanced TS setups.
Arrow functions vs Functions
Use Arrow Functions When…
You need lexical this
Writing simple callbacks (e.g., .map, .filter)
Inside React components (useEffect, handlers)
You want to avoid accidental re-declarations
Use Regular function When…
You need this or arguments
You're writing top-level reusable functions
You need to overload function signatures
You're writing class methods
AT
Adesh Tamrakar
SOFTWARE ENGINEER · VAULT
Notes, insights and random discoveries from a working engineer's vault - written for future me, published for you.