typescript compiler bug? knockout.validation.d.ts doesn't compile anymore

Viewed 4700

I just updated Typescript from v2.3 to v2.4, and now it is giving me an error on the knockout.validation.d.ts lines:

interface KnockoutSubscribableFunctions<T> {
    isValid: KnockoutComputed<boolean>;
    isValidating: KnockoutObservable<boolean>;
    rules: KnockoutObservableArray<KnockoutValidationRule>;
    isModified: KnockoutObservable<boolean>;
    error: KnockoutComputed<string>;
    setError(error: string): void;
    clearError(): void;
}

Here knockout.validation is trying to indicate that KnockoutSubscribableFunctions now has extra members. Here is the definition of this interface in knockout.d.ts:

interface KnockoutSubscribableFunctions<T> {
    [key: string]: KnockoutBindingHandler;

    notifySubscribers(valueToWrite?: T, event?: string): void;
}

the compiler now complains that:

Property 'isValid' of type 'KnockoutComputed' is not assignable to string index type 'KnockoutBindingHandler'.

I don't understand why it doesn't see these new values as new properties in the interface? why is it trying to say that they have to map onto the index signatures? The docs seem to indicate that you can have the index signature and other properties in the same interface.

I took the initial definition of the interface into the playground and it even complained that notifySubscribers isn't assignable to a KnockoutBindingHandler.

With the new compiler how would you get this code to compile?

For now there I'm using a brute force method to get this to compile, in which I am changing the knockout.d.ts definition to be as follows:

interface KnockoutSubscribableFunctions<T> {
    [key: string]: any;//KnockoutBindingHandler;

    notifySubscribers(valueToWrite?: T, event?: string): void;
}
1 Answers
Related