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

fix(types/withDefaults): ensure default values of type any do not include undefined #11490

Merged
merged 1 commit into from
Aug 5, 2024

Conversation

jh-leong
Copy link
Member

@jh-leong jh-leong commented Aug 4, 2024

In some edge cases, casting type with any is helpful when using withDefaults. However, currently, when the default values have any casting, it incorrectly includes the undefined type.

const _ = <T extends string>() => {
  const props = withDefaults(defineProps<{ foo?: T }>(), { foo: 'bar' as any })

  // before: T | NotUndefined<T> | undefined
  // after: NotUndefined<T>
  props.foo
}```

Copy link

github-actions bot commented Aug 4, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 90.1 kB 34.5 kB 31.1 kB
vue.global.prod.js 147 kB 54 kB 48 kB

Usages

Name Size Gzip Brotli
createApp 49.6 kB 19.5 kB 17.8 kB
createSSRApp 53.2 kB 20.9 kB 19.1 kB
defineCustomElement 51.9 kB 20.2 kB 18.5 kB
overall 63.1 kB 24.5 kB 22.3 kB

@jh-leong jh-leong changed the title fix(withDefaults/types): ensure default values of type any do not include undefined fix(types/withDefaults): ensure default values of type any do not include undefined Aug 5, 2024
@yyx990803 yyx990803 merged commit 4592b63 into vuejs:main Aug 5, 2024
11 checks passed
@jh-leong jh-leong deleted the fix/withDefaults branch August 5, 2024 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants