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: type narrowing not work in parent component when child component use union type to defineProps #9381

Closed
zjtakato opened this issue Oct 12, 2023 · 2 comments · Fixed by vuejs/language-tools#3672

Comments

@zjtakato
Copy link

zjtakato commented Oct 12, 2023

Vue version

3.3.4

Link to minimal reproduction

https://play.vuejs.org/#eNqNUk1v1DAQ/SuWLwWpGx/KKYRSQD2UA1SUG+YQ4snWxV+yx9tFZf87Y0e7DemHeoniN/PevPm44x9CaDYZeMu7NEQdkCXAHE6lk07b4COyT96yMdJH8kbQoxIkLxnSDd4lZFv2TvKkxqQmvBOTWJXpEGwwPQK9uiLG8E+AQgADA0rONr3JBaBfUZLEgcGPOSaqMep1c5O8I5930jGyMpARbSB+DajJg+Qtq5ES643xt58rhjHD8R4frmH4/Qh+k7YFk/wyQoK4oe4OMezjGshkCZ9ffYEt/R+C1qtsKPuZ4DdI3uTicUr7mJ0i27O86vaizlq79fd0vkVwad9UMVoydzVfcpp92cFTrd/bPWlOKk+6HU1xv7flopnp3ZpGjyRDo9cOIY79AOzChYyX0Yc0iZedvW/ZkS740dsC1bW1LGEk34RQqXv+VV3uQoD409IfEfjxc5JQMGoHldjNTPydK56+ek3Jz17a8oymY17ZPiwOaQr8P8V64GVb14ghtUIMyhFNgdGb2DhA4YIVZ5QmYnaoLayUt2c08uaNUDrhHG4g2dWv6G/ptEhktvnCr/cWVxGo8Vju4mVlF7R56UXoQfnDVez+AfyVXwE=

Steps to reproduce

If type prop is 'select', value should just a 'String[]', but it allow 'String | String[]'.

In React, it is expected.

image

What is expected?

Type narrowing should work

What is actually happening?

Type narrowing not work

System Info

No response

Any additional comments?

No response

@pikax
Copy link
Member

pikax commented Oct 16, 2023

I believe this is caused by the language service not by vue core

/cc @johnsoncodehk

@davidmatter
Copy link
Contributor

@pikax @johnsoncodehk same as #9336. Fixed in vuejs/language-tools#3672

@github-actions github-actions bot locked and limited conversation to collaborators Nov 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants