I'm new to TS so the question might be trivial to some of You, however I'm kind of missing something,
I'm trying to create a function that will return an array containing the users geolocation data like lingitude, latitude. I want this to be correctly covered by the TS type checking magic.
export const getUsersGeolocationData = (): [number,number] => {
const navigatorResult: [number, number] = navigator.geolocation.getCurrentPosition(position =>{
return [position.coords.latitude, position.coords.longitude];
})
return navigatorResult
}
console.log(getUsersGeolocationData())
My understanding: I'm letting TS know that I expect the [number, number] array as the result of getUsersGeolocationData() but I keep receiving the Type 'void' is not assignable to type '[number, number]'
Can somebody help me with understanding and fixing the issue ? :) Best regards !
getCurrentPosition?