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

Token Counter

Build a utility that counts and categorizes tokens in TypeScript source code.

Capabilities

Token Counting

  • Counts the total number of tokens in a valid TypeScript source string @test
  • Returns zero for an empty source file @test

Identifier Extraction

  • Extracts all identifier tokens from TypeScript source code @test
  • Returns an empty array when no identifiers are present in the source @test

Implementation

@generates

API

/**
 * Counts the total number of tokens in TypeScript source code
 * @param sourceCode - TypeScript source code as a string
 * @returns The total count of tokens
 */
export function countTokens(sourceCode: string): number;

/**
 * Extracts all identifier token texts from TypeScript source code
 * @param sourceCode - TypeScript source code as a string
 * @returns Array of identifier strings found in the source
 */
export function extractIdentifiers(sourceCode: string): string[];

Dependencies { .dependencies }

ts-api-utils { .dependency }

Provides TypeScript AST token traversal utilities for iterating over tokens in source code.

@satisfied-by

typescript { .dependency }

TypeScript compiler API for parsing source code and working with AST nodes.

@satisfied-by

Install with Tessl CLI

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

tile.json