export declare type Type = PrimitiveType | NeverType | AnyType | UnionType | StructValueType; export declare type ValueType = PrimitiveType | StructValueType; export declare type StructValueType = StructInstanceType | StructType | InvertedStructType; export declare type PrimitiveType = NumberPrimitive | StringPrimitive; export declare type NumberPrimitive = NumberType | NumericLiteralType | IntervalType | IntIntervalType | NonIntIntervalType; export declare type StringPrimitive = StringType | StringLiteralType | InvertedStringSetType; export declare type Int = NumericLiteralType | IntIntervalType; /** * A de-duplicated and sorted array of types. */ export declare type CanonicalTypes = readonly T[] & { readonly __CanonicalTypes: never; }; export declare type WithUnderlying = T extends { readonly underlying: U; } ? T : never; export declare type WithType = T extends { readonly type: U; } ? T : never; export declare type NonTrivialType = ValueType | UnionType; export declare type NonNeverType = Exclude; export declare type NonNever = Exclude; export declare enum Bounds { Inclusive = 0, MinExclusive = 1, MaxExclusive = 2, Exclusive = 3 } interface TypeBase { readonly type: Type['type']; readonly underlying: Type['underlying']; /** * Returns a unique string representation for the given type. * * It is guaranteed that any two types with the same type id are equivalent. Likewise, any two * equivalent types are guaranteed to have the same type id. */ getTypeId(): string; toString(): string; } export declare class NumberType implements TypeBase { readonly type = "number"; readonly underlying = "number"; private constructor(); getTypeId(): string; toString(): string; static readonly instance: NumberType; } export declare class NumericLiteralType implements TypeBase { readonly type = "literal"; readonly underlying = "number"; readonly value: number; constructor(value: number); getTypeId(): string; toString(): string; } interface Interval { readonly min: number; readonly max: number; /** * Returns `true` if the given number is contained in this interval. */ has(n: number): boolean; /** * Returns `true` if the given interval is a subset of this interval. */ hasInterval(i: IntervalType): boolean; /** * Returns `true` if the given interval is a subset of this interval. */ hasIntInterval(i: IntIntervalType): boolean; /** * Returns `true` if the given interval is a subset of this interval. */ hasNonIntInterval(i: NonIntIntervalType): boolean; } /** * An interval of numbers. The interval may be closed or open on either end. */ export declare class IntervalType implements TypeBase, Interval { readonly type = "interval"; readonly underlying = "number"; readonly min: number; readonly max: number; readonly bounds: Bounds; get minExclusive(): boolean; get maxExclusive(): boolean; constructor(min: number, max: number, bounds: Bounds); has(n: number): boolean; hasInterval(i: IntervalType): boolean; hasIntInterval(i: IntIntervalType): boolean; hasNonIntInterval(i: NonIntIntervalType): boolean; hasAnyInteger(): boolean; getTypeId(): string; toString(): string; } /** * An interval of integers. Both ends are inclusive unless they are infinite. */ export declare class IntIntervalType implements TypeBase, Interval { readonly type = "int-interval"; readonly underlying = "number"; readonly min: number; readonly max: number; constructor(min: number, max: number); has(n: number): boolean; hasInterval(_: IntervalType): false; hasIntInterval(i: IntIntervalType): boolean; hasNonIntInterval(_: NonIntIntervalType): false; getTypeId(): string; toString(): string; } /** * An interval of numbers that are not integers. Both ends are integers (or infinite) and exclusive. */ export declare class NonIntIntervalType implements TypeBase, Interval { readonly type = "non-int-interval"; readonly underlying = "number"; readonly min: number; readonly max: number; constructor(min: number, max: number); has(n: number): boolean; hasInterval(i: IntervalType): boolean; hasIntInterval(_: IntIntervalType): false; hasNonIntInterval(i: NonIntIntervalType): boolean; getTypeId(): string; toString(): string; } export declare class StringType implements TypeBase { readonly type = "string"; readonly underlying = "string"; private constructor(); getTypeId(): string; toString(): string; static readonly instance: StringType; } export declare class StringLiteralType implements TypeBase { readonly type = "literal"; readonly underlying = "string"; readonly value: string; constructor(value: string); getTypeId(): string; toString(): string; } export declare class InvertedStringSetType implements TypeBase { readonly type = "inverted-set"; readonly underlying = "string"; readonly excluded: ReadonlySet; private cachedTypeId; constructor(excluded: ReadonlySet); has(s: string): boolean; getTypeId(): string; toString(): string; } export declare class AnyType implements TypeBase { readonly type = "any"; readonly underlying = "any"; private constructor(); getTypeId(): string; toString(): string; static readonly instance: AnyType; } export declare class UnionType implements TypeBase { readonly type = "union"; readonly underlying = "union"; readonly items: CanonicalTypes; private cachedTypeId; constructor(items: CanonicalTypes); getTypeId(): string; toString(): string; } export declare class NeverType implements TypeBase { readonly type = "never"; readonly underlying = "never"; private constructor(); getTypeId(): string; toString(): string; static readonly instance: NeverType; } export declare class StructField { readonly name: string; readonly type: NonNeverType; constructor(name: string, type: NonNeverType); } export declare class StructDescriptor { readonly name: string; readonly fields: readonly StructField[]; readonly fieldNames: ReadonlySet; readonly default: StructInstanceType; constructor(name: string, fields?: readonly StructField[]); getField(name: string): StructField | undefined; static compare: (a: StructDescriptor, b: StructDescriptor) => number; } export declare class StructInstanceType implements TypeBase { readonly type = "instance"; readonly underlying = "struct"; readonly descriptor: StructDescriptor; readonly fields: readonly NonNeverType[]; private cachedTypeId; private constructor(); /** * Creates a new instance of the given struct *without* verifying that the fields match the descriptor. * * Prefer using `createInstance` instead. */ static fromDescriptorUnchecked(descriptor: StructDescriptor, fields: readonly NonNeverType[]): StructInstanceType; getField(name: string): NonNeverType | undefined; getTypeId(): string; toString(): string; } export declare class InvertedStructType implements TypeBase { readonly type = "inverted-set"; readonly underlying = "struct"; readonly excluded: ReadonlySet; private cachedTypeId; constructor(excluded: ReadonlySet); has(s: StructDescriptor): boolean; getTypeId(): string; toString(): string; } export declare class StructType implements TypeBase { readonly type = "struct"; readonly underlying = "struct"; private constructor(); getTypeId(): string; toString(): string; static readonly instance: StructType; } export {};