/** * Applies a string-based index of an optionally specified type (defaults to any). */ export interface Indexed { [index: string]: T; } /** * Construct a new type from an existing one, excluding specified keys. Opposite of TypeScript's built-in Pick type. * Learn more: http://ideasintosoftware.com/typescript-advanced-tricks/ */ export type Omit = Pick>; /** * Convert an existing type into a projection specification, where 0 is omitted and 1 is included. * Learn more: http://ideasintosoftware.com/typescript-advanced-tricks/ */ export type Projection = Partial>; /** * A simple configuration object, useful for a variety of different project types. */ export interface IConfig { /** * The name of the library or application. */ NAME?: string; /** * The current library or application version, either as a string (e.g. 1.0.0 or v1) or as a number (e.g. 1 or 2.3) */ VERSION?: string | number; /** * The host environment for the library or application. */ ENV?: string; /** * A key/value map of prefixes for outgoing data requests. */ PREFIX?: { API?: string; TEMPLATE?: string; }; } /** * A list of IConfig objects, indexed by string. */ export interface IConfigList extends Indexed { } /** * A list of items with separate display and data representations. * Useful for things like browser select lists or Array-based maps. */ export interface IListItem extends Indexed { /** * The display representation of the item. */ Text: string; /** * The data representation of the item. */ Value: T; } /** * Valid path separators for both UNIX- and Windows-based file systems. */ export type PathSeparator = '/' | '\\'; export type JSONLike = { [k: string]: string | number | (string | number)[] | JSONLike } /** * Extract Keys from T where T[Key] extends U */ export type KeyByType = Exclude< { [K in keyof T]: T[K] extends U ? K : never }[keyof T], undefined >; /** * @see https://stackoverflow.com/questions/52443276/how-to-exclude-getter-only-properties-from-type-in-typescript/52473108#52473108 * @see https://github.com/Microsoft/TypeScript/issues/27024#issuecomment-421529650 */ export type IfEquals = (() => T extends X ? 1 : 2) extends (() => T extends Y ? 1 : 2) ? A : B; /** * @see https://stackoverflow.com/questions/52443276/how-to-exclude-getter-only-properties-from-type-in-typescript/52473108#52473108 * @see https://github.com/Microsoft/TypeScript/issues/27024#issuecomment-421529650 */ export type WritableKeysOf = { [P in keyof T]: IfEquals<{ [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, P, never> }[keyof T]; /** * @see https://stackoverflow.com/questions/52443276/how-to-exclude-getter-only-properties-from-type-in-typescript/52473108#52473108 * @see https://github.com/Microsoft/TypeScript/issues/27024#issuecomment-421529650 */ export type WritablePart = Pick>;