Skip to content

Instantly share code, notes, and snippets.

View vansh-codes's full-sized avatar
:octocat:
Grinding

Vansh Chaurasiya vansh-codes

:octocat:
Grinding
View GitHub Profile
@vansh-codes
vansh-codes / type-utils.ts
Created October 12, 2025 16:22
Utility Types That Supercharge Developer Experience in TypeScript
/** Union of all JavaScript primitive types (excluding `symbol` and `function`) */
type Primitive = string | number | bigint | boolean | null | undefined;
/** Wraps a type in `null` */
type Nullable<T> = T | null;
/** Deeply nullable (all nested props can be null) */
type NullableDeep<T> = {
[K in keyof T]: T[K] extends object ? NullableDeep<T[K]> | null : T[K] | null;
};