diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index b4cd3473b6..bef989d8f6 100644 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -3435,6 +3435,18 @@ ruleTester.run('prop-types', rule, { `, features: ['ts', 'no-babel'], }, + { + code: ` + import React, { ForwardRefRenderFunction } from 'react' + + type IfooProps = { e: string }; + const Foo: ForwardRefRenderFunction = (props, ref) => { + const { e } = props; + return
hello
; + }; + `, + features: ['ts', 'no-babel'], + }, { code: ` import React from 'react' @@ -3459,6 +3471,39 @@ ruleTester.run('prop-types', rule, { `, features: ['ts', 'no-babel'], }, + { + code: ` + import React from 'react' + type IfooProps = { e: string }; + const Foo= React.forwardRef(function Foo(props, ref) { + const { e } = props; + return
hello
; + }); + `, + features: ['ts', 'no-babel'], + }, + { + code: ` + import React from 'react' + interface IfooProps { e: string } + const Foo= React.forwardRef(function Foo(props, ref) { + const { e } = props; + return
hello
; + }); + `, + features: ['ts', 'no-babel'], + }, + { + code: ` + import React, { forwardRef } from 'react' + interface IfooProps { e: string } + const Foo= forwardRef(function Foo(props, ref) { + const { e } = props; + return
hello
; + }); + `, + features: ['ts', 'no-babel'], + }, { code: ` import React, { forwardRef as X } from 'react' @@ -7235,6 +7280,42 @@ ruleTester.run('prop-types', rule, { }, ], features: ['ts', 'no-babel'], + }, + { + code: ` + import React from 'react' + + type IfooProps = { e: string }; + const Foo= React.forwardRef(function Foo(props, ref) { + const { l } = props; + return
hello
; + }); + `, + errors: [ + { + messageId: 'missingPropType', + data: { name: 'l' }, + }, + ], + features: ['ts', 'no-babel'], + }, + { + code: ` + import React, { forwardRef } from 'react' + + type IfooProps = { e: string }; + const Foo= forwardRef(function Foo(props, ref) { + const { l } = props; + return
hello
; + }); + `, + errors: [ + { + messageId: 'missingPropType', + data: { name: 'l' }, + }, + ], + features: ['ts', 'no-babel'], } )), });