UNPKG

@jsonjoy.com/json-type

Version:

High-performance JSON Pointer implementation

27 lines (26 loc) 1.26 kB
import { TypeAlias } from './TypeAlias'; import { TypeBuilder } from '../type/TypeBuilder'; import type { CustomValidator } from './types'; import type { Type, TypeMap } from '../type'; import type { Printable } from 'tree-dump/lib/types'; export declare class TypeSystem implements Printable { readonly t: TypeBuilder; readonly aliases: Map<string, TypeAlias<string, any>>; /** * @todo Add ability fetch object of given type by its ID, analogous to * GraphQL "nodes". */ readonly alias: <K extends string, T extends Type>(id: K, type: T) => TypeAlias<K, T>; readonly unalias: <K extends string>(id: K) => TypeAlias<K, Type>; readonly hasAlias: (id: string) => boolean; readonly resolve: <K extends string>(id: K) => TypeAlias<K, Type>; protected readonly customValidators: Map<string, CustomValidator>; readonly addCustomValidator: (validator: CustomValidator) => void; readonly getCustomValidator: (name: string) => CustomValidator; exportTypes(): Record<string, unknown>; importTypes<A extends TypeMap>(types: A): { readonly [K in keyof A]: TypeAlias<K extends string ? K : never, /** @todo Replace `any` by inferred type here. */ any>; }; toString(tab?: string): string; }