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

Type Inspector

A TypeScript static analysis utility that inspects types for specific properties and callable signatures.

Capabilities

Inspects callable signatures

  • Given a function type, the inspector extracts all call signatures and returns their parameter and return type information @test
  • Given a union type containing callable types, the inspector collects call signatures from all union members @test
  • Given an intersection type containing callable types, the inspector collects call signatures from all intersection members @test

Inspects type properties

  • Given a type with regular properties, the inspector retrieves a specific property by name @test
  • Given a type with well-known symbol properties (like Symbol.iterator), the inspector retrieves the symbol property @test

Implementation

@generates

API

import * as ts from 'typescript';

/**
 * Extracts information about all call signatures from a type.
 * Returns an array of objects describing each signature's parameters and return type.
 *
 * @param type - The TypeScript type to inspect
 * @param typeChecker - The TypeScript type checker instance
 * @returns Array of signature information objects
 */
export function inspectCallSignatures(
  type: ts.Type,
  typeChecker: ts.TypeChecker
): Array<{ parameters: string[]; returnType: string }>;

/**
 * Retrieves a specific property from a type by name.
 * Returns the property symbol if found, undefined otherwise.
 *
 * @param type - The TypeScript type to inspect
 * @param propertyName - The name of the property to retrieve
 * @returns The property symbol or undefined
 */
export function getTypeProperty(
  type: ts.Type,
  propertyName: string
): ts.Symbol | undefined;

/**
 * Retrieves a well-known symbol property from a type.
 * Returns the symbol property if found, undefined otherwise.
 *
 * @param type - The TypeScript type to inspect
 * @param symbolName - The well-known symbol name (e.g., 'iterator', 'toStringTag')
 * @param typeChecker - The TypeScript type checker instance
 * @returns The symbol property or undefined
 */
export function getWellKnownSymbol(
  type: ts.Type,
  symbolName: string,
  typeChecker: ts.TypeChecker
): ts.Symbol | undefined;

Dependencies { .dependencies }

typescript { .dependency }

The TypeScript compiler API for type inspection.

ts-api-utils { .dependency }

Provides utility functions for working with TypeScript's API.

Version

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