RequireJS module requests in TypeScript

I recently upgraded to TypeScript 0.9.5, which now causes new errors at compile time.

I am defining an AMD module using RequireJS as described HERE .

define('myModule', [
    'angular',
    'config'
    ], function (angular, config) {
        'use strict';

        ...
});

The TypeScript definition file for RequireJS has the following definition for RequireDefine:

/**
* Define a module with a name and dependencies.
* @param name The name of the module.
* @param deps List of dependencies module IDs.
* @param ready Callback function when the dependencies are loaded.
*   callback deps module dependencies
*   callback return module definition
**/
(name: string, deps: string[], ready: (...deps: any[]) => any): void;

However, I get the following errors:

error TS2082: Build: Supplied parameters do not match any signature of call target:
error TS2087: Build: Could not select overload for 'call' expression.

Intellisense error:

Calling signatures of types '(angular: any, config: any) => any' and '(... deps: any []) => any' are incompatible.

Is the definition file incorrect? Where am I mistaken with callback parameters?

Additional Information:

Now the following declaration is compiled:

define('myModule', [
    'angular',
    'config'
    ], function (...args:any[]) {
        'use strict';

        ...
});

However, the transition to a single parameter object is, of course, a step backward? Is this a limitation of a TypeScript definition file or compiler?

+4
2

TypeScript?

. "" TypeScript ( , ) .

:

function argLoving(fn: (...deps: any[]) => any){

}

argLoving(function(x,y){ // <- compile error

});

, argLoving x y - ​​ varargs, .

:

function argLoving(fn: (...deps: any[]) => any){

}
function foo(x:any,y:any){

}
argLoving(foo);

, argLoving , , foo .

.

# * (, Func), , & - , , .d.ts:

, , :

function argLoving(fn: (x:any) => any)
function argLoving(fn: (x:any,y:any) => any)
function argLoving(fn: (x:any,y:any,z:any) => any)
function argLoving(fn: (x:any,y:any,z:any,a:any) => any)
function argLoving(fn: (...deps: any[]) => any){

}
function foo(x:any,y:any){

}
argLoving(foo); // this compiles now

* http://msdn.microsoft.com/en-us/library/bb534960(v=vs.110).aspx - Action Func


Update:

, GitHub - DefinitelyTyped put pull , , https://github.com/borisyankov/DefinitelyTyped/issues/1434, https://github.com/borisyankov/DefinitelyTyped/pull/1435

+4

, - - :

function require(fn: Function){

}
+1

All Articles