From 4ef2fc62f206d9fe9e8365953d2f3c753587d11a Mon Sep 17 00:00:00 2001 From: Shravan Sunder Date: Thu, 21 Dec 2023 23:46:19 +0000 Subject: [PATCH] Added const modifier on type parameters so that merge will infer string union types --- package-lock.json | 16 ++++++++-------- package.json | 2 +- src/merge.ts | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index c7048d5..590c349 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "rollup": "^3.23.0", "rollup-plugin-dts": "^5.3.0", "rollup-plugin-esbuild": "^5.0.0", - "typescript": "^5.0.4", + "typescript": "^5.3.3", "vitest": "^0.31.0" }, "engines": { @@ -6418,16 +6418,16 @@ } }, "node_modules/typescript": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", - "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", + "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=12.20" + "node": ">=14.17" } }, "node_modules/ufo": { @@ -11472,9 +11472,9 @@ } }, "typescript": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", - "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", + "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", "dev": true }, "ufo": { diff --git a/package.json b/package.json index df91257..7d3b049 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "rollup": "^3.23.0", "rollup-plugin-dts": "^5.3.0", "rollup-plugin-esbuild": "^5.0.0", - "typescript": "^5.0.4", + "typescript": "^5.3.3", "vitest": "^0.31.0" }, "np": { diff --git a/src/merge.ts b/src/merge.ts index 4cd6ca9..100ee70 100644 --- a/src/merge.ts +++ b/src/merge.ts @@ -94,13 +94,13 @@ function mergeRecursively< * Objects get merged, special objects (classes etc.) are re-assigned "as is". * Basic types overwrite objects or other basic types. */ -export function merge(object: T, ...otherObjects: Tn): Merge { +export function merge(object: T, ...otherObjects: Tn): Merge { return otherObjects.reduce((result, newComer) => { return mergeRecursively(result, newComer) }, object) as any } -export function mergeAndCompare( +export function mergeAndCompare( compareFn: (prop1: any, prop2: any, propName: string | symbol) => any, object: T, ...otherObjects: Tn @@ -110,7 +110,7 @@ export function mergeAndCompare( }, object) as any } -export function mergeAndConcat( +export function mergeAndConcat( object: T, ...otherObjects: Tn ): Merge {