Skip to content
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

Create interface that can centrally provide responses for hass.call reponse required calls #66

Open
zoe-codez opened this issue Sep 9, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@zoe-codez
Copy link
Member

zoe-codez commented Sep 9, 2024

🪤 Context

Right now it's only possible to associate types with a service call response manually (per-call), or have it hard coded in type-writer.

It'd be nice if there were an interface that could store these responses, and be friendly towards declaration merging to append to.

declare module "@digital-alchemy/hass" {
  export interface CallServiceResponses {
    "domain.get_data": { ... }
  }
}
hass.call.domain.get_data = function<T = GetResponse<"domain.get_data">>(params): Promise<T> { ... }

This can be coded into type-writer as a pattern. If a response exists in the interface, then use that as a return. Otherwise unknown.

🩻 Additional details

This should be friendly towards the creation of external helper libraries that want to supplement types. Don't want to collect types from every integration as part of this repo. This could let another repo merge the types, and publish that as a package. Someone wanting to use them can do

main.ts

import "@cool-person/helper-types";

// helpers available anywhere in project now

Might require some tweaks to the proposed types workflow above, want a minimum number of helper types

@zoe-codez zoe-codez added the enhancement New feature or request label Sep 9, 2024
@zoe-codez
Copy link
Member Author

Follow up to #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant