Typescript 0.9.5 Compiler Errors

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>();

 

Advertisement
About

My musing about anything and everything

Tagged with: ,
Posted in MotorDB, Typescript
One comment on “Typescript 0.9.5 Compiler Errors
  1. Joe Mamma says:

    Thank you so much! There really isn’t a lot out there yet as far as ko errors.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 13 other followers
%d bloggers like this: