Created
December 9, 2019 14:16
-
-
Save B-Stefan/e15213e15fe7ecc36309890842242cc6 to your computer and use it in GitHub Desktop.
Typescript PlainObjectOf
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
type Primitive = | |
| string | |
| boolean | |
| number | |
| bigint | |
| symbol | |
| null | |
| undefined | |
| Date; | |
export type PlainObjectOf<T> = { | |
[P in keyof T]?: T[P] extends Array<infer U> | |
? PlainObjectOf<T[P]> | |
: T[P] extends Primitive ? T[P] : never | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment