import type { SymbolInfo, SyntaxNode } from '../types.js'; import type { LanguageDefinition } from './types.js'; import type { LanguageTraverser, DeclarationFunctionInfo } from '../traversers/types.js'; import type { LanguageExportExtractor, LanguageImportExtractor, LanguageSymbolExtractor } from '../extractors/types.js'; /** * JavaScript AST traverser * * Handles JavaScript AST node types and traversal patterns. TypeScript shares * this same base (via tree-sitter-typescript, a superset grammar) and extends * it below to recognize TS-only container node types. * * Container-node checks (`getContainerBody`, `findParentContainerName`) key * off `containerTypes` rather than hardcoding 'class_declaration', so a * subclass can widen what counts as a container just by extending that array. */ export declare class JavaScriptTraverser implements LanguageTraverser { targetNodeTypes: string[]; containerTypes: string[]; declarationTypes: string[]; functionTypes: string[]; shouldExtractChildren(node: SyntaxNode): boolean; isDeclarationWithFunction(node: SyntaxNode): boolean; getContainerBody(node: SyntaxNode): SyntaxNode | null; shouldTraverseChildren(node: SyntaxNode): boolean; findParentContainerName(node: SyntaxNode): string | undefined; findFunctionInDeclaration(node: SyntaxNode): DeclarationFunctionInfo; } /** * TypeScript AST traverser * * tree-sitter-typescript parses `abstract class Foo {}` as a distinct * `abstract_class_declaration` node — separate from `class_declaration` — * even though its shape (a `name` and a `class_body`) is identical. Without * this, an abstract class falls through every container/traversal check in * the JS base and collapses into a single anonymous chunk, hiding its * methods. Widening `containerTypes` here is enough: `getContainerBody` and * `findParentContainerName` both key off that array already, and its body * node type is still `class_body`, which `shouldTraverseChildren` already * recognizes. */ export declare class TypeScriptTraverser extends JavaScriptTraverser { constructor(); } /** * JavaScript/TypeScript export extractor * * Handles ES module exports: * - Named exports: export { foo, bar } * - Declaration exports: export function foo() {}, export const bar = ... * - Default exports: export default ... * - Re-exports: export { foo } from './module' * * Handles CommonJS exports: * - module.exports = { foo, bar } * - module.exports = function/class * - exports.foo = ... / module.exports.bar = ... */ export declare class JavaScriptExportExtractor implements LanguageExportExtractor { extractExports(rootNode: SyntaxNode): string[]; private extractExportStatementSymbols; private extractDeclarationExports; private extractExportClauseSymbols; private isModuleExports; private extractCJSExportSymbols; private extractModuleExportsValue; private extractObjectExportProperties; } /** * TypeScript uses the same export extraction as JavaScript */ export declare class TypeScriptExportExtractor extends JavaScriptExportExtractor { } /** * JavaScript/TypeScript import extractor * * Handles ES module imports: * - Named imports: import { foo, bar } from './module' * - Default imports: import foo from './module' * - Namespace imports: import * as utils from './module' * - Re-exports: export { foo } from './module' * * Handles CommonJS require(): * - const x = require('module') * - const { a, b } = require('module') * - const { a: alias } = require('module') * - require('./side-effect') */ export declare class JavaScriptImportExtractor implements LanguageImportExtractor { readonly importNodeTypes: string[]; extractImportPath(node: SyntaxNode): string | null; extractImportPaths(node: SyntaxNode): string[]; processImportSymbols(node: SyntaxNode): { importPath: string; symbols: string[]; } | null; processImportSymbolsList(node: SyntaxNode): Array<{ importPath: string; symbols: string[]; }>; private processImportStatement; private processReExportStatement; private extractImportStatementSymbols; private extractImportClauseSymbols; private extractNamespaceImportSymbol; private extractNamedImportSymbols; /** * Extract original symbol names from an export_clause (for re-exports). * Uses original name (not alias) since it maps to the source module's exports. */ private extractExportClauseSymbols; private findRequireCall; private getRequirePathFromCall; private extractRequirePath; private findRequireCallInChildren; private processRequireDeclaration; private extractRequireBindingSymbols; private extractObjectPatternSymbols; private processBareRequire; } /** * TypeScript uses the same import extraction as JavaScript */ export declare class TypeScriptImportExtractor extends JavaScriptImportExtractor { } /** * JavaScript/TypeScript symbol extractor * * Extracts symbol info from function declarations, arrow functions, * method definitions, class declarations, and interface declarations. * * Also handles call site extraction for call_expression and new_expression. */ export declare class JavaScriptSymbolExtractor implements LanguageSymbolExtractor { symbolNodeTypes: string[]; extractSymbol(node: SyntaxNode, content: string, parentClass?: string): SymbolInfo | null; extractCallSite(node: SyntaxNode): { symbol: string; line: number; key: string; } | null; private resolveSymbol; private extractFunctionInfo; private extractArrowFunctionInfo; protected extractMethodInfo(node: SyntaxNode, content: string, parentClass?: string): SymbolInfo | null; protected extractClassInfo(node: SyntaxNode): SymbolInfo | null; private extractInterfaceInfo; } /** * TypeScript symbol extractor * * Extends the JS base with the two TS-only node types tree-sitter-typescript * produces for abstract classes: the class itself parses as * `abstract_class_declaration` (not `class_declaration`), and an abstract * method (declared but not implemented) parses as `abstract_method_signature` * (not `method_definition`). Both otherwise have the same shape as their * concrete counterparts, so this reuses `extractClassInfo`/`extractMethodInfo` * from the JS base rather than duplicating them. */ export declare class TypeScriptSymbolExtractor extends JavaScriptSymbolExtractor { constructor(); extractSymbol(node: SyntaxNode, content: string, parentClass?: string): SymbolInfo | null; } /** * Complexity configuration shared by JavaScript and TypeScript. * * Both language definitions reference this single object (mirroring how the * TypeScript extractor classes above extend their JavaScript bases), so tuning * JS/TS complexity only requires one edit. Consumers only read from it. */ export declare const jsTsComplexityConfig: LanguageDefinition['complexity']; export declare const javascriptDefinition: LanguageDefinition; //# sourceMappingURL=javascript.d.ts.map