Unable to use Vuex + namespace with Typescript
See original GitHub issueHi,
I am doing the following in typescript
Vue.customElement('coupon-preview', new CouponPreview({ store }).$options);
But I am getting the following error because the store is not present in the new component:
Cannot read property '_modulesNamespaceMap' of undefined"
If I instead do
Vue.customElement('coupon-preview', new CouponPreview({ store }));
The store is there but the component fails to render:
template or render function not defined
Anything I can do to include the store in typescript?
I also tried the suggestion here but no dice https://github.com/karol-f/vue-custom-element/issues/161
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Referencing a Vuex Store Module gives namespace error for ...
In VuejS - Typescript in order to have these attributes needed your module needs to import and define them. I am utilizing only...
Read more >TypeScript Support - Vuex
Vuex provides its typings so you can use TypeScript to write a store definition. You don't need any special TypeScript configuration for Vuex....
Read more >Discussion of Vuex + TypeScript - DEV Community
The code works but typescript is unable to resolve the getters properly. ... But if you are using TS 4.1 you can use...
Read more >How To Manage State in a Vue.js Application with Vuex
I work on TypeScript apps with Vue.js. Currently a Senior Front-End Engineer at Enodo, based in Chicago. Still looking for an answer?
Read more >How to set up and code Nuxt.js apps fully in TypeScript
Since you're using namespaced Vuex modules, first import namespace from nuxt-property-decorator and then pass the name of the module to get ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@karol-f that does not work either. The only way I got this to work was by manually setting this.$store = store in beforeCreate of the component which is less than ideal
If anyone stumbles upon this thread I found an extremely simple solution to this issue. This works for issues with VueX store as well as Vue Router.
When defining your parent component you can do the following -
In your
main.ts
-You will then be able to access your
vuex-class
namespaces.