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

[Nuxt] No types for plugin to extend NuxAppInjections #13899

Closed
3 tasks done
qnp opened this issue Oct 7, 2024 · 3 comments · Fixed by #13909
Closed
3 tasks done

[Nuxt] No types for plugin to extend NuxAppInjections #13899

qnp opened this issue Oct 7, 2024 · 3 comments · Fixed by #13909
Assignees
Labels
Package: nuxt Issues related to the Sentry Nuxt SDK

Comments

@qnp
Copy link

qnp commented Oct 7, 2024

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nuxt

SDK Version

8.33.1

Framework Version

Nuxt 3.13.2

Link to Sentry event

No response

Reproduction Example/SDK Setup

@sentry/nuxt built package file located at /build/module/runtime/plugins/sentry.client.d.ts is empty. No types are exported, therefore the NuxtAppInjection type built by Nuxt fails and resolves to any which breaks every subsequent type of plugins used as, e.g. useNuxtApp().$pinia

Example in .nuxt/types/plugins.d.ts

type NuxtAppInjections =
  InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/revive-payload.client.js").default> &
  InjectionType<typeof import("../../node_modules/nuxt/dist/head/runtime/plugins/unhead.js").default> &
  InjectionType<typeof import("../../node_modules/nuxt/dist/pages/runtime/plugins/router.js").default> &
  InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/payload.client.js").default> &
  InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/navigation-repaint.client.js").default> &
  InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/check-outdated-build.client.js").default> &
  InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/revive-payload.server.js").default> &
  InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/chunk-reload.client.js").default> &
  InjectionType<typeof import("../../node_modules/@pinia/nuxt/dist/runtime/plugin.vue3.js").default> &
  InjectionType<typeof import("../../node_modules/nuxt/dist/pages/runtime/plugins/prefetch.client.js").default> &
  InjectionType<typeof import("../../node_modules/@sentry/nuxt/build/module/runtime/plugins/sentry.client.js").default> & // fails, resolves to `any`
  InjectionType<typeof import("../../plugins/error").default> &
  InjectionType<typeof import("../../plugins/fds").default> &
  InjectionType<typeof import("../../plugins/locale").default> &
  InjectionType<typeof import("../../plugins/routes").default> &
  InjectionType<typeof import("../../plugins/store").default>

Steps to Reproduce

Install @sentry/nuxt, run nuxt so that the types are generated.
If you had any use of plugins like useNuxtApp().$pinia or so on, they are resolved to unknown which breaks the type-checking.

Expected Result

File /build/module/runtime/plugins/sentry.client.d.ts must export at least:

declare const _default: any;
export default _default;

(Would be even better if it had the full type.)

Actual Result

File is empty.

@github-actions github-actions bot added the Package: nuxt Issues related to the Sentry Nuxt SDK label Oct 7, 2024
@Lms24
Copy link
Member

Lms24 commented Oct 8, 2024

Hi, @qnp thanks for reporting! You're right, something is off with the declaration files. I asked @s1gr1d, our Nuxt SDK expert, to take a look.

@s1gr1d
Copy link
Member

s1gr1d commented Oct 8, 2024

Hello, thanks for filing this issue 🙌
This should be fixed with this PR: #13909

The types look like this

declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
export default _default;

s1gr1d added a commit that referenced this issue Oct 8, 2024
[Nuxt module builder](https://github.com/nuxt/module-builder) uses the
closest `tsconfig.json` and this had `"declaration": false`. I added
another `tsconfig.json` closer to the module to generate those
declarations.

fixes #13899
Copy link
Contributor

A PR closing this issue has just been released 🚀

This issue was referenced by PR #13909, which was included in the 8.34.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nuxt Issues related to the Sentry Nuxt SDK
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants