Navigation Menu

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(useScroll): types for ref include null and undefined #828

Merged
merged 1 commit into from Oct 16, 2021
Merged

fix(useScroll): types for ref include null and undefined #828

merged 1 commit into from Oct 16, 2021

Conversation

josephfh
Copy link
Contributor

@josephfh josephfh commented Oct 7, 2021

The problem:

With Vue composition API the ref is null or undefined intially. There is a type error as these are not accepted

Example

const someEl = ref<HTMLElement | null>(null)
const { y } = useScroll(someEl)

Error:
Argument of type 'Ref<HTMLElement | null>' is not assignable to parameter of type 'MaybeRef<Window | HTMLElement | Document | SVGElement>'.

Fix:

Add null and undefined as accepted types, just like with useScroll() and other vueuse functions

@antfu antfu merged commit 091f7d0 into vueuse:main Oct 16, 2021
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.

None yet

2 participants