Skip to content

Invalid Vue App Instance Type Thrown When Use In Pinia Store Action #2036

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

Closed
lostncg opened this issue Mar 1, 2023 · 2 comments
Closed

Invalid Vue App Instance Type Thrown When Use In Pinia Store Action #2036

lostncg opened this issue Mar 1, 2023 · 2 comments

Comments

@lostncg
Copy link

lostncg commented Mar 1, 2023

Reproduction

https://codesandbox.io/s/spring-sound-y7j6o1?file=/src/store.ts

Steps to reproduce the bug

  1. Create a state interface with Vue app instance type.
    image

  2. Create a Pinia store with the state above and implement an action to set the app instance.

  3. The action param should use the state interface to ensure the typing is the same.
    image

  4. Check the type error in code line 11 in store.ts
    image

Expected behavior

Since the action param and the state are using the exact same type, it should not complaint about the type error.

Actual behavior

The pinia instance attach to Vue instance somehow showing different typings.

Additional information

No response

@posva
Copy link
Member

posva commented Mar 1, 2023

You shouldn't store the app instance in a store as it creates a cyclic reference to itself through internal properties but if you do make sure to markRaw() befor setting it this.app = markRaw(data.app).

@posva
Copy link
Member

posva commented Mar 1, 2023

Duplicate of vuejs/core#3478

@posva posva marked this as a duplicate of vuejs/core#3478 Mar 1, 2023
@posva posva closed this as not planned Won't fix, can't repro, duplicate, stale Mar 1, 2023
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

2 participants