-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Excess properties in object literals are allowed #13444
Comments
There are many legitimate reasons for allowing "extra" attributes on already existing objects, it would be very annoying if you needed to extract specific attributes in order to pass them around to methods accepting a narrower definition. However, there are few legitimate reasons for adding extra arguments in an object literal. A somewhat contrived example:
|
Agreed. But there's also legitimate use cases when you want to be stricter about what a function should receive. I should know; I've just encountered this scenario 😄 I was under the misapprehension that the stricter object literal assignment checks that arrived with TypeScript 1.6 extended to the scenarios outlined above. They don't. I'm just trying to understand if that's intentional and if there's any plans to cater for this in future. (I'm imagining if there was it would be behind a compiler flag.) |
Thanks @RyanCavanaugh - will close as dupe. Hope #12936 happens! |
TypeScript Version: 2.1.1 / nightly (2.2.0-dev.201xxxxx)
Code
Expected behavior:
I would have expected the compiler to complain in cases 2 and 3 above as they do in case 1. This might be the same as #7547 but the issue does not appear to be identical and so I wanted to double check.
suppressExcessPropertyErrors
isfalse
Actual behavior:
Cases 2 and 3 are not treated as errors.
The text was updated successfully, but these errors were encountered: