Skip to content

Commit

Permalink
Defaults for jest.fn's type parameters
Browse files Browse the repository at this point in the history
Summary:
This diff adds defaults to Jest.fn's type params.

An upcoming change to flow will be more restrictive about how we implicitly instantiation type arguments. Since the argument to jest.fn is often omitted, this signature is the single biggest offender of our new rules. To reduce the error diff, I'm adding reasonable defaults so that the mocked function can still behave like a function without adding extra flow errors where there were none before.

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D40394215

fbshipit-source-id: 2df596b6ba8b54680694e08c432a1e7c94dc2df0
  • Loading branch information
jbrown215 authored and facebook-github-bot committed Oct 14, 2022
1 parent 3e58a9c commit 4664292
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion flow/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ type JestObjectType = {
* Returns a new, unused mock function. Optionally takes a mock
* implementation.
*/
fn<TArguments: $ReadOnlyArray<mixed>, TReturn>(
fn<TArguments: $ReadOnlyArray<mixed> = $ReadOnlyArray<mixed>, TReturn = any>(
implementation?: (...args: TArguments) => TReturn,
): JestMockFn<TArguments, TReturn>,
/**
Expand Down

0 comments on commit 4664292

Please sign in to comment.