@@ -4953,7 +4953,11 @@ namespace ts {
49534953
49544954 /* @internal */
49554955 export function isLeftHandSideExpression ( node : Node ) : node is LeftHandSideExpression {
4956- switch ( node . kind ) {
4956+ return isLeftHandSideExpressionKind ( skipPartiallyEmittedExpressions ( node ) . kind ) ;
4957+ }
4958+
4959+ function isLeftHandSideExpressionKind ( kind : SyntaxKind ) : boolean {
4960+ switch ( kind ) {
49574961 case SyntaxKind . PropertyAccessExpression :
49584962 case SyntaxKind . ElementAccessExpression :
49594963 case SyntaxKind . NewExpression :
@@ -4979,19 +4983,20 @@ namespace ts {
49794983 case SyntaxKind . SuperKeyword :
49804984 case SyntaxKind . NonNullExpression :
49814985 case SyntaxKind . MetaProperty :
4986+ case SyntaxKind . ImportKeyword : // technically this is only an Expression if it's in a CallExpression
49824987 return true ;
4983- case SyntaxKind . PartiallyEmittedExpression :
4984- return isLeftHandSideExpression ( ( node as PartiallyEmittedExpression ) . expression ) ;
4985- case SyntaxKind . ImportKeyword :
4986- return node . parent . kind === SyntaxKind . CallExpression ;
49874988 default :
49884989 return false ;
49894990 }
49904991 }
49914992
49924993 /* @internal */
49934994 export function isUnaryExpression ( node : Node ) : node is UnaryExpression {
4994- switch ( node . kind ) {
4995+ return isUnaryExpressionKind ( skipPartiallyEmittedExpressions ( node ) . kind ) ;
4996+ }
4997+
4998+ function isUnaryExpressionKind ( kind : SyntaxKind ) : boolean {
4999+ switch ( kind ) {
49955000 case SyntaxKind . PrefixUnaryExpression :
49965001 case SyntaxKind . PostfixUnaryExpression :
49975002 case SyntaxKind . DeleteExpression :
@@ -5000,10 +5005,8 @@ namespace ts {
50005005 case SyntaxKind . AwaitExpression :
50015006 case SyntaxKind . TypeAssertionExpression :
50025007 return true ;
5003- case SyntaxKind . PartiallyEmittedExpression :
5004- return isUnaryExpression ( ( node as PartiallyEmittedExpression ) . expression ) ;
50055008 default :
5006- return isLeftHandSideExpression ( node ) ;
5009+ return isLeftHandSideExpressionKind ( kind ) ;
50075010 }
50085011 }
50095012
@@ -5021,8 +5024,16 @@ namespace ts {
50215024 }
50225025
50235026 /* @internal */
5027+ /**
5028+ * Determines whether a node is an expression based only on its kind.
5029+ * Use `isPartOfExpression` if not in transforms.
5030+ */
50245031 export function isExpression ( node : Node ) : node is Expression {
5025- switch ( node . kind ) {
5032+ return isExpressionKind ( skipPartiallyEmittedExpressions ( node ) . kind ) ;
5033+ }
5034+
5035+ function isExpressionKind ( kind : SyntaxKind ) : boolean {
5036+ switch ( kind ) {
50265037 case SyntaxKind . ConditionalExpression :
50275038 case SyntaxKind . YieldExpression :
50285039 case SyntaxKind . ArrowFunction :
@@ -5034,7 +5045,7 @@ namespace ts {
50345045 case SyntaxKind . PartiallyEmittedExpression :
50355046 return true ;
50365047 default :
5037- return isUnaryExpression ( node ) ;
5048+ return isUnaryExpressionKind ( kind ) ;
50385049 }
50395050 }
50405051
0 commit comments