fix(nuxt): correct type for useError (#28996)

This commit is contained in:
Artem Maslov 2024-09-16 01:37:24 +05:00 committed by Daniel Roe
parent 98215d7956
commit 870e4f6b4a
No known key found for this signature in database
GPG Key ID: CBC814C393D93268

View File

@ -1,7 +1,9 @@
import type { H3Error } from 'h3' import type { H3Error } from 'h3'
import { createError as createH3Error } from 'h3' import { createError as createH3Error } from 'h3'
import { toRef } from 'vue' import { toRef } from 'vue'
import type { Ref } from 'vue'
import { useNuxtApp } from '../nuxt' import { useNuxtApp } from '../nuxt'
import type { NuxtPayload } from '../nuxt'
import { useRouter } from './router' import { useRouter } from './router'
// @ts-expect-error virtual file // @ts-expect-error virtual file
@ -10,7 +12,7 @@ import { nuxtDefaultErrorValue } from '#build/nuxt.config.mjs'
export const NUXT_ERROR_SIGNATURE = '__nuxt_error' export const NUXT_ERROR_SIGNATURE = '__nuxt_error'
/** @since 3.0.0 */ /** @since 3.0.0 */
export const useError = () => toRef(useNuxtApp().payload, 'error') export const useError = (): Ref<NuxtPayload['error']> => toRef(useNuxtApp().payload, 'error')
// eslint-disable-next-line @typescript-eslint/no-empty-object-type // eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface NuxtError<DataT = unknown> extends H3Error<DataT> {} export interface NuxtError<DataT = unknown> extends H3Error<DataT> {}