fix(@jest/types): add partial support for done callbacks in typings of each#13756
fix(@jest/types): add partial support for done callbacks in typings of each#13756SimenB merged 11 commits intojestjs:mainfrom mrazauskas:fix-support-done-callback-in-each-types
done callbacks in typings of each#13756Conversation
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.
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.