Skip to content

Commit 992be42

Browse files
author
duqingyu
committed
fix(type): Aminadav#10 fix Type checking error
1 parent c9eeda4 commit 992be42

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ type ReadOnlyRefObject<T> = {
77
readonly current: T;
88
};
99

10+
type UseStateRefValue<T> = [T, Dispatch<SetStateAction<T>>, ReadOnlyRefObject<T>];
1011
type UseStateRef = {
11-
<S>(initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>, ReadOnlyRefObject<S>];
12-
<S = undefined>(): [S | undefined, Dispatch<SetStateAction<S | undefined>>, ReadOnlyRefObject<S | undefined>];
12+
<S>(initialState: S | (() => S)): UseStateRefValue<S>;
13+
<S = undefined>(): UseStateRefValue<S>;
1314
};
1415

15-
const useStateRef: UseStateRef = <S>(initialState?: S | (() => S)) => {
16+
const useStateRef: UseStateRef = <S>(initialState?: S | (() => S)): UseStateRefValue<S> => {
1617
const [state, setState] = useState(initialState);
1718
const ref = useRef(state);
1819

0 commit comments

Comments
 (0)