Skip to content

Commit 86f4a0d

Browse files
fix: more primitive expectations
1 parent cb6a26a commit 86f4a0d

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

packages/js-lib/src/types.test.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,28 @@ describe('_objectKeys', () => {
221221
})
222222

223223
describe('_objectEntries', () => {
224-
test('should have return type that is an array of [{union of the keys}, ValueOf<typeof o>] for const object with string keys', () => {
224+
test('should have return type that is an array of [{union of the keys}, {union of the values}] for const object with string keys', () => {
225225
const o = { b: 2, c: 3, d: 4 } as const
226226
const entries = _objectEntries(o)
227-
expectTypeOf(entries).toEqualTypeOf<[k: 'b' | 'c' | 'd', v: ValueOf<typeof o>][]>()
227+
expectTypeOf(entries).toEqualTypeOf<[k: 'b' | 'c' | 'd', v: 2 | 3 | 4][]>()
228228
})
229229

230-
test('should have return type that is an array of [{union of the stringified keys}, ValueOf<typeof o>] for const object with number keys', () => {
230+
test('should have return type that is an array of [{union of the stringified keys}, {union of the values}] for const object with number keys', () => {
231231
const o = { 1: 'b', 2: 'c', 3: 'd' } as const
232232
const entries = _objectEntries(o)
233-
expectTypeOf(entries).toEqualTypeOf<['1' | '2' | '3', ValueOf<typeof o>][]>()
233+
expectTypeOf(entries).toEqualTypeOf<[k: '1' | '2' | '3', v: 'b' | 'c' | 'd'][]>()
234+
})
235+
236+
test('should have return type narrower than [string, {union of the values}][] for const object with string keys', () => {
237+
const o = { b: 2, c: 3, d: 4 } as const
238+
const entries = _objectEntries(o)
239+
expectTypeOf(entries).not.toEqualTypeOf<[string, 2 | 3 | 4][]>()
240+
})
241+
242+
test('should have return type narrower than [string, {union of the values}][] for const object with number keys', () => {
243+
const o = { 1: 'b', 2: 'c', 3: 'd' } as const
244+
const entries = _objectEntries(o)
245+
expectTypeOf(entries).not.toEqualTypeOf<[string, 'b' | 'c' | 'd'][]>()
234246
})
235247
})
236248

0 commit comments

Comments
 (0)