Skip to main content
Module

x/rambda/pickAll-spec.ts

Faster and smaller alternative to Ramda
Go to Latest
File
import {pickAll} from 'rambda'
interface Input { a: string, b: number, c: number, d: number,}interface Output { a?: string, c?: number,}const input = {a: 'foo', b: 2, c: 3, d: 4}
describe('R.pickAll with array as props input', () => { it('without passing type', () => { const result = pickAll(['a', 'c'], input) result // $ExpectType unknown }) it('without passing type + curry', () => { const result = pickAll(['a', 'c'])(input) result // $ExpectType unknown }) it('explicitly passing types', () => { const result = pickAll<Input, Output>(['a', 'c'], input) result.a // $ExpectType string | undefined result.c // $ExpectType number | undefined }) it('explicitly passing types + curry', () => { const result = pickAll<Input, Output>(['a', 'c'])(input) result.a // $ExpectType string | undefined result.c // $ExpectType number | undefined })})
describe('R.pickAll with string as props input', () => { it('without passing type', () => { const result = pickAll('a,c', input) result // $ExpectType unknown }) it('without passing type + curry', () => { const result = pickAll('a,c')(input) result // $ExpectType unknown }) it('explicitly passing types', () => { const result = pickAll<Input, Output>('a,c', input) result.a // $ExpectType string | undefined result.c // $ExpectType number | undefined }) it('explicitly passing types + curry', () => { const result = pickAll<Input, Output>('a,c')(input) result.a // $ExpectType string | undefined result.c // $ExpectType number | undefined })})