feat: Backport cache types resolving to never (#7561)

This commit is contained in:
Jiralite
2022-03-02 09:32:46 +00:00
committed by GitHub
parent 29d42ed319
commit 611d3a7b2f
2 changed files with 34 additions and 13 deletions

View File

@@ -944,7 +944,28 @@ expectDeprecated(sticker.deleted);
// Test interactions
declare const interaction: Interaction;
declare const booleanValue: boolean;
if (interaction.inGuild()) expectType<Snowflake>(interaction.guildId);
if (interaction.inGuild()) {
expectType<Snowflake>(interaction.guildId);
} else {
expectType<Snowflake | null>(interaction.guildId);
}
client.on('interactionCreate', interaction => {
// This is for testing never type resolution
if (!interaction.inGuild()) {
return;
}
if (interaction.inRawGuild()) {
expectNotType<never>(interaction);
return;
}
if (interaction.inCachedGuild()) {
expectNotType<never>(interaction);
return;
}
});
client.on('interactionCreate', async interaction => {
if (interaction.inCachedGuild()) {