question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript support

See original GitHub issue

Hey 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:closed
  • Created 4 years ago
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
peter-murraycommented, Nov 18, 2019

Ok, so a first swipe at TypeScript definitions being generated are available from npm in the @next tagged version (which is 4.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.

$ npm install node-hue-api@next

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.

0reactions
peter-murraycommented, Dec 29, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript: JavaScript With Syntax For Types.
TypeScript extends JavaScript by adding types to the language. TypeScript speeds up your development experience by catching errors and providing fixes ...
Read more >
TypeScript - Wikipedia
TypeScript supports definition files that can contain type information of existing JavaScript libraries, much like C++ header files can describe the ...
Read more >
Using Vue with TypeScript - Vue.js
Volar is the official VSCode extension that provides TypeScript support inside Vue SFCs, along with many other great features.
Read more >
TypeScript Programming with Visual Studio Code
Visual Studio Code includes TypeScript language support but does not include the TypeScript compiler, tsc . You will need to install the TypeScript...
Read more >
TypeScript Support - Docusaurus
Docusaurus supports writing and using TypeScript theme components. ... a site with full TypeScript support by using the --typescript flag.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found