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): Use alternative Omit that enables discriminated unions in props #9336

Merged
merged 4 commits into from
Aug 2, 2024

Conversation

davidmatter
Copy link
Contributor

This resolves #9335

We use an alternative Omit that doesn't break discriminated unions when using withDefaults. More information can be found here: microsoft/TypeScript#31501

@vercel
Copy link

vercel bot commented Oct 4, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
sfc-playground ✅ Ready (Inspect) Visit Preview Oct 4, 2023 8:55am

@github-actions
Copy link

github-actions bot commented Oct 13, 2023

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

@pikax
Copy link
Member

pikax commented Oct 13, 2023

@davidmatter looks good, but wondering why there's changes on the import order, can you rollback changes on the order please

@pikax pikax added scope: types 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. labels Oct 13, 2023
@davidmatter
Copy link
Contributor Author

@pikax thanks, rolled back the import ordering

@davidmatter
Copy link
Contributor Author

@pikax The pendant fix in language tools has been merged in vuejs/language-tools#3672. Would be cool if this one could be merged too. Thanks!

@davidmatter
Copy link
Contributor Author

@pikax do you know when this one will be merged?

@skirtles-code
Copy link
Contributor

It looks like this may have been fixed by another PR, #10596.

The fixes look fairly different and my TS knowledge isn't good enough to assess the differences between them. Is there any benefit to pursuing the approach in this PR over what's currently on main?

@davidmatter
Copy link
Contributor Author

According to the ts team #10596 is the way to go. Not sure if there are any important differences for this usecase between my proposal of

type OmitKeepDiscriminatedUnion<T, K extends keyof any> = T extends any ? Pick<T, Exclude<keyof T, K>> : never

and the one in #10596

type MappedOmit<T, K extends keyof any> = { [P in keyof T as P extends K ? never : P]: T[P] }

Feel free to either close this one or, IMO even better, we could just merge my testcase without the Omit helper as it specifically tests the usage of discriminated unions.

@yyx990803 yyx990803 merged commit 2a29a71 into vuejs:main Aug 2, 2024
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. scope: types
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

withDefaults disables the use of discriminated unions (only in scripts, not in templates)
4 participants