I want to write a custom rule for Knockout-Validation library (https://github.com/Knockout-Contrib/Knockout-Validation) using Typescript. I have a .ts file and i'm trying to out this code:
export function enableCustomValidators() {
ko.validation.rules["myRule"] = {
validator: function (val: string, otherVal: string) {
return val === otherVal;
},
message: 'The field must equal {0}',
}
ko.validation.registerExtenders();
}
At build time I am receiving this error: Error TS7017 Element implicitly has an 'any' type because type 'KnockoutValidationRuleDefinitions' has no index signature.
What's the correct way to add a new custom validator using Typescript?
Thanks