Typescript support
See original GitHub issueHey there, just wanted to preface with the fact that this library is great and very convenient! Thank you!
I’ve been writing some home automation stuff and dabbling in typescript and I’m trying to figure out whether I’m misusing the library. When using the following declaration, I receive the backward compatibility shim warning:
import { HueApi } from 'node-hue-api';
Unfortunately, this is the only way I can seem to use the typed objects that the API provides. In order to avoid the warning, I have to use the require('node-hue-api').v3
declaration, but then I lose all typing and have to treat everything like a generic javascript object.
I believe this might be because the types that I installed via npm install @types/node-hue-api
are outdated. Is this correct, and do you have plans to officially expose the type definitions for v4? It seems that these type definitions are potentially made by third parties, so it’d be understandable if you don’t plan on supporting them.
In any case, thanks again for your efforts in creating this library!
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (12 by maintainers)
Ok, so a first swipe at TypeScript definitions being generated are available from npm in the
@next
tagged version (which is4.0.0-alpha-2
at the time of writing this).Note this version has the upcoming changes to the models and removal of the old v2 API,
Run this to install it into a project.
It required me to make a number of changes so that the generator would work and not complain on multiple runs, and there is some extra JSDoc added to support the generation of the types.
I am not massively keen on adding screeds of JSDoc to the code base, as I am finding it much harder to read the code where I have added it, although I could tweak the IDE settings to tone it down, it still blows up the files making it harder to work on.
I would appreciate any feedback on whether it is usable and what/where you would desire improvements. I am going to take a look at using it from a TypeScript project tomorrow.
Closing this issue as the types are now present in 4.0.0 and if there are other issues, they should be handled in PRs or another issue ticket