diff --git a/kew.js b/kew.js index 7172546..978889c 100644 --- a/kew.js +++ b/kew.js @@ -1,16 +1,13 @@ -/** @typedef {function(?, ?)} */ -var OnSuccessCallbackType; -/** @typedef {function(!Error, ?)} */ -var OnFailCallbackType; /** * An object representing a "promise" for a future value * - * @param {?OnSuccessCallbackType=} onSuccess a function to handle successful + * @param {?function(T)=} onSuccess a function to handle successful * resolution of this promise - * @param {OnFailCallbackType=} onFail a function to handle failed + * @param {?function(!Error)=} onFail a function to handle failed * resolution of this promise * @constructor + * @template T */ function Promise(onSuccess, onFail) { this.promise = this @@ -148,8 +145,8 @@ Promise.prototype.reject = function (e) { * resolves. Allows for an optional second callback to handle the failure * case. * - * @param {?OnSuccessCallbackType} onSuccess - * @param {OnFailCallbackType=} onFail + * @param {?function(this:void, T)} onSuccess + * @param {?function(this:void, !Error)=} onFail * @return {!Promise} returns a new promise with the output of the onSuccess or * onFail handler */ @@ -167,10 +164,11 @@ Promise.prototype.then = function (onSuccess, onFail) { * Provide a callback to be called whenever this promise successfully * resolves. The callback will be executed in the context of the provided scope. * - * @param {?OnSuccessCallbackType} onSuccess - * @param {Object} scope Object whose context callback will be executed in. + * @param {function(this:SCOPE, T)} onSuccess + * @param {SCOPE} scope Object whose context callback will be executed in. * @param {...*} var_args Additional arguments to be passed to the promise callback. * @return {!Promise} returns a new promise with the output of the onSuccess + * @template SCOPE */ Promise.prototype.thenBound = function (onSuccess, scope, var_args) { var promise = new Promise(onSuccess) @@ -191,7 +189,7 @@ Promise.prototype.thenBound = function (onSuccess, scope, var_args) { /** * Provide a callback to be called whenever this promise is rejected * - * @param {OnFailCallbackType} onFail + * @param {function(this:void, !Error)} onFail * @return {!Promise} returns a new promise with the output of the onFail handler */ Promise.prototype.fail = function (onFail) { @@ -202,11 +200,13 @@ Promise.prototype.fail = function (onFail) { * Provide a callback to be called whenever this promise is rejected. * The callback will be executed in the context of the provided scope. * - * @param {OnFailCallbackType} onFail - * @param {Object} scope Object whose context callback will be executed in. + * @param {function(this:SCOPE, Error)} onFail + * @param {SCOPE} scope Object whose context callback will be executed in. + * @param {...?} var_args * @return {!Promise} returns a new promise with the output of the onSuccess + * @template SCOPE */ -Promise.prototype.failBound = function (onFail, scope) { +Promise.prototype.failBound = function (onFail, scope, var_args) { var promise = new Promise(null, onFail) if (this._nextContext) promise._useContext(this._nextContext) diff --git a/package.json b/package.json index fc9375d..fd87902 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "devDependencies": { "q": "0.9.7", "nodeunit": "0.8.1", - "closure-npc": "0.0.9" + "closure-npc": "0.0.10" }, "scripts": { "test": "nodeunit test && closure-npc ./test/closure_test.js --jscomp_error=checkTypes"