(node)
| 101095 | /*typeArguments*/ undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); |
| 101096 | } |
| 101097 | function visitTypeScriptClassWrapper(node) { |
| 101098 | // This is a call to a class wrapper function (an IIFE) created by the 'ts' transformer. |
| 101099 | // The wrapper has a form similar to: |
| 101100 | // |
| 101101 | // (function() { |
| 101102 | // class C { // 1 |
| 101103 | // } |
| 101104 | // C.x = 1; // 2 |
| 101105 | // return C; |
| 101106 | // }()) |
| 101107 | // |
| 101108 | // When we transform the class, we end up with something like this: |
| 101109 | // |
| 101110 | // (function () { |
| 101111 | // var C = (function () { // 3 |
| 101112 | // function C() { |
| 101113 | // } |
| 101114 | // return C; // 4 |
| 101115 | // }()); |
| 101116 | // C.x = 1; |
| 101117 | // return C; |
| 101118 | // }()) |
| 101119 | // |
| 101120 | // We want to simplify the two nested IIFEs to end up with something like this: |
| 101121 | // |
| 101122 | // (function () { |
| 101123 | // function C() { |
| 101124 | // } |
| 101125 | // C.x = 1; |
| 101126 | // return C; |
| 101127 | // }()) |
| 101128 | // We skip any outer expressions in a number of places to get to the innermost |
| 101129 | // expression, but we will restore them later to preserve comments and source maps. |
| 101130 | var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock); |
| 101131 | // The class statements are the statements generated by visiting the first statement with initializer of the |
| 101132 | // body (1), while all other statements are added to remainingStatements (2) |
| 101133 | var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.first(stmt.declarationList.declarations).initializer; }; |
| 101134 | // visit the class body statements outside of any converted loop body. |
| 101135 | var savedConvertedLoopState = convertedLoopState; |
| 101136 | convertedLoopState = undefined; |
| 101137 | var bodyStatements = ts.visitNodes(body.statements, classWrapperStatementVisitor, ts.isStatement); |
| 101138 | convertedLoopState = savedConvertedLoopState; |
| 101139 | var classStatements = ts.filter(bodyStatements, isVariableStatementWithInitializer); |
| 101140 | var remainingStatements = ts.filter(bodyStatements, function (stmt) { return !isVariableStatementWithInitializer(stmt); }); |
| 101141 | var varStatement = ts.cast(ts.first(classStatements), ts.isVariableStatement); |
| 101142 | // We know there is only one variable declaration here as we verified this in an |
| 101143 | // earlier call to isTypeScriptClassWrapper |
| 101144 | var variable = varStatement.declarationList.declarations[0]; |
| 101145 | var initializer = ts.skipOuterExpressions(variable.initializer); |
| 101146 | // Under certain conditions, the 'ts' transformer may introduce a class alias, which |
| 101147 | // we see as an assignment, for example: |
| 101148 | // |
| 101149 | // (function () { |
| 101150 | // var C_1; |
| 101151 | // var C = C_1 = (function () { |
| 101152 | // function C() { |
| 101153 | // } |
| 101154 | // C.x = function () { return C_1; } |
no test coverage detected
searching dependent graphs…