fix(types): add explicit return type for useToast to resolve ts(2742) error

This commit is contained in:
Damiano 2024-10-27 23:11:14 +01:00
parent e0d4980e31
commit 67a5938113
2 changed files with 23 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import type { Component, VNode } from 'vue' import type { Component, ComputedRef, VNode } from 'vue'
import type { ToastProps } from '.' import type { ToastProps } from '.'
import { computed, ref } from 'vue' 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<ToasterToast[]>
}
function useToast() { function useToast() {
return { return {
toasts: computed(() => state.value.toasts), toasts: computed(() => state.value.toasts),

View File

@ -1,4 +1,4 @@
import type { Component, VNode } from 'vue' import type { Component, ComputedRef, VNode } from 'vue'
import type { ToastProps } from '.' import type { ToastProps } from '.'
import { computed, ref } from 'vue' 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<ToasterToast[]>
}
function useToast() { function useToast() {
return { return {
toasts: computed(() => state.value.toasts), toasts: computed(() => state.value.toasts),