Subscribe on changes!

Ref sugar type error

avatar
Aug 25th 2021

Version

3.2.6

Reproduction link

SFC Playground

Steps to reproduce

Copy to VSCode and enable Volar

What is expected?

fix this error

What is actually happening?

type RefValue<T> = T & { [RefMarker]?: any };

If & { [RefMarker]?: any }; is removed, the issue is just fixed.


By the way I added ref types, but it doesn't working. node_modules/vue/ref-macros.d.ts seems doesn't exist.

avatar
Aug 25th 2021

Another problem:

import { ref } from 'vue';

let ref1 = $(ref()); // any
let ref2 = $ref();
// {
//   [RefMarker]?: any;
// }

ref1 = 'hello world';
ref2 = 'hello world';
// 类型“"hello world"”与类型“{ [RefMarker]?: any; }”不具有相同的属性。ts(2559)

console.log(ref1, ref2);
avatar
Aug 25th 2021

image image

avatar
Aug 26th 2021

because 'vue-next/packages/vue/package.json' files not includes 'ref-macros.d.ts', so npm store not have this file

avatar
Aug 27th 2021

@orziz yes, same for me, seems the

/// <reference types="vue/ref-macros" />

in env.d.ts doesn't fix TS errors

avatar
Aug 30th 2021

@orziz yes, same for me, seems the

/// <reference types="vue/ref-macros" />

in env.d.ts doesn't fix TS errors

same problem,the file is hasn't export ,but you can copy from https://github.com/vuejs/vue-next/blob/master/packages/vue/ref-macros.d.ts and create ref-macros.d.ts file in local

avatar
Sep 1st 2021

Seeing the same thing as @zct1989, no ref-macros anywhere in node_modules manually adding the file myself clears everything up.

avatar
Sep 2nd 2021

updated to v3.2.7, but this issues is still not fixed.

avatar
Sep 2nd 2021

Hi, @yyx990803 Sorry to disturb you, but the type of problem I mentioned above doesn't seem to be fixed.