-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
classic-h.tsx
49 lines (43 loc) · 1.15 KB
/
classic-h.tsx
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
38
39
40
41
42
43
44
45
46
47
48
49
/* @jsx h */
/* @jsxFrag null */
import {expectType} from 'tsd'
import type {Root, Element} from 'hast'
import {h} from '../index.js'
type Result = Element | Root
expectType<Result>(<></>)
expectType<Result>(<a />)
expectType<Result>(<a b="c" />)
expectType<Result>(<a b={'c'} />)
expectType<Result>(<a>string</a>)
expectType<Result>(<a>{['string', 'string']}</a>)
expectType<Result>(
<a>
<></>
</a>
)
expectType<Result>(<a>{h()}</a>)
expectType<Result>(<a>{h('b')}</a>)
expectType<Result>(
<a>
<b />c
</a>
)
expectType<Result>(
<a>
<b />
<c />
</a>
)
expectType<Result>(<a>{[<b />, <c />]}</a>)
expectType<Result>(<a>{[<b />, <c />]}</a>)
expectType<Result>(<a>{[]}</a>)
// @ts-expect-error: not a valid property value.
const a = <a invalid={[true]} />
// @ts-expect-error: This is where the classic runtime differs from the
// automatic runtime.
// The automatic runtime the children prop to define JSX children, whereas
// it’s used as an attribute in the classic runtime.
const b = <a children={<b />} />
declare function Bar(props?: Record<string, unknown>): Element
// @ts-expect-error: components are not supported.
const c = <Bar />