@@ -15,31 +15,34 @@ type ComponentCustomProps = PublicProps & {
1515
1616export type StyledComponentType = DefineSetupFnComponent < IProps , any , SlotsType , any , ComponentCustomProps >
1717
18- type StyledFactory = ( styles : TemplateStringsArray , ...expressions : ( ExpressionType | ExpressionType [ ] ) [ ] ) => StyledComponentType
18+ type StyledFactory = < T = Record < string , any > > (
19+ styles : TemplateStringsArray ,
20+ ...expressions : ( ExpressionType < T > | ExpressionType < T > [ ] ) [ ]
21+ ) => StyledComponentType
1922type StyledComponent = StyledFactory & {
2023 attrs : < T extends Record < string , unknown > > ( attrs : T ) => StyledFactory
2124}
22- type Attrs = Record < string , unknown >
25+ type Attrs = Record < string , any >
2326
2427function baseStyled ( target : string | InstanceType < any > , propsDefinition : Record < string , unknown > = { } ) : StyledComponent {
2528 if ( ! isValidElementType ( target ) ) {
2629 throw Error ( 'The element is invalid.' )
2730 }
2831 let attributes : Attrs = { }
29- const styledComponent : StyledComponent = function styledComponent (
32+ function styledComponent < T > (
3033 styles : TemplateStringsArray ,
31- ...expressions : ( ExpressionType | ExpressionType [ ] ) [ ]
34+ ...expressions : ( ExpressionType < T > | ExpressionType < T > [ ] ) [ ]
3235 ) : StyledComponentType {
33- const cssStringsWithExpression = insertExpressions ( styles , expressions )
34- return createStyledComponent ( cssStringsWithExpression )
36+ const cssStringsWithExpression = insertExpressions < T > ( styles , expressions )
37+ return createStyledComponent < T > ( cssStringsWithExpression )
3538 }
3639
37- styledComponent . attrs = function < T extends Record < string , unknown > > ( attrs : T ) : StyledComponent {
40+ styledComponent . attrs = function < T extends Record < string , any > > ( attrs : T ) : StyledComponent {
3841 attributes = attrs
3942 return styledComponent
4043 }
4144
42- function createStyledComponent ( cssWithExpression : ExpressionType [ ] ) : StyledComponentType {
45+ function createStyledComponent < T > ( cssWithExpression : ExpressionType < T > [ ] ) : StyledComponentType {
4346 let type : string = target
4447 if ( isVueComponent ( target ) ) {
4548 type = 'vue-component'
@@ -70,11 +73,11 @@ function baseStyled(target: string | InstanceType<any>, propsDefinition: Record<
7073 theme,
7174 ...props ,
7275 }
73- injectStyle ( className , cssWithExpression , context )
76+ injectStyle < T > ( className , cssWithExpression , context )
7477 } )
7578
7679 onMounted ( ( ) => {
77- injectStyle ( className , cssWithExpression , context )
80+ injectStyle < T > ( className , cssWithExpression , context )
7881 } )
7982
8083 // Return the render function
0 commit comments