Azure / Azure/azure-iot-sdk-node
Wrong type definition in the reported properties update function
- Dominant language
- JavaScript
- Stars
- 268
- Forks
- 228
- PR merge metrics
- No merged PRs in 30d
Description
# Context
- **OS and version used:** Debian 12
- **Node.js version:** 24
- **npm version:** not relevant
- **list of installed packages:** not relevant
## Description of the issue
There is a type definition issue inside the twin.ts implementation. I've copied the code sample below from here: https://github.com/Azure/azure-iot-sdk-node/blob/main/device/core/src/twin.ts#L181
1. in my opinion it's weird, that the update function is put onto the reported properties object only if `_clearCachedProperties ` is called
2. the `done` callback function has `err?: null` as parameter, which is passed as argument to `_updateReportedProperties` which has `done: (err?: Error)` in the signature -> **null vs Error type**
3. the update method is completely missing from the type definition, since it is added to the `reported` object at runtime and not before
## Code sample exhibiting the issue
```
private _clearCachedProperties(): void {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;
this.properties = {
reported : {
update : function (state: any, done: (err?: null) => void): void {
self._updateReportedProperties(state, done);
}
},
desired : {
}
};
}
```
```
private _updateReportedProperties(state: any, done: (err?: Error) => void): void {
...
}
```
Contributor guide
Research direction
Start in device/core/src/twin.ts around _clearCachedProperties and _updateReportedProperties, including the reported-properties example at line 181. Trace the reported object’s type and callback signatures; done means the update method is represented in the type definition and its callback is compatible with _updateReportedProperties.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100