-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
index.test-d.ts
38 lines (32 loc) · 964 Bytes
/
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
import {expectType} from 'tsd';
import Cycled from './index.js';
const cycled = new Cycled([1, 2, 3]);
expectType<Cycled<number>>(cycled);
expectType<number>(cycled.index);
cycled.index = 1;
expectType<number>(cycled.current());
expectType<number>(cycled.next());
expectType<number>(cycled.previous());
expectType<number>(cycled.step(10));
expectType<number>(cycled.peek(10));
expectType<IterableIterator<number>>(cycled.indefinitely());
expectType<IterableIterator<number>>(cycled.indefinitelyReversed());
expectType<number[]>([...cycled]);
class TabComponent {
#activeView: string;
#views: Cycled<string>;
constructor(views: readonly string[]) {
this.#activeView = views[0];
this.#views = new Cycled(views);
}
setActiveView(view: string) {
this.#activeView = view;
this.#views.index = this.#views.indexOf(view);
}
nextView() {
this.setActiveView(this.#views.next());
}
previousView() {
this.setActiveView(this.#views.previous());
}
}