dbusjs / node-dbus-next

🚌 The next great dbus library for node
https://www.npmjs.com/package/dbus-next
155 stars 52 forks source link

support TypeScript decorators #101

Open mikelpr opened 2 years ago

mikelpr commented 2 years ago

I'm getting these when I try to use the @method({}) decorator:

TypeError: Cannot read properties of undefined (reading 'value')
    at /home/mikel/Workspace/<>/node_modules/dbus-next/lib/service/interface.js:158:40
    at __decorate (/home/mikel/Workspace/<>/node_modules/tslib/tslib.js:99:114)
    at file:///home/mikel/Workspace/<>/dist/index.js:189:1
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

https://github.com/dbusjs/node-dbus-next/blob/b2a6b89e79de423debb4475452db1cc410beab41/lib/service/interface.js#L158

Debugging with vscode shows me that descriptor is my Interface but descriptor.descriptor is undefined so it fails on that descriptor.descriptor.value

mikelpr commented 2 years ago

ok so I see it works if I use js and babel, while it does not work with typescript's decorators. also that the @property decorator doesn't crash on typescript but doesn't show up in D-Feet anyway. so it's a general typescript incompatibility

acrisci commented 2 years ago

https://acrisci.github.io/doc/node-dbus-next/module-interface-Interface.html

use configureMembers(). If there's a way to make the decorators compatible with TypeScript let me know.