Skip to content

Commit fac9a29

Browse files
authored
fix(compile-sfc): support Date prop type with defineProps (#4519)
1 parent 14d6518 commit fac9a29

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,7 @@ export default /*#__PURE__*/_defineComponent({
947947
fn: { type: Function, required: true },
948948
functionRef: { type: Function, required: true },
949949
objectRef: { type: Object, required: true },
950+
dateTime: { type: Date, required: true },
950951
array: { type: Array, required: true },
951952
arrayRef: { type: Array, required: true },
952953
tuple: { type: Array, required: true },

packages/compiler-sfc/__tests__/compileScript.spec.ts

+3
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ const emit = defineEmits(['a', 'b'])
678678
fn: (n: number) => void
679679
functionRef: Function
680680
objectRef: Object
681+
dateTime: Date
681682
array: string[]
682683
arrayRef: Array<any>
683684
tuple: [number, number]
@@ -706,6 +707,7 @@ const emit = defineEmits(['a', 'b'])
706707
expect(content).toMatch(`fn: { type: Function, required: true }`)
707708
expect(content).toMatch(`functionRef: { type: Function, required: true }`)
708709
expect(content).toMatch(`objectRef: { type: Object, required: true }`)
710+
expect(content).toMatch(`dateTime: { type: Date, required: true }`)
709711
expect(content).toMatch(`array: { type: Array, required: true }`)
710712
expect(content).toMatch(`arrayRef: { type: Array, required: true }`)
711713
expect(content).toMatch(`tuple: { type: Array, required: true }`)
@@ -737,6 +739,7 @@ const emit = defineEmits(['a', 'b'])
737739
fn: BindingTypes.PROPS,
738740
functionRef: BindingTypes.PROPS,
739741
objectRef: BindingTypes.PROPS,
742+
dateTime: BindingTypes.PROPS,
740743
array: BindingTypes.PROPS,
741744
arrayRef: BindingTypes.PROPS,
742745
tuple: BindingTypes.PROPS,

packages/compiler-sfc/src/compileScript.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,7 @@ function inferRuntimeType(
15151515
case 'Map':
15161516
case 'WeakSet':
15171517
case 'WeakMap':
1518+
case 'Date':
15181519
return [node.typeName.name]
15191520
case 'Record':
15201521
case 'Partial':

0 commit comments

Comments
 (0)