Skip to content

Conversation

@43081j
Copy link
Contributor

@43081j 43081j commented Mar 18, 2025

The types inside vue define that Plugin<T> where T isn't an array implies that the options must be passed.

When you do specify a tuple/array, you're defining the parameters of the function. So Plugin<[T0, T1]> means use(fn, T0, T1).

We can use this with an optional tuple member to make the parameter optional: Plugin<[T?]> (which is basically (...params: [T?]), which itself is (param0?: T | undefined)).

Summary by CodeRabbit

  • Refactor

    • The PiniaColada plugin now accepts an optional configuration array, allowing for greater flexibility and a more customized setup.
  • Tests

    • Cleaned up test configurations by removing outdated directives, contributing to improved code quality.

The types inside vue define that `Plugin<T>` where `T` isn't an array
implies that the options _must_ be passed.

When you do specify a tuple/array, you're defining the parameters of the
function. So `Plugin<[T0, T1]>` means `use(fn, T0, T1)`.

We can use this with an optional tuple member to make the parameter
optional: `Plugin<[T?]>` (which is basically `(...params: [T?])`).
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 2025

Walkthrough

The pull request modifies the type signature of the PiniaColada export in src/pinia-colada.ts, changing it from Plugin<PiniaColadaOptions> to Plugin<[options?: PiniaColadaOptions]>, which makes the options parameter optional and wraps it in an array. Additionally, a TypeScript directive comment was removed from the src/query-options.test-d.ts file, indicating that the previously suppressed error is no longer necessary.

Changes

File Change Summary
src/pinia-colada.ts Updated export type signature from Plugin<PiniaColadaOptions> to Plugin<[options?: PiniaColadaOptions]> to allow an optional array for options.
src/query-options.test-d.ts Removed the TypeScript directive comment (// @ts-expect-error: FIXME: can this be fixed?) that suppressed errors during plugin usage tests.

Poem

I'm a hopping rabbit with a coding twist,
Changing type signatures—now none is missed.
An optional array now does the trick,
And stray comments vanish, oh so quick!
Hop along, dear coder, with changes that persist!

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d5849e and 458050e.

📒 Files selected for processing (1)
  • src/pinia-colada.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pinia-colada.ts

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@netlify
Copy link

netlify bot commented Mar 18, 2025

Deploy Preview for funny-banoffee-0afb46 ready!

Name Link
🔨 Latest commit 458050e
🔍 Latest deploy log https://app.netlify.com/sites/funny-banoffee-0afb46/deploys/67d94ad7de8149000807aff2
😎 Deploy Preview https://deploy-preview-224--funny-banoffee-0afb46.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/pinia-colada.ts (1)

24-31: Consider updating the JSDoc to reflect the optional parameter.

While the implementation and type signature now properly indicate that options are optional, it would be helpful to update the JSDoc to explicitly mention this.

 /**
  * Plugin that installs the Query and Mutation plugins alongside some extra plugins.
  *
  *
  * @see {@link QueryPlugin} to only install the Query plugin.
  *
  *
  * @param app - Vue App
- * @param options - Pinia Colada options
+ * @param options - Pinia Colada options (optional)
  */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de56882 and 7d5849e.

📒 Files selected for processing (2)
  • src/pinia-colada.ts (1 hunks)
  • src/query-options.test-d.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • src/query-options.test-d.ts
🔇 Additional comments (1)
src/pinia-colada.ts (1)

32-32: Good change to make the plugin more flexible!

This type signature change from Plugin<PiniaColadaOptions> to Plugin<[PiniaColadaOptions?]> improves the plugin's usability by making the options parameter optional, which aligns with the function implementation (line 34 already has a default empty object). This change allows users to call app.use(PiniaColada) without providing options, while maintaining type safety.

The approach correctly uses the tuple syntax with an optional member, which matches Vue's Plugin typings convention for optional parameters.

Copy link
Owner

@posva posva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I will wait for vuejs/core#13063 to be merged and released as without it there is no auto completion in the options

@github-project-automation github-project-automation bot moved this from 🆕 Triaging to In progress in Pinia Colada Roadmap Mar 18, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 18, 2025

Open in Stackblitz

@pinia/colada

npm i https://pkg.pr.new/@pinia/colada@224

@pinia/colada-nuxt

npm i https://pkg.pr.new/@pinia/colada-nuxt@224

@pinia/colada-plugin-cache-persister

npm i https://pkg.pr.new/@pinia/colada-plugin-cache-persister@224

@pinia/colada-plugin-debug

npm i https://pkg.pr.new/@pinia/colada-plugin-debug@224

@pinia/colada-plugin-auto-refetch

npm i https://pkg.pr.new/@pinia/colada-plugin-auto-refetch@224

@pinia/colada-plugin-delay

npm i https://pkg.pr.new/@pinia/colada-plugin-delay@224

@pinia/colada-plugin-retry

npm i https://pkg.pr.new/@pinia/colada-plugin-retry@224

commit: 458050e

@43081j
Copy link
Contributor Author

43081j commented May 27, 2025

FYI there was a new release of vue so i think the referenced PR has now been released

do we still need this one?

@posva posva merged commit 20bca79 into posva:main May 27, 2025
8 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in Pinia Colada Roadmap May 27, 2025
@43081j 43081j deleted the plugin-funkiness branch May 27, 2025 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants