From 9f240ea0d14aea50b97ee59440721359226da4cd Mon Sep 17 00:00:00 2001 From: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com> Date: Thu, 11 Nov 2021 13:37:53 -0500 Subject: [PATCH] types: fix cache type fallback types (#6961) --- typings/index.d.ts | 6 +++--- typings/tests.ts | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index d79e51123..47123c7e8 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1177,11 +1177,11 @@ export type CacheTypeReducer< RawType = CachedType, PresentType = CachedType | RawType, Fallback = PresentType | null, -> = State extends 'cached' +> = [State] extends ['cached'] ? CachedType - : State extends 'raw' + : [State] extends ['raw'] ? RawType - : State extends 'present' + : [State] extends ['present'] ? PresentType : Fallback; diff --git a/typings/tests.ts b/typings/tests.ts index f132aff7b..ffe003437 100644 --- a/typings/tests.ts +++ b/typings/tests.ts @@ -913,6 +913,7 @@ declare const booleanValue: boolean; if (interaction.inGuild()) assertType(interaction.guildId); client.on('interactionCreate', async interaction => { + assertType(interaction.guildId); if (interaction.inCachedGuild()) { assertType(interaction.member); // @ts-expect-error