Skip to content

Commit

Permalink
[Tests] prop-types: add passing test
Browse files Browse the repository at this point in the history
Closes #2477
  • Loading branch information
ljharb committed Feb 19, 2022
1 parent 3527fa3 commit 99b38a3
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/lib/rules/prop-types.js
Expand Up @@ -3840,6 +3840,37 @@ ruleTester.run('prop-types', rule, {
name: PropTypes.string
}
`,
},
{
code: `
import React from 'react';
import { MyType } from './types';
function Component(props: Props): JSX.Element | null {
const { array } = props;
function renderFound(): JSX.Element | null {
const found = array.find(x => x.id === id); // issue here
if (!found) {
return null;
}
return (
<div>{found.id}</div>
);
}
return renderFound();
}
interface Props {
array: MyType[];
}
export default Component;
`,
features: ['types'],
}
)),

Expand Down

0 comments on commit 99b38a3

Please sign in to comment.