Last active
February 7, 2023 15:23
-
-
Save pffigueiredo/33e920d30e602a4aa94e4c9f5063e766 to your computer and use it in GitHub Desktop.
Useful types to hack around
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
// prettify intersection on types, like `a & b & c` | |
type Prettify<T> = {[K in keyof T]: T[K]} & {}; | |
// autocomplete that also accepts string | |
// so you still have intellisense but it's open to any string | |
type AutoComplete<T extends string> = T | (string & {}); | |
// the value of objects | |
type ValueOf<T extends object> = T[keyof T]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment