From bcfe480d75d822111c0d3e5fcbc7e10e073d53dc Mon Sep 17 00:00:00 2001 From: Travis Date: Tue, 8 Nov 2022 11:09:15 +0800 Subject: [PATCH] fix(compiler-core/v-on): support inline handler with return type annotation (#6769) fix #6378 --- .../__tests__/transforms/vOn.spec.ts | 15 +++++++++++++++ packages/compiler-core/src/transforms/vOn.ts | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/compiler-core/__tests__/transforms/vOn.spec.ts b/packages/compiler-core/__tests__/transforms/vOn.spec.ts index 8f943a7491f..4ed9ea23a82 100644 --- a/packages/compiler-core/__tests__/transforms/vOn.spec.ts +++ b/packages/compiler-core/__tests__/transforms/vOn.spec.ts @@ -271,6 +271,21 @@ describe('compiler: transform v-on', () => { }) }) + test('should NOT wrap as function if expression is already function expression (with Typescript)', () => { + const { node } = parseWithVOn(`
`) + expect((node.codegenNode as VNodeCall).props).toMatchObject({ + properties: [ + { + key: { content: `onClick` }, + value: { + type: NodeTypes.SIMPLE_EXPRESSION, + content: `(e: any): any => foo(e)` + } + } + ] + }) + }) + test('should NOT wrap as function if expression is already function expression (with newlines)', () => { const { node } = parseWithVOn( `