From 758e75f7d9e94a69391992ab436d5b6b47edcbe3 Mon Sep 17 00:00:00 2001 From: Fleny Date: Wed, 28 Jan 2026 20:06:39 +0100 Subject: [PATCH] fix(bot): Bug with return type in functions (#4689) * refactor(bot)!: setup desired properties for all transformers SetupDesiredProps when is given an object that does not corrispond to a transformer object that supports desired properties will behave like TransformProperty on the entire object as when it tries to get the properties for said object it will find `never` as the props and for `IsKeyDesired` a props of `never` means that all props are desired. * Use Equals helper, clean up a bit the code * Explicit the IsKeyDesired TProps never behavior * fix(bot): Bug with return type in functions --- packages/bot/src/desiredProperties.ts | 17 +++++++++++------ packages/bot/src/transformers/types.ts | 6 ++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/bot/src/desiredProperties.ts b/packages/bot/src/desiredProperties.ts index 644b3c90a..68e7979d9 100644 --- a/packages/bot/src/desiredProperties.ts +++ b/packages/bot/src/desiredProperties.ts @@ -550,6 +550,7 @@ export function createDesiredPropertiesObject> extends true ? // Yes, apply the desired props InteractionResolvedDataChannel - : // Is it an object? - IsObject extends true - ? // Yes, we need to ensure we transform the nested properties as well - { [K in keyof T]: TransformProperty } - : // No, this is a normal value such as string / bigint / number - T; + : // Is it a function? + T extends (...args: infer P) => Promise + ? // Yes, we need to ensure we transform the return type as well + (...args: P) => Promise> + : // Is it an object? + IsObject extends true + ? // Yes, we need to ensure we transform the nested properties as well + { [K in keyof T]: TransformProperty } + : // No, this is a normal value such as string / bigint / number + T; /** * Apply desired properties to an object. diff --git a/packages/bot/src/transformers/types.ts b/packages/bot/src/transformers/types.ts index 9942a1c74..6e0884bc4 100644 --- a/packages/bot/src/transformers/types.ts +++ b/packages/bot/src/transformers/types.ts @@ -1297,10 +1297,8 @@ export interface Message { tts: boolean; /** Whether this message came from the urgent message system */ urgent: boolean; - // TODO: Adding this causes errors in the interaction functions due to how `InteractionResolvedDataMember` and `InteractionResolvedDataChannel` are treated by `TransformProperty`, since they get their desired props changed - // and fixing this requires a few changes in `SetupDesiredProps` and `TransformProperty` so this is going to be done in another pr - // /** data for users, members, channels, and roles referenced in this message */ - // resolved?: InteractionDataResolved + /** data for users, members, channels, and roles referenced in this message */ + resolved?: InteractionDataResolved; } export interface MessageActivity {