Skip to content

Commit e26c4d2

Browse files
committed
convert to plain function as helper to get better context in template type checking
1 parent a6c3b61 commit e26c4d2

File tree

1 file changed

+5
-7
lines changed
  • ember-set-helper/src/helpers

1 file changed

+5
-7
lines changed

ember-set-helper/src/helpers/set.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
import { helper } from '@ember/component/helper';
21
import { set as emberSet } from '@ember/object';
32
import { assert } from '@ember/debug';
43

5-
function set<T extends object, K extends keyof T>(
6-
positional: [T, K] | [T, K, T[K]],
4+
export default function set<T extends object, K extends keyof T & string>(
5+
target: T,
6+
path: K,
7+
maybeValue?: T[K],
78
) {
8-
const [target, path, maybeValue] = positional;
99
assert(
1010
'you must pass a path to {{set}}. You can pass a path statically, as in `{{set this "foo"}}`, or with the path dynamically, as in `{{set this this.greetingPath "Hello"}}`',
1111
(typeof path === 'string' && path.length > 0) ||
1212
typeof path === 'symbol' ||
1313
typeof path === 'number',
1414
);
15-
return positional.length === 3
15+
return arguments.length === 3
1616
? () => emberSet(target, path, maybeValue)
1717
: (value: T[K]) => emberSet(target, path, value);
1818
}
19-
20-
export default helper(set);

0 commit comments

Comments
 (0)