/** * Returns type `true` if types A and B are equal (type false otherwise). * See here: https://github.com/Microsoft/TypeScript/issues/27024#issuecomment-421529650 */ type Equal = (() => T extends X ? 1 : 2) extends (() => T extends Y ? 1 : 2) ? true : false; /** Type union that represents all primitive JavaScript types. */ type Primitive = undefined | null | boolean | number | string | symbol | bigint; /** * Makes an object or array writable by removing `readonly` modifies from the object's properties. * This is a shallow operation that does *not* recursive into subobjects. */ type Writable = { -readonly [P in keyof T]: T[P]; }; /** * Like `Writable`, but recursive. * Currently does not handle containers like Set and Map (or Promise), * those can be added later. */ type DeepWritable = T extends Primitive ? T : T extends {} ? { -readonly [P in keyof T]: DeepWritable; } : T; /** * Like the builtin `Readonly` type, but recursive. * Currently does not handle containers like Set and Map (or Promise), * those can be added later. */ type DeepReadonly = T extends Primitive ? T : T extends {} ? { readonly [P in keyof T]: DeepReadonly; } : T; /** * Makes optional properties in the type `T` required. */ type RequiredProps = T & Required>; interface IndexMap { "0": 0; "1": 1; "2": 2; "3": 3; "4": 4; "5": 5; "6": 6; } type RawTupleKeys = Exclude; /** * Returns the valid tuple keys for a tuple type. * * @example * ```ts * type Keys = TupleIndices<[string, number]>; * // Keys == 0 | 1 | "0" | "1" * ``` */ type TupleKeys = RawTupleKeys | IndexMap[RawTupleKeys & keyof IndexMap]; /** * General interface of any kind of Handles, like event handles, watch handles, what ever. */ interface Handle { /** Stops watching for property changes. */ remove(): void; } /** * Source of Events. */ interface EventSource { /** Registers event listener. */ on(name: Name, callBack: EventCallback): Handle; } /** * Event listener callback. */ type EventCallback = (event: EventType) => void; /** * Fires events. */ interface EventEmitter { /** * emit a event. * @param name name of the event. * @param evt the event. */ emit(name: Name, evt: Events[Name]): void; } /** * Watch event, this matches the apprt-core/Mutable watch interface. * @param NameType the type of the name of the event. * @param ValueType the type of the value of the event. * @see Watchable */ interface WatchEvent { value: ValueType; name: NameType; } /** * Watch callback, informed about watch events. */ type WatchCallback = (event: WatchEvent) => void; /** * Interface defining a watch method. * It matches the apprt-core/Mutable watch interface. */ interface Watchable { watch(name: Name, callback: WatchCallback): Handle; } /** * Helper type to express a set of statically known values (with autocompletion) that can still be extended. * * See this issue for more details: https://github.com/microsoft/TypeScript/issues/29729 * * @example * * The following code defines `LayerType`, which has a set of statically known values (for which we want autocompletion) * but also allows arbitrary unknown strings. * * ```ts * type WellKnownLayerType = "AGS_DYNAMIC" | "AGS_FEATURE"; * type LayerType = ExtensibleUnion; * * const foo: LayerType = ""; // Should give autocompletion * ``` */ type ExtensibleUnion = Values | ({} & BaseType); /** * An object that constructs instances of type T. */ type Constructor = new (...args: Args) => T; declare const _default: null; export { _default as default }; export type { Constructor, DeepReadonly, DeepWritable, Equal, EventCallback, EventEmitter, EventSource, ExtensibleUnion, Handle, Primitive, RequiredProps, TupleKeys, WatchCallback, WatchEvent, Watchable, Writable };