-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test-d.ts
30 lines (26 loc) · 1.35 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
import { expectError, expectType } from 'tsd'
import { enumerate, enumerator } from '.'
expectError(enumerate())
expectError(enumerate(42))
expectError(enumerate('foo'))
expectError(enumerate('foo', 42))
expectError(enumerate({}))
expectError(enumerate({}, 42))
expectError(enumerate(['foo'], []))
expectError(enumerate([['foo']], []))
expectError(enumerator())
expectError(enumerator(42))
expectError(enumerator('foo'))
expectError(enumerator('foo', 42))
expectError(enumerator({}))
expectError(enumerator({}, 42))
expectError(enumerator(['foo'], []))
expectError(enumerator([['foo']], []))
expectType<Generator<(string | number | true)[], void, unknown>>(enumerator([1, 'foo', true], 3))
expectType<Generator<(string | number | boolean)[], void, unknown>>(enumerator([1, 'foo', true, false], 3))
expectType<Generator<(string | number | boolean)[], void, unknown>>(enumerator([[true], [1, 2], ['foo', 'bar']]))
expectType<Generator<(string | number | boolean)[], void, unknown>>(enumerator([[true, false], [1, 2], ['foo', 'bar']]))
expectType<(string | number | true)[][]>(enumerate([1, 'foo', true], 3))
expectType<(string | number | boolean)[][]>(enumerate([1, 'foo', true, false], 3))
expectType<(string | number | boolean)[][]>(enumerate([[true], [1, 2], ['foo', 'bar']]))
expectType<(string | number | boolean)[][]>(enumerate([[true, false], [1, 2], ['foo', 'bar']]))