/** Represents an array with `unknown` value. Use case: You want a type that all arrays can be assigned to, but you don't care about the value. @example ``` import type {UnknownArray} from 'type-fest'; type IsArray = T extends UnknownArray ? true : false; type A = IsArray<['foo']>; //=> true type B = IsArray; //=> true type C = IsArray; //=> false ``` @category Type @category Array */ type UnknownArray = readonly unknown[]; /** Extracts the element type of an array or tuple. Use-cases: - When you need type-safe element extraction that returns `never` for non-arrays. - When extracting element types from generic array parameters in function signatures. - For better readability and explicit intent over using `T[number]` directly. Note: Returns `never` if the type is not an array. @example ``` import type {ArrayElement} from 'type-fest'; // Arrays type StringArray = ArrayElement; //=> string // Tuples type Tuple = ArrayElement<[1, 2, 3]>; //=> 1 | 2 | 3 // Type-safe type NotArray = ArrayElement<{a: string}>; //=> never // Practical example declare function getRandomElement(array: T): ArrayElement; getRandomElement(['foo', 'bar', 'baz'] as const); //=> 'foo' | 'bar' | 'baz' ``` @see {@link ArrayValues} - For directly extracting values from a constant array type. @see {@link IterableElement} - For iterables like `Set`, `Map`, and generators (not suitable for all use cases due to different inference behavior). @category Array */ type ArrayElement = T extends UnknownArray ? T[number] : never; type BaseContext = { readonly [key: string]: unknown; }; type BreakpointObject = Readonly void>>; interface DebugAPIType { /** * 🚨 This is strictly for debugging only. * * List of execution points for debugger to break into. * * Type `debug($0.webChat.breakpoint.functionName)` in DevTools to break into specific execution. */ get breakpoint(): BreakpointObject; /** * 🚨 This is strictly for debugging only. * * Break into debugger immediately. * * Note: if Content Security Policy is enabled, it may not break into debugger. */ get debugger(): void; } /** * This is the triggering side of the debugging API. * * This object should be kept inside the code that need to be debugged. * * For public consumption, call `toPublic()` to create an object for receiving side. */ interface RestrictedDebugAPIType { /** * Creates a public version of Debug API for external consumption. */ toPublic(): DebugAPIType; /** * Triggers a breakpoint function. */ get UNSAFE_callBreakpoint(): Readonly void>>; readonly '~types': { readonly public: DebugAPIType; }; } type InferPublic> = T['~types']['public']; declare class DebugAPI implements DebugAPIType { #private; constructor(breakpoint: BreakpointObject, context: TContext); get breakpoint(): Readonly void>>; get debugger(): undefined; } type AsGetters = { readonly [K in keyof T]: () => T[K]; }; declare abstract class RestrictedDebugAPI implements RestrictedDebugAPIType { #private; constructor(breakpointNames: readonly TBreakpointName[], contextGetters: AsGetters); toPublic(): DebugAPI; UNSAFE_callBreakpoint: Readonly void>>; get '~types'(): Readonly<{ public: any; }>; } export { RestrictedDebugAPI as R }; export type { ArrayElement as A, InferPublic as I };