From: David Matter Date: Fri, 2 Aug 2024 03:45:23 +0000 (+0200) Subject: test(types): add test for generic discriminated unions in props (#9336) X-Git-Tag: v3.4.36~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a29a71d8ae2eabb4b57aee782dfb482ee914121;p=thirdparty%2Fvuejs%2Fcore.git test(types): add test for generic discriminated unions in props (#9336) --- diff --git a/packages/dts-test/setupHelpers.test-d.ts b/packages/dts-test/setupHelpers.test-d.ts index 883ebe6b25..729f9b97d0 100644 --- a/packages/dts-test/setupHelpers.test-d.ts +++ b/packages/dts-test/setupHelpers.test-d.ts @@ -137,6 +137,31 @@ describe('defineProps w/ object union + withDefaults', () => { >(props) }) +describe('defineProps w/ generic discriminate union + withDefaults', () => { + interface B { + b?: string + } + interface S extends B { + mode: 'single' + v: T + } + interface M extends B { + mode: 'multiple' + v: T[] + } + type Props = S | M + const props = withDefaults(defineProps(), { + b: 'b', + }) + + if (props.mode === 'single') { + expectType(props.v) + } + if (props.mode === 'multiple') { + expectType(props.v) + } +}) + describe('defineProps w/ generic type declaration + withDefaults',