Skip to content

Conversation

uhyo
Copy link
Owner

@uhyo uhyo commented Jul 7, 2024

closes #40

This fix tightens up Object.values and Object.entries types so that:

  • Object.values({}) returns unknown[] (previously never[])
  • Object.values({ foo: 123 }) returns unknown[] (previously number[])

To get non-unknown[] results you need to pass a value of type Record<string, T>.

const obj: Record<string, number> = { foo: 123 };

Object.values(obj) // number[]

This isn't still perfect but less unsafe than before.

@uhyo uhyo self-assigned this Jul 7, 2024
@uhyo uhyo merged commit 4348e7b into master Jul 15, 2024
@uhyo uhyo deleted the fix/40 branch July 15, 2024 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue when using object with Object.entries and Object.values
1 participant