Skip to content

Commit

Permalink
Add typing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nolleto committed Jul 17, 2023
1 parent 551c3d3 commit f77444f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions types/test/renameKey.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as RA from 'ramda-adjunct';

/* eslint-disable no-unused-expressions */

// Object with string as key
RA.renameKey('A', 'B', { A: 1, C: 4 }).B; // $ExpectType number
RA.renameKey('A')('B')({ A: 1, C: '123', D: 123 }).B // $ExpectType number
RA.renameKey('A', 'B')({ A: 1, C: 4, D: 123 }); // $ExpectType number

// Object with number as key
RA.renameKey(1, 99, { 1: 'one', 2: 'two', 3: 'three' })[99]; // $ExpectType string

// Object with symbol as key
const symbol = Symbol('hello')

RA.renameKey(symbol, 'B', { [symbol]: 1, B: 2, C: 3 }).B; // $ExpectType number
RA.renameKey('A', symbol, { A: 1, B: 2, C: 3 })[symbol]; // $ExpectType number


// @ts-expect-error
RA.renameKey('Z', 'B', { A: 1, C: 4 })
// @ts-expect-error
RA.renameKey('A', 'B', { C: 4 })
// @ts-expect-error
RA.renameKey({ A: 1, C: 4 }, 'A', 'B')
// @ts-expect-error
RA.renameKey('A', { A: 1, C: 4 }, 'B')

0 comments on commit f77444f

Please sign in to comment.