@@ -268,7 +268,7 @@ let hookTypesUpdateIndexDev: number = -1;
268
268
// When true, such Hooks will always be "remounted". Only used during hot reload.
269
269
let ignorePreviousDependencies : boolean = false ;
270
270
271
- function mountHookTypesDev ( ) {
271
+ function mountHookTypesDev ( ) : void {
272
272
if ( __DEV__ ) {
273
273
const hookName = ( ( currentHookNameInDev : any ) : HookType ) ;
274
274
@@ -280,7 +280,7 @@ function mountHookTypesDev() {
280
280
}
281
281
}
282
282
283
- function updateHookTypesDev ( ) {
283
+ function updateHookTypesDev ( ) : void {
284
284
if ( __DEV__ ) {
285
285
const hookName = ( ( currentHookNameInDev : any ) : HookType ) ;
286
286
@@ -293,7 +293,7 @@ function updateHookTypesDev() {
293
293
}
294
294
}
295
295
296
- function checkDepsAreArrayDev ( deps : mixed ) {
296
+ function checkDepsAreArrayDev ( deps : mixed ) : void {
297
297
if ( __DEV__ ) {
298
298
if ( deps !== undefined && deps !== null && ! isArray ( deps ) ) {
299
299
// Verify deps, but only on mount to avoid extra checks.
@@ -308,7 +308,7 @@ function checkDepsAreArrayDev(deps: mixed) {
308
308
}
309
309
}
310
310
311
- function warnOnHookMismatchInDev ( currentHookName : HookType ) {
311
+ function warnOnHookMismatchInDev ( currentHookName : HookType ) : void {
312
312
if ( __DEV__ ) {
313
313
const componentName = getComponentNameFromFiber ( currentlyRenderingFiber ) ;
314
314
if ( ! didWarnAboutMismatchedHooksForComponent . has ( componentName ) ) {
@@ -369,7 +369,7 @@ function throwInvalidHookError() {
369
369
function areHookInputsEqual (
370
370
nextDeps : Array < mixed > ,
371
371
prevDeps : Array < mixed > | null ,
372
- ) {
372
+ ) : boolean {
373
373
if ( __DEV__ ) {
374
374
if ( ignorePreviousDependencies ) {
375
375
// Only true when this component is being hot reloaded.
@@ -681,7 +681,7 @@ function renderWithHooksAgain<Props, SecondArg>(
681
681
Component : ( p : Props , arg : SecondArg ) => any ,
682
682
props : Props ,
683
683
secondArg : SecondArg ,
684
- ) {
684
+ ) : any {
685
685
// This is used to perform another render pass. It's used when setState is
686
686
// called during render, and for double invoking components in Strict Mode
687
687
// during development.
@@ -745,7 +745,7 @@ export function bailoutHooks(
745
745
current : Fiber ,
746
746
workInProgress : Fiber ,
747
747
lanes : Lanes ,
748
- ) {
748
+ ) : void {
749
749
workInProgress. updateQueue = current . updateQueue ;
750
750
// TODO: Don't need to reset the flags here, because they're reset in the
751
751
// complete phase (bubbleProperties).
@@ -1732,7 +1732,7 @@ function pushStoreConsistencyCheck<T>(
1732
1732
fiber: Fiber,
1733
1733
getSnapshot: () => T ,
1734
1734
renderedSnapshot : T ,
1735
- ) {
1735
+ ) : void {
1736
1736
fiber . flags |= StoreConsistency ;
1737
1737
const check : StoreConsistencyCheck < T > = {
1738
1738
getSnapshot,
@@ -1758,7 +1758,7 @@ function updateStoreInstance<T>(
1758
1758
inst: StoreInstance< T > ,
1759
1759
nextSnapshot: T,
1760
1760
getSnapshot: () => T ,
1761
- ) {
1761
+ ) : void {
1762
1762
// These are updated in the passive phase
1763
1763
inst . value = nextSnapshot ;
1764
1764
inst . getSnapshot = getSnapshot ;
@@ -1773,7 +1773,11 @@ function updateStoreInstance<T>(
1773
1773
}
1774
1774
}
1775
1775
1776
- function subscribeToStore < T > (fiber, inst: StoreInstance< T > , subscribe) {
1776
+ function subscribeToStore < T > (
1777
+ fiber: Fiber,
1778
+ inst: StoreInstance< T > ,
1779
+ subscribe: (() => void ) => ( ) => void ,
1780
+ ) : any {
1777
1781
const handleStoreChange = ( ) => {
1778
1782
// The store changed. Check if the snapshot changed since the last time we
1779
1783
// read from the store.
@@ -1843,7 +1847,12 @@ function rerenderState<S>(
1843
1847
return rerenderReducer ( basicStateReducer , ( initialState : any ) ) ;
1844
1848
}
1845
1849
1846
- function pushEffect(tag, create, destroy, deps: Array< mixed > | void | null) {
1850
+ function pushEffect(
1851
+ tag: HookFlags,
1852
+ create: () => ( ( ) => void ) | void ,
1853
+ destroy : ( ( ) => void ) | void ,
1854
+ deps : Array < mixed > | void | null,
1855
+ ): Effect {
1847
1856
const effect : Effect = {
1848
1857
tag,
1849
1858
create,
@@ -1963,9 +1972,9 @@ function updateRef<T>(initialValue: T): {current: T} {
1963
1972
}
1964
1973
1965
1974
function mountEffectImpl(
1966
- fiberFlags,
1967
- hookFlags,
1968
- create,
1975
+ fiberFlags: Flags ,
1976
+ hookFlags: HookFlags ,
1977
+ create: () = > ( ( ) => void ) | void ,
1969
1978
deps : Array < mixed > | void | null,
1970
1979
): void {
1971
1980
const hook = mountWorkInProgressHook ( ) ;
@@ -1980,9 +1989,9 @@ function mountEffectImpl(
1980
1989
}
1981
1990
1982
1991
function updateEffectImpl(
1983
- fiberFlags,
1984
- hookFlags,
1985
- create,
1992
+ fiberFlags: Flags ,
1993
+ hookFlags: HookFlags ,
1994
+ create: () = > ( ( ) => void ) | void ,
1986
1995
deps : Array < mixed > | void | null,
1987
1996
): void {
1988
1997
const hook = updateWorkInProgressHook ( ) ;
@@ -2019,14 +2028,14 @@ function mountEffect(
2019
2028
__DEV__ &&
2020
2029
( currentlyRenderingFiber . mode & StrictEffectsMode ) !== NoMode
2021
2030
) {
2022
- return mountEffectImpl (
2031
+ mountEffectImpl (
2023
2032
MountPassiveDevEffect | PassiveEffect | PassiveStaticEffect ,
2024
2033
HookPassive ,
2025
2034
create ,
2026
2035
deps ,
2027
2036
) ;
2028
2037
} else {
2029
- return mountEffectImpl (
2038
+ mountEffectImpl (
2030
2039
PassiveEffect | PassiveStaticEffect ,
2031
2040
HookPassive ,
2032
2041
create ,
@@ -2039,7 +2048,7 @@ function updateEffect(
2039
2048
create : ( ) => ( ( ) => void ) | void ,
2040
2049
deps : Array < mixed > | void | null,
2041
2050
): void {
2042
- return updateEffectImpl ( PassiveEffect , HookPassive , create , deps ) ;
2051
+ updateEffectImpl ( PassiveEffect , HookPassive , create , deps ) ;
2043
2052
}
2044
2053
2045
2054
function useEventImpl< Args , Return , F : ( ...Array < Args > ) => Return > (
@@ -2099,7 +2108,7 @@ function mountInsertionEffect(
2099
2108
create: () => ( ( ) => void ) | void ,
2100
2109
deps : Array < mixed > | void | null,
2101
2110
): void {
2102
- return mountEffectImpl ( UpdateEffect , HookInsertion , create , deps ) ;
2111
+ mountEffectImpl ( UpdateEffect , HookInsertion , create , deps ) ;
2103
2112
}
2104
2113
2105
2114
function updateInsertionEffect(
@@ -2133,7 +2142,7 @@ function updateLayoutEffect(
2133
2142
function imperativeHandleEffect< T > (
2134
2143
create: () => T ,
2135
2144
ref : { current : T | null } | ((inst: T | null) => mixed ) | null | void ,
2136
- ) {
2145
+ ) : void | ( ( ) => void ) {
2137
2146
if ( typeof ref === 'function' ) {
2138
2147
const refCallback = ref ;
2139
2148
const inst = create ( ) ;
@@ -2186,7 +2195,7 @@ function mountImperativeHandle<T>(
2186
2195
) {
2187
2196
fiberFlags |= MountLayoutDevEffect ;
2188
2197
}
2189
- return mountEffectImpl (
2198
+ mountEffectImpl (
2190
2199
fiberFlags ,
2191
2200
HookLayout ,
2192
2201
imperativeHandleEffect . bind ( null , create , ref ) ,
@@ -2213,7 +2222,7 @@ function updateImperativeHandle<T>(
2213
2222
const effectDeps =
2214
2223
deps !== null && deps !== undefined ? deps . concat ( [ ref ] ) : null ;
2215
2224
2216
- return updateEffectImpl (
2225
+ updateEffectImpl (
2217
2226
UpdateEffect ,
2218
2227
HookLayout ,
2219
2228
imperativeHandleEffect . bind ( null , create , ref ) ,
@@ -2361,7 +2370,11 @@ function updateDeferredValueImpl<T>(hook: Hook, prevValue: T, value: T): T {
2361
2370
}
2362
2371
}
2363
2372
2364
- function startTransition ( setPending , callback , options ) {
2373
+ function startTransition (
2374
+ setPending : boolean => void ,
2375
+ callback : ( ) = > void ,
2376
+ options ? : StartTransitionOptions ,
2377
+ ) : void {
2365
2378
const previousPriority = getCurrentUpdatePriority ( ) ;
2366
2379
setCurrentUpdatePriority (
2367
2380
higherEventPriority ( previousPriority , ContinuousEventPriority ) ,
@@ -2483,7 +2496,7 @@ function updateId(): string {
2483
2496
return id ;
2484
2497
}
2485
2498
2486
- function mountRefresh ( ) {
2499
+ function mountRefresh(): any {
2487
2500
const hook = mountWorkInProgressHook ( ) ;
2488
2501
const refresh = ( hook . memoizedState = refreshCache . bind (
2489
2502
null ,
@@ -2492,12 +2505,12 @@ function mountRefresh() {
2492
2505
return refresh ;
2493
2506
}
2494
2507
2495
- function updateRefresh ( ) {
2508
+ function updateRefresh(): any {
2496
2509
const hook = updateWorkInProgressHook ( ) ;
2497
2510
return hook . memoizedState ;
2498
2511
}
2499
2512
2500
- function refreshCache < T > ( fiber : Fiber , seedKey : ?( ) => T , seedValue : T ) {
2513
+ function refreshCache< T > (fiber: Fiber, seedKey: ?() => T , seedValue : T ) : void {
2501
2514
if ( ! enableCache) {
2502
2515
return ;
2503
2516
}
@@ -2553,7 +2566,7 @@ function dispatchReducerAction<S, A>(
2553
2566
fiber: Fiber,
2554
2567
queue: UpdateQueue< S , A > ,
2555
2568
action: A,
2556
- ) {
2569
+ ): void {
2557
2570
if ( __DEV__ ) {
2558
2571
if ( typeof arguments [ 3 ] === 'function' ) {
2559
2572
console . error (
@@ -2592,7 +2605,7 @@ function dispatchSetState<S, A>(
2592
2605
fiber: Fiber,
2593
2606
queue: UpdateQueue< S , A > ,
2594
2607
action: A,
2595
- ) {
2608
+ ): void {
2596
2609
if ( __DEV__ ) {
2597
2610
if ( typeof arguments [ 3 ] === 'function' ) {
2598
2611
console . error (
@@ -2670,7 +2683,7 @@ function dispatchSetState<S, A>(
2670
2683
markUpdateInDevTools ( fiber , lane , action ) ;
2671
2684
}
2672
2685
2673
- function isRenderPhaseUpdate ( fiber : Fiber ) {
2686
+ function isRenderPhaseUpdate ( fiber : Fiber ) : boolean {
2674
2687
const alternate = fiber . alternate ;
2675
2688
return (
2676
2689
fiber === currentlyRenderingFiber ||
@@ -2681,7 +2694,7 @@ function isRenderPhaseUpdate(fiber: Fiber) {
2681
2694
function enqueueRenderPhaseUpdate< S , A > (
2682
2695
queue: UpdateQueue< S , A > ,
2683
2696
update: Update< S , A > ,
2684
- ) {
2697
+ ): void {
2685
2698
// This is a render phase update. Stash it in a lazily-created map of
2686
2699
// queue -> linked list of updates. After this render pass, we'll restart
2687
2700
// and apply the stashed updates on top of the work-in-progress hook.
@@ -2702,7 +2715,7 @@ function entangleTransitionUpdate<S, A>(
2702
2715
root: FiberRoot,
2703
2716
queue: UpdateQueue< S , A > ,
2704
2717
lane: Lane,
2705
- ) {
2718
+ ): void {
2706
2719
if ( isTransitionLane ( lane ) ) {
2707
2720
let queueLanes = queue . lanes ;
2708
2721
@@ -2723,7 +2736,7 @@ function entangleTransitionUpdate<S, A>(
2723
2736
}
2724
2737
}
2725
2738
2726
- function markUpdateInDevTools < A > (fiber, lane, action: A) {
2739
+ function markUpdateInDevTools < A > (fiber, lane, action: A): void {
2727
2740
if ( __DEV__ ) {
2728
2741
if ( enableDebugTracing ) {
2729
2742
if ( fiber . mode & DebugTracingMode ) {
0 commit comments