Skip to content

Commit 99b38a3

Browse files
committed
[Tests] prop-types: add passing test
Closes #2477
1 parent 3527fa3 commit 99b38a3

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/lib/rules/prop-types.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3840,6 +3840,37 @@ ruleTester.run('prop-types', rule, {
38403840
name: PropTypes.string
38413841
}
38423842
`,
3843+
},
3844+
{
3845+
code: `
3846+
import React from 'react';
3847+
import { MyType } from './types';
3848+
3849+
function Component(props: Props): JSX.Element | null {
3850+
const { array } = props;
3851+
3852+
function renderFound(): JSX.Element | null {
3853+
const found = array.find(x => x.id === id); // issue here
3854+
3855+
if (!found) {
3856+
return null;
3857+
}
3858+
3859+
return (
3860+
<div>{found.id}</div>
3861+
);
3862+
}
3863+
3864+
return renderFound();
3865+
}
3866+
3867+
interface Props {
3868+
array: MyType[];
3869+
}
3870+
3871+
export default Component;
3872+
`,
3873+
features: ['types'],
38433874
}
38443875
)),
38453876

0 commit comments

Comments
 (0)