@@ -191,7 +191,7 @@ ruleTester.run(RULE_NAME, rule, {
191191 interface ComponentProps {
192192 foo: string;
193193 }
194- const Component = function Component({ ref, ...props }: ComponentProps & { ref: React.RefObject<HTMLElement> }) {
194+ const Component = function Component({ ref, ...props }: ComponentProps & { ref? : React.RefObject<HTMLElement | null > }) {
195195 return <div ref={ref} />;
196196 };
197197 ` ,
@@ -211,7 +211,7 @@ ruleTester.run(RULE_NAME, rule, {
211211 errors : [ { messageId : "noForwardRef" } ] ,
212212 output : /* tsx */ `
213213 import * as React from 'react'
214- const Component = function Component({ ref, ...props }: { foo: string } & { ref: React.RefObject<HTMLElement> }) {
214+ const Component = function Component({ ref, ...props }: { foo: string } & { ref? : React.RefObject<HTMLElement | null > }) {
215215 return <div ref={ref}>{props.foo}</div>;
216216 };
217217 ` ,
@@ -231,7 +231,7 @@ ruleTester.run(RULE_NAME, rule, {
231231 errors : [ { messageId : "noForwardRef" } ] ,
232232 output : /* tsx */ `
233233 import * as React from 'react'
234- const Component = function Component({ ref, foo }: { foo: string } & { ref: React.RefObject<HTMLElement> }) {
234+ const Component = function Component({ ref, foo }: { foo: string } & { ref? : React.RefObject<HTMLElement | null > }) {
235235 return <div ref={ref}>{foo}</div>;
236236 };
237237 ` ,
@@ -251,7 +251,7 @@ ruleTester.run(RULE_NAME, rule, {
251251 errors : [ { messageId : "noForwardRef" } ] ,
252252 output : /* tsx */ `
253253 import * as React from 'react'
254- const Component = function Component({ ref: r, foo }: { foo: string } & { ref: React.RefObject<HTMLElement> }) {
254+ const Component = function Component({ ref: r, foo }: { foo: string } & { ref? : React.RefObject<HTMLElement | null > }) {
255255 return <div ref={r}>{foo}</div>;
256256 };
257257 ` ,
@@ -271,7 +271,7 @@ ruleTester.run(RULE_NAME, rule, {
271271 errors : [ { messageId : "noForwardRef" } ] ,
272272 output : /* tsx */ `
273273 import * as React from 'react'
274- const Component = function Component({ ref: r, foo, ...rest }: { foo: string, bar: number } & { ref: React.RefObject<HTMLElement> }) {
274+ const Component = function Component({ ref: r, foo, ...rest }: { foo: string, bar: number } & { ref? : React.RefObject<HTMLElement | null > }) {
275275 return <div ref={r}>{foo}</div>;
276276 };
277277 ` ,
0 commit comments