]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-sfc): add support for @vue-ignore in runtime type resolution (#13906)
authoredison <daiwei521@126.com>
Wed, 24 Sep 2025 09:10:20 +0000 (17:10 +0800)
committerGitHub <noreply@github.com>
Wed, 24 Sep 2025 09:10:20 +0000 (17:10 +0800)
packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts
packages/compiler-sfc/src/script/resolveType.ts

index a1476c76a826e8dd6a77a72c3f8f717c3f8a2af5..0f46d608510d9c6226fc735bacecd54ea0169069 100644 (file)
@@ -149,6 +149,17 @@ describe('resolveType', () => {
     })
   })
 
+  test('TSPropertySignature with ignore', () => {
+    expect(
+      resolve(`
+      type Foo = string
+      defineProps<{ foo: /* @vue-ignore */ Foo }>()
+    `).props,
+    ).toStrictEqual({
+      foo: ['Unknown'],
+    })
+  })
+
   // #7553
   test('union type', () => {
     expect(
index fb79323cbb41cf691d6f3baf1f875d155a1f0aab..f6763b7645df0c5cceeb889268c029c8b1e065b4 100644 (file)
@@ -1515,6 +1515,13 @@ export function inferRuntimeType(
   isKeyOf = false,
   typeParameters?: Record<string, Node>,
 ): string[] {
+  if (
+    node.leadingComments &&
+    node.leadingComments.some(c => c.value.includes('@vue-ignore'))
+  ) {
+    return [UNKNOWN_TYPE]
+  }
+
   try {
     switch (node.type) {
       case 'TSStringKeyword':