Skip to content

Commit

Permalink
fix: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
chesterkmr committed Aug 29, 2024
1 parent 5dfc0b2 commit d5b0f80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ export class ValueApplyPickSelector implements ValueApplySelector {
select<TResult>(value: ValueApplyValue, context: AnyObject): TResult {
if (!this.isPickSelector(value.selector)) throw new Error('Incorrect selector params.');

return get(context, value.selector.value, value.selector.defaultValue) as TResult;
return get(context, value.selector.pickDestination, value.selector.defaultValue) as TResult;
}

private isPickSelector(value: unknown): value is PickSelector {
//@ts-ignore
return typeof value === 'object' && typeof value === 'string' && value.type === 'pick';
return (
typeof value === 'object' &&
typeof (value as AnyObject).pickDestination === 'string' &&
(value as AnyObject).type === 'pick'
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface RawSelector<TValue = unknown> {

export interface PickSelector {
type: 'pick';
value: string;
pickDestination: string;
defaultValue?: unknown;
}

Expand Down

0 comments on commit d5b0f80

Please sign in to comment.