-
Notifications
You must be signed in to change notification settings - Fork 3
feat: improve ApplicationData typization by replacing any types with proper TypeScript types #47
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
base: master
Are you sure you want to change the base?
Conversation
…eScript types Co-authored-by: mandrake-sw <174416152+mandrake-sw@users.noreply.github.com>
Co-authored-by: mandrake-sw <174416152+mandrake-sw@users.noreply.github.com>
Co-authored-by: mandrake-sw <174416152+mandrake-sw@users.noreply.github.com>
Pull Request Test Coverage Report for Build 16070395607Details
💛 - Coveralls |
|
@copilot congrats! Fix lint issues using npm run lint:fix |
|
cc @jacoscaz we are doing some experiments with copilot here :) |
Co-authored-by: mandrake-sw <174416152+mandrake-sw@users.noreply.github.com>
Fixed all lint issues using Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
I am equally terrified and astounded by what is taking place here… Feels like we’re living in sci-fi land. The fact that this is even possible continues to impress me.
I’m on my phone right now and can’t take a deeper look. At first glance, there seems to be a lot of casting via the “as” operator when passing values to encoding functions, which I would not expect given the stronger appdata typization.
I’ll have a deeper look later in the day though, don’t trust me on the above.
|
|
@jacoscaz The result is not good, we have to improve instructions and also prompts by making more detailed instructions and so on but I'm trying it in many other contexts and it's pretty impressive (don't consider this, I wasn't expecting it to do much as the instructions given were too generic). Actually you have to spend lot time making issues super detailed maybe by also use copilot to create those issues in a way that is well digested by copilot agent when doing it's things. It's just the beginning but it's a game changer |
|
Yeah, these are definitely incredibly powerful tools, though I also agree that it’s not as easy to wield them correctly.
I use the Zed editor and its integration with Anthropic’s Claude daily; some of the things I had it do go well past junior-level development.
However, I find it is only truly effective when applied to high-quality codebases with clear and consistent patterns and strong+static typization. It’s dramatically worse when applying it to low-quality codebases and/or codebases making heavy use of reflection and/or dynamic types.
It’s also quite bad when it comes to performance optimizations.
|
|
@jacoscaz agree but looking at the speed they improve I think the best has yet to come, we are just scratching the surface of the real capabilities of this |
This PR improves type safety in the BACnet client library by replacing all
anytypes in theApplicationTagValueTypeMapinterface with proper TypeScript types.Changes Made
Type Improvements
Replaced 17
anytypes inApplicationTagValueTypeMapwith appropriate TypeScript types:ApplicationTag.OCTET_STRING→number[](for octet string data)ApplicationTag.EMPTYLIST→unknown[](empty list/array)ApplicationTag.WEEKNDAY→CalendarWeekDay(existing interface)ApplicationTag.DATERANGE→CalendarDateRange(existing interface)ApplicationTag.DATETIME→Date(combination of date and time)ApplicationTag.ERROR→BACnetError(existing interface)ApplicationTag.OBJECT_PROPERTY_REFERENCE→DeviceObjPropertyRef(existing interface)ApplicationTag.DESTINATION→BACNetAddress(existing interface)ApplicationTag.CALENDAR_ENTRY→Calendar(existing interface)ApplicationTag.READ_ACCESS_SPECIFICATION→ReadAccessSpec(existing interface)ApplicationTag.READ_ACCESS_RESULT→ReadAccessDecode(existing interface)ApplicationTag.CONTEXT_SPECIFIC_ENCODED→number[](encoded data)WEEKLY_SCHEDULE,SPECIAL_EVENT,LIGHTING_COMMAND,CONTEXT_SPECIFIC_DECODED,LOG_RECORD) →unknown(for future incremental typing)Implementation Details
bacappEncodeApplicationDatafunction to handle stricter union typesBACNetTimestamp) to support new typesTagparametersTesting
Example Usage
Design Decision
Following @jacoscaz's suggestion in the issue comments, this implementation:
anytypes with proper TypeScript types for better type safetyunknownfor complex structures that need future typing workRemoving the default generic parameters was tested but would require extensive changes throughout the codebase (~70 compilation errors) and should be done as part of a future major version release.
Fixes #31.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
255.255.255.255If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.