better-typescript-lib icon indicating copy to clipboard operation
better-typescript-lib copied to clipboard

`Object.entries` broken with object literals

Open danielrentz opened this issue 10 months ago • 6 comments
trafficstars

The value type of object literals becomes unknown.

  • before (built-in TS lib):
const entries1 = Object.entries({ a: 1, b: 2 });           // => [string, number][]
const entries2 = Object.entries({ a: 1, b: 2 } as const);  // => [string, 1|2][]
  • after (with better-ts-lib):
const entries1 = Object.entries({ a: 1, b: 2 });           // => [string, unknown][]
const entries2 = Object.entries({ a: 1, b: 2 } as const);  // => [string, unknown][]

danielrentz avatar Jan 09 '25 11:01 danielrentz