diff --git a/types/react-native-safe-area/index.d.ts b/types/react-native-safe-area/index.d.ts index 7eaaf3b15e..923c5ae1bf 100644 --- a/types/react-native-safe-area/index.d.ts +++ b/types/react-native-safe-area/index.d.ts @@ -2,35 +2,47 @@ // Project: https://github.com/miyabi/react-native-safe-area#readme // Definitions by: Pavlos Vinieratos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.0 +// TypeScript Version: 2.8 /// -declare module 'react-native-safe-area' { - type Direction = - | 'top' - | 'bottom' - | 'left' - | 'right' - | 'topLeft' // DEPRECATED - | 'topAndLeft' - | 'topRight' // DEPRECATED - | 'topAndRight' - | 'bottomLeft' // DEPRECATED - | 'bottomAndLeft' - | 'bottomRight' // DEPRECATED - | 'bottomAndRight' - | 'vertical' - | 'horizontal' - | 'verticalAndLeft' - | 'verticalAndRight' - | 'horizontalAndTop' - | 'horizontalAndBottom' - | 'all'; +import { EmitterSubscription } from 'react-native'; - export function withSafeArea( - WrappedComponent: React.ComponentType, - applyTo: 'margin' | 'padding' | 'absolutePosition' | 'contentInset' = 'margin', - direction: Direction = 'all', - ): React.ComponentType; +// from `TypeDefinition.js` +export interface SafeAreaInsets { top: number; left: number; bottom: number; right: number; } + +// from `SafeArea.[ios|android].js` +declare namespace SafeArea { + function getSafeAreaInsetsForRootView(): Promise<{ safeAreaInsets: SafeAreaInsets }>; + function addEventListener(eventType: string, listener: (...args: any[]) => any, context?: any): EmitterSubscription; + function removeEventListener(eventType: string, listener: (...args: any[]) => any): void; } +export default SafeArea; + +// from `withSafeArea.js` +export type Direction = + | 'top' + | 'bottom' + | 'left' + | 'right' + | 'topLeft' // DEPRECATED + | 'topAndLeft' + | 'topRight' // DEPRECATED + | 'topAndRight' + | 'bottomLeft' // DEPRECATED + | 'bottomAndLeft' + | 'bottomRight' // DEPRECATED + | 'bottomAndRight' + | 'vertical' + | 'horizontal' + | 'verticalAndLeft' + | 'verticalAndRight' + | 'horizontalAndTop' + | 'horizontalAndBottom' + | 'all'; + +export function withSafeArea( + WrappedComponent: React.ComponentType, + applyTo: 'margin' | 'padding' | 'absolutePosition' | 'contentInset' = 'margin', + direction: Direction = 'all', +): React.ComponentType; diff --git a/types/react-native-safe-area/react-native-safe-area-tests.ts b/types/react-native-safe-area/react-native-safe-area-tests.ts index bcdbddc5f3..0dc931d026 100644 --- a/types/react-native-safe-area/react-native-safe-area-tests.ts +++ b/types/react-native-safe-area/react-native-safe-area-tests.ts @@ -1,4 +1,4 @@ -import { View } from 'react-native' +import { View } from 'react-native'; import { withSafeArea } from 'react-native-safe-area'; -const SafeAreaView = withSafeArea(View) +const SafeAreaView = withSafeArea(View);