Skip to content

Commit a23e99b

Browse files
committedJun 14, 2024··
fix(compiler-sfc): support @vue-ignore comment on more type sources
1 parent a476692 commit a23e99b

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed
 

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

+12
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,18 @@ describe('resolveType', () => {
137137
})
138138
})
139139

140+
test('intersection type with ignore', () => {
141+
expect(
142+
resolve(`
143+
type Foo = { foo: number }
144+
type Bar = { bar: string }
145+
defineProps<Foo & /* @vue-ignore */ Bar>()
146+
`).props,
147+
).toStrictEqual({
148+
foo: ['Number'],
149+
})
150+
})
151+
140152
// #7553
141153
test('union type', () => {
142154
expect(

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ function innerResolveTypeElements(
165165
scope: TypeScope,
166166
typeParameters?: Record<string, Node>,
167167
): ResolvedElements {
168+
if (
169+
node.leadingComments &&
170+
node.leadingComments.some(c => c.value.includes('@vue-ignore'))
171+
) {
172+
return { props: {} }
173+
}
168174
switch (node.type) {
169175
case 'TSTypeLiteral':
170176
return typeElementsToMap(ctx, node.members, scope, typeParameters)
@@ -414,12 +420,6 @@ function resolveInterfaceMembers(
414420
)
415421
if (node.extends) {
416422
for (const ext of node.extends) {
417-
if (
418-
ext.leadingComments &&
419-
ext.leadingComments.some(c => c.value.includes('@vue-ignore'))
420-
) {
421-
continue
422-
}
423423
try {
424424
const { props, calls } = resolveTypeElements(ctx, ext, scope)
425425
for (const key in props) {

0 commit comments

Comments
 (0)
Please sign in to comment.