Skip to main content
Module

x/rambda/source/omit-spec.ts

Faster and smaller alternative to Ramda
Go to Latest
File
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 })})