Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to typescript overloads in Store instance methods. #2142

Open
Surof1n opened this issue Mar 9, 2022 · 0 comments
Open

Changes to typescript overloads in Store instance methods. #2142

Surof1n opened this issue Mar 9, 2022 · 0 comments

Comments

@Surof1n
Copy link

Surof1n commented Mar 9, 2022

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.

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

No branches or pull requests

1 participant