1 jaydata typescript visual-studio-2013
刚开始玩JayData lib.并希望获得TypeScript的好处.我已经在我的VS2013项目中包含以下文件: - jaydata.js - jaydata.d.ts - JayDataContext.js,使用JaySvcUtil(v.1.3.5)创建 - JayDataContext.d.ts,使用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
Run Code Online (Sandbox Code Playgroud)
我想我错过了一些微不足道的东西,但我不知道是什么.谁能帮我?谢谢.
1)Object接口在lib.d.ts中定义,并在最新版本中略有改变,类型推理系统普遍收紧.只需更改jaydata.d.ts以便valueOf返回一个Object并且已经解决了.
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;
}
Run Code Online (Sandbox Code Playgroud)
2)这是由同样的紧缩造成的.在没有类型参数的泛型类型之前,它会假设任何类型,现在它是一个错误,而不是做出这个假设.如果您明确说明,代码将工作相同.例如:
旧:
var x: IPromise;
Run Code Online (Sandbox Code Playgroud)
新:
var x: IPromise<any>;
Run Code Online (Sandbox Code Playgroud)
我理解在1.0版本发布后是否会发生这些突破性变化.
| 归档时间: |
|
| 查看次数: |
425 次 |
| 最近记录: |