-
Notifications
You must be signed in to change notification settings - Fork 13
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
Type definitions #19
Comments
@DimaGashko If you have some type definitions that would work, you can just add them to DefinitelyTyped yourself. However, the best would be a new minor version here that adds the types directly into this package. DefinitelyTyped is intended to fill the gap that where package maintainers don't add the types to their own packages. |
@cinderblock type definitions that would work are something like type definitions for native Object.assign 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 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: object, ...sources: any[]): any; Unfortunately I don't have enough time to add it to type definitions |
@DimaGashko I was thinking about this a bit today. It looks like TypeScript's Intersection Types ( I wonder if this would be a better generic type: assign<T extends {}>(...args: RecursivePartial<T>}: T; |
last suggestion didn't work with latest TypeScript 4.5 but looking at other DefinitelyType declarations like this one object.assign, we can come up with pretty much the same and provides better typing I think (I had to remove the prefix of declare module 'assign-deep' {
function assign<T, U>(target: T, source: U[]): T & U;
function assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
function assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
function assign<T, U, V, W, Q>(target: T, source1: U, source2: V, source3: W, source4: Q): T & U & V & W & Q;
function assign<T, U, V, W, Q, R>(target: T, source1: U, source2: V, source3: W, source4: Q, source5: R): T & U & V & W & Q & R;
function assign(target: any, ...sources: any[]): any;
namespace assign { }
export = assign;
} |
I've just decided to use this cool lib. I found some similar libs and I think this one is better but there's one small point - type definitions.
Can you add jsDoc comment to the function, or add this lib to https://definitelytyped.org/?
If you do that, your lib will be the best.
The text was updated successfully, but these errors were encountered: