-
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
Use intersection types in Object.assign defintion #4573
Changes from all commits
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 |
---|---|---|
|
@@ -125,7 +125,34 @@ 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 sources One or more source objects to copy properties from. | ||
* @param source The source object from which to copy properties. | ||
*/ | ||
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 The first source object from which to copy properties. | ||
* @param source2 The second source object from which to copy properties. | ||
*/ | ||
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 The first source object from which to copy properties. | ||
* @param source2 The second source object from which to copy properties. | ||
* @param source3 The third source object from which to copy properties. | ||
*/ | ||
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 | ||
* target object. Returns the target object. | ||
* @param target The target object to copy to. | ||
* @param sources One or more source objects from which to copy properties | ||
*/ | ||
assign(target: any, ...sources: any[]): any; | ||
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. If you make this take 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. @DanielRosenwasser But then the resulting type would follow the pattern T & (U1 | U2 | U3 ... ) which I don't think is what you want. 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. You'd need something like the proposal in #3870. |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts === | ||
async function await(): Promise<void> { | ||
>await : Symbol(await, Decl(asyncFunctionDeclaration11_es6.ts, 0, 0)) | ||
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) | ||
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts === | ||
async function foo(): Promise<void> { | ||
>foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es6.ts, 0, 0)) | ||
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) | ||
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) | ||
|
||
return; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts === | ||
async function foo(): Promise<void> { | ||
>foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es6.ts, 0, 0)) | ||
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) | ||
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) | ||
} |
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.
"own properties" -> "properties on the object itself"
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 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 comment
The 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