Answer the question
In order to leave comments, you need to log in
How to declare a function interface with multiple call options?
How to declare a function interface with multiple call options?
The function must take either one or 4 parameters
I try like this
export interface IValidator {
(value: any): ValidationError;
(value: any, instance: any, name: string, strict: boolean): ValidationError;
}
const BadValidator: IValidator = (value: any, i: any, n: string, s: boolean): ValidationError => {
return null;
};
const SmallValidator: IValidator = (value: any): ValidationError => {
return null;
};
Type '(value: any, i: any, n: string, s: boolean) => ValidationError'
is not assignable to type 'IValidator'.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question