-
Notifications
You must be signed in to change notification settings - Fork 73
Closed
Description
As a developer I usually know what the data payload of my cloudevent will be when I get my hands on it. It would be great if I could express this in typescript to enable better type checking and auto completion:
interface MyPayload {
foo: string;
bar: number;
}
const myHandler = (e: CloudEvent<MyPayload>) => {
e.data.foo; // OK
e.data.banana; // Type Error!
};
IMO the existing type hint for the data field is not adding much value:
sdk-javascript/src/event/interfaces.ts
Line 129 in f7b2840
| data?: Record<string, unknown | string | number | boolean> | string | number | boolean | null | unknown; |
This would be better expressed as something like:
export interface CloudEventV1OptionalAttributes<T> {
// ...
data?: T;
}
Metadata
Metadata
Assignees
Labels
No labels