export type Lookup = T[number]; export declare const isInArray: (value: T, array: ReadonlyArrayOfT) => value is Lookup; export type DeepReadonly = { readonly [P in keyof T]: T[P] extends (...args: any[]) => any ? T[P] : DeepReadonly; }; export declare const exhaustiveTypeCheck: (_: never) => undefined; export declare class ExhaustiveTypeException extends Error { constructor(type: never); } export declare const exhaustiveTypeException: (type: never) => ExhaustiveTypeException; export declare class AssertionError extends Error { constructor(message: string); } export type Some = { hasValue: true; value: T; } | { hasValue: false; }; /** * Please use this instead of using the 'as' keyword directly, so it's easier * to screen for these ticking time bombs in the code from time to time. Or * better yet, just implement validation for your types straight away. * * If you would think twice before using this, then by pure logic you should * likewise also think twice - no, make it at least thrice - before making the * decision to opt into undefined behaviour by letting the compile-time TS type * diverge from the runtime JS value. * * This is your last chance to turn back. * * You have been warned. * * @example * ```ts * const someData = await AsyncStorage.getItem(SOME_KEY); * const parsedData = JSON.parse(someData); * const data = dangerousUncheckedTypeCast(parsedData); * ``` */ export declare const dangerousUncheckedTypeCast: (value: unknown) => U; export declare function assertNonNullish(value: T, message: string): asserts value is T & {}; export declare function isNonNullish(value: T): value is T & {}; /** * What it's not: "I don't know what type this value may be." * What it is: "I don't **CARE** about the type of this value." * What it is: "Disable the type system for this variable." * * Alias for `any` that makes it more clear what's going on. Avoid using this, * and absolutely avoid using `any` directly even harder! Instead, you may want * to use one of the following: * * - `unknown` // any value, can be nullish or not - need to use type guards * - `unknown[]` // same as above, but we know it's an array of these unknowns, * // so we allow array functions to be used on it * - `object` // any value where `typeof value === 'object'` - except `null` * - `{}` // any non-nullish value, object or not; ignore the lint error * - `never` // no value; not `undefined` or `null`, but _unreachable code_ */ export type UNSAFE_Untyped = any; /** * Safer alternative to `JSON.parse`. Returns `unknown` instead of `any`. * * @see JSON.parse */ export declare const parseJSON: (...args: Parameters) => unknown; /** * Same as `array[index]`, but adds `undefined` to the return type. Maybe some * fine day we will enable `noUncheckedIndexedAccess` in all our projects. 🤞 */ export declare const typeSafeIndex: (array: T[], index: number) => T | undefined; export declare const TODO: (message?: string) => never; /** * @deprecated Placeholder for avoiding cross-repo type issues due to merges. * Meant to be replaced with the enclosed type T as the earliest possible dev * convenience. DO NOT USE THIS IN PRODUCTION! */ export type TODO = T & never;