CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-ts-api-utils

tessl install tessl/npm-ts-api-utils@2.0.0

Utility 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%

task.mdevals/scenario-2/

Comment Analyzer

A TypeScript tool that analyzes comments in TypeScript source code files and provides statistics and content extraction capabilities.

Capabilities

Extract all comments from source code

  • When given a TypeScript source file, the analyzer extracts all comments (both single-line and multi-line) and returns them as an array of strings @test
  • Empty source files return an empty array of comments @test

Count comments by type

  • The analyzer counts single-line comments separately from multi-line comments @test
  • The result includes both singleLine and multiLine counts @test

Generate comment statistics

  • The analyzer provides a summary including total comment count, total character count across all comments, and average comment length @test
  • For files with no comments, statistics return zero values @test

Implementation

@generates

API

/**
 * Extracts all comments from a TypeScript source file.
 *
 * @param sourceCode - The TypeScript source code as a string
 * @returns An array of comment text content (without comment delimiters)
 */
export function extractComments(sourceCode: string): string[];

/**
 * Counts comments by type in a TypeScript source file.
 *
 * @param sourceCode - The TypeScript source code as a string
 * @returns An object with singleLine and multiLine counts
 */
export function countCommentsByType(sourceCode: string): {
  singleLine: number;
  multiLine: number;
};

/**
 * Generates statistics about comments in a TypeScript source file.
 *
 * @param sourceCode - The TypeScript source code as a string
 * @returns An object with total count, total characters, and average length
 */
export function getCommentStatistics(sourceCode: string): {
  totalComments: number;
  totalCharacters: number;
  averageLength: number;
};

Dependencies { .dependencies }

ts-api-utils { .dependency }

Provides utilities for working with TypeScript's Compiler API, including comment extraction capabilities.

typescript { .dependency }

Provides the TypeScript compiler API for parsing and analyzing TypeScript code.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/ts-api-utils@2.0.x
tile.json