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 "." {
57
57
* @see {@link https://react.dev/reference/react/Activity `<Activity>` documentation }
58
58
*/
59
59
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 ;
60
66
}
Original file line number Diff line number Diff line change @@ -108,9 +108,6 @@ declare module "." {
108
108
*/
109
109
export const unstable_SuspenseList : ExoticComponent < SuspenseListProps > ;
110
110
111
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
112
- export function experimental_useEffectEvent < T extends Function > ( event : T ) : T ;
113
-
114
111
type Reference = object ;
115
112
type TaintableUniqueValue = string | bigint | ArrayBufferView ;
116
113
function experimental_taintUniqueValue (
Original file line number Diff line number Diff line change @@ -55,3 +55,32 @@ function activityTest() {
55
55
/> ;
56
56
< Activity children = "peekaboo" name = "/" /> ;
57
57
}
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> }) {
77
77
) ;
78
78
}
79
79
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
-
109
80
function elementTypeTests ( ) {
110
81
const ReturnPromise = ( ) => Promise . resolve ( "React" ) ;
111
82
const FCPromise : React . FC = ReturnPromise ;
Original file line number Diff line number Diff line change @@ -57,4 +57,10 @@ declare module "." {
57
57
* @see {@link https://react.dev/reference/react/Activity `<Activity>` documentation }
58
58
*/
59
59
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 ;
60
66
}
Original file line number Diff line number Diff line change @@ -108,9 +108,6 @@ declare module "." {
108
108
*/
109
109
export const unstable_SuspenseList : ExoticComponent < SuspenseListProps > ;
110
110
111
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
112
- export function experimental_useEffectEvent < T extends Function > ( event : T ) : T ;
113
-
114
111
type Reference = object ;
115
112
type TaintableUniqueValue = string | bigint | ArrayBufferView ;
116
113
function experimental_taintUniqueValue (
Original file line number Diff line number Diff line change @@ -55,3 +55,32 @@ function activityTest() {
55
55
/> ;
56
56
< Activity children = "peekaboo" name = "/" /> ;
57
57
}
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> }) {
77
77
) ;
78
78
}
79
79
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
-
109
80
function elementTypeTests ( ) {
110
81
const ReturnPromise = ( ) => Promise . resolve ( "React" ) ;
111
82
const FCPromise : React . FC = ReturnPromise ;
You can’t perform that action at this time.
0 commit comments