radarlabs / react-native-radar

React Native module for Radar, the leading geofencing and location tracking platform
https://radar.com
Apache License 2.0
170 stars 32 forks source link

Typescript support #52

Closed phil-andrews closed 5 months ago

phil-andrews commented 5 years ago

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

atkit commented 5 years ago

I vote for it as well.

Segfaultd commented 4 years ago

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

nickpatrick commented 4 years ago

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

pedroraft commented 4 years ago

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;
}
getinnocuous commented 3 years ago

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

andcosta commented 2 years ago

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

balloman commented 1 year ago

Are there any updates on this?

ChromeQ commented 7 months ago

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

ChromeQ commented 5 months ago

@getinnocuous I saw you closed the #191 issue. Can you close this one too?

getinnocuous commented 5 months ago

@getinnocuous I saw you closed the #191 issue. Can you close this one too?

I didn't raise it, @phil-andrews did

ChromeQ commented 5 months ago

@getinnocuous I saw you closed the #191 issue. Can you close this one too?

I didn't raise it, @phil-andrews did

My bad, thought you might have have been a contributor and got my issues mixed up.