Created
December 17, 2018 22:29
-
-
Save lukaszfiszer/57173711b1229f51764fdd147595e8f3 to your computer and use it in GitHub Desktop.
Useful Typescript types and patterns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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