Skip to content

Commit

Permalink
fix(compile-sfc): support Date prop type with defineProps (#4519)
Browse files Browse the repository at this point in the history
  • Loading branch information
webfansplz authored Sep 5, 2021
1 parent 14d6518 commit fac9a29
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ export default /*#__PURE__*/_defineComponent({
fn: { type: Function, required: true },
functionRef: { type: Function, required: true },
objectRef: { type: Object, required: true },
dateTime: { type: Date, required: true },
array: { type: Array, required: true },
arrayRef: { type: Array, required: true },
tuple: { type: Array, required: true },
Expand Down
3 changes: 3 additions & 0 deletions packages/compiler-sfc/__tests__/compileScript.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ const emit = defineEmits(['a', 'b'])
fn: (n: number) => void
functionRef: Function
objectRef: Object
dateTime: Date
array: string[]
arrayRef: Array<any>
tuple: [number, number]
Expand Down Expand Up @@ -706,6 +707,7 @@ const emit = defineEmits(['a', 'b'])
expect(content).toMatch(`fn: { type: Function, required: true }`)
expect(content).toMatch(`functionRef: { type: Function, required: true }`)
expect(content).toMatch(`objectRef: { type: Object, required: true }`)
expect(content).toMatch(`dateTime: { type: Date, required: true }`)
expect(content).toMatch(`array: { type: Array, required: true }`)
expect(content).toMatch(`arrayRef: { type: Array, required: true }`)
expect(content).toMatch(`tuple: { type: Array, required: true }`)
Expand Down Expand Up @@ -737,6 +739,7 @@ const emit = defineEmits(['a', 'b'])
fn: BindingTypes.PROPS,
functionRef: BindingTypes.PROPS,
objectRef: BindingTypes.PROPS,
dateTime: BindingTypes.PROPS,
array: BindingTypes.PROPS,
arrayRef: BindingTypes.PROPS,
tuple: BindingTypes.PROPS,
Expand Down
1 change: 1 addition & 0 deletions packages/compiler-sfc/src/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,7 @@ function inferRuntimeType(
case 'Map':
case 'WeakSet':
case 'WeakMap':
case 'Date':
return [node.typeName.name]
case 'Record':
case 'Partial':
Expand Down

0 comments on commit fac9a29

Please sign in to comment.