@@ -1093,10 +1093,13 @@ export function discreteUpdates<A, B, C, D, R>(
1093
1093
}
1094
1094
}
1095
1095
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 ) {
1100
1103
// In legacy mode, we flush pending passive effects at the beginning of the
1101
1104
// next event, not at the end of the previous one.
1102
1105
if (
@@ -1116,9 +1119,9 @@ export function flushSyncWithoutWarningIfAlreadyRendering<A, R>(
1116
1119
ReactCurrentBatchConfig . transition = 0 ;
1117
1120
setCurrentUpdatePriority ( DiscreteEventPriority ) ;
1118
1121
if ( fn ) {
1119
- return fn ( a ) ;
1122
+ return fn ( ) ;
1120
1123
} else {
1121
- return ( undefined : $FlowFixMe ) ;
1124
+ return undefined ;
1122
1125
}
1123
1126
} finally {
1124
1127
setCurrentUpdatePriority ( previousPriority ) ;
@@ -1133,7 +1136,13 @@ export function flushSyncWithoutWarningIfAlreadyRendering<A, R>(
1133
1136
}
1134
1137
}
1135
1138
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 ) {
1137
1146
if ( __DEV__ ) {
1138
1147
if ( ( executionContext & ( RenderContext | CommitContext ) ) !== NoContext ) {
1139
1148
console . error (
@@ -1143,7 +1152,7 @@ export function flushSync<A, R>(fn: A => R, a: A): R {
1143
1152
) ;
1144
1153
}
1145
1154
}
1146
- return flushSyncWithoutWarningIfAlreadyRendering ( fn , a ) ;
1155
+ return flushSyncWithoutWarningIfAlreadyRendering ( fn ) ;
1147
1156
}
1148
1157
1149
1158
export function flushControlled ( fn : ( ) = > mixed ) : void {
0 commit comments