andreaferretti / paths-js

Generate SVG paths for geometric shapes :bar_chart:
http://andreaferretti.github.io/paths-js-react-demo/
Apache License 2.0
1.72k stars 85 forks source link

Support for Typescript typings #59

Open t-ricci-enhancers opened 4 years ago

t-ricci-enhancers commented 4 years ago

This library doesn't have support for Typescript's type definitions, right?

Is it planned to add those?

I don't see any community-provided typings on DefinitelyTyped

mfirry commented 4 years ago

My two cents:

for a little I bit I enjoyed flow.org and tried to add types (for flow) to paths-js (under a loose supervision from @andreaferretti). Here's what's left https://github.com/mfirry/typed-paths-js

It's definitely doable to add Typescript typing to paths-js and actually somebody started doing it years ago (https://github.com/bdedardel/paths-typescript).

I don't think @andreaferretti is willing to do it, but It shouldn't be so hard and paths-js itself is not going to change that much so.

t-ricci-enhancers commented 4 years ago

I could give a hand in writing typings (I'll also check the flowtypes you posted), but I haven't used the library much and the documentation doesn't seem to be precise about expected types. I'll see what I can do when I have some time... I'm currently working on a fork of a react-native library which uses paths-js, and I'm porting that from JS to TS and that's why I figured the type definitions for paths-js are missing

andreaferretti commented 4 years ago

Hi @t-ricci-enhancers , in fact there are Scala JS bindings here, so the library is fully typed. The type system for Scala JS and Typescript are not the same, but it should be doable to translate from one to another.

the documentation doesn't seem to be precise about expected types

Can you point me to an instance of this? I have tried to be precise about the shape of expected inputs and outputs for all components, but maybe I missed something

t-ricci-enhancers commented 4 years ago

Hi @andreaferretti nothing to be worrying about, I meant to say that the signatures of the methods and properties of the objects returned by functions in the markdown documentation and examples aren't as detailed and precise as TypeScript's type definition would be. That's why I'd like to see type definitions

andreaferretti commented 4 years ago

As I mentioned, I did the work for Scala JS, coming with definitions like this simple one or this more compelx one

You can take inspiration from there (or at least the peace of mind of knowing that the library is fully typed and does not do some strange dynamic metaprogramming trick behind your back). If you want to try writing types, I can give help when you get stuck

t-ricci-enhancers commented 4 years ago

Yes, now I've got plenty of informations from your comments, thank you

mfirry commented 4 years ago

For some (weird) reasons I had completely forgotten about ScalaJS bindings. Happy new year!