core icon indicating copy to clipboard operation
core copied to clipboard

fix(runtime-core): merge return value when there is undefined value in `withDefaults`

Open godxiaoji opened this issue 2 years ago • 1 comments

From #7619, increase the judgment of undefined value in withDefaults.

At the same time, according to the requirements of the document, ensures the returned props type has the optional flags removed for properties.

const res = withDefaults(
  defineProps<{
    str?: string;
    bool: boolean;
  }>(),
  {
    str: undefined,
    bool: undefined
  }
);

// res.str: string | undefined
// res.bool: boolean | undefined

godxiaoji avatar Feb 04 '23 03:02 godxiaoji