From caa8dbf0e97151f7f2fc67606ed030ed1fbc9409 Mon Sep 17 00:00:00 2001 From: Everaldo Junior Date: Thu, 20 Jul 2023 16:04:58 -0700 Subject: [PATCH] fix: unified Share Action types (#38351) Summary: This pull request simplifies the type and fixes a TypeScript object destructuring problem by combining the ShareSharedAction and ShareDismissedAction types into a single ShareAction type. Enabling proper access to the activityType property without TypeScript errors. ## Changelog: [INTERNAL] [FIXED] - Unified ShareSharedAction and ShareDismissedAction into ShareAction. Resolved TypeScript issue with object destructuring. Pull Request resolved: https://github.com/facebook/react-native/pull/38351 Test Plan: With the current typing: ![image](https://github.com/facebook/react-native/assets/7197169/40b43c40-ed6c-4b1a-8f43-0bb853920e20) With the proposed solution: ![image](https://github.com/facebook/react-native/assets/7197169/af9e601b-780c-4c69-9a8c-11771a125a0c) Reviewed By: NickGerleman Differential Revision: D47527426 Pulled By: philIip fbshipit-source-id: 9830cd993596bbac2dc07d9f37ca20b35f582156 --- packages/react-native/Libraries/Share/Share.d.ts | 12 +++--------- packages/react-native/types/__typetests__/index.tsx | 3 +-- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/packages/react-native/Libraries/Share/Share.d.ts b/packages/react-native/Libraries/Share/Share.d.ts index 76ac757c97e..789251a2c7b 100644 --- a/packages/react-native/Libraries/Share/Share.d.ts +++ b/packages/react-native/Libraries/Share/Share.d.ts @@ -27,17 +27,11 @@ export type ShareOptions = { anchor?: number | undefined; }; -export type ShareSharedAction = { - action: 'sharedAction'; - activityType?: string | undefined; +export type ShareAction = { + action: 'sharedAction' | 'dismissedAction'; + activityType?: string | null | undefined; }; -export type ShareDismissedAction = { - action: 'dismissedAction'; -}; - -export type ShareAction = ShareSharedAction | ShareDismissedAction; - export interface ShareStatic { /** * Open a dialog to share text content. diff --git a/packages/react-native/types/__typetests__/index.tsx b/packages/react-native/types/__typetests__/index.tsx index d73b93d1459..26419aa6c34 100644 --- a/packages/react-native/types/__typetests__/index.tsx +++ b/packages/react-native/types/__typetests__/index.tsx @@ -84,8 +84,7 @@ import { SectionListProps, SectionListRenderItemInfo, Share, - ShareDismissedAction, - ShareSharedAction, + ShareAction, StatusBar, StyleProp, StyleSheet,