From 793af358e1e7991e04c45f39cb9482c92e047c20 Mon Sep 17 00:00:00 2001 From: Gorkem Baris Yesiltas Date: Thu, 8 Aug 2024 12:14:55 +0200 Subject: [PATCH 1/4] now returning the whole class instance to not lose the functions --- src/languages/templates/typescript/react-native.hbs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/languages/templates/typescript/react-native.hbs b/src/languages/templates/typescript/react-native.hbs index ed21248a..f2dcd8a6 100644 --- a/src/languages/templates/typescript/react-native.hbs +++ b/src/languages/templates/typescript/react-native.hbs @@ -54,7 +54,6 @@ export const useAnalytics = () => { // @ts-ignore return {}; } - return { - ...client, - }; + + return client; }; From 401a3fa9a05d10b27d549c948d2eae3a279406a3 Mon Sep 17 00:00:00 2001 From: Gorkem Baris Yesiltas Date: Thu, 8 Aug 2024 12:15:18 +0200 Subject: [PATCH 2/4] adding explicit typing --- src/languages/templates/typescript/react-native.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/templates/typescript/react-native.hbs b/src/languages/templates/typescript/react-native.hbs index f2dcd8a6..08b5057c 100644 --- a/src/languages/templates/typescript/react-native.hbs +++ b/src/languages/templates/typescript/react-native.hbs @@ -43,7 +43,7 @@ export const AnalyticsProvider = ({ return {children}; }; -export const useAnalytics = () => { +export const useAnalytics: TypewriterSegmentClient | {} = () => { const client = useContext(Context); if (!client) { console.error( From 5c822db08d6c306f2aad48996f1230d3409405da Mon Sep 17 00:00:00 2001 From: Gorkem Baris Yesiltas Date: Thu, 8 Aug 2024 12:15:24 +0200 Subject: [PATCH 3/4] regenerated snapshots --- src/__tests__/commands/__snapshots__/build.test.ts.snap | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/__tests__/commands/__snapshots__/build.test.ts.snap b/src/__tests__/commands/__snapshots__/build.test.ts.snap index a84d8ac0..98bd7736 100644 --- a/src/__tests__/commands/__snapshots__/build.test.ts.snap +++ b/src/__tests__/commands/__snapshots__/build.test.ts.snap @@ -13282,7 +13282,7 @@ export const AnalyticsProvider = ({ return {children}; }; -export const useAnalytics = () => { +export const useAnalytics: TypewriterSegmentClient | {} = () => { const client = useContext(Context); if (!client) { console.error( @@ -13293,9 +13293,8 @@ export const useAnalytics = () => { // @ts-ignore return {}; } - return { - ...client, - }; + + return client; }; " From f689899260ff667dd70c75e107dfbb09abe5dfe3 Mon Sep 17 00:00:00 2001 From: Gorkem Baris Yesiltas Date: Thu, 8 Aug 2024 13:46:48 +0200 Subject: [PATCH 4/4] fixed the type --- src/__tests__/commands/__snapshots__/build.test.ts.snap | 2 +- src/languages/templates/typescript/react-native.hbs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/__tests__/commands/__snapshots__/build.test.ts.snap b/src/__tests__/commands/__snapshots__/build.test.ts.snap index 98bd7736..12f5d63f 100644 --- a/src/__tests__/commands/__snapshots__/build.test.ts.snap +++ b/src/__tests__/commands/__snapshots__/build.test.ts.snap @@ -13282,7 +13282,7 @@ export const AnalyticsProvider = ({ return {children}; }; -export const useAnalytics: TypewriterSegmentClient | {} = () => { +export const useAnalytics = (): TypewriterSegmentClient | {} => { const client = useContext(Context); if (!client) { console.error( diff --git a/src/languages/templates/typescript/react-native.hbs b/src/languages/templates/typescript/react-native.hbs index 08b5057c..52b13511 100644 --- a/src/languages/templates/typescript/react-native.hbs +++ b/src/languages/templates/typescript/react-native.hbs @@ -43,7 +43,7 @@ export const AnalyticsProvider = ({ return {children}; }; -export const useAnalytics: TypewriterSegmentClient | {} = () => { +export const useAnalytics = (): TypewriterSegmentClient | {} => { const client = useContext(Context); if (!client) { console.error(