(guard: string, expr: o.Expression)
| 146 | } |
| 147 | |
| 148 | function guardedExpression(guard: string, expr: o.Expression): o.Expression { |
| 149 | const guardExpr = new o.ExternalExpr({name: guard, moduleName: null}); |
| 150 | const guardNotDefined = new o.BinaryOperatorExpr( |
| 151 | o.BinaryOperator.Identical, |
| 152 | new o.TypeofExpr(guardExpr), |
| 153 | o.literal('undefined'), |
| 154 | ); |
| 155 | const guardUndefinedOrTrue = new o.BinaryOperatorExpr( |
| 156 | o.BinaryOperator.Or, |
| 157 | guardNotDefined, |
| 158 | guardExpr, |
| 159 | /* type */ undefined, |
| 160 | /* sourceSpan */ undefined, |
| 161 | ); |
| 162 | return new o.BinaryOperatorExpr(o.BinaryOperator.And, guardUndefinedOrTrue, expr); |
| 163 | } |
| 164 | |
| 165 | export function wrapReference(value: any): R3Reference { |
| 166 | const wrapped = new o.WrappedNodeExpr(value); |
no outgoing calls
no test coverage detected