Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

242
Vistas
How to more explicitly declare a variable than via const?

I have a component (NoteComponent) that emits note-not-saved. This message is handled via

<template>
(...)
    <NoteComponent @note-not-saved='() => noteNotSaved=true' />
(...)
</template>

noteNotSaved itself is defined in my <script> section:

<script setup lang='ts'>
(...)
  const noteNotSaved = ref(false)
(...)
</script>

The application works fine, I have however a weak warning from my IDE (JetBrains GoLand or WebStorm)

Variable noteNotSaved implicitly declared

What does that exactly mean? How can noteNotSaved be more explicitly declared than that?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The IDE may consider noteNotSaved=true as an implicit declaration of a global variable.

Try changing its value as follows:

const { createApp, ref } = Vue;

const NoteComponent = {
  template: `<button @click="$emit('note-not-saved')">Click</button>`
};

const App = {
  components: { NoteComponent },
  setup() {
    const noteNotSaved = ref(false);
    const setNoteAsNotSaved = () => {
      noteNotSaved.value = true;
    }
    return { noteNotSaved, setNoteAsNotSaved };
  }
};

createApp(App).mount("#myApp");
<script src="//unpkg.com/vue@next"></script>

<div id="myApp">
  <div><note-component @note-not-saved="setNoteAsNotSaved" /></div>
  <div><p>Note Not Saved: {{noteNotSaved}}</p></div>
</div>

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda