import { PropertyDeclaration } from "lit"; /** Can be used to type a TypeScript enum */ export type Enum = Readonly<{ [key: number]: string | number; }>; /** * A union representing the possible underlying types of enum members * @template T The enum type */ export type EnumValue = Readonly; /** * A type that represents the value type of a key on an enum * @template T The enum type */ export type EnumKeyValue = Readonly; /** An attribute converter type alias defined by Lit */ export type AttributeConverter = PropertyDeclaration["converter"]; /** * A type that represents a change event emitted by a HTML element * @template T The type of the events target element */ export type ChangeEvent = Event & { target: T; }; /** A type that can be used to represent a stringified css variable */ export type CssVariable = `--${string}`; /** * A theming variable that is defined in our theming.css file and customized by * the host website. */ export type ThemingVariable = `--oe-${string}`; export type FixedLengthArray = Array & { length: Length; }; /** * A number type that is guaranteed to not be NaN. * In normal TypeScript, a "number" type can also be a NaN or Infinite value * (e.g -Infinity, Infinity, NaN are all number types). * * You will probably need to type narrow a number type before using a function * that accepts this type. * You can use the "isValidNumber" guard. */ export type ValidNumber = number & object; export type FixedLengthSet = Set & { size: Length; }; /** Extracts the constructor of a class that can be used as a type */ export type Constructor = new (...args: Args) => T; /** * A JavaScript object of key-value pairs. * This is needed because the TypeScript "object" type represents any truthy * value, and Record does not handle all record edge cases * (such as when the key is a symbol). */ export type ObjectRecord = Record; /** * A JavaScript variable that is stored in the heap, and variables store a * reference to instead of the value itself. * This is useful for conditional typing where you might want to make all * reference/pointer variables readonly when exposing them to user space so that * the user cannot accidentally modify the internal state of the program. */ export type HeapVariable = ObjectRecord | unknown[] | Map | Set; export type StackVariable = string | number | bigint | boolean | null | undefined; /** * Converts a structural type to a nominal type * * @example * ```typescript * type StructuralType = "a" | "b" | "c"; * type NominalType = StructuralToNominal; * ``` * * In the example above, the `NominalType` will be converted to a "string" type * because the `StructuralType` is a discriminated union of string literals. */ export type StructuralToNominal = T extends infer U ? U : never; export type SetTimeoutRef = ReturnType;