export declare namespace TypesaurusUtils { /** * Falsy type. */ export type Falsy = undefined | null | "" | false | 0; /** * Any brand type that can be mixed with string number or symbol to create * opaque primitive. */ export type AnyBrand = { [key: string | number | symbol]: any; }; /** * Picks only keys of the given type. */ export type KeysOfType = { [Key in keyof Base]: Type extends Base[Key] ? Key : never; }[keyof Base]; /** * Removes brand from the given type. */ export type Debrand = Type extends infer _Brand extends AnyBrand & infer Debranded extends string | number | symbol ? Debranded : Type; /** * Composes collection path from base path and collection name. */ export type ComposePath = BasePath extends false ? Path : `${BasePath}/${Path}`; /** * Resolves union keys. */ export type UnionKeys = Type extends Type ? keyof Type : never; /** * Resolves union value. */ export type UnionValue> = Type extends { [Key in UnionKey]: unknown; } ? Type[UnionKey] : never; /** * Removes indexed fields leaving only statically defined. */ export type WithoutIndexed = { [Key in keyof Model as string extends Debrand ? never : number extends Debrand ? never : symbol extends Debrand ? never : Key]: Model[Key]; }; /** * Resolves true if the given key is statically defined in the given type. */ export type StaticKey = Key extends keyof WithoutIndexed ? true : false; /** * Returns a type with all fields required and all values exclude undefined. * It allows to extract key paths from nested objects with optional keys * and values. */ export type AllRequired = { [Key in keyof Required]-?: Exclude[Key], undefined | null>; }; /** * Resolves true if the passed key is a required field of the passed model. */ export type RequiredKey = StaticKey extends true ? Partial> extends Pick ? false : true : false; /** * Resolves true if the passed field is undefined union and not optionally * undefined. */ export type ActuallyUndefined = undefined extends Required[Key] ? true : false; /** * Resolves true if all sibling fields in the passed model are optional. */ export type AllOptionalBut = Partial, Key>> extends Omit, Key> ? true : false; /** * Resolves true if the passed path to a field within a nested object * is required on every nesting level. It helps to prevent updates from * causing data inconsistency. * * This is the 1-lever deep version, see RequiredPathN for more levels. * * See {@link RequiredPath2} for the internal implementation details. */ export type RequiredPath1 = RequiredKey extends true ? true : false; /** * See {@link RequiredPath1} for the documentation. * * This is the 2-level deep version of the type. */ export type RequiredPath2[Key1]> = RequiredPath1 extends true ? RequiredKey[Key1], Key2> extends true ? true : false : false; /** * See {@link RequiredPath1} for the documentation. * See {@link RequiredPath2} for the internal implementation details. * * This is the 3-level deep version of the type. */ export type RequiredPath3[Key1], Key3 extends keyof AllRequired[Key1]>[Key2]> = RequiredPath2 extends true ? RequiredKey[Key1]>[Key2], Key3> extends true ? true : false : false; /** * See {@link RequiredPath1} for the documentation. * See {@link RequiredPath2} for the internal implementation details. * * This is the 4-level deep version of the type. */ export type RequiredPath4[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3]> = RequiredPath3 extends true ? RequiredKey[Key1]>[Key2]>[Key3], Key4> extends true ? true : false : false; /** * See {@link RequiredPath1} for the documentation. * See {@link RequiredPath2} for the internal implementation details. * * This is the 5-level deep version of the type. */ export type RequiredPath5[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]> = RequiredPath4 extends true ? RequiredKey[Key1]>[Key2]>[Key3]>[Key4], Key5> extends true ? true : false : false; /** * See {@link RequiredPath1} for the documentation. * See {@link RequiredPath2} for the internal implementation details. * * This is the 6-level deep version of the type. */ export type RequiredPath6[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4], Key6 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]> = RequiredPath5 extends true ? RequiredKey[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key6> extends true ? true : false : false; /** * See {@link RequiredPath1} for the documentation. * See {@link RequiredPath2} for the internal implementation details. * * This is the 7-level deep version of the type. */ export type RequiredPath7[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4], Key6 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key7 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]> = RequiredPath6 extends true ? RequiredKey[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6], Key7> extends true ? true : false : false; /** * See {@link RequiredPath1} for the documentation. * See {@link RequiredPath2} for the internal implementation details. * * This is the 8-level deep version of the type. */ export type RequiredPath8[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4], Key6 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key7 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6], Key8 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]> = RequiredPath7 extends true ? RequiredKey[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7], Key8> extends true ? true : false : false; /** * See {@link RequiredPath1} for the documentation. * See {@link RequiredPath2} for the internal implementation details. * * This is the 9-level deep version of the type. */ export type RequiredPath9[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4], Key6 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key7 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6], Key8 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7], Key9 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]>[Key8]> = RequiredPath8 extends true ? RequiredKey[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]>[Key8], Key9> extends true ? true : false : false; /** * See {@link RequiredPath1} for the documentation. * See {@link RequiredPath2} for the internal implementation details. * * This is the 10-level deep version of the type. */ export type RequiredPath10[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4], Key6 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key7 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6], Key8 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7], Key9 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]>[Key8], Key10 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]>[Key8]>[Key9]> = RequiredPath9 extends true ? RequiredKey[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]>[Key8]>[Key9], Key10> extends true ? true : false : false; /** * Resolves true if the passed optional path to a field within a nested object * is safe to update, meaning there are no required sibling fields on every * nesting level. It helps to prevent updates from causing data inconsistency. * * This is the 1-lever deep version, see SafeOptionalPathN for more levels. * * See {@link SafeOptionalPath2} for the internal implementation details. */ export type SafeOptionalPath1 = AllOptionalBut extends true ? true : false; /** * See {@link SafeOptionalPath1} for the documentation. * * This is the 2-level deep version of the type. */ export type SafeOptionalPath2[Key1]> = SafeOptionalPath1 extends true ? AllOptionalBut[Key1], Key2> extends true ? true : false : false; /** * See {@link SafeOptionalPath1} for the documentation. * See {@link SafeOptionalPath2} for the internal implementation details. * * This is the 3-level deep version of the type. */ export type SafeOptionalPath3[Key1], Key3 extends keyof AllRequired[Key1]>[Key2]> = SafeOptionalPath2 extends true ? AllOptionalBut[Key1]>[Key2], Key3> extends true ? true : false : false; /** * See {@link SafeOptionalPath1} for the documentation. * See {@link SafeOptionalPath2} for the internal implementation details. * * This is the 4-level deep version of the type. */ export type SafeOptionalPath4[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3]> = SafeOptionalPath3 extends true ? AllOptionalBut[Key1]>[Key2]>[Key3], Key4> extends true ? true : false : false; /** * See {@link SafeOptionalPath1} for the documentation. * See {@link SafeOptionalPath2} for the internal implementation details. * * This is the 5-level deep version of the type. */ export type SafeOptionalPath5[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]> = SafeOptionalPath4 extends true ? AllOptionalBut[Key1]>[Key2]>[Key3]>[Key4], Key5> extends true ? true : false : false; /** * See {@link SafeOptionalPath1} for the documentation. * See {@link SafeOptionalPath2} for the internal implementation details. * * This is the 6-level deep version of the type. */ export type SafeOptionalPath6[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4], Key6 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]> = SafeOptionalPath5 extends true ? AllOptionalBut[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key6> extends true ? true : false : false; /** * See {@link SafeOptionalPath1} for the documentation. * See {@link SafeOptionalPath2} for the internal implementation details. * * This is the 7-level deep version of the type. */ export type SafeOptionalPath7[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4], Key6 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key7 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]> = SafeOptionalPath6 extends true ? AllOptionalBut[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6], Key7> extends true ? true : false : false; /** * See {@link SafeOptionalPath1} for the documentation. * See {@link SafeOptionalPath2} for the internal implementation details. * * This is the 8-level deep version of the type. */ export type SafeOptionalPath8[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4], Key6 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key7 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6], Key8 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]> = SafeOptionalPath7 extends true ? AllOptionalBut[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7], Key8> extends true ? true : false : false; /** * See {@link SafeOptionalPath1} for the documentation. * See {@link SafeOptionalPath2} for the internal implementation details. * * This is the 9-level deep version of the type. */ export type SafeOptionalPath9[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4], Key6 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key7 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6], Key8 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7], Key9 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]>[Key8]> = SafeOptionalPath8 extends true ? AllOptionalBut[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]>[Key8], Key9> extends true ? true : false : false; /** * See {@link SafeOptionalPath1} for the documentation. * See {@link SafeOptionalPath2} for the internal implementation details. * * This is the 10-level deep version of the type. */ export type SafeOptionalPath10[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4], Key6 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key7 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6], Key8 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7], Key9 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]>[Key8], Key10 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]>[Key8]>[Key9]> = SafeOptionalPath9 extends true ? AllOptionalBut[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]>[Key8]>[Key9], Key10> extends true ? true : false : false; /** * Resolves true if the passed path to a field within a nested object is * safe to update. * * It checks using {@link RequiredPath1} if the path is required at every * level, and if not, with the help of {@link SafeOptionalPath1} it checks if * the optional path to a given level is safe. Refer to said functions for * more details on how it works. * * This is the 1-lever deep version, see SafePathN for more levels. * * See {@link SafePath5} for the internal implementation details. */ export type SafePath1 = true; /** * See {@link SafePath1} for the documentation. * See {@link SafePath5} for the internal implementation details. * * This is the 2-level deep version of the type. */ export type SafePath2[Key1]> = AllRequired[Key1] extends any[] ? false : RequiredPath1 extends true ? true : SafeOptionalPath1[Key1], Key2>; /** * See {@link SafePath1} for the documentation. * See {@link SafePath5} for the internal implementation details. * * This is the 3-level deep version of the type. */ export type SafePath3[Key1], Key3 extends keyof AllRequired[Key1]>[Key2]> = AllRequired[Key1]>[Key2] extends any[] ? false : RequiredPath2 extends true ? true : SafeOptionalPath2[Key1], Key2, Key3>; /** * See {@link SafePath1} for the documentation. * See {@link SafePath5} for the internal implementation details. * * This is the 4-level deep version of the type. */ export type SafePath4[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3]> = AllRequired[Key1]>[Key2]>[Key3] extends any[] ? false : RequiredPath3 extends true ? true : SafeOptionalPath3[Key1], Key2, Key3, Key4>; /** * See {@link SafePath1} for the documentation. * * This is the 5-level deep version of the type. */ export type SafePath5[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]> = AllRequired[Key1]>[Key2]>[Key3]>[Key4] extends any[] ? false : RequiredPath4 extends true ? true : RequiredPath3 extends true ? SafeOptionalPath2[Key1]>[Key2]>[Key3], Key4, Key5> : RequiredPath2 extends true ? SafeOptionalPath3[Key1]>[Key2], Key3, Key4, Key5> : SafeOptionalPath4[Key1], Key2, Key3, Key4, Key5>; /** * See {@link SafePath1} for the documentation. * See {@link SafePath5} for the internal implementation details. * * This is the 6-level deep version of the type. */ export type SafePath6[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4], Key6 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]> = AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5] extends any[] ? false : RequiredPath5 extends true ? true : RequiredPath4 extends true ? SafeOptionalPath2[Key1]>[Key2]>[Key3]>[Key4], Key5, Key6> : RequiredPath3 extends true ? SafeOptionalPath3[Key1]>[Key2]>[Key3], Key4, Key5, Key6> : RequiredPath2 extends true ? SafeOptionalPath4[Key1]>[Key2], Key3, Key4, Key5, Key6> : SafeOptionalPath5[Key1], Key2, Key3, Key4, Key5, Key6>; /** * See {@link SafePath1} for the documentation. * See {@link SafePath5} for the internal implementation details. * * This is the 7-level deep version of the type. */ export type SafePath7[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4], Key6 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key7 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]> = AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6] extends any[] ? false : RequiredPath6 extends true ? true : RequiredPath5 extends true ? SafeOptionalPath2[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key6, Key7> : RequiredPath4 extends true ? SafeOptionalPath3[Key1]>[Key2]>[Key3]>[Key4], Key5, Key6, Key7> : RequiredPath3 extends true ? SafeOptionalPath4[Key1]>[Key2]>[Key3], Key4, Key5, Key6, Key7> : RequiredPath2 extends true ? SafeOptionalPath5[Key1]>[Key2], Key3, Key4, Key5, Key6, Key7> : SafeOptionalPath6[Key1], Key2, Key3, Key4, Key5, Key6, Key7>; /** * See {@link SafePath1} for the documentation. * See {@link SafePath5} for the internal implementation details. * * This is the 8-level deep version of the type. */ export type SafePath8[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4], Key6 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key7 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6], Key8 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]> = AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7] extends any[] ? false : RequiredPath7 extends true ? true : RequiredPath6 extends true ? SafeOptionalPath2[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6], Key7, Key8> : RequiredPath5 extends true ? SafeOptionalPath3[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key6, Key7, Key8> : RequiredPath4 extends true ? SafeOptionalPath4[Key1]>[Key2]>[Key3]>[Key4], Key5, Key6, Key7, Key8> : RequiredPath3 extends true ? SafeOptionalPath5[Key1]>[Key2]>[Key3], Key4, Key5, Key6, Key7, Key8> : RequiredPath2 extends true ? SafeOptionalPath6[Key1]>[Key2], Key3, Key4, Key5, Key6, Key7, Key8> : SafeOptionalPath7[Key1], Key2, Key3, Key4, Key5, Key6, Key7, Key8>; /** * See {@link SafePath1} for the documentation. * See {@link SafePath5} for the internal implementation details. * * This is the 9-level deep version of the type. */ export type SafePath9[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4], Key6 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key7 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6], Key8 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7], Key9 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]>[Key8]> = AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]>[Key8] extends any[] ? false : RequiredPath8 extends true ? true : RequiredPath7 extends true ? SafeOptionalPath2[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7], Key8, Key9> : RequiredPath6 extends true ? SafeOptionalPath3[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6], Key7, Key8, Key9> : RequiredPath5 extends true ? SafeOptionalPath4[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key6, Key7, Key8, Key9> : RequiredPath4 extends true ? SafeOptionalPath5[Key1]>[Key2]>[Key3]>[Key4], Key5, Key6, Key7, Key8, Key9> : RequiredPath3 extends true ? SafeOptionalPath6[Key1]>[Key2]>[Key3], Key4, Key5, Key6, Key7, Key8, Key9> : RequiredPath2 extends true ? SafeOptionalPath7[Key1]>[Key2], Key3, Key4, Key5, Key6, Key7, Key8, Key9> : SafeOptionalPath8[Key1], Key2, Key3, Key4, Key5, Key6, Key7, Key8, Key9>; /** * See {@link SafePath1} for the documentation. * See {@link SafePath5} for the internal implementation details. * * This is the 10-level deep version of the type. */ export type SafePath10[Key1], Key3 extends keyof AllRequired[Key1]>[Key2], Key4 extends keyof AllRequired[Key1]>[Key2]>[Key3], Key5 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4], Key6 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key7 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6], Key8 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7], Key9 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]>[Key8], Key10 extends keyof AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]>[Key8]>[Key9]> = AllRequired[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]>[Key8]>[Key9] extends any[] ? false : RequiredPath9 extends true ? true : RequiredPath8 extends true ? SafeOptionalPath2[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7]>[Key8], Key9, Key10> : RequiredPath7 extends true ? SafeOptionalPath3[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6]>[Key7], Key8, Key9, Key10> : RequiredPath6 extends true ? SafeOptionalPath4[Key1]>[Key2]>[Key3]>[Key4]>[Key5]>[Key6], Key7, Key8, Key9, Key10> : RequiredPath5 extends true ? SafeOptionalPath5[Key1]>[Key2]>[Key3]>[Key4]>[Key5], Key6, Key7, Key8, Key9, Key10> : RequiredPath4 extends true ? SafeOptionalPath6[Key1]>[Key2]>[Key3]>[Key4], Key5, Key6, Key7, Key8, Key9, Key10> : RequiredPath3 extends true ? SafeOptionalPath7[Key1]>[Key2]>[Key3], Key4, Key5, Key6, Key7, Key8, Key9, Key10> : RequiredPath2 extends true ? SafeOptionalPath8[Key1]>[Key2], Key3, Key4, Key5, Key6, Key7, Key8, Key9, Key10> : SafeOptionalPath9[Key1], Key2, Key3, Key4, Key5, Key6, Key7, Key8, Key9, Key10>; export type SharedShape = C extends undefined ? SharedShape2 : D extends undefined ? SharedShape3 : E extends undefined ? SharedShape4 : F extends undefined ? SharedShape5 : G extends undefined ? SharedShape6 : H extends undefined ? SharedShape7 : I extends undefined ? SharedShape8 : J extends undefined ? SharedShape9 : SharedShape10; export type SharedShape2 = { [Key in keyof (A | B) as A[Key] & B[Key] extends never ? never : Key]: A[Key] & B[Key]; }; export type SharedShape3 = { [Key in keyof (A | B | C) as A[Key] & B[Key] & C[Key] extends never ? never : Key]: A[Key] & B[Key] & C[Key]; }; export type SharedShape4 = { [Key in keyof (A | B | C | D) as A[Key] & B[Key] & C[Key] & D[Key] extends never ? never : Key]: A[Key] & B[Key] & C[Key] & D[Key]; }; export type SharedShape5 = { [Key in keyof (A | B | C | D | E) as [Key] & B[Key] & C[Key] & D[Key] & E[Key] extends never ? never : Key]: A[Key] & B[Key] & C[Key] & D[Key] & E[Key]; }; export type SharedShape6 = { [Key in keyof (A | B | C | D | E | F) as A[Key] & B[Key] & C[Key] & D[Key] & E[Key] & F[Key] extends never ? never : Key]: A[Key] & B[Key] & C[Key] & D[Key] & E[Key] & F[Key]; }; export type SharedShape7 = { [Key in keyof (A | B | C | D | E | F | G) as A[Key] & B[Key] & C[Key] & D[Key] & E[Key] & F[Key] & G[Key] extends never ? never : Key]: A[Key] & B[Key] & C[Key] & D[Key] & E[Key] & F[Key] & G[Key]; }; export type SharedShape8 = { [Key in keyof (A | B | C | D | E | F | G | H) as A[Key] & B[Key] & C[Key] & D[Key] & E[Key] & F[Key] & G[Key] & H[Key] extends never ? never : Key]: A[Key] & B[Key] & C[Key] & D[Key] & E[Key] & F[Key] & G[Key] & H[Key]; }; export type SharedShape9 = { [Key in keyof (A | B | C | D | E | F | G | H | I) as A[Key] & B[Key] & C[Key] & D[Key] & E[Key] & F[Key] & G[Key] & H[Key] & I[Key] extends never ? never : Key]: A[Key] & B[Key] & C[Key] & D[Key] & E[Key] & F[Key] & G[Key] & H[Key] & I[Key]; }; export type SharedShape10 = { [Key in keyof (A | B | C | D | E | F | G | H | I | J) as A[Key] & B[Key] & C[Key] & D[Key] & E[Key] & F[Key] & G[Key] & H[Key] & I[Key] & J[Key] extends never ? never : Key]: A[Key] & B[Key] & C[Key] & D[Key] & E[Key] & F[Key] & G[Key] & H[Key] & I[Key] & J[Key]; }; /** * Creates type where all fields from all variants are present. */ export type IntersectShape = C extends undefined ? IntersectShape2 : D extends undefined ? IntersectShape3 : E extends undefined ? IntersectShape4 : F extends undefined ? IntersectShape5 : G extends undefined ? IntersectShape6 : H extends undefined ? IntersectShape7 : I extends undefined ? IntersectShape8 : J extends undefined ? IntersectShape9 : IntersectShape10; type IntersectShape2 = (A & UndefinedDifference) | (B & UndefinedDifference); type IntersectShape3 = (A & UndefinedDifference & UndefinedDifference) | (B & UndefinedDifference & UndefinedDifference) | (C & UndefinedDifference & UndefinedDifference); type IntersectShape4 = (A & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (B & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (C & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (D & UndefinedDifference & UndefinedDifference & UndefinedDifference); type IntersectShape5 = (A & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (B & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (C & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (D & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (E & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference); type IntersectShape6 = (A & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (B & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (C & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (D & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (E & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (F & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference); type IntersectShape7 = (A & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (B & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (C & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (D & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (E & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (F & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (G & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference); type IntersectShape8 = (A & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (B & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (C & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (D & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (E & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (F & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (G & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (H & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference); type IntersectShape9 = (A & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (B & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (C & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (D & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (E & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (F & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (G & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (H & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (I & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference); type IntersectShape10 = (A & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (B & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (C & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (D & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (E & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (F & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (G & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (H & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (I & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference) | (J & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference & UndefinedDifference); export type UndefinedDifference = { [Key in Exclude]?: undefined; }; export type WholeOrPartial = Type | { [Key in keyof Type]?: Type[Key]; }; export type WholeOrEmpty = Type | { [Key in keyof Type]?: undefined; }; /** * Checks if exactOptionalPropertyTypes is enabled or not */ export type ExactOptionalPropertyTypesEnabled = { test: undefined; } extends { test?: boolean; } ? false : true; /** * Resolves never if the object has no keys. */ export type NeverIfEmpty = keyof Object extends never ? never : Object; /** * Resolves unknown if the object has no keys. */ export type UnknownIfEmpty = keyof Object extends never ? unknown : Object; export {}; }