From 99b38a3f453b1020ac55b67dca4193ba0f9c0966 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 18 Feb 2022 16:39:10 -0800 Subject: [PATCH] [Tests] `prop-types`: add passing test Closes #2477 --- tests/lib/rules/prop-types.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index 7c1778ac2c..25fd8c571f 100644 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -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 ( +
{found.id}
+ ); + } + + return renderFound(); + } + + interface Props { + array: MyType[]; + } + + export default Component; + `, + features: ['types'], } )),