UNPKG

alinea

Version:

[![npm](https://img.shields.io/npm/v/alinea.svg)](https://npmjs.org/package/alinea) [![install size](https://packagephobia.com/badge?p=alinea)](https://packagephobia.com/result?p=alinea)

10 lines (9 loc) 610 B
import { IsStrictlyAny, ObjectUnion } from 'alinea/core/util/Types.js'; import { Expr } from './Expr.js'; type RecordField<T> = Expr<T> & FieldsOf<ObjectUnion<T>>; type Field<T> = [T] extends [Array<any>] ? Expr<T> : [T] extends [number | string | boolean] ? Expr<T> : [T] extends [Record<string, any> | null] ? RecordField<T> : Expr<T>; type FieldsOf<Row> = [Row] extends [Record<string, any>] ? keyof Row extends never ? Expr<object> : { [K in keyof Row]-?: Field<Row[K]>; } : never; export type Fields<T> = IsStrictlyAny<T> extends true ? any : [T] extends [object] ? FieldsOf<T> : Field<T>; export {};