Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object.entries(Record<K, string>) should get [string, string] but get [string, unknow] #45064

Closed
bluelovers opened this issue Jul 16, 2021 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@bluelovers
Copy link
Contributor

Bug Report

🔎 Search Terms

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions ______ and _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

https://www.typescriptlang.org/play?ssl=12&ssc=2&pln=1&pc=1#code/CYUwxgNghgTiAEAzArgOzAFwJYHtX1RxgFsoIsAvEACgAcAueAZwxi1QHMBKRltzgLAAoYSAAetIhiRpMufAAsoqYBBAAFKGADWUDiABC7JgB4A0vHEYQKps1bsOAPmoAjY4wBK4IsHMAae35nLmEAb2EASDgMZBh8AHlXACtwDAA6GwcQJjdjUKFIyPS4YGQwGmooQIBtbUD3VABdLngAXicoyIjCosISMkoaRoL4MfGJsag6pvb4Rq7okFj4+CgugF9AsI21u28wXwCgxycCjaA

💻 Code

entries<T>(o: { [s: string]: T } | ArrayLike<T>): [string, T][];
declare function normalize(p: string): string

export function handlePackageBins<K extends string>(bins: Record<K, string>)
{
	return Object.entries(bins)
		.reduce((a, [k, bin]) =>
		{
			normalize(bin)
            a[k] = bin
			return a
		}, {} as Record<K, string>)
}

🙁 Actual behavior

image

🙂 Expected behavior

string

@MartinJohns
Copy link
Contributor

MartinJohns commented Jul 16, 2021

See #43266. This is intentional and correct. Object types are not sealed.

bluelovers added a commit to bluelovers/ws-yarn-workspaces that referenced this issue Jul 16, 2021
@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jul 16, 2021
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants