Skip to content

Commit d41c08e

Browse files
committed
refactor: descriptive names for react native types
1 parent 7bebdd7 commit d41c08e

File tree

1 file changed

+14
-27
lines changed
  • packages/styled-components-native/src

1 file changed

+14
-27
lines changed
Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,23 @@
11
import { Theme } from '@xstyled/system'
2-
import {
3-
AnyStyledComponent,
4-
StyledComponentInnerAttrs,
5-
StyledComponentInnerComponent,
6-
StyledComponentInnerOtherProps,
7-
ThemedStyledFunction,
8-
} from 'styled-components'
92
import type {
103
ReactNativeStyledInterface,
114
ReactNativeThemedStyledFunction,
125
} from 'styled-components/native'
136

14-
export type NativeElements = ReactNativeStyledInterface<Theme>
7+
export type ReactNativeElements = ReactNativeStyledInterface<Theme>
158

16-
export type NativeElement<T extends NativeElementsKeys> =
17-
NativeElements[T] extends ReactNativeThemedStyledFunction<infer U, any>
18-
? U
19-
: never
9+
export type ReactNativeElementsKeys = keyof ReactNativeElements
2010

21-
export type NativeElementsKeys = keyof NativeElements
22-
23-
export interface ReactNativeThemedBaseStyledInterface<T extends object>
24-
extends ReactNativeStyledInterface<Theme> {
25-
<C extends AnyStyledComponent>(component: C): ThemedStyledFunction<
26-
StyledComponentInnerComponent<C>,
27-
T,
28-
StyledComponentInnerOtherProps<C>,
29-
StyledComponentInnerAttrs<C>
30-
>
31-
<C extends React.ComponentType<any>>(
32-
// unfortunately using a conditional type to validate that it can receive a `theme?: Theme`
33-
// causes tests to fail in TS 3.1
34-
component: C,
35-
): ThemedStyledFunction<C, T>
11+
export type ReactNativeBoxElements = {
12+
[ReactNativeElement in ReactNativeElementsKeys as `${ReactNativeElement}Box`]: ReactNativeElement
3613
}
14+
15+
export type ReactNativeElement<
16+
RNElement extends ReactNativeElementsKeys,
17+
Theme extends object,
18+
> = ReactNativeElements[RNElement] extends ReactNativeThemedStyledFunction<
19+
infer U,
20+
Theme
21+
>
22+
? U
23+
: never

0 commit comments

Comments
 (0)