import { Expression, NewExpression } from './expressions'; import { IProperty, PropertySpec } from './property'; import { IScope } from './scope'; import { ThingSymbol } from './symbol'; import { TypeDeclaration } from './type-declaration'; export declare enum PrimitiveType { /** * A JSON date-time or date (represented as it's ISO-8601 string form). */ DateTime = "date-time", /** * A plain string. */ String = "string", /** * A number (integer or float). */ Number = "number", /** * A boolean value. */ Boolean = "boolean", /** * The value "Undefined" */ Undefined = "undefined", /** * A JSON object */ Json = "json", /** * Value with "any" or "unknown" type (aka Object). Values typed `any` may * be `null` or `undefined`. */ Any = "any", /** * No type */ Void = "void" } export type TypeReferenceSpec = { readonly fqn: string; readonly genericArguments?: Type[]; } | { readonly primitive: PrimitiveType; } | { readonly collection: { readonly kind: 'map' | 'array'; readonly elementType: Type; }; } | { readonly object: PropertySpec[]; } | { readonly union: Type[]; }; /** * A reference to an existing type in the given scope */ export declare class Type { readonly scope?: IScope | undefined; readonly symbol?: ThingSymbol | undefined; static readonly ANY: Type; static readonly VOID: Type; static readonly DATE_TIME: Type; static readonly STRING: Type; static readonly NUMBER: Type; static readonly BOOLEAN: Type; static readonly UNDEFINED: Type; static fromName(scope: IScope, name: string, genericArguments?: Type[]): Type; static arrayOf(elementType: Type): Type; static mapOf(elementType: Type): Type; static unionOf(...types: Type[]): Type; /** * A union that only contains distinct elements * * Flattens any unions of unions into a single flat union. * Type distinctiveness is determined based on its string representation. */ static distinctUnionOf(...types: Type[]): Type; static ambient(name: string): Type; /** * @see https://www.typescriptlang.org/docs/handbook/2/objects.html */ static anonymousInterface(props: PropertySpec[]): Type; readonly spec: TypeReferenceSpec; private constructor(); toString(): string; get fqn(): string | undefined; get isVoid(): boolean; get isAny(): boolean; get primitive(): PrimitiveType | undefined; get declaration(): TypeDeclaration | undefined; get arrayOfType(): Type | undefined; get mapOfType(): Type | undefined; get unionOfTypes(): Type[] | undefined; get object(): IProperty[] | undefined; get genericArguments(): Type[] | undefined; withGenericArguments(...genericArguments: Type[]): Type; newInstance(...args: Expression[]): NewExpression; optional(): Type; equals(rhs: Type): boolean; }