Skip to content

Instantly share code, notes, and snippets.

@fmartins-andre
Created February 6, 2025 16:58
Show Gist options
  • Save fmartins-andre/09e797168d458baa0d89f215dab8f712 to your computer and use it in GitHub Desktop.
Save fmartins-andre/09e797168d458baa0d89f215dab8f712 to your computer and use it in GitHub Desktop.
Useful types to typescript projects
declare type StringfyKeys<T> =
T extends Record<string, unknown> ? `${keyof T}` : never
declare type NonNullableFields<T> = {
[P in keyof T]: NonNullable<T[P]>
}
declare type NonNullableField<T, K extends keyof T> = T &
NonNullableFields<Pick<T, K>>
declare type DeepNullable<T> = {
[K in keyof T]: DeepNullable<T[K]> | null
}
declare type DeepPartial<T> = {
[K in keyof T]?: DeepPartial<T[K]> | undefined
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment