Skip to content

Plugin types break other Vue.js plugin helpers #158

@FabienMotte

Description

@FabienMotte

When using the nuxt-auth-utils module and starting Nuxt, two imports are generated in the .nuxt/types/plugins.d.ts file:

  /* ... */

  InjectionType<typeof import("../../node_modules/.pnpm/nuxt-auth-utils@0.3.5_magicast@0.3.5_rollup@4.21.2/node_modules/nuxt-auth-utils/dist/runtime/app/plugins/session.client.js").default> &
  InjectionType<typeof import("../../node_modules/.pnpm/nuxt-auth-utils@0.3.5_magicast@0.3.5_rollup@4.21.2/node_modules/nuxt-auth-utils/dist/runtime/app/plugins/session.server.js").default> &

  /* ... */

These two imports don't resolve because the files dist/runtime/app/plugins/session.client.d.ts and dist/runtime/app/plugins/session.server.d.ts are empty. This breaks the typing of other plugins that provide a helper on the NuxtApp instance, such as trpc-nuxt:

const { $trpc } = useNuxtApp() // '$trpc' is of type 'unknown'

Using export default {} in the session.client.d.ts and session.server.d.ts files solves the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions