Split function generic into generic types for args and return value #61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This allows us to specifically reference these types within
memoizeOne
and is more consistent with how decorators like these are typed elsewhere [1] [2]This also has the nice side effect of removing the
any
casting on the memoized function.This is a breaking change in the case users of
memoizeOne
were specifyingResultType
specifically rather than letting Flow infer the type of it.It also renames the input function to
inputFn
instead ofresultFn
, which I found confusing (I assume this stemmed from the name of the type that served to type both the input and output function). Hope that's all right.I'm very open to feedback!
Test Plan:
yarn test
[1] https://github.com/flow-typed/flow-typed/blob/master/definitions/npm/lodash_v4.x.x/flow_v0.63.x-/lodash_v4.x.x.js#L789
[2] https://github.com/sindresorhus/mem/blob/master/index.d.ts#L74