dpa99c / react-native-launch-navigator

A React Native module for launching today's most popular navigation/ride apps to navigate to a destination.
143 stars 34 forks source link

The types are not recognised #39

Open danieltanasec opened 2 years ago

danieltanasec commented 2 years ago

Bug report

Current behavior:

It seems the types are not recognised with this version.

Screenshot 2021-12-07 at 10 27 08

There also seems to be a typing error in index.d.ts

Screenshot 2021-12-07 at 10 27 49

Environment information React Native: "0.66.2", Typescript Version 4.2.4

liptonzuma commented 1 year ago

I'm noticing the same on my end.

sylvainp commented 1 year ago

I've got the same issue

pqkluan commented 1 year ago

It happen because the index.d.ts was typed incorrectly.

I fixed by create this patch react-native-launch-navigator+1.0.8.patch using patch-package

diff --git a/node_modules/react-native-launch-navigator/index.d.ts b/node_modules/react-native-launch-navigator/index.d.ts
index ae97e78..f6e67e8 100644
--- a/node_modules/react-native-launch-navigator/index.d.ts
+++ b/node_modules/react-native-launch-navigator/index.d.ts
@@ -3,7 +3,10 @@
 // Definitions by: Dave Alden <https://github.com/dpa99c>
 // Usage: import { LaunchNavigator, LaunchNavigatorOptions } from 'react-native-launch-navigator';

-export interface LaunchNavigatorOptions {
+declare module 'react-native-launch-navigator' {
+  type APP_KEYS = "APPLE_MAPS" | "GOOGLE_MAPS" | "WAZE" | "CITYMAPPER" | "NAVIGON" | "TRANSIT_APP" | "YANDEX" | "UBER" | "TOMTOM" | "BING_MAPS" | "SYGIC" | "HERE_MAPS" | "MOOVIT" | "LYFT" | "MAPS_ME" | "CABIFY" | "BAIDU" | "TAXIS_99" | "GAODE";
+  
+  export interface LaunchNavigatorOptions {

     /**
      * name of the navigation app to use for directions.
@@ -57,9 +60,9 @@ export interface LaunchNavigatorOptions {
      * If true, and input location type(s) doesn't match those required by the app, use geocoding to obtain the address/coords as required. Defaults to true.
      */
     enableGeocoding?: boolean;
-}
+  }

-export interface LaunchNavigator {
+  const LaunchNavigator: {

     /**
      * Supported platforms
@@ -69,7 +72,7 @@ export interface LaunchNavigator {
     /**
      * string constants, used to identify apps in native code
      */
-    APP: any;
+    APP: Record<APP_KEYS, string>;

     /**
      * All possible transport modes
@@ -97,7 +100,7 @@ export interface LaunchNavigator {
     navigate: (
         destination: string | number[], 
         options?: LaunchNavigatorOptions
-    ) => Promise;
+    ) => Promise<void>;

     logEvent: (name: string, params?: any, valueToSum?: number) => void;

@@ -114,7 +117,7 @@ export interface LaunchNavigator {
      * Returns a list indicating which apps are installed and available on the current device.
      * @return {object} - a key/value object where the key is the app name as a constant in `LaunchNavigator.APP` and the value is a boolean indicating whether the app is available.
      */
-    getAvailableApps: () => object;
+    getAvailableApps: () => Promise<Record<string, boolean>>;

     /**
      * Returns the display name of the specified app.
@@ -215,4 +218,7 @@ export interface LaunchNavigator {
     enableDebug: (
         enabled: boolean
     ) => void;
+  }
+
+  export default LaunchNavigator;
 }
\ No newline at end of file

Hope this help.

dpa99c commented 1 year ago

Fix published to npm as v1.0.9 - let me know if that fixes it

alois-beto commented 1 year ago

The setGoogleApiKey method is still missing from types 😕

jbcrestot commented 1 year ago

quick fix related to the subject : https://github.com/dpa99c/react-native-launch-navigator/pull/40