Skip to content

feat: allow augmenting event types#1784

Merged
oliverlaz merged 1 commit into
masterfrom
feat/event-type-augmentation
Jun 23, 2026
Merged

feat: allow augmenting event types#1784
oliverlaz merged 1 commit into
masterfrom
feat/event-type-augmentation

Conversation

@myandrienko

Copy link
Copy Markdown
Contributor

CLA

  • I have signed the Stream CLA (required).
  • Code changes are tested

Description of the changes, What, Why and How?

Adds a new exported interface CustomEventTypes. It should be a map where keys are custom event type strings. That allows augmenting SDK's EventTypes union with more types:

import { StreamChat, type EventTypes } from "stream-chat";

declare module "stream-chat" {
  interface CustomEventTypes {
    "custom.event": true;
  }
}

type R = "custom.event" extends EventTypes ? "yes" : "no"; // --> "yes"
new StreamChat("...").channel("...").sendEvent({
  type: "custom.event", // --> allowed
});

Useful in combination with CustomEventData.

Nice next step, but out of scope for this PR, is strongly typing event data based on event type - both for internal and custom events.

@github-actions

Copy link
Copy Markdown
Contributor

Size Change: 0 B

Total Size: 408 kB

ℹ️ View Unchanged
Filename Size
dist/cjs/index.browser.js 136 kB
dist/cjs/index.node.js 137 kB
dist/esm/index.mjs 135 kB

compressed-size-action

@isekovanic isekovanic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Matvei !

@arnautov-anton this might be relevant for you I believe and the work with OpenAPI.

Nice next step, but out of scope for this PR, is strongly typing event data based on event type - both for internal and custom events.

This is something that'll come in the next major (~October) given our OpenAPI integration. To do it now is unfortunately breaking for types. But hold on a bit longer !

@oliverlaz oliverlaz merged commit c32f7e9 into master Jun 23, 2026
6 of 8 checks passed
@oliverlaz oliverlaz deleted the feat/event-type-augmentation branch June 23, 2026 10:32
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

Successfully merging this pull request may close these issues.

3 participants