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-5/

Class Member Analyzer

Build a TypeScript tool that analyzes class declarations and reports on the access patterns of their members. The tool should identify which class members have specific access modifiers and categorize them accordingly.

Requirements

Your tool should:

  1. Accept a TypeScript source file path as input
  2. Parse the TypeScript AST to find all class declarations
  3. For each class, analyze its members (properties and methods) to determine their access modifiers
  4. Generate a report that lists:
    • Members marked as public
    • Members marked as private
    • Members marked as protected
    • Members marked as readonly
    • Members marked as static
    • Members marked as abstract
  5. Support checking for combinations of modifiers (e.g., private readonly, public static)

Output Format

The tool should output a JSON structure with the following format:

{
  "className": string,
  "members": {
    "public": string[],
    "private": string[],
    "protected": string[],
    "readonly": string[],
    "static": string[],
    "abstract": string[]
  }
}[]

Test Cases

  • Given a class with public, private, and protected members, the analyzer correctly categorizes each member @test
  • Given a class with readonly and static members, the analyzer identifies them correctly @test
  • Given a class with no explicit modifiers, the analyzer returns empty arrays @test
  • Given a class with combined modifiers like private readonly, the member appears in both arrays @test

Implementation

@generates

API

/**
 * Analyzes a TypeScript source file and returns information about class member modifiers
 * @param sourceFilePath - Path to the TypeScript source file to analyze
 * @returns Array of analysis results, one per class found in the source file
 */
export function analyzeClassModifiers(sourceFilePath: string): ClassAnalysisResult[];

export interface ClassAnalysisResult {
  className: string;
  members: {
    public: string[];
    private: string[];
    protected: string[];
    readonly: string[];
    static: string[];
    abstract: string[];
  };
}

Dependencies { .dependencies }

typescript { .dependency }

Provides TypeScript compiler API for parsing and analyzing TypeScript code.

ts-api-utils { .dependency }

Provides utility functions for working with TypeScript's API, including modifier checking capabilities.

Version

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