closure-library icon indicating copy to clipboard operation
closure-library copied to clipboard

Unknown "this" in goog.partial

Open ChadKillingsworth opened this issue 9 years ago • 1 comments

https://github.com/google/closure-library/blob/master/closure/goog/base.js#L1895

goog.parial is causing warnings with the unknownThis conformance check.

ChadKillingsworth avatar Apr 27 '16 15:04 ChadKillingsworth

Could we change its type to the following?

/** @param {function(this: T, ...*): R} func
    @param {...*} var_args
    @return {function(this: T, ...*): R}
    @template T, R */
goog.partial = function(func, var_args) {};

This should fix the definition, but could introduce problems if callers have underlying type mismatches that were getting glossed over by the raw Functions before. In the interim, we could keep the @return type as {!Function} and then fix callers in a second pass.

shicks avatar May 03 '16 19:05 shicks