* @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, onFulfilled, onRejected, transformer, hasContinuation, continuationArgName)
| 151743 | * @param continuationArgName The argument name for the continuation that follows this call. |
| 151744 | */ |
| 151745 | function transformThen(node, onFulfilled, onRejected, transformer, hasContinuation, continuationArgName) { |
| 151746 | if (!onFulfilled || isNullOrUndefined(transformer, onFulfilled)) { |
| 151747 | // If we don't have an `onfulfilled` callback, try treating this as a `.catch`. |
| 151748 | return transformCatch(node, onRejected, transformer, hasContinuation, continuationArgName); |
| 151749 | } |
| 151750 | // We don't currently support transforming a `.then` with both onfulfilled and onrejected handlers, per GH#38152. |
| 151751 | if (onRejected && !isNullOrUndefined(transformer, onRejected)) { |
| 151752 | return silentFail(); |
| 151753 | } |
| 151754 | var inputArgName = getArgBindingName(onFulfilled, transformer); |
| 151755 | // Transform the left-hand-side of `.then` into an array of inlined statements. We pass `true` for hasContinuation as `node` is the outer continuation. |
| 151756 | var inlinedLeftHandSide = transformExpression(node.expression.expression, node.expression.expression, transformer, /*hasContinuation*/ true, inputArgName); |
| 151757 | if (hasFailed()) |
| 151758 | return silentFail(); // shortcut out of more work |
| 151759 | // Transform the callback argument into an array of inlined statements. We pass whether we have an outer continuation here |
| 151760 | // as that indicates whether `return` is valid. |
| 151761 | var inlinedCallback = transformCallbackArgument(onFulfilled, hasContinuation, continuationArgName, inputArgName, node, transformer); |
| 151762 | if (hasFailed()) |
| 151763 | return silentFail(); // shortcut out of more work |
| 151764 | return ts.concatenate(inlinedLeftHandSide, inlinedCallback); |
| 151765 | } |
| 151766 | /** |
| 151767 | * Transforms the 'x' part of `x.then(...)`, or the 'y()' part of `y().catch(...)`, where 'x' and 'y()' are Promises. |
| 151768 | */ |
no test coverage detected