@@ -80,15 +80,18 @@ export default createRule('no-unused-props', {
80
80
return shouldIgnore ( typeStr ) || ( symbolName ? shouldIgnore ( symbolName ) : false ) ;
81
81
}
82
82
83
- function isExternalType ( type : ts . Type ) : boolean {
84
- const symbol = type . getSymbol ( ) ;
83
+ function isInternalType ( type : ts . Type ) : boolean {
84
+ const symbol = type . getSymbol ( ) ?? type . aliasSymbol ;
85
85
if ( ! symbol ) return false ;
86
86
87
87
const declarations = symbol . getDeclarations ( ) ;
88
88
if ( ! declarations || declarations . length === 0 ) return false ;
89
89
90
- const sourceFile = declarations [ 0 ] . getSourceFile ( ) ;
91
- return sourceFile . fileName !== fileName ;
90
+ const isSameFile = declarations . every ( ( decl ) => decl . getSourceFile ( ) . fileName === fileName ) ;
91
+ if ( ! isSameFile ) return false ;
92
+
93
+ const baseTypes = type . getBaseTypes ( ) ?? [ ] ;
94
+ return baseTypes . every ( ( baseType ) => isInternalType ( baseType ) ) ;
92
95
}
93
96
94
97
/**
@@ -200,7 +203,7 @@ export default createRule('no-unused-props', {
200
203
if ( checkedTypes . has ( typeStr ) ) return ;
201
204
checkedTypes . add ( typeStr ) ;
202
205
if ( shouldIgnoreType ( type ) ) return ;
203
- if ( ! checkImportedTypes && isExternalType ( type ) ) return ;
206
+ if ( ! checkImportedTypes && ! isInternalType ( type ) ) return ;
204
207
205
208
const properties = typeChecker . getPropertiesOfType ( type ) ;
206
209
const baseTypes = type . getBaseTypes ( ) ;
0 commit comments