Skip to content

Bug: ref typings should be inferred from element tag #342

@shigma

Description

@shigma
<template>
    <ul :ref="el => state.element = el"></ul>
</template>

<script lang="ts" setup>
    import { ref } from 'vue'
    const state = ref<{ element: Element }>({ element: null })
</script>

This will produce error because ComponentInternalInstance | Element cannot be assigned to Element.

However we can infer the real :ref is string | Ref<any> | ((ref: HTMLUListElement) => void) instead of string | Ref<any> | ((ref: ComponentInternalInstance | Element) => void) because ul is hard-coded.


Or, can we prevent the error message by <!-- @ts-ignore --> or something?

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