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

Cannot create custom client because typings #862

Open
sigorilla opened this issue Sep 6, 2020 · 0 comments
Open

Cannot create custom client because typings #862

sigorilla opened this issue Sep 6, 2020 · 0 comments

Comments

@sigorilla
Copy link
Contributor

Describe the bug
I created my own client for "other" platform, but typings does not allow use different Client type because of union.

Interfaces for my bot:

import {Bot} from 'bottender';

interface OtherRawEvent {
    update_id: number;
    message?: TextMessage;
}

class OtherClient {
    start(): Promise<void>;
    startPolling(): Promise<void>;
    stopPolling(): void;
    isPolling(): boolean;
    receiveUpdates(updates: OtherRawEvent[]): void;
    setWebhook(url?: string): Promise<OtherClient>;
    sendMessage(chatId: string, text: string): Promise<TextMessage>;
}

class OtherEvent implements Event<OtherRawEvent> {}

class OtherContext extends Context<OtherClient, OtherEvent> {}

class OtherBot extends Bot<OtherRawEvent, OtherClient, OtherEvent, OtherContext> {}
//                                        ^^^^^^^^^^^ <- error below

Type 'OtherClient' does not satisfy the constraint 'Client'.
Type 'OtherClient' is missing the following properties from type 'TelegramClient': _token, _onRequest, _axios, axios, and 47 more. ts(2344)

Expected behavior

I think that type of Client should be like this:

export type Client =
  | ConsoleClient
  | MessengerClient
  | LineClient
  | SlackOAuthClient
  | TelegramClient
  | ViberClient
  | TwilioClient
  | unknown;

The same patch should be added to Event and Body.

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

1 participant