From 04cbabb35b0a6e585ca10e0906d160eeaa11cf00 Mon Sep 17 00:00:00 2001 From: Thimo Date: Tue, 26 Mar 2024 10:14:56 +0100 Subject: [PATCH 1/2] fix(runtime-core): object unions no longer get merged --- packages/dts-test/setupHelpers.test-d.ts | 35 ++++++++++++++++++++ packages/runtime-core/src/apiSetupHelpers.ts | 5 ++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/packages/dts-test/setupHelpers.test-d.ts b/packages/dts-test/setupHelpers.test-d.ts index c749e80a5c7..883ebe6b254 100644 --- a/packages/dts-test/setupHelpers.test-d.ts +++ b/packages/dts-test/setupHelpers.test-d.ts @@ -102,6 +102,41 @@ describe('defineProps w/ union type declaration + withDefaults', () => { ) }) +describe('defineProps w/ object union + withDefaults', () => { + const props = withDefaults( + defineProps< + { + foo: string + } & ( + | { + type: 'hello' + bar: string + } + | { + type: 'world' + bar: number + } + ) + >(), + { + foo: 'default value!', + }, + ) + + expectType< + | { + readonly type: 'hello' + readonly bar: string + readonly foo: string + } + | { + readonly type: 'world' + readonly bar: number + readonly foo: string + } + >(props) +}) + describe('defineProps w/ generic type declaration + withDefaults', = T extends undefined ? never : T +type MappedOmit = { + [P in keyof T as P extends K ? never : P]: T[P] +} type InferDefaults = { [K in keyof T]?: InferDefault @@ -299,7 +302,7 @@ type PropsWithDefaults< T, Defaults extends InferDefaults, BKeys extends keyof T, -> = Readonly> & { +> = Readonly> & { readonly [K in keyof Defaults]-?: K extends keyof T ? Defaults[K] extends undefined ? T[K] From 4c1e8361b03f13279632bbbebbde60f55e044f53 Mon Sep 17 00:00:00 2001 From: Thimo Date: Tue, 26 Mar 2024 20:34:30 +0100 Subject: [PATCH 2/2] chore: retrigger ci