Subscribe on changes!

How to add type definition for function `ref` params

avatar
Sep 17th 2021

Version

3.2.6

Reproduction link

sfc.vuejs.org/

Steps to reproduce

vscode will show type incompatible

What is expected?

No error message

What is actually happening?

image

avatar
Sep 17th 2021
function setItemRef(ref: Element | null) {
  if(ref) {
    liRefs.push(ref)
  } 
}
avatar
Sep 22nd 2021

image Still have the same problem

avatar
Sep 22nd 2021
import type { ComponentPublicInstance } from 'vue'
function setItemRef(ref: Element | ComponentPublicInstance ) {
  if(ref) {
    liRefs.push(ref)
  } 
}
avatar
Sep 22nd 2021
import type { ComponentPublicInstance } from 'vue'
function setItemRef(ref: Element | ComponentPublicInstance ) {
  if(ref) {
    liRefs.push(ref)
  } 
}

Yes, i know that ,just i think it's too verbose.

avatar
Sep 23rd 2021
import type { ComponentPublicInstance } from 'vue'
function setItemRef(ref: Element | ComponentPublicInstance ) {
  if(ref) {
    liRefs.push(ref)
  } 
}

Yes, i know that ,just i think it's too verbose.

setItemRef ( ref : Element | {} ) {

}