vuejs/vuex

TypeScript type-checking bugs with mapState/mapGetters

ffxsam opened this issue · 2 comments

Version

3.0.1

Reproduction link

https://github.com/ffxsam/repro-mapstate-bug

Steps to reproduce

  1. Clone repo
  2. Run yarn
  3. Open src/components/HelloWorld.vue

What is expected?

There should be no type errors

What is actually happening?

There is a type error on line 52


If you comment out lines 46-48 (the fake computed property), the type error on line 52 goes away. It seems mapState and mapGetters merges in an interface property, [x: string] => any whenever they're used. But if other computed properties are added, this fails to exist.

For instance, with lines 46-48 not commented out, I mouse over this in the method, and I see this:

{
    doit(): void;
} & {
    fake: string;
} & Readonly<{
    msg: string;
}> & Vue

However, if I comment out lines 46-48, hovering over this reveals:

{
    doit(): void;
} & {
    [x: string]: any;
} & Readonly<{
    msg: string;
}> & Vue
ktsn commented

Duplicate of #1119 and #1220
PR is already on #1121

@ktsn That PR is super old. Any ETA on when it'll go live?