Skip to content

Commit

Permalink
Fix #749 (#954)
Browse files Browse the repository at this point in the history
  • Loading branch information
hadihallak authored Feb 15, 2022
1 parent 560e6a7 commit 9205dfc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/react/types/styled-component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ export interface StyledComponent<

<
C extends CSS,
As extends string | React.ComponentType<any> = Type extends string | React.ComponentType<any> ? Type : never
As extends string | React.ComponentType<any> = Type extends string | React.ComponentType<any> ? Type : any,
InnerProps = Type extends StyledComponent<any, infer IP, any, any> ? IP : {},
>(
props: Util.Assign<
React.ComponentPropsWithRef<As extends IntrinsicElementsKeys | React.ComponentType<any> ? As : never>,
TransformProps<Props, Media> & {
TransformProps<Util.Assign<InnerProps, Props>, Media> & {
as?: As,
css?: {
[K in keyof C]: K extends keyof CSS ? CSS[K] : never
Expand Down
31 changes: 31 additions & 0 deletions packages/test/issue-749-react.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as React from 'react'
import { styled } from './stitches.config'

const Box = styled('div', {
variants: {
size: {
small: {},
},
},
})

const Flex = styled(Box, {
variants: {
variant: {
red: {},
},
},
})

export default function App() {
return (
<>
<Flex as="a" variant="red" size="small" />
<Flex as="a" variant="red" />
<Flex as="a" size="small" />
<Flex variant="red" size="small" />
<Flex variant="red" />
<Flex size="small" />
</>
)
}
2 changes: 1 addition & 1 deletion packages/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"types/*.d.ts"
],
"devDependencies": {
"@stitches/react": "^1.0.0-canary.15",
"@stitches/react": "1.2.6",
"@typescript-eslint/eslint-plugin": "^1.6.0",
"@typescript-eslint/parser": "^1.6.0",
"eslint-config-prettier": "^4.1.0",
Expand Down

0 comments on commit 9205dfc

Please sign in to comment.