-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
chore(types): separate MatcherContext, MatcherUtils and MatcherState #13141
chore(types): separate MatcherContext, MatcherUtils and MatcherState #13141
Conversation
|
||
export type MatcherFunction<Expected extends Array<unknown> = []> = | ||
MatcherFunctionWithState<MatcherState, Expected>; | ||
MatcherFunctionWithContext<MatcherContext, Expected>; | ||
|
||
// TODO should be replaced with `MatcherFunctionWithContext` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrazauskas what is this TODO for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I recall it right, MatcherFunction
and MatcherFunctionWithContext
does not allow any
type of actual
and expected
values. Or so. Currently there is a need to have any
s internally, but would be nicer to rework these into unknown
s. After this will be done, RawMatcherFn
can be replaced with MatcherFunctionWithContext
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other words, RawMatcherFn
is redundant type, but it cannot be removed at this moment.
@@ -41,12 +45,19 @@ export type MatchersObject = { | |||
export type ThrowingMatcherFn = (actual: any) => void; | |||
export type PromiseMatcherFn = (actual: any) => Promise<void>; | |||
|
|||
export interface MatcherUtils { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just extracted the fields that felt more "util-y" - should I take others?
}; | ||
|
||
const matcherContext: MatcherContext = { | ||
...getState<MatcherState>(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explicit generic as otherwise it inferred MatcherContext
and didn't error when MatcherContext
where missing
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Inspired by DefinitelyTyped/DefinitelyTyped#61717 which differentiates.
Test plan
Green CI