From: webfansplz <308241863@qq.com> Date: Sun, 5 Sep 2021 22:13:12 +0000 (+0800) Subject: fix(compile-sfc): support `Date` prop type with defineProps (#4519) X-Git-Tag: v3.2.9~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fac9a2926d5b825b7daacb7914fd3b34abc02cb7;p=thirdparty%2Fvuejs%2Fcore.git fix(compile-sfc): support `Date` prop type with defineProps (#4519) --- diff --git a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap index 4292327ca6..54591d402b 100644 --- a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap +++ b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap @@ -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 }, diff --git a/packages/compiler-sfc/__tests__/compileScript.spec.ts b/packages/compiler-sfc/__tests__/compileScript.spec.ts index 086a2bcf28..854357b639 100644 --- a/packages/compiler-sfc/__tests__/compileScript.spec.ts +++ b/packages/compiler-sfc/__tests__/compileScript.spec.ts @@ -678,6 +678,7 @@ const emit = defineEmits(['a', 'b']) fn: (n: number) => void functionRef: Function objectRef: Object + dateTime: Date array: string[] arrayRef: Array tuple: [number, number] @@ -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 }`) @@ -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, diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index 7d8acc6797..523efd724d 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -1515,6 +1515,7 @@ function inferRuntimeType( case 'Map': case 'WeakSet': case 'WeakMap': + case 'Date': return [node.typeName.name] case 'Record': case 'Partial':