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

183
Visualizações
How can I bypass ESLint calling the Geolocation interface undefined in Typescript?

I am utilizing the Geolocation API to place a marker on a map, but ESLint is complaining that GeolocationPosition is undefined. Nevertheless, the code runs and gives me the expected result, but I want to clean my code for warnings. I am new to typescript and ESlint, so I am unsure where to go from here. Any suggestions? Code and image of warning follows.

enter image description here

import { Map } from 'leaflet';
import { iconLocation, setMarker } from './leafletMarker';

export function getUserPosition(callback : (position : GeolocationPosition) => void) {
    function success(position : GeolocationPosition) {
        callback(position);
    }
    function error() {
        console.log('Unable to retrieve your location'); // change to alerts when Alert component is ready
    }
    if (!navigator.geolocation) {
        console.log('Geolocation is not supported by your browser'); // change to alerts when Alert component is ready
    } else {
        navigator.geolocation.getCurrentPosition(success, error, { enableHighAccuracy: true });
    }
}

export function handleMyPosition(map: Map) {
    getUserPosition((userPosition: GeolocationPosition) => {
        if (map) {
            const { latitude, longitude } = userPosition.coords;
            setMarker(map, latitude, longitude, { icon: iconLocation });
            map?.setView([latitude, longitude], 9);
        }
    });
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Don't use no-undef in TypeScript projects. Just disable the rule in your config, TypeScript does the same but better.

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