Skip to content

Commit 176f06a

Browse files
committed
fix(core): [styled] autmatically infer props type
1 parent 1066cf6 commit 176f06a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

core/styled.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ import { type ExpressionType, generateClassName, generateComponentName, insertEx
1616
import { isStyledComponent, isValidElementType, isVueComponent } from '@/helper'
1717

1818
interface IProps {
19-
as?: SupportedHTMLElements
19+
as?: PropType<SupportedHTMLElements>
2020
}
2121

2222
type ComponentCustomProps = PublicProps & {
2323
styled: boolean
2424
}
2525

26-
export type StyledComponentType = DefineSetupFnComponent<IProps, any, SlotsType, any, ComponentCustomProps>
26+
export type StyledComponentType<P = any> = DefineSetupFnComponent<IProps & P, any, SlotsType, IProps & P, ComponentCustomProps>
2727

2828
type StyledFactory = <T = Record<string, any>>(
2929
styles: TemplateStringsArray,
@@ -34,7 +34,7 @@ type StyledComponent = StyledFactory & {
3434
}
3535
type Attrs = Record<string, any>
3636

37-
function baseStyled(target: string | InstanceType<any>, propsDefinition: Record<string, unknown> = {}): StyledComponent {
37+
function baseStyled<P extends Record<string, any>>(target: string | InstanceType<any>, propsDefinition?: P & IProps): StyledComponent {
3838
if (!isValidElementType(target)) {
3939
throw Error('The element is invalid.')
4040
}

0 commit comments

Comments
 (0)