Skip to content

Commit 94db382

Browse files
committed
Extend function to accept additional types (null, undefined, number, boolean)
1 parent 4201463 commit 94db382

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

packages/json-safe-extend/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default function extend<T extends object>(...sources: Partial<T>[]): T {
1+
export default function extend<T extends object>(...sources: (Partial<T> | null | undefined | number | boolean)[]): T {
22
const target: any = {}
33

44
for (const obj of sources) {

packages/json-safe-extend/tests/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ it('doesn\'t change sources', function () {
139139
const a = { a: [1] }
140140
const b = { a: [2] }
141141
const c = { c: 3 }
142-
const d = extend({}, a, b, c)
142+
const d = extend<any>({}, a, b, c)
143143

144144
expect(a).toEqual({ a: [1] })
145145
expect(b).toEqual({ a: [2] })
@@ -249,7 +249,7 @@ it('prevent source contamination', () => {
249249
}
250250
}
251251

252-
extend(source, {
252+
extend<any>(source, {
253253
1: {
254254
4: true
255255
}

0 commit comments

Comments
 (0)