Hi!
I am testing discord.js to interact on my server with my bot.
When wanting to recover a channel and use the characteristics of typescript, I realized that the return type in the .fetch method of the ChannelManager object is wrong.
The official documentation indicates that it returns an object of type Channel, but it is not what really happens.

This error prevents us from declaring the type of object received and then accessing its properties.
The following type declaration returns a typescript error:
// Fetch a channel by its id
const channel: TextChannel = await this.discordClient.channels.fetch('CHANNEL_ID');


Changing the return type would fix this error?
https://github.com/discordjs/discord.js/blob/56e8ef2d38633154540748acb64f4c1305fcc6d3/src/managers/ChannelManager.js#L78
Thanks!
Channel is the common ancestor of all types which can be fetched using that method. However tighter inference of types is not possible due to some quirks in the way the classes are written (which is in JS, not TS)
To use this with TS you'll need to force typecasting with as TextChannel or similar.
If you need help with discord.js installation or usage, please go to the discord.js Discord server instead:
https://discord.gg/bRCvFy9
This issue tracker is only for bug reports and enhancement suggestions.
If you need help with discord.js installation or usage, please go to the discord.js Discord server instead:
https://discord.gg/bRCvFy9
This issue tracker is only for bug reports and enhancement suggestions.
I posted here because I thought it was a mistake.
Most helpful comment
Channelis the common ancestor of all types which can be fetched using that method. However tighter inference of types is not possible due to some quirks in the way the classes are written (which is in JS, not TS)To use this with TS you'll need to force typecasting with
as TextChannelor similar.