Specifying Types

I'm quite new to Typescript, but I'm slowly getting the hang of it. Although, I was wondering if there's a way to set the type to an TextChannel? Check the image below for what I mean.
No description
Solution:
Yes just import the class then write as TextChannel, or first write it as such and let vscode fix the import when it says it’s not there yet.
Jump to solution
3 Replies
qvgk
qvgk8mo ago
As you can see it's specifying the type (or whatever it's called) to any, although I was wondering if I can mark it as a TextChannel as that's what it is?
Solution
Favna
Favna8mo ago
Yes just import the class then write as TextChannel, or first write it as such and let vscode fix the import when it says it’s not there yet.
Lioness100
Lioness1008mo ago
@qvgk You can also do:
const channelToSend = interaction.options.getChannel<ChannelType.GuildText>("channel");
const channelToSend = interaction.options.getChannel<ChannelType.GuildText>("channel");