@jsonjoy.com/json-type
Version:
High-performance JSON Pointer implementation
26 lines (25 loc) • 1.19 kB
TypeScript
import { TypeBuilder } from '../../TypeBuilder';
import { AliasType } from '../AliasType';
import type { Printable } from 'tree-dump/lib/types';
import type { ModuleSchema, TypeMap } from '../../../schema';
import type { Type } from '../../../type';
export declare class ModuleType implements Printable {
static readonly from: (module: ModuleSchema) => ModuleType;
readonly t: TypeBuilder;
readonly aliases: Map<string, AliasType<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) => AliasType<K, T>;
readonly unalias: <K extends string>(id: K) => AliasType<K, Type>;
readonly hasAlias: (id: string) => boolean;
readonly resolve: <K extends string>(id: K) => AliasType<K, Type>;
exportTypes(): Record<string, unknown>;
import(module: ModuleSchema): void;
importTypes<Aliases extends TypeMap>(aliases: Aliases): {
readonly [K in keyof Aliases]: AliasType<K extends string ? K : never,
/** @todo Replace `any` by inferred type here. */ any>;
};
toString(tab?: string): string;
}