Skip to content

Commit b8421bb

Browse files
committed
fix(sfc): add support for @vue-ignore in runtime type resolution
1 parent c7121d2 commit b8421bb

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ describe('resolveType', () => {
149149
})
150150
})
151151

152+
test('TSPropertySignature with ignore', () => {
153+
expect(
154+
resolve(`
155+
type Foo = string
156+
defineProps<{ foo: /* @vue-ignore */ Foo }>()
157+
`).props,
158+
).toStrictEqual({
159+
foo: ['Unknown'],
160+
})
161+
})
162+
152163
// #7553
153164
test('union type', () => {
154165
expect(

packages/compiler-sfc/src/script/resolveType.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,13 @@ export function inferRuntimeType(
15151515
isKeyOf = false,
15161516
typeParameters?: Record<string, Node>,
15171517
): string[] {
1518+
if (
1519+
node.leadingComments &&
1520+
node.leadingComments.some(c => c.value.includes('@vue-ignore'))
1521+
) {
1522+
return [UNKNOWN_TYPE]
1523+
}
1524+
15181525
try {
15191526
switch (node.type) {
15201527
case 'TSStringKeyword':

0 commit comments

Comments
 (0)