UNPKG

datum-focus

Version:

Data shape, model, metadata, JSON, JSON Schema, GraphQL, MongoDB query and aggregations, iterator generators

20 lines (17 loc) 549 B
import { KnownRecord } from "./record"; type Bit = 0 | 1; type ProjectObj<T, K> = K extends string ? Record<string, Bit> // Project<T> : T extends (infer U)[] ? Bit // ProjectItem<U> : Bit; type ProjectArr<U> = U extends boolean | number | string ? Bit : Record<string, Bit>; type ProjectObj2<T, K> = T extends (infer U)[] ? ProjectArr<U> : Record<string, Bit>; type ProjectType<T> = T extends boolean | number | string ? Bit : ProjectObj2<T, keyof T>; export type Project<T extends {}> = { [K in keyof T]: ProjectType<T[K]>; };