-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Accept generics for defineProperty #42424
Conversation
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
Both `Object.defineProperty()` and `Object.defineProperties()` return their first argument. Use a generic so that typings can be passed through.
Updated baselines. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm cautiously optimistic that this won't break anything, since there wasn't much churn in the test baselines. However, I'd like a second opinion. @orta do you think this is a good idea?
Arguably, for maximum correctness, it should be what I posted in #41424 (comment), but that might have compatibility issues and be overkill. See also: |
Wow, that's really cool! Regrettably, I'm not as well-versed in TypeScript annotations but I know just enough to be able to appreciate that one. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this generally seems reasonable to me ( hah, Exe-boss that version is wild)
I feel like it's a little strange because the object you pass it would always be modified by going through the function so in theory the T
wouldn't necessarily match in the return
position. But I think this is what you'd pragmatically expect from the function that the shape of the thing going in is the shape of the thing going out.
Both
Object.defineProperty()
andObject.defineProperties()
return theirfirst argument. Use a generic so that typings can be passed through.