tessl install tessl/npm-ts-api-utils@2.0.0Utility functions for working with TypeScript's API, providing comprehensive tools for analyzing and manipulating TypeScript AST nodes, types, and compiler APIs.
Agent Success
Agent success rate when using this tile
79%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.98x
Baseline
Agent success rate without this tile
40%
Build a tool that analyzes TypeScript source code to identify and report all scope boundaries in the code. The tool should parse TypeScript files and determine which AST nodes create new function scopes, helping developers understand the scoping structure of their code.
Your tool should:
The output should be a JSON array where each entry contains:
line: The line number where the scope boundary startskind: The syntax kind name of the nodetext: A brief excerpt of the code (first 50 characters)Example output:
[
{"line": 3, "kind": "FunctionDeclaration", "text": "function calculate(x: number): number {"},
{"line": 8, "kind": "ArrowFunction", "text": "const handler = () => {"},
{"line": 12, "kind": "ClassDeclaration", "text": "class MyClass {"}
]Create two files:
src/analyzer.ts - Contains the main analysis logictest/analyzer.test.ts - Contains tests for the analyzerYour implementation should pass the following tests:
@generates
/**
* Analyzes a TypeScript file and identifies all function scope boundaries.
*
* @param filePath - Path to the TypeScript file to analyze
* @returns Array of scope boundary information
*/
export function analyzeScopeBoundaries(filePath: string): ScopeBoundary[];
/**
* Information about a scope boundary in the source code.
*/
export interface ScopeBoundary {
/** Line number where the scope boundary starts (1-indexed) */
line: number;
/** The TypeScript syntax kind name of the node */
kind: string;
/** A brief excerpt of the code at this location */
text: string;
}Provides the TypeScript compiler API for parsing and analyzing TypeScript code.
@satisfied-by
Provides utility functions for working with TypeScript's AST, particularly for detecting scope boundaries.
@satisfied-by