ekarak / knx

KNXnet/IP protocol implementation for Node(>=6.x)
MIT License
9 stars 4 forks source link

feat: ts rewrite and DPT 22, 28 29, 213, 235, 242, 249, 251, 275, 99, 60001 support #2

Open robertsLando opened 7 months ago

robertsLando commented 7 months ago

Improvements/Fixes:

BREAKING CHANGES

robertsLando commented 7 months ago

TODOs:

ekarak commented 7 months ago

please consider:

ch-zacmo commented 7 months ago

Nice to see that someone want to invest time in knx. I wanted to contribute too since I use it in multiple small and big project. My goal was to add support for knx secure and some features to be able to import the groupAddress for direct DPT mapping, but I didn't have much time recently. Now if the project is going with TS, I will go in my own direction and stay vanilla. I think we need to weigh up whether TS will bring a lot to the table.

robertsLando commented 7 months ago

Now if the project is going with TS, I will go in my own direction and stay vanilla.

Could I ask you why?

robertsLando commented 7 months ago

please consider:

  • ensuring change to TypeScript won't break our dependents: npmjs.com/package/knx?activeTab=dependents
  • bumping up major version. We're basically porting the library to another language.
  • keeping a common text header to all files
  • (I'm sure I'm forgetting something)

@ekarak Sure! I will let you know once I end with this but my idea is to keep it full back compatibile!

ch-zacmo commented 7 months ago

Now if the project is going with TS, I will go in my own direction and stay vanilla.

Could I ask you why?

The benefit vs the work necessary to set up, undertand and maintain typescript project will complicate things for me and my colleague. I already don't have much time to do it in the simple way.

robertsLando commented 7 months ago

The benefit vs the work necessary to set up, undertand and maintain typescript project will complicate things for me and my colleague. I already don't have much time to do it in the simple way.

I can understand but trust me I had your same opinion about TS at start and now I feel so bad when I work with an untyped codebase. Also every time I do a TS refactor I found tons of issues and bugs caused by typos that js simply will never spot.

Could you wait a bit I end with this so I can help you working with the TS codebase? It would be much better and easier to debug...

robertsLando commented 7 months ago

@ekarak the PR is almost done (I only need to add eslint and prettier) I kindly ask you if you can take a look at it and also run the wired tests on your end (I don't have a way to run them)

Now to run them simply use: npm run test:wired

robertsLando commented 7 months ago

@ekarak Why no break on this line? Is this expexted? There is also a comment that doens't makes me feel safe adding it

https://github.com/ekarak/knx/blob/ccda6fe84cfafa1233459d8d63a40c7dbb7634c8/src/FSM.ts#L921-L922

robertsLando commented 7 months ago

Ok I'm done here, please @ekarak make a review when possible :)

The only breaking changes I introduced are:

ch-zacmo commented 7 months ago

Wired test are ok for me. I just did the read storm with 4 as I don't have a bigger actuator.

robertsLando commented 7 months ago

@ch-zacmo Thanks for your feedback! 🙏🏼 Hope @ekarak tests will end well too

ekarak commented 1 month ago

please rebase and test so that we can merge this

TooAngel commented 1 month ago

Just my 5 cent to this PR:

If you want to check it out, I created a commit how this could be done for the connection: https://github.com/TooAngel/knx/commit/a07637a0b942829b95201805ffde12a7d0228966

Some smaller things needs to be done to make the type file really nice, the types.d.ts is autogenerated based on the jsdoc in the Connection.js

robertsLando commented 1 month ago

I have no more time to invest on this, I'm sorry. It took me more then a week to do all this and when I stopped (due to no feedbacks) everything was working flowlessy.

I couldn't agree with any statement against Typescript, nowdays ALL major projects are written in TS and there is a reason if so, you can use JS docs or in line types but that's just a masked Typescript that most people do only because they don't want to learn it (or do such big refactors). I have found many people that were against it then all changed their mind once they started using it

Just by switich to it here I found tons of issues in code and bugs, this is not an opinion but a real fact.

About the code that is different in production: there are source maps that can be used for such purpose, never had any problem with all my projects understanding where the issue is because of TS.

Just to give you an example: I converted to TS also the MQTT.js module (almost 5 milions downloads per month on npm) and before that the project was going to die, now it's back to life as people feel much more confident making changes to code thanks to types

TooAngel commented 1 month ago

Sry, I didn't want to offend someone, just wanted to mention my opinion / give me 5 cent.

In the end it is @ekarak 's decision how to move forward. I just wanted to do a small extension so that I can work better with this library, so I'm fine.

robertsLando commented 1 month ago

@TooAngel Didn't want to be rude anyway with my comment, just wanted to explain my points as well about TS move that I'm pretty sure would be a super nice addition to this project 😄