I have been working on creating a helper that can be used across all composables and applications in my Nuxt plugin. Here is how the code looks:
// hello.ts
export default defineNuxtPlugin(async nuxtApp => {
nuxtApp.vueApp.provide('hello', (name: string) => `Hello ${name}!`);
nuxtApp.provide('hello', (name: string) => `Hello ${name}!`)
});
After setting up the helper, I wanted to use it by calling useNuxtApp()
in a composable as shown below, but encountered an issue with the return type being unknown.
// useHello.ts
export default async function() {
const nuxtApp = useNuxtApp()
console.log(nuxtApp.$hello('name'))
}
The error message states that nuxtApp.$hello
is of type 'unknown'.
Despite following the documentation, I am confused as to why it is returning an unknown type.
Could there be something missing in my nuxt.config.ts
file?
Your assistance on this matter would be greatly appreciated.