-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.test-d.ts
55 lines (42 loc) · 1.06 KB
/
index.test-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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import {expectError, expectType} from 'tsd'
import type {Parent, Literal} from 'unist'
import {visitChildren} from 'unist-util-visit-children'
/* eslint-disable @typescript-eslint/consistent-type-definitions */
interface Root extends Parent {
type: 'root'
children: Flow[]
}
type Flow = Blockquote | Heading | Paragraph
interface Blockquote extends Parent {
type: 'blockquote'
children: Flow[]
}
interface Heading extends Parent {
type: 'heading'
depth: number
children: Phrasing[]
}
interface Paragraph extends Parent {
type: 'paragraph'
children: Phrasing[]
}
type Phrasing = Text | Emphasis
interface Emphasis extends Parent {
type: 'emphasis'
children: Phrasing[]
}
interface Text extends Literal {
type: 'text'
value: string
}
/* Missing params. */
expectError(visitChildren())
visitChildren(function (node, _, parent: Emphasis) {
expectType<Phrasing>(node)
return undefined
})
visitChildren(function (node, _, parent: Root) {
expectType<Flow>(node)
return undefined
})
/* eslint-enable @typescript-eslint/consistent-type-definitions */