Skip to content

Commit 0a5972e

Browse files
committed
fix: ActionSelector type takes Source and Target
1 parent 5984cc8 commit 0a5972e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/types.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export type StrictSchema<Target = any, Source = any> = {
3838
| ActionString<Source>
3939
| ActionFunction<Target, Source, Target[destinationProperty]>
4040
| ActionAggregator<Source>
41-
| ActionSelector<Source, Target[destinationProperty]>
41+
| ActionSelector<Source, Target>
4242
| StrictSchema<Target[destinationProperty], Source>
4343
} & { [SCHEMA_OPTIONS_SYMBOL]?: SchemaOptions<Target> };
4444
export type Schema<Target = any, Source = any> = {
@@ -47,7 +47,7 @@ export type Schema<Target = any, Source = any> = {
4747
| ActionString<Source>
4848
| ActionFunction<Target, Source, Target[destinationProperty]>
4949
| ActionAggregator<Source>
50-
| ActionSelector<Source, Target[destinationProperty]>
50+
| ActionSelector<Source, Target>
5151
| Schema<Target[destinationProperty], Source>
5252
} & { [SCHEMA_OPTIONS_SYMBOL]?: SchemaOptions<Target | any> };
5353

@@ -110,7 +110,7 @@ export interface ActionFunction<D = any, S = any, R = any> {
110110
* ```
111111
*
112112
*/
113-
export type ActionString<Source> = string; // TODO: ActionString should support string and string[] for deep properties
113+
export type ActionString<Source> = string | keyof Source; // TODO: ActionString should support string and string[] for deep properties
114114

115115
/**
116116
* An Array of String that allows to perform a function over source property
@@ -158,10 +158,9 @@ export type ActionAggregator<T extends unknown = unknown> = T extends object ? (
158158
*```
159159
*
160160
*/
161-
export interface ActionSelector<Source = object, R = any> {
161+
export interface ActionSelector<Source = object, Target = any> {
162162
path?: ActionString<Source> | ActionAggregator<Source>;
163-
// | ((source: Source) => unknown);
164-
fn?: (fieldValue: any, object: Source, items: Source, objectToCompute: R) => R;
163+
fn?: (fieldValue: any, object: Source, items: Source, objectToCompute: Target) => Target;
165164
validation?: BaseValidator<ReturnType<undefined extends ActionSelector['fn'] ? any : ActionSelector['fn']>>;
166165
}
167166

0 commit comments

Comments
 (0)