@@ -593,35 +593,27 @@ function isTslibHelper(
593
593
tslibImports : ts . NamespaceImport [ ] ,
594
594
checker : ts . TypeChecker ,
595
595
) {
596
+ let name ;
596
597
597
- let callExprIdent = callExpr . expression as ts . Identifier ;
598
+ if ( ts . isIdentifier ( callExpr . expression ) ) {
599
+ name = callExpr . expression . text ;
600
+ } else if ( ts . isPropertyAccessExpression ( callExpr . expression ) ) {
601
+ const left = callExpr . expression . expression ;
598
602
599
- if ( callExpr . expression . kind !== ts . SyntaxKind . Identifier ) {
600
- if ( callExpr . expression . kind === ts . SyntaxKind . PropertyAccessExpression ) {
601
- const propAccess = callExpr . expression as ts . PropertyAccessExpression ;
602
- const left = propAccess . expression ;
603
- callExprIdent = propAccess . name ;
604
-
605
- if ( left . kind !== ts . SyntaxKind . Identifier ) {
606
- return false ;
607
- }
608
-
609
- const id = left as ts . Identifier ;
610
-
611
- if ( ! identifierIsTslib ( id , tslibImports , checker ) ) {
612
- return false ;
613
- }
603
+ if ( ! ts . isIdentifier ( left ) ) {
604
+ return false ;
605
+ }
614
606
615
- } else {
607
+ if ( ! identifierIsTslib ( left , tslibImports , checker ) ) {
616
608
return false ;
617
609
}
618
- }
619
610
620
- // node.text on a name that starts with two underscores will return three instead.
621
- // Unless it's an expression like tslib.__decorate, in which case it's only 2.
622
- if ( callExprIdent . text !== `_${ helper } ` && callExprIdent . text !== helper ) {
611
+ name = callExpr . expression . name . text ;
612
+ } else {
623
613
return false ;
624
614
}
625
615
626
- return true ;
616
+ // node.text on a name that starts with two underscores will return three instead.
617
+ // Unless it's an expression like tslib.__decorate, in which case it's only 2.
618
+ return name === `_${ helper } ` || name === helper ;
627
619
}
0 commit comments