fix(compile-sfc): support Date prop type with defineProps (#4519)

This commit is contained in:
webfansplz 2021-09-06 06:13:12 +08:00 committed by GitHub
parent 14d65181f1
commit fac9a2926d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 0 deletions

View File

@ -947,6 +947,7 @@ export default /*#__PURE__*/_defineComponent({
fn: { type: Function, required: true }, fn: { type: Function, required: true },
functionRef: { type: Function, required: true }, functionRef: { type: Function, required: true },
objectRef: { type: Object, required: true }, objectRef: { type: Object, required: true },
dateTime: { type: Date, required: true },
array: { type: Array, required: true }, array: { type: Array, required: true },
arrayRef: { type: Array, required: true }, arrayRef: { type: Array, required: true },
tuple: { type: Array, required: true }, tuple: { type: Array, required: true },

View File

@ -678,6 +678,7 @@ const emit = defineEmits(['a', 'b'])
fn: (n: number) => void fn: (n: number) => void
functionRef: Function functionRef: Function
objectRef: Object objectRef: Object
dateTime: Date
array: string[] array: string[]
arrayRef: Array<any> arrayRef: Array<any>
tuple: [number, number] tuple: [number, number]
@ -706,6 +707,7 @@ const emit = defineEmits(['a', 'b'])
expect(content).toMatch(`fn: { type: Function, required: true }`) expect(content).toMatch(`fn: { type: Function, required: true }`)
expect(content).toMatch(`functionRef: { type: Function, required: true }`) expect(content).toMatch(`functionRef: { type: Function, required: true }`)
expect(content).toMatch(`objectRef: { type: Object, 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(`array: { type: Array, required: true }`)
expect(content).toMatch(`arrayRef: { type: Array, required: true }`) expect(content).toMatch(`arrayRef: { type: Array, required: true }`)
expect(content).toMatch(`tuple: { type: Array, required: true }`) expect(content).toMatch(`tuple: { type: Array, required: true }`)
@ -737,6 +739,7 @@ const emit = defineEmits(['a', 'b'])
fn: BindingTypes.PROPS, fn: BindingTypes.PROPS,
functionRef: BindingTypes.PROPS, functionRef: BindingTypes.PROPS,
objectRef: BindingTypes.PROPS, objectRef: BindingTypes.PROPS,
dateTime: BindingTypes.PROPS,
array: BindingTypes.PROPS, array: BindingTypes.PROPS,
arrayRef: BindingTypes.PROPS, arrayRef: BindingTypes.PROPS,
tuple: BindingTypes.PROPS, tuple: BindingTypes.PROPS,

View File

@ -1515,6 +1515,7 @@ function inferRuntimeType(
case 'Map': case 'Map':
case 'WeakSet': case 'WeakSet':
case 'WeakMap': case 'WeakMap':
case 'Date':
return [node.typeName.name] return [node.typeName.name]
case 'Record': case 'Record':
case 'Partial': case 'Partial':