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

createEventBuilder input parameter bus has type never #3621

Open
gramliu opened this issue Jan 13, 2024 · 2 comments
Open

createEventBuilder input parameter bus has type never #3621

gramliu opened this issue Jan 13, 2024 · 2 comments

Comments

@gramliu
Copy link

gramliu commented Jan 13, 2024

I'm following the guide for setting up an EventBus, but I'm encountering some typing issues with the createEventBuilder function.

import { createEventBuilder, ZodValidator } from "sst/node/event-bus";

export const event = createEventBuilder({
  bus: "bus",
  validator: ZodValidator
});

In the guide, you specify the required parameter, bus. However, I'm getting an error saying its type is never.

image

I looked at the source and it seems like its type is indeed being assigned to the keys of an empty interface. Is this intentional behavior? I'm also getting the same error with a fresh template created from pnpm create sst test-app

@jayair
Copy link
Contributor

jayair commented Jan 17, 2024

Might've replied to this on Discord. But would appreciate a PR!

@AdditionAddict
Copy link

AdditionAddict commented Jan 18, 2024

Temp workaround:

export const event = createEventBuilder({
  bus: 'bus' as never,
  validator: ZodValidator,
});

Also getting error from default setup pnpm create sst(latest commit fixes)

@jayair To double check, I presume 'bus' must match the 2nd arg of new EventBus(...)?

Given the runtime nature of EventBus, are we happy to type as Bus extends string instead of Bus extends keyof typeof EventBus? Happy to create PR (likely on weekend)

Nvm, running sst build fixes

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

3 participants