Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript 0.9 + Knockout: strange compiler errors

I just upgraded my code to Typescript 0.9, updated the DefinitelyTyped definitions of Jquery, JqueryUI, Knockout, Knockout.Mapping and Knockout.Validation.

The code seemingly compiles, I see the correct output js files.

Yet VS underlines EVERY use of the obs(value: T) setter on KnockoutObservable<T> and KnockoutObservableArray<T>, saying I provided invalid type.

Error   27  Supplied parameters do not match any signature of call target.  
Error   28  Could not select overload for 'call' expression.

I have about a 100 of these errors. When I try to type one in, the intellisense offers (): T and (value: bool):void for every type - yes, it's bool regardless of the T I specified. Is it a VS, a compiler or a WebEssentials bug? How do I make the ~100 errors disappear?

EDIT (visual evidence): enter image description herelot.TimeOnServer is a KnockoutObservable<number>, data.TimeOnServer is a number.

Yes, I have restarted vs+windows. The error persisted.

like image 810
TDaver Avatar asked Nov 02 '22 19:11

TDaver


1 Answers

I was having this same issue. I haven't investigated why this is happening, but in my project after commenting out the last interface in knockout.validation.d.ts the errors go away. This will break your call to isValid for validation though.

interface KnockoutSubscribableFunctions {
  isValid: KnockoutComputed<boolean>;
  isValidating: KnockoutObservable<boolean>;
  rules: KnockoutObservableArray<KnockoutValidationRule>;
}

I added the following to get back the isValid function

interface KnockoutObservableBase {
    isValid: KnockoutComputed<boolean>;
    isValidating: KnockoutObservable<boolean>;
    rules: KnockoutObservableArray<KnockoutValidationRule>;
}
like image 111
Andy May Avatar answered Nov 09 '22 02:11

Andy May