-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 behaves differently for interfaces and types #49872
Comments
Interfaces are subject to declaration merging, whereas type aliases are not. See also #38520. |
You mean |
@MartinJohns yeah, but the basic logic that applies for both is equally (un)sound. Tbh., I'd be fine with either behaviour (although personally I prefer the "unsound, but usable" behaviour over |
The issue is still because interfaces don't have implicit string index signatures, causing it to fail to match the |
Ah, that's at least a puzzle piece that explains it. |
This issue has been marked as 'Not a Defect' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Bug Report
When using types,
Object.entries
returns a union of possible values asvalue
, while a similar interface, it returnsany
🔎 Search Terms
Object.entries union any
🕗 Version & Regression Information
This seems to go back at least until TS 4, I didn't test further.
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Object.entries behaves differently for types and interfaces
🙂 Expected behavior
Object.entries behaves the same for types and interfaces.
I am aware that the general argument is "interfaces could be extended" - but pretty much the same goes for a type here as well, right?
Is this an oversight or intended behaviour?
The text was updated successfully, but these errors were encountered: