TypeScript support

Supporting Browser-based Javascript and Node.js
Fresh meat
Posts: 1
Joined: Tue Jan 15, 2019 2:13 am

TypeScript support

Postby TorbjornLunde » Tue Jan 15, 2019 2:32 am

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.

Fresh meat
Posts: 1
Joined: Mon Apr 13, 2020 2:01 pm

Re: TypeScript support

Postby fast-boy » Mon Apr 13, 2020 2:05 pm

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!

Posts: 34
Joined: Wed Jul 17, 2019 9:28 am

Re: TypeScript support

Postby AdamLee » Tue May 05, 2020 4:48 pm

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.
Adam Lee
Software Engineer

Return to “Javascript”

Who is online

Users browsing this forum: No registered users and 2 guests