UNPKG

typir

Version:

General purpose type checking library

40 lines 2.58 kB
/****************************************************************************** * Copyright 2024 TypeFox GmbH * This program and the accompanying materials are made available under the * terms of the MIT License, which is available in the project root. ******************************************************************************/ import { Type } from '../graph/type-node.js'; import { TypirServices, TypirSpecifics } from '../typir.js'; import { TypeInitializer } from './type-initializer.js'; import { TypeReference } from './type-reference.js'; export type BasicTypeDescriptor<T extends Type, Specifics extends TypirSpecifics> = T | string | TypeInitializer<T, Specifics> | TypeReference<T, Specifics> | Specifics['LanguageType']; /** * This TypeScript type defines the possible ways to identify a desired Typir type. */ export type TypeDescriptor<T extends Type, Specifics extends TypirSpecifics> = BasicTypeDescriptor<T, Specifics> | (() => BasicTypeDescriptor<T, Specifics>); export interface TypeResolvingService<Specifics extends TypirSpecifics> { /** * Tries to find the specified type in the type system. * This method does not care about the initialization state of the found type, * this method is restricted to just search and find any type according to the given TypeDescriptor. * @param descriptor the specification for the desired type * @returns the found type; or undefined, if there is no such type in the type system */ tryToResolve<T extends Type>(descriptor: TypeDescriptor<T, Specifics>): T | undefined; /** * Finds the specified type in the type system. * This method does not care about the initialization state of the found type, * this method is restricted to just search and find any type according to the given TypeDescriptor. * @param descriptor the specification for the desired type * @returns the found type; or an exception, if the type cannot be resolved */ resolve<T extends Type>(descriptor: TypeDescriptor<T, Specifics>): T; } export declare class DefaultTypeResolver<Specifics extends TypirSpecifics> implements TypeResolvingService<Specifics> { protected readonly services: TypirServices<Specifics>; constructor(services: TypirServices<Specifics>); tryToResolve<T extends Type>(descriptor: TypeDescriptor<T, Specifics>): T | undefined; resolve<T extends Type>(descriptor: TypeDescriptor<T, Specifics>): T; protected handleError<T extends Type>(result: T | undefined, errorMessage: string): T; } //# sourceMappingURL=type-descriptor.d.ts.map