Skip to content

Commit

Permalink
Remove generic contraint
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesfries committed Jul 3, 2024
1 parent 4c0923d commit f43f371
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ember-composable-helpers/src/helpers/map-by.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { get } from '@ember/object';
import { isEmpty } from '@ember/utils';
import asArray from '../utils/as-array.ts';

export function mapBy<T extends object>([byPath, array]: [keyof T, T[]]) {
export function mapBy<T>([byPath, array]: [keyof T, T[]]) {
if (isEmpty(byPath)) {
return [];
}

return asArray(array).map(item => get(item, byPath));
return asArray(array).map(item => get(item as object, byPath as string));
}

export default helper(mapBy);
10 changes: 5 additions & 5 deletions ember-composable-helpers/src/helpers/toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ function nextIndex(length: number, currentIdx: number) {
return currentIdx + 1;
}

export function toggle<T extends object>([prop, obj, ...values]: [keyof T, T, ...(T[keyof T])[]]) {
export function toggle<T>([prop, obj, ...values]: [keyof T, T, ...(T[keyof T])[]]) {
return function() {
let currentValue = get(obj, prop);
let currentValue = get(obj as object, prop as string);

if (isPresent(values)) {
let currentIdx = values.indexOf(currentValue);
let currentIdx = values.indexOf(currentValue as T[keyof T]);
let nextIdx = nextIndex(values.length, currentIdx);

return set(obj, prop as string, values[nextIdx]!);
return set(obj as object, prop as string, values[nextIdx]!);
}

return set(obj, prop as string, !currentValue);
return set(obj as object, prop as string, !currentValue);
};
}

Expand Down

0 comments on commit f43f371

Please sign in to comment.