]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
Revert "fix(compiler-core): correctly handle ts type assertions in expression…" ...
authoredison <daiwei521@126.com>
Fri, 7 Nov 2025 00:52:07 +0000 (08:52 +0800)
committerGitHub <noreply@github.com>
Fri, 7 Nov 2025 00:52:07 +0000 (08:52 +0800)
This reverts commit e6544ac292b5b473274f87cdb83ebeac3e7e61a4.
Close #14060

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

index 8907962d81bcc5c05c6220e8a1d499739cf0fedc..5a94de5a68b9b859bf955fcb7dcaff46e03f45c4 100644 (file)
@@ -14,16 +14,6 @@ return function render(_ctx, _cache, $props, $setup, $data, $options) {
 }"
 `;
 
-exports[`compiler: expression transform > expression with type 1`] = `
-"const { openBlock: _openBlock, createElementBlock: _createElementBlock } = Vue
-
-return function render(_ctx, _cache) {
-  return (_openBlock(), _createElementBlock("div", {
-    onClick: _ctx.handleClick
-  }, null, 8 /* PROPS */, ["onClick"]))
-}"
-`;
-
 exports[`compiler: expression transform > should allow leak of var declarations in for loop 1`] = `
 "const { openBlock: _openBlock, createElementBlock: _createElementBlock } = Vue
 
index 47627ffa8d7c257be141ac21300b7e81216175a0..2f1e6eb64122c29ed7408c345dccb70322e6b9ff 100644 (file)
@@ -754,12 +754,4 @@ describe('compiler: expression transform', () => {
       expect(code).toMatch(`_ctx.bar`)
     })
   })
-
-  test('expression with type', () => {
-    const { code } = compile(
-      `<div @click="(<number>handleClick as any)"></div>`,
-    )
-    expect(code).toMatch(`onClick: _ctx.handleClick`)
-    expect(code).toMatchSnapshot()
-  })
 })
index be4b09bb67d32d25568d3deb22f871401e02a620..9ae8897e674866e821dc75d56d608fd5a0ec29cb 100644 (file)
@@ -18,7 +18,6 @@ import {
   createSimpleExpression,
 } from '../ast'
 import {
-  TS_NODE_TYPES,
   isInDestructureAssignment,
   isInNewExpression,
   isStaticProperty,
@@ -348,18 +347,15 @@ export function processExpression(
   // an ExpressionNode has the `.children` property, it will be used instead of
   // `.content`.
   const children: CompoundExpressionNode['children'] = []
-  const isTSNode = TS_NODE_TYPES.includes(ast.type)
   ids.sort((a, b) => a.start - b.start)
   ids.forEach((id, i) => {
     // range is offset by -1 due to the wrapping parens when parsed
     const start = id.start - 1
     const end = id.end - 1
     const last = ids[i - 1]
-    if (!(isTSNode && i === 0)) {
-      const leadingText = rawExp.slice(last ? last.end - 1 : 0, start)
-      if (leadingText.length || id.prefix) {
-        children.push(leadingText + (id.prefix || ``))
-      }
+    const leadingText = rawExp.slice(last ? last.end - 1 : 0, start)
+    if (leadingText.length || id.prefix) {
+      children.push(leadingText + (id.prefix || ``))
     }
     const source = rawExp.slice(start, end)
     children.push(
@@ -376,7 +372,7 @@ export function processExpression(
           : ConstantTypes.NOT_CONSTANT,
       ),
     )
-    if (i === ids.length - 1 && end < rawExp.length && !isTSNode) {
+    if (i === ids.length - 1 && end < rawExp.length) {
       children.push(rawExp.slice(end))
     }
   })