Skip to content

Instantly share code, notes, and snippets.

@lukaszfiszer
Created December 17, 2018 22:29
Show Gist options
  • Save lukaszfiszer/57173711b1229f51764fdd147595e8f3 to your computer and use it in GitHub Desktop.
Save lukaszfiszer/57173711b1229f51764fdd147595e8f3 to your computer and use it in GitHub Desktop.
Useful Typescript types and patterns
/**
* Make all properties in T reccursively optional
*/
type DeepPartial<T> = {
[K in keyof T]?: DeepPartial<T[K]>
}
interface Foo {
prop: {
bar: boolean;
baz: string;
}
}
const obj: DeepPartial<Foo> = {
prop: {
bar: false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment