-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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 getters return type error #58483
Comments
bug see typescirpt palay |
Sigh... I really wish the wording of this error message would be changed. This isn't a bug. The excess property check error is not a type error, it's a lint check. You can't rely on it to prevent extra properties from being put on an object because it won't always trigger (which is by design). If that's what you need, see #12936. The other issue you linked to this (#49511) is unrelated - there is nothing like an |
Indirect excess properties are not an error. Examples of indirect excess properties would be:
From the linked FAQ, excess property checks are to defend against things like typos: const p: Dimensions = {
width: 32,
height: 14,
depht: 11 // <-- typo!!
} But there are plenty of situations where you want or need to allow extra properties. |
The focus of this issue is not on whether additional attributes can be added, |
Thank you for your answer, but |
You are conflating two different things. The autocomplete thing is unrelated to the type checking of
No, they shouldn't; it's already been explained several times why const c: T = {
get data() {
return 42;
},
}; then you get a type error. |
Thank you, I understand my mistake |
In that case, this is a retroactive duplicate of #58484 😄 |
the real problem is #58484. I will close this issue |
c.data.b
not throw type error seems to be a mistake ?The text was updated successfully, but these errors were encountered: