Skip to content

Commit

Permalink
fix(compiler-sfc): support @vue-ignore comment on more type sources
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 14, 2024
1 parent a476692 commit a23e99b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 12 additions & 0 deletions packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ describe('resolveType', () => {
})
})

test('intersection type with ignore', () => {
expect(
resolve(`
type Foo = { foo: number }
type Bar = { bar: string }
defineProps<Foo & /* @vue-ignore */ Bar>()
`).props,
).toStrictEqual({
foo: ['Number'],
})
})

// #7553
test('union type', () => {
expect(
Expand Down
12 changes: 6 additions & 6 deletions packages/compiler-sfc/src/script/resolveType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ function innerResolveTypeElements(
scope: TypeScope,
typeParameters?: Record<string, Node>,
): ResolvedElements {
if (
node.leadingComments &&
node.leadingComments.some(c => c.value.includes('@vue-ignore'))
) {
return { props: {} }
}
switch (node.type) {
case 'TSTypeLiteral':
return typeElementsToMap(ctx, node.members, scope, typeParameters)
Expand Down Expand Up @@ -414,12 +420,6 @@ function resolveInterfaceMembers(
)
if (node.extends) {
for (const ext of node.extends) {
if (
ext.leadingComments &&
ext.leadingComments.some(c => c.value.includes('@vue-ignore'))
) {
continue
}
try {
const { props, calls } = resolveTypeElements(ctx, ext, scope)
for (const key in props) {
Expand Down

0 comments on commit a23e99b

Please sign in to comment.