diff --git a/packages-private/dts-test/setupHelpers.test-d.ts b/packages-private/dts-test/setupHelpers.test-d.ts index aeab4f9b997..7b5d6f147f0 100644 --- a/packages-private/dts-test/setupHelpers.test-d.ts +++ b/packages-private/dts-test/setupHelpers.test-d.ts @@ -58,9 +58,6 @@ describe('defineProps w/ type declaration + withDefaults', (), { number: 123, @@ -91,13 +88,6 @@ describe('defineProps w/ type declaration + withDefaults', (res.bool) expectType(res.boolAndUndefined) - - if (res.u.type === 'button') { - expectType<'submit' | undefined>(res.u.buttonType) - } - if (res.u.type === 'link') { - expectType(res.u.href) - } }) describe('defineProps w/ union type declaration + withDefaults', () => { @@ -250,6 +240,23 @@ describe('withDefaults w/ defineProp type is different from the defaults type', res1.value }) +describe('withDefaults w/ defineProp discriminate union type', () => { + const props = withDefaults( + defineProps< + { type: 'button'; buttonType?: 'submit' } | { type: 'link'; href: string } + >(), + { + type: 'button', + }, + ) + if (props.type === 'button') { + expectType<'submit' | undefined>(props.buttonType) + } + if (props.type === 'link') { + expectType(props.href) + } +}) + describe('defineProps w/ runtime declaration', () => { // runtime declaration const props = defineProps({