我有這樣的情況下,該文件是t.ts:打字稿可變數量0.9.5
interface Itest{
(event: any, ...args: any[]):any;
}
var t1: Itest = function (testparam) { return true;};
var t2: Itest = function (testparam, para1) { return true; };
var t3: Itest = function (testparam, para1, para2) { return true; };
interface Itest2 {
(event: any, para1,...args: any[]): any;
}
var t4: Itest2 = function (testparam, para1) { return true; };
var t5: Itest2 = function (testparam, para1, para2) { return true; };
當我編譯這個與TSC 0.9.5我收到以下錯誤:
tsc --target ES5 "t.ts"
t.ts(6,8): error TS2012: Cannot convert '(testparam: any, para1: any) => boolean' to 'Itest':
Call signatures of types '(testparam: any, para1: any) => boolean' and 'Itest' are incompatible:
Call signature expects 1 or fewer parameters.
t.ts(7,8): error TS2012: Cannot convert '(testparam: any, para1: any, para2: any) => boolean' to 'Itest':
Call signatures of types '(testparam: any, para1: any, para2: any) => boolean' and 'Itest' are incompatible:
Call signature expects 1 or fewer parameters.
t.ts(14,8): error TS2012: Cannot convert '(testparam: any, para1: any, para2: any) => boolean' to 'Itest2':
Call signatures of types '(testparam: any, para1: any, para2: any) => boolean' and 'Itest2' are incompatible:
Call signature expects 2 or fewer parameters.
我錯過了什麼,或者這是壞的?它曾經在0.9.1.1中工作。謝謝!
這在0.9.5已知重大更改看到的是新的[休息參數現在正確檢查函數arity](https://typescript.codeplex.com/wikipage?title=Known%20breaking%20changes%20between%200.8%20and%200.9) – nemesv