@@ -618,18 +618,10 @@ namespace ts {
618
618
return false ;
619
619
}
620
620
621
- function isNarrowingNullCheckOperands ( expr1 : Expression , expr2 : Expression ) {
622
- return ( expr1 . kind === SyntaxKind . NullKeyword || expr1 . kind === SyntaxKind . Identifier && ( < Identifier > expr1 ) . text === "undefined" ) && isNarrowableOperand ( expr2 ) ;
623
- }
624
-
625
621
function isNarrowingTypeofOperands ( expr1 : Expression , expr2 : Expression ) {
626
622
return expr1 . kind === SyntaxKind . TypeOfExpression && isNarrowableOperand ( ( < TypeOfExpression > expr1 ) . expression ) && expr2 . kind === SyntaxKind . StringLiteral ;
627
623
}
628
624
629
- function isNarrowingDiscriminant ( expr : Expression ) {
630
- return expr . kind === SyntaxKind . PropertyAccessExpression && isNarrowableReference ( ( < PropertyAccessExpression > expr ) . expression ) ;
631
- }
632
-
633
625
function isNarrowingBinaryExpression ( expr : BinaryExpression ) {
634
626
switch ( expr . operatorToken . kind ) {
635
627
case SyntaxKind . EqualsToken :
@@ -638,9 +630,8 @@ namespace ts {
638
630
case SyntaxKind . ExclamationEqualsToken :
639
631
case SyntaxKind . EqualsEqualsEqualsToken :
640
632
case SyntaxKind . ExclamationEqualsEqualsToken :
641
- return isNarrowingNullCheckOperands ( expr . right , expr . left ) || isNarrowingNullCheckOperands ( expr . left , expr . right ) ||
642
- isNarrowingTypeofOperands ( expr . right , expr . left ) || isNarrowingTypeofOperands ( expr . left , expr . right ) ||
643
- isNarrowingDiscriminant ( expr . left ) || isNarrowingDiscriminant ( expr . right ) ;
633
+ return isNarrowableOperand ( expr . left ) || isNarrowableOperand ( expr . right ) ||
634
+ isNarrowingTypeofOperands ( expr . right , expr . left ) || isNarrowingTypeofOperands ( expr . left , expr . right ) ;
644
635
case SyntaxKind . InstanceOfKeyword :
645
636
return isNarrowableOperand ( expr . left ) ;
646
637
case SyntaxKind . CommaToken :
@@ -664,11 +655,6 @@ namespace ts {
664
655
return isNarrowableReference ( expr ) ;
665
656
}
666
657
667
- function isNarrowingSwitchStatement ( switchStatement : SwitchStatement ) {
668
- const expr = switchStatement . expression ;
669
- return expr . kind === SyntaxKind . PropertyAccessExpression && isNarrowableReference ( ( < PropertyAccessExpression > expr ) . expression ) ;
670
- }
671
-
672
658
function createBranchLabel ( ) : FlowLabel {
673
659
return {
674
660
flags : FlowFlags . BranchLabel ,
@@ -718,7 +704,7 @@ namespace ts {
718
704
}
719
705
720
706
function createFlowSwitchClause ( antecedent : FlowNode , switchStatement : SwitchStatement , clauseStart : number , clauseEnd : number ) : FlowNode {
721
- if ( ! isNarrowingSwitchStatement ( switchStatement ) ) {
707
+ if ( ! isNarrowingExpression ( switchStatement . expression ) ) {
722
708
return antecedent ;
723
709
}
724
710
setFlowNodeReferenced ( antecedent ) ;
@@ -1983,7 +1969,7 @@ namespace ts {
1983
1969
function bindThisPropertyAssignment ( node : BinaryExpression ) {
1984
1970
// Declare a 'member' in case it turns out the container was an ES5 class or ES6 constructor
1985
1971
let assignee : Node ;
1986
- if ( container . kind === SyntaxKind . FunctionDeclaration || container . kind === SyntaxKind . FunctionDeclaration ) {
1972
+ if ( container . kind === SyntaxKind . FunctionDeclaration || container . kind === SyntaxKind . FunctionExpression ) {
1987
1973
assignee = container ;
1988
1974
}
1989
1975
else if ( container . kind === SyntaxKind . Constructor ) {
0 commit comments