Skip to content

Commit acbcaef

Browse files
committed
fix: deepMerge type error
1 parent 69cd8d8 commit acbcaef

4 files changed

Lines changed: 15 additions & 17 deletions

File tree

packages/babel-plugin/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"types": "./dist/index.d.ts",
88
"exports": {
99
".": {
10+
"types": "./dist/index.d.ts",
1011
"import": "./dist/index.js",
11-
"require": "./dist/index.cjs",
12-
"types": "./dist/index.d.ts"
12+
"require": "./dist/index.cjs"
1313
}
1414
},
1515
"publishConfig": {

packages/core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"types": "./dist/index.d.ts",
88
"exports": {
99
".": {
10+
"types": "./dist/index.d.ts",
1011
"import": "./dist/index.js",
11-
"require": "./dist/index.cjs",
12-
"types": "./dist/index.d.ts"
12+
"require": "./dist/index.cjs"
1313
}
1414
},
1515
"sideEffects": false,

packages/core/src/engine/ChaosEngine.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,12 @@ const DEFAULT_CONFIG: ChaosConfig = {
4949
},
5050
};
5151

52-
function deepMerge<T extends Record<string, unknown>>(
53-
target: T,
54-
source: DeepPartial<T>,
55-
): T {
56-
const result = { ...target };
57-
for (const key in source) {
58-
const sourceVal = source[key];
59-
const targetVal = target[key];
52+
function deepMerge<T>(target: T, source: DeepPartial<T>): T {
53+
const result = { ...target } as Record<string, unknown>;
54+
const src = source as Record<string, unknown>;
55+
for (const key in src) {
56+
const sourceVal = src[key];
57+
const targetVal = result[key];
6058
if (
6159
sourceVal &&
6260
typeof sourceVal === "object" &&
@@ -66,12 +64,12 @@ function deepMerge<T extends Record<string, unknown>>(
6664
result[key] = deepMerge(
6765
(targetVal as Record<string, unknown>) ?? {},
6866
sourceVal as DeepPartial<Record<string, unknown>>,
69-
) as T[Extract<keyof T, string>];
67+
);
7068
} else if (sourceVal !== undefined) {
71-
result[key] = sourceVal as T[Extract<keyof T, string>];
69+
result[key] = sourceVal;
7270
}
7371
}
74-
return result;
72+
return result as T;
7573
}
7674

7775
let eventCounter = 0;

packages/react/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"types": "./dist/index.d.ts",
88
"exports": {
99
".": {
10+
"types": "./dist/index.d.ts",
1011
"import": "./dist/index.js",
11-
"require": "./dist/index.cjs",
12-
"types": "./dist/index.d.ts"
12+
"require": "./dist/index.cjs"
1313
}
1414
},
1515
"sideEffects": false,

0 commit comments

Comments
 (0)