From 64895a2bb3c445f6e3deab85152a0d04ced17e46 Mon Sep 17 00:00:00 2001 From: Jan Amann Date: Wed, 18 Dec 2024 09:39:50 +0100 Subject: [PATCH] fix: Support `t.has` when `getTranslations` is called with an object argument (#1616) See https://github.com/amannn/next-intl/discussions/437#discussioncomment-11593318 --- .../server/react-server/getTranslations.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/next-intl/src/server/react-server/getTranslations.tsx b/packages/next-intl/src/server/react-server/getTranslations.tsx index 81deeec13..c3068e908 100644 --- a/packages/next-intl/src/server/react-server/getTranslations.tsx +++ b/packages/next-intl/src/server/react-server/getTranslations.tsx @@ -210,6 +210,24 @@ Promise<{ >( key: TargetKey ): any; + + // `has` + has< + TargetKey extends MessageKeys< + NestedValueOf< + {'!': IntlMessages}, + [NestedKey] extends [never] ? '!' : `!.${NestedKey}` + >, + NestedKeyOf< + NestedValueOf< + {'!': IntlMessages}, + [NestedKey] extends [never] ? '!' : `!.${NestedKey}` + > + > + > + >( + key: [TargetKey] extends [never] ? string : TargetKey + ): boolean; }>; // IMPLEMENTATION async function getTranslations<