Skip to content

TypeScript type-checking bugs with mapState/mapGetters #1353

Closed
@ffxsam

Description

@ffxsam

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions