Replies: 3 comments 6 replies
-
Firstly, I disagree with the following:
I think reserving the However, I like the idea of a The main con I see is the ergonomics of TypeScript types-driven definitions, currently supported by |
Beta Was this translation helpful? Give feedback.
-
On principle, I am all for consistency and good naming. It's often the fine details that are hard and I think your proposal needs some refining.
I think it's generally (not specifically for Vue) understood that
The opposite is true, though.
Maybe "something like" but please not
How does
Ok. You make a big deal out of this. In fact, do you think devs need to know whether
I'm afraid it can't. How do you put Also your proposal need to consider that unlike others,
I'd appreciate if Vue didn't take the meaning of stable too lightly. Some people waited for script-setup to become stable before using it in large, important projects, specifically to avoid having to refactor their code if the experimental API changed. |
Beta Was this translation helpful? Give feedback.
-
For what it's worth, I think that, if "something like const { foo, bar } = $props({ ... }) should not compile to the equivalent to const { foo, bar } = defineProps({ ... }) // ⚠️ reactivity lost but instead compile to something like import { toRefs as __toRefs } from 'vue'
const __props = defineProps({ ... })
const { foo, bar } = $(__toRefs(__props)) so it's consistent with Ref Sugar mental model i.e. |
Beta Was this translation helpful? Give feedback.
-
Problems
defineProps
anddefineEmits
come from. They are compiler macros, but don't have a common prefix like the ref sugar functions have.name
,inheritAttrs
, etc.) requires the use of an additionalsetup
block, which doesn't seem ideal.define*
functions, they may be mixed, with other code between them.Potential solution
Give all compiler macros a
$
prefix. If you see a$
, it's usually soft-reserved for framework functionality.defineProps
might be replaced by something like$props
, however this doesn't solve problem 3. Instead, consider a single compiler macro for component options:$vue
is unimportant in this example, it could be something else like$component
or$options
.emits
.slots
andattrs
.Benefits
$
). You learn this once.defineProps
,defineEmits
,defineExpose
, andwithDefaults
– with the above solution, the API is reduced to a single macro.Syntax
The exact syntax is less important than the goals – to make things more consistent and cohesive.
FAQ
define*
is stable API now, we can't change it.-> It can be deprecated later.
I don't like
$
, it looks like jQuery.-> No, it looks like (new) Vue.js 🙃. This symbol is already being used for the ref sugar.
Beta Was this translation helpful? Give feedback.
All reactions