Utility functions for working with TypeScript's API, providing comprehensive tools for analyzing and manipulating TypeScript AST nodes, types, and compiler APIs.
79
A TypeScript static analysis utility that inspects types for specific properties and callable signatures.
@generates
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;The TypeScript compiler API for type inspection.
Provides utility functions for working with TypeScript's API.
Install with Tessl CLI
npx tessl i tessl/npm-ts-api-utilsevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10