Skip to content

Conversation

@davidmatter
Copy link
Collaborator

@davidmatter davidmatter commented Oct 16, 2023

This fixes vuejs/core#9381

Like the fix in vue/core vuejs/core#9336 we use an alternative Omit that doesn't break discriminated unions in props. More information can be found here: microsoft/TypeScript#31501

Comment on lines 380 to 385
codes.push(
`type OmitKeepDiscriminatedUnion<T, K extends keyof any> = T extends any`,
`? Pick<T, Exclude<keyof T, K>>
: never`,
`;\n`,
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this could be defined in https://github.com/vuejs/language-tools/blob/master/packages/vue-language-core/src/utils/globalTypes.ts since it doesn't depend on any dynamic code.

(I'm not super familiar with this project so you might wait for confirmation on that)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, thanks. Done

@johnsoncodehk
Copy link
Member

LGTM, thanks!

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.

Types: type narrowing not work in parent component when child component use union type to defineProps

3 participants