-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
fix(@jest/types): add partial support for done callbacks in typings of each
#13756
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
fix(@jest/types): add partial support for done callbacks in typings of each
#13756
Conversation
done callbacks in each typesdone callbacks in typings of each
|
This PR is introduced type errors in tests of Jest repo, for example: test.each([
['Boolean', {automock: []}],
['Array', {coverageReporters: {}}],
['String', {preset: 1337}],
['Object', {haste: 42}],
// now needs this type cast to be added to pass type check
] as Array<[string, Record<string, unknown>]>)(
'pretty prints valid config for %s',
(_type, config) => {
expect(() =>
validate(config, {
exampleConfig: validConfig,
}),
).toThrowErrorMatchingSnapshot();
},
);Hm.. Looks breaking and less flexible for the user. Not sure if |
|
A |
|
/cc @mattphillips |
done callbacks in typings of each done callbacks in typings of each
|
Perhaps partial support could be added for now? Unfortunately I have no idea how to make this work, if table is an array of arrays. In other cases |
|
Some support is better than nothing 👍 |
|
Took a better look. All seems to be correct. It is possible to type the // user can pass `done`:
test.each([3, 4, 'seven'])('some test', (c, done) => {
//
}
// or simply omit it (equivalent to current typings):
test.each([3, 4, 'seven'])('some test', (c) => {
//
}
test.each([
{a: 1, b: 2, expected: 'three', extra: true},
{a: 3, b: 4, expected: 'seven', extra: false},
{a: 5, b: 6, expected: 'eleven'},
])(
'some test',
({a, b, expected, extra}, done) => {
// or:
// ({a, b, expected, extra}) => {
//
}
test.each`
a | b | expected
${1} | ${1} | ${2}
${1} | ${2} | ${3}
${2} | ${1} | ${3}
`('some test', ({a, b, expected}, done) => {
// or:
// `('some test', ({a, b, expected}) => {
//
}I can’t find a way to add typings for |
SimenB
left a comment
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.
seems reasonable to me 👍 Not complete like you say, but better than nothing 😀
|
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. |
Based on DefinitelyTyped/DefinitelyTyped#63882
Summary
As it was pointed out on DT, current types of
eachdo not supportdonecallbacks. That is undocumented feature, but it works (at least it worked for me in few simple checks).Worth to add this for completeness. Perhaps?
Test plan
Type tests added.