Subscribe on changes!

props with default values

avatar
Nov 16th 2022

What problem does this feature solve?

the props with default values need a method withDefaults to wrap it, which I think not good. chain call, currying may be better?

What does the proposed API look like?

const props = defineProps<{
  title: string;
  count?: number;
}>()({
  count: 0,
}); // may be the inside is still call the withDefaults
const props = defineProps<{
  title: string;
  count?: number;
}>().defaults({
  count: 0,
}); // call else
avatar
Nov 16th 2022

This has been discussed extensively in RFCs - neither can be done without type-related issues.

We will likely recommend using Reactive Transform in the future with reactive props destructure.