Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

531
Views
Why Object.entries not taking correct types from an object type defined with "Record<>"

Why the type of object key is not properly picked by typescript?

const k: Record<'a' | 'b', number> = { a: 5, b: 6 };

Object.entries(k).forEach(([key, value]) => {
  // key: string
  // value: number
});

I was expecting the types to be

key: 'a' | 'b'
value: number

Because we are saying Record<'a' | 'b', number> and not Record<string, number>.

Also how can I fix this in a safe way with out using any?

playground

There is a possible duplicate here. But that question is not following the minimal-reproducible-example - and hence the answers are too. I felt like that thread is taking too much energy to understand because it is not generalized.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!