diff --git a/src/filter.ts b/src/filter.ts index 371225fe..2ce60db4 100644 --- a/src/filter.ts +++ b/src/filter.ts @@ -638,7 +638,8 @@ interface Shortcuts { : [U["message_reaction"]] extends [object] ? number : [U["message_reaction_count"]] extends [object] ? number : undefined; - chatId: [Shortcuts["chat"]] extends [object] ? number + chatId: [U["callback_query"]] extends [object] ? number | undefined + : [Shortcuts["chat"]] extends [object] ? number : [U["business_connection"]] extends [object] ? number : undefined; // inlineMessageId: disregarded here because always optional on both types diff --git a/test/composer.type.test.ts b/test/composer.type.test.ts index 43909f85..675c4c7e 100644 --- a/test/composer.type.test.ts +++ b/test/composer.type.test.ts @@ -60,6 +60,7 @@ describe("Composer types", () => { const callbackQueryMessage = ctx.callbackQuery.message; const callbackQueryData = ctx.callbackQuery.data; const match = ctx.match; + const chatId = ctx.chatId; assertType< IsExact >( @@ -92,6 +93,7 @@ describe("Composer types", () => { assertType>( true, ); + assertType>(true); }); }); }); @@ -311,4 +313,15 @@ describe("Composer types", () => { }); }); }); + + describe("known combined usages", () => { + it("should work with .chatType.callbackQuery", () => { + composer.chatType("private").callbackQuery("query", (ctx) => { + assertType>(true); + }); + composer.callbackQuery("query").chatType("private", (ctx) => { + assertType>(true); + }); + }); + }); });