Skip to content

Changes to typescript overloads in Store instance methods. #2142

Open
@Surof1n

Description

@Surof1n

Version

3.6.2

Reproduction link

codesandbox.io/s/umtsos

Steps to reproduce

  1. Look up the Union type of the 'path' argument (initModule method)

  2. An error appears about the incompatibility of the types of arguments for the registerModule method, the typing of this method does not support the use of the Union type: string | string[]

  3. Familiarize yourself with the typing of this method by reference and match the union type to the two method declarations:
    https://github.com/vuejs/vuex/blob/3.x/types/index.d.ts

For more information, use the resource:
https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#use-union-types

What is expected?

Support Union type: string | string[] given the already described type overloads of the registerModule method, the following errors will be eliminated when resolving the conflict:

1. Argument of type "string | string[]" is not assignable to parameter of type "string[]".
2. Argument of type "string | string[] is not assignable to parameter of type "string".

What is actually happening?

When comparing the type "string | string[]", an error about type incompatibility is thrown, but given the type overloads, it should be possible to put an argument with the union type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions