-
-
Notifications
You must be signed in to change notification settings - Fork 68
fix: make options parameter optional in types #224
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
Conversation
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?])`).
WalkthroughThe pull request modifies the type signature of the Changes
Poem
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for funny-banoffee-0afb46 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this 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
📒 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>toPlugin<[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 callapp.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.
posva
left a comment
There was a problem hiding this 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
@pinia/colada
@pinia/colada-nuxt
@pinia/colada-plugin-cache-persister
@pinia/colada-plugin-debug
@pinia/colada-plugin-auto-refetch
@pinia/colada-plugin-delay
@pinia/colada-plugin-retry
commit: |
|
FYI there was a new release of vue so i think the referenced PR has now been released do we still need this one? |
The types inside vue define that
Plugin<T>whereTisn'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]>meansuse(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
Tests