Typescript 0.9.5 has been released by Microsoft and is available to download here:
http://www.microsoft.com/en-us/download/details.aspx?id=34790,
With the release notes available here:
http://blogs.msdn.com/b/typescript/archive/2013/12/05/announcing-typescript-0-9-5.aspx
After downloading, and installing the latest version, I now have two typescript compile error within the MotorDB Project:
Type ‘{}’ is missing property ‘Identifier’ from type ‘Policy’.
Types of property ‘extend’ of types ‘KnockoutObservableArray<{}>’ and ‘KnockoutObservableArray<Policy>’ are incompatible:
Call signatures of types ‘(requestedExtenders: { [key: string]: any; }) => KnockoutObservableArray<{}>’ and ‘(requestedExtenders: { [key: string]: any; }) => KnockoutObservableArray<Policy>’ are incompatible:
Type ‘{}’ is missing property ‘Identifier’ from type ‘Policy’.
Types of property ‘peek’ of types ‘KnockoutObservableArray<{}>’ and ‘KnockoutObservableArray<Policy>’ are incompatible:
Call signatures of types ‘() => {}[]’ and ‘() => Policy[]’ are incompatible:
Type ‘{}’ is missing property ‘Identifier’ from type ‘Policy’.
Types of property ‘concat’ of types ‘{}[]’ and ‘Policy[]’ are incompatible:
Call signatures of types ‘{ <U extends T[]>(…items: U[]): {}[]; (…items: {}[]): {}[]; }’ and ‘{ <U extend …
and
Cannot convert ‘KnockoutObservableArray<{}>’ to ‘KnockoutObservableArray<Policy>’
With the first error listed, all I could think of is what the? I should have focused on the second error message as that indicates the problem.
It appears that Generics are working within typescript, so all that is needed is one small change:
In the constructor of the PolicyViewModel class an observable array of Policy is defined
self.Policies = ko.observableArray([]);
All that needs to be done to correct the compiler errors is specify that the array must of of type Policy, and everything compiles:
self.Policies = ko.observableArray<Policy>();
Related articles
- TypeScript in Studio 2013 with Bill Wagner (dotnetrocks.com)
- Microsoft’s TypeScript language winds its way toward 1.0 (lgitss.wordpress.com)
Thank you so much! There really isn’t a lot out there yet as far as ko errors.