@@ -148,8 +148,8 @@ namespace ts {
148
148
let Symbol : new ( flags : SymbolFlags , name : __String ) => Symbol ; // tslint:disable-line variable-name
149
149
let classifiableNames : UnderscoreEscapedMap < true > ;
150
150
151
- const unreachableFlow = createFlowNode ( FlowFlags . Unreachable , /*antecedent*/ undefined , /*node*/ undefined ) ;
152
- const reportedUnreachableFlow : FlowNode = createFlowNode ( FlowFlags . Unreachable , /*antecedent*/ undefined , /*node*/ undefined ) ;
151
+ const unreachableFlow : FlowNode = { flags : FlowFlags . Unreachable } ;
152
+ const reportedUnreachableFlow : FlowNode = { flags : FlowFlags . Unreachable } ;
153
153
154
154
// state used to aggregate transform flags during bind.
155
155
let subtreeTransformFlags : TransformFlags = TransformFlags . None ;
@@ -560,7 +560,7 @@ namespace ts {
560
560
// A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave
561
561
// similarly to break statements that exit to a label just past the statement body.
562
562
if ( ! isIIFE ) {
563
- currentFlow = createFlowNode ( FlowFlags . Start , /*antecedent*/ undefined , /*node*/ undefined ) as FlowStart ;
563
+ currentFlow = { flags : FlowFlags . Start } ;
564
564
if ( containerFlags & ( ContainerFlags . IsFunctionExpression | ContainerFlags . IsObjectLiteralOrClassExpressionMethod ) ) {
565
565
currentFlow . node = < FunctionExpression | ArrowFunction | MethodDeclaration > node ;
566
566
}
@@ -842,22 +842,12 @@ namespace ts {
842
842
return isNarrowableReference ( expr ) ;
843
843
}
844
844
845
- function createFlowNode ( flags : FlowFlags , antecedent : FlowNode | undefined , node : Node | undefined ) {
846
- return {
847
- flags,
848
- antecedent,
849
- node,
850
- id : undefined ,
851
- antecedents : undefined ,
852
- } as FlowNode ;
853
- }
854
-
855
845
function createBranchLabel ( ) : FlowLabel {
856
- return createFlowNode ( FlowFlags . BranchLabel , /*antecedent*/ undefined , /*node*/ undefined ) as FlowLabel ;
846
+ return { flags : FlowFlags . BranchLabel , antecedents : undefined } ;
857
847
}
858
848
859
849
function createLoopLabel ( ) : FlowLabel {
860
- return createFlowNode ( FlowFlags . LoopLabel , /*antecedent*/ undefined , /*node*/ undefined ) as FlowLabel ;
850
+ return { flags : FlowFlags . LoopLabel , antecedents : undefined } ;
861
851
}
862
852
863
853
function setFlowNodeReferenced ( flow : FlowNode ) {
@@ -887,34 +877,30 @@ namespace ts {
887
877
return antecedent ;
888
878
}
889
879
setFlowNodeReferenced ( antecedent ) ;
890
- return flowNodeCreated ( createFlowNode ( flags , antecedent , expression ) ) ;
880
+ return flowNodeCreated ( { flags, antecedent, node : expression } ) ;
891
881
}
892
882
893
883
function createFlowSwitchClause ( antecedent : FlowNode , switchStatement : SwitchStatement , clauseStart : number , clauseEnd : number ) : FlowNode {
894
884
if ( ! isNarrowingExpression ( switchStatement . expression ) ) {
895
885
return antecedent ;
896
886
}
897
887
setFlowNodeReferenced ( antecedent ) ;
898
- const result = createFlowNode ( FlowFlags . SwitchClause , antecedent , /*node*/ undefined ) as FlowSwitchClause ;
899
- result . switchStatement = switchStatement ;
900
- result . clauseStart = clauseStart ;
901
- result . clauseEnd = clauseEnd ;
902
- return flowNodeCreated ( result ) ;
888
+ return flowNodeCreated ( { flags : FlowFlags . SwitchClause , antecedent, switchStatement, clauseStart, clauseEnd } ) ;
903
889
}
904
890
905
891
function createFlowAssignment ( antecedent : FlowNode , node : Expression | VariableDeclaration | BindingElement ) : FlowNode {
906
892
setFlowNodeReferenced ( antecedent ) ;
907
- return flowNodeCreated ( createFlowNode ( FlowFlags . Assignment , antecedent , node ) ) ;
893
+ return flowNodeCreated ( { flags : FlowFlags . Assignment , antecedent, node } ) ;
908
894
}
909
895
910
896
function createFlowCall ( antecedent : FlowNode , node : CallExpression ) : FlowNode {
911
897
setFlowNodeReferenced ( antecedent ) ;
912
- return flowNodeCreated ( createFlowNode ( FlowFlags . Call , antecedent , node ) ) ;
898
+ return flowNodeCreated ( { flags : FlowFlags . Call , antecedent, node } ) ;
913
899
}
914
900
915
901
function createFlowArrayMutation ( antecedent : FlowNode , node : CallExpression | BinaryExpression ) : FlowNode {
916
902
setFlowNodeReferenced ( antecedent ) ;
917
- return flowNodeCreated ( createFlowNode ( FlowFlags . ArrayMutation , antecedent , node ) ) ;
903
+ return flowNodeCreated ( { flags : FlowFlags . ArrayMutation , antecedent, node } ) ;
918
904
}
919
905
920
906
function finishFlowLabel ( flow : FlowLabel ) : FlowNode {
@@ -1192,8 +1178,7 @@ namespace ts {
1192
1178
//
1193
1179
// extra edges that we inject allows to control this behavior
1194
1180
// if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped.
1195
- const preFinallyFlow = createFlowNode ( FlowFlags . PreFinally , preFinallyPrior , /*node*/ undefined ) as PreFinallyFlow ;
1196
- preFinallyFlow . lock = { } ;
1181
+ const preFinallyFlow : PreFinallyFlow = { flags : FlowFlags . PreFinally , antecedent : preFinallyPrior , lock : { } } ;
1197
1182
addAntecedent ( preFinallyLabel , preFinallyFlow ) ;
1198
1183
1199
1184
currentFlow = finishFlowLabel ( preFinallyLabel ) ;
@@ -1212,7 +1197,7 @@ namespace ts {
1212
1197
}
1213
1198
}
1214
1199
if ( ! ( currentFlow . flags & FlowFlags . Unreachable ) ) {
1215
- const afterFinallyFlow = flowNodeCreated ( createFlowNode ( FlowFlags . AfterFinally , currentFlow , /*node*/ undefined ) as AfterFinallyFlow ) ;
1200
+ const afterFinallyFlow : AfterFinallyFlow = flowNodeCreated ( { flags : FlowFlags . AfterFinally , antecedent : currentFlow } ) ;
1216
1201
preFinallyFlow . lock = afterFinallyFlow ;
1217
1202
currentFlow = afterFinallyFlow ;
1218
1203
}
@@ -1836,7 +1821,7 @@ namespace ts {
1836
1821
const host = getJSDocHost ( typeAlias ) ;
1837
1822
container = findAncestor ( host . parent , n => ! ! ( getContainerFlags ( n ) & ContainerFlags . IsContainer ) ) || file ;
1838
1823
blockScopeContainer = getEnclosingBlockScopeContainer ( host ) || file ;
1839
- currentFlow = createFlowNode ( FlowFlags . Start , /*antecedent*/ undefined , /*node*/ undefined ) ;
1824
+ currentFlow = { flags : FlowFlags . Start } ;
1840
1825
parent = typeAlias ;
1841
1826
bind ( typeAlias . typeExpression ) ;
1842
1827
if ( isJSDocEnumTag ( typeAlias ) || ! typeAlias . fullName || typeAlias . fullName . kind === SyntaxKind . Identifier ) {
0 commit comments