oconr / overwatchleague

A Node.JS library for accessing and using the Overwatch League API
https://www.npmjs.com/package/overwatchleague
MIT License
22 stars 2 forks source link

Add typescript types #2

Closed PatrickHollweck closed 5 years ago

PatrickHollweck commented 5 years ago

Hey,

First of all, thanks for this insanely useful library - really helped me a ton already. Since there is no documentation of any kind of abstraction over the raw API is a huge help.

But nonetheless, I still think this library can be improved. A first step would be adding typescript types.

Typescript Types

What are types?

If you are not familiar with it, typescript is a hugely popular language from Microsoft that adds a static type system to javascript. Their compiler uses the information for the type system to do some checks and then compiles the code to javascript.

Benefits

One of the major benefits of typescript is the tight integration with tooling, Editors like vs-code can pick-up on type declaration files - like the one I added here - to give the user of the library completions.

You do not need to write your library in typescript. None of the actual source needs to change. A declaration file is enough.

Who will maintain this declaration?

Since the declaration file needs to be updated every time you change the signature of a function/class this file has to be maintained.

I would volunteer into doing this. Also if there are ever problems with it, Just ping me and I will try to help.

TODO

Example

Here is an example of what this declaration file can do, when you have an editor that supports it. Pretty much every editor worth its salt supports this.

Capture