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

Expose ts types #311

Open
suneab opened this issue Aug 15, 2023 · 0 comments
Open

Expose ts types #311

suneab opened this issue Aug 15, 2023 · 0 comments

Comments

@suneab
Copy link

suneab commented Aug 15, 2023

Would it be possible to expose payload types for sparkplug-payload?
I can make the changes, just wondering if theres a reason why it isn't exposed already.

Currently, the way i work around this is by grabbing the return type of decodePayload, which is a bit silly but works

import { get } from "sparkplug-payload"
const { decodePayload, encodePayload } = get("spBv1.0")!
export type Payload = NonNullable<ReturnType<typeof decodePayload>>
export type Metric = NonNullable<Payload["metrics"]>[0]
export type MetricValue = Metric["value"]
export type DataType = Metric["type"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant