@@ -424,26 +424,33 @@ func (f *isolatedDeclarationsFixer) extractAsVariable(span core.TextRange) strin
424424}
425425
426426// findExpandoFunction finds the function declaration that has expando properties assigned to it.
427+ // isExpandoPropertyDeclarationForFix matches TS's isExpandoPropertyDeclaration which includes
428+ // PropertyAccessExpression, ElementAccessExpression, and BinaryExpression. The shared
429+ // ast.IsExpandoPropertyDeclaration was narrowed to BinaryExpression only for checker purposes.
430+ func isExpandoPropertyDeclarationForFix (node * ast.Node ) bool {
431+ return node != nil && (ast .IsPropertyAccessExpression (node ) || ast .IsElementAccessExpression (node ) || ast .IsBinaryExpression (node ))
432+ }
433+
427434func findExpandoFunction (ch * checker.Checker , node * ast.Node ) * ast.Node {
428435 expandoDeclaration := ast .FindAncestorOrQuit (node , func (n * ast.Node ) ast.FindAncestorResult {
429436 if ast .IsStatement (n ) {
430437 return ast .FindAncestorQuit
431438 }
432- if ast . IsExpandoPropertyDeclaration (n ) {
439+ if isExpandoPropertyDeclarationForFix (n ) {
433440 return ast .FindAncestorTrue
434441 }
435442 return ast .FindAncestorFalse
436443 })
437444
438- if expandoDeclaration == nil || ! ast . IsExpandoPropertyDeclaration (expandoDeclaration ) {
445+ if expandoDeclaration == nil || ! isExpandoPropertyDeclarationForFix (expandoDeclaration ) {
439446 return nil
440447 }
441448
442449 assignmentTarget := expandoDeclaration
443450 // Some late bound expando members use the whole expression as the declaration.
444451 if ast .IsBinaryExpression (assignmentTarget ) {
445452 assignmentTarget = assignmentTarget .AsBinaryExpression ().Left
446- if ! ast . IsExpandoPropertyDeclaration (assignmentTarget ) {
453+ if ! isExpandoPropertyDeclarationForFix (assignmentTarget ) {
447454 return nil
448455 }
449456 }
0 commit comments