* Creates the guard expression: `globalThis.runtime?.isLoggingEnabled` * * Uses optional chaining so modules that evaluate before the runtime is * initialized (e.g. during bootstrap) don't throw a TypeError.
(factory: ts.NodeFactory)
| 53 | * |
| 54 | * The runtime is looked up per call, not bound at module evaluation: on web, |
| 55 | * modules can evaluate before the host installs the runtime. |
| 56 | */ |
| 57 | function createGuardExpression(factory: ts.NodeFactory): ts.Expression { |
| 58 | return factory.createPropertyAccessChain( |
| 59 | factory.createCallExpression( |
| 60 | factory.createPropertyAccessExpression( |
| 61 | factory.createIdentifier(RUNTIME_PROVIDER_BINDING), |
| 62 | factory.createIdentifier('getValdiRuntime'), |
| 63 | ), |
| 64 | undefined, |
| 65 | [], |
| 66 | ), |
| 67 | factory.createToken(ts.SyntaxKind.QuestionDotToken), |