From 83f7e6f8a688e823274379fe79f58b90ea58892d Mon Sep 17 00:00:00 2001 From: edison Date: Wed, 26 Oct 2022 16:44:30 +0800 Subject: [PATCH] fix(compiler-sfc): support using extends interface with defineProps() (#4512) fix #4498 --- .../__snapshots__/compileScript.spec.ts.snap | 27 +++++ .../__tests__/compileScript.spec.ts | 25 ++++ packages/compiler-sfc/src/compileScript.ts | 109 ++++++++++++++---- 3 files changed, 141 insertions(+), 20 deletions(-) diff --git a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap index b7fc9304b26..aa5e2d04926 100644 --- a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap +++ b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap @@ -1467,6 +1467,33 @@ export default /*#__PURE__*/_defineComponent({ +return { } +} + +})" +`; + +exports[`SFC compile + + `) + assertCode(content) + expect(content).toMatch(`z: { type: Number, required: true }`) + expect(content).toMatch(`y: { type: String, required: true }`) + expect(content).toMatch(`x: { type: Number, required: false }`) + expect(bindings).toStrictEqual({ + x: BindingTypes.PROPS, + y: BindingTypes.PROPS, + z: BindingTypes.PROPS + }) + }) + test('defineProps w/ exported interface', () => { const { content, bindings } = compile(`