diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index cbc45eb065..913af8717a 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -6709,6 +6709,17 @@ export type ShareOptions = { tintColor?: string; }; +export type ShareSharedAction = { + action: "sharedAction"; + activityType?: string; +}; + +export type ShareDismissedAction = { + action: "dismissedAction" +}; + +export type ShareAction = ShareSharedAction | ShareDismissedAction; + export interface ShareStatic { /** * Open a dialog to share text content. @@ -6742,9 +6753,9 @@ export interface ShareStatic { * - `dialogTitle` * */ - share(content: ShareContent, options?: ShareOptions): Promise; - sharedAction: string; - dismissedAction: string; + share(content: ShareContent, options?: ShareOptions): Promise; + sharedAction: "sharedAction"; + dismissedAction: "dismissedAction"; } type AccessibilityEventName = "change" | "announcementFinished"; diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 4186b082fb..dd5a543aa0 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -53,6 +53,9 @@ import { ScrollView, ScrollViewProps, SectionListRenderItemInfo, + Share, + ShareDismissedAction, + ShareSharedAction, Switch, RefreshControl, RegisteredStyle, @@ -810,3 +813,17 @@ const NativeIDTest = () => ( Text ); + +const ShareTest = () => { + Share.share( + { title: "title", message: "message" }, + { dialogTitle: "dialogTitle", excludedActivityTypes: ["activity"], tintColor: "red" } + ); + Share.share({ title: "title", url: "url" }); + Share.share({ message: "message" }).then(result => { + if (result.action === Share.sharedAction) { + const activity = result.activityType; + } else if (result.action === Share.dismissedAction) { + } + }); +};