diff --git a/packages-private/dts-test/setupHelpers.test-d.ts b/packages-private/dts-test/setupHelpers.test-d.ts index 7b5d6f147f0..2d6f1d3fc9f 100644 --- a/packages-private/dts-test/setupHelpers.test-d.ts +++ b/packages-private/dts-test/setupHelpers.test-d.ts @@ -20,7 +20,8 @@ describe('defineProps w/ type declaration', () => { // type declaration const props = defineProps<{ foo: string - bool?: boolean + bool: boolean + boolOptional?: boolean boolAndUndefined: boolean | undefined file?: File | File[] }>() @@ -30,15 +31,22 @@ describe('defineProps w/ type declaration', () => { props.bar expectType(props.bool) - expectType(props.boolAndUndefined) + expectType(props.boolOptional) + expectType(props.boolAndUndefined) }) describe('defineProps w/ generics', () => { function test() { - const props = defineProps<{ foo: T; bar: string; x?: boolean }>() + const props = defineProps<{ + foo: T + bar: string + x: boolean + xOptional?: boolean + }>() expectType(props.foo) expectType(props.bar) expectType(props.x) + expectType(props.xOptional) } test() }) diff --git a/packages/runtime-core/src/apiSetupHelpers.ts b/packages/runtime-core/src/apiSetupHelpers.ts index 54712c6807a..c96e54a84f4 100644 --- a/packages/runtime-core/src/apiSetupHelpers.ts +++ b/packages/runtime-core/src/apiSetupHelpers.ts @@ -94,7 +94,7 @@ export function defineProps() { } export type DefineProps = Readonly & { - readonly [K in BKeys]-?: boolean + readonly [K in BKeys]-?: T[K] } type BooleanKey = K extends any