Skip to content

Commit

Permalink
fix(shared): useToggle type mismatch, close vitest-dev#313 (vitest-de…
Browse files Browse the repository at this point in the history
  • Loading branch information
Raiondesu authored Jan 30, 2021
1 parent dfd0dea commit dbc0959
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/shared/useToggle/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ const toggleDark = useToggle(isDark)
* @see {@link https://vueuse.js.org/useToggle}
* @param [initialValue=false]
*/
export declare function useToggle(value: Ref<boolean>): Fn
export declare function useToggle(initialValue?: boolean): [Ref<boolean>, Fn]
export declare function useToggle(value: Ref<boolean>): () => boolean
export declare function useToggle(initialValue?: boolean): [Ref<boolean>, () => boolean]
```

## Source
Expand Down
7 changes: 3 additions & 4 deletions packages/shared/useToggle/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { isRef, Ref, ref } from 'vue-demi'
import { Fn } from '../utils'

/**
* A boolean ref with a toggler
*
* @see {@link https://vueuse.js.org/useToggle}
* @param [initialValue=false]
*/
export function useToggle(value: Ref<boolean>): Fn
export function useToggle(initialValue?: boolean): [Ref<boolean>, Fn]
export function useToggle(value: Ref<boolean>): () => boolean
export function useToggle(initialValue?: boolean): [Ref<boolean>, () => boolean]

export function useToggle(initialValue: boolean | Ref<boolean> = false): any {
export function useToggle(initialValue: boolean | Ref<boolean> = false) {
if (isRef(initialValue)) {
return () => (initialValue.value = !initialValue.value)
}
Expand Down

0 comments on commit dbc0959

Please sign in to comment.