Skip to content

Fixed typescript types #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
declare module 'react-native-geocoding' {
export default class Geocoder {
init(apiKey: string, options: Object): void;
isInit(): boolean;
setApiKey(API_KEY: string): void;
from(...params: any[]): Promise<void>;
Copy link

@iamjon iamjon Aug 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from doesn't return void, it returns a google geocoding response like so
https://developers.google.com/maps/documentation/geocoding/overview#GeocodingResponses or it throws an error.

What I did locally was create an interface that contains the geocoding response like so
interface geocodingResponse { plus_code: {compound_code: string, global_code: string} results: Array; status: string; }

and changed the declartion to:
static from(...params: any[]): Promise<geocodingResponse>;

getFromLocation(address: string): Promise<any>;
getFromLatLng(lat: number, lng: number): Promise<any>;
static init(apiKey: string, options: Object): void;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@snaquaye shouldn't options be optional ? like in the docs
static init(apiKey: string, options?: Object): void;

static isInit(): boolean;
static setApiKey(API_KEY: string): void;
static from(...params: any[]): Promise<void>;
static getFromLocation(address: string): Promise<any>;
static getFromLatLng(lat: number, lng: number): Promise<any>;
}
}