@@ -260,10 +260,36 @@ function styled(tag: any): any {
260260 } ;
261261}
262262
263+ type FunctionComponentStatic <
264+ TProps ,
265+ TKey extends PropertyKey ,
266+ > = TKey extends keyof React . FunctionComponent < TProps >
267+ ? React . FunctionComponent < TProps > [ TKey ]
268+ : never ;
269+
270+ type StyledComponentWithAs < TProps > = {
271+ < TAs extends keyof IntrinsicElements > (
272+ props : TProps & { as : TAs } & IntrinsicElements [ TAs ] ,
273+ context ?: any
274+ ) : ReturnType < React . FunctionComponent > ;
275+ (
276+ props : TProps & { as ?: React . ElementType } ,
277+ context ?: any
278+ ) : ReturnType < React . FunctionComponent < TProps > > ;
279+ contextTypes ?: FunctionComponentStatic < TProps , 'contextTypes' > ;
280+ defaultProps ?: FunctionComponentStatic <
281+ TProps & { as ?: React . ElementType } ,
282+ 'defaultProps'
283+ > ;
284+ displayName ?: FunctionComponentStatic < TProps , 'displayName' > ;
285+ propTypes ?: FunctionComponentStatic <
286+ TProps & { as ?: React . ElementType } ,
287+ 'propTypes'
288+ > ;
289+ } ;
290+
263291export type StyledComponent < T > = WYWEvalMeta &
264- ( [ T ] extends [ React . FunctionComponent < any > ]
265- ? T
266- : React . FunctionComponent < T & { as ?: React . ElementType } > ) ;
292+ ( [ T ] extends [ React . FunctionComponent < any > ] ? T : StyledComponentWithAs < T > ) ;
267293
268294type StaticPlaceholder = string | number | CSSProperties | WYWEvalMeta ;
269295
0 commit comments