@@ -81,14 +81,18 @@ export class TSHelper {
8181 }
8282
8383 // iterate over a type and its bases until the callback returns true.
84- public static forTypeOrAnySupertype ( type : ts . Type , callback : ( type : ts . Type ) => boolean ) : boolean {
84+ public static forTypeOrAnySupertype ( type : ts . Type , checker : ts . TypeChecker , callback : ( type : ts . Type ) => boolean ) :
85+ boolean {
8586 if ( callback ( type ) ) {
8687 return true ;
8788 }
89+ if ( ! type . isClassOrInterface ( ) && type . symbol ) {
90+ type = checker . getDeclaredTypeOfSymbol ( type . symbol ) ;
91+ }
8892 const baseTypes = type . getBaseTypes ( ) ;
8993 if ( baseTypes ) {
9094 for ( const baseType of baseTypes ) {
91- if ( this . forTypeOrAnySupertype ( baseType , callback ) ) {
95+ if ( this . forTypeOrAnySupertype ( baseType , checker , callback ) ) {
9296 return true ;
9397 }
9498 }
@@ -115,7 +119,7 @@ export class TSHelper {
115119 }
116120
117121 public static isArrayType ( type : ts . Type , checker : ts . TypeChecker ) : boolean {
118- return this . forTypeOrAnySupertype ( type , t => this . isExplicitArrayType ( t , checker ) ) ;
122+ return this . forTypeOrAnySupertype ( type , checker , t => this . isExplicitArrayType ( t , checker ) ) ;
119123 }
120124
121125 public static isTupleReturnCall ( node : ts . Node , checker : ts . TypeChecker ) : boolean {
@@ -203,7 +207,7 @@ export class TSHelper {
203207 if ( ts . isPropertyAccessExpression ( node ) ) {
204208 const name = node . name . escapedText ;
205209 const type = checker . getTypeAtLocation ( node . expression ) ;
206- return this . forTypeOrAnySupertype ( type , t => this . hasExplicitGetAccessor ( t , name ) ) ;
210+ return this . forTypeOrAnySupertype ( type , checker , t => this . hasExplicitGetAccessor ( t , name ) ) ;
207211 }
208212 return false ;
209213 }
@@ -219,7 +223,7 @@ export class TSHelper {
219223 if ( ts . isPropertyAccessExpression ( node ) ) {
220224 const name = node . name . escapedText ;
221225 const type = checker . getTypeAtLocation ( node . expression ) ;
222- return this . forTypeOrAnySupertype ( type , t => this . hasExplicitSetAccessor ( t , name ) ) ;
226+ return this . forTypeOrAnySupertype ( type , checker , t => this . hasExplicitSetAccessor ( t , name ) ) ;
223227 }
224228 return false ;
225229 }
0 commit comments