docs: add TypeScript example for writing plugins - #3457
Open
pooridev wants to merge 1 commit into
Open
Conversation
Show how to type a plugin with Plugin and satisfies so app.use() accepts it without casts. Fixes vuejs#2729. Co-authored-by: Cursor <cursoragent@cursor.com>
✅ Deploy Preview for vuejs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Problem
The Writing a Plugin guide only shows JavaScript. After Vue 3.4,
app.use()is typed againstPlugin, so a plain{ install }object often fails type-checking unless it is annotated. Maintainers asked for a short TypeScript subsection rather than sending people to Discord.Fixes #2729
Proposed Solution
Add a TypeScript subsection with the public
Plugintype andsatisfies Plugin(and a named-export variant), matching the pattern already used for custom directives. Also note that types should be imported fromvue, not internalruntime-corepaths.Additional Information
The
satisfies Pluginexample is the one @brc-dd suggested on the issue. No runtime change.Test plan
PluginAPI link resolvesMade with Cursor