rangy-updated icon indicating copy to clipboard operation
rangy-updated copied to clipboard

Create TypeScript definitions

Open pburrows opened this issue 6 years ago • 4 comments

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

pburrows avatar Jan 02 '19 14:01 pburrows

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

shivanikohlii avatar Feb 27 '19 03:02 shivanikohlii

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.

pburrows avatar Feb 28 '19 15:02 pburrows

DefinitelyTyped/DefinitelyTyped#34066

ohze avatar Apr 04 '19 14:04 ohze

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.

pburrows avatar Apr 04 '19 14:04 pburrows