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

[@types/jasmine] Can't pass jasmine.any(Function) to a function argument in constructor #42352

Closed
4 tasks done
dylansteen opened this issue Feb 13, 2020 · 4 comments
Closed
4 tasks done

Comments

@dylansteen
Copy link

dylansteen commented Feb 13, 2020

Before upgrading typescript to 3.7 and updating to the corresponding version of @jasmine/types, I was able to do the following:

class MyClass {
  constructor(x: Function) {}
}

function myFunction(y: MyClass) {}

...
// Do test stuff
...

expect(myFunction).toHaveBeenCalledWith(new MyClass(jasmine.any(Function)));

I can't do this anymore, I receive this error:

Argument of type 'AsymmetricMatcher<any>' is not assignable to parameter of type 'Function'. Type 'AsymmetricMatcher<any>' is missing the following properties from type 'Function': apply, call, bind, prototype, and 6 more.

@mpicciollicmq
Copy link

@dylansteen same problem for me. Did you find a solution ?

@dylansteen
Copy link
Author

@dylansteen same problem for me. Did you find a solution ?

@mpicciollicmq I don't think so. I believe I just settled for expect(myFunction).toHaveBeenCalled() or otherwise changed the test

@mpicciollicmq
Copy link

mpicciollicmq commented Jan 12, 2021

class MyClass {
  constructor(x: Function) {}
}

function myFunction(y: MyClass) {}

...
// Do test stuff
...

expect(myFunction).toHaveBeenCalledWith(new MyClass(jasmine.any(Function)  as any));

Works for me.

@orta
Copy link
Collaborator

orta commented Aug 3, 2021

Hi thread, we're moving DefinitelyTyped to use GitHub Discussions for conversations the @types modules in DefinitelyTyped.

To help with the transition, we're closing all issues which haven't had activity in the last 6 months, which includes this issue. If you think closing this issue is a mistake, please pop into the TypeScript Community Discord and mention the issue in the definitely-typed channel.

@orta orta closed this as completed Aug 3, 2021
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