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

Add declaration file for motion plugin #136

Merged
merged 1 commit into from
Jun 21, 2023
Merged

Conversation

alex-eliot
Copy link
Collaborator

Once building, there's no type shim generated for the motion plugin file. Here's why we need it:

Nuxt auto-generates types while previewing. In the .nuxt/types/plugins.d.ts file, the following type is generated that populated the NuxtApp interface:

type NuxtAppInjections = 
  InjectionType<typeof import("../../../node_modules/@pinia/nuxt/dist/runtime/plugin.vue3").default> &
  InjectionType<typeof import("../../../node_modules/nuxt/dist/app/plugins/revive-payload.server").default> &
  InjectionType<typeof import("../../../node_modules/nuxt/dist/app/plugins/revive-payload.client").default> &
  InjectionType<typeof import("../../../node_modules/nuxt/dist/head/runtime/plugins/unhead").default> &
  InjectionType<typeof import("../../../node_modules/nuxt/dist/pages/runtime/plugins/router").default> &
  InjectionType<typeof import("../../../node_modules/nuxt/dist/pages/runtime/plugins/prefetch.client").default> &
  InjectionType<typeof import("../../../node_modules/@vueuse/motion/dist/runtime/templates/motion").default> &
  {other imports}

Because it can't find a type declaration for the motion plugin, it's resolved as any, causing the entire NuxtAppInjections type to be any (as any intersection with any will resolve as any).

The effect of that is that, if you provide a plugin as, say, session, you won't find $session in the keys returned by useNuxtApp()

This PR adds the relevant shim file to ensure it's gracefully regarded as unknown, hence maintaining the types for the plugin helper.

@Tahul
Copy link
Member

Tahul commented Jun 21, 2023

Thank you so much!

@Tahul Tahul merged commit 1364fc6 into main Jun 21, 2023
@reslear
Copy link

reslear commented Nov 7, 2023

resolves #155

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants