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

182
Vistas
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 Respuestas
Responde la pregunta

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 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