UNPKG

firesage

Version:

🔥 Extremely High Precision Typescript Wrapper for Firestore Web, Providing Unparalleled Type Safe and Dev Experience

14 lines (13 loc) • 1.22 kB
import { IsUnion } from './utils'; import { ErrorUnionInvolveObjectType } from './error'; import { FieldValues, PossiblyReadAsUndefined } from './fieldValue'; declare type FilterInNonObject<T> = Extract<T, Record<string, unknown>>; declare type ReplaceUnionInvolveObjectTypeWithErrorMsg<T> = IsUnion<Exclude<T, PossiblyReadAsUndefined>> extends true ? FilterInNonObject<Exclude<T, PossiblyReadAsUndefined>> extends never ? T : ErrorUnionInvolveObjectType : T extends FieldValues ? T : T extends Record<string, unknown> ? RecursiveReplaceUnionInvolveObjectTypeWithErrorMsg<T> : T; export declare type RecursiveReplaceUnionInvolveObjectTypeWithErrorMsg<T extends Record<string, unknown>> = { [K in keyof T]: ReplaceUnionInvolveObjectTypeWithErrorMsg<T[K]>; }; declare type ExcludePossiblyUndefinedFieldValue<T> = Exclude<T, PossiblyReadAsUndefined>; export declare type RecursiveExcludePossiblyUndefinedFieldValue<T> = T extends Record<string, unknown> ? { [K in keyof T]: T[K] extends Record<string, unknown> ? RecursiveExcludePossiblyUndefinedFieldValue<ExcludePossiblyUndefinedFieldValue<T[K]>> : ExcludePossiblyUndefinedFieldValue<T[K]>; } : ExcludePossiblyUndefinedFieldValue<T>; export {};