-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test-d.ts
81 lines (64 loc) · 3.27 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { expectError, expectType } from 'tsd'
import { conjoin, conjoiner } from '.'
const numbers = [1, 2, 3, 4]
const strings = ['foo', 'bar', 'baz', 'quux']
const numberFn = (it: number, _index: number) => it ** 2
const stringFn = (it: string, _index: number) => it.toUpperCase()
const numberJoin1 = conjoiner({ map: numberFn })
const numberJoin2 = conjoiner({ $map: numberFn })
const stringJoin1 = conjoiner({ map: stringFn })
const stringJoin2 = conjoiner({ $map: stringFn })
// pass
expectType<string>(numberJoin1(numbers))
expectType<string>(numberJoin2(numbers))
expectType<string>(stringJoin1(strings))
expectType<string>(stringJoin2(strings))
expectType<string>(numberJoin1(strings, { map: stringFn }))
expectType<string>(numberJoin1(strings, { $map: stringFn }))
expectType<string>(numberJoin2(strings, { $map: stringFn }))
expectType<string>(stringJoin1(numbers, { map: numberFn }))
expectType<string>(stringJoin1(numbers, { $map: numberFn }))
expectType<string>(stringJoin2(numbers, { $map: numberFn }))
expectType<string>(numberJoin1(strings, { map: stringFn }))
expectType<string>(numberJoin1(strings, { $map: stringFn }))
expectType<string>(numberJoin2(strings, { $map: stringFn }))
expectType<string>(stringJoin1(numbers, { map: numberFn }))
expectType<string>(stringJoin1(numbers, { $map: numberFn }))
expectType<string>(stringJoin2(numbers, { $map: numberFn }))
// fail
/*
* XXX these errors throw off tsc and cause the last two tests in this file to
* appear valid (in $EDITOR), though the tsd tests pass/fail as expected
*/
expectError(conjoiner({ $map: numberFn, map: numberFn }))
expectError(conjoiner({ $map: numberFn, map: stringFn }))
expectError(conjoiner({ $map: stringFn, map: numberFn }))
expectError(conjoiner({ $map: stringFn, map: stringFn }))
expectError(numberJoin1(strings))
expectError(numberJoin1(strings, { map: numberFn }))
expectError(numberJoin1(numbers, { map: stringFn }))
expectError(numberJoin1(numbers, { $map: stringFn }))
expectError(numberJoin1(strings, { $map: numberFn }))
expectError(numberJoin1(numbers, { $map: numberFn, map: numberFn }))
expectError(numberJoin1(numbers, { $map: stringFn, map: stringFn }))
expectError(numberJoin2(strings))
expectError(numberJoin2(strings, { map: numberFn }))
expectError(numberJoin2(numbers, { map: stringFn }))
expectError(numberJoin2(numbers, { $map: stringFn }))
expectError(numberJoin2(strings, { $map: numberFn }))
expectError(numberJoin2(numbers, { $map: numberFn, map: numberFn }))
expectError(numberJoin2(numbers, { $map: stringFn, map: stringFn }))
expectError(stringJoin1(numbers))
expectError(stringJoin1(numbers, { map: stringFn }))
expectError(stringJoin1(strings, { map: numberFn }))
expectError(stringJoin1(strings, { $map: numberFn }))
expectError(stringJoin1(numbers, { $map: stringFn }))
expectError(stringJoin1(strings, { $map: stringFn, map: stringFn }))
expectError(stringJoin1(strings, { $map: numberFn, map: numberFn }))
expectError(stringJoin2(numbers))
expectError(stringJoin2(numbers, { map: stringFn }))
expectError(stringJoin2(strings, { map: numberFn }))
expectError(stringJoin2(strings, { $map: numberFn }))
expectError(stringJoin2(numbers, { $map: stringFn }))
expectError(stringJoin2(strings, { $map: stringFn, map: stringFn }))
expectError(stringJoin2(strings, { $map: numberFn, map: numberFn }))