File tree Expand file tree Collapse file tree 8 files changed +70
-64
lines changed Expand file tree Collapse file tree 8 files changed +70
-64
lines changed Original file line number Diff line number Diff line change @@ -57,4 +57,10 @@ declare module "." {
5757 * @see {@link https://react.dev/reference/react/Activity `<Activity>` documentation }
5858 */
5959 export const Activity : ExoticComponent < ActivityProps > ;
60+
61+ /**
62+ * @see {@link https://react.dev/reference/react/useEffectEvent `useEffectEvent()` documentation }
63+ */
64+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
65+ export function useEffectEvent < T extends Function > ( callback : T ) : T ;
6066}
Original file line number Diff line number Diff line change @@ -108,9 +108,6 @@ declare module "." {
108108 */
109109 export const unstable_SuspenseList : ExoticComponent < SuspenseListProps > ;
110110
111- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
112- export function experimental_useEffectEvent < T extends Function > ( event : T ) : T ;
113-
114111 type Reference = object ;
115112 type TaintableUniqueValue = string | bigint | ArrayBufferView ;
116113 function experimental_taintUniqueValue (
Original file line number Diff line number Diff line change @@ -55,3 +55,32 @@ function activityTest() {
5555 /> ;
5656 < Activity children = "peekaboo" name = "/" /> ;
5757}
58+
59+ function useEffectEventTest ( ) {
60+ // Implicit any
61+ // @ts -expect-error
62+ const anyEvent = React . useEffectEvent ( value => {
63+ // $ExpectType any
64+ return value ;
65+ } ) ;
66+ // $ExpectType any
67+ anyEvent ( { } ) ;
68+ // $ExpectType (value: string) => number
69+ const typedEvent = React . useEffectEvent ( ( value : string ) => {
70+ return Number ( value ) ;
71+ } ) ;
72+ // $ExpectType number
73+ typedEvent ( "1" ) ;
74+ // Argument of type '{}' is not assignable to parameter of type 'string'.
75+ // @ts -expect-error
76+ typedEvent ( { } ) ;
77+
78+ function useContextuallyTypedEvent ( fn : ( event : Event ) => string ) { }
79+ useContextuallyTypedEvent (
80+ React . useEffectEvent ( event => {
81+ // $ExpectType Event
82+ event ;
83+ return String ( event ) ;
84+ } ) ,
85+ ) ;
86+ }
Original file line number Diff line number Diff line change @@ -77,35 +77,6 @@ function Page({ children }: { children: NonNullable<React.ReactNode> }) {
7777 ) ;
7878}
7979
80- function useEvent ( ) {
81- // Implicit any
82- // @ts -expect-error
83- const anyEvent = React . experimental_useEffectEvent ( value => {
84- // $ExpectType any
85- return value ;
86- } ) ;
87- // $ExpectType any
88- anyEvent ( { } ) ;
89- // $ExpectType (value: string) => number
90- const typedEvent = React . experimental_useEffectEvent ( ( value : string ) => {
91- return Number ( value ) ;
92- } ) ;
93- // $ExpectType number
94- typedEvent ( "1" ) ;
95- // Argument of type '{}' is not assignable to parameter of type 'string'.
96- // @ts -expect-error
97- typedEvent ( { } ) ;
98-
99- function useContextuallyTypedEvent ( fn : ( event : Event ) => string ) { }
100- useContextuallyTypedEvent (
101- React . experimental_useEffectEvent ( event => {
102- // $ExpectType Event
103- event ;
104- return String ( event ) ;
105- } ) ,
106- ) ;
107- }
108-
10980function elementTypeTests ( ) {
11081 const ReturnPromise = ( ) => Promise . resolve ( "React" ) ;
11182 const FCPromise : React . FC = ReturnPromise ;
Original file line number Diff line number Diff line change @@ -57,4 +57,10 @@ declare module "." {
5757 * @see {@link https://react.dev/reference/react/Activity `<Activity>` documentation }
5858 */
5959 export const Activity : ExoticComponent < ActivityProps > ;
60+
61+ /**
62+ * @see {@link https://react.dev/reference/react/useEffectEvent `useEffectEvent()` documentation }
63+ */
64+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
65+ export function useEffectEvent < T extends Function > ( callback : T ) : T ;
6066}
Original file line number Diff line number Diff line change @@ -108,9 +108,6 @@ declare module "." {
108108 */
109109 export const unstable_SuspenseList : ExoticComponent < SuspenseListProps > ;
110110
111- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
112- export function experimental_useEffectEvent < T extends Function > ( event : T ) : T ;
113-
114111 type Reference = object ;
115112 type TaintableUniqueValue = string | bigint | ArrayBufferView ;
116113 function experimental_taintUniqueValue (
Original file line number Diff line number Diff line change @@ -55,3 +55,32 @@ function activityTest() {
5555 /> ;
5656 < Activity children = "peekaboo" name = "/" /> ;
5757}
58+
59+ function useEffectEventTest ( ) {
60+ // Implicit any
61+ // @ts -expect-error
62+ const anyEvent = React . useEffectEvent ( value => {
63+ // $ExpectType any
64+ return value ;
65+ } ) ;
66+ // $ExpectType any
67+ anyEvent ( { } ) ;
68+ // $ExpectType (value: string) => number
69+ const typedEvent = React . useEffectEvent ( ( value : string ) => {
70+ return Number ( value ) ;
71+ } ) ;
72+ // $ExpectType number
73+ typedEvent ( "1" ) ;
74+ // Argument of type '{}' is not assignable to parameter of type 'string'.
75+ // @ts -expect-error
76+ typedEvent ( { } ) ;
77+
78+ function useContextuallyTypedEvent ( fn : ( event : Event ) => string ) { }
79+ useContextuallyTypedEvent (
80+ React . useEffectEvent ( event => {
81+ // $ExpectType Event
82+ event ;
83+ return String ( event ) ;
84+ } ) ,
85+ ) ;
86+ }
Original file line number Diff line number Diff line change @@ -77,35 +77,6 @@ function Page({ children }: { children: NonNullable<React.ReactNode> }) {
7777 ) ;
7878}
7979
80- function useEvent ( ) {
81- // Implicit any
82- // @ts -expect-error
83- const anyEvent = React . experimental_useEffectEvent ( value => {
84- // $ExpectType any
85- return value ;
86- } ) ;
87- // $ExpectType any
88- anyEvent ( { } ) ;
89- // $ExpectType (value: string) => number
90- const typedEvent = React . experimental_useEffectEvent ( ( value : string ) => {
91- return Number ( value ) ;
92- } ) ;
93- // $ExpectType number
94- typedEvent ( "1" ) ;
95- // Argument of type '{}' is not assignable to parameter of type 'string'.
96- // @ts -expect-error
97- typedEvent ( { } ) ;
98-
99- function useContextuallyTypedEvent ( fn : ( event : Event ) => string ) { }
100- useContextuallyTypedEvent (
101- React . experimental_useEffectEvent ( event => {
102- // $ExpectType Event
103- event ;
104- return String ( event ) ;
105- } ) ,
106- ) ;
107- }
108-
10980function elementTypeTests ( ) {
11081 const ReturnPromise = ( ) => Promise . resolve ( "React" ) ;
11182 const FCPromise : React . FC = ReturnPromise ;
You can’t perform that action at this time.
0 commit comments