@@ -618,18 +618,10 @@ namespace ts {
618618 return false ;
619619 }
620620
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-
625621 function isNarrowingTypeofOperands ( expr1 : Expression , expr2 : Expression ) {
626622 return expr1 . kind === SyntaxKind . TypeOfExpression && isNarrowableOperand ( ( < TypeOfExpression > expr1 ) . expression ) && expr2 . kind === SyntaxKind . StringLiteral ;
627623 }
628624
629- function isNarrowingDiscriminant ( expr : Expression ) {
630- return expr . kind === SyntaxKind . PropertyAccessExpression && isNarrowableReference ( ( < PropertyAccessExpression > expr ) . expression ) ;
631- }
632-
633625 function isNarrowingBinaryExpression ( expr : BinaryExpression ) {
634626 switch ( expr . operatorToken . kind ) {
635627 case SyntaxKind . EqualsToken :
@@ -638,9 +630,8 @@ namespace ts {
638630 case SyntaxKind . ExclamationEqualsToken :
639631 case SyntaxKind . EqualsEqualsEqualsToken :
640632 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 ) ;
644635 case SyntaxKind . InstanceOfKeyword :
645636 return isNarrowableOperand ( expr . left ) ;
646637 case SyntaxKind . CommaToken :
@@ -664,11 +655,6 @@ namespace ts {
664655 return isNarrowableReference ( expr ) ;
665656 }
666657
667- function isNarrowingSwitchStatement ( switchStatement : SwitchStatement ) {
668- const expr = switchStatement . expression ;
669- return expr . kind === SyntaxKind . PropertyAccessExpression && isNarrowableReference ( ( < PropertyAccessExpression > expr ) . expression ) ;
670- }
671-
672658 function createBranchLabel ( ) : FlowLabel {
673659 return {
674660 flags : FlowFlags . BranchLabel ,
@@ -718,7 +704,7 @@ namespace ts {
718704 }
719705
720706 function createFlowSwitchClause ( antecedent : FlowNode , switchStatement : SwitchStatement , clauseStart : number , clauseEnd : number ) : FlowNode {
721- if ( ! isNarrowingSwitchStatement ( switchStatement ) ) {
707+ if ( ! isNarrowingExpression ( switchStatement . expression ) ) {
722708 return antecedent ;
723709 }
724710 setFlowNodeReferenced ( antecedent ) ;
@@ -1983,7 +1969,7 @@ namespace ts {
19831969 function bindThisPropertyAssignment ( node : BinaryExpression ) {
19841970 // Declare a 'member' in case it turns out the container was an ES5 class or ES6 constructor
19851971 let assignee : Node ;
1986- if ( container . kind === SyntaxKind . FunctionDeclaration || container . kind === SyntaxKind . FunctionDeclaration ) {
1972+ if ( container . kind === SyntaxKind . FunctionDeclaration || container . kind === SyntaxKind . FunctionExpression ) {
19871973 assignee = container ;
19881974 }
19891975 else if ( container . kind === SyntaxKind . Constructor ) {
0 commit comments