feat(computed): allow computed get/set to have different types#8543
feat(computed): allow computed get/set to have different types#8543Alfred-Skyblue wants to merge 3 commits into
Conversation
sxzz
left a comment
There was a problem hiding this comment.
That's great! It's exactly what I wanted to do before. However, we need to explore ways to ensure compatibility with TS versions higher than 4.4. Perhaps we can use typeVersions to differentiate between TS >= 5.1 and other versions.
If you use typeVersions to handle it, will it cause users to need to modify the tsconfig.json file in the project? |
|
No, it doesn't need to. The only thing that needs to be done is to add |
|
That's great, we can use |
resolve #7271
In certain cases, we would like the
computedproperty's getter and setter to have different types. This would provide added convenience in our usage, such as having the getter return a string while the setter accepts an object. In this PR, I have added a second generic parameter to thecomputedproperty to specify the type of the setter. With this enhancement, we can set different types for the getter and setter ofcomputedusing the following approach.Examples: