diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 066ec2d92a..8e8cd7a28b 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -35,6 +35,7 @@ // Mohamed Shaban // André Krüger // Jérémy Barbet +// Christian Ost // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -8913,6 +8914,28 @@ export interface KeyboardStatic extends NativeEventEmitter { addListener(eventType: KeyboardEventName, listener: KeyboardEventListener): EmitterSubscription; } +/** + * The DevSettings module exposes methods for customizing settings for developers in development. + */ +export interface DevSettingsStatic extends NativeEventEmitter { + /** + * Adds a custom menu item to the developer menu. + * + * @param title - The title of the menu item. Is internally used as id and should therefore be unique. + * @param handler - The callback invoked when pressing the menu item. + */ + addMenuItem(title: string, handler: () => any): void; + + /** + * Reload the application. + * + * @param reason + */ + reload(reason?: string): void; +} + +export const DevSettings: DevSettingsStatic; + ////////////////////////////////////////////////////////////////////////// // // R E - E X P O R T S diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 9cb631d71a..18c3c0c998 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -96,6 +96,7 @@ import { HostComponent, Appearance, useColorScheme, + DevSettings, } from 'react-native'; declare module 'react-native' { @@ -1085,3 +1086,10 @@ const DarkMode = () => { return Is dark mode enabled? {isDarkMode}; }; + +// DevSettings +DevSettings.addMenuItem('alert', () => { + Alert.alert('alert'); +}); +DevSettings.reload(); +DevSettings.reload('reload with reason');