Skip to content
This repository has been archived by the owner on Dec 24, 2021. It is now read-only.

typings/fix: improve typings #310

Merged
merged 6 commits into from
Jan 12, 2021
Merged

Conversation

NotSugden
Copy link
Contributor

@NotSugden NotSugden commented May 27, 2020

This PR improves certian typings within the library, such as each client event not needing to be documented, as its inherited from the discord.js Client class, and changing the CommandoMessage class to extend the discord.js Message class to match what is actually exported.

i got the impression i did something funky with making methods such as CommandoMessage#reply being CommandoMessage['say'], they seem to accept the same options so it seemed silly to just copy paste the same types for each of those functions

edit: new typings haven't been tested in typescript yet, as i haven't had time to do it extensively, but if someone would like to test them you're welcome to

@ShawnCZek
Copy link

With TypeScript, this does not really work well. Especially due to missing events where you removed most of them.

@NotSugden
Copy link
Contributor Author

NotSugden commented Jun 22, 2020

With TypeScript, this does not really work well. Especially due to missing events where you removed most of them.

the removed events are inherited from the discord.js Client class

@ShawnCZek
Copy link

With TypeScript, this does not really work well. Especially due to missing events where you removed most of them.

the removed events are inherited from the discord.js Client class

When I tried it, I did not have any type-hinting for events.

@NotSugden
Copy link
Contributor Author

NotSugden commented Jun 22, 2020

With TypeScript, this does not really work well. Especially due to missing events where you removed most of them.

the removed events are inherited from the discord.js Client class

When I tried it, I did not have any type-hinting for events.

this could be being caused by line 201, ill test this at some point and see

edit: i remember something a while back about the generic string type, essentially, remvoing all the autocompletes from ts

@ShawnCZek
Copy link

ShawnCZek commented Jun 23, 2020

I get type-hinting for the events listed there, for example, commandBlock. However, with this change, I lost the ability to get hints for events like presenceUpdate or messageUpdate.

@NotSugden
Copy link
Contributor Author

@ShawnCZek fixed

@GCamilleri
Copy link

GCamilleri commented Jan 13, 2021

Hey team I'm still getting errors at compile time using the latest discord.js package which seem to relate to this:

Property 'reply' in type 'CommandoMessage' is not assignable to the same property in base type 'Message'. Type '{ (content: any, options?: MessageEmbed | MessageAttachment | (MessageEmbed | MessageAttachment)[] | (MessageOptions & { ...; })): Promise<...>; (content: any, options?: MessageEmbed | ... 2 more ... | (MessageOptions & { ...; })): Promise<...>; }' is not assignable to type '{ (content: string | number | bigint | boolean | symbol | readonly any[] | MessageEmbed | MessageAttachment | (MessageEmbed | MessageAttachment)[] | (MessageOptions & { ...; })): Promise<...>; (options: MessageOptions & { ...; }): Promise<...>; (options: APIMessage | MessageOptions): Promise<...>; (content: any, opt...'. Type 'Promise<CommandoMessage>' is not assignable to type 'Promise<Message>'. Type 'CommandoMessage' is not assignable to type 'Message'. The types returned by 'reply(...)' are incompatible between these types. Type 'Promise<CommandoMessage>' is not assignable to type 'Promise<Message[]>'. Type 'CommandoMessage' is missing the following properties from type 'Message[]': length, pop, push, concat, and 26 more.

Anyone got any ideas?

@GCamilleri
Copy link

I can confirm the latest Commando master works with discord.js 12.2.0, but not with the latest discord.js master

@ckohen
Copy link
Member

ckohen commented Jan 13, 2021

This would be because discord.js master has switched to using discords new inline replies which will require similar changes to Commando

@GCamilleri
Copy link

I haven't figured out what the most recent compatible version of discord.js is yet, I'll keep checking.

@GCamilleri
Copy link

Looks like Commando works up to discord.js 12.3.1, but isn't compatible with 12.4.0 onwards.

@lilyissillyyy
Copy link
Contributor

If someone more knowledgeable about TypeScript would like to tackle this, feel free. My knowledge of it is zilch.

@arifali123
Copy link

Can you somehow unmerge this or something, its impossible to write a command in typescript properly. None of my old bots work and I have had to rollback to an oudated version so they would run. Please.

@tipakA
Copy link

tipakA commented Jan 15, 2021

And the issue that comes from this PR is...?

@NotSugden
Copy link
Contributor Author

why revert it when you can fix it

#355

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants