Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lack of context typing with useNuxtApp #539

Closed
thisismydesign opened this issue Sep 16, 2022 · 3 comments
Closed

Lack of context typing with useNuxtApp #539

thisismydesign opened this issue Sep 16, 2022 · 3 comments
Labels
bug Something isn't working types

Comments

@thisismydesign
Copy link

thisismydesign commented Sep 16, 2022

Environment

Reproduction

const { $auth } = useNuxtApp() gives any type, whereas nuxt2Context.$auth from const { nuxt2Context } = useNuxtApp() is typed correctly.

Describe the bug

Lack of typing

Additional context

Perhaps related to #130

Logs

No response

@antlionguard
Copy link

I think duplicate of this #465

@danielroe danielroe added bug Something isn't working types and removed pending triage labels Sep 23, 2022 — with Volta.net
@valh1996
Copy link

valh1996 commented Oct 5, 2022

Same problem for me, as a workaround, I use :

const { nuxt2Context: { $repository, $toast, $i18n } } = useNuxtApp()

/!\ EDIT: Do not use this workaround if you plan to migrate to Nuxt3 :
From doc: https://v3.nuxtjs.org/bridge/bridge-composition-api/#usecontext-and-withcontext
useNuxtApp() also provides a key called nuxt2Context which contains all the same properties you would normally access from Nuxt 2 context, but it's advised not to use this directly, as it won't exist in Nuxt 3. Instead, see if there is another way to access what you need. (If not, please raise a feature request or discussion.)

@wattanx
Copy link
Collaborator

wattanx commented Apr 23, 2023

I believe this issue has been resolved at #130.
You can extend NuxtAppCompat to add types such as $auth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working types
Projects
None yet
Development

No branches or pull requests

5 participants