add deep-assign (#12353)

* add deep-assign

Add type definitions for https://github.com/sindresorhus/deep-assign

* fix(tsconfig): Set strictNullChecks to true
This commit is contained in:
Ionut Costica 2016-11-02 16:04:21 +02:00 committed by Masahiro Wakame
parent 513dc337f9
commit e1b8d6829c
3 changed files with 106 additions and 0 deletions

View File

@ -0,0 +1,10 @@
import * as deepAssign from 'deep-assign';
deepAssign({a: 1});
deepAssign({a: 1}, {b: 2});
deepAssign({a: 1, b: {c: 2}}, {b: {e: 33}, x: 11});
deepAssign({}, {a: 1}, {b: 2}, {c: 3});
deepAssign({}, {a: 1}, {b: 2}, {c: 3}, {d: 4});
deepAssign({}, {a: 1}, {b: 2}, {c: 3}, {d: 4}, {e: 5});
deepAssign({}, {a: 1}, {b: 2}, {c: 3}, {d: 4}, {e: 5}, {f: 6});
deepAssign({}, {a: 1}, {b: 2}, {c: 3}, {d: 4}, {e: 5}, {f: 6}, {g: 7});

77
deep-assign/index.d.ts vendored Normal file
View File

@ -0,0 +1,77 @@
// Type definitions for clone 0.1.11
// Project: https://github.com/sindresorhus/deep-assign
// Definitions by: Ionut Costica <https://github.com/souldreamer>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Pretty much just returns the target object
* @param target Base object
*/
declare function deepAssign<T>(target: T): T;
/**
* Deeply assigns all the properties of the source object to the
* target object
* @param target Base object
* @param source Extending object
*/
declare function deepAssign<T, U>(target: T, source: U): T & U;
/**
* Deeply assigns all the properties of the source objects to the
* target object
* @param target Base object
* @param source1 First extending object
* @param source2 Second extending object
*/
declare function deepAssign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
/**
* Deeply assigns all the properties of the source objects to the
* target object
* @param target Base object
* @param source1 First extending object
* @param source2 Second extending object
* @param source3 Third extending object
*/
declare function deepAssign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
/**
* Deeply assigns all the properties of the source objects to the
* target object
* @param target Base object
* @param source1 First extending object
* @param source2 Second extending object
* @param source3 Third extending object
* @param source4 Fourth extending object
*/
declare function deepAssign<T, U, V, W, X>(target: T, source1: U, source2: V, source3: W, source4: X): T & U & V & W & X;
/**
* Deeply assigns all the properties of the source objects to the
* target object
* @param target Base object
* @param source1 First extending object
* @param source2 Second extending object
* @param source3 Third extending object
* @param source4 Fourth extending object
* @param source5 Fifth extending object
*/
declare function deepAssign<T, U, V, W, X, Y>(target: T, source1: U, source2: V, source3: W, source4: X, source5: Y): T & U & V & W & X & Y;
/**
* Deeply assigns all the properties of the source objects to the
* target object
* @param target Base object
* @param source1 First extending object
* @param source2 Second extending object
* @param source3 Third extending object
* @param source4 Fourth extending object
* @param source5 Fifth extending object
* @param source6 Sixth extending object
*/
declare function deepAssign<T, U, V, W, X, Y, Z>(target: T, source1: U, source2: V, source3: W, source4: X, source5: Y, source6: Z): T & U & V & W & X & Y & Z;
/**
* Deeply assigns all the properties of the source objects to the
* target object
* @param target Base object
* @param sources Extending objects
*/
declare function deepAssign(target: any, ...sources: any[]): any;
declare namespace deepAssign {}
export = deepAssign;

19
deep-assign/tsconfig.json Normal file
View File

@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"deep-assign-tests.ts"
]
}