-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Allow plugins to properly type platform config during registration #3609
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
Allow plugins to properly type platform config during registration #3609
Conversation
Pull Request Test Coverage Report for Build 9670740845Details
💛 - Coveralls |
Hi @duddu Would you be able to resolve the conflicts on the docs/ files, perhaps remove the changes to these files from your branch, are they necessary to be regenerated as part of your changes? |
99907df
to
ae59f9f
Compare
thanks @bwp91, rebased from homebridge/latest and re-generated docs. |
ae59f9f
to
b6b24bd
Compare
@donavanbecker can we merge this into a beta? |
## v1.8.4 (2024-07-19) ### Fixed - Fix default FirmwareRevision (#3644) (@hjdhjd) ### Changed - Detect config interface on registerPlatform (#3609) (@duddu) - Updated dependencies, fix `typedoc` generation - Added log messaging about upcoming Homebridge v2.0.0 update - NOTICE TO USERS AND PLUGIN DEVELOPERS - Homebridge 2.0 is on the way and brings some breaking changes to existing plugins. - Please visit the following link to learn more about the changes and how to prepare: - [Updating-To-Homebridge-v2.0](https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0)
- Fix default FirmwareRevision (#3644) (@hjdhjd) - Detect config interface on registerPlatform (#3609) (@duddu) - Updated dependencies, fix `typedoc` generation - Added log messaging about upcoming Homebridge v2.0.0 update - NOTICE TO USERS AND PLUGIN DEVELOPERS - Homebridge 2.0 is on the way and brings some breaking changes to existing plugins. - Please visit the following link to learn more about the changes and how to prepare: - [Updating-To-Homebridge-v2.0](https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0)
- Fix default FirmwareRevision (#3644) (@hjdhjd) - Detect config interface on registerPlatform (#3609) (@duddu) - Updated dependencies, fix `typedoc` generation - Added log messaging about upcoming Homebridge v2.0.0 update - NOTICE TO USERS AND PLUGIN DEVELOPERS - Homebridge 2.0 is on the way and brings some breaking changes to existing plugins. - Please visit the following link to learn more about the changes and how to prepare: - [Updating-To-Homebridge-v2.0](https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0)
- Fix default FirmwareRevision (#3644) (@hjdhjd) - Detect config interface on registerPlatform (#3609) (@duddu) - Updated dependencies, fix `typedoc` generation - Added log messaging about upcoming Homebridge v2.0.0 update - NOTICE TO USERS AND PLUGIN DEVELOPERS - Homebridge 2.0 is on the way and brings some breaking changes to existing plugins. - Please visit the following link to learn more about the changes and how to prepare: - [Updating-To-Homebridge-v2.0](https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0) Revert "v1.8.4" This reverts commit bfd209f. v1.8.4 - Fix default FirmwareRevision (#3644) (@hjdhjd) - Detect config interface on registerPlatform (#3609) (@duddu) - Updated dependencies, fix `typedoc` generation - Added log messaging about upcoming Homebridge v2.0.0 update - NOTICE TO USERS AND PLUGIN DEVELOPERS - Homebridge 2.0 is on the way and brings some breaking changes to existing plugins. - Please visit the following link to learn more about the changes and how to prepare: - [Updating-To-Homebridge-v2.0](https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0)
- Fix default FirmwareRevision (#3644) (@hjdhjd) - Detect config interface on registerPlatform (#3609) (@duddu) - Updated dependencies, fix `typedoc` generation - Added log messaging about upcoming Homebridge v2.0.0 update - NOTICE TO USERS AND PLUGIN DEVELOPERS - Homebridge 2.0 is on the way and brings some breaking changes to existing plugins. - Please visit the following link to learn more about the changes and how to prepare: - [Updating-To-Homebridge-v2.0](https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0)
- Fix default FirmwareRevision (#3644) (@hjdhjd) - Detect config interface on registerPlatform (#3609) (@duddu) - Updated dependencies, fix `typedoc` generation - Added log messaging about upcoming Homebridge v2.0.0 update - NOTICE TO USERS AND PLUGIN DEVELOPERS - Homebridge 2.0 is on the way and brings some breaking changes to existing plugins. - Please visit the following link to learn more about the changes and how to prepare: - [Updating-To-Homebridge-v2.0](https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0)
- Fix default FirmwareRevision (#3644) (@hjdhjd) - Detect config interface on registerPlatform (#3609) (@duddu) - Updated dependencies, fix `typedoc` generation - Added log messaging about upcoming Homebridge v2.0.0 update - NOTICE TO USERS AND PLUGIN DEVELOPERS - Homebridge 2.0 is on the way and brings some breaking changes to existing plugins. - Please visit the following link to learn more about the changes and how to prepare: - [Updating-To-Homebridge-v2.0](https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0)
- Fix default FirmwareRevision (#3644) (@hjdhjd) - Detect config interface on registerPlatform (#3609) (@duddu) - Updated dependencies, fix `typedoc` generation - Added log messaging about upcoming Homebridge v2.0.0 update - NOTICE TO USERS AND PLUGIN DEVELOPERS - Homebridge 2.0 is on the way and brings some breaking changes to existing plugins. - Please visit the following link to learn more about the changes and how to prepare: - [Updating-To-Homebridge-v2](https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2)
- Fix default FirmwareRevision (#3644) (@hjdhjd) - Detect config interface on registerPlatform (#3609) (@duddu) - Updated dependencies, fix `typedoc` generation - Added log messaging about upcoming Homebridge v2.0.0 update - NOTICE TO USERS AND PLUGIN DEVELOPERS - Homebridge 2.0 is on the way and brings some breaking changes to existing plugins. - Please visit the following link to learn more about the changes and how to prepare: - [Updating-To-Homebridge-v2.0](https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0)
♻️ Current situation
Currently if a plugin developer wants to strongly type their own plugin configuration interface (e.g. extending
PlatformConfig
and thus having config fields type checking throughout all plugin code), they would be somehow blocked once they invokeapi.registerPlatform
to register the platform, sincePlatformPluginConstructor.new
has the argumentconfig
typed asPlatformConfig
. A brief snippet to exemplify the scenario:💡 Proposed solution
An easy solution is to update the
PlatformPluginConstructor
interface by adding a generic that allows to auto-detect the type ofconfig
argument of thenew
method:With this change the same snippet above will work fine - example from vscode:

➕ Additional Information
I think this is a useful change because it encourages plugin developers to strongly type their config (extending
PlatformConfig
), and allows to use everywhere a single config interface (i.e. when cascading down config from platform instance).