Skip to content

Type definitions for applyToPoint and applyToPoints should accept arrays #64

@estollnitz

Description

@estollnitz

The current type definitions specify that applyToPoint() requires a Point and applyToPoints() requires a Point[]. This is more restrictive than the actual implementations, which also allow [number, number] and [number, number][], respectively.

One way to fix this is to include a union of types in the function signatures, similar to what was done for fromTriangles() here:

export function fromTriangles(t1: Array<Array<number>> | Array<Point>, t2: Array<Array<number>> | Array<Point>): Matrix;

Perhaps a better way would be to change the definition of Point to include object and array forms, if the intention is to support both forms everywhere. I'm suggesting something like this:

  type Point = { x: number; y: number } | [number, number];

The change would go here:

type Point = { x: number; y: number };

If this change is made, the function signature for fromTriangles() can be simplified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions