@@ -1093,10 +1093,13 @@ export function discreteUpdates<A, B, C, D, R>(
10931093 }
10941094}
10951095
1096- export function flushSyncWithoutWarningIfAlreadyRendering < A , R > (
1097- fn : A => R ,
1098- a : A ,
1099- ) : R {
1096+ // Overload the definition to the two valid signatures.
1097+ // Warning, this opts-out of checking the function body.
1098+ declare function flushSyncWithoutWarningIfAlreadyRendering < R > ( fn : ( ) = > R ) : R ;
1099+ // eslint-disable-next-line no-redeclare
1100+ declare function flushSyncWithoutWarningIfAlreadyRendering ( ) : void ;
1101+ // eslint-disable-next-line no-redeclare
1102+ export function flushSyncWithoutWarningIfAlreadyRendering ( fn ) {
11001103 // In legacy mode, we flush pending passive effects at the beginning of the
11011104 // next event, not at the end of the previous one.
11021105 if (
@@ -1116,9 +1119,9 @@ export function flushSyncWithoutWarningIfAlreadyRendering<A, R>(
11161119 ReactCurrentBatchConfig . transition = 0 ;
11171120 setCurrentUpdatePriority ( DiscreteEventPriority ) ;
11181121 if ( fn ) {
1119- return fn ( a ) ;
1122+ return fn ( ) ;
11201123 } else {
1121- return ( undefined : $FlowFixMe ) ;
1124+ return undefined ;
11221125 }
11231126 } finally {
11241127 setCurrentUpdatePriority ( previousPriority ) ;
@@ -1133,7 +1136,13 @@ export function flushSyncWithoutWarningIfAlreadyRendering<A, R>(
11331136 }
11341137}
11351138
1136- export function flushSync < A , R > ( fn : A => R , a : A ) : R {
1139+ // Overload the definition to the two valid signatures.
1140+ // Warning, this opts-out of checking the function body.
1141+ declare function flushSync < R > ( fn : ( ) = > R ) : R ;
1142+ // eslint-disable-next-line no-redeclare
1143+ declare function flushSync ( ) : void ;
1144+ // eslint-disable-next-line no-redeclare
1145+ export function flushSync ( fn ) {
11371146 if ( __DEV__ ) {
11381147 if ( ( executionContext & ( RenderContext | CommitContext ) ) !== NoContext ) {
11391148 console . error (
@@ -1143,7 +1152,7 @@ export function flushSync<A, R>(fn: A => R, a: A): R {
11431152 ) ;
11441153 }
11451154 }
1146- return flushSyncWithoutWarningIfAlreadyRendering ( fn , a ) ;
1155+ return flushSyncWithoutWarningIfAlreadyRendering ( fn ) ;
11471156}
11481157
11491158export function flushControlled ( fn : ( ) = > mixed ) : void {
0 commit comments