deno.land / x / rambda@v9.1.1 / source / omit-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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import {omit} from 'rambda'
describe('R.omit with array as props input', () => { it('allow Typescript to infer object type', () => { const input = {a: 'foo', b: 2, c: 3, d: 4} const result = omit(['b,c'], input)
result.a // $ExpectType string result.d // $ExpectType number
const curriedResult = omit(['a,c'], input)
curriedResult.a // $ExpectType string curriedResult.d // $ExpectType number })
it('declare type of input object', () => { interface Input { a: string, b: number, c: number, d: number, } const input: Input = {a: 'foo', b: 2, c: 3, d: 4} const result = omit(['b,c'], input) result // $ExpectType Omit<Input, "b,c">
result.a // $ExpectType string result.d // $ExpectType number
const curriedResult = omit(['a,c'], input)
curriedResult.a // $ExpectType string curriedResult.d // $ExpectType number })})
describe('R.omit with string as props input', () => { interface Output { b: number, d: number, }
it('explicitly declare output', () => { const result = omit<Output>('a,c', {a: 1, b: 2, c: 3, d: 4}) result // $ExpectType Output result.b // $ExpectType number
const curriedResult = omit<Output>('a,c')({a: 1, b: 2, c: 3, d: 4})
curriedResult.b // $ExpectType number })
it('explicitly declare input and output', () => { interface Input { a: number, b: number, c: number, d: number, } const result = omit<Input, Output>('a,c', {a: 1, b: 2, c: 3, d: 4}) result // $ExpectType Output result.b // $ExpectType number
const curriedResult = omit<Input, Output>('a,c')({ a: 1, b: 2, c: 3, d: 4, })
curriedResult.b // $ExpectType number })
it('without passing type', () => { const result = omit('a,c', {a: 1, b: 2, c: 3, d: 4}) result // $ExpectType unknown })})
rambda

Version Info

Tagged at
2 months ago