* @param hasContinuation Whether another `then`, `catch`, or `finally` continuation follows this continuation. * @param continuationArgName The argument name for the continuation that follows this call.
(node, onFinally, transformer, hasContinuation, continuationArgName)
| 151694 | * @param continuationArgName The argument name for the continuation that follows this call. |
| 151695 | */ |
| 151696 | function transformFinally(node, onFinally, transformer, hasContinuation, continuationArgName) { |
| 151697 | if (!onFinally || isNullOrUndefined(transformer, onFinally)) { |
| 151698 | // Ignore this call as it has no effect on the result |
| 151699 | return transformExpression(/* returnContextNode */ node, node.expression.expression, transformer, hasContinuation, continuationArgName); |
| 151700 | } |
| 151701 | var possibleNameForVarDecl = getPossibleNameForVarDecl(node, transformer, continuationArgName); |
| 151702 | // Transform the left-hand-side of `.finally` into an array of inlined statements. We pass `true` for hasContinuation as `node` is the outer continuation. |
| 151703 | var inlinedLeftHandSide = transformExpression(/*returnContextNode*/ node, node.expression.expression, transformer, /*hasContinuation*/ true, possibleNameForVarDecl); |
| 151704 | if (hasFailed()) |
| 151705 | return silentFail(); // shortcut out of more work |
| 151706 | // Transform the callback argument into an array of inlined statements. We pass whether we have an outer continuation here |
| 151707 | // as that indicates whether `return` is valid. |
| 151708 | var inlinedCallback = transformCallbackArgument(onFinally, hasContinuation, /*continuationArgName*/ undefined, /*argName*/ undefined, node, transformer); |
| 151709 | if (hasFailed()) |
| 151710 | return silentFail(); // shortcut out of more work |
| 151711 | var tryBlock = ts.factory.createBlock(inlinedLeftHandSide); |
| 151712 | var finallyBlock = ts.factory.createBlock(inlinedCallback); |
| 151713 | var tryStatement = ts.factory.createTryStatement(tryBlock, /*catchClause*/ undefined, finallyBlock); |
| 151714 | return finishCatchOrFinallyTransform(node, transformer, tryStatement, possibleNameForVarDecl, continuationArgName); |
| 151715 | } |
| 151716 | /** |
| 151717 | * @param hasContinuation Whether another `then`, `catch`, or `finally` continuation follows this continuation. |
| 151718 | * @param continuationArgName The argument name for the continuation that follows this call. |
no test coverage detected