Subscribe on changes!

Typescript 4058 error for ref sugar

avatar
Apr 13th 2022

Version

3.2.32

Reproduction link

sfc.vuejs.org/

Steps to reproduce

i want to export a $ref variable,like this:

const num = $ref(0);
export default num;

What is expected?

no error

What is actually happening?

i got a ts 4058 error :

Exported variable 'num' has or is using name 'RefType' from external module "path/to/vue@3.2.32/node_modules/vue/macros" but cannot be named.


How can I fix this problem? thanks

avatar
Apr 13th 2022

BTW: You probably want to export $$(num) (the actual ref)

avatar
Apr 13th 2022

BTW: You probably want to export $$(num) (the actual ref)

i know ,but this code i got the same error too , why ?

function useMouse() {
  let x = $ref(0)
  let y = $ref(0)
  return $$({
    x,
    y
  })
}
export default useMouse;
avatar
Apr 13th 2022

tsconfig.json close composite to false can fix it

avatar
Jun 17th 2022

I am version 3.2.33, encountered the same problem as you, and then I got the latest version number, 3.2.37, after the upgrade can be

avatar
Jun 17th 2022

I am version 3.2.33, encountered the same problem as you, and then I got the latest version number, 3.2.37, after the upgrade can be

两个中国人在这说英语,难为你了哈哈哈哈

avatar
Jun 17th 2022

I am version 3.2.33, encountered the same problem as you, and then I got the latest version number, 3.2.37, after the upgrade can be

两个中国人在这说英语,难为你了哈哈哈哈

兄弟,我还有个问题 image 我生成.d.ts文件的时候全红,咋解决

avatar
Jun 17th 2022

I am version 3.2.33, encountered the same problem as you, and then I got the latest version number, 3.2.37, after the upgrade can be

两个中国人在这说英语,难为你了哈哈哈哈

兄弟,我还有个问题 image 我生成.d.ts文件的时候全红,咋解决

https://staging-cn.vuejs.org/guide/extras/reactivity-transform.html#explicit-opt-in 看文档就行了,我webstorm和vscode都能正常识别,或者你vue版本低了?

avatar
Jun 17th 2022

我不是显示有问题,我显示也正确,我是把这ts文件编译一份.d.ts文件报错了

avatar
Jun 17th 2022

我不是显示有问题,我显示也正确,我是把这ts文件编译一份.d.ts文件报错了

那我就不清楚了。。。