typir
Version:
General purpose type checking library
45 lines • 3.1 kB
TypeScript
/******************************************************************************
* 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 { Kind } from '../kinds/kind.js';
import { InferenceProblem } from '../services/inference.js';
import { TypirServices, TypirSpecifics } from '../typir.js';
import { NameTypePair, TypirProblem } from './utils-definitions.js';
export type TypeCheckStrategy = 'EQUAL_TYPE' | // the most strict checking
'ASSIGNABLE_TYPE' | // SUB_TYPE or implicit conversion
'SUB_TYPE';
export declare function createTypeCheckStrategy<Specifics extends TypirSpecifics>(strategy: TypeCheckStrategy, typir: TypirServices<Specifics>): (t1: Type, t2: Type) => TypirProblem | undefined;
export interface ValueConflict extends TypirProblem {
readonly $problem: 'ValueConflict';
firstValue: string | undefined;
secondValue: string | undefined;
location: string;
subProblems?: TypirProblem[];
}
export declare const ValueConflict = "ValueConflict";
export declare function isValueConflict(problem: unknown): problem is ValueConflict;
export declare function checkValueForConflict<T>(first: T, second: T, location: string, relationToCheck?: (e: T, a: T) => boolean): ValueConflict[];
export declare function createKindConflict(first: Type | Kind, second: Type | Kind): ValueConflict;
export interface IndexedTypeConflict extends TypirProblem {
$problem: 'IndexedTypeConflict';
expected: Type | undefined;
actual: Type | undefined;
propertyIndex?: number;
propertyName?: string;
subProblems: TypirProblem[];
}
export declare const IndexedTypeConflict = "IndexedTypeConflict";
export declare function isIndexedTypeConflict(problem: unknown): problem is IndexedTypeConflict;
export type TypeToCheck<Specifics extends TypirSpecifics> = Type | NameTypePair | undefined | Array<InferenceProblem<Specifics>>;
export declare function checkTypes<Specifics extends TypirSpecifics>(left: TypeToCheck<Specifics>, right: TypeToCheck<Specifics>, relationToCheck: (l: Type, r: Type) => (TypirProblem | undefined), checkNamesOfNameTypePairs: boolean): IndexedTypeConflict[];
export declare function checkTypeArrays<Specifics extends TypirSpecifics>(leftTypes: Array<TypeToCheck<Specifics>>, rightTypes: Array<TypeToCheck<Specifics>>, relationToCheck: (l: Type, r: Type, index: number) => (TypirProblem | undefined), checkNamesOfNameTypePairs: boolean): IndexedTypeConflict[];
export declare function checkNameTypesMap(sourceFields: Map<string, Type | undefined>, targetFields: Map<string, Type | undefined>, relationToCheck: (s: Type, t: Type) => (TypirProblem | undefined)): IndexedTypeConflict[];
export declare class MapListConverter {
protected names: string[];
toList<T>(values: Map<string, T>): T[];
toMap<T>(values: T[]): Map<string, T>;
}
//# sourceMappingURL=utils-type-comparison.d.ts.map