* Ensures that there exists a declared identifier whose value holds the given expression. * This function is useful to ensure that the expression's value can be read from in subsequent expressions. * Unless 'reuseIdentifierExpressions' is false, 'value' will be returned if it is just an id
(flattenContext, value, reuseIdentifierExpressions, location)
| 91416 | * @param location The location to use for source maps and comments. |
| 91417 | */ |
| 91418 | function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) { |
| 91419 | if (ts.isIdentifier(value) && reuseIdentifierExpressions) { |
| 91420 | return value; |
| 91421 | } |
| 91422 | else { |
| 91423 | var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); |
| 91424 | if (flattenContext.hoistTempVariables) { |
| 91425 | flattenContext.context.hoistVariableDeclaration(temp); |
| 91426 | flattenContext.emitExpression(ts.setTextRange(flattenContext.context.factory.createAssignment(temp, value), location)); |
| 91427 | } |
| 91428 | else { |
| 91429 | flattenContext.emitBindingOrAssignment(temp, value, location, /*original*/ undefined); |
| 91430 | } |
| 91431 | return temp; |
| 91432 | } |
| 91433 | } |
| 91434 | function makeArrayBindingPattern(factory, elements) { |
| 91435 | ts.Debug.assertEachNode(elements, ts.isArrayBindingElement); |
| 91436 | return factory.createArrayBindingPattern(elements); |
no outgoing calls
no test coverage detected