Skip to content

Commit

Permalink
Add type definitions for deep-extend module
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Feb 12, 2016
1 parent bcd5761 commit 0df3cf8
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
36 changes: 36 additions & 0 deletions deep-extend/deep-extend-tests.ts
@@ -0,0 +1,36 @@
/// <reference path="deep-extend.d.ts" />

import deepExtend = require('deep-extend');
var obj1 = {
a: 1,
b: 2,
d: {
a: 1,
b: [true],
c: { test1: 123, test2: 321 }
},
f: 5,
g: 123,
i: 321,
j: [1, 2]
};
var obj2 = {
b: 3,
c: 5,
d: {
b: { first: 'one', second: 'two' },
c: { test2: 222 }
},
e: { one: 1, two: 2 },
f: [42],
g: function(){},
h: /abc/g,
i: null as {aaa: boolean},
j: [3, 4]
};

deepExtend(obj1, obj2);
deepExtend(obj1, obj2, {ccc: 3});
deepExtend(obj1, obj2, {ccc: 3}, {ddd: 4});


15 changes: 15 additions & 0 deletions deep-extend/deep-extend.d.ts
@@ -0,0 +1,15 @@
// Type definitions for open 0.4.1
// Project: https://github.com/unclechu/node-deep-extend
// Definitions by: rhysd <https://github.com/rhysd>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

declare module 'deep-extend' {
/*
* Recursive object extending.
*/
function deepExtend<T, U>(target: T, source: U): T & U;
function deepExtend<T, U, V>(target: T, source1: U, source2: V): T & U & V;
function deepExtend<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
function deepExtend(target: any, ...sources: any[]): any;
export = deepExtend;
}

0 comments on commit 0df3cf8

Please sign in to comment.