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

Fix types for runtime/plugin.ts not being created correctly #220

Merged
merged 2 commits into from
Sep 16, 2024

Conversation

StevenPewsey
Copy link
Contributor

Types of changes

  • Chore (a non-breaking change which is related to package maintenance)
  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

At some point, I think following #214, the following error started to happen following a pnpm build:module:

src/runtime/plugin.client.ts(4,1): error TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/nuxt@3.13.0_@parcel+watcher@2.4.1_@types[email protected][email protected][email protected][email protected].sqyrdato2lgkvg37xa7csw3nz4/node_modules/nuxt/app'. This is likely not portable. A type annotation is necessary.
src/runtime/plugin.ts(15,1): error TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/[email protected]
@parcel+watcher@2.4.1_@types[email protected][email protected][email protected][email protected]._sqyrdato2lgkvg37xa7csw3nz4/node_modules/nuxt/app'. This is likely not portable. A type annotation is necessary.

This can be seen in CI pipeline for the latest release https://github.com/nuxt-modules/prismic/actions/runs/10647703821

image

This results in the generated dist/runtime/plugin.client.d.ts and dist/runtime/plugin.d.ts being empty.

image

This causes an error in a wider nuxt application as the following lines of code have the any type

image

image

This PR fixes this error. Note - I don't have much experience with Nuxt plugins, I'm not sure if there are any consequences to importing from nuxt/app rather than #imports? Anyhow this results in the types being created correctly (alternative solution is to do a as Plugin<{ prismic: PrismicPlugin}> cast

image

Checklist:

  • My change requires an update to the official documentation.
  • All TSDoc comments are up-to-date and new ones have been added where necessary.
  • All new and existing tests are passing.

Copy link

netlify bot commented Sep 16, 2024

👷 Deploy request for prismic-module pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit ae87372

@lihbr
Copy link
Collaborator

lihbr commented Sep 16, 2024

Hey @StevenPewsey, thank you so much for taking the time to dig into that, explaining it, and figuring out a fix for it :)

Let's get that released 🚀

@lihbr lihbr merged commit 28ddc1a into nuxt-modules:master Sep 16, 2024
@lihbr
Copy link
Collaborator

lihbr commented Sep 16, 2024

Released in 3.4.1, let me know if you still experience the issue ☺️

@StevenPewsey StevenPewsey deleted the SP/fix-plugin-types branch September 16, 2024 22:07
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.

2 participants