99 ThemedBaseStyledInterface ,
1010 ThemedStyledFunction ,
1111} from 'styled-components'
12- import { createCssFunction , XCSSFunction } from './createCssFunction'
12+ import { XCSSFunction } from './createCssFunction'
1313import { ReactNativeStyledInterface } from 'styled-components/native'
1414
1515type BoxStyledTags < TProps extends object > = {
@@ -24,11 +24,10 @@ export interface XStyled<TGen extends StyleGenerator>
2424 extends ThemedBaseStyledInterface < Theme > ,
2525 BoxStyledTags < StyleGeneratorProps < TGen > > { }
2626
27- export type StyledFunctions < XObj > = {
27+ export type StyledFunctions < XStyledInterface > = {
2828 scStyled : StyledInterface | ReactNativeStyledInterface < Theme >
29- styled ?: XObj
30- xstyled ?: XObj
31- x ?: XObj
29+ styled : XStyledInterface
30+ xstyled : XStyledInterface
3231}
3332
3433const createShouldForwardProp = (
@@ -75,11 +74,11 @@ const getCreateStyle = (
7574 return createStyle
7675}
7776
78- export const createBaseStyled = < XObj , TGen extends StyleGenerator > (
77+ export const createBaseStyled = < XStyledInterface , TGen extends StyleGenerator > (
7978 scStyled : StyledInterface | ReactNativeStyledInterface < Theme > ,
8079 css : XCSSFunction ,
8180 generator ?: TGen ,
82- ) : XObj => {
81+ ) : XStyledInterface => {
8382 const config = generator
8483 ? {
8584 shouldForwardProp : createShouldForwardProp ( generator ) ,
@@ -92,30 +91,33 @@ export const createBaseStyled = <XObj, TGen extends StyleGenerator>(
9291 css ,
9392 generator ,
9493 )
95- } ) as unknown as XObj
94+ } ) as unknown as XStyledInterface
9695}
9796
9897export const createStyled = <
99- SCFN extends StyledInterface | ReactNativeStyledInterface < Theme > ,
100- SCCSSFN extends ReturnType < typeof createCssFunction > ,
101- XObj ,
98+ StyledFunction extends StyledInterface | ReactNativeStyledInterface < Theme > ,
99+ XStyledInterface ,
102100 TGen extends StyleGenerator ,
103101> (
104- scStyled : SCFN ,
105- cssFunction : SCCSSFN ,
102+ scStyled : StyledFunction ,
103+ cssFunction : XCSSFunction ,
106104 generator : TGen ,
107- ) : StyledFunctions < XObj > => {
108- const styled = createBaseStyled < XObj , TGen > ( scStyled , cssFunction )
109- const xstyled = createBaseStyled < XObj , TGen > ( scStyled , cssFunction , generator )
105+ ) : StyledFunctions < XStyledInterface > => {
106+ const styled = createBaseStyled < XStyledInterface , TGen > ( scStyled , cssFunction )
107+ const xstyled = createBaseStyled < XStyledInterface , TGen > (
108+ scStyled ,
109+ cssFunction ,
110+ generator ,
111+ )
110112
111113 return { scStyled, styled, xstyled }
112114}
113115
114- export const defineStyledInterface = < XObj > ( {
116+ export const defineStyledInterface = < XStyledInterface > ( {
115117 scStyled,
116118 styled,
117119 xstyled,
118- } : StyledFunctions < XObj > ) : XObj => {
120+ } : StyledFunctions < XStyledInterface > ) : XStyledInterface => {
119121 //@ts -ignore
120122 styled . box = xstyled ( 'div' )
121123
@@ -127,18 +129,18 @@ export const defineStyledInterface = <XObj>({
127129 styled [ `${ tag } Box` ] = xstyled ( tag )
128130 } )
129131
130- return styled as XObj
132+ return styled
131133}
132134
133- export const defineXStyledInterface = < XObj > ( {
135+ export const defineXStyledInterface = < XStyledInterface > ( {
134136 scStyled,
135137 styled,
136138 xstyled,
137- } : StyledFunctions < XObj > ) : XObj => {
139+ } : StyledFunctions < XStyledInterface > ) : XStyledInterface => {
138140 Object . keys ( scStyled ) . forEach ( ( tag ) => {
139141 //@ts -ignore
140142 styled [ tag ] = xstyled ( tag ) ``
141143 } )
142144
143- return styled as XObj
145+ return styled
144146}
0 commit comments