fix(compiler-sfc): add support for @vue-ignore in runtime type resolution (#13906)

This commit is contained in:
edison 2025-09-24 17:10:20 +08:00 committed by GitHub
parent 5358bca4a8
commit ba7f7f90f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View 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(

View 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':