-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
types: export RefSymbol #3317
types: export RefSymbol #3317
Conversation
TS4058
Could you provide a complete code sample? a screenshot where the code is covered in large parts is hard to reproduce. A complete reproduction in issue would be even better. I ask because I regularly use readonly and haven't experienced this issue. |
If you are trying to export a setup(){
const a = readonly(ref(1));
return {
a,
};
}, I am getting this error because I want to make a composable exporting a readonly value(it 's reactive but should only be modified from the composable side, not in components), and it should bind to the template. @LinusBorg |
Full code logic here, <script lang="ts">
import { DeepReadonly, defineComponent, readonly, Ref, ref } from "vue";
interface AResult {
a: DeepReadonly<Ref<number>>;
updateA: (val: number) => void;
}
const useA = (): AResult => {
const a = ref(1);
const updateA = (val: number): void => {
a.value = val;
};
return {
a: readonly(a),
updateA,
};
};
export default defineComponent({
setup() {
const { a, updateA } = useA();
return {
a,
updateA,
};
},
});
</script> |
Hm, this problem only happens with Vetur, not Volar. Does it break on build? Haven't had time to check that out. Anyway, I would suspect the issue is rather with If we added a check for like this before the generic object one, this might be fixed without exposing the internal symbol. Will try and come up with a fix for that so that we don't have to expose this internal Symbol type. |
Hey, sorry for getting back late here, I was not available in the past ~2 weeks. I've setup a branch in the project using I want to run:
If I remove it (main branch), I get the declarations as expected. By the end it is not just an IDE/plugin issue, I think. Does it help? |
Hey @LinusBorg, did my last message helped somehow? |
Hey, thanks for the gentle reminder. Need to get back to this, will look at your branch this week as I have the week off. If that branch helps me to reproduce the error it will definitely help. Already played with a solution but was not sure how to to add a proper test for it without a way to make it fail before ... |
Hey @viniciuskneves, thanks for this PR, but I will close it because #2548 precedes this PR |
If you decide to use
readonly
fromvue
you will face the following issue:The issue is that
RefSymbol
is not exported.Another example using it directly inside
setup
: