Skip to content

Commit 05b592b

Browse files
mappingValue and DeepPartialEvent
1 parent 193cc88 commit 05b592b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/types/src/mapping.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export type Condition = (
5050
) => boolean;
5151

5252
export type Fn = (
53-
event: WalkerOS.PartialEvent,
53+
value: WalkerOS.DeepPartialEvent | unknown,
5454
mapping: Value,
5555
options: Options,
5656
) => WalkerOS.Property | unknown;

packages/utils/src/core/mapping.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ function processMappingValue(
7979
return mappings.reduce((acc, mappingItem) => {
8080
if (acc) return acc; // A valid result was already found
8181

82+
const mapping = isString(mappingItem) ? { key: mappingItem } : mappingItem;
83+
8284
const {
8385
condition,
8486
consent,
@@ -89,7 +91,7 @@ function processMappingValue(
8991
set,
9092
validate,
9193
value: staticValue,
92-
} = isString(mappingItem) ? { key: mappingItem } : mappingItem;
94+
} = mapping;
9395

9496
// Check if this mapping should be used
9597
if (condition && !condition(value, mappingItem, instance)) return;
@@ -102,7 +104,7 @@ function processMappingValue(
102104

103105
if (fn) {
104106
// Use a custom function to get the value
105-
mappingValue = fn(value as WalkerOS.PartialEvent, mappingItem, options); // @TODO stop casting
107+
mappingValue = fn(value, mappingItem, options);
106108
}
107109

108110
if (key) {

0 commit comments

Comments
 (0)