check-more-types icon indicating copy to clipboard operation
check-more-types copied to clipboard

defend() blasts context

Open boneskull opened this issue 9 years ago • 2 comments
trafficstars

I think defend() should run the function in its context.

Trivial failing example:

const foo = {
  bar: 'baz',
  quux: check.defend(function quux(val) {
    // TypeError; `this.bar` is undefined
    return val.length > this.bar.length;
  }, 'string')
};

boneskull avatar Jun 13 '16 08:06 boneskull

hmm, I never used checks with OO examples, need to stop blasting the context

bahmutov avatar Jun 13 '16 13:06 bahmutov

'string' should be something else I think but the issue is still valid

boneskull avatar Jun 13 '16 16:06 boneskull