admin管理员组文章数量:1335584
I am developing two plugins that will be used by multiple vue apps. One adds the global property $routes
and the other one $auth
.
I want the vue apps that use the plugins to know the types of said properties, but when I add them they override vue-router
's augmentations ($router
and $route
), which is not what I want. The added types for both plugins work fine (so it's not like they are overriding each other).
The packages and apps are in a turborepo, referring to each other internally (i.e. @repo/auth-vue
), and therefore referred in the apps in their package json as "@repo/auth-vue": "workspace:*"
Finally, they are installed like standard vue plugins (with their install functions) in the main.ts
file (I have included otther plugins in case it adds relevant context)
const app = createApp({
setup() {
provide(ApolloClients, clients);
},
render: () => h(App),
});
app.use(i18n);
app.use(pinia);
app.use(router); // Normal vue-router
app.use(authManager); // This is the custom plugin installation
I checked the generated .d.ts types for both plugins and they have what I would expect after rollup (of course, other types are declared above)
// dist/routes-plugin.d.ts
...
export { }
declare module 'vue' {
interface ComponentCustomProperties {
$routes: RouteRecordRaw[];
}
}
// dist/auth-plugin.d.ts
...
export { }
declare module 'vue' {
interface ComponentCustomProperties {
$auth: AuthManager;
}
}
Any idea on what I should do to make sure that vue-router's (and any other plugin) augmentations are persisted when I used my plugins?
thank you for any guidance!
本文标签: typescriptAugmenting global properties without removing vuerouter augmentationsStack Overflow
版权声明:本文标题:typescript - Augmenting global properties without removing vue-router augmentations - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742383957a2464650.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论