// eslint-disable-next-line @definitelytyped/no-single-declare-module declare module "styled-components/native" { import * as ReactNative from "react-native"; import * as React from "react"; export { css, DefaultTheme, isStyledComponent, ThemeConsumer, ThemeContext, ThemeProps, ThemeProvider, useTheme, withTheme, } from "styled-components"; import { AnyStyledComponent, DefaultTheme, isStyledComponent, StyledComponentInnerAttrs, StyledComponentInnerComponent, StyledComponentInnerOtherProps, ThemedCssFunction, ThemedStyledFunction, ThemedStyledInterface, ThemeProviderComponent, WithThemeFnInterface, } from "styled-components"; type AnyIfEmpty = keyof T extends never ? any : T; export type ReactNativeThemedStyledFunction< C extends React.ComponentType, T extends object, > = ThemedStyledFunction; // Copied over from "ThemedBaseStyledInterface" in index.d.ts in order to remove DOM element typings interface ReactNativeThemedBaseStyledInterface { (component: C): ThemedStyledFunction< StyledComponentInnerComponent, T, StyledComponentInnerOtherProps, StyledComponentInnerAttrs >; >( // unfortunately using a conditional type to validate that it can receive a `theme?: Theme` // causes tests to fail in TS 3.1 component: C, ): ThemedStyledFunction; } type ReactNativeThemedStyledInterface = ReactNativeThemedBaseStyledInterface>; export interface ReactNativeStyledInterface extends ReactNativeThemedStyledInterface { ActivityIndicator: ReactNativeThemedStyledFunction; ActivityIndicatorIOS: ReactNativeThemedStyledFunction; Button: ReactNativeThemedStyledFunction; DatePickerIOS: ReactNativeThemedStyledFunction; DrawerLayoutAndroid: ReactNativeThemedStyledFunction; Image: ReactNativeThemedStyledFunction; ImageBackground: ReactNativeThemedStyledFunction; KeyboardAvoidingView: ReactNativeThemedStyledFunction; ListView: ReactNativeThemedStyledFunction; Modal: ReactNativeThemedStyledFunction; NavigatorIOS: ReactNativeThemedStyledFunction; Pressable: ReactNativeThemedStyledFunction; ProgressBarAndroid: ReactNativeThemedStyledFunction; ProgressViewIOS: ReactNativeThemedStyledFunction; ScrollView: ReactNativeThemedStyledFunction; Slider: ReactNativeThemedStyledFunction; SliderIOS: ReactNativeThemedStyledFunction; SnapshotViewIOS: ReactNativeThemedStyledFunction; Switch: ReactNativeThemedStyledFunction; RecyclerViewBackedScrollView: ReactNativeThemedStyledFunction< typeof ReactNative.RecyclerViewBackedScrollView, T >; RefreshControl: ReactNativeThemedStyledFunction; SafeAreaView: ReactNativeThemedStyledFunction; StatusBar: ReactNativeThemedStyledFunction; SwipeableListView: ReactNativeThemedStyledFunction; SwitchAndroid: ReactNativeThemedStyledFunction; SwitchIOS: ReactNativeThemedStyledFunction; TabBarIOS: ReactNativeThemedStyledFunction; Text: ReactNativeThemedStyledFunction; TextInput: ReactNativeThemedStyledFunction; TouchableHighlight: ReactNativeThemedStyledFunction; TouchableNativeFeedback: ReactNativeThemedStyledFunction; TouchableOpacity: ReactNativeThemedStyledFunction; TouchableWithoutFeedback: ReactNativeThemedStyledFunction; View: ReactNativeThemedStyledFunction; ViewPagerAndroid: ReactNativeThemedStyledFunction; FlatList: ReactNativeThemedStyledFunction; SectionList: ReactNativeThemedStyledFunction; } export interface ReactNativeThemedStyledComponentsModule { default: ReactNativeStyledInterface; css: ThemedCssFunction; withTheme: WithThemeFnInterface; ThemeProvider: ThemeProviderComponent; ThemeConsumer: React.Consumer; ThemeContext: React.Context; useTheme(): T; // This could be made to assert `target is StyledComponent` instead, but that feels not type safe isStyledComponent: typeof isStyledComponent; } const styled: ReactNativeStyledInterface; export default styled; }