UNPKG

eslint-plugin-sonarjs

Version:
34 lines (33 loc) 2.17 kB
import type estree from 'estree'; import ts from 'typescript'; import type { RequiredParserServices } from './parser-services.js'; export declare function isFunctionLikeDeclaration(declaration: ts.Declaration): declaration is ts.FunctionLikeDeclarationBase; /** * Resolves a call expression to the function-like declaration it targets, using the TypeScript * type checker's `getResolvedSignature`. Returns `undefined` when the callee does not resolve to * a known function declaration (e.g. built-ins, overloads with no single declaration, or * cross-package symbols without source). * * Only one hop is followed: the directly called function. Deeper call chains are not resolved. */ export declare function followCallToDeclaration(call: estree.CallExpression, services: RequiredParserServices): ts.SignatureDeclaration | undefined; /** * Resolves an identifier reference to the directly referenced function-like declaration. * * Only one indirection is followed: a direct function declaration or a variable whose initializer * is a function expression / arrow function. Aliases such as `const cb = setup; describe(..., cb)` * intentionally return `undefined`. */ export declare function followReferenceToDeclaration(node: estree.Identifier, services: RequiredParserServices): ts.SignatureDeclaration | undefined; /** * Resolves a call expression to executable code when possible. TypeScript may resolve a typed * function value call to its call signature rather than to the assigned implementation. In that * case, fallback to the callee's value declaration for direct identifiers and object members. */ export declare function followCallToImplementation(call: estree.CallExpression, services: RequiredParserServices): ts.SignatureDeclaration | undefined; /** * Resolves a TypeScript call expression to executable code without requiring an ESTree mapping. * This is used while recursively visiting declarations from other files, where * `tsNodeToESTreeNodeMap` only covers the originally parsed file. */ export declare function followTypeScriptCallToImplementation(call: ts.CallExpression, checker: ts.TypeChecker): ts.SignatureDeclaration | undefined;