-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.test-d.ts
42 lines (32 loc) · 1.01 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
import {expectType} from 'tsd'
import type {
Heading,
PhrasingContent,
Root,
RootContent,
RowContent,
TableCell,
TableRow,
Text
} from 'mdast'
import {findAfter} from './index.js'
const text: Text = {type: 'text', value: 'alpha'}
const heading: Heading = {type: 'heading', depth: 1, children: [text]}
const root: Root = {type: 'root', children: [heading]}
const cell: TableCell = {type: 'tableCell', children: [text]}
const row: TableRow = {type: 'tableRow', children: [cell]}
// @ts-expect-error: parent needed.
findAfter()
// @ts-expect-error: child or index needed.
findAfter(heading)
findAfter(
// @ts-expect-error: parent needed.
text,
0
)
expectType<PhrasingContent | undefined>(findAfter(heading, text))
expectType<Text | undefined>(findAfter(heading, text, 'text'))
expectType<Text | undefined>(findAfter(heading, 0, 'text'))
expectType<RootContent | undefined>(findAfter(root, 0))
expectType<Text | undefined>(findAfter(root, 0, 'text'))
expectType<RowContent | undefined>(findAfter(row, 0))