Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

331
Visualizações
Vuejs: Typing $refs values

I have a Vuejs (3) project using Typescript. I'm trying to avoid relying on the type any when using $refs:

const el = (this.$refs['target'] as any).$el

It triggers the following warning:

warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

Any idea what type I can use instead of any ?

EDIT: I don't want to disable my eslint rule :)

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

As the ref refers to a Vue component (since you're using $el), you can use the interfaces Vue or VueConstructor which ship with Vue instead of any. This will give you access to the basic Vue properties of the component like $el, $data etc., though not specific methods and properties you've added yourself to the component.

This will keep ESLint happy as it's using something more specific than any.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda