Why do I sometimes have to provide <true> to certain types?

I'm not entirely sure why sometimes I have to provide <true> to a type annotation. I've only seen this twice so far. For example. Does this have something to do with the message cache?
const execute = async (message: Message<true>) => {
// Skip if message has no components
if (!message.components || message.components.length === 0) {
return;
}
const execute = async (message: Message<true>) => {
// Skip if message has no components
if (!message.components || message.components.length === 0) {
return;
}
async execute(client: Client<true>) {
console.log(`Ready! Logged in as ${client.user.tag}`);
}
async execute(client: Client<true>) {
console.log(`Ready! Logged in as ${client.user.tag}`);
}
2 Replies
d.js toolkit
d.js toolkit3d ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
TÆMBØ
TÆMBØ3d ago
It depends on what type you're using it for. If you check the type definition, the name of the generic will generally help tell you why it's there and what it's used for

Did you find this page helpful?