CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-types--react

TypeScript definitions for React, the popular JavaScript library for building user interfaces

80

1.48x
Overview
Eval results
Files

task.mdevals/scenario-8/

Element Utilities

A utility library that provides helper functions for working with elements and renderable content in a type-safe manner.

Capabilities

Validates elements

  • It returns true when given a valid element @test
  • It returns false when given a plain object that is not an element @test

Wraps content in elements

  • It wraps text content in a div element @test
  • It applies a className prop to the wrapper div when provided @test

Clones elements

  • It creates a new element with added props while preserving original props @test
  • It overrides props when the same prop name is provided @test

Filters content arrays

  • It keeps strings, numbers, and valid elements in the output @test
  • It removes null, undefined, and boolean values from the output @test

Implementation

@generates

API

/**
 * Validates if a value is a valid renderable element.
 *
 * @param value - The value to validate
 * @returns True if the value is a valid renderable element
 */
export function isRenderable(value: unknown): boolean;

/**
 * Wraps content in a container div element with optional className.
 *
 * @param content - The content to wrap
 * @param className - Optional CSS class name for the container
 * @returns A div element containing the wrapped content
 */
export function wrapContent(content: unknown, className?: string): unknown;

/**
 * Clones an element and adds or overrides props.
 *
 * @param element - The element to clone
 * @param props - Props to add or override
 * @returns A new element with the merged props
 */
export function cloneWithProps(element: unknown, props: Record<string, unknown>): unknown;

/**
 * Filters an array to only include renderable items.
 *
 * @param items - Array of values to filter
 * @returns Array containing only valid renderable values
 */
export function filterRenderable(items: unknown[]): unknown[];

Dependencies { .dependencies }

@types/react { .dependency }

Provides TypeScript definitions for React.

Install with Tessl CLI

npx tessl i tessl/npm-types--react

tile.json