/** * @fileoverview Null-safety AST heuristics for convention-based detection. */ import * as ts from 'typescript'; /** * Check if a call expression is a known safe builder pattern. * * Two paths: * 1. Explicit allowlist (`SAFE_BUILDER_PREFIXES`) — exact-prefix match on the * full call text (e.g. `z.string(`, `pathToFileURL(`). * 2. Convention heuristic — when the callee is a bare identifier whose name * starts with a recognised safe verb (`get*`, `read*`, `resolve*`, * `current*`, `create*`, `build*`, etc.). This is the same convention that * already covers fluent-chain methods via `isSafeFluentMethod`; applying it * to standalone calls closes the gap for helpers like `resolveProjectPaths`, * `readScope`, `currentScenarioRegistry`, etc. whose names convey the same * "returns a value or throws" contract. */ export declare function isSafeBuilderPattern(expression: ts.CallExpression, sourceFile: ts.SourceFile, safeBuilders: readonly string[]): boolean; /** * Check if a method name is a known safe fluent API method. * Matches either an exact entry in SAFE_FLUENT_METHOD_NAMES or a method whose name * starts with a common safe prefix (get, set, is, has, to, etc.). */ export declare function isSafeFluentMethod(methodName: string): boolean; /** * Walk ancestors to find an enclosing truthiness guard whose condition * references the access's base expression — an `if (...)`, a `cond ? … : …`, * or the left side of a `&&` chain (e.g. `if (candidates.length === 1 && * candidates[0]) { … candidates[0].bodyHash … }`). * * The line-local {@link SAFE_PATTERNS} scan only inspects the physical line * of the access, so a guard placed on a *previous* line is missed. This * closes that cross-line gap. Substring matching is intentionally lenient: * the check errs toward treating a guarded access as safe (fewer false * positives), consistent with the existing line-local guard handling. */ export declare function isGuardedByEnclosingCondition(node: ts.PropertyAccessExpression, sourceFile: ts.SourceFile): boolean; /** * Check if a property access originates from `this`. * Accessing properties on `this` is always safe — the object exists within its own methods. */ export declare function isThisAccess(node: ts.PropertyAccessExpression): boolean; /** * Count the depth of a method chain (number of chained property accesses / calls). * e.g. `a.b().c().d` has depth 3. */ export declare function getChainDepth(node: ts.PropertyAccessExpression): number; /** * Zod and project schema-builder chains (including `FooSchema.strict().safeParse`). */ export declare function isSchemaBuilderChain(node: ts.PropertyAccessExpression, sourceFile: ts.SourceFile): boolean; /** * True when accessing `arr[i].prop` where `i` is a parameter of the enclosing * callback (e.g. chunked POST `timeoutFor: (_chunk, i) => chunks[i].signals`). */ export declare function isCallbackIndexGuarded(node: ts.PropertyAccessExpression, _sourceFile: ts.SourceFile): boolean; /** * Check if a property access chain is on a Zod method call * Handles chained calls like z.string().min(1).optional() */ export declare function isZodBuilderChain(node: ts.PropertyAccessExpression, sourceFile: ts.SourceFile): boolean; /** Check if a call expression callee originates from z.xxx() */ export declare function checkZodCallExpression(node: ts.CallExpression, sourceFile: ts.SourceFile): { resolved: true; isZod: boolean; } | { resolved: false; next: ts.Expression; }; /** * Check if a property access is part of a fluent API chain * Handles patterns like promise.then().catch() or queryBuilder.where().orderBy() */ export declare function isFluentChain(node: ts.PropertyAccessExpression): boolean; //# sourceMappingURL=null-safety-heuristics.d.ts.map