From: linzhe <40790268+linzhe141@users.noreply.github.com> Date: Fri, 11 Oct 2024 02:51:57 +0000 (+0800) Subject: fix(compiler-sfc): do not skip TSInstantiationExpression when transforming props... X-Git-Tag: v3.5.12~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3ecde8a696ff62c8d0ab067fd1d7ee0565b63c5;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler-sfc): do not skip TSInstantiationExpression when transforming props destructure (#12064) --- diff --git a/packages/compiler-sfc/__tests__/compileScript/__snapshots__/definePropsDestructure.spec.ts.snap b/packages/compiler-sfc/__tests__/compileScript/__snapshots__/definePropsDestructure.spec.ts.snap index 12d5a67db7..1044b0e167 100644 --- a/packages/compiler-sfc/__tests__/compileScript/__snapshots__/definePropsDestructure.spec.ts.snap +++ b/packages/compiler-sfc/__tests__/compileScript/__snapshots__/definePropsDestructure.spec.ts.snap @@ -320,3 +320,22 @@ return { rest } }" `; + +exports[`sfc reactive props destructure > with TSInstantiationExpression 1`] = ` +"import { defineComponent as _defineComponent } from 'vue' +type Foo = (data: T) => void + +export default /*@__PURE__*/_defineComponent({ + props: { + value: { type: Function } + }, + setup(__props: any) { + + + const foo = __props.value<123> + +return () => {} +} + +})" +`; diff --git a/packages/compiler-sfc/__tests__/compileScript/definePropsDestructure.spec.ts b/packages/compiler-sfc/__tests__/compileScript/definePropsDestructure.spec.ts index 106e469f18..50602eb59b 100644 --- a/packages/compiler-sfc/__tests__/compileScript/definePropsDestructure.spec.ts +++ b/packages/compiler-sfc/__tests__/compileScript/definePropsDestructure.spec.ts @@ -198,6 +198,21 @@ describe('sfc reactive props destructure', () => { }`) }) + test('with TSInstantiationExpression', () => { + const { content } = compile( + ` + + `, + { isProd: true }, + ) + assertCode(content) + expect(content).toMatch(`const foo = __props.value<123>`) + }) + test('aliasing', () => { const { content, bindings } = compile(`