From dbc0959946335de66fae37c43c276636db407ec0 Mon Sep 17 00:00:00 2001 From: Alexey Iskhakov Date: Sat, 30 Jan 2021 09:38:54 +0300 Subject: [PATCH] fix(shared): useToggle type mismatch, close #313 (#314) --- packages/shared/useToggle/index.md | 4 ++-- packages/shared/useToggle/index.ts | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/shared/useToggle/index.md b/packages/shared/useToggle/index.md index fd90ac9e9145..dae4f417d5d8 100644 --- a/packages/shared/useToggle/index.md +++ b/packages/shared/useToggle/index.md @@ -33,8 +33,8 @@ const toggleDark = useToggle(isDark) * @see {@link https://vueuse.js.org/useToggle} * @param [initialValue=false] */ -export declare function useToggle(value: Ref): Fn -export declare function useToggle(initialValue?: boolean): [Ref, Fn] +export declare function useToggle(value: Ref): () => boolean +export declare function useToggle(initialValue?: boolean): [Ref, () => boolean] ``` ## Source diff --git a/packages/shared/useToggle/index.ts b/packages/shared/useToggle/index.ts index fb06c4c62b1c..cea4f9e49e04 100644 --- a/packages/shared/useToggle/index.ts +++ b/packages/shared/useToggle/index.ts @@ -1,5 +1,4 @@ import { isRef, Ref, ref } from 'vue-demi' -import { Fn } from '../utils' /** * A boolean ref with a toggler @@ -7,10 +6,10 @@ import { Fn } from '../utils' * @see {@link https://vueuse.js.org/useToggle} * @param [initialValue=false] */ -export function useToggle(value: Ref): Fn -export function useToggle(initialValue?: boolean): [Ref, Fn] +export function useToggle(value: Ref): () => boolean +export function useToggle(initialValue?: boolean): [Ref, () => boolean] -export function useToggle(initialValue: boolean | Ref = false): any { +export function useToggle(initialValue: boolean | Ref = false) { if (isRef(initialValue)) { return () => (initialValue.value = !initialValue.value) }