Skip to content

[Help] About Vuex modules with typescript #6

@xieyezi

Description

@xieyezi

First of all, this is a amazing project which help me a lot.

But I have some trouble with Vuex in Typescript.

This is my // store/about.ts :

// store/about.ts
import modules from './about'
import { StateType } from '@typing/index'
import { Module } from 'vuex'

type AboutStateType = typeof state

const state = {
	aboutInfo: 'info from about state model'
}
const getters = {}
const mutations = {}
const actions = {}

const about: Module<AboutStateType, StateType> = {
	namespaced: true,
	state,
	getters,
	mutations,
	actions
	modules  // Here,Typescript have warning: 不能将类型“Module<{ aboutInfo: string; }, VuexModuleType>”分配给类型“ModuleTree<VuexModuleType>”。
}
export { AboutStateType, state }
export default about

And my project directory like this:

截屏2021-01-12 16 57 11

In the above example, There are other modules under the about module.
But TypeScript Can not Identify the type correctly.
I tried to solve this problem, but still don’t know what to do. Can you provide some help for this ?
Thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions