DEV Community

Discussion on: How to add types for Object.fromEntries

Collapse
 
fordcarta profile image
ford-carta

Hey this is super cool! I have two question if you don't mind.

  1. Do you know how to go from a {key1: 1, key2: 2} as const to [['key1', 1], ['key2', 2]] as const. It seems like this is impossible with Object.entries since the types are lost.
  2. Do you know how we could adapt the solution you gave for arbitrarily nested arrays. For example [['key1', 1], ['key2', ['key2_1',2.1]]] as const