CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-ts-api-utils

Utility functions for working with TypeScript's API, providing comprehensive tools for analyzing and manipulating TypeScript AST nodes, types, and compiler APIs.

79

1.97x
Overview
Eval results
Files

task.mdevals/scenario-7/

TypeScript AST Node Classifier

A tool that analyzes TypeScript source code and classifies different types of nodes found in the Abstract Syntax Tree (AST).

Capabilities

Classify type keyword nodes

  • Given a TypeScript source file containing any, boolean, number, and string type keywords, the classifier identifies and counts each type keyword category @test
  • Given a TypeScript source file with no type keywords, the classifier returns zero counts for all type keyword categories @test

Classify boolean literal nodes

  • Given a TypeScript source file containing true and false literals, the classifier identifies and counts true literals and false literals separately @test

Classify modifier keywords

  • Given a TypeScript class with public, private, protected, static, readonly, and abstract modifiers, the classifier identifies and counts each modifier type @test

Implementation

@generates

API

/**
 * Represents the classification results for a TypeScript source file
 */
export interface ClassificationResult {
  typeKeywords: {
    any: number;
    boolean: number;
    number: number;
    string: number;
    null: number;
  };
  booleanLiterals: {
    true: number;
    false: number;
  };
  modifiers: {
    public: number;
    private: number;
    protected: number;
    static: number;
    readonly: number;
    abstract: number;
  };
}

/**
 * Analyzes a TypeScript source file and classifies the different types of nodes
 *
 * @param sourceCode - The TypeScript source code to analyze
 * @returns A ClassificationResult object containing counts of different node types
 */
export function classifyNodes(sourceCode: string): ClassificationResult;

Dependencies { .dependencies }

ts-api-utils { .dependency }

Provides type guard functions for TypeScript AST nodes.

@satisfied-by

typescript { .dependency }

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

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-ts-api-utils

tile.json