Skip to content

fix: 修复typescript5 mapMutations推导错误#2437

Open
mackwang112 wants to merge 1 commit intomasterfrom
fix-ts-store
Open

fix: 修复typescript5 mapMutations推导错误#2437
mackwang112 wants to merge 1 commit intomasterfrom
fix-ts-store

Conversation

@mackwang112
Copy link
Collaborator

当methods中同时包含不同store的mapMutations时,如果这些store中存在相同mutations,即使在调用mapMutations时未指定,也会推导为最后一个 store 的 mutations 类型。

import { createPage } from '@mpxjs/core'

import storeA from '../store/storeA'
import storeB from '../store/storeB'


createPage({
  methods: {
    ...storeA.mapMutations(['increment']),
    ...storeB.mapMutations(['setAge']),
  },
  onReady() {
    this.increment('NewNameFromDetails')
    // 推导成了storeB中的increment方法
    // 因为`...storeB.mapMutations`写在`...storeA.mapMutations`
  }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant