@@ -77,15 +77,18 @@ function isTypeReadonlyLoose(services: ParserServicesWithTypeInformation, type:
7777// @see https://github.com/Rel1cx/eslint-react/issues/1326
7878function isClassOrInterfaceReadonlyLoose ( checker : ts . TypeChecker , type : ts . Type ) {
7979 const props = type . getProperties ( ) ;
80- const baseTypes = type . getBaseTypes ( ) ?? [ ] ;
80+ const types = type . getBaseTypes ( ) ?? [ ] ;
81+ // If there are no properties, consider it readonly
8182 if ( props . length === 0 ) {
8283 return true ;
8384 }
84- if ( baseTypes . length === 0 ) {
85- return props . every ( ( prop ) => isPropertyReadonlyInType ( type , prop . getEscapedName ( ) , checker ) ) ;
85+ // If there are no base types, check only the properties of the current type
86+ if ( types . length === 0 ) {
87+ return props . every ( ( p ) => isPropertyReadonlyInType ( type , p . getEscapedName ( ) , checker ) ) ;
8688 }
87- return props . every ( ( prop ) => {
88- if ( isPropertyReadonlyInType ( type , prop . getEscapedName ( ) , checker ) ) return true ;
89- return baseTypes . every ( ( type ) => isPropertyReadonlyInType ( type , prop . getEscapedName ( ) , checker ) ) ;
89+ // Check properties in the current type and all base types
90+ return props . every ( ( p ) => {
91+ if ( isPropertyReadonlyInType ( type , p . getEscapedName ( ) , checker ) ) return true ;
92+ return types . every ( ( t ) => isPropertyReadonlyInType ( t , p . getEscapedName ( ) , checker ) ) ;
9093 } ) ;
9194}
0 commit comments