From 67a593811323933906bd26de5f3d32976452932e Mon Sep 17 00:00:00 2001 From: Damiano Date: Sun, 27 Oct 2024 23:11:14 +0100 Subject: [PATCH] fix(types): add explicit return type for useToast to resolve ts(2742) error --- .../src/lib/registry/default/ui/toast/use-toast.ts | 12 +++++++++++- .../src/lib/registry/new-york/ui/toast/use-toast.ts | 13 ++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/apps/www/src/lib/registry/default/ui/toast/use-toast.ts b/apps/www/src/lib/registry/default/ui/toast/use-toast.ts index 228e5a79..fd85d83d 100644 --- a/apps/www/src/lib/registry/default/ui/toast/use-toast.ts +++ b/apps/www/src/lib/registry/default/ui/toast/use-toast.ts @@ -1,4 +1,4 @@ -import type { Component, VNode } from 'vue' +import type { Component, ComputedRef, VNode } from 'vue' import type { ToastProps } from '.' import { computed, ref } from 'vue' @@ -121,6 +121,16 @@ function dispatch(action: Action) { } } +interface UseToast { + dismiss: (toastId?: string) => void + toast: (props: Toast) => { + dismiss: () => void + id: string + update: (props: ToasterToast) => void + } + toasts: ComputedRef +} + function useToast() { return { toasts: computed(() => state.value.toasts), diff --git a/apps/www/src/lib/registry/new-york/ui/toast/use-toast.ts b/apps/www/src/lib/registry/new-york/ui/toast/use-toast.ts index 228e5a79..12a3f588 100644 --- a/apps/www/src/lib/registry/new-york/ui/toast/use-toast.ts +++ b/apps/www/src/lib/registry/new-york/ui/toast/use-toast.ts @@ -1,4 +1,4 @@ -import type { Component, VNode } from 'vue' +import type { Component, ComputedRef, VNode } from 'vue' import type { ToastProps } from '.' import { computed, ref } from 'vue' @@ -121,6 +121,17 @@ function dispatch(action: Action) { } } +interface UseToast { + dismiss: (toastId?: string) => void + toast: (props: Toast) => { + dismiss: () => void + id: string + update: (props: ToasterToast) => void + } + toasts: ComputedRef +} + + function useToast() { return { toasts: computed(() => state.value.toasts),