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

338
Vistas
I tried to style some element using js but getting Typescript Object is possibly 'null' error

I am learning TS and I am getting Object is possibly 'null' compailer error when I try to style some elemnt using js. I am confused how can I create interface for my below code. I am getting error here.

menuBar.style.marginLeft = '-300px',

settingDrop.style.display = "block"

What is the best way to solve this?

Code

    const subMenu = () => {
        const menuBar = document.querySelector('.menu-bar')
        const settingDrop = document.querySelector('.setting-drop')
        menuBar.style.marginLeft = '-300px'
        setTimeout(() => {
            settingDrop.style.display = "block"
        }, 100)

    }
about 4 years ago · Juan Pablo Isaza
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