Skip to content

Instantly share code, notes, and snippets.

@B-Stefan
Created December 9, 2019 14:16
Show Gist options
  • Save B-Stefan/e15213e15fe7ecc36309890842242cc6 to your computer and use it in GitHub Desktop.
Save B-Stefan/e15213e15fe7ecc36309890842242cc6 to your computer and use it in GitHub Desktop.
Typescript PlainObjectOf
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