Interface InferFunctionCall<Specifics, T>

An inference rule which is dedicated for inferrring a certain type. This utility type is often used for inference rules which are annotated to the declaration of a type. At least one of the properties needs to be specified.

interface InferFunctionCall<
    Specifics extends TypirSpecifics,
    T extends Specifics["LanguageType"] = Specifics["LanguageType"],
> {
    filter?: (languageNode: Specifics["LanguageType"]) => languageNode is T;
    inputArguments: (languageNode: T) => Specifics["LanguageType"][];
    languageKey?: string | string[];
    matching?: (languageNode: T, typeToInfer: FunctionType) => boolean;
    skipThisRuleIfThisTypeAlreadyExists?:
        | boolean
        | (existingType: FunctionType) => boolean;
    validateArgumentsOfFunctionCalls?: boolean | (languageNode: T) => boolean;
    validation?:
        | InferCurrentTypeValidationRule<FunctionType, Specifics, T>
        | InferCurrentTypeValidationRule<FunctionType, Specifics, T>[];
}

Type Parameters

Hierarchy (View Summary)

Properties

filter?: (languageNode: Specifics["LanguageType"]) => languageNode is T
inputArguments: (languageNode: T) => Specifics["LanguageType"][]

In case of overloaded functions, these input arguments are used to determine the actual function by comparing the types of the given arguments with the expected types of the input parameters of the function.

languageKey?: string | string[]
matching?: (languageNode: T, typeToInfer: FunctionType) => boolean
skipThisRuleIfThisTypeAlreadyExists?:
    | boolean
    | (existingType: FunctionType) => boolean
validateArgumentsOfFunctionCalls?: boolean | (languageNode: T) => boolean

This property controls the builtin validation which checks, whether the types of the given arguments of the function call fit to the expected types of the parameters of the function. The function calls to validate are represented by this inference rule, i.e. function calls represented by other inference rules have their own property and are not influenced by the value of this inference rule. By default, the property is switched off (e.g. validateArgumentsOfFunctionCalls: false), but in most applications this validation is desired and should be switched on (e.g. with validateArgumentsOfFunctionCalls: true). This property does not influence the type inference, this property determines only, whether this special validation is applied to the current function call.

This property is specific for this function type. If this function type is not overloaded, this property switches this validation off and on for the calls of this function, i.e. creates validation issues for all calls with mismatching argument types.

If this function type is overloaded, different values for this property for different overloaded functions might be specified: If the property is switched off for all overloads, no validation issues will be created. If the property is switched on for at least one overload, validation issues for will be shown for all calls (when none of the signatures match), since it is unclear, which of the overloads is the desired one! But the shown validation issue/message will not report about signatures for which this validation property is switched off. While different values for this property for different overloads are possible in theory with the defined behaviour, in practise this seems to be rarely useful.

This validation will be applied to all language nodes for which the current type is inferred according to this inference rule. This validation is specific for this inference rule and this inferred type.