Skip to content

Commit 11ec51a

Browse files
authored
Revert "fix(compiler-core): correctly handle ts type assertions in expression…" (#14062)
This reverts commit e6544ac. Close #14060
1 parent 5cf0097 commit 11ec51a

File tree

3 files changed

+4
-26
lines changed

3 files changed

+4
-26
lines changed

packages/compiler-core/__tests__/transforms/__snapshots__/transformExpressions.spec.ts.snap

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ return function render(_ctx, _cache, $props, $setup, $data, $options) {
1414
}"
1515
`;
1616

17-
exports[`compiler: expression transform > expression with type 1`] = `
18-
"const { openBlock: _openBlock, createElementBlock: _createElementBlock } = Vue
19-
20-
return function render(_ctx, _cache) {
21-
return (_openBlock(), _createElementBlock("div", {
22-
onClick: _ctx.handleClick
23-
}, null, 8 /* PROPS */, ["onClick"]))
24-
}"
25-
`;
26-
2717
exports[`compiler: expression transform > should allow leak of var declarations in for loop 1`] = `
2818
"const { openBlock: _openBlock, createElementBlock: _createElementBlock } = Vue
2919

packages/compiler-core/__tests__/transforms/transformExpressions.spec.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -754,12 +754,4 @@ describe('compiler: expression transform', () => {
754754
expect(code).toMatch(`_ctx.bar`)
755755
})
756756
})
757-
758-
test('expression with type', () => {
759-
const { code } = compile(
760-
`<div @click="(<number>handleClick as any)"></div>`,
761-
)
762-
expect(code).toMatch(`onClick: _ctx.handleClick`)
763-
expect(code).toMatchSnapshot()
764-
})
765757
})

packages/compiler-core/src/transforms/transformExpression.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
createSimpleExpression,
1919
} from '../ast'
2020
import {
21-
TS_NODE_TYPES,
2221
isInDestructureAssignment,
2322
isInNewExpression,
2423
isStaticProperty,
@@ -348,18 +347,15 @@ export function processExpression(
348347
// an ExpressionNode has the `.children` property, it will be used instead of
349348
// `.content`.
350349
const children: CompoundExpressionNode['children'] = []
351-
const isTSNode = TS_NODE_TYPES.includes(ast.type)
352350
ids.sort((a, b) => a.start - b.start)
353351
ids.forEach((id, i) => {
354352
// range is offset by -1 due to the wrapping parens when parsed
355353
const start = id.start - 1
356354
const end = id.end - 1
357355
const last = ids[i - 1]
358-
if (!(isTSNode && i === 0)) {
359-
const leadingText = rawExp.slice(last ? last.end - 1 : 0, start)
360-
if (leadingText.length || id.prefix) {
361-
children.push(leadingText + (id.prefix || ``))
362-
}
356+
const leadingText = rawExp.slice(last ? last.end - 1 : 0, start)
357+
if (leadingText.length || id.prefix) {
358+
children.push(leadingText + (id.prefix || ``))
363359
}
364360
const source = rawExp.slice(start, end)
365361
children.push(
@@ -376,7 +372,7 @@ export function processExpression(
376372
: ConstantTypes.NOT_CONSTANT,
377373
),
378374
)
379-
if (i === ids.length - 1 && end < rawExp.length && !isTSNode) {
375+
if (i === ids.length - 1 && end < rawExp.length) {
380376
children.push(rawExp.slice(end))
381377
}
382378
})

0 commit comments

Comments
 (0)