delaunator icon indicating copy to clipboard operation
delaunator copied to clipboard

Type definition for Typescript

Open sklay-games opened this issue 8 months ago • 0 comments

Would it be possible to add type definitions to this project so it is easier to import it as a module?

Below is an example that works for me which lets me import Delaunator as a module (import Delaunator from 'delaunator') in a Typescript project. I am not entirely sure if the type definition is 100% accurate though.

File: delaunator.d.ts

declare module 'delaunator' {
    export default class Delaunator<T extends Record<number, number>> {
        triangles: Uint32Array
        halfedges: Int32Array
        hull: Uint32Array
        coords: Float64Array

        constructor(coords: Float64Array);

        static from(points: T[], getX?: (p: T) => number, getY?: (p: T) => number): Delaunator<T>;
    }
}

sklay-games avatar May 29 '25 10:05 sklay-games