Skip to content

Commit c14f1d4

Browse files
committed
chore: should removed
1 parent adb0f93 commit c14f1d4

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

packages/compiler-vapor/__tests__/transforms/__snapshots__/vOn.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ _delegateEvents("click")
130130
131131
export function render(_ctx, $props, $emit, $attrs, $slots) {
132132
const n0 = t0()
133-
n0.$evtclick = e => (_ctx.handleClick as any)(e)
133+
n0.$evtclick = e => _ctx.handleClick(e)
134134
return n0
135135
}"
136136
`;

packages/compiler-vapor/__tests__/transforms/vOn.spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -684,12 +684,15 @@ describe('v-on', () => {
684684
})
685685

686686
test('expression with type', () => {
687-
const { code } = compileWithVOn(`<div @click="handleClick as any"></div>`, {
688-
bindingMetadata: {
689-
handleClick: BindingTypes.SETUP_CONST,
687+
const { code } = compileWithVOn(
688+
`<div @click="(<number>handleClick as any)"></div>`,
689+
{
690+
bindingMetadata: {
691+
handleClick: BindingTypes.SETUP_CONST,
692+
},
690693
},
691-
})
694+
)
692695
expect(code).matchSnapshot()
693-
expect(code).include('n0.$evtclick = e => (_ctx.handleClick as any)(e)')
696+
expect(code).include('n0.$evtclick = e => _ctx.handleClick(e)')
694697
})
695698
})

packages/compiler-vapor/src/generators/expression.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ export function genExpression(
6565
let hasMemberExpression = false
6666
if (ids.length) {
6767
const [frag, push] = buildCodeFragment()
68-
const shouldWrap = ast && TS_NODE_TYPES.includes(ast.type)
69-
if (shouldWrap) push('(')
68+
const isTSNode = ast && TS_NODE_TYPES.includes(ast.type)
7069
ids
7170
.sort((a, b) => a.start! - b.start!)
7271
.forEach((id, i) => {
@@ -75,8 +74,10 @@ export function genExpression(
7574
const end = id.end! - 1
7675
const last = ids[i - 1]
7776

78-
const leadingText = content.slice(last ? last.end! - 1 : 0, start)
79-
if (leadingText.length) push([leadingText, NewlineType.Unknown])
77+
if (!(isTSNode && i === 0)) {
78+
const leadingText = content.slice(last ? last.end! - 1 : 0, start)
79+
if (leadingText.length) push([leadingText, NewlineType.Unknown])
80+
}
8081

8182
const source = content.slice(start, end)
8283
const parentStack = parentStackMap.get(id)!
@@ -103,11 +104,10 @@ export function genExpression(
103104
),
104105
)
105106

106-
if (i === ids.length - 1 && end < content.length) {
107+
if (i === ids.length - 1 && end < content.length && !isTSNode) {
107108
push([content.slice(end), NewlineType.Unknown])
108109
}
109110
})
110-
if (shouldWrap) push(')')
111111

112112
if (assignment && hasMemberExpression) {
113113
push(` = ${assignment}`)

0 commit comments

Comments
 (0)