deno.land / x / rambda@v9.1.1 / source / pick-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
43
44
45
46
47
48
49
50
import {pick} from 'rambda'
const input = {a: 'foo', b: 2, c: 3, d: 4}
describe('R.pick with array as props input', () => { it('without passing type', () => { const result = pick(['a', 'c'], input) result.a // $ExpectType string result.c // $ExpectType number })})
describe('R.pick with string as props input', () => { interface Input { a: string, b: number, c: number, d: number, } interface Output { a: string, c: number, } it('explicitly declare output', () => { const result = pick<Output>('a,c', input) result // $ExpectType Output result.a // $ExpectType string result.c // $ExpectType number
const curriedResult = pick<Output>('a,c')(input)
curriedResult.a // $ExpectType string })
it('explicitly declare input and output', () => { const result = pick<Input, Output>('a,c', input) result // $ExpectType Output result.a // $ExpectType string
const curriedResult = pick<Input, Output>('a,c')(input)
curriedResult.a // $ExpectType string })
it('without passing type', () => { const result = pick('a,c', input) result // $ExpectType unknown })})
rambda

Version Info

Tagged at
2 months ago