@@ -313,19 +313,12 @@ export class TypeParser {
313313 if ( resolvedSymbol && ! resolvedSymbol . isExternal ) {
314314 const decls = resolvedRealSymbol ?. getDeclarations ( ) || [ ] ;
315315 if ( decls . length > 0 ) {
316- const defStartOffset = decls [ 0 ] . getStart ( ) ;
317- const defEndOffset = decls [ 0 ] . getEnd ( ) ;
318316 const key = `${ resolvedSymbol . moduleName } ?${ resolvedSymbol . packagePath } #${ resolvedSymbol . name } ` ;
319317
320- // Check if this is not a self-reference
321- const isSelfReference = (
322- resolvedSymbol . moduleName === moduleName &&
323- this . getPkgPath ( resolvedSymbol . packagePath || packagePath ) === packagePath &&
324- defStartOffset <= resolvedSymbol . startOffset &&
325- resolvedSymbol . endOffset <= defEndOffset
326- ) ;
318+ // Check if this is a self-reference: the type reference is within its own definition
319+ const isSelfRef = typeNode . getAncestors ( ) . some ( ancestor => ancestor === decls [ 0 ] ) ;
327320
328- if ( ! visited . has ( key ) && ! isSelfReference ) {
321+ if ( ! visited . has ( key ) && ! isSelfRef ) {
329322 visited . add ( key ) ;
330323 dependencies . push ( {
331324 ModPath : resolvedSymbol . moduleName || moduleName ,
@@ -380,8 +373,11 @@ export class TypeParser {
380373 continue ;
381374 }
382375
383- const defStartOffset = decls [ 0 ] . getStart ( ) ;
384- const defEndOffset = decls [ 0 ] . getEnd ( ) ;
376+ // Check if this is a self-reference: the type reference is within its own definition
377+ // If typeRef's ancestors include decls[0], it's a self-reference
378+ const isSelfRef = typeRef . getAncestors ( ) . some ( ancestor => ancestor === decls [ 0 ] ) ;
379+
380+ if ( isSelfRef ) continue ;
385381
386382 visited . add ( key ) ;
387383 const dep : Dependency = {
@@ -394,13 +390,6 @@ export class TypeParser {
394390 EndOffset : resolvedSymbol . endOffset
395391 } ;
396392
397- // Skip self-references
398- if (
399- dep . ModPath === moduleName &&
400- dep . PkgPath === packagePath &&
401- defStartOffset <= resolvedSymbol . startOffset &&
402- resolvedSymbol . endOffset <= defEndOffset
403- ) continue ;
404393 dependencies . push ( dep ) ;
405394 }
406395
0 commit comments