Skip to content

HTMLElement type is automatically expanded #416

Closed
@ollieSk8

Description

@ollieSk8

1 . define a custom hook useClickOutside and recive a argument elementRef ,the elementRef type is Ref<null | HTMLElement>
2. define a dropdownRef type is null or HTMLElement
3. template has a div set ref attribute dropdownRef

Result :
Here I think there may be a problem with the implementation of volar. It will directly expand the HTMLElement type, causing a mismatch of types.

//template  <div class="dropdown" ref="dropdownRef">

// custom hook

const useClickOutside = (elementRef: Ref<null | HTMLElement>): Ref<boolean> => {
    //some other code
}
 const dropdownRef = ref<null | HTMLElement>(null)
 const isClickOutside = useClickOutside(dropdownRef) //  causing a mismatch of types.

截屏2021-08-25 下午2 23 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions