Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect type definition for toSatisfy() and toSatisfyAll() #162

Closed
karl-chan opened this issue Aug 27, 2018 · 2 comments
Closed

Incorrect type definition for toSatisfy() and toSatisfyAll() #162

karl-chan opened this issue Aug 27, 2018 · 2 comments

Comments

@karl-chan
Copy link

Bug

  • package version: 0.8.1
  • node version: 8.11.3
  • npm (or yarn) version: 6.1.0
Relevant code or config

The readme demonstrates that toSatisfy() and toSatisfyAll() should accept a predicate:

test('passes when value passes given predicate', () => {
  const greaterThanOneButNotThree = n => n > 1 && n !== 3;
  expect(100).toSatisfy(greaterThanOneButNotThree);
  expect(0).not.toSatisfy(greaterThanOneButNotThree);
  expect(3).not.toSatisfy(greaterThanOneButNotThree);
});

but the TypeScript compiler complains (for this exact example):
Argument of type '(n: any) => boolean' is not assignable to parameter of type '() => boolean'.

What happened (please provide anything you think will help):

In types/index.d.ts, the definitions of toSatisfy() and toSatisfyAll() are incorrectly specified as:

toSatisfy(predicate: () => boolean): R;
toSatisfyAll(predicate: () => boolean): R;

in which the predicate does not accept any argument.

Possible solution:

They should be

toSatisfy(predicate: (value: any) => boolean): R;
toSatisfyAll(predicate: (value: any) => boolean): R;
@benjaminkay93
Copy link
Contributor

I believe this will be resolved in this pr #163 as raised by @tony19

(This is just a note for whomever comes into this issue to look :) )

@mattphillips
Copy link
Member

Closing as #163 is now merged, I’ll publish the fix in a couple of days as I’m AFK travelling atm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants