Open sigorilla opened 4 years ago
Describe the bug I created my own client for "other" platform, but typings does not allow use different Client type because of union.
Client
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.
Event
Body
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:
Expected behavior
I think that type of
Client
should be like this:The same patch should be added to
Event
andBody
.