Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Script refs #214

Closed
wants to merge 2 commits into from
Closed

Script refs #214

wants to merge 2 commits into from

Conversation

johnsoncodehk
Copy link
Member

We understand that most users accept the use of .value, but we still hope that we can have some solution for users who do not like .value.

Rendered: 中文 | English

If you want to try:
<script refs> requires additional IDE support, I implemented it in another Vue Language Service plugin
For the preview you don't need to compile, but if you want, you can use @cereschen webpack plugin

@jods4
Copy link

jods4 commented Sep 27, 2020

How does that work with imported functions?
How does the compiler know if the function wants a raw value or a ref?

import { square } from "./math.js";
ref x = 3
// What is passed to square? A ref or a number? 
// Both options are common, how can we have the opposite behavior?
square(x)

@johnsoncodehk
Copy link
Member Author

johnsoncodehk commented Sep 27, 2020

How does that work with imported functions?
How does the compiler know if the function wants a raw value or a ref?

import { square } from "./math.js";
ref x = 3
// What is passed to square? A ref or a number? 
// Both options are common, how can we have the opposite behavior?
square(x)

You can't, ref will alway transform to raw value and pass to function: https://github.com/cereschen/rfcs/blob/script-refs/active-rfcs/0000-sfc-script-refs.md#dont-transform
Before we has this feature: https://github.com/cereschen/rfcs/blob/956e74288552b699dafd83f0706430f86c11e0fb/active-rfcs/0000-sfc-script-no-ref.md#dont-transform
In order to reduce the magic, it was removed, welcome any good idea. :)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants