In Typescript I'd like to leverage my string enumeration:
export const enum MutationKeys {
registerUser = 'registration/REGISTER',
registerUserCompleted = 'registration/REGISTER_COMPLETED'
}
so that it's string values provide type-checking constraints on an object like this:
const mutations: IDictionary<VuexMutation> = {
['registration/REGISTER'](state, payload) {
state.registration = {
meta: {
serverValidated: false
},
value: payload
};
},
['registration/REGISTER_COMPLETED'](state) {
state.registration.meta.serverValidated = true;
}
};
In the above example the
IDictionary<VueMutation>interface allows me to type the value of the object vlue but allows any string index.