-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using template types in declarations #196
Comments
My solution to this was to just make a custom command class (extending |
They are pretty much equivalent, but I consider using a template type is a more elegant solution. But I never thought on that way, my current method was |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Most of the provided classes have a member to access to the AkairoClient, which commonly is a class that inherits from it. However, when using TypeScript, it complains if you try to access to your custom client's members because the client of, let's say,
Command
class is of typeAkairoClient
.If I want to write a command like:
You will receive the following warning:
However, if you ignore it and run the bot, it will reply with the version properly. The problem is in the types definition.
A suggestion is to add template types to these classes, so you could:
Where
Command.client
would not be of typeAkairoClient
but<Client extends AkairoClient>
. Now I could access to my custom properties properly, without having to use// @ts-ignore
.Hopefully the point is clear enough!
The text was updated successfully, but these errors were encountered: