Add typings for dismissActionSheet method (#40012)

Summary:
This pull request addresses two key issues. Firstly, it adds a missing docstring to the `dismissActionSheet` function within the `ActionSheetIOS` object. Secondly, it introduces TypeScript typings for the `dismissActionSheet` function.

## Changelog:

[iOS] [Added] - Add missing docstring to the `dismissActionSheet` function in `ActionSheetIOS`.
[iOS] [Added] - Add TypeScript typings for the `dismissActionSheet` function in `ActionSheetIOS`.

Pull Request resolved: https://github.com/facebook/react-native/pull/40012

Test Plan:
To ensure the code is solid, I followed these steps:

1. Ran Flow to verify that there were no errors.
2. Added a TypeScript test related to the `dismissActionSheet` function to ensure it's typed as expected.

Reviewed By: NickGerleman

Differential Revision: D50097458

Pulled By: arushikesarwani94

fbshipit-source-id: 63348239dfe19e3a07f94e5a7b59ae43a47c1975
This commit is contained in:
Lorenzo Pieri
2023-10-09 17:16:27 -07:00
committed by Facebook GitHub Bot
parent ea88fbe229
commit 89c7be890b
3 changed files with 13 additions and 0 deletions
@@ -74,6 +74,12 @@ export interface ActionSheetIOSStatic {
failureCallback: (error: Error) => void,
successCallback: (success: boolean, method: string) => void,
) => void;
/**
* Dismisses the most upper iOS action sheet presented, if no action sheet is
* present a warning is displayed.
*/
dismissActionSheet: () => void;
}
export const ActionSheetIOS: ActionSheetIOSStatic;
@@ -145,6 +145,10 @@ const ActionSheetIOS = {
);
},
/**
* Dismisses the most upper iOS action sheet presented, if no action sheet is
* present a warning is displayed.
*/
dismissActionSheet: () => {
invariant(RCTActionSheetManager, "ActionSheetManager doesn't exist");
if (typeof RCTActionSheetManager.dismissActionSheet === 'function') {
@@ -2115,4 +2115,7 @@ const ActionSheetIOSTest = () => {
},
() => undefined,
);
// test dismissActionSheet method
ActionSheetIOS.dismissActionSheet();
};