diff --git a/object-assign/object-assign-tests.ts b/object-assign/object-assign-tests.ts index 53dfd5e707..6b9a898ed4 100644 --- a/object-assign/object-assign-tests.ts +++ b/object-assign/object-assign-tests.ts @@ -1,17 +1,79 @@ /// import objectAssign = require("object-assign"); -function assign1() { - var result = objectAssign({hello: "world"}); - return result; +interface Target { + hellow: string; } -function assign2() { - var result = objectAssign({hello: "world"}, {hello: "worlds", second: "extra"}); - return result; +interface Source1 { + source1: string; } -function assign3() { - var result = objectAssign({hello: "world"}, {hello: "worlds", second: "extra"}, {hello: "stop", the: "spinning"}); - return result; +interface Result extends Target, Source1 { + } + +interface Source2 { + source2: string; +} + +interface Result2 extends Result, Source2 { + +} + +interface Source3 { + source3: string; +} + +interface Result3 extends Result2, Source3 { + +} + +interface Source4 { + source4: string; +} + +interface Result4 extends Result3, Source4 { + +} + +interface Source5 { + source5: string; +} + +interface Result5 extends Result4, Source5 { + +} + +function assign1(): Result { + return objectAssign({hellow: "world"}, {source1: "U"}); +} + +function assign2(): Result2 { + return objectAssign({hellow: "world"}, {source1: "U"}, {source2: "V"}); +} + +function assign3(): Result3 { + return objectAssign({hellow: "world"}, {source1: "U"}, {source2: "V"}, {source3: "W"}); +} + +function assign4(): Result4 { + return objectAssign({hellow: "world"}, {source1: "U"}, {source2: "V"}, {source3: "W"}, {source4: "Q"}); +} + +function assign5(): Result5 { + return objectAssign({hellow: "world"}, {source1: "U"}, {source2: "V"}, {source3: "W"}, {source4: "Q"}, {source5: "R"}); +} + +function assign() { + return objectAssign({hellow: "world"}, {source1: "U"}, {source2: "V"}, {source3: "W"}, {source4: "Q"}, {source5: "R"}, { + hellow: "hellow", + source1: "source1", + source2: "source2", + source3: "source3", + source4: "source4", + source5: "source5", + generic: "any" + }); +} + diff --git a/object-assign/object-assign.d.ts b/object-assign/object-assign.d.ts index 52ef486c72..c3f92b7592 100644 --- a/object-assign/object-assign.d.ts +++ b/object-assign/object-assign.d.ts @@ -4,6 +4,11 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "object-assign" { + function objectAssign(target: T, source: U): T & U; + function objectAssign(target: T, source1: U, source2: V): T & U & V; + function objectAssign(target: T, source1: U, source2: V, source3: W): T & U & V & W; + function objectAssign(target: T, source1: U, source2: V, source3: W, source4: Q): T & U & V & W & Q; + function objectAssign(target: T, source1: U, source2: V, source3: W, source4: Q, source5: R): T & U & V & W & Q & R; function objectAssign(target: any, ...sources: any[]): any; export = objectAssign; }