It may appear that Jasmine has two methods defined (one overloading the other), but this is due to the typing file declaring two versions for different usage scenarios. An example of how an older version of DefinitelyTyped set up the it()
function can be seen here:
// Type definitions for Jasmine 1.3
// ...
declare function it(expectation: string, assertion: () => void): void;
declare function it(expectation: string, assertion: (done: (err?: any) => void) => void): void;
The actual code in that version of Jasmine supports both use cases through a single function as shown here:
base.js (lines 485-501)
/**
* Creates a Jasmine spec that will be added to the current suite.
*
* // TODO: pending tests
*
* @example
* it('should be true', function() {
* expect(true).toEqual(true);
* });
*
* @param {String} desc description of this specification
* @param {Function} func defines the preconditions and expectations of the spec
*/
var it = function(desc, func) {
return jasmine.getEnv().it(desc, func);
};
if (isCommonJS) exports.it = it;
Env.js (lines 151-161)
jasmine.Env.prototype.it = function(description, func) {
var spec = new jasmine.Spec(this, this.currentSuite, description);
this.currentSuite.add(spec);
this.currentSpec = spec;
if (func) {
spec.runs(func);
}
return spec;
};