Skip to content

Commit ffaf4ed

Browse files
committedAug 23, 2020
types: Updating hooks label type to provide hint to built-in values
1 parent dd471a2 commit ffaf4ed

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎addon-test-support/@ember/test-helpers/-internal/helper-hooks.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
type Hook = (...args: any[]) => void | Promise<void>;
2+
type HookLabel = 'start' | 'end' | string;
23
type HookUnregister = {
34
unregister: () => void;
45
};
@@ -26,7 +27,7 @@ function getHelperKey(helperName: string, label: string) {
2627
* @returns {HookUnregister} An object containing an unregister function that will unregister
2728
* the specific hook registered to the helper.
2829
*/
29-
export function registerHook(helperName: string, label: string, hook: Hook): HookUnregister {
30+
export function registerHook(helperName: string, label: HookLabel, hook: Hook): HookUnregister {
3031
let helperKey = getHelperKey(helperName, label);
3132
let hooksForHelper = registeredHooks.get(helperKey);
3233

@@ -54,7 +55,7 @@ export function registerHook(helperName: string, label: string, hook: Hook): Hoo
5455
* @param {any[]} args Any arguments originally passed to the test helper.
5556
* @returns {Promise<void>} A promise representing the serial invocation of the hooks.
5657
*/
57-
export function runHooks(helperName: string, label: string, ...args: any[]): Promise<void> {
58+
export function runHooks(helperName: string, label: HookLabel, ...args: any[]): Promise<void> {
5859
let hooks = registeredHooks.get(getHelperKey(helperName, label)) || new Set<Hook>();
5960
let promises = [...hooks].map(hook => hook(...args));
6061

0 commit comments

Comments
 (0)
Please sign in to comment.