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
Cannot bypass getters with TypeScript #1605
Comments
Why would you assign to a getter? It's a getter, it has not setter. TS is warning you correctly here. if you want to do this for some exotic reason: |
Sorry I forgot to mention that it was to be able to mock getters in tests |
By the way TypeScript complains about this error for Pinia's test file :
|
I think we made the getters read only at some point because its easier to spot bugs. |
Can we have an update for the docs at least to mention this issue? |
Reproduction
https://stackblitz.com/edit/github-xe2cxw?file=src%2Fstores%2Fcounter.test.ts
Steps to reproduce the bug
Given the following code:
Expected behavior
TypeScript should not complain.
Actual behavior
TypeScript raises the following error:
Additional information
This is to be able to mock getters in tests
https://pinia.vuejs.org/cookbook/testing.html#mocking-getters
The text was updated successfully, but these errors were encountered: