brh55 / react-native-open-maps

🗺 A simple react-native library to perform cross-platform map actions (Google, Apple, or Yandex Maps)
MIT License
359 stars 47 forks source link

openMaps() ShowOptions type requires waypoints #78

Closed the-habu closed 1 year ago

the-habu commented 1 year ago

The example openMap({ latitude: 37.865101, longitude: -119.538330 }) (using my own type Coordinates) now gives the following error.

TS2345: Argument of type 'Coordinates' is not assignable to parameter of type 'ShowOptions'.
  Property 'waypoints' is missing in type 'Coordinates' but required in type 'ShowOptions'.

Seems like a mistake that waypoints is mandatory, as it has been added lately. Here is the diff created with patch-package that will make it work for me with typescript.

Want me to add a PR, or any comments by maintainers? Thank you!

diff --git a/node_modules/react-native-open-maps/index.d.ts b/node_modules/react-native-open-maps/index.d.ts
index 2cd862d..c0a8691 100644
--- a/node_modules/react-native-open-maps/index.d.ts
+++ b/node_modules/react-native-open-maps/index.d.ts
@@ -24,7 +24,7 @@ declare module 'react-native-open-maps' {
     navigate?: boolean
     /** Specifies base map type **/
     mapType?: 'standard' | 'satellite' | 'hybrid' | 'transit',
-    waypoints: Array<string>
+    waypoints?: Array<string>
   }

   export function createOpenLink(options: ShowOptions): () => Promise<void>
brh55 commented 1 year ago

Oh that would be great, ty!

ml242 commented 1 year ago

Typescript was satisfied by adding waypoints as an empty array to openMaps, if it is worth merely updating the documentation. Or perhaps that prop could be optional?

the-habu commented 1 year ago

Sorry for the late reply!

@ml242 you're right, it works. But I still think making it optional leads to less confusion and a nicer API.

@brh55 I will submit a PR now.

brh55 commented 1 year ago

Ty! @the-habu