jisotalo / ads-client

Unofficial Node.js ADS library for connecting to Beckhoff TwinCAT automation systems using ADS protocol.
https://jisotalo.fi/ads-client/
MIT License
80 stars 17 forks source link

(v2-dev) Declare `Client` event types #128

Closed crishoj closed 3 months ago

crishoj commented 4 months ago

This no-overhead change adds type information for Client events and handlers.

jisotalo commented 4 months ago

Thanks!

Maybe TypedEmitter should be added manually? Maybe adding a new dependency is not worth it: https://github.com/binier/tiny-typed-emitter/blob/master/lib/index.d.ts

Anyways, this is an excellent idea.

jisotalo commented 3 months ago

This is now implemented in commit https://github.com/jisotalo/ads-client/commit/2865ede260253a33e2a9828dd6b6dc5cb5ef6f13

It seems that nowadays Node.js supports declaring EventHandler types without any special code / library (see https://stackoverflow.com/a/78449821/8140625). However, I didn't manage to get the comments working in VSCode - not sure if there is a way to get them to work.

However, the event types are shown in intellisense as well as event payload types and names :) image image

Implemented in: https://github.com/jisotalo/ads-client/commit/2865ede260253a33e2a9828dd6b6dc5cb5ef6f13#diff-c853099932800d80432ca6685649f9952b446838f16aac7549c8c4e34eae9820

crishoj commented 3 months ago

It seems that nowadays Node.js supports declaring EventHandler types without any special code / library

Even better — TIL !