Page 1 of 1

TypeScript support

Posted: Tue Jan 15, 2019 2:32 am
by TorbjornLunde
Like many people I'm using TypeScript for many of my JavaScript-based projects as it provides compile time type checking, better tooling, etc…

While I can certainly use the Phidgets JavaScript library as-is considering that TypeScript is fully compatible with JavaScript. However, it would be really nice to get the usual advantages of TypeScript also when using the Phidgets library.

Are there any plans to add full support for TypeScript?

As far as I know TypeScript support can be added by (1) converting code fully into TypeScript (which compiles to readable JavaScript and can be done gradually), (2) by using type annotations in plain JavaScript or (3) by creating a TypeScript interface definition file (d.ts).

I would really appreciate having TypeScript support when using Phidgets!

In either case, thanks for creating and maintaining this wonderful hardware platform.

Re: TypeScript support

Posted: Mon Apr 13, 2020 2:05 pm
by fast-boy
Could I plus 1 a request for a @types/phidget22 package. It would save a huge amount of development time even for those using js. Thanks!

Re: TypeScript support

Posted: Tue May 05, 2020 4:48 pm
by AdamLee
I ran into this today, and while I fully support types for Phidget22 via DefinitelyTyped, I wound up just doing this to get around compiler errors:

// @ts-ignore
import phidget22 from 'phidget22';

From there I added my own type definition file just to cover the methods I'm using. Not ideal but it gets around errors.