From: 三咲智子 Kevin Deng Date: Mon, 14 Nov 2022 01:15:17 +0000 (+0800) Subject: refactor(compiler-sfc): drop Function prop type when no static default value (#7125) X-Git-Tag: v3.2.46~85 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4e5d9cdb8280f82c40ea3f01b1f0a13ac2908aff;p=thirdparty%2Fvuejs%2Fcore.git refactor(compiler-sfc): drop Function prop type when no static default value (#7125) --- diff --git a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap index b167dea702..ae42d6f87b 100644 --- a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap +++ b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap @@ -1784,6 +1784,29 @@ const props = __props as { foo: string, bar?: number, baz: boolean, qux(): numbe +return { props } +} + +})" +`; + +exports[`SFC compile + `, + { isProd: true } + ) + assertCode(content) + expect(content).toMatch(`const props = __props`) + + // foo has no default value, the Function can be dropped + expect(content).toMatch(`foo: null`) + expect(content).toMatch(`bar: { type: Boolean }`) + expect(content).toMatch( + `baz: { type: [Boolean, Function], default: true }` + ) + expect(content).toMatch(`qux: { default: 'hi' }`) + }) + test('withDefaults (dynamic)', () => { const { content } = compile(`