(guard: string, expr: o.Expression)
| 66 | } |
| 67 | |
| 68 | export function guardedExpression(guard: string, expr: o.Expression): o.Expression { |
| 69 | const guardExpr = new o.ExternalExpr({name: guard, moduleName: null}); |
| 70 | const guardNotDefined = new o.BinaryOperatorExpr( |
| 71 | o.BinaryOperator.Identical, |
| 72 | new o.TypeofExpr(guardExpr), |
| 73 | o.literal('undefined'), |
| 74 | ); |
| 75 | const guardUndefinedOrTrue = new o.BinaryOperatorExpr( |
| 76 | o.BinaryOperator.Or, |
| 77 | guardNotDefined, |
| 78 | guardExpr, |
| 79 | /* type */ undefined, |
| 80 | /* sourceSpan */ undefined, |
| 81 | ); |
| 82 | return new o.BinaryOperatorExpr(o.BinaryOperator.And, guardUndefinedOrTrue, expr); |
| 83 | } |
| 84 | |
| 85 | export function wrapReference(value: any): R3Reference { |
| 86 | const wrapped = new o.WrappedNodeExpr(value); |
no outgoing calls
no test coverage detected
searching dependent graphs…