Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(useFavicon): writable return type #2036

Merged
merged 3 commits into from Aug 4, 2022

Conversation

chaii3
Copy link
Contributor

@chaii3 chaii3 commented Aug 3, 2022

closes #2031

Description

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

Comment on lines 13 to 14
export type UseFaviconValue = string | null | undefined
export type UseFaviconGetter = () => UseFaviconValue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to use literals directly

/**
* Reactive favicon.
*
* @see https://vueuse.org/useFavicon
* @param newIcon
* @param options
*/
export function useFavicon(newIcon: MaybeRef<UseFaviconValue>, options?: UseFaviconOptions): Ref<UseFaviconValue>
export function useFavicon(newIcon: ComputedRef<UseFaviconValue> | UseFaviconGetter, options?: UseFaviconOptions): ComputedRef<UseFaviconValue>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export function useFavicon(newIcon: ComputedRef<UseFaviconValue> | UseFaviconGetter, options?: UseFaviconOptions): ComputedRef<UseFaviconValue>
export function useFavicon(newIcon: MaybeComputedRef<UseFaviconValue>, options?: UseFaviconOptions): ComputedRef<UseFaviconValue>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case the return type for Ref will be ComputedRef.
I mean for useFavicon(ref('str')): ComputedRef

@antfu antfu enabled auto-merge (squash) August 4, 2022 03:59
@antfu antfu merged commit 06e2639 into vueuse:main Aug 4, 2022
@stef-work
Copy link

@antfu Sorry to get back to this again, but the function without parameters still returns a ComputedRef. Therefore, it still does not match the documentation.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useFavicon().value is readonly (TypeScript)
3 participants