lifx-http-api icon indicating copy to clipboard operation
lifx-http-api copied to clipboard

✨🔧📝 Adding Typescript definition files

Open dudeofawesome opened this issue 8 years ago • 5 comments

This way, the package can be used in Typescript projects.

It also should add Intellisense support for VSCode in JS or TS.

dudeofawesome avatar Jan 18 '17 20:01 dudeofawesome

Thanks for another contribution @dudeofawesome. I'll check out the PR in a few and let you know what I'm thinking about it but it looks good so far.

klarstil avatar Jan 21 '17 11:01 klarstil

Hey, what's the status on this?

dudeofawesome avatar Mar 17 '17 17:03 dudeofawesome

Understood that. What about all the other interfaces you included? They're inaccessible from a void.

On Mar 18, 2017, 4:17 AM -0700, Louis Orleans [email protected], wrote:

@dudeofawesome commented on this pull request.

In dist/lifx.d.ts (https://github.com/klarstil/lifx-http-api/pull/3#discussion_r106778825):

@@ -0,0 +1,8 @@ +declare module 'lifx-http-api' { + interface ILifxOptions { + bearerToken: string; + } + + const LifxHTTPAPI: (options: ILifxOptions) => void;

The goal of this file is to allow for

const lifx = require('lifx-http-api'); new lifx({ … });

The return type of a constructor must be void in TypeScript

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub (https://github.com/klarstil/lifx-http-api/pull/3#discussion_r106778825), or mute the thread (https://github.com/notifications/unsubscribe-auth/AAONwJ5ZLCVPXJ0D883ommrMMetKT-Foks5rm71KgaJpZM4LnXFt).

jspiro avatar Mar 18 '17 20:03 jspiro

For an example of how this works, you can check out my Travis CI build light project: https://github.com/dudeofawesome/ci-stoplight

I create a new LifxClient here, which is then injected in to my LifxController class here, and later used in a few places within that class, including here.

The constructor method of a class always has a return type of void.

When you say you don't see any hinting, do you mean that you've attempted to use, but when you instantiate a new instance, the type returned is any?

dudeofawesome avatar Mar 19 '17 03:03 dudeofawesome

@klarstil What's the status of this?

dudeofawesome avatar Apr 14 '17 01:04 dudeofawesome