From 595b7cb3e17d369c32ab06686001e1e7c5719cef Mon Sep 17 00:00:00 2001 From: Jason Salaber Date: Mon, 10 Mar 2025 15:35:45 -0400 Subject: [PATCH] chore: added return type to react generated hooks --- internal/generators/react/react.tmpl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/generators/react/react.tmpl b/internal/generators/react/react.tmpl index e1c40cf..bb8f7e1 100644 --- a/internal/generators/react/react.tmpl +++ b/internal/generators/react/react.tmpl @@ -3,6 +3,7 @@ import { type ReactFlagEvaluationOptions, type ReactFlagEvaluationNoSuspenseOptions, + type FlagQuery, useFlag, useSuspenseFlag, } from "@openfeature/react-sdk"; @@ -15,7 +16,7 @@ import { * - default value: `{{ .DefaultValue }}` * - type: `{{ .Type | OpenFeatureType }}` */ -export const use{{ .Key | ToPascal }} = (options?: ReactFlagEvaluationOptions) => { +export const use{{ .Key | ToPascal }} = (options?: ReactFlagEvaluationOptions): FlagQuery<{{ .Type | OpenFeatureType }}> => { return useFlag({{ .Key | Quote }}, {{ .DefaultValue | QuoteString }}, options); }; @@ -30,7 +31,7 @@ export const use{{ .Key | ToPascal }} = (options?: ReactFlagEvaluationOptions) = * Equivalent to useFlag with options: `{ suspend: true }` * @experimental — Suspense is an experimental feature subject to change in future versions. */ -export const useSuspense{{ .Key | ToPascal }} = (options?: ReactFlagEvaluationNoSuspenseOptions) => { +export const useSuspense{{ .Key | ToPascal }} = (options?: ReactFlagEvaluationNoSuspenseOptions): FlagQuery<{{ .Type | OpenFeatureType }}> => { return useSuspenseFlag({{ .Key | Quote }}, {{ .DefaultValue | QuoteString }}, options); }; {{ end}} \ No newline at end of file