fix: Type issue for non-default DeviceCommandHandlers #256
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is a type issue with
deviceCommand()callback's type, impacting the usage ofsmartApp.deviceCommand()in TypeScript.deviceCommand()defines a callback with acommandparameter of typeDeviceCommand. This is incorrect, asDeviceCommandhas acomponentattribute, instead ofcomponentIdattribute as obtained from the APIs.Default
deviceCommandHandler()is not impacted, as it uses the interfaceDeviceCommandsEvent, itself using the correct typeDeviceCommandsEventCommand.This is becoming a mouthful. Here are the current classes :
Incorrect for
deviceCommand()https://github.com/SmartThingsCommunity/smartthings-core-sdk/blob/bdd6bcc59044daef46725524e7fb3234d4cc0c1a/src/endpoint/rules.ts#L185-L191
Correct for
deviceCommand()smartapp-sdk-nodejs/lib/lifecycle-events.d.ts
Lines 192 to 197 in 3725c0f
Note that this PR is marked as incomplete, as this
DeviceCommandsEventCommandis difficult to import for external projects. I would leave that decision to you in order to export or create an interface.Types of changes