Question

Just started to play with JayData lib. and want to take the benefits of TypeScript. I've included in my VS2013 project following files: - jaydata.js - jaydata.d.ts - JayDataContext.js, created with JaySvcUtil (v. 1.3.5) - JayDataContext.d.ts, created with JaySvcUtil

1) There is a compile error in jaydata.d.ts, line 2
interface IPromise<T> extends Object {
Error   1   Interface '$data.IPromise<T>' cannot extend interface 'Object':
Types of property 'valueOf' of types 'IPromise<T>' and 'Object' are incompatible:
Call signatures of types '() => any' and '() => Object' are incompatible.   C:\Users\robbin\documents\visual studio 2013\Projects\TypeScriptHTMLApp1\TypeScriptHTMLApp1\scripts\jaydata.d.ts    2   15  TypeScriptHTMLApp1

2)There are a lot of compile errors in JayDataContext.ts beacuse '$data.IPromise' it is not 'used' as generic type
Error   2   Generic type references must include all type arguments.    C:\Users\robbin\documents\visual studio 2013\Projects\TypeScriptHTMLApp1\TypeScriptHTMLApp1\scripts\jaydatacontext.d.ts 1623    16  TypeScriptHTMLApp1

I guess I'm missing something trivial but I don't know what. Can anyone help me? Thanks.

Was it helpful?

Solution

1) The Object interface is defined in lib.d.ts and changed slightly in the latest release with the general tightening up of the type inference system. Just change jaydata.d.ts so that valueOf returns an Object and that's solved.

interface IPromise<T> extends Object {
    then: {
        (handler: (args: T) => void ): IPromise<any>;
        (handler: (args: T) => any): IPromise<any>;
    };
    fail: {
        (handler: (args: T) => void ): IPromise<any>;
        (handler: (args: T) => any): IPromise<any>;
    };
    valueOf(): Object;
}

2) This is caused by the same tightening up. Before when there was a generic type with no type parameter it would assume any, and now it's an error instead of making that assumption. The code will work the same if you just make it explicit. For example:

Old:

var x: IPromise;

New:

var x: IPromise<any>;

My understanding if that these kinds of breaking changes won't happen after the 1.0 release.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top