Skip to content

Commit

Permalink
fix(useFavicon): writable return type
Browse files Browse the repository at this point in the history
  • Loading branch information
chaii3 committed Aug 3, 2022
1 parent 8b21ca2 commit f5a825e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/core/useFavicon/index.ts
@@ -1,5 +1,6 @@
import type { MaybeComputedRef } from '@vueuse/shared'
import type { MaybeRef } from '@vueuse/shared'
import { isString, resolveRef } from '@vueuse/shared'
import type { ComputedRef, Ref, WritableComputedRef } from 'vue-demi'
import { watch } from 'vue-demi'
import type { ConfigurableDocument } from '../_configurable'
import { defaultDocument } from '../_configurable'
Expand All @@ -9,15 +10,21 @@ export interface UseFaviconOptions extends ConfigurableDocument {
rel?: string
}

export type UseFaviconValue = string | null | undefined
export type UseFaviconGetter = () => UseFaviconValue

/**
* Reactive favicon.
*
* @see https://vueuse.org/useFavicon
* @param newIcon
* @param options
*/
export function useFavicon(newIcon: ComputedRef<UseFaviconValue> | UseFaviconGetter, options?: UseFaviconOptions): ComputedRef<UseFaviconValue>
export function useFavicon(newIcon: MaybeRef<UseFaviconValue>, options?: UseFaviconOptions): Ref<UseFaviconValue>
export function useFavicon(newIcon?: ComputedRef<UseFaviconValue> | MaybeRef<UseFaviconValue> | UseFaviconGetter, options?: UseFaviconOptions): Ref<UseFaviconValue>
export function useFavicon(
newIcon: MaybeComputedRef<string | null | undefined> = null,
newIcon: ComputedRef<UseFaviconValue> | MaybeRef<UseFaviconValue> | UseFaviconGetter = null,
options: UseFaviconOptions = {},
) {
const {
Expand All @@ -43,7 +50,6 @@ export function useFavicon(
{ immediate: true },
)

return favicon
return favicon as WritableComputedRef<string | null | undefined>
}

export type UseFaviconReturn = ReturnType<typeof useFavicon>

0 comments on commit f5a825e

Please sign in to comment.