website icon indicating copy to clipboard operation
website copied to clipboard

Commands plugin typo in flavor installation

Open carafelix opened this issue 10 months ago • 3 comments

https://github.com/grammyjs/website/blob/f6442084c369729edc772129e69cb03008919560/site/docs/plugins/commands.md?plain=1#L107


 type MyContext = CommandsFlavor<Context>;

and https://github.com/grammyjs/website/blob/f6442084c369729edc772129e69cb03008919560/site/docs/plugins/commands.md?plain=1#L115-L116

const loggedOutCommands = new CommandGroup<MyContext>();
const loggedInCommands = new CommandGroup<MyContext>();

carafelix avatar Feb 02 '25 23:02 carafelix

Technically, type MyContext = Context & CommandsFlavor is equivalent to type MyContext = Context & CommandsFlavor<Context>, since CommandsFlavor provides a default Context type where the parameter type is not given - i.e. interface CommandsFlavor<C extends Context = Context> extends Context {}.

Is there any particular reason why we want the Context & part when CommandsFlavor already extends Context?

Circular types feels a bit weird to me. I'm not sure what to think of it.

KnightNiwrem avatar Feb 03 '25 03:02 KnightNiwrem

Is there any particular reason why we want the Context & part when CommandsFlavor already extends Context?

as you pointed out: there isn't

carafelix avatar Feb 03 '25 04:02 carafelix

Should actually be:

 type MyContext = CommandsFlavor<Context>;

KnorpelSenf avatar Feb 03 '25 06:02 KnorpelSenf