-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtoad-cache.test-d.ts
31 lines (23 loc) · 1.27 KB
/
toad-cache.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
import {FifoMap, LruMap, FifoObject, LruObject, Fifo, Lru, CacheConstructor, CacheEntry} from './toad-cache'
import type { ToadCache } from './toad-cache'
import { expectAssignable, expectType } from 'tsd'
expectAssignable<ToadCache<number>>(new LruObject<number>())
expectAssignable<ToadCache<number>>(new LruMap<number>())
expectAssignable<ToadCache<number>>(new FifoObject<number>())
expectAssignable<ToadCache<number>>(new FifoMap<number>())
expectAssignable<ToadCache<number>>(new Fifo<number>())
expectAssignable<ToadCache<number>>(new Lru<number>())
expectAssignable<CacheConstructor<LruObject<number>>>(LruObject<number>)
expectAssignable<CacheConstructor<LruMap<number>>>(LruMap<number>)
expectAssignable<CacheConstructor<FifoObject<number>>>(FifoObject<number>)
expectAssignable<CacheConstructor<FifoMap<number>>>(FifoMap<number>)
expectAssignable<CacheConstructor<Fifo<number>>>(Fifo<number>)
expectAssignable<CacheConstructor<Lru<number>>>(Lru<number>)
expectType<number | undefined>(new Fifo<number>().get('a'))
expectType<number | undefined>(new Lru<number>().get('a'))
const lru = new Lru<number>()
const fifo = new Fifo<number>()
lru.set('a', 1)
fifo.set('a', 1)
expectType<Record<any, CacheEntry<number>>> (lru.items)
expectType<Record<any, CacheEntry<number>>> (fifo.items)