react-native-radar icon indicating copy to clipboard operation
react-native-radar copied to clipboard

Typescript support

Open phil-andrews opened this issue 6 years ago • 8 comments

I imagine they've already been discussed so just count this as my vote for Typescript typings.

phil-andrews avatar Dec 17 '18 20:12 phil-andrews

I vote for it as well.

atkit avatar Jul 16 '19 15:07 atkit

Hi Radar Devs, any update on this? Providing a typings file should not be too hard. Please consider that issue :)

Segfaultd avatar Jan 28 '20 22:01 Segfaultd

Hey, thanks for following up. We use TypeScript internally and understand how useful this would be. No timing yet, but on our roadmap.

nickpatrick avatar Jan 30 '20 15:01 nickpatrick

i just created a pr with some type definitions but as i said in the pr #98 its a wip. if any one needs a quick copy pasta just create a .d.ts anywhere in your project, paste this and it should work.

declare module 'react-native-radar' {
  export type permissionStatus = 'GRANTED' | 'DENIED' | 'UNKNOWN';
  export type errorString =
    | 'ERROR_PUBLISHABLE_KEY'
    | 'ERROR_PERMISSIONS'
    | 'ERROR_LOCATION'
    | 'ERROR_NETWORK'
    | 'ERROR_UNAUTHORIZED'
    | 'ERROR_SERVER'
    | 'ERROR_UNKNOWN';

  export interface trackResult {
    location: RadarLocation;
    events: any;
    user?: {
      geofences: any;
    };
  }

  export type onEvents = (
    event: 'events',
    callback: (result: { events: any; user: any }) => void,
  ) => void;

  export type onLocation = (
    event: 'location',
    callback: (result: { location: RadarLocation; user: any }) => void,
  ) => void;

  export type onError = (event: 'error', callback: (err: any) => void) => void;

  export type onEvent = onEvents | onLocation | onError;

  export interface RadarLocation {
    latitude: number;
    longitude: number;
    accuracy: number;
  }

  export interface Radar {
    initialize: (publishableKey: string) => void;
    setUserId: (userId: string) => void;
    setMetadata: (metadata: object) => void;
    setDescription: (setDescription: string) => void;
    setPlacesProvider: (provider: string) => void;
    getPermissionsStatus: () => Promise<permissionStatus>;
    // posible return permissionStatus but idk
    requestPermissions: (background: boolean) => any;
    trackOnce: () => Promise<trackResult>;
    startTracking: (options: object) => any;
    stopTracking: () => void;
    on: onEvent;
    off: (event: 'events' | 'location' | 'error') => void;
    updateLocation: (location: RadarLocation) => trackResult;
  }

  const Radar: Radar;
  export default Radar;
}

pedroraft avatar Mar 06 '20 16:03 pedroraft

Are there any plans to release the updated types for v3?

getinnocuous avatar Aug 13 '21 15:08 getinnocuous

UP ☝🏻 Are there any plans to release the updated types for v3?

andcosta avatar Apr 14 '22 23:04 andcosta

Are there any updates on this?

balloman avatar Sep 18 '23 21:09 balloman

Surely this can be closed now? I see typings in the latest version

ChromeQ avatar Apr 11 '24 13:04 ChromeQ