Skip to content

Instantly share code, notes, and snippets.

View krotovic's full-sized avatar

Lukáš Krotovič krotovic

  • Octopus Newsroom
  • Prague
View GitHub Profile
@krotovic
krotovic / DeepPartial.ts
Last active October 11, 2024 10:19
TS DeepPartial
declare type DeepPartial<T, K extends keyof T = keyof T> = { [P in K]?: DeepPartial<T[P]> };
// this includes support for already optional fields
declare type DeepPartial<T> = {
[K in keyof T]?: T[K] extends infer R | undefined ? (R extends object ? DeepPartial<R> : R) : T[K];
};