diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index cca7fbcd..924f40a7 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -109,10 +109,10 @@ type InferPropType = [T] extends [null] ? boolean : [T] extends [DateConstructor | { type: DateConstructor }] ? Date - : [T] extends [ - (DateConstructor | infer U)[] | { type: (DateConstructor | infer U)[] } - ] - ? Date | InferPropType + : [T] extends [(infer U)[] | { type: (infer U)[] }] + ? U extends DateConstructor + ? Date | InferPropType + : InferPropType : [T] extends [Prop] ? unknown extends V ? D diff --git a/test-dts/defineComponent.test-d.tsx b/test-dts/defineComponent.test-d.tsx index fb50648b..8604f8e9 100644 --- a/test-dts/defineComponent.test-d.tsx +++ b/test-dts/defineComponent.test-d.tsx @@ -44,6 +44,7 @@ describe('with object props', () => { date?: Date l?: Date ll?: Date | number + lll?: string | number } type GT = string & { __brand: unknown } @@ -135,7 +136,8 @@ describe('with object props', () => { }, date: Date, l: [Date], - ll: [Date, Number] + ll: [Date, Number], + lll: [String, Number] }, setup(props) { // type assertion. See https://github.com/SamVerschueren/tsd @@ -170,6 +172,7 @@ describe('with object props', () => { expectType(props.date) expectType(props.l) expectType(props.ll) + expectType(props.lll) // @ts-expect-error props should be readonly expectError((props.a = 1))