Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript d.ts file #155

Open
mo22 opened this issue Feb 25, 2021 · 2 comments
Open

typescript d.ts file #155

mo22 opened this issue Feb 25, 2021 · 2 comments

Comments

@mo22
Copy link

mo22 commented Feb 25, 2021

Hi,

maybe you want to add a d.ts typing file (package.json "typing": "index.d.ts")

declare module 'react-native-zeroconf' {

  import { EventEmitter } from 'events';

  export interface PendingService {
    name: string;
  }
  export interface Service {
    name: string;
    port: number;
    txt: { [key: string]: string; };
    addresses: string[];
    fullName: string;
    host: string;
  }

  export default class Zeroconf extends EventEmitter {
    public getServices(): { [name: string]: Service | PendingService; };
    public scan(type?: string, protocol?: string, domain?: string, implType?: 'NSD' | 'DNSSD'): void;
    public stop(implType?: 'NSD' | 'DNSSD'): void;
    public publishService(type: string, protocol: string, domain?: string, name?: Service['name'], port?: Service['port'], txt?: Service['txt'], implType?: 'NSD' | 'DNSSD'): void;
    public unpublishService(name: string, implType?: 'NSD' | 'DNSSD'): void;

    public on(event: 'start', listener: () => void): this;
    public on(event: 'stop', listener: () => void): this;
    public on(event: 'error', listener: (error: any) => void): this;
    public on(event: 'update', listener: () => void): this;
    public on(event: 'found', listener: (name: string) => void): this;
    public on(event: 'remove', listener: (name: string) => void): this;
    public on(event: 'resolved', listener: (service: Service) => void): this;
    public on(event: 'published', listener: (service: Service) => void): this;
    public on(event: 'unpublished', listener: (service: Service) => void): this;
    // addListener, once, etc?
  }

}
@balthazar
Copy link
Owner

I don't deal with typings as I don't use them, usually people do PRs on the repos I maintain and I merge them, so feel free! 🙂

@nschild
Copy link

nschild commented Apr 7, 2023

I realize this is old, but @types/react-native-zeroconf exists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants