If you know how to fix the issue, make a pull request instead.
@types/jest package and had problems.Definitions by: in index.d.ts) so they can respond.After updating @types/jest to 24.0.20, we had the following error. We were able to fix the issue by downgrading to 24.0.19, so this appears to be an issue with the changes in 24.0.20.
`ï½¢atlï½£: Using [email protected] from typescript
ï½¢atlï½£: Using tsconfig.json from C:/Projects/projectname/tsconfig.json
ï½¢atlï½£: Checking started in a separate process...
ï½¢atlï½£: Checking finished with 2 errors
Child
ERROR in [at-loader] ./node_modules/jest-enzyme/lib/index.d.ts:7:15
TS2428: All declarations of 'Matchers' must have identical type parameters.
ERROR in [at-loader] ./node_modules/@types/jest/index.d.ts:639:15
TS2428: All declarations of 'Matchers' must have identical type parameters.
pm ERR! code ELIFECYCLE `
Yeah, that’s because of #39243.
I read through #39243, but I didn't discern from that issue what steps I should be taking. Do I need to wait until for a change to @types/jest? Wait for jest-enzyme to catch up to the change in @types/jest? Or is there another package I can update to resolve my error? For now, I have pinned the version at 24.0.19.
You need to wait for jest-enzyme to add the new T type parameter to Matchers.
I see this in the types file
// should be R extends void|Promise<void> but getting dtslint error
interface Matchers<R, T = {}> {
jest-extended has this interface Matchers<R, T = void> {
https://github.com/jest-community/jest-extended/blob/master/types/index.d.ts#L5
Which is right? should it be T = {} or T = void ?
T = {}
See comment
R should be either void or Promise<void> but definitely typed files go through dtslint which was erroneously preventing this.
@kbradl16
On further thoughts I think T should just be T. The default was there for backwards compatibility, given that it is present T should be T.
I also think that there is an error with toContainEntry. Also probably with toContainEntries, toContainAllEntries and toContainAnyEntries.
toContainEntry<T>(entry: [keyof T, T[keyof T]]): R;
I think that it should be toContainEntry(entry: [keyof T, T[keyof T]]): R;
( The Expect interface on the other hand is correct. )
This is the source code
Given that testing property of T (TActual) - key should come from that T, not some other T.
export default {
toContainEntry: (actual, expected) => {
const pass = predicate(actual, expected);
/*
predicate code
export default (obj, [key, value]) => obj.hasOwnProperty && obj.hasOwnProperty(key) && equals(obj[key], value);
*/
if (pass) {
return { pass: true, message: passMessage(actual, expected) };
}
return { pass: false, message: failMessage(actual, expected) };
}
};
predicate.js
export default (obj, [key, value]) => obj.hasOwnProperty && obj.hasOwnProperty(key) && equals(obj[key], value);
@mattphillips
Given that Matchers are used for the return type of expect and expect is typed as :
<T = any>(actual: T): JestMatchers<T>;
type JestMatchers<T> = JestMatchersShape<Matchers<void, T>, Matchers<Promise<void>, T>>;
T should default to type any rather than {}.
Most helpful comment
T = {}
See comment
R should be either void or
Promise<void>but definitely typed files go through dtslint which was erroneously preventing this.