(body, constructor)
| 93167 | /*modifiers*/ undefined, ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node)); |
| 93168 | } |
| 93169 | function transformConstructorBody(body, constructor) { |
| 93170 | var parametersWithPropertyAssignments = constructor && |
| 93171 | ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); |
| 93172 | if (!ts.some(parametersWithPropertyAssignments)) { |
| 93173 | return ts.visitFunctionBody(body, visitor, context); |
| 93174 | } |
| 93175 | var statements = []; |
| 93176 | resumeLexicalEnvironment(); |
| 93177 | var prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor); |
| 93178 | var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount); |
| 93179 | // If there was a super call, visit existing statements up to and including it |
| 93180 | if (superStatementIndex >= 0) { |
| 93181 | ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount)); |
| 93182 | } |
| 93183 | // Transform parameters into property assignments. Transforms this: |
| 93184 | // |
| 93185 | // constructor (public x, public y) { |
| 93186 | // } |
| 93187 | // |
| 93188 | // Into this: |
| 93189 | // |
| 93190 | // constructor (x, y) { |
| 93191 | // this.x = x; |
| 93192 | // this.y = y; |
| 93193 | // } |
| 93194 | // |
| 93195 | var parameterPropertyAssignments = ts.mapDefined(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment); |
| 93196 | // If there is a super() call, the parameter properties go immediately after it |
| 93197 | if (superStatementIndex >= 0) { |
| 93198 | ts.addRange(statements, parameterPropertyAssignments); |
| 93199 | } |
| 93200 | // Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements |
| 93201 | else { |
| 93202 | statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true); |
| 93203 | } |
| 93204 | // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements |
| 93205 | ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount)); |
| 93206 | // End the lexical environment. |
| 93207 | statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); |
| 93208 | var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true); |
| 93209 | ts.setTextRange(block, /*location*/ body); |
| 93210 | ts.setOriginalNode(block, body); |
| 93211 | return block; |
| 93212 | } |
| 93213 | /** |
| 93214 | * Transforms a parameter into a property assignment statement. |
| 93215 | * |
no test coverage detected
searching dependent graphs…