Skip to content
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

Ref sugar type error #4433

Closed
sxzz opened this issue Aug 25, 2021 · 8 comments
Closed

Ref sugar type error #4433

sxzz opened this issue Aug 25, 2021 · 8 comments

Comments

@sxzz
Copy link
Member

sxzz commented Aug 25, 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.

@sxzz
Copy link
Member Author

sxzz commented Aug 25, 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);

@orziz
Copy link

orziz commented Aug 25, 2021

image
image

@liuzw2579
Copy link

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

@modularcoder
Copy link

@orziz yes, same for me, seems the

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

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

@zhuchentong
Copy link

@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

@aphex
Copy link

aphex commented Sep 1, 2021

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

@orziz
Copy link

orziz commented Sep 2, 2021

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

@sxzz
Copy link
Member Author

sxzz commented Sep 2, 2021

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

@github-actions github-actions bot locked and limited conversation to collaborators Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants