11import Vue from 'vue' ;
22import Vuex from 'vuex' ;
3- import { mapGetters , mapState , mapMutations , mapActions } from 'vuex' ;
3+ import { mapGetters , mapState , mapMutations , mapActions , createNamespacedHelpers } from 'vuex' ;
44
55Vue . use ( Vuex ) ;
66
@@ -18,6 +18,9 @@ const submoduleB = {
1818 }
1919} ;
2020
21+ const { mapGetters : mapGettersA } = createNamespacedHelpers ( 'submoduleA' ) ;
22+ const { mapGetters : mapGettersB } = createNamespacedHelpers ( 'submoduleB' ) ;
23+
2124const store = new Vuex . Store ( {
2225 getters : {
2326 getterWithSink : state => { sink ( state . tainted ) ; } , // NOT OK
@@ -72,8 +75,10 @@ const Component = new Vue({
7275 derivedUntainted : state => state . untainted ,
7376 } ) ,
7477 ...mapState ( [ 'tainted2' ] ) ,
75- ...mapGetters ( 'submoduleA' , { fooA : 'foo' } ) ,
76- ...mapGetters ( 'submoduleB' , { fooB : 'foo' } ) ,
78+ ...mapGetters ( 'submoduleA' , { fooA1 : 'foo' } ) ,
79+ ...mapGettersA ( { fooA2 : 'foo' } ) ,
80+ ...mapGetters ( 'submoduleB' , { fooB1 : 'foo' } ) ,
81+ ...mapGettersB ( { fooB2 : 'foo' } ) ,
7782 } ,
7883 methods : {
7984 doCommitsAndActions ( ) {
@@ -95,8 +100,10 @@ const Component = new Vue({
95100 sink ( this . untaintedGetter ) ; // OK
96101 sink ( this . derivedUntainted ) ; // OK
97102
98- sink ( this . fooA ) ; // NOT OK
99- sink ( this . fooB ) ; // OK
103+ sink ( this . fooA1 ) ; // NOT OK
104+ sink ( this . fooA2 ) ; // NOT OK
105+ sink ( this . fooB1 ) ; // OK
106+ sink ( this . fooB2 ) ; // OK
100107 } ,
101108 ...mapMutations ( { sneakyTaint3 : 'setTainted3' } ) ,
102109 ...mapActions ( { emitTaint4 : 'doTaint4' } ) ,
0 commit comments