peter-murray / node-hue-api

Node.js Library for interacting with the Philips Hue Bridge and Lights
Apache License 2.0
1.19k stars 145 forks source link

Initial Typings commit #85

Closed hansmbakker closed 7 years ago

hansmbakker commented 8 years ago

For a small Typescript project I needed typings for your node module. They were not available yet on http://definitelytyped.org/ or any other repository so I created them myself.

I'd like to share them with you so that others can also use it.

I changed package.json so that the TypeScript compiler should be able to find them according to https://github.com/Microsoft/TypeScript/wiki/Typings-for-npm-packages.

Please note that not all functions are typed yet; this is an initial commit that others can contribute to as well (since this was my first encounter with TypeScript I might have made mistakes or chosen solutions that others might know better ways for).

hansmbakker commented 8 years ago

Maybe @typings could help here - for them it would be interesting to add a popular node Hue library to their registry, and for us node-hue-api users it would be nice to have their expertise!

They propose collaboration and support in https://github.com/typings/typings/issues/322.

peter-murray commented 8 years ago

Wow, a lot of lines of code in there... I need to take a look at this to understand exactly what I consequences there are to me in building/maintaining this.

I have not spent much time with Typescript yet so need to see what this builds like on my MacBook and what extra testing I need to perform for it.

Thanks for the contribution and I hope to come back to you soon.

TwanoO67 commented 8 years ago

Very good idea @wind-rider ! It could be a huge improvement for this API :)

Maybe we could take a look at the project: https://github.com/typings/generator-typings To generate the typings definitions for the missing functions that you haven't defined yet ? Or can you precise what 'parts' still needs to be defined, so we can help complete that :)

hansmbakker commented 8 years ago

Hi,

@peter-murray: the preferred way to go would of course be - converting the whole library to Typescript ;) the output can then still be plain old javascript.

If that's not really what you want, but you want to support others using Typescript, you can maintain these type definitions or you can ask others to do it.

On a Mac both workflows are nicely supported by Visual Studio Code. The advantage of using Typescript is improved code assistance ('Intellisense') and strong type checking. Furthermore it helps you structuring your code.

@TwanoO67: the parts that are still missing are the lines in my commit that are commented out.

fjmorel commented 7 years ago

@wind-rider Could you submit the typings to DefinitelyTyped in the meantime? I'd love to be able to just include @types/node-hue-api in my package.json rather than copy code from a PR.

hansmbakker commented 7 years ago

@fjmorel im currently not able to do PRs (away from computer for some time) but personally I also stopped using this library.

You're free to take my code and push it to definitelytyped though.

fjmorel commented 7 years ago

@wind-rider Submitted this with some additions to the DefinitelyTyped repo: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/12149

fjmorel commented 7 years ago

TypeScript definition file is now published at @types/node-hue-api

hansmbakker commented 7 years ago

@fjmorel thanks for publishing it