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

TypeScript Code Property Analyzer

Build a utility that analyzes TypeScript code properties and validates property access patterns. The tool should identify assignments, validate property names, and suggest appropriate property access syntax.

Capabilities

Assignment Detection

Detects assignment operations in TypeScript code.

  • Given a binary expression with = operator, identifies it as an assignment @test
  • Given a binary expression with += operator, identifies it as an assignment @test
  • Given a binary expression with comparison operator ===, identifies it as not an assignment @test

Property Name Analysis

Analyzes and categorizes property names in object literals.

  • Given property name "0", identifies it as numeric @test
  • Given property name "name", identifies it as non-numeric @test
  • Given property name "42", identifies it as numeric @test

Property Access Validation

Validates property names for dot notation access and recommends appropriate access syntax.

  • Given property name "validName", recommends dot notation access @test
  • Given property name "123", recommends bracket notation access @test
  • Given property name "my-property", recommends bracket notation access @test

Implementation

@generates

API

import * as ts from "typescript";

/**
 * Analyzes a binary expression to determine if it represents an assignment operation.
 *
 * @param expression - The binary expression to analyze
 * @returns true if the expression is an assignment, false otherwise
 */
export function isAssignment(expression: ts.BinaryExpression): boolean;

/**
 * Determines if a property name is numeric.
 *
 * @param propertyName - The property name to analyze
 * @returns true if the property name is numeric, false otherwise
 */
export function isNumericProperty(propertyName: string): boolean;

/**
 * Recommends the appropriate property access syntax for a given property name.
 *
 * @param propertyName - The property name to validate
 * @returns "dot" if dot notation can be used, "bracket" if bracket notation must be used
 */
export function recommendAccessSyntax(propertyName: string): "dot" | "bracket";

Dependencies { .dependencies }

ts-api-utils { .dependency }

Provides TypeScript AST analysis utilities.

@satisfied-by

typescript { .dependency }

TypeScript compiler API for AST node types.

@satisfied-by

Version

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