diff --git a/types/enzyme/enzyme-tests.tsx b/types/enzyme/enzyme-tests.tsx index 720037cbfa..50f9bf3f38 100644 --- a/types/enzyme/enzyme-tests.tsx +++ b/types/enzyme/enzyme-tests.tsx @@ -109,8 +109,13 @@ function ShallowWrapperTest() { function test_filter() { anotherComponentWrapper = shallowWrapper.filter(AnotherComponent); anotherStatelessWrapper = shallowWrapper.filter(AnotherStatelessComponent); + // NOTE: The following calls to filter do not narrow down the possible type of the result based + // on the type of the param, so the return type should not be different than the original + // "this". This is a special case for "filter" vs other methods like "find", because "filter" + // is guaranteed to return only a subset of the existing list of components/elements without + // finding/adding more. shallowWrapper = shallowWrapper.filter({ numberProp: 12 }); - elementWrapper = shallowWrapper.filter('.selector'); + shallowWrapper = shallowWrapper.filter('.selector'); } function test_filterWhere() { @@ -487,10 +492,15 @@ function ReactWrapperTest() { } function test_filter() { - elementWrapper = reactWrapper.filter('.selector'); anotherComponentWrapper = reactWrapper.filter(AnotherComponent); anotherStatelessWrapper = reactWrapper.filter(AnotherStatelessComponent); + // NOTE: The following calls to filter do not narrow down the possible type of the result based + // on the type of the param, so the return type should not be different than the original + // "this". This is a special case for "filter" vs other methods like "find", because "filter" + // is guaranteed to return only a subset of the existing list of components/elements without + // finding/adding more. reactWrapper = reactWrapper.filter({ numberProp: 12 }); + reactWrapper = reactWrapper.filter('.selector'); } function test_filterWhere() { diff --git a/types/enzyme/index.d.ts b/types/enzyme/index.d.ts index 4d3c75d6c1..d23af4ab04 100644 --- a/types/enzyme/index.d.ts +++ b/types/enzyme/index.d.ts @@ -375,8 +375,7 @@ export class ShallowWrapper
{
*/
filter ;
/**
* Finds every node in the render tree that returns true for the provided predicate function.
@@ -496,8 +495,7 @@ export class ReactWrapper {
*/
filter ;
/**
* Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector