Created
June 11, 2024 12:46
-
-
Save olibooty/7b44d6100f956c4e92d36db72c3979e0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /** | |
| * Renders supplied properties of an object required | |
| */ | |
| type Requirer <T, K extends keyof T> = T & { [P in K]-?: T[P] } | |
| interface Foo { | |
| opt?: string; | |
| } | |
| type ReqFoo = Requirer<Foo, 'opt'> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
better implementation: https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#mapping-modifiers