UNPKG

devghost

Version:

👻 Find dead code, dead imports, and dead dependencies before they haunt your project

58 lines • 2.2 kB
import * as ts from 'typescript'; /** * Parse a TypeScript/JavaScript file using the TS Compiler API */ export declare function parseFile(filePath: string): ts.SourceFile | null; /** * Extract all import declarations from a source file */ export declare function extractImports(sourceFile: ts.SourceFile): ts.ImportDeclaration[]; /** * Extract all export declarations from a source file */ export declare function extractExports(sourceFile: ts.SourceFile): ts.ExportDeclaration[]; /** * Check if an identifier is used in the source file */ export declare function isIdentifierUsed(sourceFile: ts.SourceFile, identifierName: string): boolean; /** * Extract package names from all imports in a source file */ export declare function getImportedPackages(sourceFile: ts.SourceFile): Set<string>; /** * Get the text of a specific line in the source file */ export declare function getLineText(sourceFile: ts.SourceFile, lineNumber: number): string; /** * Get line and column from a position in the source file * Returns 1-indexed line numbers (line 1 = first line) for consistency */ export declare function getLineAndColumn(sourceFile: ts.SourceFile, pos: number): { line: number; column: number; }; /** * Get all identifiers imported from an import declaration */ export declare function getImportedIdentifiers(importDecl: ts.ImportDeclaration): string[]; /** * Check if an import is a type-only import */ export declare function isTypeOnlyImport(importDecl: ts.ImportDeclaration): boolean; /** * Check if an import is a side-effect import (no imported identifiers) */ export declare function isSideEffectImport(importDecl: ts.ImportDeclaration): boolean; /** * Create a source file from file path and content */ export declare function createSourceFile(filePath: string, content?: string): ts.SourceFile; /** * Check if a file should be ignored based on devghost-ignore-file comment */ export declare function shouldIgnoreFile(content: string): boolean; /** * Check if a line should be ignored based on devghost-ignore-next-line comment */ export declare function shouldIgnoreLine(content: string, lineNumber: number): boolean; //# sourceMappingURL=tsparser.d.ts.map