From a418d36c7f38b1969c542765fe8ccbae23e69344 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Mon, 22 Mar 2021 15:30:35 +0100 Subject: [PATCH] Add type signatures to asyncReactive --- ts/sveltelib/asyncReactive.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ts/sveltelib/asyncReactive.ts b/ts/sveltelib/asyncReactive.ts index 2411f9411..0b0aced12 100644 --- a/ts/sveltelib/asyncReactive.ts +++ b/ts/sveltelib/asyncReactive.ts @@ -12,14 +12,14 @@ function useAsyncReactive( ): AsyncReativeData { const promise = derived( dependencies, - (_, set: (value: Promise | null) => void) => set(asyncFunction()), + (_, set: (value: Promise | null) => void): void => set(asyncFunction()), // initialize with null to avoid duplicate fetch on init null ); const value = derived( promise, - ($promise, set: (value: T) => void) => { + ($promise, set: (value: T) => void): void => { $promise?.then((value: T) => set(value)); }, null @@ -27,18 +27,18 @@ function useAsyncReactive( const error = derived( promise, - ($promise, set: (error: E | null) => void) => { + ($promise, set: (error: E | null) => void): (() => void) => { $promise?.catch((error: E) => set(error)); - return () => set(null); + return (): void => set(null); }, null ); const loading = derived( promise, - ($promise, set: (value: boolean) => void) => { + ($promise, set: (value: boolean) => void): (() => void) => { $promise?.finally(() => set(false)); - return () => set(true); + return (): void => set(true); }, true );