mapbox / earcut

The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
ISC License
2.21k stars 207 forks source link

Typescript or JSDoc #164

Open stefnotch opened 1 year ago

stefnotch commented 1 year ago

I used the excellent earcut library, and it was rock solid.

However, once I started looking into porting it to other languages (e.g. C#), I quickly ran into the issue of "wait, what type does this have"?

For example, what type does list have? https://github.com/mapbox/earcut/blob/afb5797dbf9272661ca4d49ee2e08bd0cd96e1ed/src/earcut.js#L272C30-L272C30 (Spoiler: It's a Node. Not a Node[])

To make porting this library easier, and maybe also to make contributing to this library slightly easier, it would be lovely if we had type annotations.

stefnotch commented 1 year ago

If desired, I'd be happy to make a PR with either Typescript or JSDoc.

surdu commented 9 months ago

You can find the types here

You can add it to your project like this:

npm i --save-dev @types/earcut
stefnotch commented 9 months ago

@surdu Yes, the public API types are available. I'm specifically asking about internal types though.

After all, I did port earcut to C# once, and it took a fair chunk of time to figure out the internal types.

stefnotch commented 9 months ago

@mourner If someone wants to take on this task, do you have any preferences? JSDoc, and keeping the tooling the same?

Or Typescript, and changing the build tooling? I think ideally it'd remain very straightforward, and would support https://github.com/mapbox/earcut/issues/126 ?