Skip to content

Commit a5d9d85

Browse files
committed
Restrict return type further
1 parent 2ae5546 commit a5d9d85

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

packages/react-debug-tools/src/ReactDebugHooks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function useRef<T>(initialValue: T): {current: T} {
142142
}
143143

144144
function useLayoutEffect(
145-
create: () => mixed,
145+
create: () => (() => void) | void,
146146
inputs: Array<mixed> | void | null,
147147
): void {
148148
nextHook();
@@ -154,7 +154,7 @@ function useLayoutEffect(
154154
}
155155

156156
function useEffect(
157-
create: () => mixed,
157+
create: () => (() => void) | void,
158158
inputs: Array<mixed> | void | null,
159159
): void {
160160
nextHook();

packages/react-dom/src/server/ReactPartialRendererHooks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ function useRef<T>(initialValue: T): {current: T} {
329329
}
330330

331331
export function useLayoutEffect(
332-
create: () => mixed,
332+
create: () => (() => void) | void,
333333
inputs: Array<mixed> | void | null,
334334
) {
335335
if (__DEV__) {

packages/react-reconciler/src/ReactFiberHooks.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ export type Hook = {
6666

6767
type Effect = {
6868
tag: HookEffectTag,
69-
create: () => mixed,
70-
destroy: (() => mixed) | null,
69+
create: () => (() => void) | void,
70+
destroy: (() => void) | null,
7171
deps: Array<mixed> | null,
7272
next: Effect,
7373
};
@@ -608,7 +608,7 @@ export function useRef<T>(initialValue: T): {current: T} {
608608
}
609609

610610
export function useLayoutEffect(
611-
create: () => mixed,
611+
create: () => (() => void) | void,
612612
deps: Array<mixed> | void | null,
613613
): void {
614614
if (__DEV__) {
@@ -618,7 +618,7 @@ export function useLayoutEffect(
618618
}
619619

620620
export function useEffect(
621-
create: () => mixed,
621+
create: () => (() => void) | void,
622622
deps: Array<mixed> | void | null,
623623
): void {
624624
if (__DEV__) {
@@ -679,7 +679,9 @@ export function useImperativeHandle<T>(
679679
const refCallback = ref;
680680
const inst = create();
681681
refCallback(inst);
682-
return () => refCallback(null);
682+
return () => {
683+
refCallback(null);
684+
};
683685
} else if (ref !== null && ref !== undefined) {
684686
const refObject = ref;
685687
const inst = create();

packages/react/src/ReactHooks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ export function useRef<T>(initialValue: T): {current: T} {
7171
}
7272

7373
export function useEffect(
74-
create: () => mixed,
74+
create: () => (() => void) | void,
7575
inputs: Array<mixed> | void | null,
7676
) {
7777
const dispatcher = resolveDispatcher();
7878
return dispatcher.useEffect(create, inputs);
7979
}
8080

8181
export function useLayoutEffect(
82-
create: () => mixed,
82+
create: () => (() => void) | void,
8383
inputs: Array<mixed> | void | null,
8484
) {
8585
const dispatcher = resolveDispatcher();

0 commit comments

Comments
 (0)