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
Custom plugin in Typescript after Vue 3.4 update #2729
Comments
@joaoefornazari have you reached the issue on the core repository? It looks like we might improve the code instead of adding a specific section to docs 🤔 |
@NataliaTepluhina I'll give a try. This is a thing that never happened to me so I was lost in what to do about it - I thought that there was already something on Vue core that would solve this but people forgot to put it on the docs. That's why I opened the issue. Maybe I open an issue on vuejs/core? What would you recommend? |
Where? There is no deprecation notice for that (https://github.com/vuejs/core/blob/01172fdb777f9a0b51781ed2015a1ba3824340a3/packages/runtime-core/src/apiCreateApp.ts#L168). import type { Plugin } from 'vue'
export default {
install(app, options) {
}
} satisfies Plugin
// or if you're using named exports
export const foo: Plugin = {
install(app, options) {
}
} |
I solved the problem that happened with me here. I did it like this:
Thanks @brc-dd for the clarification! |
According to Vue 3.4 docs, if I want to define a custom plugin, I need to create it like this:
Then, on
main.ts
, I set app to use it:And that was OK until I updated Vue to version 3.4.20. I was using 3.2.45 before.
Now, when I try to build the project with
yarn build
(which usesvite build
too) it throws this error:After searching for type definitiions in
node_modules/@vue/runtime-core/dist/runtime-core.d.ts
, I found out that, in order to Typescript doesn't claim any type errors, I must define my plugin as an ObjectPlugin type.I did it this way:
I can't use Plugin type because it says that
Plugin type is deprecated
.Is my fix correct? How can I contribute so the Vue docs has some notes regarding Typescript support?
The text was updated successfully, but these errors were encountered: