CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-tns-platform-declarations

Platform-specific TypeScript declarations for NativeScript for accessing native objects

84

1.23x
Overview
Eval results
Files

task.mdevals/scenario-9/

Geometry Utilities for NativeScript

Build a TypeScript module that provides utilities for working with geometric shapes using native iOS structs in a NativeScript application.

Requirements

Your module should provide functionality to:

  1. Create and manipulate rectangle structures representing geometric bounds
  2. Calculate the area of rectangles
  3. Check if two rectangles are equal
  4. Create a copy of a rectangle with modified dimensions
  5. Determine if a point lies within a rectangle's bounds

The module should work with native struct types and handle coordinate systems appropriately.

API

/**
 * Creates a rectangle with the specified origin and dimensions
 */
export function createRectangle(x: number, y: number, width: number, height: number): any;

/**
 * Calculates the area of a rectangle
 */
export function calculateArea(rect: any): number;

/**
 * Checks if two rectangles are equal
 */
export function areRectanglesEqual(rect1: any, rect2: any): boolean;

/**
 * Creates a copy of a rectangle with width and height scaled by the given factor
 */
export function scaleRectangle(rect: any, scaleFactor: number): any;

/**
 * Checks if a point is contained within a rectangle
 */
export function containsPoint(rect: any, x: number, y: number): boolean;

Implementation

@generates

Test Cases

  • Creating a rectangle with origin (10, 20) and size (100, 50) produces a valid struct @test
  • Calculating area of a rectangle with width 100 and height 50 returns 5000 @test
  • Two rectangles with identical coordinates and dimensions are equal @test
  • Scaling a rectangle (x:0, y:0, width:100, height:50) by factor 2 produces rectangle with width 200 and height 100 @test
  • Point (50, 25) is contained within rectangle (x:0, y:0, width:100, height:50) @test
  • Point (150, 25) is not contained within rectangle (x:0, y:0, width:100, height:50) @test

Dependencies { .dependencies }

tns-platform-declarations { .dependency }

Provides TypeScript type definitions for NativeScript platform APIs, including iOS native struct types and interoperability utilities.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-tns-platform-declarations

tile.json