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

types(defineProps): remove optional properties from type #6421

Merged
merged 5 commits into from
Nov 9, 2023

Conversation

pikax
Copy link
Member

@pikax pikax commented Aug 7, 2022

fixes #6420

I haven't tested this on an actual repo.

When we use defineProps<{ a?:string}> it will create a type { a?: string } which is not correct for the vue props context, since if a property is declared the key will always be present, a more accurate representation of the type is { a: string | undefined }, this PR does that.

@netlify
Copy link

netlify bot commented Aug 7, 2022

Deploy Preview for vuejs-coverage failed.

Name Link
🔨 Latest commit 43065b5
🔍 Latest deploy log https://app.netlify.com/sites/vuejs-coverage/deploys/62efd0f4eb1fea0009152167

@Justineo
Copy link
Member

Justineo commented Aug 7, 2022

Maybe related: #6244

# Conflicts:
#	packages/runtime-core/src/apiSetupHelpers.ts
#	packages/shared/src/typeUtils.ts
#	test-dts/setupHelpers.test-d.ts
@github-actions
Copy link

github-actions bot commented Oct 6, 2023

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 86.4 kB 32.9 kB 29.6 kB
vue.global.prod.js 132 kB 49.6 kB 44.5 kB

Usages

Name Size Gzip Brotli
createApp 48 kB 18.9 kB 17.3 kB
createSSRApp 51.1 kB 20.1 kB 18.4 kB
defineCustomElement 50.3 kB 19.7 kB 17.9 kB
overall 61.3 kB 23.7 kB 21.6 kB

@pikax pikax marked this pull request as ready for review October 6, 2023 13:49
@pikax pikax requested a review from sxzz October 6, 2023 13:49
@sxzz sxzz added the ready to merge The PR is ready to be merged. label Oct 6, 2023
@yyx990803 yyx990803 merged commit 94c049d into main Nov 9, 2023
15 checks passed
@yyx990803 yyx990803 deleted the types_defineProps_remove_optional_properties branch November 9, 2023 06:52
DrJume added a commit to DrJume/vuejs-core that referenced this pull request Dec 5, 2023
…gn with type declaration

* add tests for Extract*PropTypes

ref: vuejs#6421
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge The PR is ready to be merged. scope: types
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

ref returned by toRefs(props) have type Ref<X | undefined> | undefined
4 participants