grammyjs / menu

Interactive menus for grammY.
https://grammy.dev/plugins/menu
MIT License
29 stars 10 forks source link

bug: issue with constraint on 1.15.3 #32

Closed shevernitskiy closed 1 year ago

shevernitskiy commented 1 year ago

I have constraint type mismatch on grammy 1.15.3 and menu 1.1.3 with sessions

Example:

import { Bot, session, type SessionFlavor } from "https://deno.land/x/grammy@v1.15.3/mod.ts";
import { Menu } from "https://deno.land/x/grammy_menu@v1.1.3/mod.ts";

type SessionData = {
  message_to_delete: number;
};

type SessionContext = Context & SessionFlavor<SessionData>;

const bot = new Bot<SessionContext>("TOKEN");

bot.use(session({
  initial: () => ({
    message_to_delete: 0,
  })
}));

const menu = new Menu<SessionContext>("my-menu") // error on <SessionContext>
  .text("one").row()
  .text("two").row();

bot.use(menu)
bot.start()

Error message:

Type 'SessionContext' does not satisfy the constraint 'Context'.
The types of 'update.my_chat_member' are incompatible between these types.
Type 'import("https://deno.land/x/grammy_types@v3.0.3/manage").ChatMemberUpdated | undefined' is not assignable to type 'import("https://esm.sh/v99/@grammyjs/types@2.10.0/manage").ChatMemberUpdated | undefined'.
Type 'import("https://deno.land/x/grammy_types@v3.0.3/manage").ChatMemberUpdated' is not assignable to type 'import("https://esm.sh/v99/@grammyjs/types@2.10.0/manage").ChatMemberUpdated'.
Types of property 'old_chat_member' are incompatible.
Type 'import("https://deno.land/x/grammy_types@v3.0.3/manage").ChatMember' is not assignable to type 'import("https://esm.sh/v99/@grammyjs/types@2.10.0/manage").ChatMember'.
Type 'ChatMemberRestricted' is not assignable to type 'ChatMember'.
Property 'can_send_media_messages' is missing in type 'import("https://deno.land/x/grammy_types@v3.0.3/manage").ChatMemberRestricted' but required in type 'import("https://esm.sh/v99/@grammyjs/types@2.10.0/manage").ChatMemberRestricted'.
KnorpelSenf commented 1 year ago

Can you update all your dependencies related to grammY and use --reload to see if it fixes the issue?

shevernitskiy commented 1 year ago

Now its work! Thanks!