-
Notifications
You must be signed in to change notification settings - Fork 86
/
mapObjIndexed-spec.ts
42 lines (40 loc) · 1.24 KB
/
mapObjIndexed-spec.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 {mapObjIndexed} from 'rambda'
const obj = {a: 1, b: 2, c: 3}
describe('R.mapObjIndexed', () => {
it('without type transform', () => {
const result = mapObjIndexed((x, prop, obj) => {
x // $ExpectType number
prop // $ExpectType string
obj // $ExpectType Dictionary<number>
return x + 2
}, obj)
result // $ExpectType Dictionary<number>
})
it('without type transform - curried', () => {
const result = mapObjIndexed<number>((x, prop, obj) => {
x // $ExpectType number
prop // $ExpectType string
obj // $ExpectType Dictionary<number>
return x + 2
})(obj)
result // $ExpectType Dictionary<number>
})
it('change of type', () => {
const result = mapObjIndexed((x, prop, obj) => {
x // $ExpectType number
prop // $ExpectType string
obj // $ExpectType Dictionary<number>
return String(x + 2)
}, obj)
result // $ExpectType Dictionary<string>
})
it('change of type - curried', () => {
const result = mapObjIndexed<number, string>((x, prop, obj) => {
x // $ExpectType number
prop // $ExpectType string
obj // $ExpectType Dictionary<number>
return String(x + 2)
})(obj)
result // $ExpectType Dictionary<string>
})
})