/
stailwc.d.ts
37 lines (29 loc) 路 820 Bytes
/
stailwc.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import type { CSSInterpolation } from '@emotion/serialize'
export type TemplateFn<R> = (
strings: Readonly<TemplateStringsArray>,
...values: readonly string[]
) => R
export type TwFn = TemplateFn<CSSInterpolation>
export type TwComponentMap = {
[K in keyof JSX.IntrinsicElements]: TemplateFn<TwComponent<K>>
}
export type TwComponent<K extends keyof JSX.IntrinsicElements> = (
props: JSX.IntrinsicElements[K]
) => JSX.Element
type TwComponentWrapper = <T extends ComponentType<any>>(
component: T
) => TemplateFn<T>
declare module 'react' {
interface DOMAttributes<T> {
tw?: string
css?: CSSInterpolation
}
}
declare global {
const tw: TwFn & TwComponentMap & TwComponentWrapper
namespace JSX {
interface IntrinsicAttributes extends React.Attributes {
tw?: string
}
}
}