meteorrn / meteor-react-native

Meteor client for React Native matching Meteor Spec
https://guide.meteor.com/react-native.html
Other
59 stars 31 forks source link

Typescript Types .d.ts file #46

Closed j-khong closed 3 years ago

j-khong commented 3 years ago

following this PR https://github.com/TheRealNate/meteor-react-native/issues/13

i've just made a quick meteorrn-core.d.ts file in order to remove all the red in my vscode window

feel free to correct/update it

declare module '@meteorrn/core' {
   function connect(endpoint: string, options?: any): void;
   function disconnect(): void;
   function reconnect(): void;

   type Status = 'change' | 'connected' | 'disconnected' | 'loggingIn' | 'change';

   function call(...args: any[]): void;
   function status(): {
      connected: boolean;
      status: Status;
   };

   interface Data {
      getUrl(): string;
      waitDdpReady(cb: (...args: any[]) => void): void;
      onChange(cb: (...args: any[]) => void): void;
      offChange(cb: (...args: any[]) => void): void;
      on(eventName: string, cb: (...args: any[]) => void): void;
      off(eventName: string, cb: (...args: any[]) => void): void;
      waitDdpConnected(cb: (...args: any[]) => void): void;
   }
   function getData(): Data;
}
TheRealNate commented 3 years ago

Hey @j-khong, this is really helpful! Would you like to open a PR to make sure you get properly credited?

j-khong commented 3 years ago

see https://github.com/TheRealNate/meteor-react-native/pull/47