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

Function isConsoleCall

compiler/companion/src/ConsoleLogTransformer.ts:38–47  ·  view source on GitHub ↗

* Returns true if the given CallExpression is a `console.X(...)` call * where X is one of log, warn, error, info, debug.

(node: ts.CallExpression)

Source from the content-addressed store, hash-verified

36 * where X is one of log, warn, error, info, debug.
37 */
38function isConsoleCall(node: ts.CallExpression): boolean {
39 const expr = node.expression;
40 if (!ts.isPropertyAccessExpression(expr)) {
41 return false;
42 }
43 if (!ts.isIdentifier(expr.expression) || expr.expression.text !== 'console') {
44 return false;
45 }
46 return CONSOLE_METHODS.has(expr.name.text);
47}
48
49/**
50 * Creates the guard expression: `globalThis.runtime?.isLoggingEnabled`

Callers 1

visitorFunction · 0.85

Calls 2

isIdentifierMethod · 0.80
hasMethod · 0.65

Tested by

no test coverage detected