Skip to content

Commit

Permalink
Merge branch 'feature/typescript-component-wrapping' into release/1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-rogerson committed Jul 21, 2020
2 parents 8c51892 + a87b2b2 commit 545214a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
10 changes: 7 additions & 3 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable-next-line import/no-unassigned-import */
import 'react'
import { ComponentType } from 'react'

export interface TwStyle {
[key: string]: string | number | TwStyle
Expand Down Expand Up @@ -32,7 +31,12 @@ export type TwComponentMap = {
[K in keyof JSX.IntrinsicElements]: TemplateFn<TwComponent<K>>
}

declare const tw: TwFn & TwComponentMap
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
type TwComponentWrapper = <T extends ComponentType<any>>(
component: T
) => TemplateFn<T>

declare const tw: TwFn & TwComponentMap & TwComponentWrapper
export default tw

declare module 'react' {
Expand Down
3 changes: 2 additions & 1 deletion types/tests/emotion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const Container = styled.div`
`

export const Link = tw.a``
export const ComposedLink = styled(Link)``
export const ComposedLink = tw(Link)``
export const ComposedLink2 = styled(Link)``

export const cssProperty = <div css={tw`bg-red-100`} />
3 changes: 2 additions & 1 deletion types/tests/styled-components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const Container = styled.div`
`

export const Link = tw.a``
export const ComposedLink = styled(Link)``
export const ComposedLink = tw(Link)``
export const ComposedLink2 = styled(Link)``

export const cssProperty = <div css={tw`bg-red-100`} />

0 comments on commit 545214a

Please sign in to comment.