Skip to content

Commit

Permalink
manual type
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte committed Dec 20, 2024
1 parent 050c41b commit ea837b5
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,21 @@ type UseGeolocationPosition = WritableProperties<Omit<GeolocationPosition, "toJS
coords: WritableProperties<Omit<GeolocationPosition["coords"], "toJSON">>;
};

export type UseGeolocationReturn = {
readonly isSupported: boolean;
readonly position: UseGeolocationPosition;
readonly error: GeolocationPositionError | null;
readonly isPaused: boolean;
resume: () => void;
pause: () => void;
};

/**
* Reactive access to the browser's [Geolocation API](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API).
*
* @see https://runed.dev/docs/utilities/use-geolocation
*/
export function useGeolocation(options: UseGeolocationOptions = {}) {
export function useGeolocation(options: UseGeolocationOptions = {}): UseGeolocationReturn {
const {
enableHighAccuracy = true,
maximumAge = 30000,
Expand Down Expand Up @@ -89,9 +98,7 @@ export function useGeolocation(options: UseGeolocationOptions = {}) {
get isSupported() {
return isSupported;
},
get position() {
return position;
},
position,
get error() {
return error;
},
Expand All @@ -102,5 +109,3 @@ export function useGeolocation(options: UseGeolocationOptions = {}) {
pause,
};
}

export type useGeolocationReturn = ReturnType<typeof useGeolocation>;

0 comments on commit ea837b5

Please sign in to comment.