MCPcopy Create free account
hub / github.com/Snapchat/Valdi / createGuardExpression

Function createGuardExpression

compiler/companion/src/ConsoleLogTransformer.ts:55–64  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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 */
57function 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),

Callers 1

visitorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected