question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`prefer-object-from-entries` triggering where I can't use `Object.fromEntries`

See original GitHub issue

Code:

/** @type {{ [key: string]: import("../../types").Page }} */
const clientsByPage = authClients.reduce(
	(accumulated, client) => ({ ...accumulated, ...client.pages }),
	{},
);

Produces:

Prefer `Object.fromEntries()` over `Array#reduce()`  unicorn/prefer-object-from-entries

I don’t think I can use Object.fromEntries here, so unless I’m mistaken, this is a bug.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
fiskercommented, Aug 15, 2021
Object.assign(
  {},
  ...authClients.map(({pages}) => pages),
)
1reaction
fiskercommented, Aug 15, 2021
Object.fromEntries(
  authClients.flatMap(({pages}) => Object.entries(pages))
)
Read more comments on GitHub >

github_iconTop Results From Across the Web

eslint-plugin-unicorn/prefer-object-from-entries.md at main
Prefer using Object.fromEntries(…) to transform a list of key-value pairs into an object. This rule is enabled in the ✓ recommended config.
Read more >
Object.fromEntries() - JavaScript - MDN Web Docs
The method returns an iterator object that produces two-element array-like objects. The first element is a value that will be used as a...
Read more >
Object.fromEntries is not a function error when using chakra-ui ...
I had to update my node version, which was at v10.17.0. I updated it to v14.17.0!
Read more >
const fssync = object.fromentries(object.entries(fs).filter(([k, v]) =>
The method returns an iterator object that produces two-element array-like objects. The first element is a value that will be used as a...
Read more >
JavaScript Object.fromEntries() | SamanthaMing.com
Object.fromEntries is the inverse of Object.entries. It will take key-value pairs and return a new object. You can use it on Arrays and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found