-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript support #5322
TypeScript support #5322
Conversation
Although I'm a big fan of TypeScript, I'm still wondering wether it is the correct choice for zigbee-herdsman-converters. The main point is that for adding new devices, people copy code from this repo to their external converters (which cannot support typescript). Thus it will be more complicated to do this, especially if you have no clue about TypeScript/JavaScript. |
I thought so. Personally I'd love to be able to use TS and the advantages it brings, and I've been missing it in the other PRs I created, so I gave it a try. To make new TS-based code copyable, we could commit the compiled JS files as well. That's not pretty but serves this purpose. Alternatively we could ditch the compile step altogether in all Z2M repos (except in CI for validation), publish packages with TS files and migrate to |
These are pretty unreadable, so not good solution IMO.
It's a long time ago that I checked ts-node, although I find using ts-node a bad solution (extra overhead), could we use it for just loading the external converters? If we can maintain |
Since this package targets
The overhead that To keep the current startup performance, we could still transpile all existing code to JS as currently done, and just execute it with Edit: Alternatively, a custom Edit 2: A quick test has shown 95 MB memory use after startup of an empty Z2M instance (Windows, Node 14, dummy COM port) vs. 135 MB (+40 MB) with |
This is definitely an acceptable trade-off. External converters should only be used when adding support for new devices, not long-term (and even then users still can write @nurikk @kirovilya what do you think about this? |
Allow new code in TypeScript while keeping support for all existing JS files. This will help TS-experienced contributors to write code more cleanly and efficiently and allows to smoothly transition existing code to TS over time.
Uses the same TS config as https://github.com/Koenkk/zigbee-herdsman and introduces one breaking change (see
README
for details) that requires updating two imports in Z2M.