-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Use intersection types in Object.assign defintion #4573
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,33 @@ interface Object { | |
} | ||
|
||
interface ObjectConstructor { | ||
/** | ||
* Copy the values of all of the enumerable own properties from one or more source objects to a | ||
* target object. Returns the target object. | ||
* @param target The target object to copy to. | ||
* @param source source objects to copy properties from. | ||
*/ | ||
assign<T, U>(target: T, source: U): T & U; | ||
|
||
/** | ||
* Copy the values of all of the enumerable own properties from one or more source objects to a | ||
* target object. Returns the target object. | ||
* @param target The target object to copy to. | ||
* @param source1 first source objects to copy properties from. | ||
* @param source2 second source objects to copy properties from. | ||
*/ | ||
assign<T, U, V>(target: T, source1: U, source2: V): T & U & V; | ||
|
||
/** | ||
* Copy the values of all of the enumerable own properties from one or more source objects to a | ||
* target object. Returns the target object. | ||
* @param target The target object to copy to. | ||
* @param source1 first source objects to copy properties from. | ||
* @param source2 second source objects to copy properties from. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "source objects" -> "source object" "to copy properties from" -> "from which to copy properties" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "to copy properties from" |
||
* @param source3 second source objects to copy properties from. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. third There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "source objects" -> "source object" "to copy properties from" -> "from which to copy properties" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Er... "to copy properties from" is indeed better I believe. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, agreed, sorry |
||
*/ | ||
assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W; | ||
|
||
/** | ||
* Copy the values of all of the enumerable own properties from one or more source objects to a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "own properties" -> "properties on the object itself" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think own properties has reference to JS hasOwnProeprties and getOwnProeprties.. etc.. so i would say it is more meaningful in this sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Current message is aligned with Object.assign from MDN so I'll keep it as is |
||
* target object. Returns the target object. | ||
|
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.
"source objects" -> "source object"
"to copy properties from" -> "from which to copy properties"
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.
"to copy properties from" is the better syntax.