Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

337
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!