@@ -2,20 +2,22 @@ import {
22 codeFixAll ,
33 createCodeFixAction ,
44 generateAccessorFromProperty ,
5- getAllSupers ,
65 registerCodeFix ,
76} from "../_namespaces/ts.codefix.js" ;
87import {
98 CodeFixAllContext ,
109 CodeFixContext ,
1110 Debug ,
1211 Diagnostics ,
12+ getEffectiveBaseTypeNode ,
1313 getSourceFileOfNode ,
1414 getTextOfPropertyName ,
1515 getTokenAtPosition ,
1616 isAccessor ,
17+ isClassExpression ,
1718 isClassLike ,
18- singleOrUndefined ,
19+ isComputedPropertyName ,
20+ skipParentheses ,
1921 SourceFile ,
2022 unescapeLeadingUnderscores ,
2123} from "../_namespaces/ts.js" ;
@@ -56,15 +58,20 @@ function doChange(file: SourceFile, start: number, length: number, code: number,
5658 else if ( code === Diagnostics . _0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor . code ) {
5759 const checker = context . program . getTypeChecker ( ) ;
5860 const node = getTokenAtPosition ( file , start ) . parent ;
61+ if ( isComputedPropertyName ( node ) ) {
62+ return ;
63+ }
5964 Debug . assert ( isAccessor ( node ) , "error span of fixPropertyOverrideAccessor should only be on an accessor" ) ;
6065 const containingClass = node . parent ;
6166 Debug . assert ( isClassLike ( containingClass ) , "erroneous accessors should only be inside classes" ) ;
62- const base = singleOrUndefined ( getAllSupers ( containingClass , checker ) ) ;
63- if ( ! base ) return [ ] ;
64-
65- const name = unescapeLeadingUnderscores ( getTextOfPropertyName ( node . name ) ) ;
66- const baseProp = checker . getPropertyOfType ( checker . getTypeAtLocation ( base ) , name ) ;
67- if ( ! baseProp || ! baseProp . valueDeclaration ) return [ ] ;
67+ const baseTypeNode = getEffectiveBaseTypeNode ( containingClass ) ;
68+ if ( ! baseTypeNode ) return ;
69+ const expression = skipParentheses ( baseTypeNode . expression ) ;
70+ const base = isClassExpression ( expression ) ? expression . symbol : checker . getSymbolAtLocation ( expression ) ;
71+ if ( ! base ) return ;
72+ const baseType = checker . getDeclaredTypeOfSymbol ( base ) ;
73+ const baseProp = checker . getPropertyOfType ( baseType , unescapeLeadingUnderscores ( getTextOfPropertyName ( node . name ) ) ) ;
74+ if ( ! baseProp || ! baseProp . valueDeclaration ) return ;
6875
6976 startPosition = baseProp . valueDeclaration . pos ;
7077 endPosition = baseProp . valueDeclaration . end ;
0 commit comments