From 583b528f40dfaa74fec6819c5cb57ec4a592350e Mon Sep 17 00:00:00 2001 From: vishtree Date: Fri, 27 Mar 2020 09:57:51 +0100 Subject: [PATCH] Fixing types for StreamChat constructor Fixes https://github.com/GetStream/stream-chat-js/issues/250 --- types/stream-chat/index.d.ts | 3 ++- types/stream-chat/test-stream-chat.ts | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/types/stream-chat/index.d.ts b/types/stream-chat/index.d.ts index caa09e912..8a1ebfd07 100644 --- a/types/stream-chat/index.d.ts +++ b/types/stream-chat/index.d.ts @@ -157,7 +157,8 @@ export interface StreamChatOptions { export type EventHandler = (event: Event) => void; export class StreamChat { - constructor(key: string, secretOrOptions?: string, options?: StreamChatOptions); + constructor(key: string, options?: StreamChatOptions); + constructor(key: string, secret?: string, options?: StreamChatOptions); key: string; userToken?: string; diff --git a/types/stream-chat/test-stream-chat.ts b/types/stream-chat/test-stream-chat.ts index 5dbcd07d1..3dfd45c7c 100644 --- a/types/stream-chat/test-stream-chat.ts +++ b/types/stream-chat/test-stream-chat.ts @@ -8,6 +8,11 @@ const client = new StreamChat(apiKey, null, { logger: (logLevel: string, msg: string, extraData: {}) => {}, }); +const clientWithoutSecret = new StreamChat(apiKey, { + timeout: 3000, + logger: (logLevel: string, msg: string, extraData: {}) => {}, +}); + const devToken = client.devToken('joshua'); // $ExpectType string client.createToken('james', 3600); // $ExpectType string client.getAuthType(); // $ExpectType string