pburrows / rangy-updated

A clone of timdown/rangy that accepts additional contributors and pull requests.
MIT License
39 stars 5 forks source link

Create TypeScript definitions #3

Open pburrows opened 5 years ago

pburrows commented 5 years ago

Need to create / add typescript definitions during build (in /lib)

shivanikohlii commented 5 years ago

Could you explain a bit more about what you're looking for via an example, please?

pburrows commented 5 years ago

Currently, to use rangy in a project which uses typescript (such as angular), you need to include the module separately and consume it in code like this:

declare const rangy: any;

This gives you no type information when using it, and you wind up having to depend heavily on the documentation to learn methods.

It would be easy to start from the type definitions created by Rudolph Gottesheim here: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/rangy

These probably cover a good bit of the existing functionality already (though many of the modules are missing).

To get started with this, it makes sense to create a new folder at the root called types and put the existing type definitions from the link above in there. After that we would want to write some tests which used typescript.

ohze commented 5 years ago

DefinitelyTyped/DefinitelyTyped#34066

pburrows commented 5 years ago

Thsi is great @ohze ! If you want to make a PR to add these definitions straight to rangy here, that would be great. Then we wouldn't even need to include @types/rangy to use them (people using the old rangy would still need them, but anyone using rangy-updated would not.